mod schema;
mod sqlite;
mod error;
pub mod jsonl;
pub use sqlite::SqliteStorage;
pub use error::StorageError;
pub use jsonl::{export_to_jsonl, import_from_jsonl, sync_jsonl, ExportStats, ImportStats};
use crate::types::{
BlockedIssue, Comment, Dependency, DependencyType, Event, Issue,
IssueFilter, Statistics,
};
pub type Result<T> = std::result::Result<T, StorageError>;
pub trait Storage: Send + Sync {
fn create_issue(&self, issue: &Issue) -> Result<()>;
fn create_issues(&self, issues: &[Issue]) -> Result<()>;
fn get_issue(&self, id: &str) -> Result<Option<Issue>>;
fn get_issue_by_external_ref(&self, external_ref: &str) -> Result<Option<Issue>>;
fn update_issue(&self, issue: &Issue) -> Result<()>;
fn close_issue(&self, id: &str, actor: &str, reason: Option<&str>) -> Result<()>;
fn delete_issue(&self, id: &str, actor: &str, reason: Option<&str>) -> Result<()>;
fn search_issues(&self, filter: &IssueFilter) -> Result<Vec<Issue>>;
fn add_dependency(&self, dep: &Dependency) -> Result<()>;
fn remove_dependency(&self, issue_id: &str, depends_on_id: &str) -> Result<()>;
fn get_dependencies(&self, issue_id: &str) -> Result<Vec<Dependency>>;
fn get_dependents(&self, issue_id: &str) -> Result<Vec<Dependency>>;
fn would_create_cycle(&self, from_id: &str, to_id: &str, dep_type: DependencyType) -> Result<bool>;
fn get_ready_work(&self) -> Result<Vec<Issue>>;
fn get_blocked_issues(&self) -> Result<Vec<BlockedIssue>>;
fn is_blocked(&self, issue_id: &str) -> Result<bool>;
fn add_label(&self, issue_id: &str, label: &str) -> Result<()>;
fn remove_label(&self, issue_id: &str, label: &str) -> Result<()>;
fn get_labels(&self, issue_id: &str) -> Result<Vec<String>>;
fn get_issues_by_label(&self, label: &str) -> Result<Vec<Issue>>;
fn add_comment(&self, issue_id: &str, author: &str, text: &str) -> Result<i64>;
fn get_comments(&self, issue_id: &str) -> Result<Vec<Comment>>;
fn get_events(&self, issue_id: &str) -> Result<Vec<Event>>;
fn set_config(&self, key: &str, value: &str) -> Result<()>;
fn get_config(&self, key: &str) -> Result<Option<String>>;
fn delete_config(&self, key: &str) -> Result<()>;
fn get_all_config(&self) -> Result<std::collections::HashMap<String, String>>;
fn mark_dirty(&self, issue_id: &str) -> Result<()>;
fn get_dirty_issues(&self) -> Result<Vec<String>>;
fn clear_dirty(&self, issue_ids: &[String]) -> Result<()>;
fn get_statistics(&self) -> Result<Statistics>;
fn next_child_counter(&self, parent_id: &str) -> Result<u32>;
fn transaction<F, T>(&self, f: F) -> Result<T>
where
F: FnOnce() -> Result<T>;
fn close(&self) -> Result<()>;
}