mangofetch_plugin_sdk/
manifest.rs1use 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)]
54#[serde(rename_all = "lowercase")]
55pub enum NavGroup {
56 Primary,
57 Secondary,
58}
59
60impl Default for NavGroup {
61 fn default() -> Self {
62 NavGroup::Secondary
63 }
64}
65
66fn default_nav_group() -> NavGroup {
67 NavGroup::Secondary
68}
69
70fn default_nav_order() -> u32 {
71 50
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct InstalledPlugin {
76 pub id: String,
77 pub version: String,
78 pub installed_at: String,
79 pub updated_at: String,
80 pub enabled: bool,
81 pub repo: Option<String>,
82 pub source_release: Option<String>,
83}
84
85#[derive(Debug, Clone, Serialize, Deserialize)]
86pub struct RegistryEntry {
87 pub id: String,
88 pub name: String,
89 pub description: String,
90 pub author: String,
91 pub repo: String,
92 #[serde(default)]
93 pub homepage: Option<String>,
94 #[serde(default)]
95 pub tags: Vec<String>,
96 #[serde(default)]
97 pub official: bool,
98 #[serde(default)]
99 pub capabilities: Vec<String>,
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
103pub struct PluginRegistry {
104 #[serde(default)]
105 pub schema_version: u32,
106 pub plugins: Vec<RegistryEntry>,
107}