diff --git a/Cargo.lock b/Cargo.lock index f895e9232..646de1e9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -320,9 +320,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e9eabd7a98fe442131a17c316bd9349c43695e49e730c3c8e12cfb5f4da2693" +checksum = "9c90a406b4495d129f00461241616194cb8a032c8d1c53c657f0961d5f8e0498" dependencies = [ "brotli", "flate2", @@ -334,16 +334,16 @@ dependencies = [ [[package]] name = "async-graphql" -version = "7.0.3" +version = "7.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261fa27d5bff5afdf7beff291b3bc73f99d1529804c70e51b0fbc51e70b1c6a9" +checksum = "d0808e3dc8be9cee801000b9261081cd7caae9935658be7e52d4df3d5c22bdce" dependencies = [ "async-graphql-derive", "async-graphql-parser", "async-graphql-value", "async-stream", "async-trait", - "base64 0.21.7", + "base64 0.22.1", "blocking", "bytes", "fnv", @@ -370,9 +370,9 @@ dependencies = [ [[package]] name = "async-graphql-axum" -version = "7.0.3" +version = "7.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93605d26b9da33b4cf6541906a9eb9e74396f1accbbc0f066e06f3b0869b84fc" +checksum = "d94b2673899046dbbb803dff9c400330f7908727f5edb99979c3d841136ee754" dependencies = [ "async-graphql", "async-trait", @@ -388,9 +388,9 @@ dependencies = [ [[package]] name = "async-graphql-derive" -version = "7.0.3" +version = "7.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3188809947798ea6db736715a60cf645ba3b87ea031c710130e1476b48e45967" +checksum = "ae80fb7b67deeae84441a9eb156359b99be7902d2d706f43836156eec69a8226" dependencies = [ "Inflector", "async-graphql-parser", @@ -405,9 +405,9 @@ dependencies = [ [[package]] name = "async-graphql-parser" -version = "7.0.3" +version = "7.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4e65a0b83027f35b2a5d9728a098bc66ac394caa8191d2c65ed9eb2985cf3d8" +checksum = "8f0fffb19cd96eb084428289f4568b5ad48df32f782f891f709db96384fbdeb2" dependencies = [ "async-graphql-value", "pest", @@ -417,9 +417,9 @@ dependencies = [ [[package]] name = "async-graphql-value" -version = "7.0.3" +version = "7.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68e40849c29a39012d38bff87bfed431f1ed6c53fbec493294c1045d61a7ae75" +checksum = "c224c93047a7197fe0f1d6eee98245ba6049706c6c04a372864557fb61495e94" dependencies = [ "bytes", "indexmap 2.2.6", @@ -942,61 +942,11 @@ dependencies = [ "tracing", ] -[[package]] -name = "bollard" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0aed08d3adb6ebe0eff737115056652670ae290f177759aac19c30456135f94c" -dependencies = [ - "base64 0.22.1", - "bollard-stubs", - "bytes", - "futures-core", - "futures-util", - "hex", - "home", - "http 1.1.0", - "http-body-util", - "hyper 1.3.1", - "hyper-named-pipe", - "hyper-rustls 0.26.0", - "hyper-util", - "hyperlocal-next", - "log", - "pin-project-lite", - "rustls 0.22.4", - "rustls-native-certs", - "rustls-pemfile 2.1.2", - "rustls-pki-types", - "serde", - "serde_derive", - "serde_json", - "serde_repr", - "serde_urlencoded", - "thiserror", - "tokio", - "tokio-util", - "tower-service", - "url", - "winapi", -] - -[[package]] -name = "bollard-stubs" -version = "1.44.0-rc.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "709d9aa1c37abb89d40f19f5d0ad6f0d88cb1581264e571c9350fc5bb89cf1c5" -dependencies = [ - "serde", - "serde_repr", - "serde_with", -] - [[package]] name = "brotli" -version = "5.0.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19483b140a7ac7174d34b5a581b406c64f84da5409d3e09cf4fff604f9270e67" +checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -1997,50 +1947,6 @@ dependencies = [ "subtle", ] -[[package]] -name = "dirs" -version = "5.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" -dependencies = [ - "dirs-sys", -] - -[[package]] -name = "dirs-sys" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" -dependencies = [ - "libc", - "option-ext", - "redox_users", - "windows-sys 0.48.0", -] - -[[package]] -name = "dns-lookup" -version = "2.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5766087c2235fec47fafa4cfecc81e494ee679d0fd4a59887ea0919bfb0e4fc" -dependencies = [ - "cfg-if", - "libc", - "socket2", - "windows-sys 0.48.0", -] - -[[package]] -name = "docker_credential" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31951f49556e34d90ed28342e1df7e1cb7a229c4cab0aecc627b5d91edd41d07" -dependencies = [ - "base64 0.21.7", - "serde", - "serde_json", -] - [[package]] name = "dotenvy" version = "0.15.7" @@ -2917,15 +2823,6 @@ dependencies = [ "digest", ] -[[package]] -name = "home" -version = "0.5.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" -dependencies = [ - "windows-sys 0.52.0", -] - [[package]] name = "hostname" version = "0.3.1" @@ -3131,40 +3028,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-named-pipe" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b7d8abf35697b81a825e386fc151e0d503e8cb5fcb93cc8669c376dfd6f278" -dependencies = [ - "hex", - "hyper 1.3.1", - "hyper-util", - "pin-project-lite", - "tokio", - "tower-service", - "winapi", -] - -[[package]] -name = "hyper-rustls" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" -dependencies = [ - "futures-util", - "http 1.1.0", - "hyper 1.3.1", - "hyper-util", - "log", - "rustls 0.22.4", - "rustls-native-certs", - "rustls-pki-types", - "tokio", - "tokio-rustls 0.25.0", - "tower-service", -] - [[package]] name = "hyper-rustls" version = "0.27.1" @@ -3216,21 +3079,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "hyperlocal-next" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf569d43fa9848e510358c07b80f4adf34084ddc28c6a4a651ee8474c070dcc" -dependencies = [ - "hex", - "http-body-util", - "hyper 1.3.1", - "hyper-util", - "pin-project-lite", - "tokio", - "tower-service", -] - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -3562,6 +3410,7 @@ dependencies = [ "kitsune-config", "kitsune-core", "kitsune-db", + "kitsune-derive", "kitsune-email", "kitsune-embed", "kitsune-error", @@ -3774,6 +3623,24 @@ dependencies = [ "typed-builder", ] +[[package]] +name = "kitsune-derive" +version = "0.0.1-pre.6" +dependencies = [ + "kitsune-derive-impl", + "triomphe", + "typed-builder", +] + +[[package]] +name = "kitsune-derive-impl" +version = "0.0.1-pre.6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.61", +] + [[package]] name = "kitsune-email" version = "0.0.1-pre.6" @@ -3801,12 +3668,12 @@ dependencies = [ "http 1.1.0", "iso8601-timestamp", "kitsune-db", + "kitsune-derive", "kitsune-error", "kitsune-http-client", "once_cell", "scraper", "smol_str", - "typed-builder", ] [[package]] @@ -3847,6 +3714,7 @@ version = "0.0.1-pre.6" dependencies = [ "globset", "kitsune-config", + "kitsune-derive", "kitsune-error", "kitsune-type", "url", @@ -3863,7 +3731,7 @@ dependencies = [ "http-body-util", "http-signatures", "hyper 1.3.1", - "hyper-rustls 0.27.1", + "hyper-rustls", "hyper-util", "kitsune-type", "pin-project", @@ -3993,6 +3861,7 @@ dependencies = [ "http 1.1.0", "http-body-util", "kitsune-config", + "kitsune-derive", "kitsune-error", "kitsune-http-client", "moka", @@ -4049,6 +3918,7 @@ dependencies = [ "http 1.1.0", "kitsune-config", "kitsune-db", + "kitsune-derive", "kitsune-error", "kitsune-http-client", "kitsune-language", @@ -4059,7 +3929,6 @@ dependencies = [ "speedy-uuid", "strum", "tracing", - "typed-builder", ] [[package]] @@ -4090,6 +3959,7 @@ dependencies = [ "kitsune-config", "kitsune-core", "kitsune-db", + "kitsune-derive", "kitsune-email", "kitsune-embed", "kitsune-error", @@ -4158,8 +4028,6 @@ dependencies = [ "rand 0.8.5", "redis", "rusty-s3", - "testcontainers", - "testcontainers-modules", "tokio", "url", "uuid", @@ -4184,9 +4052,9 @@ dependencies = [ name = "kitsune-url" version = "0.0.1-pre.6" dependencies = [ + "kitsune-derive", "smol_str", "speedy-uuid", - "typed-builder", ] [[package]] @@ -4214,6 +4082,7 @@ dependencies = [ "enum_dispatch", "futures-util", "kitsune-config", + "kitsune-derive", "kitsune-error", "kitsune-type", "mrf-manifest", @@ -4227,7 +4096,6 @@ dependencies = [ "tokio", "tracing", "tracing-subscriber", - "typed-builder", "walkdir", "wasmtime", "wasmtime-wasi", @@ -4398,16 +4266,6 @@ dependencies = [ "libc", ] -[[package]] -name = "libredox" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" -dependencies = [ - "bitflags 2.5.0", - "libc", -] - [[package]] name = "linked-hash-map" version = "0.5.6" @@ -5297,12 +5155,6 @@ dependencies = [ "tokio-stream", ] -[[package]] -name = "option-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" - [[package]] name = "ordered-float" version = "2.10.1" @@ -5467,31 +5319,6 @@ dependencies = [ "windows-targets 0.52.5", ] -[[package]] -name = "parse-display" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06af5f9333eb47bd9ba8462d612e37a8328a5cb80b13f0af4de4c3b89f52dee5" -dependencies = [ - "parse-display-derive", - "regex", - "regex-syntax 0.8.3", -] - -[[package]] -name = "parse-display-derive" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc9252f259500ee570c75adcc4e317fa6f57a1e47747d622e0bf838002a7b790" -dependencies = [ - "proc-macro2", - "quote", - "regex", - "regex-syntax 0.8.3", - "structmeta", - "syn 2.0.61", -] - [[package]] name = "password-hash" version = "0.5.0" @@ -5878,12 +5705,11 @@ dependencies = [ [[package]] name = "proc-macro-crate" -version = "1.3.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ - "once_cell", - "toml_edit 0.19.15", + "toml_edit 0.21.1", ] [[package]] @@ -6249,17 +6075,6 @@ dependencies = [ "bitflags 2.5.0", ] -[[package]] -name = "redox_users" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" -dependencies = [ - "getrandom 0.2.15", - "libredox", - "thiserror", -] - [[package]] name = "ref-cast" version = "1.0.23" @@ -6957,17 +6772,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_repr" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.61", -] - [[package]] name = "serde_spanned" version = "0.6.5" @@ -7554,38 +7358,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "testcontainers" -version = "0.16.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69d47265a44d1035a322691cf0a6cc227d79b62ef86ffb0dbc204b394fee3d07" -dependencies = [ - "async-trait", - "bollard", - "bollard-stubs", - "dirs", - "dns-lookup", - "docker_credential", - "futures", - "log", - "parse-display", - "serde", - "serde_json", - "serde_with", - "tokio", - "tokio-util", - "url", -] - -[[package]] -name = "testcontainers-modules" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8da66a6ebd55684c8e3c58c7374dc2b2d0d1884ac688987e7ffb2d02103a3ee" -dependencies = [ - "testcontainers", -] - [[package]] name = "text-size" version = "1.1.1" @@ -7912,6 +7684,17 @@ dependencies = [ "winnow 0.5.40", ] +[[package]] +name = "toml_edit" +version = "0.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +dependencies = [ + "indexmap 2.2.6", + "toml_datetime", + "winnow 0.5.40", +] + [[package]] name = "toml_edit" version = "0.22.12" @@ -8184,6 +7967,10 @@ name = "triomphe" version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3" +dependencies = [ + "serde", + "stable_deref_trait", +] [[package]] name = "try-lock" diff --git a/Cargo.toml b/Cargo.toml index e536057bc..f240e61d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,8 @@ members = [ "crates/kitsune-config", "crates/kitsune-core", "crates/kitsune-db", + "crates/kitsune-derive", + "crates/kitsune-derive/impl", "crates/kitsune-email", "crates/kitsune-embed", "crates/kitsune-error", diff --git a/crates/kitsune-derive/Cargo.toml b/crates/kitsune-derive/Cargo.toml new file mode 100644 index 000000000..742d07bc4 --- /dev/null +++ b/crates/kitsune-derive/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "kitsune-derive" +authors.workspace = true +edition.workspace = true +version.workspace = true +license.workspace = true + +[dependencies] +kitsune-derive-impl = { path = "impl" } +triomphe = "0.1.11" +typed-builder = "0.18.2" + +[lints] +workspace = true diff --git a/crates/kitsune-derive/LICENSE-AGPL-3.0 b/crates/kitsune-derive/LICENSE-AGPL-3.0 new file mode 120000 index 000000000..43db21b4c --- /dev/null +++ b/crates/kitsune-derive/LICENSE-AGPL-3.0 @@ -0,0 +1 @@ +../../LICENSE-AGPL-3.0 \ No newline at end of file diff --git a/crates/kitsune-derive/impl/Cargo.toml b/crates/kitsune-derive/impl/Cargo.toml new file mode 100644 index 000000000..8e90c1e20 --- /dev/null +++ b/crates/kitsune-derive/impl/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "kitsune-derive-impl" +authors.workspace = true +edition.workspace = true +version.workspace = true +license.workspace = true + +[lib] +proc-macro = true + +[dependencies] +proc-macro2 = "1.0.82" +quote = "1.0.36" +syn = { version = "2.0.61", features = ["full"] } + +[lints] +workspace = true diff --git a/crates/kitsune-derive/impl/src/expand.rs b/crates/kitsune-derive/impl/src/expand.rs new file mode 100644 index 000000000..d5b7c93e0 --- /dev/null +++ b/crates/kitsune-derive/impl/src/expand.rs @@ -0,0 +1,116 @@ +use proc_macro2::TokenStream; +use quote::{format_ident, quote}; +use std::iter; +use syn::{ + parse::{Parse, ParseStream}, + punctuated::Punctuated, + spanned::Spanned, + Token, Visibility, +}; + +struct Attributes { + expand_builder: bool, +} + +impl Default for Attributes { + fn default() -> Self { + Self { + expand_builder: true, + } + } +} + +impl Parse for Attributes { + fn parse(input: ParseStream<'_>) -> syn::Result { + let mut attributes = Self::default(); + let punctuated = Punctuated::::parse_terminated(input)?; + + for ident in punctuated { + if ident == "omit_builder" { + attributes.expand_builder = false; + } else { + return Err(syn::Error::new( + ident.span(), + format!("unknown attribute: {ident}"), + )); + } + } + + Ok(attributes) + } +} + +fn expand_builder( + parsed_struct: &syn::ItemStruct, + inner_struct_name: &syn::Ident, +) -> (TokenStream, TokenStream) { + let struct_name = &parsed_struct.ident; + let inner_builder_name = format_ident!("{inner_struct_name}Builder"); + + let num_lifetimes = parsed_struct.generics.lifetimes().count(); + let lifetimes = iter::repeat(quote!('_)).take(num_lifetimes); + + let attrs = quote! { + #[derive(::kitsune_derive::typed_builder::TypedBuilder)] + #[builder(build_method(into = #struct_name))] + #[builder(crate_module_path = ::kitsune_derive::typed_builder)] + }; + let impls = quote! { + impl #struct_name { + pub fn builder() -> #inner_builder_name<#(#lifetimes),*> { + #inner_struct_name::builder() + } + } + }; + + (attrs, impls) +} + +pub fn expand(attrs: TokenStream, input: TokenStream) -> syn::Result { + let attributes = syn::parse2::(attrs)?; + let mut parsed_struct = syn::parse2::(input)?; + + let struct_name = parsed_struct.ident.clone(); + let inner_struct_name = format_ident!("__{struct_name}__Inner"); + + let (builder_attrs, builder_impls) = if attributes.expand_builder { + expand_builder(&parsed_struct, &inner_struct_name) + } else { + (TokenStream::new(), TokenStream::new()) + }; + + parsed_struct.ident = inner_struct_name.clone(); + parsed_struct.vis = Visibility::Public(Token![pub](parsed_struct.span())); + + let output = quote! { + #builder_attrs + #[allow(non_camel_case_types)] + #[doc(hidden)] + #parsed_struct + + #[derive(Clone)] + pub struct #struct_name { + inner: ::kitsune_derive::triomphe::Arc<#inner_struct_name>, + } + + #builder_impls + + impl ::core::ops::Deref for #struct_name { + type Target = #inner_struct_name; + + fn deref(&self) -> &Self::Target { + &self.inner + } + } + + impl From<#inner_struct_name> for #struct_name { + fn from(inner: #inner_struct_name) -> Self { + Self { + inner: ::kitsune_derive::triomphe::Arc::new(inner), + } + } + } + }; + + Ok(output) +} diff --git a/crates/kitsune-derive/impl/src/lib.rs b/crates/kitsune-derive/impl/src/lib.rs new file mode 100644 index 000000000..9f844ead4 --- /dev/null +++ b/crates/kitsune-derive/impl/src/lib.rs @@ -0,0 +1,12 @@ +mod expand; + +#[proc_macro_attribute] +pub fn kitsune_service( + attrs: proc_macro::TokenStream, + input: proc_macro::TokenStream, +) -> proc_macro::TokenStream { + match self::expand::expand(attrs.into(), input.into()) { + Ok(out) => out.into(), + Err(error) => error.to_compile_error().into(), + } +} diff --git a/crates/kitsune-derive/src/lib.rs b/crates/kitsune-derive/src/lib.rs new file mode 100644 index 000000000..98f900ded --- /dev/null +++ b/crates/kitsune-derive/src/lib.rs @@ -0,0 +1,3 @@ +pub use ::kitsune_derive_impl::kitsune_service; +pub use ::triomphe; +pub use ::typed_builder; diff --git a/crates/kitsune-embed/Cargo.toml b/crates/kitsune-embed/Cargo.toml index 5d8530113..97d6c8576 100644 --- a/crates/kitsune-embed/Cargo.toml +++ b/crates/kitsune-embed/Cargo.toml @@ -12,12 +12,12 @@ embed-sdk = { git = "https://github.com/Lantern-chat/embed-service.git", rev = " http = "1.1.0" iso8601-timestamp = "0.2.17" kitsune-db = { path = "../kitsune-db" } +kitsune-derive = { path = "../kitsune-derive" } kitsune-error = { path = "../kitsune-error" } kitsune-http-client = { path = "../kitsune-http-client" } once_cell = "1.19.0" scraper = { version = "0.19.0", default-features = false } smol_str = "0.2.1" -typed-builder = "0.18.2" [lints] workspace = true diff --git a/crates/kitsune-embed/src/lib.rs b/crates/kitsune-embed/src/lib.rs index a0f774e2d..1cf3a158a 100644 --- a/crates/kitsune-embed/src/lib.rs +++ b/crates/kitsune-embed/src/lib.rs @@ -9,12 +9,12 @@ use kitsune_db::{ schema::link_previews, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::Result; use kitsune_http_client::Client as HttpClient; use once_cell::sync::Lazy; use scraper::{Html, Selector}; use smol_str::SmolStr; -use typed_builder::TypedBuilder; pub use embed_sdk; pub use embed_sdk::Embed; @@ -32,7 +32,7 @@ fn first_link_from_fragment(fragment: &str) -> Option { .and_then(|element| element.value().attr("href").map(ToString::to_string)) } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct Client { db_pool: PgPool, #[builder(setter(into))] diff --git a/crates/kitsune-federation-filter/Cargo.toml b/crates/kitsune-federation-filter/Cargo.toml index fd385f953..06d8d4cd7 100644 --- a/crates/kitsune-federation-filter/Cargo.toml +++ b/crates/kitsune-federation-filter/Cargo.toml @@ -8,6 +8,7 @@ license.workspace = true [dependencies] globset = "0.4.14" kitsune-config = { path = "../kitsune-config" } +kitsune-derive = { path = "../kitsune-derive" } kitsune-error = { path = "../kitsune-error" } kitsune-type = { path = "../kitsune-type" } url = "2.5.0" diff --git a/crates/kitsune-federation-filter/src/lib.rs b/crates/kitsune-federation-filter/src/lib.rs index 1dd0c566a..b8b011f57 100644 --- a/crates/kitsune-federation-filter/src/lib.rs +++ b/crates/kitsune-federation-filter/src/lib.rs @@ -1,8 +1,8 @@ use globset::{Glob, GlobSet, GlobSetBuilder}; use kitsune_config::instance::FederationFilterConfiguration; +use kitsune_derive::kitsune_service; use kitsune_error::{kitsune_error, Result}; use kitsune_type::ap::{actor::Actor, Activity, Object}; -use std::sync::Arc; use url::Url; pub trait Entity { @@ -33,9 +33,9 @@ enum FilterMode { Deny, } -#[derive(Clone)] +#[kitsune_service(omit_builder)] pub struct FederationFilter { - domains: Arc, + domains: GlobSet, filter: FilterMode, } @@ -50,9 +50,12 @@ impl FederationFilter { for glob in globs { globset.add(Glob::new(glob)?); } - let domains = Arc::new(globset.build()?); - Ok(Self { domains, filter }) + Ok(__FederationFilter__Inner { + domains: globset.build()?, + filter, + } + .into()) } pub fn is_url_allowed(&self, url: &Url) -> Result { diff --git a/crates/kitsune-oidc/Cargo.toml b/crates/kitsune-oidc/Cargo.toml index 0e415e0ca..a140b4797 100644 --- a/crates/kitsune-oidc/Cargo.toml +++ b/crates/kitsune-oidc/Cargo.toml @@ -10,6 +10,7 @@ enum_dispatch = "0.3.13" http = "1.1.0" http-body-util = "0.1.1" kitsune-config = { path = "../kitsune-config" } +kitsune-derive = { path = "../kitsune-derive" } kitsune-error = { path = "../kitsune-error" } kitsune-http-client = { path = "../kitsune-http-client" } moka = { version = "0.12.7", features = ["future"] } diff --git a/crates/kitsune-oidc/src/lib.rs b/crates/kitsune-oidc/src/lib.rs index b7cb5af93..3de18cf33 100644 --- a/crates/kitsune-oidc/src/lib.rs +++ b/crates/kitsune-oidc/src/lib.rs @@ -3,6 +3,7 @@ use crate::state::{ LoginState, OAuth2LoginState, Store, }; use kitsune_config::oidc::{Configuration, StoreConfiguration}; +use kitsune_derive::kitsune_service; use kitsune_error::{bail, kitsune_error, Result}; use multiplex_pool::RoundRobinStrategy; use openidconnect::{ @@ -66,7 +67,7 @@ pub struct UserInfo { pub oauth2: OAuth2Info, } -#[derive(Clone)] +#[kitsune_service(omit_builder)] pub struct OidcService { client: OidcClient, login_state_store: self::state::AnyStore, @@ -103,10 +104,11 @@ impl OidcService { } }; - Ok(Self { + Ok(__OidcService__Inner { client, login_state_store, - }) + } + .into()) } pub async fn authorisation_url( diff --git a/crates/kitsune-search/Cargo.toml b/crates/kitsune-search/Cargo.toml index a74301481..eeca5f04e 100644 --- a/crates/kitsune-search/Cargo.toml +++ b/crates/kitsune-search/Cargo.toml @@ -17,6 +17,7 @@ futures-util = "0.3.30" http = "1.1.0" kitsune-config = { path = "../kitsune-config" } kitsune-db = { path = "../kitsune-db" } +kitsune-derive = { path = "../kitsune-derive" } kitsune-error = { path = "../kitsune-error" } kitsune-http-client = { path = "../kitsune-http-client" } kitsune-language = { path = "../kitsune-language" } @@ -27,7 +28,6 @@ serde_urlencoded = "0.7.1" speedy-uuid = { path = "../../lib/speedy-uuid" } strum = { version = "0.26.2", features = ["derive"] } tracing = "0.1.40" -typed-builder = "0.18.2" [lints] workspace = true diff --git a/crates/kitsune-search/src/meilisearch/mod.rs b/crates/kitsune-search/src/meilisearch/mod.rs index ed516b8ff..4d452e5cd 100644 --- a/crates/kitsune-search/src/meilisearch/mod.rs +++ b/crates/kitsune-search/src/meilisearch/mod.rs @@ -1,5 +1,6 @@ use self::http_client::HttpClient; use super::{Result, SearchBackend, SearchIndex, SearchItem, SearchResultReference}; +use kitsune_derive::kitsune_service; use meilisearch_sdk::{client::Client, indexes::Index, settings::Settings}; use serde::Deserialize; use speedy_uuid::Uuid; @@ -12,7 +13,7 @@ struct MeilisearchResult { id: Uuid, } -#[derive(Clone)] +#[kitsune_service(omit_builder)] pub struct MeiliSearchService { client: Client, } @@ -29,9 +30,9 @@ impl MeiliSearchService { .content_length_limit(None) .build(), }; - let service = Self { + let service = Self::from(__MeiliSearchService__Inner { client: Client::new_with_client(host, Some(api_key), http_client), - }; + }); let settings = Settings::new() .with_filterable_attributes(["created_at"]) diff --git a/crates/kitsune-search/src/sql.rs b/crates/kitsune-search/src/sql.rs index a2f76485a..0c947ef20 100644 --- a/crates/kitsune-search/src/sql.rs +++ b/crates/kitsune-search/src/sql.rs @@ -11,10 +11,10 @@ use kitsune_db::{ schema::{accounts, posts}, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use speedy_uuid::Uuid; -use typed_builder::TypedBuilder; -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct SearchService { db_pool: PgPool, language_detection_config: LanguageDetectionConfig, diff --git a/crates/kitsune-service/Cargo.toml b/crates/kitsune-service/Cargo.toml index 6d8205c91..40f744790 100644 --- a/crates/kitsune-service/Cargo.toml +++ b/crates/kitsune-service/Cargo.toml @@ -32,6 +32,7 @@ kitsune-captcha = { path = "../kitsune-captcha" } kitsune-config = { path = "../kitsune-config" } kitsune-core = { path = "../kitsune-core" } kitsune-db = { path = "../kitsune-db" } +kitsune-derive = { path = "../kitsune-derive" } kitsune-email = { path = "../kitsune-email" } kitsune-embed = { path = "../kitsune-embed" } kitsune-error = { path = "../kitsune-error" } diff --git a/crates/kitsune-service/src/account.rs b/crates/kitsune-service/src/account.rs index 08112ed4d..815f2796c 100644 --- a/crates/kitsune-service/src/account.rs +++ b/crates/kitsune-service/src/account.rs @@ -27,6 +27,7 @@ use kitsune_db::{ schema::{accounts, accounts_follows, accounts_preferences, notifications, posts}, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::{Error, Result}; use kitsune_jobs::deliver::{ accept::DeliverAccept, @@ -178,7 +179,7 @@ impl Update { } } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct AccountService { attachment_service: AttachmentService, db_pool: PgPool, diff --git a/crates/kitsune-service/src/attachment.rs b/crates/kitsune-service/src/attachment.rs index f31e7aa09..c52a2b2b9 100644 --- a/crates/kitsune-service/src/attachment.rs +++ b/crates/kitsune-service/src/attachment.rs @@ -11,6 +11,7 @@ use kitsune_db::{ schema::media_attachments, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::{kitsune_error, Error, ErrorType, Result}; use kitsune_http_client::Client; use kitsune_storage::{AnyStorageBackend, StorageBackend}; @@ -73,7 +74,7 @@ impl Upload { } } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct AttachmentService { #[builder(default = Client::builder() diff --git a/crates/kitsune-service/src/captcha.rs b/crates/kitsune-service/src/captcha.rs index 2f61abae2..3b203ab05 100644 --- a/crates/kitsune-service/src/captcha.rs +++ b/crates/kitsune-service/src/captcha.rs @@ -1,8 +1,8 @@ use kitsune_captcha::{AnyCaptcha, CaptchaBackend, ChallengeStatus}; +use kitsune_derive::kitsune_service; use kitsune_error::Result; -use typed_builder::TypedBuilder; -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct CaptchaService { #[builder(setter(into))] pub backend: Option, diff --git a/crates/kitsune-service/src/custom_emoji.rs b/crates/kitsune-service/src/custom_emoji.rs index f48be5bad..9dbb54ea5 100644 --- a/crates/kitsune-service/src/custom_emoji.rs +++ b/crates/kitsune-service/src/custom_emoji.rs @@ -14,6 +14,7 @@ use kitsune_db::{ schema::{custom_emojis, media_attachments, posts, posts_custom_emojis}, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::{Error, Result}; use kitsune_url::UrlService; use speedy_uuid::Uuid; @@ -60,7 +61,7 @@ pub struct EmojiUpload { stream: S, } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct CustomEmojiService { attachment_service: AttachmentService, db_pool: PgPool, diff --git a/crates/kitsune-service/src/instance.rs b/crates/kitsune-service/src/instance.rs index 30188506e..08bd112d5 100644 --- a/crates/kitsune-service/src/instance.rs +++ b/crates/kitsune-service/src/instance.rs @@ -4,11 +4,11 @@ use kitsune_db::{ schema::{accounts, posts, users}, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::{Error, Result}; use smol_str::SmolStr; -use typed_builder::TypedBuilder; -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct InstanceService { db_pool: PgPool, #[builder(setter(into))] diff --git a/crates/kitsune-service/src/job.rs b/crates/kitsune-service/src/job.rs index aa1562c95..9410c6284 100644 --- a/crates/kitsune-service/src/job.rs +++ b/crates/kitsune-service/src/job.rs @@ -1,5 +1,6 @@ use athena::{JobDetails, JobQueue}; use iso8601_timestamp::Timestamp; +use kitsune_derive::kitsune_service; use kitsune_error::Result; use kitsune_jobs::{Job, KitsuneContextRepo}; use std::sync::Arc; @@ -12,7 +13,7 @@ pub struct Enqueue { run_at: Option, } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct JobService { job_queue: Arc>, } diff --git a/crates/kitsune-service/src/notification.rs b/crates/kitsune-service/src/notification.rs index 2171f281f..ae6613f90 100644 --- a/crates/kitsune-service/src/notification.rs +++ b/crates/kitsune-service/src/notification.rs @@ -11,11 +11,12 @@ use kitsune_db::{ schema::{accounts, accounts_follows, accounts_preferences, notifications, posts}, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::{Error, Result}; use speedy_uuid::Uuid; use typed_builder::TypedBuilder; -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct NotificationService { db_pool: PgPool, } diff --git a/crates/kitsune-service/src/post/mod.rs b/crates/kitsune-service/src/post/mod.rs index d980ae1eb..daff6bd92 100644 --- a/crates/kitsune-service/src/post/mod.rs +++ b/crates/kitsune-service/src/post/mod.rs @@ -33,6 +33,7 @@ use kitsune_db::{ }, with_connection, with_transaction, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_embed::Client as EmbedClient; use kitsune_error::{bail, Error, ErrorType, Result}; use kitsune_jobs::deliver::{ @@ -294,7 +295,7 @@ pub struct GetAccountsInteractingWithPost { max_id: Option, } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct PostService { db_pool: PgPool, embed_client: Option, diff --git a/crates/kitsune-service/src/search.rs b/crates/kitsune-service/src/search.rs index 401818f3f..9a520a0c8 100644 --- a/crates/kitsune-service/src/search.rs +++ b/crates/kitsune-service/src/search.rs @@ -9,6 +9,7 @@ use kitsune_db::{ schema::{accounts, posts}, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::Result; use kitsune_search::{SearchBackend, SearchIndex}; use speedy_uuid::Uuid; @@ -37,7 +38,7 @@ pub struct Search<'a> { max_id: Option, } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct SearchService { db_pool: PgPool, fetcher: Arc, diff --git a/crates/kitsune-service/src/timeline.rs b/crates/kitsune-service/src/timeline.rs index a7a1f3292..abdd68ca0 100644 --- a/crates/kitsune-service/src/timeline.rs +++ b/crates/kitsune-service/src/timeline.rs @@ -9,6 +9,7 @@ use kitsune_db::{ schema::{accounts_follows, posts, posts_mentions}, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::{Error, Result}; use speedy_uuid::Uuid; use typed_builder::TypedBuilder; @@ -62,7 +63,7 @@ pub struct GetPublic { only_remote: bool, } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct TimelineService { db_pool: PgPool, } diff --git a/crates/kitsune-service/src/user.rs b/crates/kitsune-service/src/user.rs index 743f0147d..f09b83d76 100644 --- a/crates/kitsune-service/src/user.rs +++ b/crates/kitsune-service/src/user.rs @@ -16,6 +16,7 @@ use kitsune_db::{ schema::{accounts, accounts_preferences, users}, with_transaction, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::{bail, kitsune_error, Error, ErrorType, Result}; use kitsune_jobs::mailing::confirmation::SendConfirmationMail; use kitsune_url::UrlService; @@ -112,7 +113,7 @@ pub struct Register { force_registration: bool, } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct UserService { allow_non_ascii_usernames: bool, captcha_service: CaptchaService, diff --git a/crates/kitsune-test/Cargo.toml b/crates/kitsune-test/Cargo.toml index c47d1acf1..997d67d08 100644 --- a/crates/kitsune-test/Cargo.toml +++ b/crates/kitsune-test/Cargo.toml @@ -23,12 +23,6 @@ redis = { version = "0.25.3", default-features = false, features = [ "tokio-rustls-comp", ] } rusty-s3 = { version = "0.5.0", default-features = false } -testcontainers = "0.16.7" -testcontainers-modules = { version = "0.4.2", features = [ - "minio", - "postgres", - "redis", -] } tokio = { version = "1.37.0", features = ["time"] } url = "2.5.0" uuid = { version = "1.8.0", features = ["fast-rng", "v4"] } diff --git a/crates/kitsune-test/src/container.rs b/crates/kitsune-test/src/container.rs deleted file mode 100644 index 97fbf1659..000000000 --- a/crates/kitsune-test/src/container.rs +++ /dev/null @@ -1,56 +0,0 @@ -use testcontainers::{core::ContainerAsync, runners::AsyncRunner, RunnableImage}; -use testcontainers_modules::{minio::MinIO, postgres::Postgres, redis::Redis}; - -pub trait Service { - const PORT: u16; - - async fn url(&self) -> String; -} - -impl Service for ContainerAsync { - const PORT: u16 = 9000; - - async fn url(&self) -> String { - let port = self.get_host_port_ipv4(Self::PORT).await; - format!("http://127.0.0.1:{port}") - } -} - -impl Service for ContainerAsync { - const PORT: u16 = 5432; - - async fn url(&self) -> String { - let port = self.get_host_port_ipv4(Self::PORT).await; - format!("postgres://postgres:postgres@127.0.0.1:{port}/test_db") - } -} - -impl Service for ContainerAsync { - const PORT: u16 = 6379; - - async fn url(&self) -> String { - let port = self.get_host_port_ipv4(Self::PORT).await; - format!("redis://127.0.0.1:{port}") - } -} - -pub async fn minio() -> impl Service { - MinIO::default().start().await -} - -pub async fn postgres() -> impl Service { - let base = Postgres::default() - .with_user("postgres") - .with_password("postgres") - .with_db_name("test_db"); - - RunnableImage::from(base) - .with_tag("15-alpine") - .start() - .await -} - -pub async fn redis() -> impl Service { - #[allow(clippy::default_constructed_unit_structs)] - Redis::default().start().await -} diff --git a/crates/kitsune-test/src/lib.rs b/crates/kitsune-test/src/lib.rs index 121a810fe..9f4b8583a 100644 --- a/crates/kitsune-test/src/lib.rs +++ b/crates/kitsune-test/src/lib.rs @@ -12,12 +12,11 @@ use kitsune_config::{ use kitsune_db::PgPool; use multiplex_pool::RoundRobinStrategy; use resource::provide_resource; -use std::sync::Arc; +use std::{env, sync::Arc}; use url::Url; use uuid::Uuid; mod catch_panic; -mod container; mod macros; mod redis; mod resource; @@ -37,8 +36,8 @@ where F: FnOnce(PgPool) -> Fut, Fut: Future, { - let resource_handle = get_resource!("DATABASE_URL", self::container::postgres); - let mut url = Url::parse(&resource_handle.url().await).unwrap(); + let db_url = env::var("DATABASE_URL").unwrap(); + let mut url = Url::parse(&db_url).unwrap(); // Create a new separate database for this test let id = Uuid::new_v4().as_simple().to_string(); @@ -84,8 +83,8 @@ where F: FnOnce(Arc) -> Fut, Fut: Future, { - let resource_handle = get_resource!("MINIO_URL", self::container::minio); - let endpoint = resource_handle.url().await.parse().unwrap(); + let endpoint = env::var("MINIO_URL").unwrap(); + let endpoint = endpoint.parse().unwrap(); // Create a new bucket with a random ID let bucket_id = Uuid::new_v4().as_simple().to_string(); @@ -116,8 +115,8 @@ where F: FnOnce(multiplex_pool::Pool) -> Fut, Fut: Future, { - let resource_handle = get_resource!("REDIS_URL", self::container::redis); - let client = ::redis::Client::open(resource_handle.url().await.as_ref()).unwrap(); + let redis_url = env::var("REDIS_URL").unwrap(); + let client = ::redis::Client::open(redis_url.as_ref()).unwrap(); // Connect to a random Redis database let db_id = self::redis::find_unused_database(&client).await; diff --git a/crates/kitsune-test/src/resource.rs b/crates/kitsune-test/src/resource.rs index 421e2b261..1cb711870 100644 --- a/crates/kitsune-test/src/resource.rs +++ b/crates/kitsune-test/src/resource.rs @@ -1,37 +1,5 @@ -use crate::{catch_panic::CatchPanic, container::Service}; -use std::{borrow::Cow, future::Future, panic}; - -#[macro_export] -macro_rules! get_resource { - ($env_name:literal, $container_fn:path) => { - if let Ok(url) = ::std::env::var($env_name) { - $crate::resource::ResourceHandle::Url(url) - } else { - let container = $container_fn().await; - $crate::resource::ResourceHandle::Container(container) - } - }; -} - -pub enum ResourceHandle -where - S: Service, -{ - Container(S), - Url(String), -} - -impl ResourceHandle -where - S: Service, -{ - pub async fn url(&self) -> Cow<'_, str> { - match self { - Self::Container(container) => Cow::Owned(container.url().await), - Self::Url(ref url) => Cow::Borrowed(url), - } - } -} +use crate::catch_panic::CatchPanic; +use std::{future::Future, panic}; /// Provide a resource to the `run` closure, catch any panics that may occur while polling the future returned by `run`, /// then run the `cleanup` closure, and resume any panic unwinds that were caught diff --git a/crates/kitsune-url/Cargo.toml b/crates/kitsune-url/Cargo.toml index a8196b249..1aaf929b0 100644 --- a/crates/kitsune-url/Cargo.toml +++ b/crates/kitsune-url/Cargo.toml @@ -6,9 +6,9 @@ version.workspace = true license.workspace = true [dependencies] +kitsune-derive = { path = "../kitsune-derive" } smol_str = "0.2.1" speedy-uuid = { path = "../../lib/speedy-uuid" } -typed-builder = "0.18.2" [lints] workspace = true diff --git a/crates/kitsune-url/src/lib.rs b/crates/kitsune-url/src/lib.rs index 440ed2466..61097f186 100644 --- a/crates/kitsune-url/src/lib.rs +++ b/crates/kitsune-url/src/lib.rs @@ -1,12 +1,12 @@ +use kitsune_derive::kitsune_service; use smol_str::SmolStr; use speedy_uuid::Uuid; -use typed_builder::TypedBuilder; /// Small "service" to centralise the creation of URLs /// /// For some light deduplication purposes and to centralise the whole formatting story. /// Allows for easier adjustments of URLs. -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct UrlService { #[builder(setter(into))] scheme: SmolStr, diff --git a/crates/kitsune-wasm-mrf/Cargo.toml b/crates/kitsune-wasm-mrf/Cargo.toml index 4de759a09..7f9eed25d 100644 --- a/crates/kitsune-wasm-mrf/Cargo.toml +++ b/crates/kitsune-wasm-mrf/Cargo.toml @@ -16,6 +16,7 @@ futures-util = { version = "0.3.30", default-features = false, features = [ "alloc", ] } kitsune-config = { path = "../kitsune-config" } +kitsune-derive = { path = "../kitsune-derive" } kitsune-error = { path = "../kitsune-error" } kitsune-type = { path = "../kitsune-type" } mrf-manifest = { path = "../../lib/mrf-manifest", features = ["decode"] } @@ -30,7 +31,6 @@ sled = "0.34.7" smol_str = "0.2.1" tokio = { version = "1.37.0", features = ["fs"] } tracing = "0.1.40" -typed-builder = "0.18.2" walkdir = "2.5.0" wasmtime = { version = "20.0.2", default-features = false, features = [ "addr2line", diff --git a/crates/kitsune-wasm-mrf/src/lib.rs b/crates/kitsune-wasm-mrf/src/lib.rs index b519f5be7..a424f7a80 100644 --- a/crates/kitsune-wasm-mrf/src/lib.rs +++ b/crates/kitsune-wasm-mrf/src/lib.rs @@ -11,6 +11,7 @@ use futures_util::{stream::FuturesUnordered, Stream, TryFutureExt, TryStreamExt} use kitsune_config::mrf::{ Configuration as MrfConfiguration, FsKvStorage, KvStorage, RedisKvStorage, }; +use kitsune_derive::kitsune_service; use kitsune_error::Error; use kitsune_type::ap::Activity; use mrf_manifest::{Manifest, ManifestV1}; @@ -23,7 +24,6 @@ use std::{ sync::Arc, }; use tokio::fs; -use typed_builder::TypedBuilder; use walkdir::WalkDir; use wasmtime::{ component::{Component, Linker}, @@ -111,7 +111,7 @@ pub struct MrfModule { pub manifest: ManifestV1<'static>, } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct MrfService { engine: Engine, linker: Arc>, @@ -131,12 +131,13 @@ impl MrfService { mrf_wit::v1::Mrf::add_to_linker(&mut linker, |ctx| ctx).map_err(eyre::Report::msg)?; wasmtime_wasi::add_to_linker_async(&mut linker).map_err(eyre::Report::msg)?; - Ok(Self { + Ok(__MrfService__Inner { engine, linker: Arc::new(linker), modules: modules.into(), storage: Arc::new(storage), - }) + } + .into()) } #[instrument(skip_all, fields(module_dir = %config.module_dir))] diff --git a/kitsune/Cargo.toml b/kitsune/Cargo.toml index 656eb6c58..a785dce5c 100644 --- a/kitsune/Cargo.toml +++ b/kitsune/Cargo.toml @@ -51,6 +51,7 @@ kitsune-captcha = { path = "../crates/kitsune-captcha" } kitsune-config = { path = "../crates/kitsune-config" } kitsune-core = { path = "../crates/kitsune-core" } kitsune-db = { path = "../crates/kitsune-db" } +kitsune-derive = { path = "../crates/kitsune-derive" } kitsune-email = { path = "../crates/kitsune-email" } kitsune-embed = { path = "../crates/kitsune-embed" } kitsune-error = { path = "../crates/kitsune-error" } @@ -112,7 +113,7 @@ utoipa-swagger-ui = { version = "=6.0.0", features = ["axum"] } # --- Optional dependencies --- # "graphql" feature -async-graphql = { version = "7.0.3", default-features = false, features = [ +async-graphql = { version = "7.0.5", default-features = false, features = [ "playground", "tempfile", "time", @@ -120,7 +121,7 @@ async-graphql = { version = "7.0.3", default-features = false, features = [ "unblock", "uuid", ], optional = true } -async-graphql-axum = { version = "7.0.3", optional = true } +async-graphql-axum = { version = "7.0.5", optional = true } # "mastodon-api" feature kitsune-mastodon = { path = "../crates/kitsune-mastodon", optional = true } diff --git a/kitsune/src/consts.rs b/kitsune/src/consts.rs index c0e7dc3bf..fe1ae9f94 100644 --- a/kitsune/src/consts.rs +++ b/kitsune/src/consts.rs @@ -1,18 +1,4 @@ pub const API_DEFAULT_LIMIT: usize = 20; -pub const STARTUP_FIGLET: &str = r" -┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ -┃ ┃ -┃ ██╗ ██╗██╗████████╗███████╗██╗ ██╗███╗ ██╗███████╗ ┃ -┃ ██║ ██╔╝██║╚══██╔══╝██╔════╝██║ ██║████╗ ██║██╔════╝ ┃ -┃ █████╔╝ ██║ ██║ ███████╗██║ ██║██╔██╗ ██║█████╗ ┃ -┃ ██╔═██╗ ██║ ██║ ╚════██║██║ ██║██║╚██╗██║██╔══╝ ┃ -┃ ██║ ██╗██║ ██║ ███████║╚██████╔╝██║ ╚████║███████╗ ┃ -┃ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝ ┃ -┃ ┃ -┃ ActivityPub-federated microblogging ┃ -┃ ┃ -┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ -"; #[must_use] pub fn default_limit() -> T diff --git a/kitsune/src/main.rs b/kitsune/src/main.rs index 107ca69d3..d40bf5d33 100644 --- a/kitsune/src/main.rs +++ b/kitsune/src/main.rs @@ -1,6 +1,5 @@ use clap::Parser; use color_eyre::eyre::{self, Context}; -use kitsune::consts::STARTUP_FIGLET; use kitsune_config::Configuration; use kitsune_core::consts::VERSION; use kitsune_job_runner::JobDispatcherState; @@ -19,8 +18,6 @@ struct Args { } async fn boot() -> eyre::Result<()> { - println!("{STARTUP_FIGLET}"); - let args = Args::parse(); let config = Configuration::load(args.config).await?; kitsune_observability::initialise(env!("CARGO_PKG_NAME"), &config)?; diff --git a/kitsune/src/oauth2/mod.rs b/kitsune/src/oauth2/mod.rs index b195e223d..a22cd1751 100644 --- a/kitsune/src/oauth2/mod.rs +++ b/kitsune/src/oauth2/mod.rs @@ -9,6 +9,7 @@ use kitsune_db::{ schema::{oauth2_applications, oauth2_authorization_codes}, with_connection, PgPool, }; +use kitsune_derive::kitsune_service; use kitsune_error::{Error, Result}; use kitsune_url::UrlService; use kitsune_util::generate_secret; @@ -84,7 +85,7 @@ struct ShowTokenPage { token: String, } -#[derive(Clone, TypedBuilder)] +#[kitsune_service] pub struct OAuth2Service { db_pool: PgPool, url_service: UrlService, diff --git a/lib/masto-id-convert/fuzz/Cargo.lock b/lib/masto-id-convert/fuzz/Cargo.lock index 374e96768..9b40396c5 100644 --- a/lib/masto-id-convert/fuzz/Cargo.lock +++ b/lib/masto-id-convert/fuzz/Cargo.lock @@ -16,28 +16,29 @@ checksum = "b6970a22a33d6a8f862aac371bac48505a1bfaa230ecb268c7b86fa4ac6e7121" [[package]] name = "cc" -version = "1.0.89" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libfuzzer-sys" @@ -52,7 +53,7 @@ dependencies = [ [[package]] name = "masto-id-convert" -version = "0.0.1-pre.5" +version = "0.0.1-pre.6" dependencies = [ "atoi_radix10", "nanorand", @@ -81,6 +82,6 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "uuid" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f00cc9702ca12d3c81455259621e676d0f7251cec66a21e98fe2e9a37db93b2a" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/lib/post-process/fuzz/Cargo.lock b/lib/post-process/fuzz/Cargo.lock index 313d19532..5317d00f9 100644 --- a/lib/post-process/fuzz/Cargo.lock +++ b/lib/post-process/fuzz/Cargo.lock @@ -10,9 +10,9 @@ checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" [[package]] name = "autocfg" -version = "1.1.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "beef" @@ -22,12 +22,13 @@ checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" [[package]] name = "cc" -version = "1.0.89" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" +checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" dependencies = [ "jobserver", "libc", + "once_cell", ] [[package]] @@ -74,9 +75,9 @@ dependencies = [ [[package]] name = "jobserver" -version = "0.1.28" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6" +checksum = "d2b099aaa34a9751c5bf0878add70444e1ed2dd73f347be99003d4577277de6e" dependencies = [ "libc", ] @@ -89,9 +90,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.154" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" [[package]] name = "libfuzzer-sys" @@ -145,9 +146,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "pin-project-lite" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" @@ -157,7 +158,7 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "post-process" -version = "0.0.1-pre.5" +version = "0.0.1-pre.6" dependencies = [ "logos", ] @@ -173,27 +174,27 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.78" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.35" +version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ "proc-macro2", ] [[package]] name = "regex-syntax" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" +checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" [[package]] name = "slab" @@ -206,9 +207,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.52" +version = "2.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" +checksum = "c993ed8ccba56ae856363b1845da7266a7cb78e1d146c8a32d54b45a8b831fc9" dependencies = [ "proc-macro2", "quote", diff --git a/lib/speedy-uuid/Cargo.toml b/lib/speedy-uuid/Cargo.toml index b36caa7e3..8459a93e7 100644 --- a/lib/speedy-uuid/Cargo.toml +++ b/lib/speedy-uuid/Cargo.toml @@ -6,7 +6,7 @@ version.workspace = true license = "MIT OR Apache-2.0" [dependencies] -async-graphql = { version = "7.0.3", default-features = false, optional = true } +async-graphql = { version = "7.0.5", default-features = false, optional = true } diesel = { version = "2.1.6", features = [ "postgres_backend", "uuid",