@bridge-ds/core 0.2.0 → 0.4.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/bridge.config.schema.json +74 -5
- package/dist/audit/index.js +1 -1
- package/dist/change-drafts.d.ts +29 -0
- package/dist/{component-spec-B0V_D3gM.js → component-spec-cvrSvIZj.js} +628 -140
- package/dist/component-spec-cvrSvIZj.js.map +1 -0
- package/dist/config.d.ts +16 -2
- package/dist/css-overrides.d.ts +11 -0
- package/dist/docs-ai.d.ts +116 -0
- package/dist/docs-draft.d.ts +30 -4
- package/dist/draft-exchange.d.ts +135 -14
- package/dist/explorations-github.d.ts +43 -5
- package/dist/explorations.d.ts +40 -28
- package/dist/github-client.d.ts +125 -2
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1955 -647
- package/dist/index.js.map +1 -1
- package/dist/{layered-DGate4nv.js → layered-BnbmToGs.js} +10 -10
- package/dist/{layered-DGate4nv.js.map → layered-BnbmToGs.js.map} +1 -1
- package/dist/node/index.js +3 -3
- package/dist/previews-github.d.ts +22 -0
- package/dist/previews.d.ts +102 -0
- package/dist/protection-github.d.ts +25 -0
- package/dist/protection.d.ts +139 -0
- package/dist/{report-tNzTriGF.js → report-Bf2HEr9t.js} +2 -2
- package/dist/{report-tNzTriGF.js.map → report-Bf2HEr9t.js.map} +1 -1
- package/dist/requests-github.d.ts +21 -0
- package/dist/requests.d.ts +16 -1
- package/dist/rights.d.ts +63 -0
- package/dist/teams.d.ts +149 -0
- package/dist/token-combine.d.ts +78 -0
- package/dist/token-merge.d.ts +72 -0
- package/package.json +1 -1
- package/dist/component-spec-B0V_D3gM.js.map +0 -1
package/dist/github-client.d.ts
CHANGED
|
@@ -1,9 +1,59 @@
|
|
|
1
1
|
import { type BridgeConfig } from './config';
|
|
2
|
+
import type { ClassicProtection, Ruleset, RulesetPayload } from './protection';
|
|
3
|
+
/**
|
|
4
|
+
* What an auth failure means for the token:
|
|
5
|
+
* - "rejected": GitHub refused the token itself (401). It was revoked, regenerated or has expired; every call
|
|
6
|
+
* with it will fail until it is replaced.
|
|
7
|
+
* - "missing-permission": the token works but lacks a permission this call needs (403 "Resource not accessible
|
|
8
|
+
* by personal access token", or a permission GitHub names in X-Accepted-GitHub-Permissions).
|
|
9
|
+
* Undefined for everything else, including rate limits and a missing token.
|
|
10
|
+
*/
|
|
11
|
+
export type GitHubAuthState = 'rejected' | 'missing-permission';
|
|
12
|
+
/** Fine-grained token permission names, as GitHub spells them (issues, pull_requests, contents...). */
|
|
13
|
+
export type GitHubPermission = string;
|
|
14
|
+
export interface GitHubErrorInfo {
|
|
15
|
+
auth?: GitHubAuthState | undefined;
|
|
16
|
+
/** The permission the call needed, when GitHub or the endpoint tells (only with auth "missing-permission"). */
|
|
17
|
+
permission?: GitHubPermission | undefined;
|
|
18
|
+
}
|
|
2
19
|
export declare class GitHubError extends Error {
|
|
3
20
|
readonly status: number;
|
|
4
21
|
readonly detail?: string | undefined;
|
|
5
|
-
|
|
22
|
+
/** Set when the failure is about the token: rejected (401) or missing a permission (403). */
|
|
23
|
+
readonly auth: GitHubAuthState | undefined;
|
|
24
|
+
/** With auth "missing-permission": the permission the call needed, when known. */
|
|
25
|
+
readonly permission: GitHubPermission | undefined;
|
|
26
|
+
constructor(status: number, message: string, detail?: string | undefined, info?: GitHubErrorInfo);
|
|
6
27
|
}
|
|
28
|
+
/** True when `err` says GitHub refused the token itself (revoked, regenerated or expired). */
|
|
29
|
+
export declare const isTokenRejected: (err: unknown) => boolean;
|
|
30
|
+
/** True when `err` says the token works but lacks a permission for that call. */
|
|
31
|
+
export declare const isMissingPermission: (err: unknown) => boolean;
|
|
32
|
+
/** "pull_requests" -> "Pull requests", as GitHub labels it on the token page. */
|
|
33
|
+
export declare function permissionLabel(permission: GitHubPermission): string;
|
|
34
|
+
/** Where a fine-grained token's permissions are edited. */
|
|
35
|
+
export declare const TOKEN_SETTINGS_URL = "https://github.com/settings/personal-access-tokens";
|
|
36
|
+
/** The one sentence for a token GitHub no longer accepts. */
|
|
37
|
+
export declare const TOKEN_REJECTED_MESSAGE = "Your GitHub token stopped working. It was revoked, regenerated or has expired: replace it with a new one.";
|
|
38
|
+
/**
|
|
39
|
+
* "This token cannot create issues. Add Issues: Read and write on GitHub." `action` is a verb phrase
|
|
40
|
+
* ("create issues"); without it the sentence names only the permission.
|
|
41
|
+
*/
|
|
42
|
+
export declare function missingPermissionMessage(permission: GitHubPermission | undefined, action?: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* The permission a refused call needed. GitHub names it in X-Accepted-GitHub-Permissions ("issues=write",
|
|
45
|
+
* alternatives split by ";"); otherwise the endpoint says it (/issues, /pulls, /contents, /git...).
|
|
46
|
+
*/
|
|
47
|
+
export declare function requiredPermission(path: string, acceptedHeader?: string | null): GitHubPermission | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Classifies a GitHub error response for the token. 401 with a token sent = rejected. 403 (not a rate limit,
|
|
50
|
+
* not archived) where GitHub names a permission or says the resource is not accessible = missing permission.
|
|
51
|
+
*/
|
|
52
|
+
export declare function classifyAuth(status: number, detail: string, opts?: {
|
|
53
|
+
path?: string;
|
|
54
|
+
acceptedPermissions?: string | null;
|
|
55
|
+
withToken?: boolean;
|
|
56
|
+
}): GitHubErrorInfo;
|
|
7
57
|
export interface RepoInfo {
|
|
8
58
|
fullName: string;
|
|
9
59
|
defaultBranch: string;
|
|
@@ -80,6 +130,8 @@ export interface CheckRun {
|
|
|
80
130
|
status: string;
|
|
81
131
|
conclusion: string | null;
|
|
82
132
|
url: string | undefined;
|
|
133
|
+
/** Slug of the GitHub App that reported it ("github-actions", "vercel"), when GitHub says. */
|
|
134
|
+
app?: string | undefined;
|
|
83
135
|
}
|
|
84
136
|
export interface CommitSummary {
|
|
85
137
|
sha: string;
|
|
@@ -220,6 +272,11 @@ export declare class GitHubClient {
|
|
|
220
272
|
* markPullRequestReadyForReview, with the same token (pull requests: write).
|
|
221
273
|
*/
|
|
222
274
|
markReadyForReview(n: number): Promise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Turns an open pull request back into a draft: the GraphQL mutation convertPullRequestToDraft (REST cannot set
|
|
277
|
+
* `draft` either), same token. No-op when it is already a draft.
|
|
278
|
+
*/
|
|
279
|
+
convertToDraft(n: number): Promise<void>;
|
|
223
280
|
createPullRequest(input: {
|
|
224
281
|
title: string;
|
|
225
282
|
head: string;
|
|
@@ -231,6 +288,13 @@ export declare class GitHubClient {
|
|
|
231
288
|
/** Best effort: labels need the repo to allow it; failure is not fatal. */
|
|
232
289
|
addLabels(issueNumber: number, labels: string[]): Promise<boolean>;
|
|
233
290
|
addComment(issueNumber: number, body: string): Promise<void>;
|
|
291
|
+
/** Comments on an issue or pull request, oldest first (first 100: the sticky preview comment is posted early). */
|
|
292
|
+
listIssueComments(issueNumber: number): Promise<{
|
|
293
|
+
id: number;
|
|
294
|
+
body: string;
|
|
295
|
+
author: string;
|
|
296
|
+
updatedAt: string;
|
|
297
|
+
}[]>;
|
|
234
298
|
createIssue(input: {
|
|
235
299
|
title: string;
|
|
236
300
|
body: string;
|
|
@@ -244,6 +308,34 @@ export declare class GitHubClient {
|
|
|
244
308
|
perPage?: number;
|
|
245
309
|
}): Promise<IssueSummary[]>;
|
|
246
310
|
getIssue(n: number): Promise<IssueSummary>;
|
|
311
|
+
/** Edits an issue: its body, or closes it with a reason ("not_planned" for a declined request). */
|
|
312
|
+
updateIssue(n: number, patch: {
|
|
313
|
+
body?: string;
|
|
314
|
+
state?: 'open' | 'closed';
|
|
315
|
+
state_reason?: 'completed' | 'not_planned' | 'reopened';
|
|
316
|
+
}): Promise<IssueSummary>;
|
|
317
|
+
/** Adds people to an issue's assignees (GitHub ignores logins that cannot be assigned: the result says who is). */
|
|
318
|
+
addAssignees(n: number, logins: string[]): Promise<string[]>;
|
|
319
|
+
/** People with at least `permission` on the repository (reading the list needs push access). First 100. */
|
|
320
|
+
listCollaborators(permission?: 'pull' | 'triage' | 'push' | 'maintain' | 'admin'): Promise<{
|
|
321
|
+
login: string;
|
|
322
|
+
avatarUrl: string;
|
|
323
|
+
}[]>;
|
|
324
|
+
/** Whether a token is sent with each request (TeamReader). */
|
|
325
|
+
get hasToken(): boolean;
|
|
326
|
+
/** Every page of a list endpoint (per_page 100), up to `maxPages`. */
|
|
327
|
+
private paginate;
|
|
328
|
+
/** Every member login of an organization team (needs read:org, or Members: Read on a fine-grained token). */
|
|
329
|
+
listTeamMembers(org: string, slug: string): Promise<string[]>;
|
|
330
|
+
/** A user's membership of a team: "active", "pending", or null when GitHub says they are not a member (404). */
|
|
331
|
+
getTeamMembership(org: string, slug: string, login: string): Promise<'active' | 'pending' | null>;
|
|
332
|
+
/** "User" or "Organization" for a login, null when GitHub does not know it. */
|
|
333
|
+
getAccountType(login: string): Promise<'User' | 'Organization' | null>;
|
|
334
|
+
/** The organization's teams this token can see. */
|
|
335
|
+
listOrgTeams(org: string): Promise<{
|
|
336
|
+
slug: string;
|
|
337
|
+
name: string;
|
|
338
|
+
}[]>;
|
|
247
339
|
/** Create or update a binary file (base64 content) on a branch, e.g. a Figma export attached to a request. */
|
|
248
340
|
putBase64File(input: {
|
|
249
341
|
path: string;
|
|
@@ -311,6 +403,23 @@ export declare class GitHubClient {
|
|
|
311
403
|
conclusion: string | null;
|
|
312
404
|
}[];
|
|
313
405
|
}>;
|
|
406
|
+
/** Commit statuses of a commit, newest first (Vercel reports each project as "Vercel – <project>"). */
|
|
407
|
+
listCommitStatuses(sha: string): Promise<{
|
|
408
|
+
context: string;
|
|
409
|
+
state: string;
|
|
410
|
+
target_url: string | null;
|
|
411
|
+
description: string | null;
|
|
412
|
+
}[]>;
|
|
413
|
+
/**
|
|
414
|
+
* GitHub deployments of a commit with their latest status (environment "Preview – <project>", environment_url the
|
|
415
|
+
* preview). Latest per environment only, so it costs one read plus one per environment.
|
|
416
|
+
*/
|
|
417
|
+
listDeployments(sha: string): Promise<{
|
|
418
|
+
id: number;
|
|
419
|
+
environment: string;
|
|
420
|
+
state: string | null;
|
|
421
|
+
environmentUrl: string | null;
|
|
422
|
+
}[]>;
|
|
314
423
|
getPullRequest(n: number): Promise<PullRequest & PullRequestSummary & {
|
|
315
424
|
body: string;
|
|
316
425
|
mergeable: boolean | null;
|
|
@@ -328,6 +437,20 @@ export declare class GitHubClient {
|
|
|
328
437
|
body: string;
|
|
329
438
|
}): Promise<Review>;
|
|
330
439
|
listCheckRuns(ref: string): Promise<CheckRun[]>;
|
|
440
|
+
/** Rulesets that apply to the repository, without their rules (GET /rulesets; read access is enough). */
|
|
441
|
+
listRulesets(): Promise<Ruleset[]>;
|
|
442
|
+
/** One ruleset with its rules. */
|
|
443
|
+
getRuleset(id: number): Promise<Ruleset>;
|
|
444
|
+
/** Creates a repository ruleset. Needs admin on the repo (fine-grained token: Administration read and write). */
|
|
445
|
+
createRuleset(payload: RulesetPayload): Promise<Ruleset>;
|
|
446
|
+
/** Replaces a repository ruleset (same permissions as createRuleset). */
|
|
447
|
+
updateRuleset(id: number, payload: RulesetPayload): Promise<Ruleset>;
|
|
448
|
+
/**
|
|
449
|
+
* Classic branch protection of `branch`: the settings, null when the branch has none (404), undefined when this
|
|
450
|
+
* token cannot read them (403: the endpoint needs admin). On a 403 the public branch summary still tells
|
|
451
|
+
* whether the branch is protected at all: `protected: false` means there is nothing to read, so null.
|
|
452
|
+
*/
|
|
453
|
+
getBranchProtection(branch: string): Promise<ClassicProtection | null | undefined>;
|
|
331
454
|
/** Create a check run (needs a GitHub App token; personal tokens are refused by GitHub). */
|
|
332
455
|
createCheckRun(input: {
|
|
333
456
|
name: string;
|
|
@@ -342,7 +465,7 @@ export declare class GitHubClient {
|
|
|
342
465
|
}): Promise<CheckRun>;
|
|
343
466
|
removeLabel(issueNumber: number, label: string): Promise<void>;
|
|
344
467
|
}
|
|
345
|
-
export declare function friendlyMessage(status: number, detail: string): string;
|
|
468
|
+
export declare function friendlyMessage(status: number, detail: string, info?: GitHubErrorInfo): string;
|
|
346
469
|
export interface RepoFiles {
|
|
347
470
|
commitSha: string;
|
|
348
471
|
treeSha: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export * from './wcag';
|
|
|
10
10
|
export * from './validators';
|
|
11
11
|
export * from './id-map';
|
|
12
12
|
export * from './diff-engine';
|
|
13
|
+
export * from './token-merge';
|
|
14
|
+
export * from './token-combine';
|
|
15
|
+
export * from './css-overrides';
|
|
13
16
|
export * from './compose';
|
|
14
17
|
export * from './risk';
|
|
15
18
|
export * from './pr-composer';
|
|
@@ -18,18 +21,25 @@ export * from './layered';
|
|
|
18
21
|
export * from './token-edits';
|
|
19
22
|
export * from './layered-review';
|
|
20
23
|
export * from './governance';
|
|
24
|
+
export * from './rights';
|
|
25
|
+
export * from './teams';
|
|
26
|
+
export * from './protection';
|
|
27
|
+
export * from './protection-github';
|
|
21
28
|
export * from './usage';
|
|
22
29
|
export * from './github-client';
|
|
23
30
|
export * from './history';
|
|
24
31
|
export * from './history-github';
|
|
25
32
|
export * from './history-demo';
|
|
26
33
|
export * from './previews';
|
|
34
|
+
export * from './previews-github';
|
|
27
35
|
export * from './ramps';
|
|
28
36
|
export * from './brand';
|
|
29
37
|
export * from './docs-draft';
|
|
38
|
+
export * from './docs-ai';
|
|
30
39
|
export * from './requests';
|
|
31
40
|
export * from './change-drafts';
|
|
32
41
|
export * from './draft-exchange';
|
|
33
42
|
export * from './explorations';
|
|
34
43
|
export * from './explorations-github';
|
|
44
|
+
export * from './requests-github';
|
|
35
45
|
export * from './component-spec';
|