diff --git a/.github/labeler.yml b/.github/labeler.yml index fca2a40588..5dce73dddb 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -31,3 +31,9 @@ api-keys: - core/api-keys/* - flake.lock - Cargo.lock + +notifications: + - third-party/rust/* + - core/notifications/* + - flake.lock + - Cargo.lock diff --git a/.github/workflows/buck2-test.yaml b/.github/workflows/buck2-test.yaml index 36cf3e9f29..fb8f1e0e2c 100644 --- a/.github/workflows/buck2-test.yaml +++ b/.github/workflows/buck2-test.yaml @@ -23,7 +23,7 @@ jobs: ${{ toJSON(github.event.pull_request.labels.*.name) }} EOF - DEFAULT_LABELS=("dashboard" "consent" "pay" "core", "api-keys") + DEFAULT_LABELS=("dashboard" "consent" "pay" "core", "api-keys", "notfications") LABELS=($(jq -r '.[]' < labels.json)) if [ ${#LABELS[@]} -eq 0 ]; then LABELS=("${DEFAULT_LABELS[@]}") @@ -37,7 +37,7 @@ jobs: core) ARGS+=" //core/api:test" ;; - api-keys) + api-keys|notifications) ARGS+=" //core/$LABEL:test" ;; esac diff --git a/Cargo.lock b/Cargo.lock index 80fb126279..1e9e74c1e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -134,6 +134,7 @@ dependencies = [ "axum", "chrono", "clap", + "es-entity", "jsonwebtoken", "rand", "reqwest", @@ -207,7 +208,7 @@ checksum = "c7f329c7eb9b646a72f70c9c4b516c70867d356ec46cb00dcac8ad343fd006b0" dependencies = [ "Inflector", "async-graphql-parser", - "darling", + "darling 0.20.3", "proc-macro-crate", "proc-macro2", "quote", @@ -591,14 +592,38 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core 0.14.4", + "darling_macro 0.14.4", +] + [[package]] name = "darling" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.20.3", + "darling_macro 0.20.3", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", ] [[package]] @@ -615,13 +640,24 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core 0.14.4", + "quote", + "syn 1.0.109", +] + [[package]] name = "darling_macro" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ - "darling_core", + "darling_core 0.20.3", "quote", "syn 2.0.48", ] @@ -653,6 +689,37 @@ dependencies = [ "serde", ] +[[package]] +name = "derive_builder" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +dependencies = [ + "darling 0.14.4", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + [[package]] name = "digest" version = "0.10.7" @@ -705,6 +772,18 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "es-entity" +version = "0.1.0" +dependencies = [ + "derive_builder", + "serde", + "serde_json", + "sqlx", + "thiserror", + "uuid", +] + [[package]] name = "etcetera" version = "0.8.0" @@ -1349,6 +1428,30 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "notifications" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-graphql", + "async-graphql-axum", + "axum", + "chrono", + "clap", + "jsonwebtoken", + "rand", + "reqwest", + "serde", + "serde_json", + "serde_with", + "serde_yaml", + "sqlx", + "thiserror", + "tokio", + "tracing 0.1.0", + "uuid", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2060,7 +2163,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" dependencies = [ - "darling", + "darling 0.20.3", "proc-macro2", "quote", "syn 2.0.48", diff --git a/Cargo.toml b/Cargo.toml index 65107b493e..a4a82039df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,9 @@ debug = true resolver = "2" members = [ "core/api-keys", + "core/notifications", "lib/tracing-rs", + "lib/es-entity-rs", ] [workspace.dependencies] @@ -15,6 +17,7 @@ async-graphql-axum = "6.0.9" axum = { version = "0.6.20", features = ["headers", "macros"] } jsonwebtoken = "9.2.0" clap = { version = "4.4", features = ["derive", "env"] } +derive_builder = "0.12.0" serde = { version = "1.0.158", features = ["derive"] } tokio = { version = "1.33.0", features = ["full"] } reqwest = { version = "0.11.23", default-features = false, features = ["json", "rustls-tls"] } diff --git a/core/api-keys/BUCK b/core/api-keys/BUCK index bf5c878262..231531ef43 100644 --- a/core/api-keys/BUCK +++ b/core/api-keys/BUCK @@ -46,6 +46,7 @@ rust_library( edition = "2021", deps = [ "//lib/tracing-rs:tracing", + "//lib/es-entity-rs:es-entity", "//third-party/rust:tokio", "//third-party/rust:anyhow", "//third-party/rust:async-graphql", @@ -88,6 +89,7 @@ rust_test( crate_root = "src/lib.rs", deps = [ "//lib/tracing-rs:tracing", + "//lib/es-entity-rs:es-entity", "//third-party/rust:tokio", "//third-party/rust:anyhow", "//third-party/rust:async-graphql", diff --git a/core/api-keys/Cargo.toml b/core/api-keys/Cargo.toml index 753c7e9758..4e14e2e1af 100644 --- a/core/api-keys/Cargo.toml +++ b/core/api-keys/Cargo.toml @@ -16,6 +16,7 @@ fail-on-warnings = [] [dependencies] tracing = { path = "../../lib/tracing-rs" } +es-entity = { path = "../../lib/es-entity-rs" } anyhow = { workspace = true } async-graphql = { workspace = true } diff --git a/core/api-keys/src/identity/mod.rs b/core/api-keys/src/identity/mod.rs index 04c151e3a4..25863ceec7 100644 --- a/core/api-keys/src/identity/mod.rs +++ b/core/api-keys/src/identity/mod.rs @@ -7,8 +7,8 @@ use std::sync::Arc; pub use error::*; -crate::entity_id! { IdentityApiKeyId } -crate::entity_id! { IdentityId } +es_entity::entity_id! { IdentityApiKeyId } +es_entity::entity_id! { IdentityId } #[derive(Debug)] pub struct IdentityApiKey { diff --git a/core/api-keys/src/lib.rs b/core/api-keys/src/lib.rs index 6208624fed..3429322a92 100644 --- a/core/api-keys/src/lib.rs +++ b/core/api-keys/src/lib.rs @@ -3,7 +3,6 @@ pub mod app; pub mod cli; -mod entity; pub mod graphql; pub mod identity; pub mod scope; diff --git a/core/notifications/BUCK b/core/notifications/BUCK new file mode 100644 index 0000000000..57b57e8218 --- /dev/null +++ b/core/notifications/BUCK @@ -0,0 +1,138 @@ +load("@toolchains//rover:macros.bzl", "sdl", "diff_check", "dev_update_file") +load("@toolchains//rust:macros.bzl", "rustfmt_check", "clippy_check") + +sdl( + name = "sdl", + generator = ":write-sdl", + visibility = ["PUBLIC"], +) + +diff_check( + name = "schema-diff", + original = "subgraph/schema.graphql", + new = ":sdl" +) + +dev_update_file( + name = "update-schema", + generated = ":sdl", + out = "subgraph/schema.graphql" +) + +rust_binary( + name = "write-sdl", + edition = "2021", + crate_root = "src/bin/write_sdl.rs", + srcs = glob(["src/**/*.rs"]), + deps = [ + ":lib-notifications", + "//third-party/rust:async-graphql", + ], +) + +rust_binary( + name = "notifications", + edition = "2021", + srcs = glob(["src/**/*.rs"]), + deps = [ + ":lib-notifications", + "//third-party/rust:tokio", + "//third-party/rust:anyhow", + ], +) + +rust_library( + name = "lib-notifications", + edition = "2021", + deps = [ + "//lib/tracing-rs:tracing", + "//third-party/rust:tokio", + "//third-party/rust:anyhow", + "//third-party/rust:async-graphql", + "//third-party/rust:async-graphql-axum", + "//third-party/rust:axum", + "//third-party/rust:jsonwebtoken", + "//third-party/rust:clap", + "//third-party/rust:reqwest", + "//third-party/rust:serde", + "//third-party/rust:serde_yaml", + "//third-party/rust:serde_json", + "//third-party/rust:thiserror", + "//third-party/rust:chrono", + "//third-party/rust:sqlx", + "//third-party/rust:rand", + "//third-party/rust:uuid", + "//third-party/rust:serde_with", + ], + srcs = glob([ + "src/**/*.rs", + ".sqlx/*", + "migrations/*", + "notifications.yml" + ]), + env = { + "CARGO_MANIFEST_DIR": ".", + "SQLX_OFFLINE": "true", + } +) + +rust_test( + name = "test-unit", + edition = "2021", + srcs = glob([ + "src/**/*.rs", + ".sqlx/*", + "migrations/*", + "api-keys.yml" + ]), + crate_root = "src/lib.rs", + deps = [ + "//lib/tracing-rs:tracing", + "//third-party/rust:tokio", + "//third-party/rust:anyhow", + "//third-party/rust:async-graphql", + "//third-party/rust:async-graphql-axum", + "//third-party/rust:axum", + "//third-party/rust:jsonwebtoken", + "//third-party/rust:clap", + "//third-party/rust:reqwest", + "//third-party/rust:serde", + "//third-party/rust:serde_yaml", + "//third-party/rust:serde_json", + "//third-party/rust:thiserror", + "//third-party/rust:chrono", + "//third-party/rust:sqlx", + "//third-party/rust:rand", + "//third-party/rust:uuid", + "//third-party/rust:serde_with", + ], + env = { + "CARGO_MANIFEST_DIR": ".", + "SQLX_OFFLINE": "true", + } +) + +rustfmt_check( + name = "check-format-rust", + srcs = glob([ + "src/**/*.rs", + ".sqlx/*", + "migrations/*", + "api-keys.yml" + ]), + crate_root = "src/lib.rs", +) + +clippy_check( + name = "check-lint-rust-lib", + clippy_txt_dep = ":lib-notifications[clippy.txt]", +) + +test_suite( + name = "test", + tests = [ + ":check-format-rust", + ":check-lint-rust-lib", + ":test-unit" + ], +) diff --git a/core/notifications/Cargo.toml b/core/notifications/Cargo.toml new file mode 100644 index 0000000000..752c9e7016 --- /dev/null +++ b/core/notifications/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "notifications" +version = "0.1.0" +edition = "2021" + +[lib] +name = "lib_notifications" + +[[bin]] +name = "write_sdl" +path = "src/bin/write_sdl.rs" + +[features] + +fail-on-warnings = [] + +[dependencies] +tracing = { path = "../../lib/tracing-rs" } + +anyhow = { workspace = true } +async-graphql = { workspace = true } +async-graphql-axum = { workspace = true } +axum = { workspace = true } +jsonwebtoken = { workspace = true } +clap = { workspace = true } +tokio = { workspace = true } +reqwest = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +serde_yaml = { workspace = true } +thiserror = { workspace = true } +chrono = { workspace = true } +sqlx = { workspace = true } +rand = { workspace = true } +uuid = { workspace = true } +serde_with = { workspace = true } diff --git a/core/notifications/src/bin/write_sdl.rs b/core/notifications/src/bin/write_sdl.rs new file mode 100644 index 0000000000..dda59aead3 --- /dev/null +++ b/core/notifications/src/bin/write_sdl.rs @@ -0,0 +1,10 @@ +use async_graphql::SDLExportOptions; + +fn main() { + // println!( + // "{}", + // lib_notifications::graphql::schema(None) + // .sdl_with_options(SDLExportOptions::new().federation()) + // .trim() + // ); +} diff --git a/core/notifications/src/lib.rs b/core/notifications/src/lib.rs new file mode 100644 index 0000000000..394544aec7 --- /dev/null +++ b/core/notifications/src/lib.rs @@ -0,0 +1,4 @@ +#![cfg_attr(feature = "fail-on-warnings", deny(warnings))] +#![cfg_attr(feature = "fail-on-warnings", deny(clippy::all))] + +mod settings; diff --git a/core/notifications/src/main.rs b/core/notifications/src/main.rs new file mode 100644 index 0000000000..e7a11a969c --- /dev/null +++ b/core/notifications/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/core/notifications/src/settings/mod.rs b/core/notifications/src/settings/mod.rs new file mode 100644 index 0000000000..414527815b --- /dev/null +++ b/core/notifications/src/settings/mod.rs @@ -0,0 +1 @@ +// mod entity; diff --git a/core/notifications/subgraph/schema.graphql b/core/notifications/subgraph/schema.graphql new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/es-entity-rs/BUCK b/lib/es-entity-rs/BUCK new file mode 100644 index 0000000000..ff2e51090b --- /dev/null +++ b/lib/es-entity-rs/BUCK @@ -0,0 +1,18 @@ +rust_library( + name = "es-entity", + edition = "2021", + deps = [ + "//third-party/rust:thiserror", + "//third-party/rust:derive_builder", + "//third-party/rust:serde_json", + "//third-party/rust:serde", + "//third-party/rust:sqlx", + "//third-party/rust:uuid", + ], + srcs = glob(["src/**/*.rs"]), + env = { + "CARGO_PKG_NAME": "es-entity" , + "CARGO_PKG_VERSION": "0.1.0" , + }, + visibility = ["PUBLIC"], +) diff --git a/lib/es-entity-rs/Cargo.toml b/lib/es-entity-rs/Cargo.toml new file mode 100644 index 0000000000..a911803e3d --- /dev/null +++ b/lib/es-entity-rs/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "es-entity" +version = "0.1.0" +edition = "2021" + +[features] + +fail-on-warnings = [] + +[dependencies] +thiserror = { workspace = true } +derive_builder = { workspace = true } +serde_json = { workspace = true } +serde = { workspace = true } +uuid = { workspace = true } +sqlx = { workspace = true } diff --git a/lib/es-entity-rs/src/error.rs b/lib/es-entity-rs/src/error.rs new file mode 100644 index 0000000000..4e5755ee0f --- /dev/null +++ b/lib/es-entity-rs/src/error.rs @@ -0,0 +1,9 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum EntityError { + #[error("EntityError - UninitializedFieldError: {0}")] + UninitializedFieldError(#[from] derive_builder::UninitializedFieldError), + #[error("EntityError - LoadEvent: {0}")] + LoadEvent(#[from] serde_json::Error), +} diff --git a/lib/es-entity-rs/src/events.rs b/lib/es-entity-rs/src/events.rs new file mode 100644 index 0000000000..0d4e4c7386 --- /dev/null +++ b/lib/es-entity-rs/src/events.rs @@ -0,0 +1,123 @@ +use serde::{de::DeserializeOwned, Serialize}; + +use super::error::EntityError; + +#[derive(sqlx::Type)] +pub struct GenericEvent { + pub id: uuid::Uuid, + pub sequence: i32, + pub event: serde_json::Value, +} + +pub trait EntityEvent: DeserializeOwned + Serialize { + type EntityId: Into + From + Copy; + + fn event_table_name() -> &'static str + where + Self: Sized; +} + +pub trait Entity: TryFrom::Event>, Error = EntityError> { + type Event: EntityEvent; +} + +pub struct EntityEvents { + entity_id: ::EntityId, + persisted_events: Vec, + new_events: Vec, +} + +impl EntityEvents +where + T: DeserializeOwned + Serialize + 'static + EntityEvent, +{ + pub fn init( + id: ::EntityId, + initial_events: impl IntoIterator, + ) -> Self { + Self { + entity_id: id, + persisted_events: Vec::new(), + new_events: initial_events.into_iter().collect(), + } + } + + pub async fn persist( + &mut self, + tx: &mut sqlx::Transaction<'_, sqlx::Postgres>, + ) -> Result { + let uuid: uuid::Uuid = self.entity_id.into(); + let mut events = Vec::new(); + std::mem::swap(&mut events, &mut self.new_events); + + let mut query_builder = sqlx::QueryBuilder::new(format!( + "INSERT INTO {} (id, sequence, event_type, event)", + ::event_table_name(), + )); + + let sequence = self.persisted_events.len() + 1; + let n_persisted = self.new_events.len(); + + query_builder.push_values(events.iter().enumerate(), |mut builder, (offset, event)| { + let event_json = serde_json::to_value(event).expect("Could not serialize event"); + let event_type = event_json + .get("type") + .and_then(serde_json::Value::as_str) + .expect("Could not get type") + .to_owned(); + builder.push_bind(uuid); + builder.push_bind((sequence + offset) as i32); + builder.push_bind(event_type); + builder.push_bind(event_json); + }); + let query = query_builder.build(); + query.execute(&mut **tx).await?; + + self.persisted_events.extend(events); + Ok(n_persisted) + } + + pub fn load_n>( + events: impl IntoIterator, + n: usize, + ) -> Result<(Vec, bool), EntityError> { + let mut ret: Vec = Vec::new(); + let mut current_id = None; + let mut current = None; + for e in events { + if current_id != Some(e.id) { + if let Some(current) = current.take() { + ret.push(E::try_from(current)?); + if ret.len() == n { + return Ok((ret, true)); + } + } + + current_id = Some(e.id); + current = Some(Self { + entity_id: e.id.into(), + persisted_events: Vec::new(), + new_events: Vec::new(), + }); + } + current + .as_mut() + .expect("Could not get current") + .persisted_events + .push(serde_json::from_value(e.event).expect("Could not deserialize event")); + } + if let Some(current) = current.take() { + ret.push(E::try_from(current)?); + } + Ok((ret, false)) + } + + pub fn iter(&self) -> impl DoubleEndedIterator { + self.persisted_events.iter().chain(self.new_events.iter()) + } + + pub fn last_persisted(&self, n: usize) -> impl Iterator { + let start = self.persisted_events.len() - n - 1; + self.persisted_events[start..].iter() + } +} diff --git a/core/api-keys/src/entity.rs b/lib/es-entity-rs/src/id.rs similarity index 87% rename from core/api-keys/src/entity.rs rename to lib/es-entity-rs/src/id.rs index daf63ce71c..ee5391d5c6 100644 --- a/core/api-keys/src/entity.rs +++ b/lib/es-entity-rs/src/id.rs @@ -2,6 +2,7 @@ macro_rules! entity_id { ($name:ident) => { #[derive( + sqlx::Type, Debug, Clone, Copy, @@ -10,7 +11,6 @@ macro_rules! entity_id { PartialOrd, Ord, Hash, - sqlx::Type, serde::Deserialize, serde::Serialize, )] @@ -18,8 +18,8 @@ macro_rules! entity_id { #[sqlx(transparent)] pub struct $name(uuid::Uuid); - #[allow(clippy::new_without_default)] impl $name { + #[allow(clippy::new_without_default)] pub fn new() -> Self { uuid::Uuid::new_v4().into() } @@ -37,6 +37,12 @@ macro_rules! entity_id { } } + impl From<&$name> for uuid::Uuid { + fn from(id: &$name) -> Self { + id.0 + } + } + impl std::fmt::Display for $name { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) diff --git a/lib/es-entity-rs/src/lib.rs b/lib/es-entity-rs/src/lib.rs new file mode 100644 index 0000000000..e34e07af6b --- /dev/null +++ b/lib/es-entity-rs/src/lib.rs @@ -0,0 +1,9 @@ +#![cfg_attr(feature = "fail-on-warnings", deny(warnings))] +#![cfg_attr(feature = "fail-on-warnings", deny(clippy::all))] + +mod error; +mod events; +mod id; + +pub use error::*; +pub use events::*; diff --git a/lib/es-entity-rs/src/main.rs b/lib/es-entity-rs/src/main.rs new file mode 100644 index 0000000000..e7a11a969c --- /dev/null +++ b/lib/es-entity-rs/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/third-party/rust/BUCK b/third-party/rust/BUCK index b6a0687cc1..86931eb821 100644 --- a/third-party/rust/BUCK +++ b/third-party/rust/BUCK @@ -1308,6 +1308,31 @@ cargo.rust_library( ], ) +http_archive( + name = "darling-0.14.4.crate", + sha256 = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850", + strip_prefix = "darling-0.14.4", + urls = ["https://crates.io/api/v1/crates/darling/0.14.4/download"], + visibility = [], +) + +cargo.rust_library( + name = "darling-0.14.4", + srcs = [":darling-0.14.4.crate"], + crate = "darling", + crate_root = "darling-0.14.4.crate/src/lib.rs", + edition = "2018", + features = [ + "default", + "suggestions", + ], + visibility = [], + deps = [ + ":darling_core-0.14.4", + ":darling_macro-0.14.4", + ], +) + http_archive( name = "darling-0.20.3.crate", sha256 = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e", @@ -1333,6 +1358,35 @@ cargo.rust_library( ], ) +http_archive( + name = "darling_core-0.14.4.crate", + sha256 = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0", + strip_prefix = "darling_core-0.14.4", + urls = ["https://crates.io/api/v1/crates/darling_core/0.14.4/download"], + visibility = [], +) + +cargo.rust_library( + name = "darling_core-0.14.4", + srcs = [":darling_core-0.14.4.crate"], + crate = "darling_core", + crate_root = "darling_core-0.14.4.crate/src/lib.rs", + edition = "2018", + features = [ + "strsim", + "suggestions", + ], + visibility = [], + deps = [ + ":fnv-1.0.7", + ":ident_case-1.0.1", + ":proc-macro2-1.0.76", + ":quote-1.0.35", + ":strsim-0.10.0", + ":syn-1.0.109", + ], +) + http_archive( name = "darling_core-0.20.3.crate", sha256 = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621", @@ -1362,6 +1416,29 @@ cargo.rust_library( ], ) +http_archive( + name = "darling_macro-0.14.4.crate", + sha256 = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e", + strip_prefix = "darling_macro-0.14.4", + urls = ["https://crates.io/api/v1/crates/darling_macro/0.14.4/download"], + visibility = [], +) + +cargo.rust_library( + name = "darling_macro-0.14.4", + srcs = [":darling_macro-0.14.4.crate"], + crate = "darling_macro", + crate_root = "darling_macro-0.14.4.crate/src/lib.rs", + edition = "2018", + proc_macro = True, + visibility = [], + deps = [ + ":darling_core-0.14.4", + ":quote-1.0.35", + ":syn-1.0.109", + ], +) + http_archive( name = "darling_macro-0.20.3.crate", sha256 = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5", @@ -1463,6 +1540,79 @@ cargo.rust_library( ], ) +alias( + name = "derive_builder", + actual = ":derive_builder-0.12.0", + visibility = ["PUBLIC"], +) + +http_archive( + name = "derive_builder-0.12.0.crate", + sha256 = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8", + strip_prefix = "derive_builder-0.12.0", + urls = ["https://crates.io/api/v1/crates/derive_builder/0.12.0/download"], + visibility = [], +) + +cargo.rust_library( + name = "derive_builder-0.12.0", + srcs = [":derive_builder-0.12.0.crate"], + crate = "derive_builder", + crate_root = "derive_builder-0.12.0.crate/src/lib.rs", + edition = "2015", + features = [ + "default", + "std", + ], + visibility = [], + deps = [":derive_builder_macro-0.12.0"], +) + +http_archive( + name = "derive_builder_core-0.12.0.crate", + sha256 = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f", + strip_prefix = "derive_builder_core-0.12.0", + urls = ["https://crates.io/api/v1/crates/derive_builder_core/0.12.0/download"], + visibility = [], +) + +cargo.rust_library( + name = "derive_builder_core-0.12.0", + srcs = [":derive_builder_core-0.12.0.crate"], + crate = "derive_builder_core", + crate_root = "derive_builder_core-0.12.0.crate/src/lib.rs", + edition = "2015", + visibility = [], + deps = [ + ":darling-0.14.4", + ":proc-macro2-1.0.76", + ":quote-1.0.35", + ":syn-1.0.109", + ], +) + +http_archive( + name = "derive_builder_macro-0.12.0.crate", + sha256 = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e", + strip_prefix = "derive_builder_macro-0.12.0", + urls = ["https://crates.io/api/v1/crates/derive_builder_macro/0.12.0/download"], + visibility = [], +) + +cargo.rust_library( + name = "derive_builder_macro-0.12.0", + srcs = [":derive_builder_macro-0.12.0.crate"], + crate = "derive_builder_macro", + crate_root = "derive_builder_macro-0.12.0.crate/src/lib.rs", + edition = "2015", + proc_macro = True, + visibility = [], + deps = [ + ":derive_builder_core-0.12.0", + ":syn-1.0.109", + ], +) + http_archive( name = "digest-0.10.7.crate", sha256 = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292", @@ -7064,6 +7214,7 @@ cargo.rust_binary( ":axum-0.6.20", ":chrono-0.4.31", ":clap-4.4.7", + ":derive_builder-0.12.0", ":http-0.2.9", ":jsonwebtoken-9.2.0", ":opentelemetry-0.20.0", diff --git a/third-party/rust/Cargo.lock b/third-party/rust/Cargo.lock index 58f22596e3..d8b4ccc777 100644 --- a/third-party/rust/Cargo.lock +++ b/third-party/rust/Cargo.lock @@ -183,7 +183,7 @@ checksum = "c7f329c7eb9b646a72f70c9c4b516c70867d356ec46cb00dcac8ad343fd006b0" dependencies = [ "Inflector", "async-graphql-parser", - "darling", + "darling 0.20.3", "proc-macro-crate", "proc-macro2", "quote", @@ -567,14 +567,38 @@ dependencies = [ "typenum", ] +[[package]] +name = "darling" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" +dependencies = [ + "darling_core 0.14.4", + "darling_macro 0.14.4", +] + [[package]] name = "darling" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.20.3", + "darling_macro 0.20.3", +] + +[[package]] +name = "darling_core" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 1.0.109", ] [[package]] @@ -591,13 +615,24 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "darling_macro" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" +dependencies = [ + "darling_core 0.14.4", + "quote", + "syn 1.0.109", +] + [[package]] name = "darling_macro" version = "0.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5" dependencies = [ - "darling_core", + "darling_core 0.20.3", "quote", "syn 2.0.48", ] @@ -629,6 +664,37 @@ dependencies = [ "serde", ] +[[package]] +name = "derive_builder" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +dependencies = [ + "darling 0.14.4", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_builder_macro" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +dependencies = [ + "derive_builder_core", + "syn 1.0.109", +] + [[package]] name = "digest" version = "0.10.7" @@ -2036,7 +2102,7 @@ version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93634eb5f75a2323b16de4748022ac4297f9e76b6dced2be287a099f41b5e788" dependencies = [ - "darling", + "darling 0.20.3", "proc-macro2", "quote", "syn 2.0.48", @@ -2517,6 +2583,7 @@ dependencies = [ "axum", "chrono", "clap", + "derive_builder", "http", "jsonwebtoken", "opentelemetry", diff --git a/third-party/rust/Cargo.toml b/third-party/rust/Cargo.toml index 8cb6f2c35e..8221066ca6 100644 --- a/third-party/rust/Cargo.toml +++ b/third-party/rust/Cargo.toml @@ -25,6 +25,7 @@ async-graphql-axum = "6.0.9" axum = { version = "0.6.20", features = ["headers", "macros"] } jsonwebtoken = "9.2.0" clap = { version = "4.4", features = ["derive", "env"] } +derive_builder = "0.12.0" tokio = { version = "1.33.0", features = ["full"] } serde = { version = "1.0.158", features = ["derive"] } reqwest = { version = "0.11.23", default-features = false, features = ["json", "rustls-tls"] }