Skip to content
Sarj Workspace Sync

identity-provisioning/github-organization-api-port

@sarj-ai/workspace-sync/identity-provisioning/github-organization-api-port ยท Source

import { z } from "zod";
import { GitHubLoginSchema, GitHubUserIdSchema } from "../catalog/identity-authority.ts";
import { type ReviewedGitHubDirectGrantRetention } from "../github-access-audit/reviewed-direct-grants.ts";
import { GitHubObservedOrganizationAccountSchema, type GitHubProvisioningOperation, type MutatingGitHubOrganizationPort } from "./github-organization-connector.ts";
import { type GithubDispatchClaim, type GithubPrewriteRefusalCategory } from "./github-zero-dispatch.ts";
declare const ConfigSchema: z.ZodObject<{
fetchImpl: z.ZodOptional<z.ZodCustom<typeof fetch, typeof fetch>>;
managedTeamPins: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>>;
managedTeamSlugs: z.ZodReadonly<z.ZodArray<z.ZodString>>;
maxPages: z.ZodDefault<z.ZodNumber>;
maxRequests: z.ZodDefault<z.ZodNumber>;
organizationId: z.ZodString;
organizationLogin: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
requestTimeoutMs: z.ZodDefault<z.ZodNumber>;
reviewedDirectGrantRetentions: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
githubLogin: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>, "GitHubLogin", "out">;
githubUserId: z.core.$ZodBranded<z.ZodString, "GitHubUserId", "out">;
allowedTeamSlugs: z.ZodReadonly<z.ZodArray<z.core.$ZodBranded<z.ZodString, "GitHubTeamSlug", "out">>>;
googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">;
grants: z.ZodReadonly<z.ZodArray<z.ZodObject<{
customRoleName: z.ZodOptional<z.ZodString>;
permission: z.ZodEnum<{
admin: "admin";
maintain: "maintain";
pull: "pull";
push: "push";
triage: "triage";
}>;
repositoryId: z.core.$ZodBranded<z.ZodNumber, "GitHubRepositoryId", "out">;
repositoryName: z.core.$ZodBranded<z.ZodString, "GitHubRepositoryName", "out">;
}, z.core.$strict>>>;
primaryEmail: z.core.$ZodBranded<z.ZodPipe<z.ZodString, z.ZodEmail>, "PrimaryEmail", "out">;
reviewedAt: z.ZodISODate;
}, z.core.$strict>>>>>;
samlToken: z.ZodString;
token: z.ZodString;
}, z.core.$strict>;
declare const OBSERVATION_STAGES: readonly ["direct_grants", "identity_pins", "invitations", "membership", "outside_collaborator", "repositories", "result_schema", "saml", "team_memberships", "teams", "writer_tenant_probe"];
type ObservationStage = (typeof OBSERVATION_STAGES)[number];
export type GitHubOrganizationApiPortConfig = z.input<typeof ConfigSchema>;
export declare function assertDistinctGitHubOrganizationCredentials(samlToken: string, writerToken: string): Promise<void>;
/**
* Bounded first-party GitHub organization adapter. Constructing this port does
* not enable a workflow; production writes still require explicit runtime wiring.
*/
export declare class GitHubOrganizationApiPort implements MutatingGitHubOrganizationPort {
#private;
readonly capability = "mutating";
constructor(rawConfig: GitHubOrganizationApiPortConfig);
observeAccount(rawIdentity: {
readonly primaryEmail?: string;
readonly githubLogin: z.output<typeof GitHubLoginSchema>;
readonly githubUserId: z.output<typeof GitHubUserIdSchema>;
}): Promise<Readonly<{
complete: true;
directRepositoryGrants: readonly Readonly<{
githubLogin: string & z.$brand<"GitHubLogin">;
githubUserId: string & z.$brand<"GitHubUserId">;
customRoleName?: string | undefined;
unresolvedDirectRole?: true | undefined;
permission: "admin" | "maintain" | "pull" | "push" | "triage";
repositoryId: number & z.$brand<"GitHubRepositoryId">;
repositoryName: string & z.$brand<"GitHubRepositoryName">;
}>[];
identity: Readonly<{
githubLogin: string & z.$brand<"GitHubLogin">;
githubUserId: string & z.$brand<"GitHubUserId">;
}>;
membership: Readonly<{
githubLogin: string & z.$brand<"GitHubLogin">;
githubUserId: string & z.$brand<"GitHubUserId">;
role: "member" | "owner";
}> | null;
observedAt: string;
outsideCollaborator: boolean;
pendingInvitations: readonly Readonly<{
githubLogin: string & z.$brand<"GitHubLogin">;
githubUserId: string & z.$brand<"GitHubUserId">;
invitationId: number & z.$brand<"GitHubInvitationId">;
role: "admin" | "billing_manager" | "direct_member";
}>[];
unresolvedInvitations?: "identity-or-privilege" | "opaque-direct" | undefined;
repositoryInventoryComplete: boolean;
samlLinked: boolean;
teamMemberships: readonly Readonly<{
githubLogin: string & z.$brand<"GitHubLogin">;
githubUserId: string & z.$brand<"GitHubUserId">;
inherited: boolean;
role: "maintainer" | "member";
state: "active" | "pending";
teamId: number & z.$brand<"GitHubTeamId">;
teamSlug: string & z.$brand<"GitHubTeamSlug">;
}>[];
}>>;
verifyWriterTenant(): Promise<void>;
execute(operation: GitHubProvisioningOperation, assertFinalWriteAuthority?: () => Promise<void>, dispatchClaim?: GithubDispatchClaim): Promise<Readonly<{
kind: "add-team-member" | "cancel-invitation" | "invite-organization-member" | "remove-organization-member" | "remove-team-member";
state: "converged";
}> | Readonly<{
access: "active-member" | "pending-acceptance";
kind: "invite-organization-member";
state: "invited";
}>>;
}
export declare function githubPrewriteSafetyFlags(operation: GitHubProvisioningOperation, observed: z.output<typeof GitHubObservedOrganizationAccountSchema>, reviewedRetentions?: readonly ReviewedGitHubDirectGrantRetention[]): {
owner: boolean;
outsideCollaborator: boolean;
directRepositoryGrants: boolean;
privilegedInvitation: boolean;
teamMaintainer: boolean;
invitationAlreadyPending: boolean;
removalRepositoryInventoryIncomplete: boolean;
teamSamlUnlinked: boolean;
pendingSelectedTeam: boolean;
inheritedSelectedTeam: boolean;
};
export declare class GitHubOrganizationPinError extends Error {
constructor();
}
export declare class GitHubCredentialSeparationError extends Error {
constructor();
}
export declare class GitHubRequestHeadersError extends Error {
constructor(options?: ErrorOptions);
}
export declare class GitHubRequestTransportError extends Error {
constructor(options?: ErrorOptions);
}
export declare class GitHubWriterTenantResponseError extends Error {
constructor();
}
export declare class GitHubIdentityPinError extends Error {
constructor();
}
export declare class GitHubOrganizationScopeError extends Error {
constructor();
}
export declare class GitHubOrganizationBoundExceededError extends Error {
constructor(bound: "pages" | "requests", options?: ErrorOptions);
}
export declare class GitHubUnresolvedPrivilegedInvitationError extends Error {
constructor();
}
export declare class GitHubMutationReadbackError extends Error {
constructor(kind: GitHubProvisioningOperation["kind"], options?: ErrorOptions);
}
export declare class GitHubPreWriteSafetyError extends Error {
constructor();
}
export declare function githubProviderObservationStage(error: unknown): ObservationStage | undefined;
export declare function takeGithubZeroDispatchProof(error: unknown): GithubZeroDispatchProof | undefined;
export declare function assertTrustedGithubZeroDispatchProof(proof: GithubZeroDispatchProof): void;
export interface GithubZeroDispatchProof {
readonly category: GithubPrewriteRefusalCategory;
readonly claim: GithubDispatchClaim;
readonly operation: GitHubProvisioningOperation;
}
export {};