use super::{MilestoneId, NaiveDate, NewProject, Project, ProjectId, Result, UserId, async_trait}; /// Repository for project CRUD operations. /// /// All operations are scoped to a specific user for multi-tenancy support. #[async_trait] pub trait ProjectRepository: Send + Sync { /// Lists all projects for a user. async fn list_all(&self, user_id: UserId) -> Result>; /// Retrieves a project by ID, returning `None` if not found. async fn get_by_id(&self, id: ProjectId, user_id: UserId) -> Result>; /// Creates a new project. async fn create(&self, user_id: UserId, project: NewProject) -> Result; /// Restores a project verbatim from a backup, preserving its original ID /// and `created_at`. Idempotent (`INSERT OR IGNORE`): re-restoring the same /// backup is a no-op rather than a duplicate. async fn restore(&self, user_id: UserId, project: &Project) -> Result<()>; /// Updates an existing project, returning `None` if not found. async fn update( &self, id: ProjectId, user_id: UserId, project: crate::models::UpdateProject, ) -> Result>; /// Deletes a project, returning `true` if deleted. async fn delete(&self, id: ProjectId, user_id: UserId) -> Result; /// Finds a project by exact name match. async fn find_by_name(&self, user_id: UserId, name: &str) -> Result>; } /// Repository for milestone management within projects. #[async_trait] pub trait MilestoneRepository: Send + Sync { /// Lists all milestones for a project, ordered by position. async fn list_by_project( &self, project_id: ProjectId, user_id: UserId, ) -> Result>; /// Lists every milestone for a user across all projects (for full backup export). async fn list_all(&self, user_id: UserId) -> Result>; /// Gets a milestone by ID. async fn get_by_id( &self, id: MilestoneId, user_id: UserId, ) -> Result>; /// Creates a new milestone. async fn create( &self, user_id: UserId, milestone: crate::models::NewMilestone, ) -> Result; /// Updates an existing milestone. async fn update( &self, id: MilestoneId, user_id: UserId, name: &str, description: &str, target_date: Option, status: &crate::models::MilestoneStatus, ) -> Result>; /// Deletes a milestone. async fn delete(&self, id: MilestoneId, user_id: UserId) -> Result; /// Reorders milestones within a project. async fn reorder( &self, project_id: ProjectId, user_id: UserId, milestone_ids: &[MilestoneId], ) -> Result<()>; }