use crate::pipeline::NodeDefinition;
pub mod collect;
pub mod concept;
pub mod foreach_;
pub mod if_;
pub mod match_;
pub mod reduce;
pub mod retry;
pub const LOOP_ITEMS_METADATA_KEY: &str = "loop_items";
pub fn definitions() -> Vec<NodeDefinition> {
vec![
if_::definition(),
match_::definition(),
collect::definition(),
foreach_::definition(),
reduce::definition(),
retry::definition(),
concept::definition(),
]
}
pub(crate) fn expression_text<'de, D: serde::Deserializer<'de>>(de: D) -> Result<String, D::Error> {
use serde::Deserialize;
match serde_json::Value::deserialize(de)? {
serde_json::Value::String(text) => Ok(text),
serde_json::Value::Null => Ok(String::new()),
other @ (serde_json::Value::Bool(_) | serde_json::Value::Number(_)) => Ok(other.to_string()),
other => Err(serde::de::Error::custom(format!("an expression is text, got {other}"))),
}
}
pub(crate) fn required_expression<'a>(
text: &'a str,
flag: &str,
code: &'static str,
) -> Result<&'a str, crate::pipeline::PipelineError> {
let text = text.trim();
if text.is_empty() {
return Err(crate::pipeline::PipelineError::new(code, format!("{flag} is empty; it needs an expression")));
}
Ok(text)
}