use std::sync::Arc; use sqlx::SqlitePool; use domain::ports::{ activity::{ActivityLogCommand, ActivityLogQuery}, channel::{ChannelCommand, ChannelQuery}, library::{LibraryCommand, LibraryQuery}, provider_config::{ProviderConfigCommand, ProviderConfigQuery}, schedule::{ScheduleCommand, ScheduleQuery}, settings::AppSettingsRepository, transcode::TranscodeSettingsRepository, user::{UserCommand, UserQuery}, }; use crate::{ activity::SqliteActivityLog, channel::SqliteChannelRepository, library::SqliteLibraryRepository, provider_config::SqliteProviderConfig, schedule::SqliteScheduleRepository, settings::SqliteAppSettings, transcode::SqliteTranscodeSettings, user::SqliteUserRepository, }; pub struct SqliteWireOutput { pub user_command: Arc, pub user_query: Arc, pub channel_command: Arc, pub channel_query: Arc, pub schedule_command: Arc, pub schedule_query: Arc, pub library_command: Arc, pub library_query: Arc, pub activity_command: Arc, pub activity_query: Arc, pub settings: Arc, pub provider_config_command: Arc, pub provider_config_query: Arc, pub transcode_settings: Arc, } pub fn wire(pool: SqlitePool) -> SqliteWireOutput { let user = Arc::new(SqliteUserRepository::new(pool.clone())); let channel = Arc::new(SqliteChannelRepository::new(pool.clone())); let schedule = Arc::new(SqliteScheduleRepository::new(pool.clone())); let library = Arc::new(SqliteLibraryRepository::new(pool.clone())); let activity = Arc::new(SqliteActivityLog::new(pool.clone())); let settings = Arc::new(SqliteAppSettings::new(pool.clone())); let provider_config = Arc::new(SqliteProviderConfig::new(pool.clone())); let transcode_settings = Arc::new(SqliteTranscodeSettings::new(pool)); SqliteWireOutput { user_command: user.clone(), user_query: user, channel_command: channel.clone(), channel_query: channel, schedule_command: schedule.clone(), schedule_query: schedule, library_command: library.clone(), library_query: library, activity_command: activity.clone(), activity_query: activity, settings, provider_config_command: provider_config.clone(), provider_config_query: provider_config, transcode_settings, } }