export api types to ts (#2583)

This commit is contained in:
Aiden McClelland
2024-04-01 13:14:22 -06:00
committed by GitHub
parent 8884f64b4e
commit f021ad9b0a
94 changed files with 629 additions and 179 deletions

View File

@@ -8,6 +8,7 @@ use imbl_value::InternedString;
use rpc_toolkit::{command, from_fn_async, AnyContext, Empty, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::prelude::*;
@@ -34,7 +35,8 @@ impl Map for SshKeys {
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[derive(Clone, Debug, Deserialize, Serialize, TS)]
#[ts(type = "string")]
pub struct SshPubKey(
#[serde(serialize_with = "crate::util::serde::serialize_display")]
#[serde(deserialize_with = "crate::util::serde::deserialize_from_str")]
@@ -102,9 +104,10 @@ pub fn ssh() -> ParentHandler {
)
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct AddParams {
key: SshPubKey,
}
@@ -135,10 +138,12 @@ pub async fn add(ctx: RpcContext, AddParams { key }: AddParams) -> Result<SshKey
Ok(res)
}
#[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 = "string")]
fingerprint: InternedString,
}