use serde_json::Value;
pub mod audit;
pub mod marketing;
pub mod executive;
pub use audit::AuditPattern;
pub use marketing::MarketingPattern;
pub use executive::ExecutivePattern;
pub struct BasePattern {
pub hero: Option<Value>,
pub context: Vec<Value>,
pub analysis: Vec<Value>,
pub solution: Vec<Value>,
pub actions: Vec<Value>,
pub cta: Option<Value>,
}
impl BasePattern {
pub fn new() -> Self {
Self {
hero: None,
context: Vec::new(),
analysis: Vec::new(),
solution: Vec::new(),
actions: Vec::new(),
cta: None,
}
}
pub fn to_components(&self) -> Vec<Value> {
let mut components = Vec::new();
if let Some(hero) = &self.hero {
components.push(hero.clone());
}
if !self.context.is_empty() {
components.push(section("Context", 2));
components.extend(self.context.iter().cloned());
}
if !self.analysis.is_empty() {
components.push(section("Analysis", 2));
components.extend(self.analysis.iter().cloned());
}
if !self.solution.is_empty() {
components.push(section("Recommended Actions", 2));
components.extend(self.solution.iter().cloned());
}
if !self.actions.is_empty() {
components.push(section("Implementation", 2));
components.extend(self.actions.iter().cloned());
}
if let Some(cta) = &self.cta {
components.push(cta.clone());
}
components
}
}
impl Default for BasePattern {
fn default() -> Self {
Self::new()
}
}
fn section(title: &str, level: usize) -> Value {
serde_json::json!({
"type": "section",
"data": {
"title": title,
"level": level,
"content": []
}
})
}
pub fn component_json(component_id: &str, data: Value) -> Value {
serde_json::json!({
"type": component_id,
"data": data
})
}