Skip to content

Commit

Permalink
Update specta (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Oct 22, 2023
1 parent 899a185 commit f5031c7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ pprof = { version = "0.13.0", features = ["flamegraph", "criterion", "protobuf-c
members = ["./crates/*", "./examples", "./examples/axum", "./examples/vercel", "./examples/tauri/src-tauri"]

[workspace.dependencies]
specta = { version = "=2.0.0-rc.1", default-features = false, features = ["serde", "serde_json"] }
specta = { version = "=2.0.0-rc.5", default-features = false, features = ["serde", "serde_json"] }
serde = { version = "1", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.49", default-features = false }

[patch.crates-io]
specta = { git = "https://github.com/oscartbeaumont/specta", rev = "5948d80f2551780eda2c7bf38450fc796c74cfbf" }
specta = { git = "https://github.com/oscartbeaumont/specta", rev = "4dea4d52ebced76e9ccf5970f8122b00772b809c" }
4 changes: 2 additions & 2 deletions crates/core/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{error, fmt, sync::Arc};

use serde::Serialize;
use specta::{ts::TsExportError, Type};
use specta::{ts, Type};

#[derive(Clone, Debug, Serialize, PartialEq, Eq, Type)]
pub enum ProcedureError {
Expand Down Expand Up @@ -151,7 +151,7 @@ pub enum ExportError {
#[error("IO error exporting bindings: {0}")]
IOErr(#[from] std::io::Error),
#[error("error exporting typescript bindings: {0}")]
TsExportErr(#[from] TsExportError),
TsExportErr(#[from] ts::ExportError),
}

#[derive(Clone, Debug, Serialize, Type)]
Expand Down
20 changes: 10 additions & 10 deletions crates/core/src/procedure_store.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::{borrow::Cow, convert::Infallible};

use specta::{
ts::TsExportError, DataType, DataTypeFrom, DefOpts, NamedDataType, StructType, TupleType, Type,
TypeMap,
};
use specta::{ts, DataType, DataTypeFrom, DefOpts, NamedDataType, StructType, Type, TypeMap};

use crate::{
layer::{DynLayer, Layer},
Expand Down Expand Up @@ -66,14 +63,13 @@ fn never() -> DataType {
},
&[],
)
.expect("rspc: error exporting `never`")
}

impl ProcedureDef {
pub fn from_tys<TArg, TResult, TError>(
key: Cow<'static, str>,
type_map: &mut TypeMap,
) -> Result<Self, TsExportError>
) -> Result<Self, ts::ExportError>
where
TArg: Type,
TResult: Type,
Expand All @@ -87,8 +83,10 @@ impl ProcedureDef {
type_map,
},
&[],
)? {
DataType::Tuple(TupleType::Named { fields, .. }) if fields.is_empty() => never(),
)
.inner
{
DataType::Tuple(tuple) if tuple.elements().is_empty() => never(),
t => t,
},
result: TResult::reference(
Expand All @@ -97,14 +95,16 @@ impl ProcedureDef {
type_map,
},
&[],
)?,
)
.inner,
error: TError::reference(
DefOpts {
parent_inline: false,
type_map,
},
&[],
)?,
)
.inner,
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{
};

use specta::{
ts::{self, FormatterFn, TsExportError},
ts::{self, FormatterFn},
TypeMap,
};

Expand Down Expand Up @@ -152,7 +152,7 @@ where
{
if existing_sid != sid {
return Err(ExportError::TsExportErr(
TsExportError::DuplicateTypeName(
ts::ExportError::DuplicateTypeName(
dt.name().clone(),
*ext.impl_location(),
existing_impl_location,
Expand Down

0 comments on commit f5031c7

Please sign in to comment.