import { type Readable } from "node:stream"; export interface ByteRange { start: number; end: number; } export interface StagedObject { id: string; size: number; /** A private local copy used only for inspection before commit. */ inspectionPath: string; } export interface ResumableUpload { id: string; ownerUserId: string; filename: string; contentType?: string; size: number; offset: number; createdAt: string; updatedAt: string; } export interface CleanupResult { expiredUploadIds: string[]; deletedQuarantineIds: string[]; deletedQuarantineObjects: number; } export interface StageOptions { id?: string; onBytes?: (bytes: number) => Promise; } export interface CompletedResumableUpload { uploadId: string; ownerUserId: string; fileId: string; completedAt: string; } /** * Storage boundary used by FileStorage. Remote providers may stage locally for * inspection, then implement commit/open with object storage or multipart APIs. */ export interface FileStorageProvider { stage(input: Readable, maximumBytes: number, options?: StageOptions): Promise; stageBuffer(input: Buffer, id?: string): Promise; commit(staged: StagedObject, storageName: string): Promise; discard(staged: StagedObject): Promise; quarantine(staged: StagedObject, reason: string): Promise; open(storageName: string, range?: ByteRange): Readable; pathFor?(storageName: string): string; sizeOf(storageName: string): Promise; writeVariant(storageName: string, variant: MediaVariant, input: Buffer): Promise; openVariant(storageName: string, variant: MediaVariant): Readable; variantSize(storageName: string, variant: MediaVariant): Promise; delete(storageName: string): Promise; committedBytes(): Promise; createResumable(input: Omit): Promise; resumableState(uploadId: string): Promise; appendResumable(uploadId: string, expectedOffset: number, input: Readable, maximumChunkBytes: number): Promise; finishResumable(uploadId: string): Promise<{ upload: ResumableUpload; staged: StagedObject; }>; completedResumable(uploadId: string): Promise; recordResumableCompletion(completion: CompletedResumableUpload): Promise; cancelResumable(uploadId: string): Promise; cleanup(before: Date, quarantineBefore: Date): Promise; cleanupOrphans(referencedStorageNames: Set, before: Date): Promise; } export type MediaVariant = "thumbnail" | "preview"; export declare class UploadLimitError extends Error { constructor(message: string); } export declare class UploadOffsetError extends Error { readonly actualOffset: number; constructor(actualOffset: number); } export declare class UploadIncompleteError extends Error { readonly actualOffset: number; readonly expectedSize: number; constructor(actualOffset: number, expectedSize: number); } export declare class UploadNotFoundError extends Error { constructor(); } export declare class LocalFileStorageProvider implements FileStorageProvider { readonly directory: string; private readonly stagingDirectory; private readonly uploadDirectory; private readonly quarantineDirectory; private readonly receiptDirectory; private readonly lockPath; private queue; constructor(directory: string); stage(input: Readable, maximumBytes: number, options?: StageOptions): Promise; stageBuffer(input: Buffer, suppliedId?: string): Promise; commit(staged: StagedObject, storageName: string): Promise; discard(staged: StagedObject): Promise; quarantine(staged: StagedObject, reason: string): Promise; open(storageName: string, range?: ByteRange): Readable; pathFor(storageName: string): string; sizeOf(storageName: string): Promise; writeVariant(storageName: string, variant: MediaVariant, input: Buffer): Promise; openVariant(storageName: string, variant: MediaVariant): Readable; variantSize(storageName: string, variant: MediaVariant): Promise; delete(storageName: string): Promise; committedBytes(): Promise; createResumable(input: Omit): Promise; resumableState(uploadId: string): Promise; appendResumable(uploadId: string, expectedOffset: number, input: Readable, maximumChunkBytes: number): Promise; finishResumable(uploadId: string): Promise<{ upload: ResumableUpload; staged: StagedObject; }>; cancelResumable(uploadId: string): Promise; completedResumable(uploadId: string): Promise; recordResumableCompletion(completion: CompletedResumableUpload): Promise; cleanup(before: Date, quarantineBefore: Date): Promise; cleanupOrphans(referencedStorageNames: Set, before: Date): Promise; private objectPath; private stagedPath; private variantPath; private uploadDataPath; private uploadManifestPath; private receiptPath; private writeUploadManifest; private ensureDirectories; private serialized; } export declare function parseUpload(input: string): ResumableUpload; export declare function parseCompletion(input: string): CompletedResumableUpload; //# sourceMappingURL=provider.d.ts.map