Skip to main content

pipedash_plugin_api/
metadata.rs

1use serde::{
2    Deserialize,
3    Serialize,
4};
5
6use crate::history::RunHistoryPolicy;
7use crate::presentation::PluginPresentation;
8use crate::schema::{
9    ConfigSchema,
10    TableSchema,
11};
12use crate::types::{
13    Feature,
14    Permission,
15};
16use crate::utils::{
17    provider_type,
18    svg_data_url,
19};
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
22pub struct PluginMetadata {
23    pub name: String,
24    pub provider_type: String,
25    pub version: String,
26    pub description: String,
27    pub author: Option<String>,
28    pub icon: Option<String>,
29    pub config_schema: ConfigSchema,
30    pub table_schema: TableSchema,
31    pub capabilities: PluginCapabilities,
32    #[serde(default)]
33    pub required_permissions: Vec<Permission>,
34    #[serde(default)]
35    pub features: Vec<Feature>,
36    #[serde(default)]
37    pub run_history: RunHistoryPolicy,
38    #[serde(default)]
39    pub token_prefixes: Vec<String>,
40    pub presentation: PluginPresentation,
41}
42
43#[derive(Debug, Clone, Serialize, Deserialize, Default)]
44pub struct PluginCapabilities {
45    pub trigger: bool,
46    pub cancel: bool,
47    #[serde(default)]
48    pub force_cancel: bool,
49    #[serde(default)]
50    pub retains_run_history: bool,
51    #[serde(default)]
52    pub logs: bool,
53    #[serde(default)]
54    pub sign_in: bool,
55    #[serde(default)]
56    pub uses_http_proxy: bool,
57    #[serde(default)]
58    pub async_trigger: bool,
59}
60
61#[derive(Debug, Clone, Copy)]
62pub struct PluginManifest {
63    pub package_name: &'static str,
64    pub version: &'static str,
65    pub description: &'static str,
66    pub authors: &'static str,
67    pub icon_svg: &'static str,
68}
69
70impl PluginManifest {
71    pub fn provider_type(&self) -> &'static str {
72        provider_type(self.package_name)
73    }
74
75    pub(crate) fn apply(&self, metadata: &mut PluginMetadata) {
76        metadata.provider_type = self.provider_type().to_string();
77        metadata.version = self.version.to_string();
78        metadata.description = self.description.to_string();
79        metadata.author = Some(self.authors.to_string());
80        metadata.icon = Some(svg_data_url(self.icon_svg));
81    }
82}