@happyvertical/repos 0.83.0 → 0.85.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/README.md +100 -0
- package/dist/index.d.ts +638 -0
- package/dist/index.js +1097 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,27 @@ export declare interface Branch {
|
|
|
4
4
|
protected: boolean;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/** Normalized provider check run. */
|
|
8
|
+
export declare interface CheckRun {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
headSha: string;
|
|
12
|
+
status: ForgeCheckStatus;
|
|
13
|
+
conclusion?: ForgeCheckConclusion;
|
|
14
|
+
detailsUrl?: string;
|
|
15
|
+
externalId?: string;
|
|
16
|
+
startedAt?: Date;
|
|
17
|
+
completedAt?: Date;
|
|
18
|
+
raw?: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Human-readable check-run output published by a forge. */
|
|
22
|
+
export declare interface CheckRunOutput {
|
|
23
|
+
title: string;
|
|
24
|
+
summary: string;
|
|
25
|
+
text?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
7
28
|
declare interface Comment_2 {
|
|
8
29
|
id: string;
|
|
9
30
|
body: string;
|
|
@@ -14,6 +35,40 @@ declare interface Comment_2 {
|
|
|
14
35
|
}
|
|
15
36
|
export { Comment_2 as Comment }
|
|
16
37
|
|
|
38
|
+
/** Normalized provider commit status. */
|
|
39
|
+
export declare interface CommitStatus {
|
|
40
|
+
id: string;
|
|
41
|
+
sha: string;
|
|
42
|
+
state: string;
|
|
43
|
+
context: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
targetUrl?: string;
|
|
46
|
+
createdAt?: Date;
|
|
47
|
+
raw?: unknown;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Input for publishing a provider check run. */
|
|
51
|
+
export declare interface CreateCheckRunInput {
|
|
52
|
+
name: string;
|
|
53
|
+
headSha: string;
|
|
54
|
+
status?: ForgeCheckStatus;
|
|
55
|
+
conclusion?: ForgeCheckConclusion;
|
|
56
|
+
detailsUrl?: string;
|
|
57
|
+
externalId?: string;
|
|
58
|
+
startedAt?: Date | string;
|
|
59
|
+
completedAt?: Date | string;
|
|
60
|
+
output?: CheckRunOutput;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Input for publishing a provider commit status. */
|
|
64
|
+
export declare interface CreateCommitStatusInput {
|
|
65
|
+
sha: string;
|
|
66
|
+
state: 'error' | 'failure' | 'pending' | 'success';
|
|
67
|
+
context: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
targetUrl?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
17
72
|
/**
|
|
18
73
|
* Options for creating a repository from a template
|
|
19
74
|
*/
|
|
@@ -30,6 +85,29 @@ export declare interface CreateFromTemplateOptions {
|
|
|
30
85
|
includeAllBranches?: boolean;
|
|
31
86
|
}
|
|
32
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Creates a short-lived GitHub App JWT without mutating process credentials.
|
|
90
|
+
* @param credentials GitHub App ID and RSA private key.
|
|
91
|
+
* @param now Clock value used for issued-at and expiry claims.
|
|
92
|
+
* @returns Signed RS256 GitHub App JWT.
|
|
93
|
+
* @throws {ForgeError} When credentials are missing or the key cannot sign.
|
|
94
|
+
*/
|
|
95
|
+
export declare function createGitHubAppJwt(credentials: GitHubAppCredentials, now?: Date): string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Produces exact, repeatable webhook bytes and headers for integration suites.
|
|
99
|
+
* Pass the same delivery id for duplicates, or a new id with the same payload
|
|
100
|
+
* for a provider redelivery.
|
|
101
|
+
* @param options Secret, delivery identity, event name, and payload.
|
|
102
|
+
* @returns Exact bytes and matching GitHub delivery headers.
|
|
103
|
+
*/
|
|
104
|
+
export declare function createGitHubWebhookFixture(options: {
|
|
105
|
+
secret: string;
|
|
106
|
+
deliveryId: string;
|
|
107
|
+
event: string;
|
|
108
|
+
payload: unknown;
|
|
109
|
+
}): GitHubWebhookFixture;
|
|
110
|
+
|
|
33
111
|
export declare interface CreateIssueInput {
|
|
34
112
|
title: string;
|
|
35
113
|
body?: string;
|
|
@@ -81,6 +159,272 @@ export declare function detectTemplateFromLabels(labels: string[], templates: Is
|
|
|
81
159
|
*/
|
|
82
160
|
export declare function fetchIssueTemplates(repo: IRepository): Promise<IssueTemplate[]>;
|
|
83
161
|
|
|
162
|
+
/** Actor identity supplied by a forge event. */
|
|
163
|
+
export declare interface ForgeActor {
|
|
164
|
+
id?: string;
|
|
165
|
+
login: string;
|
|
166
|
+
type?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Provider health or webhook availability observation. */
|
|
170
|
+
export declare interface ForgeAvailabilityObservation extends ForgeObservationBase {
|
|
171
|
+
kind: 'availability';
|
|
172
|
+
available: boolean;
|
|
173
|
+
message?: string;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export declare type ForgeCheckConclusion = 'action_required' | 'cancelled' | 'failure' | 'neutral' | 'skipped' | 'stale' | 'startup_failure' | 'success' | 'timed_out';
|
|
177
|
+
|
|
178
|
+
/** Check-run or check-suite observation. */
|
|
179
|
+
export declare interface ForgeCheckObservation extends ForgeObservationBase {
|
|
180
|
+
kind: 'check';
|
|
181
|
+
check: CheckRun;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export declare type ForgeCheckStatus = 'queued' | 'in_progress' | 'completed';
|
|
185
|
+
|
|
186
|
+
/** Deployment or deployment-status observation. */
|
|
187
|
+
export declare interface ForgeDeploymentObservation extends ForgeObservationBase {
|
|
188
|
+
kind: 'deployment';
|
|
189
|
+
deployment: {
|
|
190
|
+
id: string;
|
|
191
|
+
sha?: string;
|
|
192
|
+
ref?: string;
|
|
193
|
+
environment?: string;
|
|
194
|
+
state?: string;
|
|
195
|
+
url?: string;
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export declare class ForgeError extends Error {
|
|
200
|
+
readonly provider?: ForgeProvider;
|
|
201
|
+
readonly code: ForgeErrorCode;
|
|
202
|
+
readonly status?: number;
|
|
203
|
+
readonly requestId?: string;
|
|
204
|
+
readonly rateLimit?: ForgeRateLimit;
|
|
205
|
+
readonly details?: unknown;
|
|
206
|
+
readonly retryable: boolean;
|
|
207
|
+
constructor(message: string, code: ForgeErrorCode, options?: {
|
|
208
|
+
cause?: unknown;
|
|
209
|
+
provider?: ForgeProvider;
|
|
210
|
+
status?: number;
|
|
211
|
+
requestId?: string;
|
|
212
|
+
rateLimit?: ForgeRateLimit;
|
|
213
|
+
details?: unknown;
|
|
214
|
+
retryable?: boolean;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export declare type ForgeErrorCode = 'AUTHENTICATION_FAILED' | 'AUTHORITY_MISMATCH' | 'CONFIGURATION_ERROR' | 'INVALID_INPUT' | 'NOT_FOUND' | 'PROVIDER_ERROR' | 'RATE_LIMITED' | 'SIGNATURE_INVALID' | 'TRANSPORT_ERROR';
|
|
219
|
+
|
|
220
|
+
/** Verified delivery envelope retaining the parsed provider payload. */
|
|
221
|
+
export declare interface ForgeEventEnvelope<TObservation extends ForgeObservation = ForgeObservation> {
|
|
222
|
+
provider: ForgeProvider;
|
|
223
|
+
deliveryId: string;
|
|
224
|
+
event: string;
|
|
225
|
+
action?: string;
|
|
226
|
+
occurredAt?: Date;
|
|
227
|
+
receivedAt: Date;
|
|
228
|
+
installation?: ForgeInstallationRef;
|
|
229
|
+
repository?: ForgeRepositoryRef;
|
|
230
|
+
actor?: ForgeActor;
|
|
231
|
+
observation: TObservation;
|
|
232
|
+
/** Original parsed provider payload. Raw request bytes remain caller-owned. */
|
|
233
|
+
raw: unknown;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/** Installation lifecycle or repository-scope observation. */
|
|
237
|
+
export declare interface ForgeInstallationObservation extends ForgeObservationBase {
|
|
238
|
+
kind: 'installation';
|
|
239
|
+
installation: ForgeInstallationRef;
|
|
240
|
+
repositories?: readonly ForgeRepositoryRef[];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Installation identity associated with provider authority. */
|
|
244
|
+
export declare interface ForgeInstallationRef {
|
|
245
|
+
id: string;
|
|
246
|
+
account?: string;
|
|
247
|
+
repositorySelection?: 'all' | 'selected';
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Merge-queue group observation tied to its synthetic head revision. */
|
|
251
|
+
export declare interface ForgeMergeGroupObservation extends ForgeObservationBase {
|
|
252
|
+
kind: 'merge_group';
|
|
253
|
+
headSha: string;
|
|
254
|
+
headRef?: string;
|
|
255
|
+
baseSha?: string;
|
|
256
|
+
baseRef?: string;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** Completed pull-request merge observation. */
|
|
260
|
+
export declare interface ForgeMergeObservation extends ForgeObservationBase {
|
|
261
|
+
kind: 'merge';
|
|
262
|
+
pullRequest: ForgePullRequestRef;
|
|
263
|
+
mergeCommitSha?: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export declare type ForgeObservation = ForgeAvailabilityObservation | ForgeCheckObservation | ForgeDeploymentObservation | ForgeInstallationObservation | ForgeMergeGroupObservation | ForgeMergeObservation | ForgePullRequestObservation | ForgePushObservation | ForgeRepositoryObservation | ForgeReviewObservation | ForgeStatusObservation | ForgeUnknownObservation;
|
|
267
|
+
|
|
268
|
+
/** Shared discriminator implemented by every normalized observation. */
|
|
269
|
+
declare interface ForgeObservationBase {
|
|
270
|
+
kind: 'availability' | 'check' | 'deployment' | 'installation' | 'merge' | 'merge_group' | 'pull_request' | 'push' | 'repository' | 'review' | 'status' | 'unknown';
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Provider-neutral forge reconciliation and check-publishing operations. */
|
|
274
|
+
export declare interface ForgeOperations {
|
|
275
|
+
/** Returns the configured repository. */
|
|
276
|
+
getRepository(): Promise<ForgeResponse<ForgeRepositoryRef>>;
|
|
277
|
+
/** Returns one pull request by repository-local number. */
|
|
278
|
+
getPullRequest(number: number): Promise<ForgeResponse<ForgePullRequestRef>>;
|
|
279
|
+
/** Returns provider review payloads for one pull request. */
|
|
280
|
+
listPullRequestReviews(number: number): Promise<ForgeResponse<readonly unknown[]>>;
|
|
281
|
+
/** Returns one commit payload by SHA. */
|
|
282
|
+
getCommit(sha: string): Promise<ForgeResponse<unknown>>;
|
|
283
|
+
/** Returns complete commit-status history across provider pages. */
|
|
284
|
+
listCommitStatuses(sha: string): Promise<ForgeResponse<readonly CommitStatus[]>>;
|
|
285
|
+
/** Publishes one commit status. */
|
|
286
|
+
createCommitStatus(input: CreateCommitStatusInput): Promise<ForgeResponse<CommitStatus>>;
|
|
287
|
+
/** Returns complete check history, including reruns, across provider pages. */
|
|
288
|
+
listCheckRuns(sha: string): Promise<ForgeResponse<readonly CheckRun[]>>;
|
|
289
|
+
/** Publishes one check run. */
|
|
290
|
+
createCheckRun(input: CreateCheckRunInput): Promise<ForgeResponse<CheckRun>>;
|
|
291
|
+
/** Changes one check run by provider ID. */
|
|
292
|
+
updateCheckRun(id: string, input: UpdateCheckRunInput): Promise<ForgeResponse<CheckRun>>;
|
|
293
|
+
/** Lists deployments using narrow optional filters. */
|
|
294
|
+
listDeployments(options?: {
|
|
295
|
+
sha?: string;
|
|
296
|
+
environment?: string;
|
|
297
|
+
limit?: number;
|
|
298
|
+
}): Promise<ForgeResponse<unknown[]>>;
|
|
299
|
+
/** Returns one deployment by provider ID. */
|
|
300
|
+
getDeployment(id: string): Promise<ForgeResponse<unknown>>;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
export declare type ForgeProvider = 'github' | (string & {});
|
|
304
|
+
|
|
305
|
+
/** Pull-request lifecycle or revision observation. */
|
|
306
|
+
export declare interface ForgePullRequestObservation extends ForgeObservationBase {
|
|
307
|
+
kind: 'pull_request';
|
|
308
|
+
pullRequest: ForgePullRequestRef;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Pull-request identity and exact revision references. */
|
|
312
|
+
export declare interface ForgePullRequestRef {
|
|
313
|
+
id?: string;
|
|
314
|
+
number: number;
|
|
315
|
+
state: 'open' | 'closed';
|
|
316
|
+
draft?: boolean;
|
|
317
|
+
headSha: string;
|
|
318
|
+
headRef?: string;
|
|
319
|
+
baseSha?: string;
|
|
320
|
+
baseRef?: string;
|
|
321
|
+
merged?: boolean;
|
|
322
|
+
mergeCommitSha?: string;
|
|
323
|
+
url?: string;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** Git reference update observation. */
|
|
327
|
+
export declare interface ForgePushObservation extends ForgeObservationBase {
|
|
328
|
+
kind: 'push';
|
|
329
|
+
ref: string;
|
|
330
|
+
beforeSha?: string;
|
|
331
|
+
afterSha: string;
|
|
332
|
+
forced?: boolean;
|
|
333
|
+
created?: boolean;
|
|
334
|
+
deleted?: boolean;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/** Provider quota information captured from one forge response. */
|
|
338
|
+
export declare interface ForgeRateLimit {
|
|
339
|
+
limit?: number;
|
|
340
|
+
remaining?: number;
|
|
341
|
+
used?: number;
|
|
342
|
+
resetAt?: Date;
|
|
343
|
+
retryAfterMs?: number;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Repository lifecycle or metadata observation. */
|
|
347
|
+
export declare interface ForgeRepositoryObservation extends ForgeObservationBase {
|
|
348
|
+
kind: 'repository';
|
|
349
|
+
repository: ForgeRepositoryRef;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** Provider-neutral repository identity and reconciled attributes. */
|
|
353
|
+
export declare interface ForgeRepositoryRef {
|
|
354
|
+
id?: string;
|
|
355
|
+
owner: string;
|
|
356
|
+
name: string;
|
|
357
|
+
fullName: string;
|
|
358
|
+
defaultBranch?: string;
|
|
359
|
+
private?: boolean;
|
|
360
|
+
url?: string;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/** Provider data paired with concurrency-safe request metadata. */
|
|
364
|
+
export declare interface ForgeResponse<T> {
|
|
365
|
+
data: T;
|
|
366
|
+
metadata: ForgeResponseMetadata;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Metadata for the same provider request that produced a response. */
|
|
370
|
+
export declare interface ForgeResponseMetadata {
|
|
371
|
+
provider: ForgeProvider;
|
|
372
|
+
requestId?: string;
|
|
373
|
+
status: number;
|
|
374
|
+
rateLimit?: ForgeRateLimit;
|
|
375
|
+
pagination?: {
|
|
376
|
+
pages: number;
|
|
377
|
+
totalCount?: number;
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** Pull-request review observation tied to an exact commit when available. */
|
|
382
|
+
export declare interface ForgeReviewObservation extends ForgeObservationBase {
|
|
383
|
+
kind: 'review';
|
|
384
|
+
pullRequest: ForgePullRequestRef;
|
|
385
|
+
review: {
|
|
386
|
+
id: string;
|
|
387
|
+
state: string;
|
|
388
|
+
body?: string;
|
|
389
|
+
commitSha?: string;
|
|
390
|
+
submittedAt?: Date;
|
|
391
|
+
author?: ForgeActor;
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export declare class ForgeSignatureError extends ForgeError {
|
|
396
|
+
constructor(message?: string);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Commit-status observation. */
|
|
400
|
+
export declare interface ForgeStatusObservation extends ForgeObservationBase {
|
|
401
|
+
kind: 'status';
|
|
402
|
+
status: CommitStatus;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
/** Executes authenticated provider requests and normalizes their metadata. */
|
|
406
|
+
export declare interface ForgeTransport {
|
|
407
|
+
/**
|
|
408
|
+
* Executes one provider request.
|
|
409
|
+
* @throws {ForgeError} When transport or provider processing fails.
|
|
410
|
+
*/
|
|
411
|
+
request<T>(request: ForgeTransportRequest): Promise<ForgeResponse<T>>;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Provider-neutral HTTP request accepted by a forge transport. */
|
|
415
|
+
export declare interface ForgeTransportRequest {
|
|
416
|
+
method: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT';
|
|
417
|
+
path: string;
|
|
418
|
+
body?: unknown;
|
|
419
|
+
headers?: Readonly<Record<string, string>>;
|
|
420
|
+
signal?: AbortSignal;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/** Forward-compatible observation for an unsupported provider event. */
|
|
424
|
+
export declare interface ForgeUnknownObservation extends ForgeObservationBase {
|
|
425
|
+
kind: 'unknown';
|
|
426
|
+
}
|
|
427
|
+
|
|
84
428
|
/**
|
|
85
429
|
* Get a specific field value from an issue body
|
|
86
430
|
*
|
|
@@ -122,6 +466,172 @@ export declare function getIssueField(body: string, fieldIdOrLabel: string, temp
|
|
|
122
466
|
*/
|
|
123
467
|
export declare function getRepository(options: RepositoryConfig | IRepository): Promise<IRepository>;
|
|
124
468
|
|
|
469
|
+
/**
|
|
470
|
+
* Request/job-scoped GitHub App authority.
|
|
471
|
+
*
|
|
472
|
+
* Keep this object inside a single request or job. Its token cache and in-flight
|
|
473
|
+
* acquisitions are instance fields, so installations cannot share credentials.
|
|
474
|
+
*/
|
|
475
|
+
export declare class GitHubAppAuth {
|
|
476
|
+
private readonly credentials;
|
|
477
|
+
private readonly baseUrl?;
|
|
478
|
+
private readonly fetchImplementation?;
|
|
479
|
+
private readonly now;
|
|
480
|
+
private readonly expirySkewMs;
|
|
481
|
+
private readonly tokens;
|
|
482
|
+
private readonly issuedTokens;
|
|
483
|
+
private readonly tokenRequests;
|
|
484
|
+
private readonly authorizationRequests;
|
|
485
|
+
private readonly revokedInstallations;
|
|
486
|
+
private nextTokenGeneration;
|
|
487
|
+
/**
|
|
488
|
+
* Creates isolated GitHub App authority from credentials and dependencies.
|
|
489
|
+
* @param options Credentials, clock, provider URL, and fetch override.
|
|
490
|
+
*/
|
|
491
|
+
constructor(options: GitHubAppAuthOptions);
|
|
492
|
+
/**
|
|
493
|
+
* Clears locally cached credentials without remote revocation.
|
|
494
|
+
* @param installationId Optional installation to clear; omitted clears all.
|
|
495
|
+
* @returns Nothing.
|
|
496
|
+
*/
|
|
497
|
+
clear(installationId?: string | number): void;
|
|
498
|
+
/**
|
|
499
|
+
* Acquires and verifies one installation/repository boundary.
|
|
500
|
+
* @param scope Installation ID and exact repository coordinates.
|
|
501
|
+
* @returns An isolated forge provider and revocation handle.
|
|
502
|
+
* @throws {ForgeError} When authentication, provider access, or scope fails.
|
|
503
|
+
*/
|
|
504
|
+
createInstallationContext(scope: GitHubInstallationScope): Promise<GitHubInstallationContext>;
|
|
505
|
+
private getAuthorizedToken;
|
|
506
|
+
private getInstallationToken;
|
|
507
|
+
private acquireInstallationToken;
|
|
508
|
+
private verifyRepositoryScope;
|
|
509
|
+
private revokeInstallationTokens;
|
|
510
|
+
private revokeToken;
|
|
511
|
+
private clearCachedInstallation;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/** Construction options for one request/job-scoped GitHub App authority. */
|
|
515
|
+
export declare interface GitHubAppAuthOptions extends GitHubAppCredentials {
|
|
516
|
+
baseUrl?: string;
|
|
517
|
+
fetch?: typeof globalThis.fetch;
|
|
518
|
+
now?: () => Date;
|
|
519
|
+
/** Refresh before provider expiry. Defaults to 60 seconds. */
|
|
520
|
+
expirySkewMs?: number;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/** Credentials required to sign GitHub App JSON Web Tokens. */
|
|
524
|
+
export declare interface GitHubAppCredentials {
|
|
525
|
+
appId: string | number;
|
|
526
|
+
privateKey: string;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Repository-scoped GitHub implementation of provider-neutral forge operations.
|
|
531
|
+
* Every operation may throw `ForgeError` for transport or provider failures.
|
|
532
|
+
*/
|
|
533
|
+
export declare class GitHubForgeProvider implements ForgeOperations {
|
|
534
|
+
private readonly transport;
|
|
535
|
+
private readonly path;
|
|
536
|
+
/**
|
|
537
|
+
* Creates a repository-scoped GitHub forge provider.
|
|
538
|
+
* @param options Repository coordinates and authenticated transport.
|
|
539
|
+
*/
|
|
540
|
+
constructor(options: GitHubForgeProviderOptions);
|
|
541
|
+
/** @returns Normalized repository data and request metadata. */
|
|
542
|
+
getRepository(): Promise<ForgeResponse<ForgeRepositoryRef>>;
|
|
543
|
+
/**
|
|
544
|
+
* Returns one normalized pull request.
|
|
545
|
+
* @param number Repository-local pull-request number.
|
|
546
|
+
* @returns Pull-request data and request metadata.
|
|
547
|
+
* @throws {ForgeError} When GitHub rejects the request.
|
|
548
|
+
*/
|
|
549
|
+
getPullRequest(number: number): Promise<ForgeResponse<ForgePullRequestRef>>;
|
|
550
|
+
/**
|
|
551
|
+
* Lists every raw provider review for one pull request.
|
|
552
|
+
* @param number Repository-local pull-request number.
|
|
553
|
+
* @returns All reviews and final-page request metadata.
|
|
554
|
+
*/
|
|
555
|
+
listPullRequestReviews(number: number): Promise<ForgeResponse<readonly unknown[]>>;
|
|
556
|
+
/**
|
|
557
|
+
* Returns one raw provider commit payload.
|
|
558
|
+
* @param sha Exact commit SHA.
|
|
559
|
+
* @returns Commit payload and request metadata.
|
|
560
|
+
*/
|
|
561
|
+
getCommit(sha: string): Promise<ForgeResponse<unknown>>;
|
|
562
|
+
/**
|
|
563
|
+
* Returns complete normalized commit-status history.
|
|
564
|
+
* @param sha Exact commit SHA.
|
|
565
|
+
* @returns All status pages and final-page request metadata.
|
|
566
|
+
*/
|
|
567
|
+
listCommitStatuses(sha: string): Promise<ForgeResponse<readonly CommitStatus[]>>;
|
|
568
|
+
/**
|
|
569
|
+
* Publishes one commit status.
|
|
570
|
+
* @param input Exact SHA and status attributes.
|
|
571
|
+
* @returns Published status and request metadata.
|
|
572
|
+
*/
|
|
573
|
+
createCommitStatus(input: CreateCommitStatusInput): Promise<ForgeResponse<CommitStatus>>;
|
|
574
|
+
/**
|
|
575
|
+
* Returns all normalized check runs, including reruns.
|
|
576
|
+
* @param sha Exact commit SHA.
|
|
577
|
+
* @returns All check pages and final-page request metadata.
|
|
578
|
+
*/
|
|
579
|
+
listCheckRuns(sha: string): Promise<ForgeResponse<readonly CheckRun[]>>;
|
|
580
|
+
/**
|
|
581
|
+
* Publishes one check run.
|
|
582
|
+
* @param input Check identity, exact head SHA, state, and output.
|
|
583
|
+
* @returns Published check and request metadata.
|
|
584
|
+
*/
|
|
585
|
+
createCheckRun(input: CreateCheckRunInput): Promise<ForgeResponse<CheckRun>>;
|
|
586
|
+
/**
|
|
587
|
+
* Changes one check run by provider ID.
|
|
588
|
+
* @param id GitHub check-run ID.
|
|
589
|
+
* @param input Attributes to change.
|
|
590
|
+
* @returns Updated check and request metadata.
|
|
591
|
+
*/
|
|
592
|
+
updateCheckRun(id: string, input: UpdateCheckRunInput): Promise<ForgeResponse<CheckRun>>;
|
|
593
|
+
/**
|
|
594
|
+
* Lists raw deployment payloads using narrow filters.
|
|
595
|
+
* @param options Optional SHA, environment, and result limit.
|
|
596
|
+
* @returns Matching deployments and request metadata.
|
|
597
|
+
*/
|
|
598
|
+
listDeployments(options?: {
|
|
599
|
+
sha?: string;
|
|
600
|
+
environment?: string;
|
|
601
|
+
limit?: number;
|
|
602
|
+
}): Promise<ForgeResponse<unknown[]>>;
|
|
603
|
+
/**
|
|
604
|
+
* Returns one raw deployment payload.
|
|
605
|
+
* @param id GitHub deployment ID.
|
|
606
|
+
* @returns Deployment payload and request metadata.
|
|
607
|
+
*/
|
|
608
|
+
getDeployment(id: string): Promise<ForgeResponse<unknown>>;
|
|
609
|
+
private paginate;
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/** Repository coordinates and transport for a GitHub forge provider. */
|
|
613
|
+
export declare interface GitHubForgeProviderOptions {
|
|
614
|
+
owner: string;
|
|
615
|
+
repo: string;
|
|
616
|
+
transport: ForgeTransport;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
/** Authorized repository client and explicit token-revocation handle. */
|
|
620
|
+
export declare interface GitHubInstallationContext {
|
|
621
|
+
installation: ForgeInstallationRef;
|
|
622
|
+
repository: ForgeRepositoryRef;
|
|
623
|
+
forge: GitHubForgeProvider;
|
|
624
|
+
/** Revokes issued tokens remotely and closes this local context. */
|
|
625
|
+
revoke(): Promise<void>;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** Installation and repository boundary requested by a caller. */
|
|
629
|
+
export declare interface GitHubInstallationScope {
|
|
630
|
+
installationId: string | number;
|
|
631
|
+
owner: string;
|
|
632
|
+
repo: string;
|
|
633
|
+
}
|
|
634
|
+
|
|
125
635
|
/**
|
|
126
636
|
* GitHub repository implementation
|
|
127
637
|
*/
|
|
@@ -164,6 +674,40 @@ export declare class GitHubRepository implements IRepository {
|
|
|
164
674
|
findIssueForPR(prNumber: number): Promise<Issue | null>;
|
|
165
675
|
getFileContent(path: string, ref?: string): Promise<string | null>;
|
|
166
676
|
listDirectoryFiles(path: string, ref?: string): Promise<string[]>;
|
|
677
|
+
/**
|
|
678
|
+
* Publishes one GitHub commit status.
|
|
679
|
+
* @param input Exact commit SHA and status attributes.
|
|
680
|
+
* @returns Normalized published status.
|
|
681
|
+
*/
|
|
682
|
+
createCommitStatus(input: CreateCommitStatusInput): Promise<CommitStatus>;
|
|
683
|
+
/**
|
|
684
|
+
* Returns complete commit-status history across GitHub pages.
|
|
685
|
+
* @param sha Exact commit SHA.
|
|
686
|
+
* @returns Every normalized status for the commit.
|
|
687
|
+
*/
|
|
688
|
+
listCommitStatuses(sha: string): Promise<readonly CommitStatus[]>;
|
|
689
|
+
/**
|
|
690
|
+
* Publishes one GitHub check run.
|
|
691
|
+
* @param input Check identity, exact head SHA, state, and output.
|
|
692
|
+
* @returns Normalized published check run.
|
|
693
|
+
*/
|
|
694
|
+
createCheckRun(input: CreateCheckRunInput): Promise<CheckRun>;
|
|
695
|
+
/**
|
|
696
|
+
* Changes one GitHub check run.
|
|
697
|
+
* @param id GitHub check-run ID.
|
|
698
|
+
* @param input Attributes to change.
|
|
699
|
+
* @returns Normalized updated check run.
|
|
700
|
+
*/
|
|
701
|
+
updateCheckRun(id: string, input: UpdateCheckRunInput): Promise<CheckRun>;
|
|
702
|
+
/**
|
|
703
|
+
* Returns complete GitHub check history, including reruns.
|
|
704
|
+
* @param sha Exact commit SHA.
|
|
705
|
+
* @returns Every normalized check run for the commit.
|
|
706
|
+
*/
|
|
707
|
+
listCheckRuns(sha: string): Promise<readonly CheckRun[]>;
|
|
708
|
+
private mapCommitStatus;
|
|
709
|
+
private mapCheckRunInput;
|
|
710
|
+
private mapCheckRun;
|
|
167
711
|
/**
|
|
168
712
|
* Create a new repository from this repository as a template.
|
|
169
713
|
*
|
|
@@ -173,6 +717,75 @@ export declare class GitHubRepository implements IRepository {
|
|
|
173
717
|
createRepositoryFromTemplate(options: CreateFromTemplateOptions): Promise<Repository>;
|
|
174
718
|
}
|
|
175
719
|
|
|
720
|
+
export declare type GitHubTokenSource = string | (() => string | Promise<string>);
|
|
721
|
+
|
|
722
|
+
export declare class GitHubTransport implements ForgeTransport {
|
|
723
|
+
private readonly token;
|
|
724
|
+
private readonly baseUrl;
|
|
725
|
+
private readonly fetchImplementation;
|
|
726
|
+
/**
|
|
727
|
+
* Creates a GitHub REST transport with fixed or lazy credentials.
|
|
728
|
+
* @param options Token source, provider URL, and fetch override.
|
|
729
|
+
*/
|
|
730
|
+
constructor(options: GitHubTransportOptions);
|
|
731
|
+
/**
|
|
732
|
+
* Executes one GitHub REST request.
|
|
733
|
+
* @param request Method, provider-relative path, body, headers, and signal.
|
|
734
|
+
* @returns Parsed data and metadata for this exact request.
|
|
735
|
+
* @throws {ForgeError} For transport, authentication, rate, or provider failures.
|
|
736
|
+
*/
|
|
737
|
+
request<T>(request: ForgeTransportRequest): Promise<ForgeResponse<T>>;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/** Construction options for an authenticated GitHub REST transport. */
|
|
741
|
+
export declare interface GitHubTransportOptions {
|
|
742
|
+
token: GitHubTokenSource;
|
|
743
|
+
baseUrl?: string;
|
|
744
|
+
fetch?: typeof globalThis.fetch;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/** Exact webhook bytes and headers suitable for deterministic tests. */
|
|
748
|
+
export declare interface GitHubWebhookFixture {
|
|
749
|
+
rawBody: Uint8Array;
|
|
750
|
+
headers: GitHubWebhookHeaders;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export declare type GitHubWebhookHeaders = Headers | Readonly<Record<string, string | readonly string[] | undefined>>;
|
|
754
|
+
|
|
755
|
+
export declare class GitHubWebhookVerifier {
|
|
756
|
+
private readonly secrets;
|
|
757
|
+
private readonly now;
|
|
758
|
+
/**
|
|
759
|
+
* Creates a verifier with a current secret and optional rotation secrets.
|
|
760
|
+
* @param options Current/rotation secrets and optional clock.
|
|
761
|
+
* @throws {ForgeError} When no non-empty secret is configured.
|
|
762
|
+
*/
|
|
763
|
+
constructor(options: GitHubWebhookVerifierOptions);
|
|
764
|
+
/**
|
|
765
|
+
* Verifies unchanged provider bytes with constant-time comparisons.
|
|
766
|
+
* @param rawBody Exact bytes received from the HTTP server.
|
|
767
|
+
* @param signature GitHub SHA-256 signature header.
|
|
768
|
+
* @returns Index of the configured secret that matched.
|
|
769
|
+
* @throws {ForgeSignatureError} When the signature is missing or invalid.
|
|
770
|
+
*/
|
|
771
|
+
verify(rawBody: Uint8Array, signature: string | undefined): number;
|
|
772
|
+
/**
|
|
773
|
+
* Verifies raw bytes before decoding and normalizes the delivery.
|
|
774
|
+
* @param rawBody Exact bytes received from the HTTP server.
|
|
775
|
+
* @param headers Case-insensitive GitHub delivery headers.
|
|
776
|
+
* @returns Verified normalized delivery.
|
|
777
|
+
* @throws {ForgeError} For invalid signatures, headers, UTF-8, or JSON.
|
|
778
|
+
*/
|
|
779
|
+
verifyAndNormalize(rawBody: Uint8Array, headers: GitHubWebhookHeaders): ForgeEventEnvelope;
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/** Construction options for raw GitHub webhook verification. */
|
|
783
|
+
export declare interface GitHubWebhookVerifierOptions {
|
|
784
|
+
/** Current secret first, followed by still-valid rotation secrets. */
|
|
785
|
+
secrets: string | readonly string[];
|
|
786
|
+
now?: () => Date;
|
|
787
|
+
}
|
|
788
|
+
|
|
176
789
|
/**
|
|
177
790
|
* Repository interface - all repository implementations must implement this
|
|
178
791
|
*/
|
|
@@ -210,6 +823,16 @@ export declare interface IRepository {
|
|
|
210
823
|
findIssueForPR(prNumber: number): Promise<Issue | null>;
|
|
211
824
|
getFileContent(path: string, ref?: string): Promise<string | null>;
|
|
212
825
|
listDirectoryFiles(path: string, ref?: string): Promise<string[]>;
|
|
826
|
+
/** Publishes one provider commit status. */
|
|
827
|
+
createCommitStatus?(input: CreateCommitStatusInput): Promise<CommitStatus>;
|
|
828
|
+
/** Returns complete commit-status history across provider pages. */
|
|
829
|
+
listCommitStatuses?(sha: string): Promise<readonly CommitStatus[]>;
|
|
830
|
+
/** Publishes one provider check run. */
|
|
831
|
+
createCheckRun?(input: CreateCheckRunInput): Promise<CheckRun>;
|
|
832
|
+
/** Changes one provider check run. */
|
|
833
|
+
updateCheckRun?(id: string, input: UpdateCheckRunInput): Promise<CheckRun>;
|
|
834
|
+
/** Returns complete check history, including reruns, across provider pages. */
|
|
835
|
+
listCheckRuns?(sha: string): Promise<readonly CheckRun[]>;
|
|
213
836
|
}
|
|
214
837
|
|
|
215
838
|
export declare interface Issue {
|
|
@@ -261,6 +884,16 @@ export declare function loadIssueTemplate(yamlPath: string): Promise<IssueTempla
|
|
|
261
884
|
|
|
262
885
|
export declare type MergeMethod = 'merge' | 'squash' | 'rebase';
|
|
263
886
|
|
|
887
|
+
/**
|
|
888
|
+
* Normalizes one already-verified GitHub payload.
|
|
889
|
+
* @param deliveryId Stable provider delivery identity.
|
|
890
|
+
* @param event GitHub event header value.
|
|
891
|
+
* @param raw Parsed provider payload.
|
|
892
|
+
* @param receivedAt Local receipt timestamp.
|
|
893
|
+
* @returns A provider-neutral event envelope preserving the parsed payload.
|
|
894
|
+
*/
|
|
895
|
+
export declare function normalizeGitHubWebhook(deliveryId: string, event: string, raw: unknown, receivedAt?: Date): ForgeEventEnvelope;
|
|
896
|
+
|
|
264
897
|
/**
|
|
265
898
|
* Parse an issue body into field values
|
|
266
899
|
*
|
|
@@ -422,6 +1055,11 @@ export declare interface TemplateField {
|
|
|
422
1055
|
};
|
|
423
1056
|
}
|
|
424
1057
|
|
|
1058
|
+
/** Input for changing an existing provider check run. */
|
|
1059
|
+
export declare interface UpdateCheckRunInput extends Omit<CreateCheckRunInput, 'name' | 'headSha'> {
|
|
1060
|
+
name?: string;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
425
1063
|
/**
|
|
426
1064
|
* Update a specific field in an issue body
|
|
427
1065
|
*
|