use serde_json::Value; use sqlx::PgPool; use std::collections::HashMap; use uuid::Uuid; mod ai_text_process; mod echo; /// Trait for jobbhandlere. /// Hver jobbtype implementerer dette. #[async_trait::async_trait] pub trait JobHandler: Send + Sync { async fn handle( &self, pool: &PgPool, workspace_id: &Uuid, payload: &Value, ) -> anyhow::Result>; } pub type HandlerRegistry = HashMap>; /// Bygg registeret med alle tilgjengelige handlers. pub fn build_registry(http: reqwest::Client, ai_gateway_url: String) -> HandlerRegistry { let mut registry: HandlerRegistry = HashMap::new(); // Echo-handler for testing registry.insert("echo".into(), Box::new(echo::EchoHandler)); // AI-behandling av tekst (✨-knappen i editoren) registry.insert( "ai_text_process".into(), Box::new(ai_text_process::AiTextProcessHandler::new( http.clone(), ai_gateway_url.clone(), )), ); // Fremtidige handlers: // registry.insert("whisper_transcribe".into(), ...); // registry.insert("openrouter_analyze".into(), ...); // registry.insert("research_clip".into(), ...); registry }