Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia7efa6db85da2d44b59e0e2e57f6e45b6a6a6964
67 lines
1.6 KiB
Rust
67 lines
1.6 KiB
Rust
use pinakes_plugin_api::{UiPage, UiWidget};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Debug, Serialize)]
|
|
pub struct PluginResponse {
|
|
pub id: String,
|
|
pub name: String,
|
|
pub version: String,
|
|
pub author: String,
|
|
pub description: String,
|
|
pub api_version: String,
|
|
pub enabled: bool,
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct InstallPluginRequest {
|
|
pub source: String, // URL or file path
|
|
}
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct TogglePluginRequest {
|
|
pub enabled: bool,
|
|
}
|
|
|
|
/// A single plugin UI page entry in the list response
|
|
#[derive(Debug, Serialize)]
|
|
pub struct PluginUiPageEntry {
|
|
/// Plugin ID that provides this page
|
|
pub plugin_id: String,
|
|
/// Full page definition
|
|
pub page: UiPage,
|
|
/// Endpoint paths this plugin is allowed to fetch (empty means no
|
|
/// restriction)
|
|
pub allowed_endpoints: Vec<String>,
|
|
}
|
|
|
|
/// A single plugin UI widget entry in the list response
|
|
#[derive(Debug, Serialize)]
|
|
pub struct PluginUiWidgetEntry {
|
|
/// Plugin ID that provides this widget
|
|
pub plugin_id: String,
|
|
/// Full widget definition
|
|
pub widget: UiWidget,
|
|
}
|
|
|
|
/// Request body for emitting a plugin event
|
|
#[derive(Debug, Deserialize)]
|
|
pub struct PluginEventRequest {
|
|
pub event: String,
|
|
#[serde(default)]
|
|
pub payload: serde_json::Value,
|
|
}
|
|
|
|
impl PluginResponse {
|
|
#[must_use]
|
|
pub fn new(meta: pinakes_plugin_api::PluginMetadata, enabled: bool) -> Self {
|
|
Self {
|
|
id: meta.id,
|
|
name: meta.name,
|
|
version: meta.version,
|
|
author: meta.author,
|
|
description: meta.description,
|
|
api_version: meta.api_version,
|
|
enabled,
|
|
}
|
|
}
|
|
}
|