use ts_rs::TS;
#[doc(hidden)]
pub struct ResourceIdentifierTs;
impl TS for ResourceIdentifierTs {
type WithoutGenerics = Self;
type OptionInnerType = Self;
fn name(_: &ts_rs::Config) -> String {
"ResourceIdentifier".into()
}
fn inline(cfg: &ts_rs::Config) -> String {
Self::name(cfg)
}
fn decl(_: &ts_rs::Config) -> String {
"type ResourceIdentifier = string;".into()
}
fn decl_concrete(cfg: &ts_rs::Config) -> String {
Self::decl(cfg)
}
fn output_path() -> Option<std::path::PathBuf> {
Some("api/admin/types.ts".into())
}
}
#[doc(hidden)]
pub struct ResourceMapTs;
impl TS for ResourceMapTs {
type WithoutGenerics = Self;
type OptionInnerType = Self;
fn name(_: &ts_rs::Config) -> String {
"ResourceMap".into()
}
fn inline(cfg: &ts_rs::Config) -> String {
Self::name(cfg)
}
fn decl(_: &ts_rs::Config) -> String {
"type ResourceMap = Record<ResourceIdentifier, ResourceBytes>;".into()
}
fn decl_concrete(cfg: &ts_rs::Config) -> String {
Self::decl(cfg)
}
fn visit_dependencies(v: &mut impl ts_rs::TypeVisitor)
where
Self: 'static,
{
v.visit::<ResourceIdentifierTs>();
v.visit::<crate::ResourceBytes>();
}
fn output_path() -> Option<std::path::PathBuf> {
Some("api/admin/types.ts".into())
}
}
#[doc(hidden)]
pub struct BundleWithoutGenerics;
impl TS for BundleWithoutGenerics {
type WithoutGenerics = Self;
type OptionInnerType = Self;
fn name(_: &ts_rs::Config) -> String {
"Bundle".into()
}
fn inline(_: &ts_rs::Config) -> String {
panic!("BundleWithoutGenerics is a type-level placeholder and cannot be inlined")
}
fn visit_dependencies(v: &mut impl ts_rs::TypeVisitor)
where
Self: 'static,
{
v.visit::<ResourceMapTs>();
}
fn output_path() -> Option<std::path::PathBuf> {
Some("api/admin/types.ts".into())
}
}
pub fn export_ts_bindings(cfg: &ts_rs::Config) -> Result<(), ts_rs::ExportError> {
ResourceIdentifierTs::export_all(cfg)?;
ResourceMapTs::export_all(cfg)?;
Ok(())
}