import type { JsonValue } from './canonical-model'; export type ImportFormat = 'CSV' | 'HTML' | 'Excel' | 'JSON' | 'XML'; export type ImportStatus = 'complete' | 'partial' | 'failed'; export type ImportDiagnosticSeverity = 'info' | 'warning' | 'error'; export type ImportValueType = 'empty' | 'string' | 'number' | 'boolean' | 'date' | 'json'; export type ImportProcessingStage = 'format-decoding' | 'structure-decoding' | 'extraction' | 'mapping' | 'normalization' | 'persistence'; export type ImportProcessingStatus = 'pending' | 'running' | 'complete' | 'partial' | 'failed' | 'skipped'; export type ImportProcessorKind = 'format-adapter' | 'source-extractor' | 'mapping-profile' | 'normalizer' | 'artifact-parser' | 'repository'; export type ImportFormatEvidenceSignal = 'file-signature' | 'container-signature' | 'content-structure' | 'extension' | 'media-type'; export interface ImportFormatEvidence { signal: ImportFormatEvidenceSignal; format?: ImportFormat; contribution: number; message: string; } export interface ImportFormatCandidate { format: ImportFormat; score: number; evidence: ImportFormatEvidence[]; } export interface ImportFormatDetectionResult { version: 1; selected: ImportFormat; score: number; candidates: ImportFormatCandidate[]; evidence: ImportFormatEvidence[]; conflicts: ImportFormatEvidence[]; structurallyValidated: boolean; requiresParserValidation: boolean; binary: boolean; containerKind?: 'zip' | 'excel-zip' | 'ole'; } export interface ImportProcessorReference { kind: ImportProcessorKind; id: string; version: string; } export interface SourceLocator { fileName: string; relativePath?: string; containerEntryPath?: string; tableIndex?: number; rowIndex?: number; columnIndex?: number; cellReference?: string; objectPath?: string; elementSelector?: string; } export interface ImportTransformationRecord { id: string; version: string; kind: 'decode' | 'sanitize' | 'flatten-for-compatibility' | 'extract' | 'map' | 'normalize'; lossless: boolean; } export interface ImportProvenance { version: 1; source: SourceLocator; processor: ImportProcessorReference; transformations: ImportTransformationRecord[]; } export interface ImportProcessingState { stage: ImportProcessingStage; status: ImportProcessingStatus; processor: ImportProcessorReference; diagnosticCodes: string[]; } export interface ImportSourcePosition extends Omit { fileName?: string; tableIndex: number; } export interface ImportFileMetadata { name: string; sizeBytes: number; lastModified: number; extension: string; mediaType?: string; encoding?: string; } export interface ImportCell { rawValue: JsonValue; decodedValue: string; detectedType: ImportValueType; source: ImportSourcePosition; } export interface ImportRow { index: number; cells: ImportCell[]; source: ImportSourcePosition; /** Der Bericht markiert diese Zeile selbst (z. B. CIS-CAT: ``). */ highlighted?: boolean; } export interface HeaderCandidate { rowIndex: number; headers: string[]; confidence: number; reason: string; } export interface ImportColumn { index: number; headerCandidates: Array<{ rowIndex: number; value: string; confidence: number; }>; } export interface ImportTable { id: string; name: string; index: number; columns: ImportColumn[]; rows: ImportRow[]; rawText: string; headerCandidates: HeaderCandidate[]; attributes: Record; } export interface ImportDiagnostic { severity: ImportDiagnosticSeverity; code: string; message: string; stage?: ImportProcessingStage; source?: SourceLocator; provenance?: ImportProvenance; details?: JsonValue; } export interface DiscardedImportContent { kind: string; reason: string; count?: number; source?: SourceLocator; details?: JsonValue; } export interface DecodedViewBase { id: string; name: string; source: SourceLocator; provenance: ImportProvenance; attributes: Record; } export interface DecodedTableView extends DecodedViewBase { kind: 'table'; tableId: string; } export interface DecodedObjectView extends DecodedViewBase { kind: 'object'; rootKind: 'object' | 'array' | 'primitive'; value: JsonValue; } export interface DecodedHierarchyNode { path: string; name: string; value?: JsonValue; attributes: Record; source: SourceLocator; } export interface DecodedHierarchyView extends DecodedViewBase { kind: 'hierarchy'; nodes: DecodedHierarchyNode[]; } export interface DecodedTextView extends DecodedViewBase { kind: 'text'; text: string; } export interface DecodedContainerEntry { path: string; sizeBytes?: number; mediaType?: string; encoding?: string; source: SourceLocator; } export interface DecodedContainerView extends DecodedViewBase { kind: 'container'; entries: DecodedContainerEntry[]; } export type DecodedSourceView = DecodedTableView | DecodedObjectView | DecodedHierarchyView | DecodedTextView | DecodedContainerView; export interface DecodedSourceDocument { version: 1; status: ImportStatus; format: ImportFormat; file: ImportFileMetadata; rawText: string; tables: ImportTable[]; diagnostics: ImportDiagnostic[]; discardedContent: DiscardedImportContent[]; views: DecodedSourceView[]; processing: ImportProcessingState[]; formatDetection?: ImportFormatDetectionResult; } /** Compatibility name used by the current UI and recognition pipeline. */ export type ImportDocument = DecodedSourceDocument;