Skip to content

Commit 8cd5ede

Browse files
a bunch of changes
1 parent 09fd59d commit 8cd5ede

File tree

7 files changed

+113
-112
lines changed

7 files changed

+113
-112
lines changed

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ members = [
1414

1515
[workspace.dependencies]
1616
# Private
17-
specta-typescript = { version = "0.0.7", default-features = false }
17+
specta-typescript = { version = "0.0.9", default-features = false }
1818
pin-project-lite = { version = "0.2", default-features = false }
1919
erased-serde = { version = "0.4", default-features = false }
2020

2121
# Public
22-
specta = { version = "=2.0.0-rc.20", default-features = false }
22+
specta = { version = "=2.0.0-rc.22", default-features = false }
2323
serde = { version = "1", default-features = false }
2424
serde_json = { version = "1", default-features = false }
2525
futures = { version = "0.3", default-features = false }
@@ -35,10 +35,10 @@ panic = { level = "warn", priority = -1 }
3535
todo = { level = "warn", priority = -1 }
3636
panic_in_result_fn = { level = "warn", priority = -1 }
3737

38-
[patch.crates-io]
39-
specta = { git = "https://github.com/specta-rs/specta", rev = "bf3a0937cceb29eca11df207076b9e1b942ba7bb" }
40-
specta-serde = { git = "https://github.com/specta-rs/specta", rev = "bf3a0937cceb29eca11df207076b9e1b942ba7bb" }
41-
specta-typescript = { git = "https://github.com/specta-rs/specta", rev = "bf3a0937cceb29eca11df207076b9e1b942ba7bb" }
38+
# [patch.crates-io]
39+
# specta = { git = "https://github.com/specta-rs/specta", rev = "bf3a0937cceb29eca11df207076b9e1b942ba7bb" }
40+
# specta-serde = { git = "https://github.com/specta-rs/specta", rev = "bf3a0937cceb29eca11df207076b9e1b942ba7bb" }
41+
# specta-typescript = { git = "https://github.com/specta-rs/specta", rev = "bf3a0937cceb29eca11df207076b9e1b942ba7bb" }
4242

4343
# specta = { path = "/Users/oscar/Desktop/specta/specta" }
4444
# specta-typescript = { path = "/Users/oscar/Desktop/specta/specta-typescript" }

crates/legacy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ specta = { workspace = true, features = [
2525
"serde_json",
2626
"derive", # TODO: remove this
2727
] }
28-
specta-typescript = { version = "=0.0.7", features = [] }
28+
specta-typescript = { workspace = true, features = [] }
2929
serde_json = { workspace = true }
3030
thiserror = "2.0.9"
3131
tokio = { version = "1.42.0", features = ["macros", "sync", "rt"] }

examples/core/src/lib.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ pub fn mount() -> Router<Ctx> {
153153
// Invalidate::None
154154
// }))
155155
})
156-
.procedure("sfmPostEdit", {
157-
<BaseProcedure>::builder().query(|ctx, id: String| async move {
158-
println!("UPDATE THE POST {id:?}");
159-
ctx.invalidator.invalidate(InvalidateEvent::Post { id });
160-
Ok(())
161-
})
162-
})
156+
// .procedure("sfmPostEdit", {
157+
// <BaseProcedure>::builder().query(|ctx, id: String| async move {
158+
// println!("UPDATE THE POST {id:?}");
159+
// ctx.invalidator.invalidate(InvalidateEvent::Post { id });
160+
// Ok(())
161+
// })
162+
// })
163163
// .procedure("sfmStatefulPost", {
164164
// <BaseProcedure>::builder()
165165
// // .with(Invalidator::mw(|ctx, input, event| {
@@ -188,15 +188,15 @@ pub fn mount() -> Router<Ctx> {
188188
Ok(())
189189
})
190190
})
191-
.procedure("login", {
192-
<BaseProcedure>::builder().query(|ctx, name: String| async move {
193-
ctx.zer.set_session(&MySession { name });
194-
Ok(())
195-
})
196-
})
197-
.procedure("me", {
198-
<BaseProcedure>::builder().query(|ctx, _: ()| async move { Ok(ctx.zer.session()?) })
199-
})
191+
// .procedure("login", {
192+
// <BaseProcedure>::builder().query(|ctx, name: String| async move {
193+
// ctx.zer.set_session(&MySession { name });
194+
// Ok(())
195+
// })
196+
// })
197+
// .procedure("me", {
198+
// <BaseProcedure>::builder().query(|ctx, _: ()| async move { Ok(ctx.zer.session()?) })
199+
// })
200200
.procedure("streamInStreamInStreamInStream", {
201201
// You would never actually do this but it's just checking how the system behaves
202202
<BaseProcedure>::builder().query(|_, _: ()| async move {

examples/tauri/src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ serde = { version = "1", features = ["derive"] }
2121
serde_json = "1"
2222
rspc = { path = "../../../rspc", features = ["typescript"] }
2323
tauri-plugin-rspc = { path = "../../../integrations/tauri" }
24-
specta = { version = "=2.0.0-rc.20", features = ["derive"] }
24+
specta = { workspace = true, features = ["derive"] }
2525
example-core = { path = "../../core" }

rspc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ specta = { workspace = true, features = [
3838
] }
3939

4040
# Private
41-
specta-typescript = { version = "=0.0.7", optional = true, features = [] }
41+
specta-typescript = { workspace = true, optional = true, features = [] }
4242
serde_json = { workspace = true, optional = true }
4343
specta-rust = { git = "https://github.com/specta-rs/specta", optional = true, rev = "bf3a0937cceb29eca11df207076b9e1b942ba7bb" }
4444

rspc/src/languages.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ mod rust;
55
#[cfg_attr(docsrs, doc(cfg(feature = "typescript")))]
66
mod typescript;
77

8-
#[cfg(feature = "rust")]
9-
#[cfg_attr(docsrs, doc(cfg(feature = "rust")))]
10-
pub use rust::Rust;
8+
// #[cfg(feature = "rust")]
9+
// #[cfg_attr(docsrs, doc(cfg(feature = "rust")))]
10+
// pub use rust::Rust; // TODO
1111
#[cfg(feature = "typescript")]
1212
#[cfg_attr(docsrs, doc(cfg(feature = "typescript")))]
1313
pub use typescript::Typescript;

rspc/src/languages/rust.rs

Lines changed: 85 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,85 @@
1-
use std::{borrow::Cow, collections::HashMap, path::Path};
2-
3-
use specta::datatype::DataType;
4-
use specta_typescript::ExportError;
5-
6-
use crate::{procedure::ProcedureType, types::TypesOrType, ProcedureKind, Types};
7-
8-
pub struct Rust(()); // TODO: specta_rust::Rust
9-
10-
// TODO: Traits - `Debug`, `Clone`, etc
11-
12-
impl Default for Rust {
13-
fn default() -> Self {
14-
Self(()) // TODO: specta_typescript::Typescript::default().framework_header("// This file was generated by [rspc](https://github.com/specta-rs/rspc). Do not edit this file manually.")
15-
}
16-
}
17-
18-
impl Rust {
19-
// TODO: Clone all methods from `specta_rust::Rust`
20-
21-
pub fn export_to(&self, path: impl AsRef<Path>, types: &Types) -> Result<(), ExportError> {
22-
std::fs::write(path, self.export(types)?)?;
23-
// TODO: Format file
24-
Ok(())
25-
}
26-
27-
pub fn export(&self, types: &Types) -> Result<String, ExportError> {
28-
println!("WARNING: `rspc::Rust` is an unstable feature! Use at your own discretion!");
29-
30-
let mut s = "//! This file was generated by [rspc](https://github.com/specta-rs/rspc). Do not edit this file manually.\n\npub struct Procedures;\n\n".to_string();
31-
32-
// TODO: Move to `specta_rust::Rust` which should handle this like we do with Typescript.
33-
for (_, ty) in types.types.into_iter() {
34-
s.push_str(&specta_rust::export_named_datatype(ty).unwrap())
35-
}
36-
37-
// TODO: disabling warning on the output???
38-
39-
for (key, item) in types.procedures.clone().into_iter() {
40-
export(&mut s, key.to_string(), key, item);
41-
}
42-
43-
Ok(s)
44-
}
45-
}
46-
47-
fn export(s: &mut String, full_key: String, ident: Cow<'static, str>, item: TypesOrType) {
48-
match item {
49-
TypesOrType::Type(ty) => {
50-
let kind = match ty.kind {
51-
ProcedureKind::Query => "Query",
52-
ProcedureKind::Mutation => "Mutation",
53-
ProcedureKind::Subscription => "Subscription",
54-
};
55-
56-
let input = specta_rust::datatype(&ty.input).unwrap();
57-
let output = specta_rust::datatype(&ty.output).unwrap();
58-
let error = "()"; // TODO: specta_rust::datatype(&ty.error).unwrap();
59-
60-
s.push_str(&format!(
61-
r#"pub struct {ident};
62-
63-
impl rspc_client::Procedure for {ident} {{
64-
type Input = {input};
65-
type Output = {output};
66-
type Error = {error};
67-
type Procedures = Procedures;
68-
const KIND: rspc_client::ProcedureKind = rspc_client::ProcedureKind::{kind};
69-
const KEY: &'static str = "{ident}";
70-
}}
71-
72-
"#
73-
));
74-
}
75-
TypesOrType::Types(inner) => {
76-
for (key, item) in inner {
77-
s.push_str(&format!("\npub mod {key} {{\n"));
78-
s.push_str(&"\tpub use super::Procedures;\n");
79-
export(s, format!("{full_key}.{key}"), key, item); // TODO: Inset all items by the correct nuber of tabs
80-
s.push_str("}\n");
81-
}
82-
}
83-
}
84-
}
1+
//! TODO: Bring this back when published.
2+
// use std::{borrow::Cow, collections::HashMap, path::Path};
3+
4+
// use specta::datatype::DataType;
5+
// use specta_typescript::ExportError;
6+
7+
// use crate::{procedure::ProcedureType, types::TypesOrType, ProcedureKind, Types};
8+
9+
// pub struct Rust(()); // TODO: specta_rust::Rust
10+
11+
// // TODO: Traits - `Debug`, `Clone`, etc
12+
13+
// impl Default for Rust {
14+
// fn default() -> Self {
15+
// Self(()) // TODO: specta_typescript::Typescript::default().framework_header("// This file was generated by [rspc](https://github.com/specta-rs/rspc). Do not edit this file manually.")
16+
// }
17+
// }
18+
19+
// impl Rust {
20+
// // TODO: Clone all methods from `specta_rust::Rust`
21+
22+
// pub fn export_to(&self, path: impl AsRef<Path>, types: &Types) -> Result<(), ExportError> {
23+
// std::fs::write(path, self.export(types)?)?;
24+
// // TODO: Format file
25+
// Ok(())
26+
// }
27+
28+
// pub fn export(&self, types: &Types) -> Result<String, ExportError> {
29+
// println!("WARNING: `rspc::Rust` is an unstable feature! Use at your own discretion!");
30+
31+
// let mut s = "//! This file was generated by [rspc](https://github.com/specta-rs/rspc). Do not edit this file manually.\n\npub struct Procedures;\n\n".to_string();
32+
33+
// // TODO: Move to `specta_rust::Rust` which should handle this like we do with Typescript.
34+
// for (_, ty) in types.types.into_iter() {
35+
// s.push_str(&specta_rust::export_named_datatype(ty).unwrap())
36+
// }
37+
38+
// // TODO: disabling warning on the output???
39+
40+
// for (key, item) in types.procedures.clone().into_iter() {
41+
// export(&mut s, key.to_string(), key, item);
42+
// }
43+
44+
// Ok(s)
45+
// }
46+
// }
47+
48+
// fn export(s: &mut String, full_key: String, ident: Cow<'static, str>, item: TypesOrType) {
49+
// match item {
50+
// TypesOrType::Type(ty) => {
51+
// let kind = match ty.kind {
52+
// ProcedureKind::Query => "Query",
53+
// ProcedureKind::Mutation => "Mutation",
54+
// ProcedureKind::Subscription => "Subscription",
55+
// };
56+
57+
// let input = specta_rust::datatype(&ty.input).unwrap();
58+
// let output = specta_rust::datatype(&ty.output).unwrap();
59+
// let error = "()"; // TODO: specta_rust::datatype(&ty.error).unwrap();
60+
61+
// s.push_str(&format!(
62+
// r#"pub struct {ident};
63+
64+
// impl rspc_client::Procedure for {ident} {{
65+
// type Input = {input};
66+
// type Output = {output};
67+
// type Error = {error};
68+
// type Procedures = Procedures;
69+
// const KIND: rspc_client::ProcedureKind = rspc_client::ProcedureKind::{kind};
70+
// const KEY: &'static str = "{ident}";
71+
// }}
72+
73+
// "#
74+
// ));
75+
// }
76+
// TypesOrType::Types(inner) => {
77+
// for (key, item) in inner {
78+
// s.push_str(&format!("\npub mod {key} {{\n"));
79+
// s.push_str(&"\tpub use super::Procedures;\n");
80+
// export(s, format!("{full_key}.{key}"), key, item); // TODO: Inset all items by the correct nuber of tabs
81+
// s.push_str("}\n");
82+
// }
83+
// }
84+
// }
85+
// }

0 commit comments

Comments
 (0)