import type { IdentityDatabase } from './db'; export interface AccountRoleContext { accountId: string; webId?: string; roles: string[]; } export interface AccountRoleRepositoryOptions { /** * CSS 文件存储时代的账户目录(`.internal/accounts/data`)。 * 仅在迁移期兜底读取;默认按进程 CWD 惰性解析,桌面/集群部署应显式注入。 */ legacyAccountDataDir?: string; } export declare class AccountRoleRepository { private readonly db; private readonly logger; private readonly legacyAccountDataDir?; constructor(db: IdentityDatabase, options?: AccountRoleRepositoryOptions); findByAccountId(accountId: string): Promise; findByWebId(webId: string): Promise; findByWebIdLoose(webId: string): Promise; listAccounts(): Promise; addRoles(accountId: string, roles: string[]): Promise; /** * 按主键直查 identity_store 中的 account 行;表不存在时返回 undefined(由调用方走兜底)。 */ private getIdentityStoreAccount; /** * 按 CSS 行契约(webIdLink.accountId、pod.accountId、owner.podId)下推查询账户的 WebID。 */ private findWebIdsForAccount; /** * WebID → accountId 的下推解析:webIdLink 优先,其次 account 行内嵌 webId 字段, * 最后 owner→pod 链路。全部 miss 返回 undefined(调用方再走全量兜底)。 */ private findAccountIdByWebId; /** * owner→pod 链路里把 owner 行的 podId 与 pod 行的 id 对齐。 */ private ownerPodJoin; /** * legacy 来源:internal_kv 与文件账户(迁移期兜底),不含 identity_store。 */ private loadLegacyAccounts; private loadAllAccounts; private loadIdentityStoreAccounts; private loadInternalKvAccounts; private loadFileAccountMap; private updateAccountRecord; private toJsonSql; private isTableMissing; }