use axum::{
Json,
extract::{Path, State},
http::StatusCode,
response::IntoResponse,
};
use fraiseql_core::db::traits::DatabaseAdapter;
use serde::{Deserialize, Serialize};
use crate::routes::graphql::app_state::AppState;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionEntry {
pub name: String,
pub version: u32,
pub runtime: String,
pub status: String,
pub deployed_at: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FunctionListResponse {
pub functions: Vec<FunctionEntry>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvokeResponse {
pub value: serde_json::Value,
pub logs: Vec<String>,
pub duration_ms: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvocationLogEntry {
pub status: String,
pub duration_ms: u64,
pub error: Option<String>,
pub timestamp: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SecretsKeysResponse {
pub keys: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InvokeRequest {
pub event: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SecretSetRequest {
pub value: String,
}
pub async fn list_functions_handler<A>(State(_state): State<AppState<A>>) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(FunctionListResponse { functions: vec![] })
}
pub async fn invoke_function_handler<A>(
Path(_name): Path<String>,
State(_state): State<AppState<A>>,
Json(_req): Json<InvokeRequest>,
) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
(
StatusCode::NOT_IMPLEMENTED,
Json(serde_json::json!({
"error": "Not Implemented",
"message": "Function invocation endpoint available in a future release"
})),
)
}
pub async fn function_logs_handler<A>(
Path(_name): Path<String>,
State(_state): State<AppState<A>>,
) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(serde_json::json!({ "logs": [] }))
}
pub async fn list_secrets_handler<A>(
Path(_name): Path<String>,
State(_state): State<AppState<A>>,
) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(SecretsKeysResponse { keys: vec![] })
}
pub async fn set_secret_handler<A>(
Path((_name, _key)): Path<(String, String)>,
State(_state): State<AppState<A>>,
Json(_req): Json<SecretSetRequest>,
) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(serde_json::json!({"success": true}))
}
pub async fn delete_secret_handler<A>(
Path((_name, _key)): Path<(String, String)>,
State(_state): State<AppState<A>>,
) -> impl IntoResponse
where
A: DatabaseAdapter + Clone + Send + Sync + 'static,
{
Json(serde_json::json!({"success": true}))
}