use agent_sdk_core::AgentError;
use crate::auth::SupabaseAuth;
#[derive(Clone, Debug)]
pub struct SupabaseStoreConfig {
project_url: String,
schema: String,
store_scope: String,
auth: SupabaseAuth,
}
impl SupabaseStoreConfig {
pub fn new(
project_url: impl Into<String>,
schema: impl Into<String>,
store_scope: impl Into<String>,
auth: SupabaseAuth,
) -> Result<Self, AgentError> {
let project_url = project_url.into().trim_end_matches('/').to_string();
if project_url.is_empty() {
return Err(AgentError::missing_required_field("supabase.project_url"));
}
let schema = schema.into();
if schema.is_empty() {
return Err(AgentError::missing_required_field("supabase.schema"));
}
let store_scope = store_scope.into();
if store_scope.is_empty() {
return Err(AgentError::missing_required_field("supabase.store_scope"));
}
Ok(Self {
project_url,
schema,
store_scope,
auth,
})
}
pub fn project_url(&self) -> &str {
&self.project_url
}
pub fn schema(&self) -> &str {
&self.schema
}
pub fn store_scope(&self) -> &str {
&self.store_scope
}
pub fn auth(&self) -> &SupabaseAuth {
&self.auth
}
}