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, Eq, PartialEq)]
55pub enum PluginManifest {
56 V2(PluginManifestV2),
57 V3(PluginManifestV3),
58}
59
60impl PluginManifest {
61 pub fn plugin_id(&self) -> &str {
62 match self {
63 Self::V2(value) => &value.plugin_id,
64 Self::V3(value) => value.contract.plugin_id(),
65 }
66 }
67
68 pub fn release_version(&self) -> &str {
69 match self {
70 Self::V2(value) => &value.release_version,
71 Self::V3(value) => value.contract.release_version(),
72 }
73 }
74}