/** * Upload error classes * * Errors thrown during file upload operations. */ import { ComplianceError, type ComplianceErrorOptions } from "./base"; /** * Stage of upload where the error occurred */ export type UploadStage = "request" | "upload" | "confirm"; /** * Error thrown during file upload operations. * * @example * ```typescript * try { * await sdk.documents.upload(file, { clientId: "..." }); * } catch (error) { * if (error instanceof UploadError) { * console.log(`Upload failed at stage: ${error.stage}`); * } * } * ``` */ export declare class UploadError extends ComplianceError { /** * Stage of the upload process where the error occurred: * - "request": Failed to request upload URL * - "upload": Failed to upload file to storage * - "confirm": Failed to confirm upload with API */ readonly stage: UploadStage; /** * The id of the record that was created server-side before the upload * failed, if any. Present on errors thrown at the `upload` or `confirm` * stage of `sdk.evidence.upload()` / `sdk.documents.upload()` — i.e., * the create step succeeded and the record exists in `pending_upload`. * * Use this to call `retryUpload(resourceId, file)` instead of starting * over and orphaning the original record. */ readonly resourceId?: string; constructor(message: string, stage: UploadStage, options?: ComplianceErrorOptions & { resourceId?: string; }); } /** * File exceeds maximum allowed size. * * @example * ```typescript * try { * await sdk.documents.upload(largeFile, { clientId: "..." }); * } catch (error) { * if (error instanceof FileTooLargeError) { * console.log(`Max size: ${error.maxSizeFormatted}`); * console.log(`Your file: ${error.actualSizeFormatted}`); * } * } * ``` */ export declare class FileTooLargeError extends UploadError { /** * Maximum allowed file size in bytes */ readonly maxSize: number; /** * Actual file size in bytes */ readonly actualSize: number; constructor(actualSize: number, maxSize: number); /** * Maximum size formatted for display (e.g., "10 MB") */ get maxSizeFormatted(): string; /** * Actual size formatted for display (e.g., "15.2 MB") */ get actualSizeFormatted(): string; } /** * Upload timed out. */ export declare class UploadTimeoutError extends UploadError { /** * Timeout duration in milliseconds */ readonly timeout: number; constructor(timeout: number, requestId?: string); } /** * Invalid file type. */ export declare class InvalidFileTypeError extends UploadError { /** * Allowed MIME types */ readonly allowedTypes: string[]; /** * Actual MIME type of the file */ readonly actualType: string; constructor(actualType: string, allowedTypes: string[]); } /** * Upload was aborted. */ export declare class UploadAbortedError extends UploadError { constructor(requestId?: string); } /** * Upload URL expired before upload completed. */ export declare class UploadUrlExpiredError extends UploadError { constructor(requestId?: string); } /** * Type guard to check if an error is an upload error. */ export declare function isUploadError(error: unknown): error is UploadError;