pub struct Style {
pub width: usize,
pub indent: usize,
pub max_scalar_inline: usize,
}
pub const STYLE: Style = Style {
width: 100,
indent: 2,
max_scalar_inline: 8,
};
pub const FROM_KEY: &str = "$from";
pub const WORKFLOW_KEYS: &[&str] = &[
"workflow_id",
"name",
"description",
"tags",
"priority",
"condition",
"loop",
"continue_on_error",
"activate",
"tasks",
];
pub const TASK_KEYS: &[&str] = &[
"id",
"name",
"description",
"condition",
"terminal",
"continue_on_error",
"function",
];
pub const GROUP_KEYS: &[&str] = &[
"id",
"name",
"description",
"condition",
"terminal",
"tasks",
];
pub const USE_STEP_KEYS: &[&str] = &["id", "use", "with"];
pub const FUNCTION_KEYS: &[&str] = &["name", "input"];
pub const MAPPING_KEYS: &[&str] = &["path", "logic"];
pub const VALIDATION_RULE_KEYS: &[&str] = &["logic", "message"];
pub const LOOP_KEYS: &[&str] = &["counter", "init", "max", "increment"];
pub const CHANNEL_KEYS: &[&str] = &[
"channel_id",
"name",
"description",
"tags",
"channel_type",
"protocol",
"methods",
"route_pattern",
"topic",
"consumer_group",
"priority",
"workflow_id",
"activate",
"transport_config",
"config",
];
pub const CONNECTOR_KEYS: &[&str] = &["id", "name", "connector_type", "enabled", "tags", "config"];
pub const SHARED_DOC_KEYS: &[&str] = &["constants", "errors", "fragments"];
pub const FRAGMENT_KEYS: &[&str] = &["params", "tasks"];
pub const CASE_KEYS: &[&str] = &[
"name",
"workflow",
"input",
"metadata",
"secrets",
"stubs",
"stubs_file",
"expect",
"expect_errors",
"expect_calls",
"expect_tasks",
];
pub const BUILTIN_INPUT_KEYS: &[(&str, &[&str])] = &[
("parse_json", &["source", "target"]),
("parse_xml", &["source", "target"]),
("map", &["mappings"]),
("filter", &["condition", "on_reject"]),
("validation", &["rules"]),
("validate", &["rules"]),
("log", &["message", "level", "fields"]),
("publish_json", &["source", "target", "pretty"]),
("publish_xml", &["source", "target", "root_element"]),
];
pub const ARTIFACT_KEYS: &[&str] = &["package", "requires", "connectors", "workflows", "channels"];
pub const ARTIFACT_META_KEYS: &[&str] = &[
"name",
"version",
"orion",
"content_hash",
"exported_from",
"exported_at",
];
pub fn all_tables() -> &'static [(&'static str, &'static [&'static str])] {
&[
("workflow", WORKFLOW_KEYS),
("task", TASK_KEYS),
("group", GROUP_KEYS),
("use_step", USE_STEP_KEYS),
("function", FUNCTION_KEYS),
("mapping", MAPPING_KEYS),
("validation_rule", VALIDATION_RULE_KEYS),
("loop", LOOP_KEYS),
("channel", CHANNEL_KEYS),
("connector", CONNECTOR_KEYS),
("shared_doc", SHARED_DOC_KEYS),
("fragment", FRAGMENT_KEYS),
("case", CASE_KEYS),
("artifact", ARTIFACT_KEYS),
("artifact_meta", ARTIFACT_META_KEYS),
]
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn no_table_repeats_a_key() {
for (name, table) in all_tables() {
let mut sorted = table.to_vec();
sorted.sort_unstable();
sorted.dedup();
assert_eq!(sorted.len(), table.len(), "{name} repeats a key");
}
}
}