RM / src /types /api.ts
trretretret's picture
Initial commit: Add research assistant application
b708f13
/**
* Global Type Definitions
* Strictly aligned with FastAPI Pydantic Models (March 2026).
*/
// --- Auth & Identity ---
export interface User {
id: number;
email: string;
full_name?: string;
is_premium: boolean;
}
export interface AuthResponse {
access_token: string;
token_type: string;
}
// --- Research Paper (paper.py) ---
export interface Author {
name: string;
affiliation?: string;
orcid?: string;
}
export interface Paper {
id: number;
openalex_id: string; // ✅ Fixed: Aligned with backend schema
title: string;
authors: Author[]; // ✅ Fixed: Now a structured list of dicts
publication_year: number;
journal_name?: string;
abstract?: string;
doi?: string;
pdf_url?: string;
relevance_score?: number;
created_at: string;
}
// --- Extraction (extraction.py) ---
export type ExtractionStatus = "pending" | "processing" | "completed" | "failed";
export interface Extraction {
id: number; // Primary Key
job_id: string; // ✅ The string ID used as 'pico_context_id'
paper_id: number;
status: ExtractionStatus;
// Flattened PICO structure to match backend storage
pico_population: string;
pico_intervention: string;
pico_comparison: string;
pico_outcome: string;
risk_of_bias_data?: string;
created_at: string;
}
// Helper for Frontend UI (Nested view)
export interface PicoContext {
job_id: string;
population: string;
intervention: string;
comparison: string;
outcome: string;
}
// --- WriteSage (writesage.py) ---
export type StudyDesign = "RCT" | "Systematic Review" | "Meta-Analysis" | "Cohort Study" | "Case Report" | "Observational";
export interface ManuscriptSection {
id: number;
name: string; // e.g., "Abstract", "Introduction"
content: string;
order_index: number;
}
export interface Manuscript {
id: string; // UUID
title: string;
target_journal?: string;
study_design: StudyDesign;
pico_context_id: string; // ✅ Maps directly to Extraction.job_id
sections: ManuscriptSection[]; // ✅ Fixed: Relationship list, not a JSON blob
updated_at: string;
}
// --- Response Wrappers ---
export interface PaginatedResponse<T> {
items: T[];
total: number;
page: number;
size: number;
}