import { type IdentityDatabase } from './db'; export interface PodLookupResult { podId: string; accountId: string; baseUrl: string; storageUrl?: string; webId?: string; webIds?: string[]; nodeId?: string; edgeNodeId?: string; } /** * Repository for Pod lookup operations. * * Reads Pod facts from the canonical identity_store table and from CSS * WrappedIndexedStorage rows when that storage backend is active. * * 点查(findById / findAllByWebId / findByWebIds / listByAccountId)走字段下推 * 快路径,避免每请求全扫 identity_store;KV 历史账户记录独立读取, * 同 ID 的 canonical 记录整条优先,包括无法解析的记录,不能恢复旧身份。 * findByResourceIdentifier / listAllPods 本质上需要 * 候选全集,仍保留全量读取(identity_store 侧用反向前缀 LIKE 下推预筛)。 */ export declare class PodLookupRepository { private readonly db; private readonly kvTableName; private readonly indexedStoreTableName; constructor(db: IdentityDatabase, kvTableName?: string); /** * Find Pod by resource path (matches longest canonical storage/base URL prefix). * * kv 账户行无法按 URL 下推,保持全量解析(cloud 部署 kv 为空,local 规模有限)。 */ findByResourceIdentifier(resourcePath: string): Promise; /** * Get Pod by ID. * * 快路径按主键直查 identity_store 的 pod 行并补齐 owner/node 关联; * 独立读取 KV 历史记录,并按原始 ID 检查 canonical 遮蔽。 */ findById(podId: string): Promise; /** * Find Pod by an explicit owner or pod.webId URL. * * Pod ownership stores WebIDs separately from Pod base URLs. This is * the precise lookup for IdP/SP split deployments where the WebID path does * not have to match the storage base URL. */ findByWebId(webId: string): Promise; /** * Find all Pods explicitly owned by a WebID. * * A Cloud WebID can legitimately back both a Cloud Pod and a Local SP Pod. * Callers that are scoped to a storage provider must inspect all candidates * instead of accepting the first account record returned by CSS storage. */ findAllByWebId(webId: string): Promise; /** * Find Pods by explicit WebID bindings with batched canonical queries. */ findByWebIds(webIds: string[]): Promise; /** * List Pods for a specific account. * * 定向查询与全扫描等价:kv 按账户键直取,identity_store 按 accountId 下推, * canonical 整条优先与 getAllPods 一致,KV 扫描补齐 .json 等历史键。 */ listByAccountId(accountId: string): Promise; /** * List all pods. */ listAllPods(): Promise; /** * Extract all pods from the configured CSS identity storage. */ private getAllPods; private getLegacyPods; private extractKvPods; private getAccountRowsFromKv; private getNodeAssignments; private mergeCanonicalPods; private extractPodsFromAccountData; /** * 与全扫描一致的 WebID 匹配过滤:按 Pod 解析后的 WebID 列表按原字符串比较, * 命中时附加该 Pod 自身存储的 WebID。 */ private filterPodsByWebIds; /** * DrizzleIndexedStorage stores CSS identity facts as typed rows in * identity_store; this is the canonical clustered identity source. */ private getPodsFromIndexedStore; /** * 按主键直查 identity_store pod 行并补齐关联。 */ private getIndexedStorePodsByIds; /** * 按 payload.accountId 下推查询 identity_store pod 行并补齐关联。 */ private getIndexedStorePodsByAccountId; /** * 反向前缀 LIKE 预筛候选 pod 行(baseUrl/storageUrl/storage 任一前缀), * JS 侧 startsWith 复核由调用方(findByResourceIdentifier)执行。 */ private findIndexedStorePodsByResource; /** * WebID → Pod 的下推解析:owner 按 webId 命中拿 podId,pod.webId * 直查;Account webIdLink 不建立 Pod ownership。 * webIdForms 只携带完整原字符串;URL 等价不代表相同身份。 */ private findIndexedStorePodsByWebIds; /** * 为候选 pod 行补齐 owner 关联与 nodeAssignments,组装最终结果。 * 与全扫描共用 buildIndexedStorePods,保证返回形状一致。 */ private enrichIndexedStorePods; private queryIndexedStoreRows; /** * 组装 identity_store Pod 视图:pod 行为主体,owner 行补充 WebID, * nodeAssignments 兜底 nodeId。全扫描与下推快路径共用,保证返回形状一致。 */ private buildIndexedStorePods; }