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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
use anagolay_support::{
AnagolayRecord, AnagolayStructure, AnagolayStructureData, AnagolayStructureExtra, AnagolayVersionData,
AnagolayVersionExtra, ArtifactType, Characters, CreatorId, ForWhat, VersionId, WasmArtifactSubType,
};
use codec::{Decode, Encode};
use sp_runtime::RuntimeDebug;
use sp_std::{clone::Clone, collections::btree_map::BTreeMap, default::Default, vec, vec::Vec};
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct OperationVersionReference {
pub version_id: VersionId,
pub config: BTreeMap<Characters, Characters>,
}
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct WorkflowSegment {
pub inputs: Vec<i8>,
pub sequence: Vec<OperationVersionReference>,
}
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct WorkflowData {
pub name: Characters,
pub creators: Vec<CreatorId>,
pub description: Characters,
pub groups: Vec<ForWhat>,
pub segments: Vec<WorkflowSegment>,
}
impl AnagolayStructureData for WorkflowData {
fn validate(&self) -> Result<(), Characters> {
if self.name.len() < 8 || self.name.len() > 128 {
Err("WorkflowData.name: length must be between 8 and 128 characters".into())
} else if self.description.len() < 8 || self.description.len() > 1024 {
Err("WorkflowData.description: length must be between 4 and 1024 characters".into())
} else if self.name.len() < 8 || self.name.len() > 128 {
Err("WorkflowData.name: length must be between 4 and 128 characters".into())
} else if self.creators.len() != 1 {
Err("WorkflowData.creators: only Workflows with a single creator are supported at the moment".into())
} else {
Ok(())
}
}
}
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub struct WorkflowExtra {}
impl AnagolayStructureExtra for WorkflowExtra {}
impl Default for WorkflowExtra {
fn default() -> Self {
WorkflowExtra {}
}
}
impl Default for WorkflowData {
fn default() -> Self {
WorkflowData {
name: "".into(),
creators: vec!["".into()],
description: "".into(),
groups: vec![ForWhat::default()],
segments: vec![],
}
}
}
pub type Workflow = AnagolayStructure<WorkflowData, WorkflowExtra>;
pub type WorkflowRecord<T> =
AnagolayRecord<Workflow, <T as frame_system::Config>::AccountId, <T as frame_system::Config>::BlockNumber>;
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(serde::Serialize, serde::Deserialize))]
pub enum WorkflowArtifactType {
Docs,
Git,
Wasm(WasmArtifactSubType),
}
impl ArtifactType for WorkflowArtifactType {}
pub type WorkflowVersionData = AnagolayVersionData<WorkflowArtifactType>;
pub type WorkflowVersion = AnagolayStructure<WorkflowVersionData, AnagolayVersionExtra>;
pub type WorkflowVersionRecord<T> =
AnagolayRecord<WorkflowVersion, <T as frame_system::Config>::AccountId, <T as frame_system::Config>::BlockNumber>;