github-access-audit/git-hub-access-audit-client
@sarj-ai/workspace-sync/github-access-audit/github-client ยท Source
import { z } from "zod";import { type GitHubOrganizationMembershipSnapshot } from "../github/organization-membership-reader.ts";import { type GitHubActorSchema as ActorSchema, GitHubCollaboratorSchema as CollaboratorSchema, GitHubOrganizationSchema as OrganizationSchema, GitHubRepositorySchema as RepositorySchema, GitHubScimPageSchema as ScimPageSchema, GitHubTeamGrantSchema as TeamGrantSchema, GitHubTeamMemberSchema as TeamMemberSchema, GitHubTeamSchema as TeamSchema } from "./github-contracts.ts";import { type GitHubDeprovisionAuthority } from "./github-deprovision-authority-contract.ts";export interface GitHubAuditError { capability: GitHubCapability; code: string; message: string;}export type GitHubCapability = "invitations" | "members" | "organization" | "outside_collaborators" | "repositories" | "saml_external_identities" | "scim_identities" | "teams";export interface GitHubAccessSnapshot { capturedAt: string; errors: GitHubAuditError[]; invitations: GitHubOrganizationMembershipSnapshot["invitations"]; members: (z.infer<typeof ActorSchema> & { role: "admin" | "member"; })[]; organization: null | z.infer<typeof OrganizationSchema>; outsideCollaborators: z.infer<typeof ActorSchema>[]; repositories: (z.infer<typeof RepositorySchema> & { directCollaborators: z.infer<typeof CollaboratorSchema>[]; teamGrants: z.infer<typeof TeamGrantSchema>[]; })[]; samlExternalIdentities: { databaseId?: number; guid: string; login: null | string; nameId: null | string; }[]; scimIdentities: z.infer<typeof ScimPageSchema>["Resources"]; teams: (z.infer<typeof TeamSchema> & { directMembers: z.infer<typeof TeamMemberSchema>[]; maintainers: z.infer<typeof TeamMemberSchema>[]; })[];}export interface GitHubIdentitySeedSnapshot { capturedAt: string; errors: GitHubAuditError[]; members: GitHubAccessSnapshot["members"]; samlExternalIdentities: GitHubAccessSnapshot["samlExternalIdentities"];}export interface GitHubAccessAuditClientOptions { fetchImpl?: typeof fetch; maxConcurrentRequests?: number; maxPages?: number; maxRequests?: number; organization: string; token: string;}export interface GitHubAccessAuditReader { capture(deadlineAt?: number): Promise<GitHubAccessSnapshot>; captureDeprovisionAuthority(deadlineAt?: number): Promise<GitHubDeprovisionAuthority>; captureIdentitySeed(deadlineAt?: number): Promise<GitHubIdentitySeedSnapshot>;}/** Read-only GitHub organization inventory with capability-scoped failures. */export declare class GitHubAccessAuditClient implements GitHubAccessAuditReader { #private; constructor(options: GitHubAccessAuditClientOptions); capture(deadlineAt?: number): Promise<GitHubAccessSnapshot>; captureIdentitySeed(deadlineAt?: number): Promise<GitHubIdentitySeedSnapshot>; captureDeprovisionAuthority(deadlineAt?: number): Promise<GitHubDeprovisionAuthority>;}