execution/sentry-workspace-service
@sarj-ai/workspace-sync/execution/sentry-workspace-service ยท Source
import { z } from "zod";import { type EmployeeEntitlementAuthority } from "../identity-provisioning/employee-entitlement-policy.ts";import { type ResourceLeaseRepository } from "../identity-sync/resource-lease.ts";import type { IGoogleDirectoryClient } from "../org-sync/google-directory-client.ts";import type { IGoogleGroupsClient } from "../org-sync/google-groups-client.ts";import { type ISentryWorkspaceClient } from "../workspace-directory/sentry-workspace-client.ts";import { auditSentryWorkspaceSync, type SentryWorkspaceActionSchema } from "../workspace-directory/sentry-workspace-sync.ts";import type { ReviewedActionContext, ReviewedActionState } from "./reviewed-action-context.ts";import { type ReviewedSentryWorkspace } from "./reviewed-sentry-workspace.ts";import { type SentryDeprovisionPorts } from "./sentry-deprovision.ts";import type { SentryWorkspaceAuthorityPins } from "./sentry-workspace-authority-pins.ts";export declare const SentryWorkspaceParentAuditSchema: z.ZodObject<{ authorityFingerprint: z.ZodString; googleIdentities: z.ZodArray<z.ZodObject<{ email: z.ZodEmail; googleUserId: z.core.$ZodBranded<z.ZodString, "GoogleUserId", "out">; }, z.core.$strict>>; plan: z.ZodObject<{ actions: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{ email: z.ZodEmail; memberId: z.ZodString; type: z.ZodLiteral<"remove-organization-member">; }, z.core.$strict>, z.ZodObject<{ email: z.ZodEmail; memberId: z.ZodString; type: z.ZodLiteral<"add-team-member">; }, z.core.$strict>, z.ZodObject<{ email: z.ZodEmail; type: z.ZodLiteral<"invite">; }, z.core.$strict>, z.ZodObject<{ email: z.ZodEmail; memberId: z.ZodString; type: z.ZodLiteral<"repair-pending-invite">; }, z.core.$strict>, z.ZodObject<{ email: z.ZodEmail; memberId: z.ZodString; type: z.ZodLiteral<"reinvite-expired">; }, z.core.$strict>], "type">>; activeGoogleMembers: z.ZodArray<z.ZodEmail>; planHash: z.ZodString; }, z.core.$strict>; providerAuthority: z.ZodObject<{ actor: z.ZodObject<{ id: z.ZodString; orgRole: z.ZodEnum<{ admin: "admin"; billing: "billing"; manager: "manager"; member: "member"; owner: "owner"; }>; role: z.ZodEnum<{ admin: "admin"; billing: "billing"; manager: "manager"; member: "member"; owner: "owner"; }>; scopes: z.ZodArray<z.ZodString>; teamRole: z.ZodNullable<z.ZodEnum<{ admin: "admin"; contributor: "contributor"; }>>; }, z.core.$strict>; organization: z.ZodObject<{ id: z.ZodString; slug: z.ZodString; }, z.core.$strict>; project: z.ZodObject<{ id: z.ZodString; slug: z.ZodString; }, z.core.$strict>; mode: z.ZodLiteral<"audit">; team: z.ZodObject<{ id: z.ZodString; slug: z.ZodString; }, z.core.$strict>; writes: z.ZodLiteral<0>; }, z.core.$strict>;}, z.core.$strict>;type SentryParentEvidenceStage = "google-authority" | "provider-authority" | "provider-snapshot";type SentryParentEvidenceReason = "authority-mismatch" | "provider-contract" | "provider-rate-limited" | "provider-timeout" | "provider-unavailable" | "source-unavailable" | "unsupported-credential";export declare class SentryParentEvidenceError extends Error { readonly reason: SentryParentEvidenceReason; readonly stage: SentryParentEvidenceStage; constructor(stage: SentryParentEvidenceStage, reason: SentryParentEvidenceReason, options: ErrorOptions);}export interface SentryWorkspaceServiceDependencies { directory: SentryDeprovisionPorts["directory"]; employeeEntitlementAuthority: () => Promise<EmployeeEntitlementAuthority>; groups: Pick<IGoogleGroupsClient, "listGroups">; leaseRepository: ResourceLeaseRepository; sentry: ISentryWorkspaceClient;}export interface SentryWorkspaceParentExecution extends Extract<ReviewedActionContext<z.output<typeof SentryWorkspaceActionSchema>>, { mode: "parent";}> { assertFinalSourceAuthority(): Promise<void>;}export interface SentryWorkspaceServiceContract { auditPlan(): ReturnType<typeof auditSentryWorkspaceSync>; applyReviewed(reviewed: ReviewedSentryWorkspace, parent: SentryWorkspaceParentExecution): Promise<"busy" | "completed">; auditParentPlan(): Promise<z.output<typeof SentryWorkspaceParentAuditSchema>>; readReviewed(reviewed: ReviewedSentryWorkspace): Promise<ReviewedActionState>;}export declare function readActiveTeamPlatformEmails(directory: Pick<IGoogleDirectoryClient, "listAllUsers">, groups: Pick<IGoogleGroupsClient, "listGroups">, captureEmployeeEntitlementAuthority: () => Promise<EmployeeEntitlementAuthority>): Promise<string[]>;export declare class SentryWorkspaceService implements SentryWorkspaceServiceContract { #private; auditPlan(): Promise<{ actions: ({ email: string; memberId: string; type: "remove-organization-member"; } | { email: string; memberId: string; type: "add-team-member"; } | { email: string; type: "invite"; } | { email: string; memberId: string; type: "repair-pending-invite"; } | { email: string; memberId: string; type: "reinvite-expired"; })[]; activeGoogleMembers: string[]; planHash: string; }>; constructor(mode: SentryExecutionMode, dependencies: SentryWorkspaceServiceDependencies); auditParentPlan(): Promise<{ authorityFingerprint: string; googleIdentities: { email: string; googleUserId: string & z.$brand<"GoogleUserId">; }[]; plan: { actions: ({ email: string; memberId: string; type: "remove-organization-member"; } | { email: string; memberId: string; type: "add-team-member"; } | { email: string; type: "invite"; } | { email: string; memberId: string; type: "repair-pending-invite"; } | { email: string; memberId: string; type: "reinvite-expired"; })[]; activeGoogleMembers: string[]; planHash: string; }; providerAuthority: { actor: { id: string; orgRole: "admin" | "billing" | "manager" | "member" | "owner"; role: "admin" | "billing" | "manager" | "member" | "owner"; scopes: string[]; teamRole: "admin" | "contributor" | null; }; organization: { id: string; slug: string; }; project: { id: string; slug: string; }; mode: "audit"; team: { id: string; slug: string; }; writes: 0; }; }>; readReviewed(reviewed: ReviewedSentryWorkspace): Promise<ReviewedActionState>; applyReviewed(reviewed: ReviewedSentryWorkspace, parent: SentryWorkspaceParentExecution): Promise<"busy" | "completed">;}export type SentryExecutionMode = { readonly kind: "audit";} | { readonly kind: "parent"; readonly pins: SentryWorkspaceAuthorityPins;};export type SentryWorkspaceExecutionPort = Omit<SentryWorkspaceServiceContract, "auditPlan">;export {};