use hamelin_lib::func::registry::FunctionRegistry;
use serde::Serialize;
use tsify::Tsify;
use wasm_bindgen::prelude::wasm_bindgen;

#[derive(Debug, Clone, Serialize, Tsify)]
#[tsify(into_wasm_abi)]
pub struct FunctionDescription {
    pub name: String,
    pub parameters: String,
}

#[wasm_bindgen]
pub fn get_function_descriptions() -> Vec<FunctionDescription> {
    FunctionRegistry::default()
        .function_defs
        .iter()
        .flat_map(|(name, defs)| {
            defs.iter().map(|def| FunctionDescription {
                name: name.clone(),
                parameters: def.parameters().to_string(),
            })
        })
        .collect()
}
