143 lines
2.8 KiB
Rust
143 lines
2.8 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum NodeConfiguration {
|
|
FileNode,
|
|
MoveMoneyNode(MoveMoneyNode),
|
|
MergeNode(MergeNode),
|
|
DeriveNode(DeriveNode),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct NodeInfo {
|
|
pub name: String,
|
|
pub output_files: Vec<String>,
|
|
pub configuration: NodeConfiguration,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum MoveMoneyAmountType {
|
|
Percent,
|
|
Amount,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct MoveMoneyRule {
|
|
pub from_account: String,
|
|
pub from_cc: String,
|
|
pub to_account: String,
|
|
pub to_cc: String,
|
|
pub value: f64,
|
|
pub amount_type: MoveMoneyAmountType,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct MoveMoneyNode {
|
|
pub departments_path: String,
|
|
pub accounts_path: String,
|
|
pub gl_path: String,
|
|
pub rules: Vec<MoveMoneyRule>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum JoinType {
|
|
Left,
|
|
Inner,
|
|
Right,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct MergeJoin {
|
|
pub join_type: JoinType,
|
|
pub left_column_name: String,
|
|
pub right_column_name: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct MergeNode {
|
|
pub input_files: Vec<String>,
|
|
pub joins: Vec<MergeJoin>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum DeriveColumnType {
|
|
Column(String),
|
|
Constant(String),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct MapOperation {
|
|
pub mapped_value: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum DatePart {
|
|
Year,
|
|
Month,
|
|
Week,
|
|
Day,
|
|
Hour,
|
|
Minute,
|
|
Second,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum SplitType {
|
|
DateTime(String, DatePart),
|
|
Numeric(String, isize),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum MatchComparisonType {
|
|
Equal,
|
|
GreaterThan,
|
|
LessThan,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub enum DeriveOperation {
|
|
Concat(Vec<DeriveColumnType>),
|
|
Add(Vec<DeriveColumnType>),
|
|
Multiply(Vec<DeriveColumnType>),
|
|
Subtract(DeriveColumnType, DeriveColumnType),
|
|
Divide(DeriveColumnType, DeriveColumnType),
|
|
Map(String, Vec<MapOperation>),
|
|
Split(String, SplitType),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct DeriveFilter {
|
|
pub column_name: String,
|
|
pub comparator: MatchComparisonType,
|
|
pub match_value: String,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct DeriveRule {
|
|
pub operations: Vec<DeriveOperation>,
|
|
pub filters: Vec<DeriveFilter>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct DeriveNode {
|
|
pub rules: Vec<DeriveRule>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct Node {
|
|
pub id: i64,
|
|
pub info: NodeInfo,
|
|
pub dependent_node_ids: Vec<i64>,
|
|
}
|
|
|
|
impl Node {
|
|
pub fn has_dependent_nodes(&self) -> bool {
|
|
!self.dependent_node_ids.is_empty()
|
|
}
|
|
}
|
|
|
|
pub struct Graph {
|
|
pub name: String,
|
|
pub nodes: Vec<Node>,
|
|
}
|