/** * DocumentImportService — FR-W08 文档导入数据层 * * AC1: 支持 PDF/Markdown/纯文本/EPUB,单文件上限 50MB * AC2: 提取进度(已处理分段/总分段) * AC3: 提取结果分类展示 + 逐条/批量确认 * AC4: 来源段落定位 * AC5: 导入摘要 */ import type { ImportFileFormat, ImportProgress, ExtractedCandidate, ImportSummary, ReviewDecision } from './workbench-types.js'; export type ImportEventType = 'progress' | 'candidate-extracted' | 'status-changed' | 'completed' | 'failed'; export interface ImportEvent { type: ImportEventType; taskId: string; timestamp: Date; payload: Record; } export type ImportEventHandler = (event: ImportEvent) => void; export interface SourceLocation { candidateId: string; fileName: string; /** Page number (1-based) for PDF/EPUB, or line range for text/markdown */ pageOrLine: string; /** Character offset range in the original document */ charRange: [start: number, end: number]; /** Raw excerpt from the source document around the extraction point */ contextSnippet: string; } export interface ImportTask { id: string; fileName: string; format: ImportFileFormat; fileSizeBytes: number; progress: ImportProgress; candidates: ExtractedCandidate[]; sourceLocations: Map; summary?: ImportSummary; } export declare class DocumentImportService { private tasks; private idCounter; private emitter; constructor(); /** AC2: Subscribe to import progress events */ on(handler: ImportEventHandler): void; /** Unsubscribe from import events */ off(handler: ImportEventHandler): void; private emit; /** AC1: 验证文件格式和大小 */ validateFile(fileName: string, sizeBytes: number): { valid: boolean; error?: string; }; /** 创建导入任务 */ createTask(fileName: string, format: ImportFileFormat, sizeBytes: number): ImportTask; /** AC2: 更新提取进度 (with event emission) */ updateProgress(taskId: string, processed: number, total: number): void; /** AC3 + AC4: 添加提取候选 (with source location tracking) */ addCandidates(taskId: string, candidates: ExtractedCandidate[], sourceLocations?: SourceLocation[]): void; /** AC4: Get source location for a specific candidate */ getSourceLocation(taskId: string, candidateId: string): SourceLocation | undefined; /** AC4: Get all source locations for a task */ getSourceLocations(taskId: string): SourceLocation[]; /** AC3: 批量审核决策 */ reviewCandidates(taskId: string, decisions: ReviewDecision[]): void; /** AC3: 全选批量确认 */ acceptAll(taskId: string): void; /** AC5: 生成导入摘要 */ finalize(taskId: string): ImportSummary | null; getTask(taskId: string): ImportTask | undefined; } //# sourceMappingURL=document-import-service.d.ts.map