@theholocron/github-client 1.58.0-alpha.2 → 1.58.0-alpha.3
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/dist/index.d.mts +62 -1
- package/dist/index.mjs +21 -0
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -242,6 +242,13 @@ interface OrgProperty {
|
|
|
242
242
|
/** The values a `single_select` or `multi_select` property accepts; `null` for any other type. */
|
|
243
243
|
allowed_values?: string[] | null;
|
|
244
244
|
}
|
|
245
|
+
/** One custom property value set on a repository. */
|
|
246
|
+
interface RepoPropertyValue {
|
|
247
|
+
/** The property's name. */
|
|
248
|
+
property_name: string;
|
|
249
|
+
/** A string, a string array for `multi_select`, or `null` when unset. */
|
|
250
|
+
value: string | string[] | null;
|
|
251
|
+
}
|
|
245
252
|
interface GitHubPullRequest {
|
|
246
253
|
number: number;
|
|
247
254
|
title: string;
|
|
@@ -351,6 +358,36 @@ interface ReviewThread {
|
|
|
351
358
|
interface GitHubRepo {
|
|
352
359
|
default_branch: string;
|
|
353
360
|
full_name: string;
|
|
361
|
+
/** The repository description. */
|
|
362
|
+
description?: string | null;
|
|
363
|
+
/** The repository homepage URL. */
|
|
364
|
+
homepage?: string | null;
|
|
365
|
+
/** The topics set on the repository. */
|
|
366
|
+
topics?: string[];
|
|
367
|
+
/** Whether squash merging is allowed. */
|
|
368
|
+
allow_squash_merge?: boolean;
|
|
369
|
+
/** Whether merge commits are allowed. */
|
|
370
|
+
allow_merge_commit?: boolean;
|
|
371
|
+
/** Whether rebase merging is allowed. */
|
|
372
|
+
allow_rebase_merge?: boolean;
|
|
373
|
+
/** Whether auto-merge is allowed. */
|
|
374
|
+
allow_auto_merge?: boolean;
|
|
375
|
+
/** Whether a pull request branch can be updated from its base. */
|
|
376
|
+
allow_update_branch?: boolean;
|
|
377
|
+
/** Whether a merged pull request's branch is deleted. */
|
|
378
|
+
delete_branch_on_merge?: boolean;
|
|
379
|
+
/** Whether issues are enabled. */
|
|
380
|
+
has_issues?: boolean;
|
|
381
|
+
/** Whether discussions are enabled. */
|
|
382
|
+
has_discussions?: boolean;
|
|
383
|
+
/** Whether projects are enabled. */
|
|
384
|
+
has_projects?: boolean;
|
|
385
|
+
/** Whether the wiki is enabled. */
|
|
386
|
+
has_wiki?: boolean;
|
|
387
|
+
/** Each feature's `status` (`enabled` / `disabled`). Only an admin token sees it; absent for the rest. */
|
|
388
|
+
security_and_analysis?: Record<string, {
|
|
389
|
+
status: string;
|
|
390
|
+
} | undefined> | null;
|
|
354
391
|
}
|
|
355
392
|
interface GitHubContents {
|
|
356
393
|
content: string;
|
|
@@ -361,6 +398,16 @@ interface GitHubRuleset {
|
|
|
361
398
|
name: string;
|
|
362
399
|
enforcement: string;
|
|
363
400
|
}
|
|
401
|
+
/** One ruleset in full, as `GET /repos/{repo}/rulesets/{id}` returns it. */
|
|
402
|
+
interface GitHubRulesetDetail extends GitHubRuleset {
|
|
403
|
+
/** What the ruleset applies to, e.g. `branch`. */
|
|
404
|
+
target?: string;
|
|
405
|
+
/** Each rule has a `type`; some carry `parameters`. */
|
|
406
|
+
rules?: Array<{
|
|
407
|
+
type: string;
|
|
408
|
+
parameters?: Record<string, unknown>;
|
|
409
|
+
}>;
|
|
410
|
+
}
|
|
364
411
|
type SecretScope = {
|
|
365
412
|
kind: "repo";
|
|
366
413
|
} | {
|
|
@@ -379,6 +426,13 @@ interface CodeScanningSetupResult {
|
|
|
379
426
|
run_url: string;
|
|
380
427
|
}
|
|
381
428
|
type TeamPermission = "pull" | "triage" | "push" | "maintain" | "admin";
|
|
429
|
+
/** A team with access to a repository, and the permission it has there. */
|
|
430
|
+
interface RepoTeam {
|
|
431
|
+
/** The team's slug. */
|
|
432
|
+
slug: string;
|
|
433
|
+
/** The team's permission on the repository. */
|
|
434
|
+
permission: TeamPermission;
|
|
435
|
+
}
|
|
382
436
|
/** A member of a team, as GitHub lists it. `id` is the numeric user id, which survives a rename; `login` does not. */
|
|
383
437
|
interface TeamMember {
|
|
384
438
|
id: number;
|
|
@@ -595,6 +649,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
595
649
|
updatePages: (repo: string, payload: UpdatePagesPayload) => Promise<void>;
|
|
596
650
|
};
|
|
597
651
|
properties: {
|
|
652
|
+
getValues: (repo: string) => Promise<RepoPropertyValue[]>;
|
|
598
653
|
orgSchema: (org: string) => Promise<OrgProperty[]>;
|
|
599
654
|
setProperties: (repo: string, values: Record<string, string | string[]>) => Promise<void>;
|
|
600
655
|
};
|
|
@@ -613,6 +668,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
613
668
|
getContents: (repo: string, path: string) => Promise<GitHubContents>;
|
|
614
669
|
};
|
|
615
670
|
rulesets: {
|
|
671
|
+
getRuleset: (repo: string, id: number) => Promise<GitHubRulesetDetail>;
|
|
616
672
|
listRulesets: (repo: string) => Promise<GitHubRuleset[]>;
|
|
617
673
|
createRuleset: (repo: string, payload: Record<string, unknown>) => Promise<GitHubRuleset>;
|
|
618
674
|
updateRuleset: (repo: string, id: number, payload: Record<string, unknown>) => Promise<GitHubRuleset>;
|
|
@@ -624,6 +680,10 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
624
680
|
deleteSecret: (repo: string, scope: SecretScope, name: string) => Promise<void>;
|
|
625
681
|
};
|
|
626
682
|
security: {
|
|
683
|
+
vulnerabilityAlertsEnabled: (repo: string) => Promise<boolean>;
|
|
684
|
+
automatedSecurityFixesEnabled: (repo: string) => Promise<boolean>;
|
|
685
|
+
privateVulnerabilityReportingEnabled: (repo: string) => Promise<boolean>;
|
|
686
|
+
codeScanningDefaultSetupState: (repo: string) => Promise<string>;
|
|
627
687
|
enableVulnerabilityAlerts: (repo: string) => Promise<void>;
|
|
628
688
|
enableAutomatedSecurityFixes: (repo: string) => Promise<void>;
|
|
629
689
|
enableSecretScanning: (repo: string) => Promise<void>;
|
|
@@ -634,6 +694,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
634
694
|
};
|
|
635
695
|
teams: {
|
|
636
696
|
members: (org: string, teamSlug: string) => Promise<TeamMember[]>;
|
|
697
|
+
listForRepo: (repo: string) => Promise<RepoTeam[]>;
|
|
637
698
|
addRepo: (org: string, teamSlug: string, owner: string, repo: string, permission: TeamPermission) => Promise<void>;
|
|
638
699
|
};
|
|
639
700
|
topics: {
|
|
@@ -657,4 +718,4 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
|
|
|
657
718
|
};
|
|
658
719
|
};
|
|
659
720
|
export type GitHubClient = ReturnType<typeof createGitHubClient>;
|
|
660
|
-
export type { CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, CodeScanningSetupResult, CreateCheckRunInput, CreatePagesPayload, CreatePullInput, CreateReviewComment, CreateReviewInput, GitBlob, GitCommit, GitContents, GitHubAppCredentials, GitHubCheckRun, GitHubClientOptions, GitHubContents, GitHubEnvironment, GitHubInstallationWebhookPayload, GitHubIssue, GitHubLabel, GitHubMilestone, GitHubPages, GitHubPublicKey, GitHubPullRequest, GitHubPullRequestCommit, GitHubPullRequestFile, GitHubPullRequestReview, GitHubPullRequestWebhookPayload, GitHubPushWebhookPayload, GitHubRepo, GitHubRuleset, GitHubUser, GitHubUserWithExpiry, GitHubVariable, GitHubWebhookHeaders, GitHubWorkflowRun, GitPull, GitRef, GitTree, GitTreeItem, InstallationAccessToken, IssueSearchParams, OrgProperty, PagesBuildStatus, PagesBuildType, PutContentsInput, PutContentsResult, ReviewThread, SecretScope, TeamMember, TeamPermission, UpdateCheckRunInput, UpdatePagesPayload, VariableScope, VariableVisibility, WorkflowRunFilter };
|
|
721
|
+
export type { CheckRunAnnotation, CheckRunAnnotationLevel, CheckRunConclusion, CheckRunOutput, CheckRunStatus, CodeScanningSetupResult, CreateCheckRunInput, CreatePagesPayload, CreatePullInput, CreateReviewComment, CreateReviewInput, GitBlob, GitCommit, GitContents, GitHubAppCredentials, GitHubCheckRun, GitHubClientOptions, GitHubContents, GitHubEnvironment, GitHubInstallationWebhookPayload, GitHubIssue, GitHubLabel, GitHubMilestone, GitHubPages, GitHubPublicKey, GitHubPullRequest, GitHubPullRequestCommit, GitHubPullRequestFile, GitHubPullRequestReview, GitHubPullRequestWebhookPayload, GitHubPushWebhookPayload, GitHubRepo, GitHubRuleset, GitHubRulesetDetail, GitHubUser, GitHubUserWithExpiry, GitHubVariable, GitHubWebhookHeaders, GitHubWorkflowRun, GitPull, GitRef, GitTree, GitTreeItem, InstallationAccessToken, IssueSearchParams, OrgProperty, PagesBuildStatus, PagesBuildType, PutContentsInput, PutContentsResult, RepoPropertyValue, RepoTeam, ReviewThread, SecretScope, TeamMember, TeamPermission, UpdateCheckRunInput, UpdatePagesPayload, VariableScope, VariableVisibility, WorkflowRunFilter };
|
package/dist/index.mjs
CHANGED
|
@@ -293,6 +293,8 @@ function pages(rest) {
|
|
|
293
293
|
// src/properties/properties.ts
|
|
294
294
|
function properties(rest) {
|
|
295
295
|
return {
|
|
296
|
+
/** The custom property values set on a repository (read-only). */
|
|
297
|
+
getValues: (repo) => rest.request(`${repoBase(repo)}/properties/values`),
|
|
296
298
|
/**
|
|
297
299
|
* The custom properties an organization defines, with their types and allowed values (read-only).
|
|
298
300
|
* The token needs read access to the organization's custom properties.
|
|
@@ -431,6 +433,7 @@ function repos(rest) {
|
|
|
431
433
|
// src/rulesets/rulesets.ts
|
|
432
434
|
function rulesets(rest) {
|
|
433
435
|
return {
|
|
436
|
+
getRuleset: (repo, id) => rest.request(`${repoBase(repo)}/rulesets/${id}`),
|
|
434
437
|
listRulesets: (repo) => rest.request(`${repoBase(repo)}/rulesets`),
|
|
435
438
|
createRuleset: (repo, payload) => rest.request(`${repoBase(repo)}/rulesets`, {
|
|
436
439
|
method: "POST",
|
|
@@ -468,6 +471,22 @@ function secrets(rest) {
|
|
|
468
471
|
// src/security/security.ts
|
|
469
472
|
function security(rest) {
|
|
470
473
|
return {
|
|
474
|
+
/** Whether vulnerability alerts are on: GitHub answers 204 when they are and 404 when they are not. */
|
|
475
|
+
vulnerabilityAlertsEnabled: async (repo) => {
|
|
476
|
+
try {
|
|
477
|
+
await rest.request(`${repoBase(repo)}/vulnerability-alerts`, { expectNoContent: true });
|
|
478
|
+
return true;
|
|
479
|
+
} catch (err) {
|
|
480
|
+
if (err instanceof ProviderApiError && err.status === 404) return false;
|
|
481
|
+
throw err;
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
/** Whether Dependabot security updates are on. */
|
|
485
|
+
automatedSecurityFixesEnabled: async (repo) => (await rest.request(`${repoBase(repo)}/automated-security-fixes`)).enabled,
|
|
486
|
+
/** Whether private vulnerability reporting is on. */
|
|
487
|
+
privateVulnerabilityReportingEnabled: async (repo) => (await rest.request(`${repoBase(repo)}/private-vulnerability-reporting`)).enabled,
|
|
488
|
+
/** The state of CodeQL default setup: `configured` or `not-configured`. */
|
|
489
|
+
codeScanningDefaultSetupState: async (repo) => (await rest.request(`${repoBase(repo)}/code-scanning/default-setup`)).state,
|
|
471
490
|
enableVulnerabilityAlerts: (repo) => rest.request(`${repoBase(repo)}/vulnerability-alerts`, {
|
|
472
491
|
method: "PUT",
|
|
473
492
|
expectNoContent: true
|
|
@@ -535,6 +554,8 @@ function teams(rest) {
|
|
|
535
554
|
if ((await read(51)).length > 0) throw new Error(`team ${org}/${teamSlug} has more than 5000 members; refusing to read them all`);
|
|
536
555
|
return all;
|
|
537
556
|
},
|
|
557
|
+
/** The teams that have access to a repository, with each team's permission there (read-only). */
|
|
558
|
+
listForRepo: (repo) => rest.request(`${repoBase(repo)}/teams`, { query: { per_page: String(PAGE$1) } }),
|
|
538
559
|
addRepo: (org, teamSlug, owner, repo, permission) => rest.request(`/orgs/${org}/teams/${teamSlug}/repos/${owner}/${repo}`, {
|
|
539
560
|
method: "PUT",
|
|
540
561
|
body: { permission }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/github-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.3",
|
|
4
4
|
"description": "A TypeScript client for the GitHub REST API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.3",
|
|
36
36
|
"@theholocron/observability": "^0.6.1-alpha.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|