Skip to content
Sarj Workspace Sync

execution/pager-duty-team-service

@sarj-ai/workspace-sync/execution/pager-duty-team-service ยท Source

import type { 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 { logErrorEvent } from "../shared/log-event.ts";
import { PagerDutyReadinessSchema } from "../workspace-directory/pagerduty-readiness-contracts.ts";
import type { IPagerDutyLicenseReader, IPagerDutyTeamClient, IPagerDutyTeamReader } from "../workspace-directory/pagerduty-team-client.ts";
import { type PagerDutyTeamSyncSettings } from "../workspace-directory/pagerduty-team-config.ts";
import { type AuditedPagerDutyTeamPlanSchema, type PagerDutyTeamWritableAction } from "../workspace-directory/pagerduty-team-sync.ts";
import type { WorkspaceProviderExecution } from "./provider-execution.ts";
import type { ReviewedActionContext, ReviewedActionState } from "./reviewed-action-context.ts";
import { type ReviewedPagerDutyTeam } from "./reviewed-pagerduty-team.ts";
export interface PagerDutyTeamServiceDependencies {
directory: Pick<IGoogleDirectoryClient, "listAllUsers">;
employeeEntitlementAuthority: () => Promise<EmployeeEntitlementAuthority>;
groups: Pick<IGoogleGroupsClient, "listGroups">;
leaseRepository?: ResourceLeaseRepository;
logError?: typeof logErrorEvent;
pagerDuty: IPagerDutyTeamReader | null;
pagerDutyLicenses?: IPagerDutyLicenseReader | null;
pagerDutyWriter?: IPagerDutyTeamClient | null;
settings: PagerDutyTeamSyncSettings;
}
export interface PagerDutyTeamParentExecution extends Extract<ReviewedActionContext<PagerDutyTeamWritableAction>, {
mode: "parent";
}> {
assertFinalSourceAuthority(): Promise<void>;
}
export interface PagerDutyTeamServiceContract {
readiness(): Promise<z.output<typeof PagerDutyReadinessSchema>>;
applyReviewed(reviewed: ReviewedPagerDutyTeam, parent: PagerDutyTeamParentExecution): Promise<"busy" | "completed">;
auditPlan(correlationId?: string): Promise<z.output<typeof AuditedPagerDutyTeamPlanSchema>>;
readReviewed(reviewed: ReviewedPagerDutyTeam): Promise<ReviewedActionState>;
}
export declare class PagerDutyTeamService implements PagerDutyTeamServiceContract {
#private;
constructor(mode: WorkspaceProviderExecution, dependencies: PagerDutyTeamServiceDependencies);
readReviewed(reviewed: ReviewedPagerDutyTeam): Promise<ReviewedActionState>;
applyReviewed(reviewed: ReviewedPagerDutyTeam, parent: PagerDutyTeamParentExecution): Promise<"busy" | "completed">;
readiness(): Promise<{
mutationDisabled: boolean;
writesAttempted: 0;
credentialEvidence: "missing" | "read-verified" | "unavailable";
writePermissionEvidence: "unverified";
paidCapacity: "unknown";
sourceComplete: boolean;
missingUserCount: number;
missingUsersTruncated: boolean;
missingUsers: {
googleUserId: string & z.$brand<"GoogleUserId">;
email: string;
targets: {
googleGroupId: string;
pagerDutyTeamId: string;
desiredRole: "manager" | "observer" | "responder";
}[];
}[];
licensing: {
licenses: {
id: string;
valid_roles: ("admin" | "limited_user" | "observer" | "owner" | "read_only_limited_user" | "read_only_user" | "restricted_access" | "user")[];
current_value: number;
allocations_available: number | null;
}[];
allocationCount: number;
} | null;
diagnostics: {
code: "contractor-membership-preserved" | "credential-missing" | "dedicated_credential_missing" | "dedicated_credential_unavailable" | "evidence-incomplete" | "google-group-member-ineligible" | "google-group-pin-mismatch" | "mapping-configuration-empty" | "pagerduty-team-pin-mismatch" | "pagerduty-user-email-ambiguous" | "pagerduty-user-missing" | "paid_capacity_unverified" | "protected-identity";
severity: "blocker" | "warning";
}[];
}>;
auditPlan(correlationId?: string): Promise<Readonly<{
actions: readonly (Readonly<{
email: string;
pagerDutyTeamId: string;
pagerDutyUserId: string;
googleGroupId: string;
googleUserId: string;
desiredPagerDutyRole: "manager" | "observer" | "responder";
type: "add";
}> | Readonly<{
email: string;
pagerDutyTeamId: string;
pagerDutyUserId: string;
googleGroupId: string;
googleUserId: string;
currentPagerDutyRole: "manager" | "observer" | "responder";
desiredPagerDutyRole: "manager" | "observer" | "responder";
type: "set-role";
}> | Readonly<{
email: string;
pagerDutyTeamId: string;
pagerDutyUserId: string;
currentPagerDutyRole: "manager" | "observer" | "responder";
type: "remove";
}>)[];
diagnostics: readonly Readonly<{
code: "contractor-membership-preserved" | "credential-missing" | "evidence-incomplete" | "google-group-member-ineligible" | "google-group-pin-mismatch" | "mapping-configuration-empty" | "pagerduty-team-pin-mismatch" | "pagerduty-user-email-ambiguous" | "pagerduty-user-missing" | "protected-identity";
detail: string;
severity: "error" | "warning";
}>[];
evidenceHash: string;
mappingCount: number;
mutationsDisabled: boolean;
pagerDutyTeamCount: number | null;
pagerDutyUserCount: number | null;
reviewId: string;
status: "blocked" | "ready";
planHash: string;
}>>;
}
export type PagerDutyTeamExecutionPort = Omit<PagerDutyTeamServiceContract, "readiness">;