Skip to main content

mangofetch_plugin_sdk/
manifest.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct PluginManifest {
6    pub id: String,
7    pub name: String,
8    pub version: String,
9    pub description: String,
10    pub author: String,
11    #[serde(default)]
12    pub min_mangofetch_version: Option<String>,
13    #[serde(default)]
14    pub license: Option<String>,
15    #[serde(default)]
16    pub homepage: Option<String>,
17    #[serde(default)]
18    pub icon: Option<String>,
19    #[serde(default)]
20    pub nav: Vec<PluginNavItem>,
21    #[serde(default)]
22    pub events: PluginEvents,
23    #[serde(default)]
24    pub capabilities: Vec<String>,
25    #[serde(default)]
26    pub settings_schema: Option<serde_json::Value>,
27    #[serde(default)]
28    pub rust_crate: Option<String>,
29    #[serde(default)]
30    pub frontend_dir: Option<String>,
31}
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct PluginNavItem {
35    pub route: String,
36    pub label: HashMap<String, String>,
37    #[serde(default)]
38    pub icon_svg: Option<String>,
39    #[serde(default = "default_nav_group")]
40    pub group: NavGroup,
41    #[serde(default = "default_nav_order")]
42    pub order: u32,
43}
44
45#[derive(Debug, Clone, Default, Serialize, Deserialize)]
46pub struct PluginEvents {
47    #[serde(default)]
48    pub progress: Vec<String>,
49    #[serde(default)]
50    pub complete: Vec<String>,
51}
52
53#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Default)]
54#[serde(rename_all = "lowercase")]
55pub enum NavGroup {
56    Primary,
57    #[default]
58    Secondary,
59}
60
61fn default_nav_group() -> NavGroup {
62    NavGroup::Secondary
63}
64
65fn default_nav_order() -> u32 {
66    50
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
70pub struct InstalledPlugin {
71    pub id: String,
72    pub version: String,
73    pub installed_at: String,
74    pub updated_at: String,
75    pub enabled: bool,
76    pub repo: Option<String>,
77    pub source_release: Option<String>,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
81pub struct RegistryEntry {
82    pub id: String,
83    pub name: String,
84    pub description: String,
85    pub author: String,
86    pub repo: String,
87    #[serde(default)]
88    pub homepage: Option<String>,
89    #[serde(default)]
90    pub tags: Vec<String>,
91    #[serde(default)]
92    pub official: bool,
93    #[serde(default)]
94    pub capabilities: Vec<String>,
95}
96
97#[derive(Debug, Clone, Serialize, Deserialize)]
98pub struct PluginRegistry {
99    #[serde(default)]
100    pub schema_version: u32,
101    pub plugins: Vec<RegistryEntry>,
102}