2025-04-13 01:04:04 +02:00
|
|
|
use crate::common::errors::DomainError;
|
|
|
|
|
use crate::domain::entities::calendar_event::CalendarEvent;
|
2026-02-14 01:29:34 +01:00
|
|
|
use async_trait::async_trait;
|
|
|
|
|
use chrono::{DateTime, Utc};
|
|
|
|
|
use uuid::Uuid;
|
2025-04-13 01:04:04 +02:00
|
|
|
|
|
|
|
|
pub type CalendarEventRepositoryResult<T> = Result<T, DomainError>;
|
|
|
|
|
|
|
|
|
|
/// Repository interface for CalendarEvent entity operations
|
|
|
|
|
#[async_trait]
|
|
|
|
|
pub trait CalendarEventRepository: Send + Sync + 'static {
|
|
|
|
|
/// Creates a new calendar event
|
2026-02-14 01:29:34 +01:00
|
|
|
async fn create_event(
|
|
|
|
|
&self,
|
|
|
|
|
event: CalendarEvent,
|
|
|
|
|
) -> CalendarEventRepositoryResult<CalendarEvent>;
|
|
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Updates an existing calendar event
|
2026-02-14 01:29:34 +01:00
|
|
|
async fn update_event(
|
|
|
|
|
&self,
|
|
|
|
|
event: CalendarEvent,
|
|
|
|
|
) -> CalendarEventRepositoryResult<CalendarEvent>;
|
|
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Deletes a calendar event by ID
|
|
|
|
|
async fn delete_event(&self, id: &Uuid) -> CalendarEventRepositoryResult<()>;
|
2026-02-14 01:29:34 +01:00
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Finds a calendar event by its ID
|
|
|
|
|
async fn find_event_by_id(&self, id: &Uuid) -> CalendarEventRepositoryResult<CalendarEvent>;
|
2026-02-14 01:29:34 +01:00
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Lists all events in a specific calendar
|
2026-02-14 01:29:34 +01:00
|
|
|
async fn list_events_by_calendar(
|
|
|
|
|
&self,
|
|
|
|
|
calendar_id: &Uuid,
|
|
|
|
|
) -> CalendarEventRepositoryResult<Vec<CalendarEvent>>;
|
|
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Finds events in a calendar by their summary/title (partial match)
|
2026-02-14 01:29:34 +01:00
|
|
|
async fn find_events_by_summary(
|
|
|
|
|
&self,
|
|
|
|
|
calendar_id: &Uuid,
|
|
|
|
|
summary: &str,
|
|
|
|
|
) -> CalendarEventRepositoryResult<Vec<CalendarEvent>>;
|
|
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Gets events in a specific time range for a calendar
|
|
|
|
|
async fn get_events_in_time_range(
|
2026-02-14 01:29:34 +01:00
|
|
|
&self,
|
|
|
|
|
calendar_id: &Uuid,
|
|
|
|
|
start: &DateTime<Utc>,
|
|
|
|
|
end: &DateTime<Utc>,
|
2025-04-13 01:04:04 +02:00
|
|
|
) -> CalendarEventRepositoryResult<Vec<CalendarEvent>>;
|
2026-02-14 01:29:34 +01:00
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Finds an event by its iCalendar UID in a specific calendar
|
2026-02-14 01:29:34 +01:00
|
|
|
async fn find_event_by_ical_uid(
|
|
|
|
|
&self,
|
|
|
|
|
calendar_id: &Uuid,
|
|
|
|
|
ical_uid: &str,
|
|
|
|
|
) -> CalendarEventRepositoryResult<Option<CalendarEvent>>;
|
|
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Counts events in a calendar
|
2026-02-14 01:29:34 +01:00
|
|
|
async fn count_events_in_calendar(
|
|
|
|
|
&self,
|
|
|
|
|
calendar_id: &Uuid,
|
|
|
|
|
) -> CalendarEventRepositoryResult<i64>;
|
|
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Deletes all events in a calendar
|
2026-02-14 01:29:34 +01:00
|
|
|
async fn delete_all_events_in_calendar(
|
|
|
|
|
&self,
|
|
|
|
|
calendar_id: &Uuid,
|
|
|
|
|
) -> CalendarEventRepositoryResult<i64>;
|
|
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Lists events by calendar with pagination
|
|
|
|
|
async fn list_events_by_calendar_paginated(
|
2026-02-14 01:29:34 +01:00
|
|
|
&self,
|
2025-04-13 01:04:04 +02:00
|
|
|
calendar_id: &Uuid,
|
|
|
|
|
limit: i64,
|
2026-02-14 01:29:34 +01:00
|
|
|
offset: i64,
|
2025-04-13 01:04:04 +02:00
|
|
|
) -> CalendarEventRepositoryResult<Vec<CalendarEvent>>;
|
2026-02-14 01:29:34 +01:00
|
|
|
|
2025-04-13 01:04:04 +02:00
|
|
|
/// Finds events with recurrence rules that might occur in a time range
|
|
|
|
|
async fn find_recurring_events_in_range(
|
|
|
|
|
&self,
|
|
|
|
|
calendar_id: &Uuid,
|
|
|
|
|
start: &DateTime<Utc>,
|
2026-02-14 01:29:34 +01:00
|
|
|
end: &DateTime<Utc>,
|
2025-04-13 01:04:04 +02:00
|
|
|
) -> CalendarEventRepositoryResult<Vec<CalendarEvent>>;
|
2026-02-14 01:29:34 +01:00
|
|
|
}
|