diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 09946aed..439134fb 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -10,7 +10,7 @@ members = [ [workspace.package] rust-version = "1.83" authors = ["Andras Schmelczer "] -edition = "2022" +edition = "2024" license = "MIT" repository = "https://github.com/schmelczer/vault-link" version = "0.0.20" diff --git a/backend/reconcile/src/lib.rs b/backend/reconcile/src/lib.rs index 5ffc76c2..9c5bb764 100644 --- a/backend/reconcile/src/lib.rs +++ b/backend/reconcile/src/lib.rs @@ -3,5 +3,5 @@ mod operation_transformation; mod tokenizer; mod utils; -pub use operation_transformation::{reconcile, reconcile_with_tokenizer, EditedText}; +pub use operation_transformation::{EditedText, reconcile, reconcile_with_tokenizer}; pub use tokenizer::token::Token; diff --git a/backend/reconcile/src/operation_transformation/edited_text.rs b/backend/reconcile/src/operation_transformation/edited_text.rs index 7b710bb4..3e8162ab 100644 --- a/backend/reconcile/src/operation_transformation/edited_text.rs +++ b/backend/reconcile/src/operation_transformation/edited_text.rs @@ -7,7 +7,7 @@ use super::Operation; use crate::{ diffs::{myers::diff, raw_operation::RawOperation}, operation_transformation::merge_context::MergeContext, - tokenizer::{word_tokenizer::word_tokenizer, Tokenizer}, + tokenizer::{Tokenizer, word_tokenizer::word_tokenizer}, utils::{ merge_iters::MergeSorted as _, ordered_operation::OrderedOperation, side::Side, string_builder::StringBuilder, diff --git a/backend/reconcile/src/operation_transformation/operation.rs b/backend/reconcile/src/operation_transformation/operation.rs index e37e119e..c19265b5 100644 --- a/backend/reconcile/src/operation_transformation/operation.rs +++ b/backend/reconcile/src/operation_transformation/operation.rs @@ -8,8 +8,8 @@ use serde::{Deserialize, Serialize}; use super::merge_context::MergeContext; use crate::{ - utils::{find_common_overlap::find_common_overlap, string_builder::StringBuilder}, Token, + utils::{find_common_overlap::find_common_overlap, string_builder::StringBuilder}, }; /// Represents a change that can be applied to a text document. @@ -355,9 +355,11 @@ mod tests { #[test] #[should_panic] fn test_shifting_error() { - insta::assert_debug_snapshot!(Operation::create_insert(1, vec!["hi".into()]) - .unwrap() - .with_shifted_index(-2)); + insta::assert_debug_snapshot!( + Operation::create_insert(1, vec!["hi".into()]) + .unwrap() + .with_shifted_index(-2) + ); } #[test] diff --git a/backend/reconcile/src/utils/find_common_overlap.rs b/backend/reconcile/src/utils/find_common_overlap.rs index ac586b81..80616952 100644 --- a/backend/reconcile/src/utils/find_common_overlap.rs +++ b/backend/reconcile/src/utils/find_common_overlap.rs @@ -40,26 +40,29 @@ mod tests { assert_eq!(find_common_overlap(&["".into()], &["".into()]), 0); assert_eq!( - find_common_overlap( - &["a".into(), "b".into(), "c".into()], - &["b".into(), "c".into(), "a".into()] - ), + find_common_overlap(&["a".into(), "b".into(), "c".into()], &[ + "b".into(), + "c".into(), + "a".into() + ]), 1 ); assert_eq!( - find_common_overlap( - &["a".into(), "a".into(), "a".into()], - &["a".into(), "b".into(), "c".into()] - ), + find_common_overlap(&["a".into(), "a".into(), "a".into()], &[ + "a".into(), + "b".into(), + "c".into() + ]), 2 ); assert_eq!( - find_common_overlap( - &["a".into(), "b".into(), "c".into()], - &["d".into(), "e".into(), "a".into()] - ), + find_common_overlap(&["a".into(), "b".into(), "c".into()], &[ + "d".into(), + "e".into(), + "a".into() + ]), 3 ); diff --git a/backend/sync_lib/src/lib.rs b/backend/sync_lib/src/lib.rs index d5e6c1d2..164939ac 100644 --- a/backend/sync_lib/src/lib.rs +++ b/backend/sync_lib/src/lib.rs @@ -10,7 +10,7 @@ //! - `errors`: Contains error types used in this crate. use core::str; -use base64::{engine::general_purpose::STANDARD, Engine as _}; +use base64::{Engine as _, engine::general_purpose::STANDARD}; use errors::SyncLibError; use wasm_bindgen::prelude::*; diff --git a/backend/sync_server/src/config/user_config.rs b/backend/sync_server/src/config/user_config.rs index bb7d8e54..c3afca14 100644 --- a/backend/sync_server/src/config/user_config.rs +++ b/backend/sync_server/src/config/user_config.rs @@ -1,4 +1,4 @@ -use rand::{distributions::Alphanumeric, thread_rng, Rng as _}; +use rand::{Rng as _, distributions::Alphanumeric, thread_rng}; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize, Clone)] diff --git a/backend/sync_server/src/database.rs b/backend/sync_server/src/database.rs index 4c638faf..52305629 100644 --- a/backend/sync_server/src/database.rs +++ b/backend/sync_server/src/database.rs @@ -6,7 +6,7 @@ use models::{ }; use sqlx::{sqlite::SqliteConnectOptions, types::chrono::Utc}; pub mod models; -use sqlx::{sqlite::SqlitePoolOptions, Pool, Sqlite}; +use sqlx::{Pool, Sqlite, sqlite::SqlitePoolOptions}; use crate::config::database_config::DatabaseConfig; diff --git a/backend/sync_server/src/errors.rs b/backend/sync_server/src/errors.rs index d66f25bd..aa109c82 100644 --- a/backend/sync_server/src/errors.rs +++ b/backend/sync_server/src/errors.rs @@ -1,8 +1,8 @@ use aide::OperationOutput; use axum::{ + Json, http::StatusCode, response::{IntoResponse, Response}, - Json, }; use log::{error, info}; use schemars::JsonSchema; diff --git a/backend/sync_server/src/main.rs b/backend/sync_server/src/main.rs index 02e4104b..61f6f2af 100644 --- a/backend/sync_server/src/main.rs +++ b/backend/sync_server/src/main.rs @@ -6,7 +6,7 @@ mod server; mod utils; use anyhow::{Context as _, Result}; -use errors::{init_error, SyncServerError}; +use errors::{SyncServerError, init_error}; use log::info; use server::create_server; use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt}; diff --git a/backend/sync_server/src/server/auth.rs b/backend/sync_server/src/server/auth.rs index 3e936097..9c73070c 100644 --- a/backend/sync_server/src/server/auth.rs +++ b/backend/sync_server/src/server/auth.rs @@ -1,7 +1,7 @@ use super::app_state::AppState; use crate::{ config::user_config::User, - errors::{unauthorized_error, SyncServerError}, + errors::{SyncServerError, unauthorized_error}, }; pub fn auth(app_state: &AppState, token: &str) -> Result { diff --git a/backend/sync_server/src/server/delete_document.rs b/backend/sync_server/src/server/delete_document.rs index 83fcda83..a9d307b5 100644 --- a/backend/sync_server/src/server/delete_document.rs +++ b/backend/sync_server/src/server/delete_document.rs @@ -1,19 +1,17 @@ use anyhow::Context as _; -use axum::{ - extract::{Path, State}, - Json, -}; +use axum::extract::{Path, State}; use axum_extra::{ - headers::{authorization::Bearer, Authorization}, TypedHeader, + headers::{Authorization, authorization::Bearer}, }; +use axum_jsonschema::Json; use schemars::JsonSchema; use serde::Deserialize; use super::{app_state::AppState, auth::auth, requests::DeleteDocumentVersion}; use crate::{ database::models::{DocumentId, StoredDocumentVersion, VaultId}, - errors::{server_error, SyncServerError}, + errors::{SyncServerError, server_error}, utils::sanitize_path, }; diff --git a/backend/sync_server/src/server/fetch_latest_document_version.rs b/backend/sync_server/src/server/fetch_latest_document_version.rs index 47c4514e..a53f2703 100644 --- a/backend/sync_server/src/server/fetch_latest_document_version.rs +++ b/backend/sync_server/src/server/fetch_latest_document_version.rs @@ -1,19 +1,17 @@ use anyhow::anyhow; -use axum::{ - extract::{Path, State}, - Json, -}; +use axum::extract::{Path, State}; use axum_extra::{ - headers::{authorization::Bearer, Authorization}, TypedHeader, + headers::{Authorization, authorization::Bearer}, }; +use axum_jsonschema::Json; use schemars::JsonSchema; use serde::Deserialize; use super::{app_state::AppState, auth::auth}; use crate::{ database::models::{DocumentId, DocumentVersion, VaultId}, - errors::{not_found_error, server_error, SyncServerError}, + errors::{SyncServerError, not_found_error, server_error}, }; // This is required for aide to infer the path parameter types and names diff --git a/backend/sync_server/src/server/fetch_latest_documents.rs b/backend/sync_server/src/server/fetch_latest_documents.rs index f0181173..b19c3dec 100644 --- a/backend/sync_server/src/server/fetch_latest_documents.rs +++ b/backend/sync_server/src/server/fetch_latest_documents.rs @@ -1,18 +1,16 @@ -use axum::{ - extract::{Path, Query, State}, - Json, -}; +use axum::extract::{Path, Query, State}; use axum_extra::{ - headers::{authorization::Bearer, Authorization}, TypedHeader, + headers::{Authorization, authorization::Bearer}, }; +use axum_jsonschema::Json; use schemars::JsonSchema; use serde::Deserialize; use super::{app_state::AppState, auth::auth, responses::FetchLatestDocumentsResponse}; use crate::{ database::models::{VaultId, VaultUpdateId}, - errors::{server_error, SyncServerError}, + errors::{SyncServerError, server_error}, }; // This is required for aide to infer the path parameter types and names diff --git a/backend/sync_server/src/server/ping.rs b/backend/sync_server/src/server/ping.rs index 3ffd2cf7..1823c9f9 100644 --- a/backend/sync_server/src/server/ping.rs +++ b/backend/sync_server/src/server/ping.rs @@ -1,7 +1,7 @@ -use axum::{extract::State, Json}; +use axum::{Json, extract::State}; use axum_extra::{ - headers::{authorization::Bearer, Authorization}, TypedHeader, + headers::{Authorization, authorization::Bearer}, }; use super::{app_state::AppState, auth::auth, responses::PingResponse};