Files
botsmann/types/document.ts
T
g-butandClaude Opus 4.5 6da1c37668 refactor: extract document status to constants and shared component (SSOT)
- Added DOCUMENT_STATUS constant to lib/constants.ts
- Added DocumentStatusType derived from constant
- Added DOCUMENT_STATUS_CONFIG for display (labels, colors)
- Created DocumentStatusBadge shared component
- Updated types/document.ts to use DocumentStatusType
- Updated app/documents/page.tsx to use shared component and constants

Changes to add a new status now require only 1 file (lib/constants.ts).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-23 18:45:37 +01:00

70 lines
1.3 KiB
TypeScript

/**
* Document types for the RAG system
*/
import { type DocumentStatusType } from '@/lib/constants';
export interface Document {
id: string;
user_id: string;
name: string;
type: string;
size_bytes: number;
storage_path: string;
status: DocumentStatusType;
error_message?: string;
chunk_count?: number;
created_at: string;
updated_at: string;
}
export interface DocumentChunk {
id: string;
document_id: string;
user_id: string;
content: string;
embedding: number[];
metadata: {
chunk_index: number;
start_char?: number;
end_char?: number;
};
created_at: string;
}
export interface DocumentUploadResponse {
success: boolean;
document?: Document;
error?: string;
}
export interface DocumentListResponse {
success: boolean;
documents?: Document[];
error?: string;
}
export interface DocumentSearchResult {
chunk_id: string;
document_id: string;
document_name: string;
content: string;
similarity: number;
}
export interface SearchResponse {
success: boolean;
results?: DocumentSearchResult[];
error?: string;
}
export type SupportedFileType = 'text/plain' | 'text/markdown' | 'application/pdf';
export const SUPPORTED_FILE_TYPES: SupportedFileType[] = [
'text/plain',
'text/markdown',
'application/pdf',
];
export const MAX_FILE_SIZE = 10 * 1024 * 1024; // 10MB