1use std::collections::{BTreeMap, HashMap};
6
7use serde::{Deserialize, Serialize};
8
9use crate::utils::true_default;
10use nirvati::utils::MultiLanguageItem;
11
12#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, Hash)]
13#[serde(untagged)]
14pub enum Dependency {
15 OneDependency(String),
16 AlternativeDependency(Vec<String>),
17}
18
19#[derive(Clone, PartialEq, Eq, Debug, Default, Serialize, Deserialize)]
20pub struct SvcPorts {
21 pub udp: Vec<u16>,
22 pub tcp: Vec<u16>,
23}
24
25impl SvcPorts {
26 pub fn append(&mut self, other: SvcPorts) {
27 self.udp.extend(other.udp);
28 self.tcp.extend(other.tcp);
29 }
30}
31
32#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq)]
33#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
34pub struct Permission {
35 pub id: String,
36 pub name: MultiLanguageItem,
37 pub description: MultiLanguageItem,
38 pub includes: Vec<String>,
41 #[cfg_attr(feature = "graphql", graphql(skip))]
43 pub secrets: BTreeMap<String, Vec<String>>,
44 pub hidden: Vec<String>,
47 pub services: BTreeMap<String, SvcPorts>,
49}
50
51#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
52#[serde(rename_all = "snake_case")]
53#[cfg_attr(feature = "graphql", derive(async_graphql::Enum))]
54pub enum SettingType {
55 Enum,
56 String,
57 Bool,
58}
59
60#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
61#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
62pub struct SettingsDeclaration {
63 #[serde(rename = "type")]
64 pub setting_type: SettingType,
65 #[serde(default = "Vec::default")]
66 #[serde(skip_serializing_if = "Vec::<String>::is_empty")]
67 pub values: Vec<String>,
68 pub name: BTreeMap<String, String>,
69 pub description: BTreeMap<String, String>,
70 #[serde(skip_serializing_if = "Option::is_none")]
71 pub default: Option<String>,
72}
73
74#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq)]
75#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
76#[cfg_attr(feature = "graphql", graphql(name = "VolumeDefinition"))]
77pub struct Volume {
78 pub minimum_size: u64,
79 pub recommended_size: u64,
80 pub name: MultiLanguageItem,
81 pub description: MultiLanguageItem,
82}
83
84#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
85pub enum Runtime {
86 AppYml,
87 Plugin(String),
88}
89
90#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
91#[cfg_attr(feature = "graphql", derive(async_graphql::Enum))]
92pub enum AppType {
93 App,
94 Library,
95 SystemLibrary,
96}
97
98#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
99#[serde(rename_all = "camelCase")]
100#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
101pub struct InputDeclaration {
102 pub label: MultiLanguageItem,
103 pub description: MultiLanguageItem,
104}
105
106#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
107#[serde(rename_all = "camelCase")]
108#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
109pub struct StorePlugin {
110 pub name: String,
111 pub icon: String,
112 pub description: String,
113 pub id: String,
114 pub inputs: BTreeMap<String, InputDeclaration>,
115}
116
117#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
118#[serde(rename_all = "camelCase")]
119#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
120pub struct UiMenuEntry {
121 pub name: MultiLanguageItem,
122 pub icon: String,
124 pub path: String,
125}
126
127#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
128#[serde(rename_all = "camelCase")]
129#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
130pub struct UiModule {
131 pub menu_entries: Vec<UiMenuEntry>,
132}
133
134#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)]
135#[serde(rename_all = "camelCase")]
136#[cfg_attr(feature = "graphql", derive(async_graphql::SimpleObject))]
137pub struct Metadata {
138 pub id: String,
140 pub name: String,
142 #[cfg_attr(feature = "graphql", graphql(skip))]
144 pub version: semver::Version,
145 #[cfg_attr(feature = "graphql", graphql(name = "version"))]
147 pub display_version: String,
148 pub category: MultiLanguageItem,
150 pub tagline: MultiLanguageItem,
152 pub developers: BTreeMap<String, String>,
154 pub description: MultiLanguageItem,
156 #[serde(default)]
157 #[serde(skip_serializing_if = "Vec::is_empty")]
158 #[cfg_attr(feature = "graphql", graphql(skip))]
159 pub dependencies: Vec<Dependency>,
161 #[cfg_attr(feature = "graphql", graphql(skip))]
164 pub has_permissions: Vec<String>,
165 pub exposes_permissions: Vec<Permission>,
167 pub repos: BTreeMap<String, String>,
169 pub support: String,
171 #[serde(default)]
173 #[serde(skip_serializing_if = "Vec::is_empty")]
174 pub gallery: Vec<String>,
175 pub icon: Option<String>,
177 #[serde(skip_serializing_if = "Option::is_none")]
179 pub path: Option<String>,
180 #[serde(skip_serializing_if = "Option::is_none")]
181 pub default_username: Option<String>,
183 pub default_password: Option<String>,
185 #[serde(skip_serializing_if = "Option::is_none")]
187 pub implements: Option<String>,
188 #[serde(
189 default,
190 skip_serializing_if = "BTreeMap::<String, BTreeMap<String, String>>::is_empty"
191 )]
192 pub release_notes: BTreeMap<String, BTreeMap<String, String>>,
193 pub license: String,
195 #[serde(
197 default,
198 skip_serializing_if = "BTreeMap::<String, SettingsDeclaration>::is_empty"
199 )]
200 pub settings: BTreeMap<String, SettingsDeclaration>,
201 pub volumes: HashMap<String, Volume>,
203 pub ports: Vec<u16>,
207 #[serde(skip_serializing_if = "Option::is_none")]
209 #[cfg_attr(feature = "graphql", graphql(skip))]
210 pub exported_data: Option<HashMap<String, HashMap<String, serde_json::Value>>>,
211 #[cfg_attr(feature = "graphql", graphql(skip))]
213 pub runtime: Runtime,
214 pub r#type: AppType,
216 #[serde(default)]
217 pub store_plugins: Vec<StorePlugin>,
218 #[serde(default)]
219 pub ui_module: Option<UiModule>,
220 #[serde(default = "true_default")]
224 pub supports_ingress: bool,
225 #[cfg_attr(feature = "graphql", graphql(skip))]
227 pub allow_all_internal_ingress: bool,
228 #[cfg_attr(feature = "graphql", graphql(skip))]
229 pub allow_ingress_from_ns: Vec<String>,
230 #[cfg_attr(feature = "graphql", graphql(skip))]
233 pub can_be_protected: bool,
234}