zen_engine/nodes/input/
mod.rs

1use crate::decision_graph::cleaner::VariableCleaner;
2use crate::nodes::definition::NodeHandler;
3use crate::nodes::result::NodeResult;
4use crate::nodes::NodeContext;
5use zen_types::decision::InputNodeContent;
6use zen_types::variable::Variable;
7
8#[derive(Debug, Clone)]
9pub struct InputNodeHandler;
10
11pub type InputNodeData = InputNodeContent;
12pub type InputNodeTrace = Variable;
13
14impl NodeHandler for InputNodeHandler {
15    type NodeData = InputNodeData;
16    type TraceData = InputNodeTrace;
17
18    async fn handle(&self, ctx: NodeContext<Self::NodeData, Self::TraceData>) -> NodeResult {
19        if let Some(json_schema) = &ctx.node.schema {
20            let input_json = VariableCleaner::new().clone_clean(&ctx.input).to_value();
21            ctx.validate(json_schema, &input_json)?;
22        };
23
24        ctx.success(ctx.input.clone())
25    }
26}