use crate::domain::models::*; use anyhow::Result; /// Domain-focused repository for OAuth clients pub trait DomainClientRepository: Send + Sync { fn get_client(&self, client_id: &str) -> Result>; fn create_client(&self, client: &OAuthClient, client_secret_hash: &str) -> Result<()>; fn update_client(&self, client: &OAuthClient) -> Result<()>; fn delete_client(&self, client_id: &str) -> Result<()>; fn list_clients(&self) -> Result>; } /// Domain-focused repository for authorization codes pub trait DomainAuthCodeRepository: Send + Sync { fn create_auth_code(&self, code: &AuthorizationCode) -> Result<()>; fn get_auth_code(&self, code: &str) -> Result>; fn mark_auth_code_used(&self, code: &str) -> Result<()>; fn cleanup_expired_codes(&self) -> Result<()>; } /// Domain-focused repository for access tokens pub trait DomainTokenRepository: Send + Sync { fn create_access_token(&self, token: &AccessToken, token_hash: &str) -> Result<()>; fn get_access_token(&self, token_hash: &str) -> Result>; fn revoke_access_token(&self, token_hash: &str) -> Result<()>; fn cleanup_expired_tokens(&self) -> Result<()>; } /// Domain-focused repository for audit events pub trait DomainAuditRepository: Send + Sync { fn create_audit_event(&self, event: &AuditEvent) -> Result<()>; fn get_audit_events(&self, limit: Option) -> Result>; fn cleanup_old_audit_events(&self, days: u32) -> Result<()>; } /// Domain-focused repository for rate limiting pub trait DomainRateRepository: Send + Sync { fn check_rate_limit(&self, limit: &RateLimit) -> Result; // Returns current count fn increment_rate_limit( &self, identifier: &str, endpoint: &str, window_minutes: u32, ) -> Result; fn cleanup_old_rate_limits(&self) -> Result<()>; }