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

@@ -12,6 +12,7 @@ use regex::Regex;
use rpc_toolkit::{from_fn_async, Empty, HandlerExt, ParentHandler};
use serde::{Deserialize, Serialize};
use tracing::instrument;
use ts_rs::TS;
use crate::context::{CliContext, RpcContext};
use crate::prelude::*;
@@ -125,9 +126,10 @@ pub enum MatchError {
ListUniquenessViolation,
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[command(rename_all = "kebab-case")]
#[ts(export)]
pub struct ConfigParams {
pub id: PackageId,
}
@@ -156,12 +158,14 @@ pub async fn get(ctx: RpcContext, _: Empty, id: PackageId) -> Result<ConfigRes,
.await
}
#[derive(Deserialize, Serialize, Parser)]
#[derive(Deserialize, Serialize, Parser, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export)]
pub struct SetParams {
#[arg(long = "timeout")]
pub timeout: Option<crate::util::serde::Duration>,
#[command(flatten)]
#[ts(type = "{ [key: string]: any } | null")]
pub config: StdinDeserializable<Option<Config>>,
}