wakflo_common/
plugin.rs

1use crate::Value;
2use serde::{Deserialize, Serialize};
3use std::collections::HashMap;
4use strum_macros::{AsRefStr, EnumIter, EnumString, IntoStaticStr};
5
6#[derive(
7    PartialEq,
8    Eq,
9    Clone,
10    Debug,
11    Serialize,
12    Deserialize,
13    EnumString,
14    EnumIter,
15    AsRefStr,
16    IntoStaticStr,
17    Default,
18)]
19pub enum PluginLanguage {
20    #[serde(rename = "rust")]
21    #[default]
22    Rust,
23    #[serde(rename = "golang")]
24    Golang,
25    #[serde(rename = "python")]
26    Python,
27    #[serde(rename = "zig")]
28    Zig,
29}
30
31impl PluginLanguage {
32    pub fn string_to_lang(lang: &str) -> Self {
33        if lang == "rust" {
34            Self::Rust
35        } else if lang == "golang" {
36            Self::Golang
37        } else if lang == "zig" {
38            Self::Zig
39        } else if lang == "python" {
40            Self::Python
41        } else {
42            Self::Rust
43        }
44    }
45}
46
47#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize, EnumString, EnumIter, AsRefStr)]
48pub enum PluginCompiler {
49    #[serde(rename = "wasm")]
50    Wasm,
51    #[serde(rename = "wasi")]
52    Wasi,
53    #[serde(rename = "wasix")]
54    Wasix,
55    #[serde(rename = "tinygo")]
56    TinyGo,
57}
58
59/// # WakfloWorkspace
60///
61/// Connector contract represent an ant schema that takes in
62/// operators and actions to be performed on a dataset
63#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug, Default)]
64pub struct WakfloWorkspace {
65    /// plugin structure
66    pub plugin: WakfloPlugin,
67    // pub dependencies: Option<Vec<EntityConnector>>,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize)]
71pub struct PluginWorkspaceMetadata {
72    pub properties: HashMap<String, serde_json::Value>,
73
74    pub compiler: PluginCompiler,
75    /// Name of the the schema
76    pub name: String,
77
78    /// Icon based on https://icon-sets.iconify.design/
79    pub icon: String,
80
81    /// Human readable identity of a category
82    pub category: String,
83
84    /// Language plugin is written in
85    pub language: PluginLanguage,
86
87    /// Version of the plugin
88    pub version: String,
89
90    /// Description of the the schema
91    pub description: String,
92}
93
94/// # WakfloPlugin
95///
96/// Connector contract represent an ant schema that takes in
97/// operators and actions to be performed on a dataset
98#[derive(PartialEq, Eq, Serialize, Deserialize, Clone, Debug, Default)]
99pub struct WakfloPlugin {
100    /// Name of the the schema
101    pub name: String,
102
103    /// Icon based on https://icon-sets.iconify.design/
104    pub icon: String,
105
106    /// Human readable identity of a category
107    pub category: String,
108
109    /// Version of the plugin
110    pub language: PluginLanguage,
111
112    /// Version of the plugin
113    pub version: String,
114
115    /// Description of the the schema
116    pub description: String,
117
118    /// Name of the the schema
119    pub documentation: Option<String>,
120
121    pub properties: Option<HashMap<String, Value>>,
122}