/** * Document Upload Utilities * * Provides browser and Node.js compatible file upload with progress tracking. * Handles the complete upload flow: presigned URL → PUT upload → confirmation. */ import type { PresignedUploadUrl } from "@artu-ai/shared"; /** * Maximum file size in bytes (25 MB). * Must match the server-side limit. */ export declare const MAX_FILE_SIZE_BYTES: number; /** * Default upload timeout in milliseconds (5 minutes). */ export declare const DEFAULT_UPLOAD_TIMEOUT_MS: number; /** * File-like object that can be uploaded. * Compatible with browser File, Blob, and Node.js Buffer. */ export interface UploadableFile { /** File name */ name: string; /** MIME type */ type: string; /** File size in bytes */ size: number; /** For browser: the file/blob itself. For Node: Buffer or stream. */ data: Blob | Buffer | ArrayBuffer; } /** * Progress callback function. * @param progress - Upload progress from 0 to 1 */ export type ProgressCallback = (progress: number) => void; /** * Options for uploading a file to storage. */ export interface UploadToStorageOptions { /** Progress callback (0-1) */ onProgress?: ProgressCallback; /** AbortSignal for cancellation */ signal?: AbortSignal; /** Timeout in milliseconds */ timeout?: number; } /** * Result of a successful storage upload. */ export interface UploadToStorageResult { /** Whether the upload was successful */ success: true; } /** * Normalizes a file input to an UploadableFile. * Accepts browser File/Blob or Node.js Buffer with metadata. */ export declare function normalizeFile(file: File | Blob | UploadableFile | { buffer: Buffer; name: string; type: string; }): UploadableFile; /** * Validates file size before upload. * @throws FileTooLargeError if file exceeds limit */ export declare function validateFileSize(size: number): void; /** * Uploads a file to storage using a presigned PUT URL. * * Sends the file body directly with a Content-Type header. * Uses XMLHttpRequest in browsers for progress tracking, * falls back to fetch in Node.js (no progress). * * @param file - The file to upload * @param presigned - Presigned URL info from the API * @param options - Upload options * @returns Upload result * @throws UploadError on failure */ export declare function uploadToStorage(file: UploadableFile, presigned: PresignedUploadUrl, options?: UploadToStorageOptions): Promise;