/** * Type definitions for SeaVerse Utils SDK */ /** * Utils SDK 配置选项 */ export interface UtilsClientOptions { /** * Bearer Token(必需) */ token: string; /** * API 基础 URL(可选) * @default 'https://resource.seaverse.ai' */ baseURL?: string; /** * 请求超时时间(毫秒) * @default 60000 */ timeout?: number; /** * 图片压缩配置(可选) */ compress?: CompressionConfig; } /** * 图片压缩配置 */ export interface CompressionConfig { /** * 是否启用压缩 * @default true */ enabled?: boolean; /** * 最大宽度(像素) * @default 1080 */ maxWidth?: number; /** * 最大高度(像素) * @default 1080 */ maxHeight?: number; /** * 压缩质量 (0-1) * @default 0.8 */ quality?: number; } /** * 上传选项 */ export interface UploadOptions { /** * 进度回调函数 */ onProgress?: (progress: UploadProgress) => void; /** * 是否压缩(覆盖全局配置) */ compress?: boolean; } /** * 上传进度信息 */ export interface UploadProgress { /** * 已上传字节数 */ loaded: number; /** * 总字节数 */ total: number; /** * 上传进度百分比 (0-100) */ percent: number; /** * 当前上传阶段 */ stage: 'preparing' | 'compressing' | 'uploading' | 'complete'; /** * 上传速度(字节/秒) */ speed?: number; /** * 预计剩余时间(秒) */ remainingTime?: number; } /** * 预签名 URL 请求 */ export interface PresignUploadRequest { /** * 文件 MIME 类型 */ content_type: string; } /** * 预签名 URL 响应数据 */ export interface PresignUploadData { /** * 上传 URL(用于 PUT 文件) */ upload_url: string; /** * 文件存储路径 */ object_path: string; /** * CDN 访问 URL */ cdn_url: string; /** * 过期时间(RFC3339 格式) */ expires_at: string; } /** * 预签名 URL 响应 */ export interface PresignUploadResponse { /** * 状态码 */ code: number; /** * 消息 */ message: string; /** * 数据 */ data: PresignUploadData; } /** * 上传结果 */ export interface UploadResult { /** * 文件名 */ fileName: string; /** * 原始文件名 */ originalFileName: string; /** * CDN 访问 URL */ cdnUrl: string; /** * 存储路径 */ objectPath: string; /** * 文件大小(字节) */ fileSize: number; /** * 原始文件大小(字节) */ originalSize: number; /** * 是否被压缩 */ compressed: boolean; /** * MIME 类型 */ contentType: string; /** * 上传耗时(毫秒) */ duration: number; /** * 过期时间 */ expiresAt: string; } /** * 验证结果 */ export interface ValidationResult { /** * 是否有效 */ valid: boolean; /** * 错误信息列表 */ errors: string[]; } /** * 验证规则 */ export interface ValidationRules { /** * 最大文件大小(字节) * @default 100 * 1024 * 1024 (100MB) */ maxSize?: number; /** * 允许的 MIME 类型列表 * @example ['image/jpeg', 'image/png', 'application/pdf'] */ allowedTypes?: string[]; } /** * 上传错误类 */ export declare class UtilsAPIError extends Error { code: string; statusCode?: number | undefined; response?: any | undefined; constructor(message: string, code: string, statusCode?: number | undefined, response?: any | undefined); } /** * 错误码枚举 */ export declare const ErrorCode: { readonly FILE_TOO_LARGE: "FILE_TOO_LARGE"; readonly INVALID_FILE_TYPE: "INVALID_FILE_TYPE"; readonly PRESIGNED_URL_FAILED: "PRESIGNED_URL_FAILED"; readonly UPLOAD_FAILED: "UPLOAD_FAILED"; readonly COMPRESSION_FAILED: "COMPRESSION_FAILED"; readonly NETWORK_ERROR: "NETWORK_ERROR"; readonly TIMEOUT: "TIMEOUT"; readonly VALIDATION_FAILED: "VALIDATION_FAILED"; }; export type ErrorCodeType = typeof ErrorCode[keyof typeof ErrorCode]; /** * 压缩结果 */ export interface CompressionResult { /** * 原始文件 */ originalFile: File; /** * 压缩后的文件 */ compressedFile: File; /** * 原始大小(字节) */ originalSize: number; /** * 压缩后大小(字节) */ compressedSize: number; /** * 压缩率 (0-1) */ compressionRatio: number; /** * 图片宽度 */ width: number; /** * 图片高度 */ height: number; } //# sourceMappingURL=models.d.ts.map