ironflow_engine/config/
mod.rs1mod agent;
8mod approval;
9mod http;
10mod shell;
11mod workflow;
12
13pub use agent::AgentStepConfig;
14pub use approval::ApprovalConfig;
15pub use http::HttpConfig;
16pub use shell::ShellConfig;
17pub use workflow::WorkflowStepConfig;
18
19use ironflow_store::entities::StepKind;
20use serde::{Deserialize, Serialize};
21
22#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(tag = "type", rename_all = "snake_case")]
38pub enum StepConfig {
39 Shell(ShellConfig),
41 Http(HttpConfig),
43 Agent(AgentStepConfig),
45 Workflow(WorkflowStepConfig),
47 Approval(ApprovalConfig),
49}
50
51impl StepConfig {
52 pub fn kind(&self) -> StepKind {
64 match self {
65 StepConfig::Shell(_) => StepKind::Shell,
66 StepConfig::Http(_) => StepKind::Http,
67 StepConfig::Agent(_) => StepKind::Agent,
68 StepConfig::Workflow(_) => StepKind::Workflow,
69 StepConfig::Approval(_) => StepKind::Approval,
70 }
71 }
72}
73
74#[cfg(test)]
75mod tests {
76 use super::*;
77
78 #[test]
79 fn serde_roundtrip() {
80 let configs = vec![
81 StepConfig::Shell(ShellConfig::new("echo test")),
82 StepConfig::Http(HttpConfig::get("http://example.com")),
83 StepConfig::Agent(AgentStepConfig::new("summarize")),
84 StepConfig::Workflow(WorkflowStepConfig::new("build", serde_json::json!({}))),
85 StepConfig::Approval(ApprovalConfig::new("Deploy to production?")),
86 ];
87
88 for config in configs {
89 let json = serde_json::to_string(&config).expect("serialize");
90 let back: StepConfig = serde_json::from_str(&json).expect("deserialize");
91 let json2 = serde_json::to_string(&back).expect("serialize2");
92 assert_eq!(json, json2);
93 }
94 }
95}