use crate::{domain::entities::Event, error::Result};
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use uuid::Uuid;
#[async_trait]
pub trait EventRepository: Send + Sync {
async fn save(&self, event: &Event) -> Result<()>;
async fn save_batch(&self, events: &[Event]) -> Result<()>;
async fn find_by_id(&self, id: Uuid) -> Result<Option<Event>>;
async fn find_by_entity(&self, entity_id: &str, tenant_id: &str) -> Result<Vec<Event>>;
async fn find_by_type(&self, event_type: &str, tenant_id: &str) -> Result<Vec<Event>>;
async fn find_by_time_range(
&self,
tenant_id: &str,
start: DateTime<Utc>,
end: DateTime<Utc>,
) -> Result<Vec<Event>>;
async fn find_by_entity_as_of(
&self,
entity_id: &str,
tenant_id: &str,
as_of: DateTime<Utc>,
) -> Result<Vec<Event>>;
async fn count(&self, tenant_id: &str) -> Result<usize>;
async fn health_check(&self) -> Result<()>;
}
#[async_trait]
pub trait EventReader: Send + Sync {
async fn find_by_id(&self, id: Uuid) -> Result<Option<Event>>;
async fn find_by_entity(&self, entity_id: &str, tenant_id: &str) -> Result<Vec<Event>>;
async fn find_by_type(&self, event_type: &str, tenant_id: &str) -> Result<Vec<Event>>;
async fn count(&self, tenant_id: &str) -> Result<usize>;
}
#[async_trait]
pub trait EventWriter: Send + Sync {
async fn save(&self, event: &Event) -> Result<()>;
async fn save_batch(&self, events: &[Event]) -> Result<()>;
}