Skip to content
Sarj Workspace Sync

execution/slack-name-service

@sarj-ai/workspace-sync/execution/slack-name-service ยท Source

import { type ResourceLeaseRepository } from "../identity-sync/resource-lease.ts";
import type { IGoogleDirectoryClient } from "../org-sync/google-directory-client.ts";
import type { GoogleDirectoryUser } from "../org-sync/model.ts";
import type { SlackSnapshot } from "../org-sync/org-slack-client.ts";
import { type ParentNameEligibility } from "../workspace-directory/parent-name-identity-eligibility.ts";
import { type AuditedSlackNamePlan, type ISlackNameClient, type SlackNameAction } from "../workspace-directory/slack-name-sync.ts";
import type { ReviewedAction, ReviewedActionContext, ReviewedActionState } from "./reviewed-action-context.ts";
export interface SlackNameServiceDependencies {
directory: Pick<IGoogleDirectoryClient, "listAllUsers">;
leaseRepository: ResourceLeaseRepository;
slack: ISlackNameClient;
}
export interface ParentSlackNameCapture {
diagnostics: {
googleUserId: string;
reason: Exclude<ParentNameEligibility, "eligible">;
}[];
eligibleActions: SlackNameAction[];
plan: AuditedSlackNamePlan;
sourceFingerprint: string;
}
export interface ISlackNameReader {
capture(): Promise<AuditedSlackNamePlan>;
captureParent(googleUsers?: readonly GoogleDirectoryUser[]): Promise<ParentSlackNameCapture>;
readReviewed(reviewed: ReviewedAction<SlackNameAction>): Promise<ReviewedActionState>;
readSourceFingerprint(): Promise<string>;
}
export interface ISlackNameWriter {
applyReviewed(reviewed: ReviewedAction<SlackNameAction>, context: ReviewedActionContext<SlackNameAction>): Promise<"busy" | "completed">;
}
export declare class SlackNameService implements ISlackNameReader, ISlackNameWriter {
#private;
constructor(dependencies: SlackNameServiceDependencies, writeEnabled: boolean, expectedTeamId: string);
capture(): Promise<{
actions: {
beforeRealName: string;
desiredName: string;
email: string;
googleUserId: string;
slackUserId: string;
type: "repair-default-name";
}[];
actorUserId: string;
authorityUsers: {
email: string;
googleUserId: string;
name: string;
}[];
planHash: string;
teamId: string;
}>;
readReviewed(reviewed: ReviewedAction<SlackNameAction>): Promise<ReviewedActionState>;
readSourceFingerprint(): Promise<string>;
captureParent(googleUsers?: readonly GoogleDirectoryUser[]): Promise<ParentSlackNameCapture>;
applyReviewed(reviewed: ReviewedAction<SlackNameAction>, context: ReviewedActionContext<SlackNameAction>): Promise<"busy" | "completed">;
}
export declare function slackNameParentEligibility(users: readonly GoogleDirectoryUser[], snapshot: SlackSnapshot, action: SlackNameAction, expectedTeamId: string): ParentNameEligibility;