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,1723 @@
|
|
|
1
|
+
//#region src/model.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Every public type in this module is JSON-serialisable except `Date`, which
|
|
4
|
+
* serialises to an ISO 8601 string through `JSON.stringify`, and the bytes of
|
|
5
|
+
* a binary {@link FileContent}. `raw` and `payload` fields hold the forge's
|
|
6
|
+
* own JSON.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Identifier of a forge implementation. Unknown forges are permitted so that
|
|
10
|
+
* third-party providers can be registered without a core release.
|
|
11
|
+
*/
|
|
12
|
+
type ForgeKind = KnownForgeKind | (string & {});
|
|
13
|
+
/** The forges this package ships providers for. */
|
|
14
|
+
type KnownForgeKind = "github" | "gitlab" | "bitbucket" | "forgejo" | "gitea" | "tangled" | "gitee" | "azure-devops" | "cursor-origin" | "pushin";
|
|
15
|
+
/**
|
|
16
|
+
* Capability flag. Every value other than `false` means the operation is
|
|
17
|
+
* available:
|
|
18
|
+
*
|
|
19
|
+
* - `true`: native, and verified against the forge's responses.
|
|
20
|
+
* - `'experimental'`: native and verified, but built on an API the forge marks
|
|
21
|
+
* unstable, so it can change.
|
|
22
|
+
* - `'emulated'`: composed from other calls, so the result is approximate.
|
|
23
|
+
* - `'unverified'`: implemented, but not yet verified against the forge's
|
|
24
|
+
* responses, so it may not work.
|
|
25
|
+
*/
|
|
26
|
+
type Support = boolean | "emulated" | "experimental" | "unverified";
|
|
27
|
+
/** Host of a single forge deployment, for example `github.com` or `codeberg.org`. */
|
|
28
|
+
type ForgeInstance = string;
|
|
29
|
+
/** Where an object comes from: the forge and the instance of that forge. */
|
|
30
|
+
interface ForgeOrigin {
|
|
31
|
+
forge: ForgeKind;
|
|
32
|
+
/** The host of the instance, such as `github.com` or `git.example.com`. */
|
|
33
|
+
instance: ForgeInstance;
|
|
34
|
+
}
|
|
35
|
+
/** Addresses a repository by its forge, instance, owner and name. */
|
|
36
|
+
interface RepoRef extends ForgeOrigin {
|
|
37
|
+
/**
|
|
38
|
+
* Full namespace path. On forges with nested groups (GitLab) this contains
|
|
39
|
+
* slashes, for example `acme/platform`; `name` never does.
|
|
40
|
+
*/
|
|
41
|
+
owner: string;
|
|
42
|
+
/** Repository name. Empty for namespace-scoped refs. */
|
|
43
|
+
name: string;
|
|
44
|
+
/**
|
|
45
|
+
* `'namespace'` for subjects that belong to a group rather than a repository
|
|
46
|
+
* (GitLab epics). Absent means a repository.
|
|
47
|
+
*/
|
|
48
|
+
kind?: "repo" | "namespace";
|
|
49
|
+
/**
|
|
50
|
+
* Stable forge-native identifier that survives renames and transfers: a
|
|
51
|
+
* GitHub, Forgejo or Gitea numeric id, a GitLab project or group id, a
|
|
52
|
+
* Bitbucket UUID or a Tangled repo DID. {@link repoKey} prefers it over
|
|
53
|
+
* `owner` and `name`.
|
|
54
|
+
*/
|
|
55
|
+
externalId?: string;
|
|
56
|
+
}
|
|
57
|
+
/** Who can see a repository. */
|
|
58
|
+
type RepoVisibility = "public" | "private" | "internal";
|
|
59
|
+
/** The authenticated account's access to a repository. */
|
|
60
|
+
interface RepoPermissions {
|
|
61
|
+
/** Full administrative access. */
|
|
62
|
+
admin: boolean;
|
|
63
|
+
/** Manage the repository without access to sensitive or destructive settings. */
|
|
64
|
+
maintain: boolean;
|
|
65
|
+
push: boolean;
|
|
66
|
+
/** Manage issues and pull requests without write access. */
|
|
67
|
+
triage: boolean;
|
|
68
|
+
/** Read and clone the repository. */
|
|
69
|
+
pull: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** Which subjects a repository has switched on, where the forge makes them per repository. */
|
|
72
|
+
interface RepoFeatures {
|
|
73
|
+
issues: boolean;
|
|
74
|
+
pullRequests: boolean;
|
|
75
|
+
discussions: boolean;
|
|
76
|
+
wiki: boolean;
|
|
77
|
+
projects: boolean;
|
|
78
|
+
releases: boolean;
|
|
79
|
+
}
|
|
80
|
+
/** A collaborator's role, highest first. `'none'` is an explicit absence of access. */
|
|
81
|
+
type RepoRole = "admin" | "maintain" | "write" | "triage" | "read" | "none";
|
|
82
|
+
/** An account with a role on a repository. */
|
|
83
|
+
interface Collaborator {
|
|
84
|
+
actor: Actor;
|
|
85
|
+
role: RepoRole;
|
|
86
|
+
/** Forge-native role name, for example `maintainer` or `reporter`. */
|
|
87
|
+
roleRaw?: string;
|
|
88
|
+
/** What the role allows. */
|
|
89
|
+
permissions?: RepoPermissions;
|
|
90
|
+
raw: unknown;
|
|
91
|
+
}
|
|
92
|
+
/** A repository as every forge reports it. Fields that not every forge has, such as `openPullCount`, are optional. */
|
|
93
|
+
interface Repo {
|
|
94
|
+
ref: RepoRef;
|
|
95
|
+
/** The repository's name where `ref.name` is an identifier rather than the name (a Tangled record key). */
|
|
96
|
+
displayName?: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
defaultBranch?: string;
|
|
99
|
+
/** Who can see the repository. */
|
|
100
|
+
visibility: RepoVisibility;
|
|
101
|
+
visibilityRaw?: string;
|
|
102
|
+
isFork: boolean;
|
|
103
|
+
/** The repository is archived and read-only. */
|
|
104
|
+
isArchived: boolean;
|
|
105
|
+
/** The repository that this one was forked from. */
|
|
106
|
+
parent?: RepoRef;
|
|
107
|
+
/** Topics, also called tags, that describe the repository. */
|
|
108
|
+
topics: string[];
|
|
109
|
+
url?: string;
|
|
110
|
+
/** Git remotes. Tangled maps the hosting knot to its SSH host. */
|
|
111
|
+
cloneUrls?: {
|
|
112
|
+
https?: string;
|
|
113
|
+
ssh?: string;
|
|
114
|
+
};
|
|
115
|
+
createdAt?: Date;
|
|
116
|
+
updatedAt?: Date;
|
|
117
|
+
/** Last push, where the listing endpoint reports it. */
|
|
118
|
+
pushedAt?: Date;
|
|
119
|
+
/**
|
|
120
|
+
* Open issues only, never combined with pull requests. Absent where the
|
|
121
|
+
* forge reports only the combined count (GitHub).
|
|
122
|
+
*/
|
|
123
|
+
openIssueCount?: number;
|
|
124
|
+
/** The number of open pull requests, where the forge reports it. */
|
|
125
|
+
openPullCount?: number;
|
|
126
|
+
/** The account or organisation that owns the repository, where the forge reports one. */
|
|
127
|
+
owner?: Actor;
|
|
128
|
+
/** Primary language, as the forge detects it. */
|
|
129
|
+
language?: string;
|
|
130
|
+
/** Project website, apart from the repository's own `url`. */
|
|
131
|
+
homepage?: string;
|
|
132
|
+
/**
|
|
133
|
+
* SPDX identifier of the licence the forge detects, for example `MIT`. SPDX identifiers are case-insensitive, and
|
|
134
|
+
* GitLab reports them in lower case, such as `mit`.
|
|
135
|
+
*/
|
|
136
|
+
licence?: string;
|
|
137
|
+
stars?: number;
|
|
138
|
+
forks?: number;
|
|
139
|
+
/** Accounts watching the repository's activity, apart from stars. */
|
|
140
|
+
watchers?: number;
|
|
141
|
+
/** What the authenticated account may do. */
|
|
142
|
+
permissions?: RepoPermissions;
|
|
143
|
+
/** Merge methods the repository allows, where the forge reports them. Empty means the forge reported none. */
|
|
144
|
+
mergeMethods?: MergeMethod[];
|
|
145
|
+
features?: RepoFeatures;
|
|
146
|
+
raw: unknown;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Kind of thread. `'other'` holds forge-specific subjects with no shared kind
|
|
150
|
+
* (check suites, epics); `ThreadRef.typeRaw` names them.
|
|
151
|
+
*/
|
|
152
|
+
type ThreadKind = "issue" | "pull_request" | "discussion" | "commit" | "other";
|
|
153
|
+
/**
|
|
154
|
+
* Reference to a thread. A thread `number` is unique only within its repo, so
|
|
155
|
+
* the repo is always carried alongside it.
|
|
156
|
+
*/
|
|
157
|
+
interface ThreadRef extends ForgeOrigin {
|
|
158
|
+
repo: RepoRef;
|
|
159
|
+
kind: ThreadKind;
|
|
160
|
+
/** Forge-native subject type, for example `PullRequest` or `MergeRequest`. */
|
|
161
|
+
typeRaw?: string;
|
|
162
|
+
/**
|
|
163
|
+
* Per-repo thread number, the commit sha for `kind: 'commit'`, or the
|
|
164
|
+
* forge-native id for `kind: 'other'`. Absent when the forge did not
|
|
165
|
+
* identify the thread; such a ref cannot be fetched or keyed until enriched.
|
|
166
|
+
*/
|
|
167
|
+
number?: string;
|
|
168
|
+
/**
|
|
169
|
+
* Human-facing per-repo number, when it differs from `number`. Tangled
|
|
170
|
+
* identifies threads by AT-URI but shows numbers in its UI and webhooks.
|
|
171
|
+
*/
|
|
172
|
+
displayNumber?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Globally unique forge-native identifier, where one exists: a GitHub
|
|
175
|
+
* `node_id`, a GitLab global id, or an atproto record URI.
|
|
176
|
+
*/
|
|
177
|
+
externalId?: string;
|
|
178
|
+
}
|
|
179
|
+
/** A release, as a notification subject or event target. */
|
|
180
|
+
interface ReleaseRef extends ForgeOrigin {
|
|
181
|
+
repo: RepoRef;
|
|
182
|
+
/** Forge-native release id; the tag name on forges that key releases by tag. */
|
|
183
|
+
id: string;
|
|
184
|
+
tag?: string;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Reference to a registered webhook. `target` is the repository, or a
|
|
188
|
+
* namespace ref (`kind: 'namespace'`, empty `name`) for an organisation or
|
|
189
|
+
* workspace hook.
|
|
190
|
+
*/
|
|
191
|
+
interface WebhookRef extends ForgeOrigin {
|
|
192
|
+
/** The repository or namespace that the hook is registered on. */
|
|
193
|
+
target: RepoRef;
|
|
194
|
+
/** Forge-native hook id. */
|
|
195
|
+
id: string;
|
|
196
|
+
}
|
|
197
|
+
/** Reference to one delivery of a webhook. */
|
|
198
|
+
interface WebhookDeliveryRef extends ForgeOrigin {
|
|
199
|
+
hook: WebhookRef;
|
|
200
|
+
id: string;
|
|
201
|
+
/** Delivery guid, where the forge needs it to redeliver. */
|
|
202
|
+
guid?: string;
|
|
203
|
+
}
|
|
204
|
+
/** A normalised event a provider can deliver, optionally narrowed to one action. */
|
|
205
|
+
interface WebhookEventType {
|
|
206
|
+
kind: EventKind;
|
|
207
|
+
action?: EventAction;
|
|
208
|
+
}
|
|
209
|
+
/** A registered webhook. The secret is never readable, so it is never returned. */
|
|
210
|
+
interface Webhook {
|
|
211
|
+
ref: WebhookRef;
|
|
212
|
+
url: string;
|
|
213
|
+
/** Normalised kinds the subscription covers, derived from `nativeEvents`. */
|
|
214
|
+
events: EventKind[];
|
|
215
|
+
/** Forge-native event names exactly as the forge stores them. */
|
|
216
|
+
nativeEvents: string[];
|
|
217
|
+
active: boolean;
|
|
218
|
+
/** `'json'` or `'form'` where the forge offers a choice. */
|
|
219
|
+
contentType?: "json" | "form";
|
|
220
|
+
createdAt?: Date;
|
|
221
|
+
updatedAt?: Date;
|
|
222
|
+
/** Never returned: no forge reads a webhook secret back. */
|
|
223
|
+
secret?: never;
|
|
224
|
+
raw: unknown;
|
|
225
|
+
}
|
|
226
|
+
/** What `webhooks.create()` needs to register a hook. */
|
|
227
|
+
interface WebhookInput {
|
|
228
|
+
url: string;
|
|
229
|
+
/** Normalised kinds, translated to the forge's own event names. */
|
|
230
|
+
events?: EventKind[];
|
|
231
|
+
/** Forge-native event names, sent as given and merged with the translation of `events`. */
|
|
232
|
+
nativeEvents?: string[];
|
|
233
|
+
/** The secret that signs the deliveries. */
|
|
234
|
+
secret?: string;
|
|
235
|
+
/** How to encode the delivery body. */
|
|
236
|
+
contentType?: "json" | "form";
|
|
237
|
+
/**
|
|
238
|
+
* @default true
|
|
239
|
+
*/
|
|
240
|
+
active?: boolean;
|
|
241
|
+
}
|
|
242
|
+
/** A change to a registered webhook. Fields left out are left as they are. */
|
|
243
|
+
type WebhookUpdate = Partial<WebhookInput>;
|
|
244
|
+
/** One recorded delivery attempt. */
|
|
245
|
+
interface WebhookDeliveryRecord {
|
|
246
|
+
ref: WebhookDeliveryRef;
|
|
247
|
+
/** Forge-native event name of the delivery. */
|
|
248
|
+
event: string;
|
|
249
|
+
/** The HTTP status that the receiver answered with. */
|
|
250
|
+
status: number;
|
|
251
|
+
/** `true` when the forge considered the delivery successful. */
|
|
252
|
+
ok: boolean;
|
|
253
|
+
deliveredAt?: Date;
|
|
254
|
+
/** Round trip in milliseconds, where the forge reports it. */
|
|
255
|
+
duration?: number;
|
|
256
|
+
raw: unknown;
|
|
257
|
+
}
|
|
258
|
+
/** What an alert is about. `other` is a kind that the model does not name. */
|
|
259
|
+
type SecurityAlertKind = "dependency" | "code_scanning" | "secret" | "advisory" | "other";
|
|
260
|
+
/** A security alert: a vulnerable dependency, a code scanning result, a leaked secret or an advisory. */
|
|
261
|
+
interface SecurityAlertRef extends ForgeOrigin {
|
|
262
|
+
repo: RepoRef;
|
|
263
|
+
/** Forge-native alert id. GitHub numbers each alert kind separately, so `kind` is needed to address one. */
|
|
264
|
+
id: string;
|
|
265
|
+
kind?: SecurityAlertKind;
|
|
266
|
+
severityRaw?: string;
|
|
267
|
+
}
|
|
268
|
+
/** One check run, commit status or CI job. */
|
|
269
|
+
interface CheckRef extends ForgeOrigin {
|
|
270
|
+
repo: RepoRef;
|
|
271
|
+
id: string;
|
|
272
|
+
/** What the id addresses: a check run, a commit status, a CI job, or a branch policy evaluation. */
|
|
273
|
+
type: "check_run" | "status" | "job" | "policy";
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Reference to a notification. Distinct from {@link ThreadRef}: a notification
|
|
277
|
+
* is a per-user delivery record whose lifetime and identity are independent of
|
|
278
|
+
* the thread it points at.
|
|
279
|
+
*/
|
|
280
|
+
interface NotificationRef extends ForgeOrigin {
|
|
281
|
+
/** Forge-native notification identifier, used for read/done/unsubscribe writes. */
|
|
282
|
+
id: string;
|
|
283
|
+
}
|
|
284
|
+
/** An account: a user, an organisation or a bot. */
|
|
285
|
+
interface Actor extends ForgeOrigin {
|
|
286
|
+
login: string;
|
|
287
|
+
id: string;
|
|
288
|
+
name?: string;
|
|
289
|
+
avatarUrl?: string;
|
|
290
|
+
url?: string;
|
|
291
|
+
/** Forge-reported account type, retained verbatim for callers that classify further. */
|
|
292
|
+
typeRaw?: string;
|
|
293
|
+
/**
|
|
294
|
+
* Hint derived from forge metadata that the actor is automation. Callers own
|
|
295
|
+
* the classification policy.
|
|
296
|
+
*/
|
|
297
|
+
isBotHint: boolean;
|
|
298
|
+
/** The app behind a bot account, where the forge ties one to it (GitHub Apps' `slug[bot]` users). */
|
|
299
|
+
app?: {
|
|
300
|
+
slug: string;
|
|
301
|
+
id?: string;
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
/** A user or organisation account, as `users.get()` reads it. */
|
|
305
|
+
interface User extends Actor {
|
|
306
|
+
bio?: string;
|
|
307
|
+
company?: string;
|
|
308
|
+
location?: string;
|
|
309
|
+
websiteUrl?: string;
|
|
310
|
+
createdAt?: Date;
|
|
311
|
+
followers?: number;
|
|
312
|
+
following?: number;
|
|
313
|
+
publicRepos?: number;
|
|
314
|
+
raw: unknown;
|
|
315
|
+
}
|
|
316
|
+
/** A label that a repository defines. */
|
|
317
|
+
interface Label {
|
|
318
|
+
name: string;
|
|
319
|
+
/** The colour as hex digits, without a leading `#`. */
|
|
320
|
+
colour?: string;
|
|
321
|
+
description?: string;
|
|
322
|
+
}
|
|
323
|
+
/** What a label is created or updated with. */
|
|
324
|
+
interface LabelInput {
|
|
325
|
+
name: string;
|
|
326
|
+
/** Six-digit hex, without the leading `#`. */
|
|
327
|
+
colour?: string;
|
|
328
|
+
description?: string;
|
|
329
|
+
}
|
|
330
|
+
/** Every name {@link ReactionContent} covers. */
|
|
331
|
+
declare const REACTION_CONTENTS: readonly ["+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", "eyes"];
|
|
332
|
+
/**
|
|
333
|
+
* The reactions every forge with reactions has in common, named as GitHub
|
|
334
|
+
* names them. A {@link Reaction} whose forge-native name has no entry here
|
|
335
|
+
* has `content: 'other'`, with the forge-native name in `contentRaw`.
|
|
336
|
+
*/
|
|
337
|
+
type ReactionContent = (typeof REACTION_CONTENTS)[number];
|
|
338
|
+
/** The normalised name for a forge-native reaction name, or `'other'` where there is none. */
|
|
339
|
+
declare function reactionContent(raw: string): ReactionContent | "other";
|
|
340
|
+
/** One reaction left on a thread or a comment, as `threads.reactions()` lists them. */
|
|
341
|
+
interface Reaction {
|
|
342
|
+
/** `'other'` where the forge's name has no entry in {@link ReactionContent}. */
|
|
343
|
+
content: ReactionContent | "other";
|
|
344
|
+
/** The forge's own name for the reaction, such as a GitLab award emoji or a Forgejo emoji. */
|
|
345
|
+
contentRaw: string;
|
|
346
|
+
actor: Actor;
|
|
347
|
+
createdAt?: Date;
|
|
348
|
+
raw: unknown;
|
|
349
|
+
}
|
|
350
|
+
/** The reactions on a thread or comment, counted. */
|
|
351
|
+
interface ReactionSummary {
|
|
352
|
+
/** The number of reactions of every kind. */
|
|
353
|
+
total: number;
|
|
354
|
+
/** The number of reactions of each kind. A reaction with no {@link ReactionContent} entry has no key here. */
|
|
355
|
+
counts: Partial<Record<ReactionContent, number>>;
|
|
356
|
+
/** Reactions the authenticated account has left. Absent when the forge does not report them. */
|
|
357
|
+
viewerReacted?: ReactionContent[];
|
|
358
|
+
}
|
|
359
|
+
/** A milestone that groups threads. */
|
|
360
|
+
interface Milestone {
|
|
361
|
+
/** Forge-native milestone id, as `threads.setMilestone` takes it. */
|
|
362
|
+
id: string;
|
|
363
|
+
title: string;
|
|
364
|
+
state: "open" | "closed";
|
|
365
|
+
description?: string;
|
|
366
|
+
dueOn?: Date;
|
|
367
|
+
url?: string;
|
|
368
|
+
raw: unknown;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Thread state. `'unknown'` is distinct from any real state and signals that
|
|
372
|
+
* the value was not present in the payload, so the caller may enrich it with
|
|
373
|
+
* `threads.get()`. Draft status is orthogonal; see `Thread.isDraft`.
|
|
374
|
+
*/
|
|
375
|
+
type ThreadState = "open" | "closed" | "merged" | "unknown";
|
|
376
|
+
/** What a review or a reviewer says about a pull request. `unknown` is a state that the model does not name. */
|
|
377
|
+
type ReviewState = "approved" | "changes_requested" | "commented" | "pending" | "dismissed" | "unknown";
|
|
378
|
+
/** Reference to a review on a pull request. */
|
|
379
|
+
interface ReviewRef extends ForgeOrigin {
|
|
380
|
+
thread: ThreadRef;
|
|
381
|
+
/** Forge-native review id; a synthesised `approval:<login>` where the forge has approvals but no review objects. */
|
|
382
|
+
id: string;
|
|
383
|
+
}
|
|
384
|
+
/** A comment left on a line of the diff as part of a review. */
|
|
385
|
+
interface ReviewComment {
|
|
386
|
+
ref?: CommentRef;
|
|
387
|
+
body: string;
|
|
388
|
+
author?: Actor;
|
|
389
|
+
path?: string;
|
|
390
|
+
/** Line in the file the comment is anchored to, in the side it is anchored to. */
|
|
391
|
+
line?: number;
|
|
392
|
+
/** `'left'` is the base of the diff, `'right'` the head. */
|
|
393
|
+
side?: "left" | "right";
|
|
394
|
+
/** Forge-native id of the comment this one replies to. */
|
|
395
|
+
inReplyTo?: string;
|
|
396
|
+
/** The resolvable conversation the comment belongs to, where the forge has one. */
|
|
397
|
+
thread?: {
|
|
398
|
+
id: string;
|
|
399
|
+
resolved: boolean;
|
|
400
|
+
};
|
|
401
|
+
createdAt?: Date;
|
|
402
|
+
url?: string;
|
|
403
|
+
raw: unknown;
|
|
404
|
+
}
|
|
405
|
+
/** A review of a pull request. */
|
|
406
|
+
interface Review {
|
|
407
|
+
ref: ReviewRef;
|
|
408
|
+
author?: Actor;
|
|
409
|
+
state: ReviewState;
|
|
410
|
+
stateRaw?: string;
|
|
411
|
+
body?: string;
|
|
412
|
+
submittedAt?: Date;
|
|
413
|
+
/**
|
|
414
|
+
* Inline comments submitted with the review. `false` where the forge has
|
|
415
|
+
* approvals but no review objects to hang comments on.
|
|
416
|
+
*/
|
|
417
|
+
comments: ReviewComment[] | false;
|
|
418
|
+
url?: string;
|
|
419
|
+
raw: unknown;
|
|
420
|
+
}
|
|
421
|
+
/** What a review does when it is submitted. Omitted creates a pending review where the forge has them. */
|
|
422
|
+
type ReviewEvent = "approve" | "request_changes" | "comment";
|
|
423
|
+
/** An inline comment to send with a review. */
|
|
424
|
+
interface ReviewCommentInput {
|
|
425
|
+
path: string;
|
|
426
|
+
/** Line in the diff, in `side`. */
|
|
427
|
+
line?: number;
|
|
428
|
+
side?: "left" | "right";
|
|
429
|
+
/** First line of a multi-line comment. */
|
|
430
|
+
startLine?: number;
|
|
431
|
+
body: string;
|
|
432
|
+
}
|
|
433
|
+
/** What `threads.createReview()` needs. */
|
|
434
|
+
interface ReviewInput {
|
|
435
|
+
/** Omitted creates a pending review, where the forge has them; submit it with `submitReview`. */
|
|
436
|
+
event?: ReviewEvent;
|
|
437
|
+
body?: string;
|
|
438
|
+
/** Inline comments to send with the review. */
|
|
439
|
+
comments?: ReviewCommentInput[];
|
|
440
|
+
}
|
|
441
|
+
/** A reviewer who was asked to review a pull request, and what they said. */
|
|
442
|
+
interface Reviewer {
|
|
443
|
+
actor: Actor;
|
|
444
|
+
state: ReviewState;
|
|
445
|
+
stateRaw?: string;
|
|
446
|
+
/** True when the reviewer is a team rather than an account. */
|
|
447
|
+
isTeam?: boolean;
|
|
448
|
+
}
|
|
449
|
+
/** The branches of a pull request. */
|
|
450
|
+
interface PullBranches {
|
|
451
|
+
/** `sha` is absent on forges where a pull is a patch rather than a branch (Tangled). */
|
|
452
|
+
head: {
|
|
453
|
+
ref: string;
|
|
454
|
+
sha?: string;
|
|
455
|
+
/** The repository that holds the head branch, which differs for a fork. */
|
|
456
|
+
repo?: RepoRef;
|
|
457
|
+
};
|
|
458
|
+
base: {
|
|
459
|
+
ref: string;
|
|
460
|
+
sha?: string;
|
|
461
|
+
};
|
|
462
|
+
/** The merge commit, once the pull request is merged. */
|
|
463
|
+
mergeCommitSha?: string;
|
|
464
|
+
}
|
|
465
|
+
/** Where a pull request sits in a stack of pull requests. */
|
|
466
|
+
interface ThreadStack {
|
|
467
|
+
/** Forge-native stack id, where the forge names stacks. */
|
|
468
|
+
id?: string;
|
|
469
|
+
/** The pull request this one is stacked on. Absent for the root of the stack. */
|
|
470
|
+
parent?: ThreadRef;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Combined state of the checks on a pull request's head commit. `failure`
|
|
474
|
+
* when any check failed, else `pending` while any runs, else `success`.
|
|
475
|
+
*/
|
|
476
|
+
interface ChecksSummary {
|
|
477
|
+
state: "pending" | "success" | "failure" | "unknown";
|
|
478
|
+
stateRaw?: string;
|
|
479
|
+
/** Absent when the forge reports only a combined state. */
|
|
480
|
+
total?: number;
|
|
481
|
+
failed?: number;
|
|
482
|
+
url?: string;
|
|
483
|
+
}
|
|
484
|
+
/** `neutral` covers skipped and informational results, which neither pass nor fail. */
|
|
485
|
+
type CheckState = "pending" | "success" | "failure" | "neutral" | "unknown";
|
|
486
|
+
/** One check on a commit: a check run, a commit status, a job or a policy evaluation. */
|
|
487
|
+
interface Check {
|
|
488
|
+
ref: CheckRef;
|
|
489
|
+
name: string;
|
|
490
|
+
state: CheckState;
|
|
491
|
+
/** Forge-native status, for example `in_progress` or `running`. */
|
|
492
|
+
stateRaw: string;
|
|
493
|
+
/** Forge-native conclusion, where the forge reports one apart from the status. */
|
|
494
|
+
conclusionRaw?: string;
|
|
495
|
+
url?: string;
|
|
496
|
+
startedAt?: Date;
|
|
497
|
+
completedAt?: Date;
|
|
498
|
+
raw: unknown;
|
|
499
|
+
}
|
|
500
|
+
/** What `checks.report` writes: a commit status everywhere, a check run on GitHub under app auth. */
|
|
501
|
+
interface CheckReportInput {
|
|
502
|
+
/** Status context or check run name. */
|
|
503
|
+
name: string;
|
|
504
|
+
state: Exclude<CheckState, "unknown">;
|
|
505
|
+
/** A short description of the state. */
|
|
506
|
+
description?: string;
|
|
507
|
+
/** Where a person goes to see the detail. */
|
|
508
|
+
url?: string;
|
|
509
|
+
/** The caller's own id for the check, where the forge stores one. */
|
|
510
|
+
externalId?: string;
|
|
511
|
+
}
|
|
512
|
+
/** A CI run: a workflow run, a pipeline, or a build. */
|
|
513
|
+
interface CiRunRef extends ForgeOrigin {
|
|
514
|
+
repo: RepoRef;
|
|
515
|
+
id: string;
|
|
516
|
+
}
|
|
517
|
+
/** One job inside a run. `run` is absent when the job was addressed on its own. */
|
|
518
|
+
interface CiJobRef extends ForgeOrigin {
|
|
519
|
+
repo: RepoRef;
|
|
520
|
+
id: string;
|
|
521
|
+
run?: CiRunRef;
|
|
522
|
+
}
|
|
523
|
+
/** A CI run, such as a workflow run or a pipeline. */
|
|
524
|
+
interface CiRun {
|
|
525
|
+
ref: CiRunRef;
|
|
526
|
+
name: string;
|
|
527
|
+
state: CheckState;
|
|
528
|
+
stateRaw: string;
|
|
529
|
+
/** Per-repo run number, where the forge has one. */
|
|
530
|
+
number?: string;
|
|
531
|
+
/** What triggered the run, as the forge names it. */
|
|
532
|
+
eventRaw?: string;
|
|
533
|
+
branch?: string;
|
|
534
|
+
/** The commit that the run ran on. */
|
|
535
|
+
sha?: string;
|
|
536
|
+
url?: string;
|
|
537
|
+
actor?: Actor;
|
|
538
|
+
createdAt?: Date;
|
|
539
|
+
startedAt?: Date;
|
|
540
|
+
completedAt?: Date;
|
|
541
|
+
raw: unknown;
|
|
542
|
+
}
|
|
543
|
+
/** One job of a CI run. */
|
|
544
|
+
interface CiJob {
|
|
545
|
+
ref: CiJobRef;
|
|
546
|
+
name: string;
|
|
547
|
+
state: CheckState;
|
|
548
|
+
stateRaw: string;
|
|
549
|
+
/** Stage or group the job belongs to, where the forge has one. */
|
|
550
|
+
stage?: string;
|
|
551
|
+
url?: string;
|
|
552
|
+
startedAt?: Date;
|
|
553
|
+
completedAt?: Date;
|
|
554
|
+
raw: unknown;
|
|
555
|
+
}
|
|
556
|
+
/** Filters for `ci.runs()`. */
|
|
557
|
+
interface CiRunQuery extends PageOptions {
|
|
558
|
+
branch?: string;
|
|
559
|
+
/** Normalised state; forges that filter on their own names translate it. */
|
|
560
|
+
state?: Exclude<CheckState, "unknown">;
|
|
561
|
+
}
|
|
562
|
+
/** A commit addressed by its full sha. */
|
|
563
|
+
interface CommitRef extends ForgeOrigin {
|
|
564
|
+
repo: RepoRef;
|
|
565
|
+
/** The full sha of the commit. */
|
|
566
|
+
sha: string;
|
|
567
|
+
}
|
|
568
|
+
/** `'binary'` carries bytes; `'utf-8'` carries text the forge reported as text. */
|
|
569
|
+
type FileEncoding = "utf-8" | "binary";
|
|
570
|
+
/** What a forge reports about a file, apart from its content. */
|
|
571
|
+
interface FileMetadata {
|
|
572
|
+
/** The path from the repository root. */
|
|
573
|
+
path: string;
|
|
574
|
+
/** Blob sha, where the forge reports one. */
|
|
575
|
+
sha?: string;
|
|
576
|
+
size?: number;
|
|
577
|
+
/** Web page for the file at this ref, where the forge has one. */
|
|
578
|
+
url?: string;
|
|
579
|
+
}
|
|
580
|
+
/** A file's contents. Narrow on `encoding` to get text or bytes. */
|
|
581
|
+
type FileContent = FileMetadata & {
|
|
582
|
+
encoding: "utf-8";
|
|
583
|
+
content: string;
|
|
584
|
+
} | FileMetadata & {
|
|
585
|
+
encoding: "binary";
|
|
586
|
+
content: Uint8Array;
|
|
587
|
+
};
|
|
588
|
+
/** Options for `contents.file()`. */
|
|
589
|
+
interface FileOptions extends BaseOptions {
|
|
590
|
+
/** Branch, tag or sha. Defaults to the repository's default branch. */
|
|
591
|
+
ref?: string;
|
|
592
|
+
/**
|
|
593
|
+
* `'text'` decodes as UTF-8 and rejects with {@link ContentNotTextError} when the bytes are not text.
|
|
594
|
+
* @default 'binary'
|
|
595
|
+
*/
|
|
596
|
+
as?: "text" | "binary";
|
|
597
|
+
}
|
|
598
|
+
/** What a tree entry is. */
|
|
599
|
+
type TreeEntryType = "file" | "directory" | "symlink" | "submodule";
|
|
600
|
+
/** One entry of a repository tree. */
|
|
601
|
+
interface TreeEntry {
|
|
602
|
+
/** Path from the repository root, without a leading slash. */
|
|
603
|
+
path: string;
|
|
604
|
+
type: TreeEntryType;
|
|
605
|
+
sha?: string;
|
|
606
|
+
/** The size in bytes, for a file. */
|
|
607
|
+
size?: number;
|
|
608
|
+
/** POSIX mode as the forge reports it, for example `100644`. */
|
|
609
|
+
mode?: string;
|
|
610
|
+
url?: string;
|
|
611
|
+
}
|
|
612
|
+
/** Options for `contents.tree()`. */
|
|
613
|
+
interface TreeOptions extends PageOptions {
|
|
614
|
+
/** Branch, tag or sha. Defaults to the repository's default branch. */
|
|
615
|
+
ref?: string;
|
|
616
|
+
/** Subdirectory to list; the root when omitted. */
|
|
617
|
+
path?: string;
|
|
618
|
+
/** Every descendant rather than one level. Unsupported on some forges, which then warn. */
|
|
619
|
+
recursive?: boolean;
|
|
620
|
+
}
|
|
621
|
+
/** A branch of a repository. */
|
|
622
|
+
interface Branch {
|
|
623
|
+
name: string;
|
|
624
|
+
/** The commit that the branch points at. */
|
|
625
|
+
sha: string;
|
|
626
|
+
isDefault?: boolean;
|
|
627
|
+
isProtected?: boolean;
|
|
628
|
+
url?: string;
|
|
629
|
+
raw: unknown;
|
|
630
|
+
}
|
|
631
|
+
/** A tag of a repository. */
|
|
632
|
+
interface Tag {
|
|
633
|
+
name: string;
|
|
634
|
+
/** Commit the tag points at, after dereferencing an annotated tag where the forge does so. */
|
|
635
|
+
sha: string;
|
|
636
|
+
url?: string;
|
|
637
|
+
raw: unknown;
|
|
638
|
+
}
|
|
639
|
+
/** Git authorship, with the forge account behind it where the forge matched one. */
|
|
640
|
+
interface CommitSignature {
|
|
641
|
+
/** The account, where the forge can match it. */
|
|
642
|
+
actor?: Actor;
|
|
643
|
+
name?: string;
|
|
644
|
+
email?: string;
|
|
645
|
+
/** When the commit was authored or committed. */
|
|
646
|
+
date?: Date;
|
|
647
|
+
}
|
|
648
|
+
/** How a commit or pull request changed a file. */
|
|
649
|
+
type FileStatus = "added" | "modified" | "removed" | "renamed" | "copied" | "changed";
|
|
650
|
+
/** A file that a commit or pull request changed. */
|
|
651
|
+
interface ChangedFile {
|
|
652
|
+
path: string;
|
|
653
|
+
/** Path before a rename or copy. */
|
|
654
|
+
previousPath?: string;
|
|
655
|
+
status: FileStatus;
|
|
656
|
+
statusRaw?: string;
|
|
657
|
+
additions?: number;
|
|
658
|
+
deletions?: number;
|
|
659
|
+
/** Unified diff for the file, where the forge returns one inline. */
|
|
660
|
+
patch?: string;
|
|
661
|
+
/** Blob sha after the change. */
|
|
662
|
+
sha?: string;
|
|
663
|
+
/** The file is binary, so it has no patch. */
|
|
664
|
+
isBinary?: boolean;
|
|
665
|
+
}
|
|
666
|
+
/** A commit. */
|
|
667
|
+
interface Commit {
|
|
668
|
+
ref: CommitRef;
|
|
669
|
+
/** The full sha. */
|
|
670
|
+
sha: string;
|
|
671
|
+
message: string;
|
|
672
|
+
/** Who wrote the change. */
|
|
673
|
+
author?: CommitSignature;
|
|
674
|
+
/** Who recorded the change. */
|
|
675
|
+
committer?: CommitSignature;
|
|
676
|
+
parents: string[];
|
|
677
|
+
url?: string;
|
|
678
|
+
stats?: {
|
|
679
|
+
additions: number;
|
|
680
|
+
deletions: number;
|
|
681
|
+
total?: number;
|
|
682
|
+
};
|
|
683
|
+
/** Present on `contents.commit`; absent from listings. */
|
|
684
|
+
files?: ChangedFile[];
|
|
685
|
+
raw: unknown;
|
|
686
|
+
}
|
|
687
|
+
/** Filters for `contents.commits()`. */
|
|
688
|
+
interface CommitQuery extends PageOptions {
|
|
689
|
+
/** Branch, tag or sha to walk back from. */
|
|
690
|
+
ref?: string;
|
|
691
|
+
/** Only commits at or after this time. */
|
|
692
|
+
since?: Date;
|
|
693
|
+
/** Only commits at or before this time. */
|
|
694
|
+
until?: Date;
|
|
695
|
+
/** Only commits touching this path. */
|
|
696
|
+
path?: string;
|
|
697
|
+
/** Login or email, as the forge matches it. */
|
|
698
|
+
author?: string;
|
|
699
|
+
}
|
|
700
|
+
/** The difference between two revisions. */
|
|
701
|
+
interface Comparison {
|
|
702
|
+
/** The revision that the comparison starts from. */
|
|
703
|
+
base: string;
|
|
704
|
+
/** The revision that the comparison ends at. */
|
|
705
|
+
head: string;
|
|
706
|
+
/** The number of commits that `head` has and `base` lacks. */
|
|
707
|
+
aheadBy?: number;
|
|
708
|
+
/** The number of commits that `base` has and `head` lacks. */
|
|
709
|
+
behindBy?: number;
|
|
710
|
+
/** The commits between the two revisions. */
|
|
711
|
+
commits: Commit[];
|
|
712
|
+
files: ChangedFile[];
|
|
713
|
+
/** The merge base, where the forge reports it. */
|
|
714
|
+
mergeBaseSha?: string;
|
|
715
|
+
raw: unknown;
|
|
716
|
+
}
|
|
717
|
+
/** A file that a code search found. A file whose excerpts span two pages comes back on both. */
|
|
718
|
+
interface CodeMatch {
|
|
719
|
+
repo: RepoRef;
|
|
720
|
+
path: string;
|
|
721
|
+
/** The branch, tag or sha the forge searched, where it reports one. */
|
|
722
|
+
ref?: string;
|
|
723
|
+
/** The excerpts of the file that matched. */
|
|
724
|
+
fragments: CodeFragment[];
|
|
725
|
+
url?: string;
|
|
726
|
+
raw: unknown;
|
|
727
|
+
}
|
|
728
|
+
/** An excerpt of a file that matched a code search. */
|
|
729
|
+
interface CodeFragment {
|
|
730
|
+
text: string;
|
|
731
|
+
/** The line the excerpt starts on, where the forge reports it. */
|
|
732
|
+
line?: number;
|
|
733
|
+
}
|
|
734
|
+
/** A release asset, addressable for download with `releases.downloadAsset`. */
|
|
735
|
+
interface ReleaseAssetRef extends ForgeOrigin {
|
|
736
|
+
repo: RepoRef;
|
|
737
|
+
release: ReleaseRef;
|
|
738
|
+
/** Forge-native asset id; the asset name, or the link id, on forges that have no asset id. */
|
|
739
|
+
id: string;
|
|
740
|
+
}
|
|
741
|
+
/** A file attached to a release. */
|
|
742
|
+
interface ReleaseAsset {
|
|
743
|
+
/** Absent where the forge publishes a download URL but nothing to address the asset by. */
|
|
744
|
+
ref?: ReleaseAssetRef;
|
|
745
|
+
name: string;
|
|
746
|
+
url: string;
|
|
747
|
+
size?: number;
|
|
748
|
+
downloadCount?: number;
|
|
749
|
+
/** The media type. */
|
|
750
|
+
contentType?: string;
|
|
751
|
+
}
|
|
752
|
+
/** A release of a repository. */
|
|
753
|
+
interface Release {
|
|
754
|
+
ref: ReleaseRef;
|
|
755
|
+
name?: string;
|
|
756
|
+
tag: string;
|
|
757
|
+
/** The release notes. */
|
|
758
|
+
body?: string;
|
|
759
|
+
isDraft: boolean;
|
|
760
|
+
isPrerelease: boolean;
|
|
761
|
+
/**
|
|
762
|
+
* The release is immutable: its tag and assets are locked. `true` where the
|
|
763
|
+
* forge supports immutable releases and this one is published as immutable
|
|
764
|
+
* (GitHub). The name, notes, prerelease and latest flags stay editable.
|
|
765
|
+
*/
|
|
766
|
+
immutable?: boolean;
|
|
767
|
+
author?: Actor;
|
|
768
|
+
publishedAt?: Date;
|
|
769
|
+
createdAt?: Date;
|
|
770
|
+
url?: string;
|
|
771
|
+
assets?: ReleaseAsset[];
|
|
772
|
+
raw: unknown;
|
|
773
|
+
}
|
|
774
|
+
/** The fields that `releases.create()` sets. */
|
|
775
|
+
interface ReleaseInput {
|
|
776
|
+
/** The tag to release. The forge creates it from `target` when it does not exist yet. */
|
|
777
|
+
tag: string;
|
|
778
|
+
name?: string;
|
|
779
|
+
/** The release notes. */
|
|
780
|
+
body?: string;
|
|
781
|
+
/** Saves the release unpublished. `true` rejects with `UnsupportedOperationError` on a forge without drafts. */
|
|
782
|
+
draft?: boolean;
|
|
783
|
+
/** Marks the release as a prerelease. `true` rejects with `UnsupportedOperationError` on a forge without prereleases. */
|
|
784
|
+
prerelease?: boolean;
|
|
785
|
+
/**
|
|
786
|
+
* The branch or commit sha to create the tag from when it does not exist yet. GitHub, Forgejo and Gitea
|
|
787
|
+
* default to the default branch; GitLab requires it for a new tag.
|
|
788
|
+
*/
|
|
789
|
+
target?: string;
|
|
790
|
+
}
|
|
791
|
+
/** The fields that `releases.update()` changes. Fields left out stay as they are. */
|
|
792
|
+
type ReleaseUpdate = Partial<ReleaseInput>;
|
|
793
|
+
/** How severe an alert is. `unknown` is a level that the model does not name. */
|
|
794
|
+
type SecuritySeverity = "critical" | "high" | "medium" | "low" | "unknown";
|
|
795
|
+
/** A security alert on a repository. */
|
|
796
|
+
interface SecurityAlert {
|
|
797
|
+
ref: SecurityAlertRef;
|
|
798
|
+
kind: SecurityAlertKind;
|
|
799
|
+
kindRaw: string;
|
|
800
|
+
severity: SecuritySeverity;
|
|
801
|
+
severityRaw?: string;
|
|
802
|
+
state: "open" | "fixed" | "dismissed" | "unknown";
|
|
803
|
+
stateRaw: string;
|
|
804
|
+
/** A short description of the problem. */
|
|
805
|
+
title: string;
|
|
806
|
+
/** `ecosystem` is absent where the forge reports only the package name. */
|
|
807
|
+
package?: {
|
|
808
|
+
ecosystem?: string;
|
|
809
|
+
name: string;
|
|
810
|
+
vulnerableRange?: string;
|
|
811
|
+
fixedIn?: string;
|
|
812
|
+
};
|
|
813
|
+
url?: string;
|
|
814
|
+
createdAt?: Date;
|
|
815
|
+
updatedAt?: Date;
|
|
816
|
+
dismissedAt?: Date;
|
|
817
|
+
raw: unknown;
|
|
818
|
+
}
|
|
819
|
+
/** Filters for `securityAlerts.list()`. */
|
|
820
|
+
interface SecurityAlertListOptions extends PageOptions {
|
|
821
|
+
/** Omitted lists every kind the provider can read, one after another. */
|
|
822
|
+
kind?: Exclude<SecurityAlertKind, "other">;
|
|
823
|
+
/**
|
|
824
|
+
* `'closed'` is fixed or dismissed.
|
|
825
|
+
* @default 'open'
|
|
826
|
+
*/
|
|
827
|
+
state?: "open" | "closed" | "all";
|
|
828
|
+
}
|
|
829
|
+
/** The warning codes providers emit; providers may add codes in a minor release. */
|
|
830
|
+
type ForgeWarningCode = "checks_unreadable" | "collaborators_unreachable" | "discussion_unresolved" | "filter_unsupported" | "index_possibly_stale" | "insufficient_scope" | "kind_unsupported" | "notifications_failed" | "record_unreachable" | "recursive_unsupported" | "search_failed" | "search_incomplete" | "sort_unsupported" | "state_record_unreachable" | "thread_unreadable" | "thread_unresolved" | "tree_truncated" | (string & {});
|
|
831
|
+
/** A non-fatal problem encountered while producing a result. */
|
|
832
|
+
interface ForgeWarning {
|
|
833
|
+
/** Stable machine-readable code. */
|
|
834
|
+
code: ForgeWarningCode;
|
|
835
|
+
/** A description of the problem, for a person. */
|
|
836
|
+
message: string;
|
|
837
|
+
/** Key or URI of the item the warning concerns, when it concerns one. */
|
|
838
|
+
subject?: string;
|
|
839
|
+
cause?: {
|
|
840
|
+
name: string;
|
|
841
|
+
message: string;
|
|
842
|
+
status?: number;
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
/** An issue, pull request, discussion or commit conversation. */
|
|
846
|
+
interface Thread {
|
|
847
|
+
ref: ThreadRef;
|
|
848
|
+
kind: ThreadKind;
|
|
849
|
+
title: string;
|
|
850
|
+
body?: string;
|
|
851
|
+
state: ThreadState;
|
|
852
|
+
/** Forge-native state string the normalised `state` was derived from. */
|
|
853
|
+
stateRaw?: string;
|
|
854
|
+
/** Forge-native state qualifier, for example `completed` or `not_planned`. */
|
|
855
|
+
stateReason?: string;
|
|
856
|
+
isDraft: boolean;
|
|
857
|
+
author?: Actor;
|
|
858
|
+
assignees: Actor[];
|
|
859
|
+
/**
|
|
860
|
+
* Reviewers the thread read reports. Some forges report outstanding requests
|
|
861
|
+
* only, others each reviewer's verdict; `threads.reviews()` has every
|
|
862
|
+
* submitted review.
|
|
863
|
+
*/
|
|
864
|
+
reviewers: Reviewer[];
|
|
865
|
+
labels: Label[];
|
|
866
|
+
url?: string;
|
|
867
|
+
createdAt?: Date;
|
|
868
|
+
updatedAt?: Date;
|
|
869
|
+
closedAt?: Date;
|
|
870
|
+
/** Latest activity the forge reports for the thread. */
|
|
871
|
+
lastActivityAt?: Date;
|
|
872
|
+
locked?: boolean;
|
|
873
|
+
commentCount?: number;
|
|
874
|
+
/** Everyone who authored or commented on the thread, where the forge reports them. */
|
|
875
|
+
participants?: Actor[];
|
|
876
|
+
/** Whether the authenticated account has read the thread, where the forge tracks it per thread. */
|
|
877
|
+
readState?: "read" | "unread";
|
|
878
|
+
/** The authenticated account's subscription, where the thread read already carries it. */
|
|
879
|
+
subscription?: SubscriptionState;
|
|
880
|
+
milestone?: Milestone;
|
|
881
|
+
reactions?: ReactionSummary;
|
|
882
|
+
/** Pull requests only. */
|
|
883
|
+
branches?: PullBranches;
|
|
884
|
+
/** Pull requests only. */
|
|
885
|
+
checks?: ChecksSummary;
|
|
886
|
+
/** Pull requests in a stack: a chain of dependent pull requests, each based on the one before. */
|
|
887
|
+
stack?: ThreadStack;
|
|
888
|
+
/** Non-fatal problems hit while reading the thread, for example an unreachable record. */
|
|
889
|
+
warnings?: ForgeWarning[];
|
|
890
|
+
/** Unnormalised forge payload, retained for fidelity. */
|
|
891
|
+
raw: unknown;
|
|
892
|
+
}
|
|
893
|
+
/** Reference to a comment on a thread. */
|
|
894
|
+
interface CommentRef extends ForgeOrigin {
|
|
895
|
+
thread: ThreadRef;
|
|
896
|
+
/** Forge-native comment id; an AT-URI on Tangled. */
|
|
897
|
+
id: string;
|
|
898
|
+
}
|
|
899
|
+
/** A comment on a thread. */
|
|
900
|
+
interface Comment {
|
|
901
|
+
ref: CommentRef;
|
|
902
|
+
body: string;
|
|
903
|
+
author?: Actor;
|
|
904
|
+
createdAt?: Date;
|
|
905
|
+
updatedAt?: Date;
|
|
906
|
+
url?: string;
|
|
907
|
+
reactions?: ReactionSummary;
|
|
908
|
+
/** The resolvable conversation the comment belongs to, where the forge has one; `resolveReviewThread()` takes its id. */
|
|
909
|
+
thread?: {
|
|
910
|
+
id: string;
|
|
911
|
+
resolved: boolean;
|
|
912
|
+
};
|
|
913
|
+
raw: unknown;
|
|
914
|
+
}
|
|
915
|
+
/** Whether the account gets notifications for a thread. */
|
|
916
|
+
type SubscriptionState = "subscribed" | "ignored" | "none";
|
|
917
|
+
/** What an event is about. */
|
|
918
|
+
type EventKind = "comment" | "review" | "review_comment" | "commit" | "label" | "state_change" | "assignment" | "mention" | "referenced" | "reaction" | "push" | "ref" | "repo" | "installation" | "membership" | "release" | "other";
|
|
919
|
+
/** A commit as a push delivery reports it. */
|
|
920
|
+
interface PushCommit {
|
|
921
|
+
sha: string;
|
|
922
|
+
message?: string;
|
|
923
|
+
author?: string;
|
|
924
|
+
url?: string;
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* What happened, independent of `kind`, so "anything that closed" is
|
|
928
|
+
* `action === 'closed'` whatever the subject.
|
|
929
|
+
*/
|
|
930
|
+
type EventAction = "opened" | "closed" | "reopened" | "merged" | "edited" | "created" | "deleted" | "submitted" | "labelled" | "unlabelled" | "assigned" | "unassigned" | "review_requested" | "synchronised" | "ready_for_review" | "converted_to_draft" | "published" | "renamed" | "transferred" | "archived" | "unarchived" | "added" | "removed" | "other";
|
|
931
|
+
/** Typed detail for an event. Discriminated by `type`. */
|
|
932
|
+
type EventDetail = {
|
|
933
|
+
type: "comment";
|
|
934
|
+
comment?: CommentRef;
|
|
935
|
+
body?: string;
|
|
936
|
+
} | {
|
|
937
|
+
type: "review_comment";
|
|
938
|
+
comment?: CommentRef;
|
|
939
|
+
body?: string;
|
|
940
|
+
path?: string;
|
|
941
|
+
line?: number;
|
|
942
|
+
} | {
|
|
943
|
+
type: "review";
|
|
944
|
+
state: ReviewState;
|
|
945
|
+
stateRaw?: string;
|
|
946
|
+
body?: string;
|
|
947
|
+
} | {
|
|
948
|
+
type: "state_change";
|
|
949
|
+
state?: ThreadState;
|
|
950
|
+
draft?: boolean;
|
|
951
|
+
} | {
|
|
952
|
+
type: "label";
|
|
953
|
+
label: string;
|
|
954
|
+
} | {
|
|
955
|
+
type: "assignment";
|
|
956
|
+
assignee?: Actor;
|
|
957
|
+
} | {
|
|
958
|
+
type: "push";
|
|
959
|
+
ref: string;
|
|
960
|
+
before?: string;
|
|
961
|
+
after?: string;
|
|
962
|
+
commitCount: number;
|
|
963
|
+
forced: boolean;
|
|
964
|
+
commits: PushCommit[];
|
|
965
|
+
} | {
|
|
966
|
+
type: "ref";
|
|
967
|
+
ref: string;
|
|
968
|
+
refType: "branch" | "tag" | (string & {});
|
|
969
|
+
} | {
|
|
970
|
+
type: "repo_renamed";
|
|
971
|
+
from: string;
|
|
972
|
+
to: string;
|
|
973
|
+
} | {
|
|
974
|
+
type: "repo_transferred";
|
|
975
|
+
fromOwner?: string;
|
|
976
|
+
toOwner?: string;
|
|
977
|
+
} | {
|
|
978
|
+
type: "repo_archived";
|
|
979
|
+
archived: boolean;
|
|
980
|
+
} | {
|
|
981
|
+
type: "installation";
|
|
982
|
+
actionRaw: string;
|
|
983
|
+
installationId?: string;
|
|
984
|
+
added: RepoRef[];
|
|
985
|
+
removed: RepoRef[];
|
|
986
|
+
} | {
|
|
987
|
+
type: "membership";
|
|
988
|
+
actionRaw: string;
|
|
989
|
+
member?: Actor;
|
|
990
|
+
} | {
|
|
991
|
+
type: "release";
|
|
992
|
+
release: ReleaseRef;
|
|
993
|
+
name?: string;
|
|
994
|
+
} | {
|
|
995
|
+
type: "referenced";
|
|
996
|
+
from?: ThreadRef | CommitRef;
|
|
997
|
+
fromRepo?: RepoRef;
|
|
998
|
+
text?: string;
|
|
999
|
+
};
|
|
1000
|
+
/** An event on a forge, such as a comment, a state change or a push. */
|
|
1001
|
+
interface ForgeEvent extends ForgeOrigin {
|
|
1002
|
+
id: string;
|
|
1003
|
+
kind: EventKind;
|
|
1004
|
+
/** Forge-native event name the normalised `kind` was derived from. */
|
|
1005
|
+
kindRaw?: string;
|
|
1006
|
+
/** Normalised verb; `other` when the forge's wording has no equivalent. */
|
|
1007
|
+
action: EventAction;
|
|
1008
|
+
/** Forge-native verb `action` was derived from. */
|
|
1009
|
+
actionRaw?: string;
|
|
1010
|
+
/** Single line describing the event, suitable for a list row. */
|
|
1011
|
+
summary: string;
|
|
1012
|
+
occurredAt: Date;
|
|
1013
|
+
actor?: Actor;
|
|
1014
|
+
repo?: RepoRef;
|
|
1015
|
+
thread?: ThreadRef;
|
|
1016
|
+
/** The details that belong to the kind of event. */
|
|
1017
|
+
detail?: EventDetail;
|
|
1018
|
+
/** App installation the delivery belongs to, for app webhooks. */
|
|
1019
|
+
installationId?: string;
|
|
1020
|
+
/** Delivery mechanism the event arrived through. */
|
|
1021
|
+
source: SourceKind;
|
|
1022
|
+
/** Unnormalised forge payload, retained for fidelity. */
|
|
1023
|
+
payload: unknown;
|
|
1024
|
+
}
|
|
1025
|
+
/** A {@link ForgeEvent} as a provider builds it; core derives `action` when it is absent. */
|
|
1026
|
+
type ForgeEventInput = Omit<ForgeEvent, "action"> & {
|
|
1027
|
+
action?: EventAction;
|
|
1028
|
+
};
|
|
1029
|
+
/** How an event reached the caller. */
|
|
1030
|
+
type SourceKind = "poll" | "webhook" | "subscribe";
|
|
1031
|
+
/**
|
|
1032
|
+
* Why a notification was delivered. `'unknown'` covers forges that report no
|
|
1033
|
+
* reason and native reasons with no normalised equivalent; `reasonRaw` keeps
|
|
1034
|
+
* the original.
|
|
1035
|
+
*/
|
|
1036
|
+
type NotificationReason = "access_requested" | "approval_requested" | "assigned" | "author" | "ci_activity" | "comment" | "followed" | "invitation" | "manual" | "mention" | "merge_blocked" | "review_requested" | "review_submitted" | "security_alert" | "starred" | "state_change" | "subscribed" | "team_mention" | "unknown";
|
|
1037
|
+
/** What a notification is about. Not every notification concerns a thread. */
|
|
1038
|
+
type NotificationSubject = {
|
|
1039
|
+
type: "thread";
|
|
1040
|
+
thread: ThreadRef;
|
|
1041
|
+
} | {
|
|
1042
|
+
type: "repo";
|
|
1043
|
+
repo: RepoRef;
|
|
1044
|
+
} | {
|
|
1045
|
+
type: "actor";
|
|
1046
|
+
actor: Actor;
|
|
1047
|
+
} | {
|
|
1048
|
+
type: "release";
|
|
1049
|
+
release: ReleaseRef;
|
|
1050
|
+
} | {
|
|
1051
|
+
type: "security_alert";
|
|
1052
|
+
alert: SecurityAlertRef;
|
|
1053
|
+
} | {
|
|
1054
|
+
type: "other";
|
|
1055
|
+
typeRaw: string;
|
|
1056
|
+
repo?: RepoRef;
|
|
1057
|
+
id?: string;
|
|
1058
|
+
url?: string;
|
|
1059
|
+
};
|
|
1060
|
+
/** A notification of the authenticated account. */
|
|
1061
|
+
interface Notification {
|
|
1062
|
+
ref: NotificationRef;
|
|
1063
|
+
subject: NotificationSubject;
|
|
1064
|
+
/** Why the account got the notification. */
|
|
1065
|
+
reason: NotificationReason;
|
|
1066
|
+
/** Forge-native reason string. Absent when the forge reports no reason at all. */
|
|
1067
|
+
reasonRaw?: string;
|
|
1068
|
+
/** Forge-native subject type, for example `PullRequest`, `Release` or `followed`. */
|
|
1069
|
+
subjectTypeRaw?: string;
|
|
1070
|
+
unread: boolean;
|
|
1071
|
+
title: string;
|
|
1072
|
+
/** State of a thread subject as reported by the notification payload. */
|
|
1073
|
+
subjectState: ThreadState;
|
|
1074
|
+
subjectStateRaw?: string;
|
|
1075
|
+
updatedAt: Date;
|
|
1076
|
+
lastReadAt?: Date;
|
|
1077
|
+
url?: string;
|
|
1078
|
+
/** Unnormalised forge payload, retained for fidelity. */
|
|
1079
|
+
raw: unknown;
|
|
1080
|
+
}
|
|
1081
|
+
/**
|
|
1082
|
+
* Opaque-ish resumption token. Fields are optional because forges differ in
|
|
1083
|
+
* what they support; callers should persist the whole object and hand it back.
|
|
1084
|
+
*/
|
|
1085
|
+
interface Cursor {
|
|
1086
|
+
/** Absolute URL of the next page, from a `Link` header or the body, on the requested origin. */
|
|
1087
|
+
nextUrl?: string;
|
|
1088
|
+
/** A validator for a conditional request. */
|
|
1089
|
+
etag?: string;
|
|
1090
|
+
/** Opaque forge-native cursor, for example a GraphQL `endCursor`. */
|
|
1091
|
+
token?: string;
|
|
1092
|
+
}
|
|
1093
|
+
/** Request budget the forge reported on the response, where it reports one. */
|
|
1094
|
+
interface RateLimit {
|
|
1095
|
+
/** The size of the request budget. */
|
|
1096
|
+
limit?: number;
|
|
1097
|
+
/** The number of requests left in the budget. */
|
|
1098
|
+
remaining?: number;
|
|
1099
|
+
/** When `remaining` resets. */
|
|
1100
|
+
resetAt?: Date;
|
|
1101
|
+
}
|
|
1102
|
+
/**
|
|
1103
|
+
* One page of a listing: its `items`, and the `cursor` to pass back for the next page. The cursor is absent on the
|
|
1104
|
+
* last page.
|
|
1105
|
+
*/
|
|
1106
|
+
interface Page<T> {
|
|
1107
|
+
items: T[];
|
|
1108
|
+
/** From the response headers of the request behind this page. */
|
|
1109
|
+
rateLimit?: RateLimit;
|
|
1110
|
+
/** Absent when the listing is exhausted. */
|
|
1111
|
+
cursor?: Cursor;
|
|
1112
|
+
/**
|
|
1113
|
+
* Validator of the first page, where the forge supports conditional
|
|
1114
|
+
* requests. Pass it back as `cursor: { etag }` to read the first page again.
|
|
1115
|
+
*/
|
|
1116
|
+
etag?: string;
|
|
1117
|
+
/** True when the forge reported no change since `cursor.etag`. */
|
|
1118
|
+
notModified?: boolean;
|
|
1119
|
+
/** The non-fatal problems that came up while reading the page. */
|
|
1120
|
+
warnings?: ForgeWarning[];
|
|
1121
|
+
}
|
|
1122
|
+
/** Options for listings that can start from a point in time: events, comments, reactions. */
|
|
1123
|
+
interface ListOptions extends PageOptions {
|
|
1124
|
+
/** Only items updated at or after this time. */
|
|
1125
|
+
since?: Date;
|
|
1126
|
+
}
|
|
1127
|
+
/** Options for `notifications.list()`. */
|
|
1128
|
+
interface NotificationListOptions extends ListOptions {
|
|
1129
|
+
/**
|
|
1130
|
+
* Include notifications already marked read.
|
|
1131
|
+
* @default false
|
|
1132
|
+
*/
|
|
1133
|
+
all?: boolean;
|
|
1134
|
+
}
|
|
1135
|
+
/** Filters for `threads.list()`. */
|
|
1136
|
+
interface ThreadQuery extends PageOptions {
|
|
1137
|
+
/** Omitted lists every listable kind; forges that list kinds separately emit them one after another. */
|
|
1138
|
+
kind?: "issue" | "pull_request" | "discussion";
|
|
1139
|
+
/**
|
|
1140
|
+
* `'closed'` includes merged pull requests; `'merged'` lists pull requests only,
|
|
1141
|
+
* and lists nothing for another `kind`.
|
|
1142
|
+
* @default 'open'
|
|
1143
|
+
*/
|
|
1144
|
+
state?: "open" | "closed" | "merged" | "all";
|
|
1145
|
+
/** Threads carrying every one of these labels. */
|
|
1146
|
+
labels?: string[];
|
|
1147
|
+
/** Author login. */
|
|
1148
|
+
author?: string;
|
|
1149
|
+
/** Assignee login. */
|
|
1150
|
+
assignee?: string;
|
|
1151
|
+
/** Threads the login authored, is assigned, commented on or was mentioned in. */
|
|
1152
|
+
involves?: string;
|
|
1153
|
+
/** Threads the login was mentioned in. */
|
|
1154
|
+
mentions?: string;
|
|
1155
|
+
/** Milestone title, or `'none'` for threads with no milestone. */
|
|
1156
|
+
milestone?: string;
|
|
1157
|
+
/** Updated at or after. */
|
|
1158
|
+
since?: Date;
|
|
1159
|
+
/** Created at or after. */
|
|
1160
|
+
createdAfter?: Date;
|
|
1161
|
+
/**
|
|
1162
|
+
* Unsupported orders produce a warning and the forge's own order.
|
|
1163
|
+
* @default 'created'
|
|
1164
|
+
*/
|
|
1165
|
+
sort?: "created" | "updated" | "comments";
|
|
1166
|
+
/**
|
|
1167
|
+
* @default 'desc'
|
|
1168
|
+
*/
|
|
1169
|
+
direction?: "asc" | "desc";
|
|
1170
|
+
}
|
|
1171
|
+
/**
|
|
1172
|
+
* A structured search. Providers translate it into their own syntax; a
|
|
1173
|
+
* field the forge cannot filter on becomes a `filter_unsupported` warning
|
|
1174
|
+
* on the page rather than a filter applied client-side.
|
|
1175
|
+
*/
|
|
1176
|
+
interface SearchQuery extends PageOptions {
|
|
1177
|
+
/** Free text, matched against title and body. */
|
|
1178
|
+
text?: string;
|
|
1179
|
+
/**
|
|
1180
|
+
* Forge-native query syntax, added to the query as is, for qualifiers the
|
|
1181
|
+
* other fields don't cover. Forges whose search has no query syntax ignore
|
|
1182
|
+
* it with a `filter_unsupported` warning.
|
|
1183
|
+
*/
|
|
1184
|
+
queryRaw?: string;
|
|
1185
|
+
/** Limit to one repository. */
|
|
1186
|
+
repo?: RepoRef;
|
|
1187
|
+
kind?: "issue" | "pull_request";
|
|
1188
|
+
/** Defaults to every state. */
|
|
1189
|
+
state?: "open" | "closed" | "all";
|
|
1190
|
+
author?: string;
|
|
1191
|
+
/** Threads the login authored, is assigned, commented on or was mentioned in. */
|
|
1192
|
+
involves?: string;
|
|
1193
|
+
assignee?: string;
|
|
1194
|
+
/** Threads carrying every one of these labels. */
|
|
1195
|
+
labels?: string[];
|
|
1196
|
+
/** Updated at or after. */
|
|
1197
|
+
since?: Date;
|
|
1198
|
+
/** Defaults to the forge's relevance order. */
|
|
1199
|
+
sort?: "created" | "updated" | "comments" | "relevance";
|
|
1200
|
+
/**
|
|
1201
|
+
* @default 'desc'
|
|
1202
|
+
*/
|
|
1203
|
+
direction?: "asc" | "desc";
|
|
1204
|
+
}
|
|
1205
|
+
/** A search for commits. */
|
|
1206
|
+
interface CommitSearchQuery extends PageOptions {
|
|
1207
|
+
/** Free text, matched against the commit message. */
|
|
1208
|
+
text?: string;
|
|
1209
|
+
/** Forge-native query syntax; see {@link SearchQuery.queryRaw}. */
|
|
1210
|
+
queryRaw?: string;
|
|
1211
|
+
/** Limit to one repository. */
|
|
1212
|
+
repo?: RepoRef;
|
|
1213
|
+
/** Commits whose author is this login. */
|
|
1214
|
+
author?: string;
|
|
1215
|
+
/** Commits whose committer is this login. */
|
|
1216
|
+
committer?: string;
|
|
1217
|
+
/** Authored or committed at or after. */
|
|
1218
|
+
since?: Date;
|
|
1219
|
+
/** Authored or committed at or before. */
|
|
1220
|
+
until?: Date;
|
|
1221
|
+
/** Defaults to the forge's relevance order. */
|
|
1222
|
+
sort?: "author_date" | "committer_date";
|
|
1223
|
+
/**
|
|
1224
|
+
* @default 'desc'
|
|
1225
|
+
*/
|
|
1226
|
+
direction?: "asc" | "desc";
|
|
1227
|
+
}
|
|
1228
|
+
/** A search for repositories. */
|
|
1229
|
+
interface RepoSearchQuery extends PageOptions {
|
|
1230
|
+
text?: string;
|
|
1231
|
+
/** Forge-native query syntax; see {@link SearchQuery.queryRaw}. */
|
|
1232
|
+
queryRaw?: string;
|
|
1233
|
+
/** Limit to one account or namespace. */
|
|
1234
|
+
owner?: string;
|
|
1235
|
+
/** The main language of the repository. */
|
|
1236
|
+
language?: string;
|
|
1237
|
+
/** Defaults to the forge's relevance order. */
|
|
1238
|
+
sort?: "created" | "updated" | "stars" | "relevance";
|
|
1239
|
+
/**
|
|
1240
|
+
* @default desc
|
|
1241
|
+
*/
|
|
1242
|
+
direction?: "asc" | "desc";
|
|
1243
|
+
}
|
|
1244
|
+
/** A search for code. */
|
|
1245
|
+
interface CodeSearchQuery extends PageOptions {
|
|
1246
|
+
/** Free text, matched against the contents of files. */
|
|
1247
|
+
text?: string;
|
|
1248
|
+
/** Forge-native query syntax; see {@link SearchQuery.queryRaw}. */
|
|
1249
|
+
queryRaw?: string;
|
|
1250
|
+
/** Limit to one repository. */
|
|
1251
|
+
repo?: RepoRef;
|
|
1252
|
+
/** Limit to one account or namespace. */
|
|
1253
|
+
owner?: string;
|
|
1254
|
+
}
|
|
1255
|
+
/** Options accepted by every operation that sends requests; the other options types extend it. */
|
|
1256
|
+
interface BaseOptions {
|
|
1257
|
+
/**
|
|
1258
|
+
* Aborts the operation's requests, and the operation rejects with the signal's reason.
|
|
1259
|
+
* Writes the forge has already received are not undone.
|
|
1260
|
+
*/
|
|
1261
|
+
signal?: AbortSignal;
|
|
1262
|
+
}
|
|
1263
|
+
/** Options for listings that take no filters: releases, installations, labels. */
|
|
1264
|
+
interface PageOptions extends BaseOptions {
|
|
1265
|
+
/** How many items to ask for. The forge may return fewer. */
|
|
1266
|
+
perPage?: number;
|
|
1267
|
+
/** Resume after the page that returned this cursor. */
|
|
1268
|
+
cursor?: Cursor;
|
|
1269
|
+
}
|
|
1270
|
+
/** How the account is attached to the repositories it lists. */
|
|
1271
|
+
type RepoAffiliation = "owner" | "collaborator" | "organisation_member";
|
|
1272
|
+
/** Filters for `repos.list()`. */
|
|
1273
|
+
interface RepoQuery extends PageOptions {
|
|
1274
|
+
/** Defaults to every affiliation the forge lists. Unsupported values produce a `filter_unsupported` warning. */
|
|
1275
|
+
affiliation?: RepoAffiliation[];
|
|
1276
|
+
/** Only repositories with this visibility. */
|
|
1277
|
+
visibility?: RepoVisibility | "all";
|
|
1278
|
+
/** Defaults to the forge's own order. Unsupported orders produce a `sort_unsupported` warning. */
|
|
1279
|
+
sort?: "created" | "updated" | "pushed" | "name";
|
|
1280
|
+
/** Defaults to the forge's own direction. */
|
|
1281
|
+
direction?: "asc" | "desc";
|
|
1282
|
+
}
|
|
1283
|
+
/** What `threads.upsertComment()` needs. */
|
|
1284
|
+
interface UpsertCommentInput {
|
|
1285
|
+
/**
|
|
1286
|
+
* Identifies the comment to replace across runs. It is written into the
|
|
1287
|
+
* body as an HTML comment, so it is invisible when rendered but matchable
|
|
1288
|
+
* on the next run.
|
|
1289
|
+
*/
|
|
1290
|
+
key: string;
|
|
1291
|
+
body: string;
|
|
1292
|
+
}
|
|
1293
|
+
/** What `threads.upsertComment()` did. */
|
|
1294
|
+
interface UpsertCommentResult {
|
|
1295
|
+
/** The comment that was created or edited. */
|
|
1296
|
+
comment: Comment;
|
|
1297
|
+
/** `false` when an existing comment with the same key was edited. */
|
|
1298
|
+
created: boolean;
|
|
1299
|
+
}
|
|
1300
|
+
/** What `threads.create()` needs. */
|
|
1301
|
+
interface ThreadCreateInput {
|
|
1302
|
+
kind: "issue" | "pull_request" | "discussion";
|
|
1303
|
+
title: string;
|
|
1304
|
+
body?: string;
|
|
1305
|
+
/** Names of the labels to add. */
|
|
1306
|
+
labels?: string[];
|
|
1307
|
+
/** Logins, or actors where the forge needs ids. */
|
|
1308
|
+
assignees?: Array<string | Actor>;
|
|
1309
|
+
/** Pull requests: source branch, optionally `owner:branch` for forks. */
|
|
1310
|
+
head?: string;
|
|
1311
|
+
/** Pull requests: target branch. */
|
|
1312
|
+
base?: string;
|
|
1313
|
+
/** Open the pull request as a draft. */
|
|
1314
|
+
draft?: boolean;
|
|
1315
|
+
/** Discussions: category name or id. */
|
|
1316
|
+
category?: string;
|
|
1317
|
+
}
|
|
1318
|
+
/** The fields that `threads.update()` changes. Fields left out stay as they are. */
|
|
1319
|
+
interface ThreadUpdateInput {
|
|
1320
|
+
title?: string;
|
|
1321
|
+
body?: string;
|
|
1322
|
+
}
|
|
1323
|
+
/** One `threads.getMany()` entry, in input order; narrow on `ok`. */
|
|
1324
|
+
type GetManyResult = {
|
|
1325
|
+
ok: true;
|
|
1326
|
+
ref: ThreadRef;
|
|
1327
|
+
thread: Thread;
|
|
1328
|
+
} | {
|
|
1329
|
+
ok: false;
|
|
1330
|
+
ref: ThreadRef;
|
|
1331
|
+
warning: ForgeWarning;
|
|
1332
|
+
};
|
|
1333
|
+
/**
|
|
1334
|
+
* The hidden marker `threads.upsertComment()` writes into a comment body to
|
|
1335
|
+
* find it again. It renders as nothing on every forge that renders Markdown
|
|
1336
|
+
* as HTML.
|
|
1337
|
+
*/
|
|
1338
|
+
declare function commentMarker(key: string): string;
|
|
1339
|
+
/** Whether `body` carries the marker for `key`. */
|
|
1340
|
+
declare function hasCommentMarker(body: string, key: string): boolean;
|
|
1341
|
+
/** A short-lived token that acts as one app installation. */
|
|
1342
|
+
interface InstallationToken {
|
|
1343
|
+
token: string;
|
|
1344
|
+
expiresAt: Date;
|
|
1345
|
+
permissions: Record<string, string>;
|
|
1346
|
+
/** Whether the token reaches all repositories or only selected ones. */
|
|
1347
|
+
repositorySelection?: string;
|
|
1348
|
+
}
|
|
1349
|
+
/** Maximum lengths the forge accepts, in characters. */
|
|
1350
|
+
interface TextLimits {
|
|
1351
|
+
bodyLength?: number;
|
|
1352
|
+
commentLength?: number;
|
|
1353
|
+
labelLength?: number;
|
|
1354
|
+
}
|
|
1355
|
+
/** Whether `forge` treats owner and repository names case-insensitively. Unknown forges are assumed not to. */
|
|
1356
|
+
declare function namesAreCaseInsensitive(forge: ForgeKind): boolean;
|
|
1357
|
+
/** `repo` with `owner` and `name` lowercased where the forge ignores case, so equal repositories compare equal. */
|
|
1358
|
+
declare function normaliseRepoName(repo: RepoRef): RepoRef;
|
|
1359
|
+
/** Whether `ref` addresses an organisation, group or workspace rather than a repository. */
|
|
1360
|
+
declare function isNamespaceRef(ref: RepoRef): boolean;
|
|
1361
|
+
/**
|
|
1362
|
+
* Stable identity key for a repository: by `externalId` when known, so renames
|
|
1363
|
+
* and transfers keep the key, otherwise by path, lowercased on forges that
|
|
1364
|
+
* ignore case. A hand-built ref without `externalId` therefore keys
|
|
1365
|
+
* differently from the same repo as a provider returns it.
|
|
1366
|
+
*/
|
|
1367
|
+
declare function repoKey(repo: RepoRef): string;
|
|
1368
|
+
/**
|
|
1369
|
+
* Reads a {@link repoKey} back. Keys built from an `externalId` carry no path,
|
|
1370
|
+
* so `owner` and `name` are empty on those.
|
|
1371
|
+
*/
|
|
1372
|
+
declare function parseRepoKey(key: string): RepoRef | undefined;
|
|
1373
|
+
/** The `owner/name` people read and type; the owner alone for a namespace. */
|
|
1374
|
+
declare function repoSlug(repo: RepoRef): string;
|
|
1375
|
+
/** A thread ref whose number is known, and which can therefore be keyed and fetched. */
|
|
1376
|
+
type ResolvedThreadRef = ThreadRef & {
|
|
1377
|
+
number: string;
|
|
1378
|
+
};
|
|
1379
|
+
/** Whether a thread ref has a number, so that it is a `ResolvedThreadRef`. */
|
|
1380
|
+
declare function isResolvedThread(thread: ThreadRef): thread is ResolvedThreadRef;
|
|
1381
|
+
/**
|
|
1382
|
+
* Stable identity key for a thread. `'other'` threads are keyed by their
|
|
1383
|
+
* forge-native type so unrelated subjects with the same id never collide.
|
|
1384
|
+
*/
|
|
1385
|
+
declare function threadKey(thread: ResolvedThreadRef): string;
|
|
1386
|
+
/** A string that identifies a notification, for use as a key in a map or a store. */
|
|
1387
|
+
declare function notificationKey(ref: NotificationRef): string;
|
|
1388
|
+
/** Reads a {@link threadKey} back. */
|
|
1389
|
+
declare function parseThreadKey(key: string): ResolvedThreadRef | undefined;
|
|
1390
|
+
/** Reads a {@link notificationKey} back. */
|
|
1391
|
+
declare function parseNotificationKey(key: string): NotificationRef | undefined;
|
|
1392
|
+
/** `acme/widgets#42`, or `acme/widgets@abc1234` for a commit; uses the display number where the forge has one. */
|
|
1393
|
+
declare function threadSlug(ref: ThreadRef): string;
|
|
1394
|
+
/** The thread a notification concerns, or `undefined` for repo, actor and other subjects. */
|
|
1395
|
+
declare function notificationThread(notification: Notification): ThreadRef | undefined;
|
|
1396
|
+
/** How a pull request is merged. */
|
|
1397
|
+
type MergeMethod = "merge" | "squash" | "rebase" | "rebase_merge" | "fast_forward_only";
|
|
1398
|
+
/** Options for `threads.merge()`. */
|
|
1399
|
+
interface MergeOptions extends BaseOptions {
|
|
1400
|
+
/** Defaults to the repository's only allowed method. */
|
|
1401
|
+
method?: MergeMethod;
|
|
1402
|
+
/** Expected head sha; the merge is refused if the branch has moved. */
|
|
1403
|
+
sha?: string;
|
|
1404
|
+
/** Merge commit title. Where the forge takes a single message, it goes above `message`, separated by a blank line. */
|
|
1405
|
+
title?: string;
|
|
1406
|
+
/** Merge commit body, where the forge takes one. Where the forge takes a single message and `title` is unset, this is the whole message. */
|
|
1407
|
+
message?: string;
|
|
1408
|
+
/** Queue the merge until required checks pass, where the forge supports it. */
|
|
1409
|
+
whenChecksPass?: boolean;
|
|
1410
|
+
}
|
|
1411
|
+
/** Options for `threads.approveAndMerge()`. */
|
|
1412
|
+
interface ApproveAndMergeOptions extends MergeOptions {
|
|
1413
|
+
/** Review body sent with the approval. Rejected where approvals carry no body (Azure DevOps, Bitbucket, GitLab). */
|
|
1414
|
+
body?: string;
|
|
1415
|
+
}
|
|
1416
|
+
/** An app installation on an account, with its own credential scope. */
|
|
1417
|
+
interface Installation extends ForgeOrigin {
|
|
1418
|
+
id: string;
|
|
1419
|
+
account?: Actor;
|
|
1420
|
+
/** Forge-native target type, for example `Organization` or `User`. */
|
|
1421
|
+
targetTypeRaw?: string;
|
|
1422
|
+
/** Forge-native repository selection, for example `all` or `selected`. */
|
|
1423
|
+
repositorySelectionRaw?: string;
|
|
1424
|
+
raw: unknown;
|
|
1425
|
+
}
|
|
1426
|
+
/** Every `Date` field in the model, by name. */
|
|
1427
|
+
declare const DATE_FIELDS: ReadonlySet<string>;
|
|
1428
|
+
/**
|
|
1429
|
+
* Turns the ISO strings `JSON.stringify` left in a model value back into
|
|
1430
|
+
* `Date`s, at any depth, for every field in {@link DATE_FIELDS}, skipping
|
|
1431
|
+
* `raw` and `payload`. Returns a copy.
|
|
1432
|
+
*/
|
|
1433
|
+
declare function reviveDates<T>(value: T): T;
|
|
1434
|
+
//#endregion
|
|
1435
|
+
//#region src/errors.d.ts
|
|
1436
|
+
/** Where an error happened: the forge, the instance and the request. */
|
|
1437
|
+
interface ForgeErrorContext {
|
|
1438
|
+
forge?: ForgeKind;
|
|
1439
|
+
instance?: ForgeInstance;
|
|
1440
|
+
url?: string;
|
|
1441
|
+
method?: string;
|
|
1442
|
+
}
|
|
1443
|
+
/** Base class for every error that forges throws. */
|
|
1444
|
+
declare class ForgeError extends Error {
|
|
1445
|
+
override name: string;
|
|
1446
|
+
/** The forge that the request went to. */
|
|
1447
|
+
readonly forge?: ForgeKind;
|
|
1448
|
+
readonly instance?: ForgeInstance;
|
|
1449
|
+
readonly url?: string;
|
|
1450
|
+
readonly method?: string;
|
|
1451
|
+
constructor(message: string, context?: ForgeErrorContext, options?: ErrorOptions);
|
|
1452
|
+
}
|
|
1453
|
+
/** The forge responded with an error. */
|
|
1454
|
+
declare class ForgeApiError extends ForgeError {
|
|
1455
|
+
override name: string;
|
|
1456
|
+
readonly status: number;
|
|
1457
|
+
/** Truncated response body, for diagnostics. */
|
|
1458
|
+
readonly body: string;
|
|
1459
|
+
constructor(message: string, status: number, body: string, context?: ForgeErrorContext, options?: ErrorOptions);
|
|
1460
|
+
}
|
|
1461
|
+
/** A 404: the resource does not exist, or the credential cannot see it. Many forges respond the same way to both. */
|
|
1462
|
+
declare class NotFoundError extends ForgeApiError {
|
|
1463
|
+
override name: string;
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
* A 401, or a 403 with a request budget of zero (GitHub GraphQL), for a request
|
|
1467
|
+
* sent without credentials. A rejected credential is {@link TokenRevokedError}.
|
|
1468
|
+
*/
|
|
1469
|
+
declare class AuthenticationRequiredError extends ForgeApiError {
|
|
1470
|
+
override name: string;
|
|
1471
|
+
}
|
|
1472
|
+
/** A rate limit was hit and a retry didn't help. */
|
|
1473
|
+
declare class RateLimitedError extends ForgeApiError {
|
|
1474
|
+
override name: string;
|
|
1475
|
+
/** When the limit resets, when the forge says. */
|
|
1476
|
+
readonly resetAt?: Date;
|
|
1477
|
+
/** A secondary (abuse) limit, which has no remaining-request counter. */
|
|
1478
|
+
readonly secondary: boolean;
|
|
1479
|
+
constructor(message: string, status: number, body: string, options?: {
|
|
1480
|
+
resetAt?: Date;
|
|
1481
|
+
secondary?: boolean;
|
|
1482
|
+
} & ForgeErrorContext, errorOptions?: ErrorOptions);
|
|
1483
|
+
}
|
|
1484
|
+
/** The credential was revoked or expired. */
|
|
1485
|
+
declare class TokenRevokedError extends ForgeApiError {
|
|
1486
|
+
override name: string;
|
|
1487
|
+
}
|
|
1488
|
+
/** The credential is valid but lacks the scope or permission for this call. */
|
|
1489
|
+
declare class InsufficientScopeError extends ForgeApiError {
|
|
1490
|
+
override name: string;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Why the forge refused a request the credential is otherwise valid for.
|
|
1494
|
+
* `unknown` is a 403 whose body matched nothing recognised.
|
|
1495
|
+
*/
|
|
1496
|
+
type ForbiddenReason = "org_restriction" | "sso_required" | "rate_limit_abuse" | "immutable_release" | "resource_protected" | "unknown";
|
|
1497
|
+
/**
|
|
1498
|
+
* The forge refused the request for a reason other than a missing scope: an
|
|
1499
|
+
* organisation policy, an SSO requirement, an abuse limit, a protected
|
|
1500
|
+
* resource, or a release the forge has marked immutable. A missing scope is
|
|
1501
|
+
* {@link InsufficientScopeError}.
|
|
1502
|
+
*/
|
|
1503
|
+
declare class ForbiddenError extends ForgeApiError {
|
|
1504
|
+
override name: string;
|
|
1505
|
+
/** Why the forge refused the request. */
|
|
1506
|
+
readonly reason: ForbiddenReason;
|
|
1507
|
+
/** The forge's own wording, for diagnostics and for reasons that have no `ForbiddenReason`. */
|
|
1508
|
+
readonly reasonRaw?: string;
|
|
1509
|
+
constructor(message: string, status: number, body: string, reason: ForbiddenReason, context?: ForgeErrorContext & {
|
|
1510
|
+
reasonRaw?: string;
|
|
1511
|
+
}, options?: ErrorOptions);
|
|
1512
|
+
}
|
|
1513
|
+
/** The pull request cannot be merged yet, typically because of failing or pending checks or branch protection. */
|
|
1514
|
+
declare class MergeBlockedError extends ForgeApiError {
|
|
1515
|
+
override name: string;
|
|
1516
|
+
}
|
|
1517
|
+
/** The merge conflicts with the base branch, or the head moved since `sha` was read. */
|
|
1518
|
+
declare class MergeConflictError extends ForgeApiError {
|
|
1519
|
+
override name: string;
|
|
1520
|
+
}
|
|
1521
|
+
/** A request or a pending merge exceeded `timeout`. */
|
|
1522
|
+
declare class ForgeTimeoutError extends ForgeError {
|
|
1523
|
+
override name: string;
|
|
1524
|
+
/** The timeout that was exceeded, in milliseconds. */
|
|
1525
|
+
readonly timeout: number;
|
|
1526
|
+
constructor(message: string, timeout: number, context?: ForgeErrorContext, options?: ErrorOptions);
|
|
1527
|
+
}
|
|
1528
|
+
/** A subscription connection closed or failed. Resume from `cursor`. */
|
|
1529
|
+
declare class SubscriptionClosedError extends ForgeError {
|
|
1530
|
+
override name: string;
|
|
1531
|
+
/** The cursor of the last event received. Pass it to `subscribe()` to resume. */
|
|
1532
|
+
readonly cursor?: string;
|
|
1533
|
+
constructor(message: string, cursor: string | undefined, context?: ForgeErrorContext, options?: ErrorOptions);
|
|
1534
|
+
}
|
|
1535
|
+
/** The request never got a response: DNS, TLS, connection refused or a proxy refusal. */
|
|
1536
|
+
declare class ForgeNetworkError extends ForgeError {
|
|
1537
|
+
override name: string;
|
|
1538
|
+
}
|
|
1539
|
+
/** A delivery's signature didn't match. */
|
|
1540
|
+
declare class WebhookVerificationError extends ForgeError {
|
|
1541
|
+
override name: string;
|
|
1542
|
+
}
|
|
1543
|
+
/** The forge doesn't support the operation. */
|
|
1544
|
+
declare class UnsupportedOperationError extends ForgeError {
|
|
1545
|
+
override name: string;
|
|
1546
|
+
}
|
|
1547
|
+
/** A write was called on a provider constructed with `readOnly: true`. */
|
|
1548
|
+
declare class ReadOnlyError extends UnsupportedOperationError {
|
|
1549
|
+
override name: string;
|
|
1550
|
+
}
|
|
1551
|
+
/** `contents.file` was asked for text and the file's bytes are not valid UTF-8. */
|
|
1552
|
+
declare class ContentNotTextError extends ForgeError {
|
|
1553
|
+
override name: string;
|
|
1554
|
+
}
|
|
1555
|
+
/** A ref names a forge instance no registered provider serves. */
|
|
1556
|
+
declare class UnknownForgeError extends ForgeError {
|
|
1557
|
+
override name: string;
|
|
1558
|
+
}
|
|
1559
|
+
/** Maps a generic merge-endpoint failure onto {@link MergeBlockedError} or {@link MergeConflictError}. */
|
|
1560
|
+
declare function toMergeError(error: unknown): unknown;
|
|
1561
|
+
/** The thread ref has no number, or is a kind the provider cannot address. */
|
|
1562
|
+
declare class UnresolvedThreadError extends ForgeError {
|
|
1563
|
+
override name: string;
|
|
1564
|
+
}
|
|
1565
|
+
/** No merge method was given, and the repository allows several or reports none. */
|
|
1566
|
+
declare class MergeMethodRequiredError extends ForgeError {
|
|
1567
|
+
override name: string;
|
|
1568
|
+
/** The merge methods that the repository allows. */
|
|
1569
|
+
readonly allowed: MergeMethod[];
|
|
1570
|
+
constructor(allowed: MergeMethod[], context?: ForgeErrorContext, options?: ErrorOptions);
|
|
1571
|
+
}
|
|
1572
|
+
/** Picks the only allowed merge method, or throws {@link MergeMethodRequiredError}. */
|
|
1573
|
+
declare function soleMergeMethod(allowed: Partial<Record<MergeMethod, boolean | undefined>>, context?: ForgeErrorContext): MergeMethod;
|
|
1574
|
+
//#endregion
|
|
1575
|
+
//#region src/fetch.d.ts
|
|
1576
|
+
/** The subset of `fetch` that forges needs, so a test or a runtime without a global `fetch` can supply its own. */
|
|
1577
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
1578
|
+
/** Options for `createFetcher()`. */
|
|
1579
|
+
interface FetcherOptions {
|
|
1580
|
+
baseUrl: string;
|
|
1581
|
+
/** Injected for tests and for runtimes with a non-global fetch. */
|
|
1582
|
+
fetch?: FetchLike;
|
|
1583
|
+
/**
|
|
1584
|
+
* Timeout in milliseconds (headers only for streams).
|
|
1585
|
+
* @default 30000
|
|
1586
|
+
*/
|
|
1587
|
+
timeout?: number;
|
|
1588
|
+
/** Default headers, sent only to the API origin. */
|
|
1589
|
+
headers?: Record<string, string>;
|
|
1590
|
+
/** Credentials resolved before each API-origin request. */
|
|
1591
|
+
authHeaders?: () => Promise<Record<string, string>> | Record<string, string>;
|
|
1592
|
+
/** Requests carry credentials that `authHeaders` does not set, for example through a `fetch` that signs them. */
|
|
1593
|
+
authenticated?: boolean;
|
|
1594
|
+
/** API-origin query defaults; request parameters take precedence. */
|
|
1595
|
+
query?: Record<string, string>;
|
|
1596
|
+
/** Attached to every error the fetcher throws. */
|
|
1597
|
+
context?: ForgeErrorContext;
|
|
1598
|
+
/**
|
|
1599
|
+
* Called before a request is retried. A secondary rate limit with a
|
|
1600
|
+
* `retry-after` of at most a minute is retried once, after that wait.
|
|
1601
|
+
*/
|
|
1602
|
+
onRetry?: (retry: {
|
|
1603
|
+
url: string;
|
|
1604
|
+
method: string;
|
|
1605
|
+
wait: number;
|
|
1606
|
+
}) => void;
|
|
1607
|
+
}
|
|
1608
|
+
/** Options for one request of a fetcher. */
|
|
1609
|
+
interface RequestOptions extends Omit<RequestInit, "signal"> {
|
|
1610
|
+
/** Query parameters. Parameters that are `undefined` are left out. */
|
|
1611
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
1612
|
+
signal?: AbortSignal;
|
|
1613
|
+
/** Send `If-None-Match`, and resolve with `notModified` instead of throwing. */
|
|
1614
|
+
etag?: string;
|
|
1615
|
+
/** Serialised as the JSON request body, with a matching `content-type`. */
|
|
1616
|
+
json?: unknown;
|
|
1617
|
+
/** Rewrites a failure from this request, for endpoints whose statuses mean something specific. */
|
|
1618
|
+
mapError?: (error: unknown) => unknown;
|
|
1619
|
+
}
|
|
1620
|
+
/** Options for reading one page of a paginated endpoint. */
|
|
1621
|
+
interface PaginateOptions extends RequestOptions {
|
|
1622
|
+
/**
|
|
1623
|
+
* Reads items and the next page URL from a response body, for APIs that
|
|
1624
|
+
* paginate in the body (Bitbucket's `values` / `next`). Without it, the
|
|
1625
|
+
* body is the item array and the next page comes from the `Link` header.
|
|
1626
|
+
* `linkNext` is the `Link` header's next URL, for APIs that wrap items in
|
|
1627
|
+
* the body but still paginate with `Link`.
|
|
1628
|
+
*/
|
|
1629
|
+
select?: (body: unknown, linkNext?: string) => {
|
|
1630
|
+
items: unknown[];
|
|
1631
|
+
next?: string;
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
/** A parsed response. */
|
|
1635
|
+
interface FetchResult<T> {
|
|
1636
|
+
data: T;
|
|
1637
|
+
response: Response;
|
|
1638
|
+
/** The server answered `304 Not Modified` to the `etag` that the request sent. */
|
|
1639
|
+
notModified: boolean;
|
|
1640
|
+
/** Where the next page starts, when there is one. */
|
|
1641
|
+
cursor?: Cursor;
|
|
1642
|
+
}
|
|
1643
|
+
/** A response whose body is read as it arrives rather than parsed. */
|
|
1644
|
+
interface RawResponse {
|
|
1645
|
+
status: number;
|
|
1646
|
+
headers: Headers;
|
|
1647
|
+
/** The body, read as it arrives. */
|
|
1648
|
+
body: ReadableStream<Uint8Array>;
|
|
1649
|
+
}
|
|
1650
|
+
/** A client for one forge API. It adds credentials, applies the timeout and retries, and maps failures to errors. */
|
|
1651
|
+
interface Fetcher {
|
|
1652
|
+
/** Sends a request and returns the response unparsed. */
|
|
1653
|
+
raw: (path: string, options?: RequestOptions) => Promise<Response>;
|
|
1654
|
+
/**
|
|
1655
|
+
* Bytes as they arrive, through the same timeout and error mapping as
|
|
1656
|
+
* {@link Fetcher.json}. HTTP(S) download redirects to another origin omit
|
|
1657
|
+
* all headers and credentials. HTTPS downloads cannot redirect to HTTP.
|
|
1658
|
+
* Where `fetch` hides redirects (browsers), the runtime follows GET and HEAD
|
|
1659
|
+
* under its own header rules.
|
|
1660
|
+
*/
|
|
1661
|
+
stream: (path: string, options?: RequestOptions) => Promise<RawResponse>;
|
|
1662
|
+
/** Sends a request and parses the JSON body. */
|
|
1663
|
+
json: <T>(path: string, options?: RequestOptions) => Promise<FetchResult<T>>;
|
|
1664
|
+
/** One page: `path` with its query, or `cursor.nextUrl` when given. */
|
|
1665
|
+
page: <T>(path: string, options?: PaginateOptions & {
|
|
1666
|
+
cursor?: Cursor;
|
|
1667
|
+
}) => Promise<FetchResult<T[]>>;
|
|
1668
|
+
/** Every item across every page, in order. */
|
|
1669
|
+
items: <T>(path: string, options?: PaginateOptions) => AsyncGenerator<T>;
|
|
1670
|
+
/** The absolute URL of a path and query, without sending a request. */
|
|
1671
|
+
resolve: (path: string, query?: RequestOptions["query"]) => string;
|
|
1672
|
+
}
|
|
1673
|
+
/** Parses an RFC 5988 `Link` header into a map of rel to URL. */
|
|
1674
|
+
declare function parseLinkHeader(header: string | null | undefined): Record<string, string>;
|
|
1675
|
+
/**
|
|
1676
|
+
* Creates a fetcher for one forge API.
|
|
1677
|
+
* @param options The base URL and the credentials, timeout and error context of every request.
|
|
1678
|
+
*/
|
|
1679
|
+
declare function createFetcher(options: FetcherOptions): Fetcher;
|
|
1680
|
+
/** Options for `provider.request()`. */
|
|
1681
|
+
interface ForgeRequestOptions extends BaseOptions {
|
|
1682
|
+
/** Query parameters. Parameters that are `undefined` are left out. */
|
|
1683
|
+
query?: RequestOptions["query"];
|
|
1684
|
+
/** Native fetch bodies and strings are sent as-is; other values are sent as JSON. */
|
|
1685
|
+
body?: unknown;
|
|
1686
|
+
/** Headers to send. They add to the provider's default headers. */
|
|
1687
|
+
headers?: Record<string, string>;
|
|
1688
|
+
/** Caller-declared mutation. Defaults to `false` for GET/HEAD/OPTIONS, otherwise `true`. */
|
|
1689
|
+
mutates?: boolean;
|
|
1690
|
+
}
|
|
1691
|
+
/** The result of `provider.request()`. */
|
|
1692
|
+
interface ForgeResponse<T> {
|
|
1693
|
+
status: number;
|
|
1694
|
+
/** The parsed JSON body, or the text of a body that is not JSON. */
|
|
1695
|
+
data: T;
|
|
1696
|
+
headers: Headers;
|
|
1697
|
+
/** The rate limit that the response headers report, when there is one. */
|
|
1698
|
+
rateLimit?: RateLimit;
|
|
1699
|
+
}
|
|
1700
|
+
/** `request()` with `raw`, for endpoints that respond with bytes rather than JSON. */
|
|
1701
|
+
interface ForgeRawRequestOptions extends ForgeRequestOptions {
|
|
1702
|
+
raw: true;
|
|
1703
|
+
}
|
|
1704
|
+
/**
|
|
1705
|
+
* `provider.request()`: sends a request with the provider's credentials, for endpoints that the model does not cover.
|
|
1706
|
+
*/
|
|
1707
|
+
interface ForgeRequest {
|
|
1708
|
+
(method: string, path: string, options: ForgeRawRequestOptions): Promise<RawResponse>;
|
|
1709
|
+
<T = unknown>(method: string, path: string, options?: ForgeRequestOptions): Promise<ForgeResponse<T>>;
|
|
1710
|
+
}
|
|
1711
|
+
/** Options for `createRequest()`. */
|
|
1712
|
+
interface CreateRequestOptions {
|
|
1713
|
+
/** Error for mutating requests. */
|
|
1714
|
+
readOnly?: (method: string, path: string) => Error;
|
|
1715
|
+
}
|
|
1716
|
+
/**
|
|
1717
|
+
* Builds a provider's `request()` escape hatch on top of its fetcher.
|
|
1718
|
+
* @param fetcher The fetcher to send requests with.
|
|
1719
|
+
* @param createOptions Where to reject writes, for a read-only provider.
|
|
1720
|
+
*/
|
|
1721
|
+
declare function createRequest(fetcher: Fetcher, createOptions?: CreateRequestOptions): ForgeRequest;
|
|
1722
|
+
//#endregion
|
|
1723
|
+
export { CiRunQuery as $, WebhookInput as $n, ReactionSummary as $t, RateLimitedError as A, SourceKind as An, GetManyResult as At, Actor as B, ThreadStack as Bn, Notification as Bt, ForgeNetworkError as C, Reviewer as Cn, ForgeEvent as Ct, MergeConflictError as D, SecurityAlertListOptions as Dn, ForgeOrigin as Dt, MergeBlockedError as E, SecurityAlertKind as En, ForgeKind as Et, UnresolvedThreadError as F, Thread as Fn, LabelInput as Ft, Check as G, TreeOptions as Gn, Page as Gt, BaseOptions as H, ThreadUpdateInput as Hn, NotificationReason as Ht, UnsupportedOperationError as I, ThreadCreateInput as In, ListOptions as It, CheckState as J, User as Jn, PushCommit as Jt, CheckRef as K, UpsertCommentInput as Kn, PageOptions as Kt, WebhookVerificationError as L, ThreadKind as Ln, MergeMethod as Lt, SubscriptionClosedError as M, Support as Mn, InstallationToken as Mt, TokenRevokedError as N, Tag as Nn, KnownForgeKind as Nt, MergeMethodRequiredError as O, SecurityAlertRef as On, ForgeWarning as Ot, UnknownForgeError as P, TextLimits as Pn, Label as Pt, CiRun as Q, WebhookEventType as Qn, ReactionContent as Qt, soleMergeMethod as R, ThreadQuery as Rn, MergeOptions as Rt, ForgeErrorContext as S, ReviewState as Sn, FileStatus as St, InsufficientScopeError as T, SecurityAlert as Tn, ForgeInstance as Tt, Branch as U, TreeEntry as Un, NotificationRef as Ut, ApproveAndMergeOptions as V, ThreadState as Vn, NotificationListOptions as Vt, ChangedFile as W, TreeEntryType as Wn, NotificationSubject as Wt, CiJob as X, WebhookDeliveryRecord as Xn, RateLimit as Xt, ChecksSummary as Y, Webhook as Yn, REACTION_CONTENTS as Yt, CiJobRef as Z, WebhookDeliveryRef as Zn, Reaction as Zt, ContentNotTextError as _, ReviewComment as _n, threadKey as _r, EventKind as _t, FetcherOptions as a, ReleaseUpdate as an, isResolvedThread as ar, Comment as at, ForgeApiError as b, ReviewInput as bn, FileMetadata as bt, ForgeRequestOptions as c, RepoFeatures as cn, notificationKey as cr, CommitQuery as ct, RawResponse as d, RepoRef as dn, parseRepoKey as dr, CommitSignature as dt, Release as en, WebhookRef as er, CiRunRef as et, RequestOptions as f, RepoRole as fn, parseThreadKey as fr, Comparison as ft, AuthenticationRequiredError as g, Review as gn, reviveDates as gr, EventDetail as gt, parseLinkHeader as h, ResolvedThreadRef as hn, repoSlug as hr, EventAction as ht, Fetcher as i, ReleaseRef as in, isNamespaceRef as ir, Collaborator as it, ReadOnlyError as j, SubscriptionState as jn, Installation as jt, NotFoundError as k, SecuritySeverity as kn, ForgeWarningCode as kt, ForgeResponse as l, RepoPermissions as ln, notificationThread as lr, CommitRef as lt, createRequest as m, RepoVisibility as mn, repoKey as mr, DATE_FIELDS as mt, FetchLike as n, ReleaseAssetRef as nn, commentMarker as nr, CodeMatch as nt, ForgeRawRequestOptions as o, Repo as on, namesAreCaseInsensitive as or, CommentRef as ot, createFetcher as p, RepoSearchQuery as pn, reactionContent as pr, Cursor as pt, CheckReportInput as q, UpsertCommentResult as qn, PullBranches as qt, FetchResult as r, ReleaseInput as rn, hasCommentMarker as rr, CodeSearchQuery as rt, ForgeRequest as s, RepoAffiliation as sn, normaliseRepoName as sr, Commit as st, CreateRequestOptions as t, ReleaseAsset as tn, WebhookUpdate as tr, CodeFragment as tt, PaginateOptions as u, RepoQuery as un, parseNotificationKey as ur, CommitSearchQuery as ut, ForbiddenError as v, ReviewCommentInput as vn, threadSlug as vr, FileContent as vt, ForgeTimeoutError as w, SearchQuery as wn, ForgeEventInput as wt, ForgeError as x, ReviewRef as xn, FileOptions as xt, ForbiddenReason as y, ReviewEvent as yn, FileEncoding as yt, toMergeError as z, ThreadRef as zn, Milestone as zt };
|