mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
export api types to ts (#2583)
This commit is contained in:
@@ -11,6 +11,7 @@ use models::PackageId;
|
||||
use rpc_toolkit::{command, from_fn_async, HandlerExt, ParentHandler};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tracing::instrument;
|
||||
use ts_rs::TS;
|
||||
|
||||
use crate::backup::BackupReport;
|
||||
use crate::context::{CliContext, RpcContext};
|
||||
@@ -48,11 +49,14 @@ pub fn notification() -> ParentHandler {
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Parser)]
|
||||
#[derive(Deserialize, Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
#[ts(export)]
|
||||
pub struct ListParams {
|
||||
#[ts(type = "number | null")]
|
||||
before: Option<u32>,
|
||||
#[ts(type = "number | null")]
|
||||
limit: Option<usize>,
|
||||
}
|
||||
// #[command(display(display_serializable))]
|
||||
@@ -110,10 +114,12 @@ pub async fn list(
|
||||
.await
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Parser)]
|
||||
#[derive(Deserialize, Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
#[ts(export)]
|
||||
pub struct DeleteParams {
|
||||
#[ts(type = "number")]
|
||||
id: u32,
|
||||
}
|
||||
|
||||
@@ -125,10 +131,12 @@ pub async fn delete(ctx: RpcContext, DeleteParams { id }: DeleteParams) -> Resul
|
||||
})
|
||||
.await
|
||||
}
|
||||
#[derive(Deserialize, Serialize, Parser)]
|
||||
#[derive(Deserialize, Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
#[ts(export)]
|
||||
pub struct DeleteBeforeParams {
|
||||
#[ts(type = "number")]
|
||||
before: u32,
|
||||
}
|
||||
|
||||
@@ -148,9 +156,10 @@ pub async fn delete_before(
|
||||
.await
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Parser)]
|
||||
#[derive(Deserialize, Serialize, Parser, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[command(rename_all = "kebab-case")]
|
||||
#[ts(export)]
|
||||
pub struct CreateParams {
|
||||
package: Option<PackageId>,
|
||||
level: NotificationLevel,
|
||||
@@ -172,7 +181,7 @@ pub async fn create(
|
||||
.await
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum NotificationLevel {
|
||||
Success,
|
||||
|
||||
Reference in New Issue
Block a user