/** * Lightweight IndexedDB persistence layer for Image Generation Gallery. * Stores lightweight metadata indexes; image binaries remain managed by DSH Attachment service. * Supports tombstones to ensure deleted items are never resurrected when revisiting conversations. */ import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment'; import type { ImageProvider } from '../shared.js'; export interface GalleryItem { id: string; attachment: ImageAttachmentRef; prompt: string; provider: ImageProvider; model: string; createdAt: number; aspectRatio?: string | undefined; imageSize?: string | undefined; output?: string | undefined; /** Workflow seed reported by the ComfyUI provider. Optional so records written by older versions stay readable; the object store is schemaless, so no IndexedDB version bump is needed. */ seed?: number | undefined; /** Saved file path on workspace disk if savedTo was returned */ savedTo?: string | undefined; /** Whether this item is marked as favorite */ isFavorite?: boolean | undefined; /** Custom tags or collection markers */ tags?: string[] | undefined; /** Workspace filesystem path where the image was generated/saved */ workspacePath?: string | undefined; /** Workspace ID if known */ workspaceId?: string | undefined; /** Conversation session ID where the image was generated */ sessionId?: string | undefined; /** Attachment ids of the source images this image was edited from; used by the canvas to rebuild edit chains. Optional so records written by older versions stay readable. */ sourceAttachmentIds?: string[] | undefined; } type GalleryListener = () => void; /** * Subscribe to gallery mutations (insert/delete/clear). */ export declare function subscribeGallery(listener: GalleryListener): () => void; /** * Save or update a gallery record by attachmentId. * Skipped if the item was previously deleted (tombstoned). * Preserves existing isFavorite, tags, and original createdAt on re-renders. * Returns false when the record was not persisted (e.g. IndexedDB unavailable) * so callers can surface the failure and let the user retry. */ export declare function saveGalleryItem(item: Omit & { createdAt?: number; }): Promise; /** * Retrieve all gallery records sorted by createdAt descending. */ export declare function getGalleryItems(): Promise; /** * Toggle favorite status of a gallery item. * Returns the new favorite status (true if favorited, false if unfavorited). */ export declare function toggleFavoriteGalleryItem(id: string): Promise; /** * Delete a single gallery record by ID and record a tombstone. */ export declare function deleteGalleryItem(id: string): Promise; /** * Bulk delete multiple gallery records by IDs and record tombstones in a single transaction. */ export declare function bulkDeleteGalleryItems(ids: string[]): Promise; /** * Bulk update favorite status for multiple gallery records in a single transaction. */ export declare function bulkSetFavoriteGalleryItems(ids: string[], isFavorite: boolean): Promise; /** * Clear all gallery records and reset tombstones. */ export declare function clearGallery(): Promise; /** * Standardize path format across Windows and POSIX (lowercase, forward slashes, no trailing slash). */ export declare function normalizeWorkspacePath(rawPath: string): string; /** * Determine if a gallery item belongs to the given workspace context. * Compares workspaceId, sessionId membership, workspacePath, and savedTo file path prefix. */ export declare function isItemInWorkspace(item: GalleryItem, workspace?: { workspaceId?: string | undefined; path?: string | undefined; sessionIds?: readonly string[] | undefined; } | null): boolean; export {};