// Database model interfaces
export interface User {
  id: string;
  email: string;
  name: string;
  password_hash: string;
  role: 'user' | 'admin';
  created_at: Date;
  updated_at: Date;
  last_login?: Date;
  is_active: boolean;
}

export interface Document {
  id: string;
  user_id: string;
  original_file_name: string;
  file_path: string;
  file_size: number;
  uploaded_at: Date;
  status: ProcessingStatus;
  extracted_text?: string;
  generated_summary?: string;
  summary_markdown_path?: string;
  summary_pdf_path?: string;
  processing_started_at?: Date;
  processing_completed_at?: Date;
  error_message?: string;
  analysis_data?: any; // BPCP CIM Review Template data
  created_at: Date;
  updated_at: Date;
}

export interface DocumentFeedback {
  id: string;
  document_id: string;
  user_id: string;
  feedback: string;
  regeneration_instructions?: string;
  created_at: Date;
}

export interface DocumentVersion {
  id: string;
  document_id: string;
  version_number: number;
  summary_markdown: string;
  summary_pdf_path: string;
  feedback?: string;
  created_at: Date;
}

export interface ProcessingJob {
  id: string;
  document_id: string;
  type: JobType;
  status: JobStatus;
  progress: number;
  error_message?: string;
  created_at: Date;
  started_at?: Date;
  completed_at?: Date;
}

export type ProcessingStatus = 
  | 'uploading'
  | 'uploaded' 
  | 'extracting_text' 
  | 'processing_llm' 
  | 'generating_pdf' 
  | 'enhanced_processing'
  | 'vector_indexing'
  | 'advanced_analysis'
  | 'basic_analysis'
  | 'analysis_complete'
  | 'financial_analysis'
  | 'quality_validation'
  | 'refinement'
  | 'saving_results'
  | 'completed' 
  | 'failed';

export type JobType = 'text_extraction' | 'llm_processing' | 'pdf_generation';

export type JobStatus = 'pending' | 'processing' | 'completed' | 'failed';

// Database query result types
export interface UserWithDocuments extends User {
  documents?: Document[];
}

export interface DocumentWithFeedback extends Document {
  feedback?: DocumentFeedback[];
  versions?: DocumentVersion[];
  processing_jobs?: ProcessingJob[];
}

// Input types for creating/updating records
export interface CreateUserInput {
  email: string;
  name: string;
  password: string;
  role?: 'user' | 'admin';
}

export interface CreateDocumentInput {
  user_id: string;
  original_file_name: string;
  file_path: string;
  file_size: number;
  status?: ProcessingStatus;
}

export interface CreateDocumentFeedbackInput {
  document_id: string;
  user_id: string;
  feedback: string;
  regeneration_instructions?: string;
}

export interface CreateDocumentVersionInput {
  document_id: string;
  version_number: number;
  summary_markdown: string;
  summary_pdf_path: string;
  feedback?: string;
}

export interface CreateProcessingJobInput {
  document_id: string;
  type: JobType;
  job_id?: string;
} 