import { WatchOptions } from 'chokidar'; import { Stats } from 'node:fs'; import { FileReadOptions } from 'node:fs/promises'; import { Readable } from 'node:stream'; import { CrawlOptionsDto } from 'src/dtos/library.dto'; export interface ImmichReadStream { stream: Readable; type?: string; length?: number; } export interface ImmichZipStream extends ImmichReadStream { addFile: (inputPath: string, filename: string) => void; finalize: () => Promise; } export interface DiskUsage { available: number; free: number; total: number; } export const IStorageRepository = 'IStorageRepository'; export interface WatchEvents { onReady(): void; onAdd(path: string): void; onChange(path: string): void; onUnlink(path: string): void; onError(error: Error): void; } export enum StorageEventType { READY = 'ready', ADD = 'add', CHANGE = 'change', UNLINK = 'unlink', ERROR = 'error', } export interface IStorageRepository { createZipStream(): ImmichZipStream; createReadStream(filepath: string, mimeType?: string | null): Promise; readFile(filepath: string, options?: FileReadOptions): Promise; writeFile(filepath: string, buffer: Buffer): Promise; unlink(filepath: string): Promise; unlinkDir(folder: string, options?: { recursive?: boolean; force?: boolean }): Promise; removeEmptyDirs(folder: string, self?: boolean): Promise; checkFileExists(filepath: string, mode?: number): Promise; mkdirSync(filepath: string): void; checkDiskUsage(folder: string): Promise; readdir(folder: string): Promise; stat(filepath: string): Promise; crawl(crawlOptions: CrawlOptionsDto): Promise; walk(crawlOptions: CrawlOptionsDto): AsyncGenerator; copyFile(source: string, target: string): Promise; rename(source: string, target: string): Promise; watch(paths: string[], options: WatchOptions, events: Partial): () => Promise; utimes(filepath: string, atime: Date, mtime: Date): Promise; }