Skip to content
Sarj Workspace Sync

org-sync/channel-model

@sarj-ai/workspace-sync/org-sync/channel-model ยท Source

import { z } from "zod";
import type { GoogleDirectoryUser, SlackMember } from "./model.ts";
export declare const GoogleGroupMemberSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
id: z.ZodString;
role: z.ZodEnum<{
MANAGER: "MANAGER";
MEMBER: "MEMBER";
OWNER: "OWNER";
}>;
status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
ACTIVE: "ACTIVE";
ARCHIVED: "ARCHIVED";
SUSPENDED: "SUSPENDED";
UNKNOWN: "UNKNOWN";
}>>>;
email: z.ZodEmail;
type: z.ZodLiteral<"USER">;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
role: z.ZodEnum<{
MANAGER: "MANAGER";
MEMBER: "MEMBER";
OWNER: "OWNER";
}>;
status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
ACTIVE: "ACTIVE";
ARCHIVED: "ARCHIVED";
SUSPENDED: "SUSPENDED";
UNKNOWN: "UNKNOWN";
}>>>;
email: z.ZodEmail;
type: z.ZodLiteral<"GROUP">;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
role: z.ZodEnum<{
MANAGER: "MANAGER";
MEMBER: "MEMBER";
OWNER: "OWNER";
}>;
status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
ACTIVE: "ACTIVE";
ARCHIVED: "ARCHIVED";
SUSPENDED: "SUSPENDED";
UNKNOWN: "UNKNOWN";
}>>>;
email: z.ZodDefault<z.ZodOptional<z.ZodString>>;
type: z.ZodLiteral<"CUSTOMER">;
}, z.core.$strip>], "type">;
export declare const GoogleGroupSnapshotSchema: z.ZodObject<{
email: z.ZodEmail;
id: z.ZodString;
members: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
id: z.ZodString;
role: z.ZodEnum<{
MANAGER: "MANAGER";
MEMBER: "MEMBER";
OWNER: "OWNER";
}>;
status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
ACTIVE: "ACTIVE";
ARCHIVED: "ARCHIVED";
SUSPENDED: "SUSPENDED";
UNKNOWN: "UNKNOWN";
}>>>;
email: z.ZodEmail;
type: z.ZodLiteral<"USER">;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
role: z.ZodEnum<{
MANAGER: "MANAGER";
MEMBER: "MEMBER";
OWNER: "OWNER";
}>;
status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
ACTIVE: "ACTIVE";
ARCHIVED: "ARCHIVED";
SUSPENDED: "SUSPENDED";
UNKNOWN: "UNKNOWN";
}>>>;
email: z.ZodEmail;
type: z.ZodLiteral<"GROUP">;
}, z.core.$strip>, z.ZodObject<{
id: z.ZodString;
role: z.ZodEnum<{
MANAGER: "MANAGER";
MEMBER: "MEMBER";
OWNER: "OWNER";
}>;
status: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
ACTIVE: "ACTIVE";
ARCHIVED: "ARCHIVED";
SUSPENDED: "SUSPENDED";
UNKNOWN: "UNKNOWN";
}>>>;
email: z.ZodDefault<z.ZodOptional<z.ZodString>>;
type: z.ZodLiteral<"CUSTOMER">;
}, z.core.$strip>], "type">>;
}, z.core.$strip>;
export declare const GoogleGroupIdentitySchema: z.ZodObject<{
email: z.ZodEmail;
id: z.ZodString;
}, z.core.$strip>;
export type GoogleGroupMember = z.output<typeof GoogleGroupMemberSchema>;
export type GoogleGroupSnapshot = z.output<typeof GoogleGroupSnapshotSchema>;
export type GoogleGroupIdentity = z.output<typeof GoogleGroupIdentitySchema>;
export interface SlackChannelSnapshot {
id: string;
isArchived: boolean;
isPrivate: boolean;
memberIds: string[];
name: string;
}
export interface SlackChannelSyncSnapshot {
channels: SlackChannelSnapshot[];
inventory: SlackChannelIdentity[];
members: SlackMember[];
scopes: string[];
teamId: string;
userGroups: SlackUserGroupSnapshot[];
}
export interface SlackUserGroupSnapshot {
channelIds: string[];
handle: string;
id: string;
isDisabled: boolean;
name: string;
userIds: string[];
}
export interface SlackChannelIdentity {
id: string;
isArchived: boolean;
isPrivate: boolean;
name: string;
}
export interface SlackChannelRemovalSafety extends SlackChannelIdentity {
isExternallyShared: boolean;
}
export interface ChannelMembershipChange {
channelId: string;
channelName: string;
identity: string;
isPrivate: boolean;
removalAuthority?: "contractor_group_authoritative" | undefined;
slackUserId: string;
}
export interface ManualManagerTarget {
channelId: string;
channelName: string;
googleRole: "MANAGER" | "OWNER";
identity: string;
slackUserId: string;
verification: "manual_required";
}
export interface OrgChannelPlan {
additions: ChannelMembershipChange[];
channelRenames: ChannelRenameChange[];
errors: string[];
lifecycle: OrgChannelLifecycleAudit;
managerTargets: ManualManagerTarget[];
removals: ChannelMembershipChange[];
userGroups: SlackUserGroupReconciliation[];
warnings: string[];
}
export interface SlackUserGroupMemberChange {
identity: string;
slackUserId: string;
}
export interface SlackUserGroupReconciliation {
authority: SlackUserGroupAuthority;
automationOwnership: SlackUserGroupAutomationOwnership;
channelAdditions: SlackChannelIdentity[];
channelMembershipMode: "additive" | "authoritative";
channelRemovals: SlackChannelIdentity[];
currentHandle: null | string;
currentName: null | string;
desiredChannelIds: string[];
desiredName: string;
desiredUserIds: string[];
effectiveAccessAdditions: ChannelMembershipChange[];
expectedSlackUserGroupId: null | string;
handle: string;
memberAdditions: SlackUserGroupMemberChange[];
memberRemovalAuthority: "contractor_group_authoritative" | "explicit_google_lifecycle" | "google_group_authoritative";
memberRemovals: SlackUserGroupMemberChange[];
membershipMode: ManagedTeamPolicy["membershipMode"];
requiredChannelIds: string[];
rolloutPriority: "canonical_team" | "workspace_union";
slackUserGroupId: null | string;
status: "create" | "in_sync" | "update";
}
export type SlackUserGroupAuthority = {
email: string;
excludedEmails?: string[] | undefined;
excludedIds?: string[] | undefined;
id: string;
kind: "google_group";
} | {
emails: string[];
excludedEmails: string[];
excludedIds: string[];
ids: string[];
kind: "google_group_union";
};
export type SlackUserGroupAutomationOwnership = {
allowedChannelIds: readonly string[];
cutoverRevision: string;
evidenceDigest: string;
excludedGoogleGroupIds: readonly string[];
kind: "automation_created" | "explicitly_adopted";
sourceGoogleGroupIds: readonly string[];
} | {
allowedChannelIds: readonly string[];
evidenceDigest: string;
excludedGoogleGroupIds: readonly string[];
kind: "automation_bootstrap";
sourceGoogleGroupIds: readonly string[];
} | {
kind: "legacy_unmanaged";
};
export interface ChannelRenameChange {
channelId: string;
currentName: string;
expectedName: string;
isPrivate: boolean;
}
export interface OrgChannelLifecycleAudit {
allTeamProjection?: AllTeamProjectionAudit;
canonicalAsksPrivacy?: CanonicalAsksPrivacyAudit[];
googleTeamGroupsOutsideAssignmentAllowlist: GoogleGroupIdentity[];
inventoryVisibility: "token_visible_only";
legacyUserGroupRenameCandidates?: LegacyUserGroupRenameCandidate[];
nonstandardPublicChannels: SlackChannelIdentity[];
privateChannelRenameCandidates: PrivateChannelRenameCandidate[];
slackTeamChannelCollisions: SlackChannelIdentity[];
slackUsersWithoutTeamAssignment: SlackTeamAssignmentGap[];
verticalRetirementCandidates: SlackChannelIdentity[];
}
export interface AllTeamProjectionAudit {
excludedFromSourceMembers: SlackUserGroupMemberChange[];
excludedGoogleGroupEmails: string[];
handle: string;
includedViaAnotherSourceMembers: SlackUserGroupMemberChange[];
preservedSlackOnlyMembers: SlackUserGroupMemberChange[];
removalMode: "deferred";
requiredChannels: SlackChannelIdentity[];
requiredMembers: SlackUserGroupMemberChange[];
sourceGoogleGroupEmails: string[];
}
export interface CanonicalAsksPrivacyAudit {
channelId: null | string;
expectedName: string;
googleGroupEmail: string;
observed: "ambiguous" | "archived" | "missing" | "private" | "public";
}
export interface LegacyUserGroupRenameCandidate {
currentHandle: string;
expectedHandle: string;
slackUserGroupId: string;
}
export interface SlackTeamAssignmentGap {
identity: null | string;
slackUserId: string;
}
export interface PrivateChannelRenameCandidate {
channelId: string;
currentName: string;
expectedName: string;
}
export interface ManagedTeamPolicy {
accessMode: "direct" | "user_group";
additionalChannels?: readonly {
name: string;
}[];
additionalLegacyPrivateChannels?: readonly {
name: string;
}[];
asksChannel: {
name: string;
};
asksMembershipMode: "additive" | "authoritative";
channelMode: "existing" | "none" | "required";
excludedGoogleGroupEmails?: readonly string[];
googleGroupEmail: string;
legacyAsksChannels?: readonly {
name: string;
}[];
legacyPrivateChannel: {
name: string;
};
membershipMode: "additive" | "authoritative";
privateChannel: {
name: string;
};
projectionMode?: "assignment_only" | "slack_user_group";
slackUserGroup: {
automationOwnership?: SlackUserGroupAutomationOwnership;
expectedId?: string;
handle: string;
legacyHandles: readonly string[];
};
userGroupChannelMembershipMode?: "additive" | "authoritative";
}
export interface AllTeamPolicy {
channelMembershipMode?: "additive" | "authoritative";
excludedGoogleGroupEmails: readonly string[];
expectedExcludedGoogleGroupIds?: Readonly<Record<string, string>>;
googleGroupEmails: readonly string[];
membershipMode: "additive" | "authoritative";
protectedGoogleUserIds?: readonly string[];
/** Invite the employee union into active public channels with these prefixes using the existing bounded direct-invitation path. Group defaults and ownership pins remain unchanged. */
publicChannelPrefixes?: readonly string[];
slackUserGroup: {
automationOwnership?: SlackUserGroupAutomationOwnership;
expectedId?: string;
handle: string;
legacyHandles: readonly string[];
};
}
export declare function deriveExcludedGoogleGroupEmails(managedTeams: readonly ManagedTeamPolicy[], allTeam?: AllTeamPolicy): string[];
export declare function buildOrgChannelPlan(input: {
activeGoogleUsers: readonly GoogleDirectoryUser[];
inactiveGoogleUsers?: readonly GoogleDirectoryUser[];
allTeam?: AllTeamPolicy;
allowedPublicChannelNames: readonly string[];
allowedPublicChannelPrefixes: readonly string[];
assignmentGroupEmails: readonly string[];
assignmentGroups: readonly GoogleGroupSnapshot[];
googleGroupInventory: readonly GoogleGroupIdentity[];
managedGroups: readonly GoogleGroupSnapshot[];
managedTeams: readonly ManagedTeamPolicy[];
protectedSlackUserIds?: readonly string[];
requiredPrivateChannelNames?: readonly string[];
slack: SlackChannelSyncSnapshot;
}): OrgChannelPlan;