import type { DirectoryUser, EnterpriseConnection, EnterpriseConnectionKind, EnterpriseConnectionStatus, EnterpriseOrg, EnterpriseState, ProvisionedGrant } from "./types.js"; export declare function enterpriseStateDir(): string; export declare function enterpriseStatePath(): string; export declare function emptyEnterpriseState(): EnterpriseState; export declare function hasEnterpriseState(): boolean; export declare function loadEnterpriseState(): EnterpriseState | null; /** Atomic write: 0700 dir, 0600 file, tmp + rename. */ export declare function saveEnterpriseState(state: EnterpriseState): void; export type PlatformEnterprisePayload = { org?: EnterpriseOrg; connections?: Array>; roster?: DirectoryUser[]; grants?: ProvisionedGrant[]; }; /** * Merge a platform delivery payload into the local state. Rules: * - connections merge by kind: platform wins unless the local entry is pinned; * local-only kinds are kept; stale platform kinds are dropped. * - roster/grants/org replace wholesale when present in the payload (an * `include` filter on the endpoint may omit sections — those stay local). */ export declare function mergePlatformPayload(local: EnterpriseState | null, payload: PlatformEnterprisePayload): EnterpriseState; /** * Overlay freshly-listed provider users onto the existing roster. Merge key is * the lowercased email; sources union, externalIds merge, a user is active if * ANY source reports them active. */ export declare function mergeRoster(base: DirectoryUser[], updates: DirectoryUser[]): DirectoryUser[]; /** Upsert grant rows by (email, provider). */ export declare function upsertGrants(state: EnterpriseState, grants: ProvisionedGrant[]): EnterpriseState; export declare function upsertLocalConnection(state: EnterpriseState | null, conn: { kind: EnterpriseConnectionKind; config: Record; status?: EnterpriseConnectionStatus; meta?: Record; pinned?: boolean; }): EnterpriseState; export declare function removeConnection(state: EnterpriseState, kind: EnterpriseConnectionKind): EnterpriseState;