@theholocron/github-client 1.58.0-alpha.1 → 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 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;
@@ -411,6 +465,18 @@ interface GitHubUser {
411
465
  name: string | null;
412
466
  email: string | null;
413
467
  }
468
+ /** The authenticated user and, for a token that expires, when. */
469
+ interface GitHubUserWithExpiry {
470
+ /** The authenticated user. */
471
+ user: GitHubUser;
472
+ /** When the token stops working, ISO 8601 in UTC. Absent for a token that never expires. */
473
+ expiresAt?: string;
474
+ }
475
+ /**
476
+ * The expiry GitHub reports in the `github-authentication-token-expiration` header (`2026-11-19 03:46:04 UTC`) as
477
+ * ISO 8601, or `undefined` when the header is missing or is not a date.
478
+ */
479
+ export declare function parseTokenExpiration(header: string | null): string | undefined;
414
480
  interface GitHubWorkflowRun {
415
481
  id: number;
416
482
  name: string | null;
@@ -583,6 +649,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
583
649
  updatePages: (repo: string, payload: UpdatePagesPayload) => Promise<void>;
584
650
  };
585
651
  properties: {
652
+ getValues: (repo: string) => Promise<RepoPropertyValue[]>;
586
653
  orgSchema: (org: string) => Promise<OrgProperty[]>;
587
654
  setProperties: (repo: string, values: Record<string, string | string[]>) => Promise<void>;
588
655
  };
@@ -601,6 +668,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
601
668
  getContents: (repo: string, path: string) => Promise<GitHubContents>;
602
669
  };
603
670
  rulesets: {
671
+ getRuleset: (repo: string, id: number) => Promise<GitHubRulesetDetail>;
604
672
  listRulesets: (repo: string) => Promise<GitHubRuleset[]>;
605
673
  createRuleset: (repo: string, payload: Record<string, unknown>) => Promise<GitHubRuleset>;
606
674
  updateRuleset: (repo: string, id: number, payload: Record<string, unknown>) => Promise<GitHubRuleset>;
@@ -612,6 +680,10 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
612
680
  deleteSecret: (repo: string, scope: SecretScope, name: string) => Promise<void>;
613
681
  };
614
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>;
615
687
  enableVulnerabilityAlerts: (repo: string) => Promise<void>;
616
688
  enableAutomatedSecurityFixes: (repo: string) => Promise<void>;
617
689
  enableSecretScanning: (repo: string) => Promise<void>;
@@ -622,6 +694,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
622
694
  };
623
695
  teams: {
624
696
  members: (org: string, teamSlug: string) => Promise<TeamMember[]>;
697
+ listForRepo: (repo: string) => Promise<RepoTeam[]>;
625
698
  addRepo: (org: string, teamSlug: string, owner: string, repo: string, permission: TeamPermission) => Promise<void>;
626
699
  };
627
700
  topics: {
@@ -636,6 +709,7 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
636
709
  };
637
710
  user: {
638
711
  getCurrentUser: () => Promise<GitHubUser>;
712
+ getCurrentUserWithExpiry(): Promise<GitHubUserWithExpiry>;
639
713
  };
640
714
  workflows: {
641
715
  listRuns: (repo: string, filter?: WorkflowRunFilter) => Promise<GitHubWorkflowRun[]>;
@@ -644,4 +718,4 @@ export declare function createGitHubClient(opts: GitHubClientOptions): {
644
718
  };
645
719
  };
646
720
  export type GitHubClient = ReturnType<typeof createGitHubClient>;
647
- 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, 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 }
@@ -549,8 +570,31 @@ function topics(rest) {
549
570
  }) };
550
571
  }
551
572
  // src/user/user.ts
573
+ /**
574
+ * The expiry GitHub reports in the `github-authentication-token-expiration` header (`2026-11-19 03:46:04 UTC`) as
575
+ * ISO 8601, or `undefined` when the header is missing or is not a date.
576
+ */
577
+ function parseTokenExpiration(header) {
578
+ if (!header) return void 0;
579
+ const time = Date.parse(header.replace(/ UTC$/, "Z").replace(" ", "T"));
580
+ return Number.isNaN(time) ? void 0 : new Date(time).toISOString();
581
+ }
552
582
  function user(rest) {
553
- return { getCurrentUser: () => rest.request("/user") };
583
+ return {
584
+ getCurrentUser: () => rest.request("/user"),
585
+ /** The authenticated user plus when the token expires, read from the response header on the same call. */
586
+ async getCurrentUserWithExpiry() {
587
+ let header = null;
588
+ const me = await rest.request("/user", { onResponse: (headers) => {
589
+ header = headers.get("github-authentication-token-expiration");
590
+ } });
591
+ const expiresAt = parseTokenExpiration(header);
592
+ return expiresAt ? {
593
+ user: me,
594
+ expiresAt
595
+ } : { user: me };
596
+ }
597
+ };
554
598
  }
555
599
  // src/variables/variables.ts
556
600
  /** GitHub's maximum page size for this listing is 30, not the usual 100. */
@@ -871,4 +915,4 @@ function createGitHubClient(opts) {
871
915
  workflows: workflows(rest)
872
916
  };
873
917
  }
874
- export { MAX_CHECK_RUN_ANNOTATIONS, createAppJWT, createGitHubClient, createInstallationClient, getInstallationAccessToken, parseGitHubWebhookHeaders, verifyGitHubWebhookSignature };
918
+ export { MAX_CHECK_RUN_ANNOTATIONS, createAppJWT, createGitHubClient, createInstallationClient, getInstallationAccessToken, parseGitHubWebhookHeaders, parseTokenExpiration, verifyGitHubWebhookSignature };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/github-client",
3
- "version": "1.58.0-alpha.1",
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.1",
35
+ "@theholocron/http-client": "^1.58.0-alpha.3",
36
36
  "@theholocron/observability": "^0.6.1-alpha.1"
37
37
  },
38
38
  "devDependencies": {
@@ -45,8 +45,8 @@
45
45
  "tsdown": "^0.23.3",
46
46
  "typescript": "^5.9.3",
47
47
  "vitest": "^5.0.5",
48
- "@theholocron/tsconfig": "^8.9.0-alpha.3",
49
48
  "@theholocron/eslint-config": "^8.9.0-alpha.3",
49
+ "@theholocron/tsconfig": "^8.9.0-alpha.3",
50
50
  "@theholocron/tsdown-config": "^8.9.0-alpha.3",
51
51
  "@theholocron/vitest-config": "^8.9.0-alpha.3"
52
52
  },