import { FileEntity } from './file-entity.interface'; import { ProcessOptions, ProcessResult } from './processor-options.interface'; /** * 文件处理器基础接口 */ export interface IFileProcessor { /** 处理器名称 */ readonly name: string; /** 支持的MIME类型 */ readonly supportedTypes: string[]; /** * 验证文件是否可以被此处理器处理 * @param buffer 文件缓冲区 * @returns 是否支持 */ validate(buffer: Buffer): Promise; /** * 处理文件 * @param file 文件实体 * @param options 处理选项 * @returns 处理结果 */ process(file: FileEntity, options: ProcessOptions): Promise; /** * 获取处理器信息(可选) */ getInfo?(): ProcessorInfo; /** * 清理资源(可选) */ cleanup?(): Promise; /** * 健康检查(可选) */ healthCheck?(): Promise; } /** * 处理器信息 */ export interface ProcessorInfo { /** 处理器名称 */ name: string; /** 处理器版本 */ version: string; /** 处理器描述 */ description: string; /** 支持的文件类型 */ supportedTypes: string[]; /** 支持的文件扩展名 */ supportedExtensions: string[]; /** 处理器能力 */ capabilities: ProcessorCapabilities; /** 性能指标 */ performance?: { /** 最大文件大小(字节) */ maxFileSize?: number; /** 平均处理时间(毫秒/MB) */ avgProcessTime?: number; /** 内存使用量(MB) */ memoryUsage?: number; }; /** 配置选项 */ configOptions?: Record; } /** * 处理器能力 */ export interface ProcessorCapabilities { /** 是否支持读取 */ read: boolean; /** 是否支持写入 */ write: boolean; /** 是否支持转换 */ transform: boolean; /** 是否支持批量处理 */ batch: boolean; /** 是否支持流式处理 */ stream: boolean; /** 是否支持实时处理 */ realtime: boolean; /** 是否支持并行处理 */ parallel: boolean; /** 是否支持压缩 */ compress: boolean; /** 是否支持加密 */ encrypt: boolean; }