import type { ShareRecord, ShareConfig, CreateShareParams, WorkspaceShareRecord, NoteShareRecord, SessionShareRecord, DirectoryShareRecord } from './share-types.js'; export interface DirectoryListingEntry { name: string; /** Workspace/share-relative POSIX path. */ path: string; isDirectory: boolean; size: number; mtime: string; mimeType: string; } export interface DirectoryListing { /** Share-relative path of the listed dir ('' for root). */ path: string; entries: DirectoryListingEntry[]; truncated: boolean; } export declare class ShareStore { private shares; private cleanupTimer; private config; private listingCache; /** Optional cleanup hook invoked when a share record is dropped (e.g. delete thumbnail). */ private onCleanup; constructor(config?: Partial); private saveNew; updateConfig(config: Partial): void; /** Register a cleanup hook (idempotent — last wins). */ setCleanupHook(hook: (record: ShareRecord) => void): void; getConfig(): ShareConfig; create(params: CreateShareParams & { workspaceRoot: string; gatewayTokenHash: string; }): Promise; private createFileShare; private createDirectoryShare; private buildRecord; createNoteShare(input: { id: string; sourceNoteId: string; sourceVersion: number; artifactRelativePath: string; artifactSize: number; attachmentCount: number; snapshotRevision?: number; fileName: string; ttlMs?: number; maxViews?: number | null; description?: string; gatewayTokenHash: string; }): NoteShareRecord; updateNoteSnapshot(id: string, patch: { sourceVersion: number; artifactSize: number; attachmentCount: number; fileName: string; }): NoteShareRecord | null; getNoteShares(noteId: string): NoteShareRecord[]; createSessionShare(input: { id: string; sourceSessionId: string; cutoffSeq: number; artifactRelativePath: string; artifactSize: number; messageCount: number; attachmentCount?: number; includeToolActivities?: boolean; snapshotRevision?: number; fileName: string; ttlMs?: number; maxViews?: number | null; description?: string; gatewayTokenHash: string; }): SessionShareRecord; getSessionShares(sessionId: string): SessionShareRecord[]; updateSessionSnapshot(id: string, patch: { cutoffSeq: number; artifactSize: number; messageCount: number; attachmentCount: number; includeToolActivities: boolean; fileName: string; }): SessionShareRecord | null; private persistAndAudit; getById(id: string): ShareRecord | null; getByToken(token: string): ShareRecord | null; /** Validate a share is still accessible for download. Returns null reason if valid. */ validateAccess(record: ShareRecord): { valid: boolean; reason?: string; }; /** Increment download counter (used by directory & file downloads). Persisted before returning. */ incrementDownloadCount(id: string): void; /** Atomically validate and consume one access in the single-threaded store. */ consumeAccess(id: string): { valid: true; } | { valid: false; reason: string; }; /** Check if the file still exists and inode matches. */ validateFileIntegrity(record: WorkspaceShareRecord): Promise<{ valid: boolean; reason?: string; }>; /** * Resolve a child path inside a directory share. Returns the absolute path * if it stays within both the share root and the workspace. */ resolveDirectoryChild(record: DirectoryShareRecord, relativePath: string): Promise<{ ok: true; absolutePath: string; } | { ok: false; reason: string; }>; /** List a single directory level (cached, share-root-relative). */ listDirectory(record: DirectoryShareRecord, relativePath: string): Promise; /** Update thumbnail status. Persists immediately so generator restart is safe. */ setThumbnailStatus(id: string, status: 'pending' | 'ready' | 'failed'): void; /** Drop the listing cache for a share (used on revoke/update). */ invalidateListingCache(shareId: string): void; revoke(id: string): boolean; revokeMany(ids: string[]): number; revokeExpired(): number; update(id: string, patch: { extendTtlMs?: number; maxViews?: number | null; }): ShareRecord | null; getActiveShares(): ShareRecord[]; getAllShares(): ShareRecord[]; private startCleanupTimer; private cleanupExpired; shutdown(): void; private resolveAndValidatePath; private cleanupStateArtifact; } export declare function resolveMimeType(fileName: string): string; /** HTTP Content-Type with charset for text-like bodies (browser inline preview). */ export declare function shareResponseContentType(mime: string): string; export declare function getShareStore(config?: Partial): ShareStore; export declare function resetShareStoreForTests(): void;