use async_trait::async_trait;
use platform_core::AppResult;
use serde_json::Value;
#[async_trait]
pub trait AdminDataSource: std::fmt::Debug + Send + Sync {
async fn list(&self, entity: &str, query: &AdminListQuery) -> AppResult<AdminPage>;
async fn get(&self, entity: &str, id: &str) -> AppResult<Option<Value>>;
}
#[async_trait]
pub trait AdminActionSource: std::fmt::Debug + Send + Sync {
async fn invoke(&self, action: &str, input: Value) -> AppResult<Value>;
}
#[async_trait]
pub trait AdminQuerySource: std::fmt::Debug + Send + Sync {
async fn query(&self, query: &str) -> AppResult<Value>;
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct AdminListQuery {
pub limit: i64,
pub cursor: Option<String>,
}
#[derive(Debug, Clone)]
pub struct AdminPage {
pub records: Vec<Value>,
pub next_cursor: Option<String>,
}
impl AdminListQuery {
#[must_use]
pub fn new(limit: i64, cursor: Option<String>) -> Self {
Self { limit, cursor }
}
}