1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
use crate::step::{StepEdge, TaskStep};
use serde::{Deserialize, Serialize};

/// Workflow types type
#[derive(
    PartialEq,
    Eq,
    Debug,
    Serialize,
    Deserialize,
    Clone,
    strum_macros::AsRefStr,
    strum_macros::EnumString,
    strum_macros::IntoStaticStr,
    Default,
)]
pub enum WorkflowVersionSchema {
    #[default]
    V1,
}

#[cfg(not(feature = "sql"))]
impl std::fmt::Display for WorkflowVersionSchema {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
        match self {
            WorkflowVersionSchema::V1 => write!(f, "io.wakflow.ngine/workflows/jsonschema/v1"),
        }
    }
}

/// # Workflow
/// Workflow contract represent an ant workflows that takes in operators and actions
/// to be performed on a dataset
#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug)]
pub struct Workflow {
    /// [WorkflowSchema] workflows types definition
    pub schema_version: WorkflowVersionSchema,

    pub id: String,

    pub team_id: String,

    pub revision: i64,

    pub enabled: bool,

    pub settings: WorkflowSettings,

    /// Name of the workflows
    pub name: String,

    /// Display name of the workflows
    pub display_name: String,

    /// Description of the workflows
    pub description: Option<String>,

    /// [TaskStep] in a workflows
    ///
    /// [TaskStep]: crate::schema::contracts::TaskStep
    pub steps: Vec<TaskStep>,

    pub step_edges: Vec<StepEdge>,

    /// Date the entity was created
    pub created_at: chrono::DateTime<chrono::FixedOffset>,

    /// Date the entity was updated
    pub updated_at: chrono::DateTime<chrono::FixedOffset>,
}

#[derive(Default, PartialEq, Serialize, Deserialize, Eq, Clone, Debug)]
pub struct WorkflowSettings {}