use crate::engine::parser::{extract_intent, extract_intent_value};
use serde_json::Value;
pub fn generate_hash(tenant_id: &str, payload: &[u8]) -> Option<String> {
let intent = extract_intent(payload)?;
hash_intent(tenant_id, &intent)
}
pub fn generate_hash_value(tenant_id: &str, json: &Value) -> Option<String> {
let intent = extract_intent_value(json)?;
hash_intent(tenant_id, &intent)
}
fn hash_intent(tenant_id: &str, intent: &Value) -> Option<String> {
let intent_str = serde_json::to_string(intent).ok()?;
let hash_input = format!("{}:{}", tenant_id, intent_str);
let hash = blake3::hash(hash_input.as_bytes());
Some(hash.to_hex().to_string())
}