lenso_plugin_bundle/
model.rs1use serde::{Deserialize, Serialize};
2
3use lenso_app_plan::authoring::{PluginContract, PluginImplementation};
4
5#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
7#[serde(deny_unknown_fields)]
8pub struct PluginManifestV2 {
9 pub schema_version: u32,
10 pub plugin_id: String,
11 pub release_version: String,
12 pub artifact: PluginArtifactV2,
13 pub entry: PluginEntryV2,
14}
15
16#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
18#[serde(deny_unknown_fields)]
19pub struct PluginArtifactV2 {
20 pub path: String,
21 pub digest: String,
22 pub size: u64,
23 pub media_type: String,
24 pub target: String,
25}
26
27#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
29#[serde(deny_unknown_fields)]
30pub struct PluginEntryV2 {
31 pub descriptor: serde_json::Value,
32}
33
34#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
36#[serde(deny_unknown_fields)]
37pub struct PluginManifestV3 {
38 pub schema_version: u32,
39 pub contract: PluginContract,
40 pub implementations: Vec<PluginImplementationV3>,
41}
42
43#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
45#[serde(deny_unknown_fields)]
46pub struct PluginImplementationV3 {
47 pub id: String,
48 pub host_targets: Vec<String>,
49 pub artifact: PluginArtifactV2,
50 pub runtime: PluginImplementation,
51}
52
53#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
55#[serde(deny_unknown_fields)]
56pub struct PluginManifestV4 {
57 pub schema_version: u32,
58 pub contract: PluginContract,
59 pub implementations: Vec<PluginImplementationV4>,
60}
61
62#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
64#[serde(deny_unknown_fields)]
65pub struct PluginImplementationV4 {
66 pub id: String,
67 pub host_targets: Vec<String>,
68 pub artifact: PluginArtifactV2,
69 pub runtime: PluginImplementation,
70}
71
72#[derive(Clone, Debug, Eq, PartialEq)]
74pub enum PluginManifest {
75 V2(PluginManifestV2),
76 V3(PluginManifestV3),
77 V4(PluginManifestV4),
78}
79
80impl PluginManifest {
81 pub fn plugin_id(&self) -> &str {
82 match self {
83 Self::V2(value) => &value.plugin_id,
84 Self::V3(value) => value.contract.plugin_id(),
85 Self::V4(value) => value.contract.plugin_id(),
86 }
87 }
88
89 pub fn release_version(&self) -> &str {
90 match self {
91 Self::V2(value) => &value.release_version,
92 Self::V3(value) => value.contract.release_version(),
93 Self::V4(value) => value.contract.release_version(),
94 }
95 }
96}