Skip to content
Sarj Workspace Sync

org-sync/service

@sarj-ai/workspace-sync/org-sync/service ยท Source

import { type IdentityWriteBudget } from "../identity-provisioning/identity-budget-contracts.ts";
import type { IGoogleDirectoryClient } from "./google-directory-client.ts";
import { type GoogleDirectoryUser, type ManagedFieldIds, type ProfilePlan } from "./model.ts";
import type { IOrgSlackClient, SlackProfileField } from "./org-slack-client.ts";
type ConfiguredFieldIds = Omit<ManagedFieldIds, "linkedin">;
export interface OrgSyncConfig {
allowedEmptyDepartmentGoogleUserIds: string[];
excludedGoogleUserIds: string[];
expectedRootGoogleUserIds: string[];
expectedSlackTeamId: string;
fieldIds: ConfiguredFieldIds;
managedDomain: string;
maxAutomaticChanges: number;
minimumGoogleParticipants: number;
protectedDepartedGoogleUserIds: string[];
}
export interface OrgSyncRunOptions {
expectedPlanHash?: string;
identityBudget?: IdentityWriteBudget | undefined;
mode: "audit" | "live";
trigger: "cron" | "http" | "local";
}
export interface OrgSyncFailure {
error: string;
slackUserId: string;
}
export interface OrgSyncRunReport {
blocked: OrgSyncFailure[];
changedProfiles: number;
errors: string[];
failed: OrgSyncFailure[];
googleOnly: string[];
googleParticipants: number;
matched: number;
mode: OrgSyncRunOptions["mode"];
planHash: string;
planned: ProfilePlan[];
rootGoogleUserIds: string[];
runId: string;
selectedSlackUserId: null | string;
slackOrphans: string[];
status: "audit" | "blocked" | "failed" | "success";
unplacedGoogle: string[];
verified: number;
warnings: string[];
writes: number;
}
export interface OrgSyncServiceOptions {
config: OrgSyncConfig;
google: IGoogleDirectoryClient;
slack: IOrgSlackClient;
}
export interface OrgSyncServiceContract {
run(options: OrgSyncRunOptions, googleSnapshot?: readonly GoogleDirectoryUser[]): Promise<OrgSyncRunReport>;
}
export interface SlackProfileSyncContract {
plan(): Promise<OrgSyncRunReport>;
apply(reviewed: Pick<OrgSyncRunReport, "planHash" | "status">, options?: Pick<OrgSyncRunOptions, "identityBudget">): Promise<OrgSyncRunReport>;
}
export declare class OrgSyncService implements OrgSyncServiceContract, SlackProfileSyncContract {
#private;
constructor(options: OrgSyncServiceOptions);
plan(): Promise<OrgSyncRunReport>;
apply(reviewed: Pick<OrgSyncRunReport, "planHash" | "status">, options?: Pick<OrgSyncRunOptions, "identityBudget">): Promise<OrgSyncRunReport>;
run(options: OrgSyncRunOptions, googleSnapshot?: readonly GoogleDirectoryUser[]): Promise<OrgSyncRunReport>;
}
export declare function optionalLinkedInField(fields: readonly SlackProfileField[]): null | string;
export {};