From 19787a3f51aca28d71552dd020a2bad34369c0b2 Mon Sep 17 00:00:00 2001 From: Jai Agrawal <18202329+Geometrically@users.noreply.github.com> Date: Sat, 1 Mar 2025 20:53:43 -0800 Subject: [PATCH] Subpackage common -> ariadne (#3323) * Subpackage common -> ariadne * add common * Remove build * only build labrinth * common * set sqlx offline * copy dirs * Fix build --- .github/workflows/labrinth-docker.yml | 4 +++- .idea/code.iml | 3 ++- Cargo.lock | 18 ++++++++++++++++- Cargo.toml | 1 + apps/labrinth/Cargo.toml | 2 ++ apps/labrinth/Dockerfile | 8 +++++--- apps/labrinth/src/auth/mod.rs | 2 +- apps/labrinth/src/auth/oauth/errors.rs | 2 +- apps/labrinth/src/database/models/ids.rs | 4 ++-- .../src/database/models/organization_item.rs | 2 +- apps/labrinth/src/database/models/pat_item.rs | 2 +- .../src/database/models/project_item.rs | 2 +- .../src/database/models/session_item.rs | 2 +- .../labrinth/src/database/models/user_item.rs | 2 +- apps/labrinth/src/database/redis.rs | 2 +- apps/labrinth/src/lib.rs | 8 ++------ apps/labrinth/src/models/v3/ids.rs | 6 +++--- apps/labrinth/src/models/v3/users.rs | 2 +- apps/labrinth/src/routes/internal/admin.rs | 9 ++++----- apps/labrinth/src/routes/internal/billing.rs | 2 +- apps/labrinth/src/routes/internal/flows.rs | 4 ++-- .../src/routes/internal/moderation.rs | 2 +- apps/labrinth/src/routes/internal/statuses.rs | 10 +++++----- apps/labrinth/src/routes/maven.rs | 2 +- apps/labrinth/src/routes/mod.rs | 2 +- apps/labrinth/src/routes/v3/analytics_get.rs | 2 +- apps/labrinth/src/routes/v3/collections.rs | 2 +- apps/labrinth/src/routes/v3/friends.rs | 2 +- apps/labrinth/src/routes/v3/oauth_clients.rs | 2 +- apps/labrinth/src/routes/v3/organizations.rs | 2 +- .../src/routes/v3/project_creation.rs | 2 +- apps/labrinth/src/routes/v3/projects.rs | 2 +- apps/labrinth/src/routes/v3/reports.rs | 2 +- apps/labrinth/src/routes/v3/versions.rs | 2 +- apps/labrinth/src/search/indexing/mod.rs | 2 +- apps/labrinth/src/util/webhook.rs | 2 +- apps/labrinth/tests/analytics.rs | 2 +- .../tests/common/api_common/generic.rs | 16 +++++++-------- .../tests/common/api_common/request_data.rs | 2 +- apps/labrinth/tests/common/api_v2/project.rs | 2 +- .../tests/common/api_v2/request_data.rs | 2 +- apps/labrinth/tests/common/api_v2/user.rs | 2 +- .../tests/common/api_v3/request_data.rs | 2 +- apps/labrinth/tests/common/api_v3/user.rs | 2 +- apps/labrinth/tests/common/asserts.rs | 2 +- apps/labrinth/tests/common/database.rs | 2 +- apps/labrinth/tests/common/permissions.rs | 2 +- apps/labrinth/tests/loader_fields.rs | 10 ++++------ apps/labrinth/tests/notifications.rs | 2 +- apps/labrinth/tests/organizations.rs | 4 ++-- apps/labrinth/tests/pats.rs | 2 +- apps/labrinth/tests/project.rs | 10 +++++----- apps/labrinth/tests/scopes.rs | 12 +++++------ apps/labrinth/tests/search.rs | 2 +- apps/labrinth/tests/tags.rs | 2 +- apps/labrinth/tests/teams.rs | 2 +- apps/labrinth/tests/user.rs | 2 +- apps/labrinth/tests/v2/error.rs | 6 +++--- apps/labrinth/tests/v2/notifications.rs | 2 +- apps/labrinth/tests/v2/project.rs | 2 +- apps/labrinth/tests/v2/scopes.rs | 18 ++++++++--------- apps/labrinth/tests/v2/search.rs | 20 +++++++++---------- apps/labrinth/tests/v2/tags.rs | 2 +- apps/labrinth/tests/v2/version.rs | 12 +++++------ apps/labrinth/tests/version.rs | 12 +++++------ packages/app-lib/Cargo.toml | 2 +- packages/app-lib/src/api/friends.rs | 2 +- packages/app-lib/src/api/mod.rs | 2 +- packages/app-lib/src/error.rs | 2 +- packages/app-lib/src/event/mod.rs | 2 +- packages/app-lib/src/state/friends.rs | 8 ++++---- packages/app-lib/src/state/tunnel.rs | 2 +- packages/ariadne/Cargo.toml | 15 ++++++++++++++ .../common => packages/ariadne/src}/ids.rs | 8 +++----- .../mod.rs => packages/ariadne/src/lib.rs | 0 packages/ariadne/src/mod.rs | 3 +++ .../ariadne/src}/networking/message.rs | 4 ++-- .../ariadne/src}/networking/mod.rs | 0 .../ariadne/src}/networking/serialization.rs | 0 .../common => packages/ariadne/src}/users.rs | 0 80 files changed, 181 insertions(+), 152 deletions(-) create mode 100644 packages/ariadne/Cargo.toml rename {apps/labrinth/src/common => packages/ariadne/src}/ids.rs (96%) rename apps/labrinth/src/common/mod.rs => packages/ariadne/src/lib.rs (100%) create mode 100644 packages/ariadne/src/mod.rs rename {apps/labrinth/src/common => packages/ariadne/src}/networking/message.rs (94%) rename {apps/labrinth/src/common => packages/ariadne/src}/networking/mod.rs (100%) rename {apps/labrinth/src/common => packages/ariadne/src}/networking/serialization.rs (100%) rename {apps/labrinth/src/common => packages/ariadne/src}/users.rs (100%) diff --git a/.github/workflows/labrinth-docker.yml b/.github/workflows/labrinth-docker.yml index 6f408025..1ed8e968 100644 --- a/.github/workflows/labrinth-docker.yml +++ b/.github/workflows/labrinth-docker.yml @@ -38,8 +38,10 @@ jobs: - name: Build and push id: docker_build uses: docker/build-push-action@v2 + env: + SQLX_OFFLINE: true with: - context: ./apps/labrinth + file: ./apps/labrinth/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.docker_meta.outputs.tags }} labels: ${{ steps.docker_meta.outputs.labels }} diff --git a/.idea/code.iml b/.idea/code.iml index 5fda4410..a4489bea 100644 --- a/.idea/code.iml +++ b/.idea/code.iml @@ -11,9 +11,10 @@ + - + \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index a3923eb1..fdce2942 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -426,6 +426,21 @@ dependencies = [ "password-hash 0.5.0", ] +[[package]] +name = "ariadne" +version = "0.1.0" +dependencies = [ + "chrono", + "either", + "rand 0.8.5", + "serde", + "serde_bytes", + "serde_cbor", + "serde_json", + "thiserror 1.0.64", + "uuid 1.12.0", +] + [[package]] name = "arrayvec" version = "0.7.6" @@ -4238,6 +4253,7 @@ dependencies = [ "actix-web-prom", "actix-ws", "argon2", + "ariadne", "async-stripe", "async-trait", "base64 0.21.7", @@ -8900,6 +8916,7 @@ dependencies = [ name = "theseus" version = "0.9.3" dependencies = [ + "ariadne", "async-recursion", "async-tungstenite", "async_zip", @@ -8916,7 +8933,6 @@ dependencies = [ "flate2", "futures 0.3.30", "indicatif", - "labrinth", "lazy_static", "notify", "notify-debouncer-mini", diff --git a/Cargo.toml b/Cargo.toml index 9afcf86c..97d69a24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ members = [ './apps/labrinth', './apps/daedalus_client', './packages/daedalus', + './packages/ariadne', ] # Optimize for speed and reduce size on release builds diff --git a/apps/labrinth/Cargo.toml b/apps/labrinth/Cargo.toml index 7ae09784..e4915fec 100644 --- a/apps/labrinth/Cargo.toml +++ b/apps/labrinth/Cargo.toml @@ -127,6 +127,8 @@ async-stripe = { version = "0.39.1", features = ["runtime-tokio-hyper-rustls"] } rusty-money = "0.4.1" json-patch = "*" +ariadne = { path = "../../packages/ariadne" } + [dev-dependencies] actix-http = "3.4.0" diff --git a/apps/labrinth/Dockerfile b/apps/labrinth/Dockerfile index 851579f7..8c046449 100644 --- a/apps/labrinth/Dockerfile +++ b/apps/labrinth/Dockerfile @@ -3,7 +3,9 @@ ENV PKG_CONFIG_ALLOW_CROSS=1 WORKDIR /usr/src/labrinth COPY . . -RUN cargo build --release +ENV SQLX_OFFLINE=true +COPY apps/labrinth/.sqlx/ .sqlx/ +RUN cargo build --release --package labrinth FROM debian:bookworm-slim @@ -20,8 +22,8 @@ RUN apt-get update \ RUN update-ca-certificates COPY --from=build /usr/src/labrinth/target/release/labrinth /labrinth/labrinth -COPY --from=build /usr/src/labrinth/migrations/* /labrinth/migrations/ -COPY --from=build /usr/src/labrinth/assets /labrinth/assets +COPY --from=build /usr/src/labrinth/apps/labrinth/migrations/* /labrinth/migrations/ +COPY --from=build /usr/src/labrinth/apps/labrinth/assets /labrinth/assets WORKDIR /labrinth CMD /labrinth/labrinth \ No newline at end of file diff --git a/apps/labrinth/src/auth/mod.rs b/apps/labrinth/src/auth/mod.rs index 9a8a29c0..9b969caa 100644 --- a/apps/labrinth/src/auth/mod.rs +++ b/apps/labrinth/src/auth/mod.rs @@ -34,7 +34,7 @@ pub enum AuthenticationError { #[error("Error uploading user profile picture")] FileHosting(#[from] FileHostingError), #[error("Error while decoding PAT: {0}")] - Decoding(#[from] crate::common::ids::DecodingError), + Decoding(#[from] ariadne::ids::DecodingError), #[error("{0}")] Mail(#[from] email::MailError), #[error("Invalid Authentication Credentials")] diff --git a/apps/labrinth/src/auth/oauth/errors.rs b/apps/labrinth/src/auth/oauth/errors.rs index bc2c66cb..af1d253e 100644 --- a/apps/labrinth/src/auth/oauth/errors.rs +++ b/apps/labrinth/src/auth/oauth/errors.rs @@ -1,9 +1,9 @@ use super::ValidatedRedirectUri; use crate::auth::AuthenticationError; -use crate::common::ids::DecodingError; use crate::models::error::ApiError; use actix_web::http::{header::LOCATION, StatusCode}; use actix_web::HttpResponse; +use ariadne::ids::DecodingError; #[derive(thiserror::Error, Debug)] #[error("{}", .error_type)] diff --git a/apps/labrinth/src/database/models/ids.rs b/apps/labrinth/src/database/models/ids.rs index b7f33872..9c730a71 100644 --- a/apps/labrinth/src/database/models/ids.rs +++ b/apps/labrinth/src/database/models/ids.rs @@ -1,6 +1,6 @@ use super::DatabaseError; -use crate::common::ids::base62_impl::to_base62; -use crate::common::ids::{random_base62_rng, random_base62_rng_range}; +use ariadne::ids::base62_impl::to_base62; +use ariadne::ids::{random_base62_rng, random_base62_rng_range}; use censor::Censor; use rand::SeedableRng; use rand_chacha::ChaCha20Rng; diff --git a/apps/labrinth/src/database/models/organization_item.rs b/apps/labrinth/src/database/models/organization_item.rs index 51a9c8c0..32c779f5 100644 --- a/apps/labrinth/src/database/models/organization_item.rs +++ b/apps/labrinth/src/database/models/organization_item.rs @@ -1,5 +1,5 @@ -use crate::common::ids::base62_impl::parse_base62; use crate::database::redis::RedisPool; +use ariadne::ids::base62_impl::parse_base62; use dashmap::DashMap; use futures::TryStreamExt; use std::fmt::{Debug, Display}; diff --git a/apps/labrinth/src/database/models/pat_item.rs b/apps/labrinth/src/database/models/pat_item.rs index 2ae53666..f389cce9 100644 --- a/apps/labrinth/src/database/models/pat_item.rs +++ b/apps/labrinth/src/database/models/pat_item.rs @@ -1,8 +1,8 @@ use super::ids::*; -use crate::common::ids::base62_impl::parse_base62; use crate::database::models::DatabaseError; use crate::database::redis::RedisPool; use crate::models::pats::Scopes; +use ariadne::ids::base62_impl::parse_base62; use chrono::{DateTime, Utc}; use dashmap::DashMap; use futures::TryStreamExt; diff --git a/apps/labrinth/src/database/models/project_item.rs b/apps/labrinth/src/database/models/project_item.rs index 2a40b686..e2ca2522 100644 --- a/apps/labrinth/src/database/models/project_item.rs +++ b/apps/labrinth/src/database/models/project_item.rs @@ -3,11 +3,11 @@ use super::loader_fields::{ VersionField, }; use super::{ids::*, User}; -use crate::common::ids::base62_impl::parse_base62; use crate::database::models; use crate::database::models::DatabaseError; use crate::database::redis::RedisPool; use crate::models::projects::{MonetizationStatus, ProjectStatus}; +use ariadne::ids::base62_impl::parse_base62; use chrono::{DateTime, Utc}; use dashmap::{DashMap, DashSet}; use futures::TryStreamExt; diff --git a/apps/labrinth/src/database/models/session_item.rs b/apps/labrinth/src/database/models/session_item.rs index 4717c2a8..57fd42ce 100644 --- a/apps/labrinth/src/database/models/session_item.rs +++ b/apps/labrinth/src/database/models/session_item.rs @@ -1,7 +1,7 @@ use super::ids::*; -use crate::common::ids::base62_impl::parse_base62; use crate::database::models::DatabaseError; use crate::database::redis::RedisPool; +use ariadne::ids::base62_impl::parse_base62; use chrono::{DateTime, Utc}; use dashmap::DashMap; use serde::{Deserialize, Serialize}; diff --git a/apps/labrinth/src/database/models/user_item.rs b/apps/labrinth/src/database/models/user_item.rs index 09f01759..a231c2c6 100644 --- a/apps/labrinth/src/database/models/user_item.rs +++ b/apps/labrinth/src/database/models/user_item.rs @@ -1,10 +1,10 @@ use super::ids::{ProjectId, UserId}; use super::{CollectionId, ReportId, ThreadId}; -use crate::common::ids::base62_impl::{parse_base62, to_base62}; use crate::database::models; use crate::database::models::{DatabaseError, OrganizationId}; use crate::database::redis::RedisPool; use crate::models::users::Badges; +use ariadne::ids::base62_impl::{parse_base62, to_base62}; use chrono::{DateTime, Utc}; use dashmap::DashMap; use serde::{Deserialize, Serialize}; diff --git a/apps/labrinth/src/database/redis.rs b/apps/labrinth/src/database/redis.rs index b28317fc..fa77707e 100644 --- a/apps/labrinth/src/database/redis.rs +++ b/apps/labrinth/src/database/redis.rs @@ -1,5 +1,5 @@ use super::models::DatabaseError; -use crate::common::ids::base62_impl::{parse_base62, to_base62}; +use ariadne::ids::base62_impl::{parse_base62, to_base62}; use chrono::{TimeZone, Utc}; use dashmap::DashMap; use deadpool_redis::{Config, Runtime}; diff --git a/apps/labrinth/src/lib.rs b/apps/labrinth/src/lib.rs index 9856cfb1..2e4b6cf0 100644 --- a/apps/labrinth/src/lib.rs +++ b/apps/labrinth/src/lib.rs @@ -25,8 +25,6 @@ use crate::{ util::env::{parse_strings_from_var, parse_var}, }; -pub mod common; - pub mod auth; pub mod clickhouse; pub mod database; @@ -299,10 +297,8 @@ pub fn app_setup( } let ip_salt = Pepper { - pepper: crate::common::ids::Base62Id( - crate::common::ids::random_base62(11), - ) - .to_string(), + pepper: ariadne::ids::Base62Id(ariadne::ids::random_base62(11)) + .to_string(), }; let payouts_queue = web::Data::new(PayoutsQueue::new()); diff --git a/apps/labrinth/src/models/v3/ids.rs b/apps/labrinth/src/models/v3/ids.rs index 3d8a8cfd..033bfdc0 100644 --- a/apps/labrinth/src/models/v3/ids.rs +++ b/apps/labrinth/src/models/v3/ids.rs @@ -12,12 +12,12 @@ pub use super::sessions::SessionId; pub use super::teams::TeamId; pub use super::threads::ThreadId; pub use super::threads::ThreadMessageId; -pub use super::users::UserId; -use crate::common::ids::base62_id_impl; -pub use crate::common::ids::Base62Id; pub use crate::models::billing::{ ChargeId, ProductId, ProductPriceId, UserSubscriptionId, }; +use ariadne::ids::base62_id_impl; +pub use ariadne::ids::Base62Id; +pub use ariadne::users::UserId; base62_id_impl!(ProjectId, ProjectId); base62_id_impl!(VersionId, VersionId); diff --git a/apps/labrinth/src/models/v3/users.rs b/apps/labrinth/src/models/v3/users.rs index 8e9427dd..0c44fa09 100644 --- a/apps/labrinth/src/models/v3/users.rs +++ b/apps/labrinth/src/models/v3/users.rs @@ -1,5 +1,5 @@ -pub use crate::common::users::{UserId, UserStatus}; use crate::{auth::AuthProvider, bitflags_serde_impl}; +pub use ariadne::users::{UserId, UserStatus}; use chrono::{DateTime, Utc}; use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; diff --git a/apps/labrinth/src/routes/internal/admin.rs b/apps/labrinth/src/routes/internal/admin.rs index 62562ab1..cf7f8a10 100644 --- a/apps/labrinth/src/routes/internal/admin.rs +++ b/apps/labrinth/src/routes/internal/admin.rs @@ -74,11 +74,10 @@ pub async fn count_download( let project_id: crate::database::models::ids::ProjectId = download_body.project_id.into(); - let id_option = crate::common::ids::base62_impl::parse_base62( - &download_body.version_name, - ) - .ok() - .map(|x| x as i64); + let id_option = + ariadne::ids::base62_impl::parse_base62(&download_body.version_name) + .ok() + .map(|x| x as i64); let (version_id, project_id) = if let Some(version) = sqlx::query!( " diff --git a/apps/labrinth/src/routes/internal/billing.rs b/apps/labrinth/src/routes/internal/billing.rs index 380533cd..28c9954c 100644 --- a/apps/labrinth/src/routes/internal/billing.rs +++ b/apps/labrinth/src/routes/internal/billing.rs @@ -1,5 +1,4 @@ use crate::auth::{get_user_from_headers, send_email}; -use crate::common::ids::base62_impl::{parse_base62, to_base62}; use crate::database::models::charge_item::ChargeItem; use crate::database::models::{ generate_charge_id, generate_user_subscription_id, product_item, @@ -16,6 +15,7 @@ use crate::models::users::Badges; use crate::queue::session::AuthQueue; use crate::routes::ApiError; use actix_web::{delete, get, patch, post, web, HttpRequest, HttpResponse}; +use ariadne::ids::base62_impl::{parse_base62, to_base62}; use chrono::Utc; use log::{info, warn}; use rust_decimal::prelude::ToPrimitive; diff --git a/apps/labrinth/src/routes/internal/flows.rs b/apps/labrinth/src/routes/internal/flows.rs index 5d20b6c8..31e3c620 100644 --- a/apps/labrinth/src/routes/internal/flows.rs +++ b/apps/labrinth/src/routes/internal/flows.rs @@ -1,8 +1,6 @@ use crate::auth::email::send_email; use crate::auth::validate::get_user_record_from_bearer_token; use crate::auth::{get_user_from_headers, AuthProvider, AuthenticationError}; -use crate::common::ids::base62_impl::{parse_base62, to_base62}; -use crate::common::ids::random_base62_rng; use crate::database::models::flow_item::Flow; use crate::database::redis::RedisPool; use crate::file_hosting::FileHost; @@ -20,6 +18,8 @@ use actix_web::web::{scope, Data, Query, ServiceConfig}; use actix_web::{delete, get, patch, post, web, HttpRequest, HttpResponse}; use argon2::password_hash::SaltString; use argon2::{Argon2, PasswordHash, PasswordHasher, PasswordVerifier}; +use ariadne::ids::base62_impl::{parse_base62, to_base62}; +use ariadne::ids::random_base62_rng; use base64::Engine; use chrono::{Duration, Utc}; use rand_chacha::rand_core::SeedableRng; diff --git a/apps/labrinth/src/routes/internal/moderation.rs b/apps/labrinth/src/routes/internal/moderation.rs index 28f604e3..06654100 100644 --- a/apps/labrinth/src/routes/internal/moderation.rs +++ b/apps/labrinth/src/routes/internal/moderation.rs @@ -1,5 +1,4 @@ use super::ApiError; -use crate::common::ids::random_base62; use crate::database; use crate::database::redis::RedisPool; use crate::models::projects::ProjectStatus; @@ -7,6 +6,7 @@ use crate::queue::moderation::{ApprovalType, IdentifiedFile, MissingMetadata}; use crate::queue::session::AuthQueue; use crate::{auth::check_is_moderator_from_headers, models::pats::Scopes}; use actix_web::{web, HttpRequest, HttpResponse}; +use ariadne::ids::random_base62; use serde::Deserialize; use sqlx::PgPool; use std::collections::HashMap; diff --git a/apps/labrinth/src/routes/internal/statuses.rs b/apps/labrinth/src/routes/internal/statuses.rs index c531c5c7..5054ad67 100644 --- a/apps/labrinth/src/routes/internal/statuses.rs +++ b/apps/labrinth/src/routes/internal/statuses.rs @@ -1,10 +1,5 @@ use crate::auth::validate::get_user_record_from_bearer_token; use crate::auth::AuthenticationError; -use crate::common::ids::UserId; -use crate::common::networking::message::{ - ClientToServerMessage, ServerToClientMessage, -}; -use crate::common::users::UserStatus; use crate::database::models::friend_item::FriendItem; use crate::database::redis::RedisPool; use crate::models::pats::Scopes; @@ -17,6 +12,11 @@ use crate::routes::ApiError; use actix_web::web::{Data, Payload}; use actix_web::{get, web, HttpRequest, HttpResponse}; use actix_ws::Message; +use ariadne::ids::UserId; +use ariadne::networking::message::{ + ClientToServerMessage, ServerToClientMessage, +}; +use ariadne::users::UserStatus; use chrono::Utc; use either::Either; use futures_util::{StreamExt, TryStreamExt}; diff --git a/apps/labrinth/src/routes/maven.rs b/apps/labrinth/src/routes/maven.rs index e53ec6a3..bf024784 100644 --- a/apps/labrinth/src/routes/maven.rs +++ b/apps/labrinth/src/routes/maven.rs @@ -164,7 +164,7 @@ async fn find_version( pool: &PgPool, redis: &RedisPool, ) -> Result, ApiError> { - let id_option = crate::common::ids::base62_impl::parse_base62(vcoords) + let id_option = ariadne::ids::base62_impl::parse_base62(vcoords) .ok() .map(|x| x as i64); diff --git a/apps/labrinth/src/routes/mod.rs b/apps/labrinth/src/routes/mod.rs index 504b1970..c2a990fa 100644 --- a/apps/labrinth/src/routes/mod.rs +++ b/apps/labrinth/src/routes/mod.rs @@ -117,7 +117,7 @@ pub enum ApiError { #[error("Captcha Error. Try resubmitting the form.")] Turnstile, #[error("Error while decoding Base62: {0}")] - Decoding(#[from] crate::common::ids::DecodingError), + Decoding(#[from] ariadne::ids::DecodingError), #[error("Image Parsing Error: {0}")] ImageParse(#[from] image::ImageError), #[error("Password Hashing Error: {0}")] diff --git a/apps/labrinth/src/routes/v3/analytics_get.rs b/apps/labrinth/src/routes/v3/analytics_get.rs index 8d609574..85a3de60 100644 --- a/apps/labrinth/src/routes/v3/analytics_get.rs +++ b/apps/labrinth/src/routes/v3/analytics_get.rs @@ -1,5 +1,4 @@ use super::ApiError; -use crate::common::ids::base62_impl::to_base62; use crate::database; use crate::database::redis::RedisPool; use crate::models::teams::ProjectPermissions; @@ -13,6 +12,7 @@ use crate::{ queue::session::AuthQueue, }; use actix_web::{web, HttpRequest, HttpResponse}; +use ariadne::ids::base62_impl::to_base62; use chrono::{DateTime, Duration, Utc}; use serde::{Deserialize, Serialize}; use sqlx::postgres::types::PgInterval; diff --git a/apps/labrinth/src/routes/v3/collections.rs b/apps/labrinth/src/routes/v3/collections.rs index 0e9ad7d9..0d6a0c31 100644 --- a/apps/labrinth/src/routes/v3/collections.rs +++ b/apps/labrinth/src/routes/v3/collections.rs @@ -1,6 +1,5 @@ use crate::auth::checks::is_visible_collection; use crate::auth::{filter_visible_collections, get_user_from_headers}; -use crate::common::ids::base62_impl::parse_base62; use crate::database::models::{ collection_item, generate_collection_id, project_item, }; @@ -18,6 +17,7 @@ use crate::util::validate::validation_errors_to_string; use crate::{database, models}; use actix_web::web::Data; use actix_web::{web, HttpRequest, HttpResponse}; +use ariadne::ids::base62_impl::parse_base62; use chrono::Utc; use itertools::Itertools; use serde::{Deserialize, Serialize}; diff --git a/apps/labrinth/src/routes/v3/friends.rs b/apps/labrinth/src/routes/v3/friends.rs index dc4bff0f..1f745323 100644 --- a/apps/labrinth/src/routes/v3/friends.rs +++ b/apps/labrinth/src/routes/v3/friends.rs @@ -1,5 +1,4 @@ use crate::auth::get_user_from_headers; -use crate::common::networking::message::ServerToClientMessage; use crate::database::models::UserId; use crate::database::redis::RedisPool; use crate::models::pats::Scopes; @@ -9,6 +8,7 @@ use crate::queue::socket::ActiveSockets; use crate::routes::internal::statuses::send_message_to_user; use crate::routes::ApiError; use actix_web::{delete, get, post, web, HttpRequest, HttpResponse}; +use ariadne::networking::message::ServerToClientMessage; use chrono::Utc; use sqlx::PgPool; diff --git a/apps/labrinth/src/routes/v3/oauth_clients.rs b/apps/labrinth/src/routes/v3/oauth_clients.rs index 9ba574d9..b196b510 100644 --- a/apps/labrinth/src/routes/v3/oauth_clients.rs +++ b/apps/labrinth/src/routes/v3/oauth_clients.rs @@ -1,7 +1,6 @@ use std::{collections::HashSet, fmt::Display, sync::Arc}; use super::ApiError; -use crate::common::ids::base62_impl::parse_base62; use crate::{ auth::{checks::ValidateAuthorized, get_user_from_headers}, database::{ @@ -31,6 +30,7 @@ use actix_web::{ web::{self, scope}, HttpRequest, HttpResponse, }; +use ariadne::ids::base62_impl::parse_base62; use chrono::Utc; use itertools::Itertools; use rand::{distributions::Alphanumeric, Rng, SeedableRng}; diff --git a/apps/labrinth/src/routes/v3/organizations.rs b/apps/labrinth/src/routes/v3/organizations.rs index 0048c45e..06711e74 100644 --- a/apps/labrinth/src/routes/v3/organizations.rs +++ b/apps/labrinth/src/routes/v3/organizations.rs @@ -3,7 +3,6 @@ use std::sync::Arc; use super::ApiError; use crate::auth::{filter_visible_projects, get_user_from_headers}; -use crate::common::ids::base62_impl::parse_base62; use crate::database::models::team_item::TeamMember; use crate::database::models::{ generate_organization_id, team_item, Organization, @@ -21,6 +20,7 @@ use crate::util::routes::read_from_payload; use crate::util::validate::validation_errors_to_string; use crate::{database, models}; use actix_web::{web, HttpRequest, HttpResponse}; +use ariadne::ids::base62_impl::parse_base62; use futures::TryStreamExt; use rust_decimal::Decimal; use serde::{Deserialize, Serialize}; diff --git a/apps/labrinth/src/routes/v3/project_creation.rs b/apps/labrinth/src/routes/v3/project_creation.rs index 1b9e393c..fcd1507e 100644 --- a/apps/labrinth/src/routes/v3/project_creation.rs +++ b/apps/labrinth/src/routes/v3/project_creation.rs @@ -1,6 +1,5 @@ use super::version_creation::{try_create_version_fields, InitialVersionData}; use crate::auth::{get_user_from_headers, AuthenticationError}; -use crate::common::ids::base62_impl::to_base62; use crate::database::models::loader_fields::{ Loader, LoaderField, LoaderFieldEnumValue, }; @@ -28,6 +27,7 @@ use actix_multipart::{Field, Multipart}; use actix_web::http::StatusCode; use actix_web::web::{self, Data}; use actix_web::{HttpRequest, HttpResponse}; +use ariadne::ids::base62_impl::to_base62; use chrono::Utc; use futures::stream::StreamExt; use image::ImageError; diff --git a/apps/labrinth/src/routes/v3/projects.rs b/apps/labrinth/src/routes/v3/projects.rs index c8a20781..237e3b22 100644 --- a/apps/labrinth/src/routes/v3/projects.rs +++ b/apps/labrinth/src/routes/v3/projects.rs @@ -3,7 +3,6 @@ use std::sync::Arc; use crate::auth::checks::{filter_visible_versions, is_visible_project}; use crate::auth::{filter_visible_projects, get_user_from_headers}; -use crate::common::ids::base62_impl::parse_base62; use crate::database::models::notification_item::NotificationBuilder; use crate::database::models::project_item::{GalleryItem, ModCategory}; use crate::database::models::thread_item::ThreadMessageBuilder; @@ -30,6 +29,7 @@ use crate::util::img::{delete_old_images, upload_image_optimized}; use crate::util::routes::read_from_payload; use crate::util::validate::validation_errors_to_string; use actix_web::{web, HttpRequest, HttpResponse}; +use ariadne::ids::base62_impl::parse_base62; use chrono::Utc; use futures::TryStreamExt; use itertools::Itertools; diff --git a/apps/labrinth/src/routes/v3/reports.rs b/apps/labrinth/src/routes/v3/reports.rs index 3a565555..710cce74 100644 --- a/apps/labrinth/src/routes/v3/reports.rs +++ b/apps/labrinth/src/routes/v3/reports.rs @@ -1,5 +1,4 @@ use crate::auth::{check_is_moderator_from_headers, get_user_from_headers}; -use crate::common::ids::base62_impl::parse_base62; use crate::database; use crate::database::models::image_item; use crate::database::models::thread_item::{ @@ -16,6 +15,7 @@ use crate::queue::session::AuthQueue; use crate::routes::ApiError; use crate::util::img; use actix_web::{web, HttpRequest, HttpResponse}; +use ariadne::ids::base62_impl::parse_base62; use chrono::Utc; use futures::StreamExt; use serde::Deserialize; diff --git a/apps/labrinth/src/routes/v3/versions.rs b/apps/labrinth/src/routes/v3/versions.rs index 734ecd5b..cd9ff36d 100644 --- a/apps/labrinth/src/routes/v3/versions.rs +++ b/apps/labrinth/src/routes/v3/versions.rs @@ -5,7 +5,6 @@ use crate::auth::checks::{ filter_visible_versions, is_visible_project, is_visible_version, }; use crate::auth::get_user_from_headers; -use crate::common::ids::base62_impl::parse_base62; use crate::database; use crate::database::models::loader_fields::{ self, LoaderField, LoaderFieldEnumValue, VersionField, @@ -28,6 +27,7 @@ use crate::search::SearchConfig; use crate::util::img; use crate::util::validate::validation_errors_to_string; use actix_web::{web, HttpRequest, HttpResponse}; +use ariadne::ids::base62_impl::parse_base62; use itertools::Itertools; use serde::{Deserialize, Serialize}; use sqlx::PgPool; diff --git a/apps/labrinth/src/search/indexing/mod.rs b/apps/labrinth/src/search/indexing/mod.rs index 12ddd852..28de1c12 100644 --- a/apps/labrinth/src/search/indexing/mod.rs +++ b/apps/labrinth/src/search/indexing/mod.rs @@ -1,9 +1,9 @@ /// This module is used for the indexing from any source. pub mod local_import; -use crate::common::ids::base62_impl::to_base62; use crate::database::redis::RedisPool; use crate::search::{SearchConfig, UploadSearchProject}; +use ariadne::ids::base62_impl::to_base62; use local_import::index_local; use log::info; use meilisearch_sdk::client::{Client, SwapIndexes}; diff --git a/apps/labrinth/src/util/webhook.rs b/apps/labrinth/src/util/webhook.rs index 4e27b5f0..1f6a476b 100644 --- a/apps/labrinth/src/util/webhook.rs +++ b/apps/labrinth/src/util/webhook.rs @@ -1,8 +1,8 @@ -use crate::common::ids::base62_impl::to_base62; use crate::database::models::legacy_loader_fields::MinecraftGameVersion; use crate::database::redis::RedisPool; use crate::models::projects::ProjectId; use crate::routes::ApiError; +use ariadne::ids::base62_impl::to_base62; use chrono::{DateTime, Utc}; use serde::Serialize; use sqlx::PgPool; diff --git a/apps/labrinth/tests/analytics.rs b/apps/labrinth/tests/analytics.rs index 477f9177..5c591c21 100644 --- a/apps/labrinth/tests/analytics.rs +++ b/apps/labrinth/tests/analytics.rs @@ -1,3 +1,4 @@ +use ariadne::ids::base62_impl::parse_base62; use chrono::{DateTime, Duration, Utc}; use common::permissions::PermissionsTest; use common::permissions::PermissionsTestContext; @@ -7,7 +8,6 @@ use common::{ environment::{with_test_environment, TestEnvironment}, }; use itertools::Itertools; -use labrinth::common::ids::base62_impl::parse_base62; use labrinth::models::teams::ProjectPermissions; use labrinth::queue::payouts; use rust_decimal::{prelude::ToPrimitive, Decimal}; diff --git a/apps/labrinth/tests/common/api_common/generic.rs b/apps/labrinth/tests/common/api_common/generic.rs index f07a153e..0edd96f7 100644 --- a/apps/labrinth/tests/common/api_common/generic.rs +++ b/apps/labrinth/tests/common/api_common/generic.rs @@ -7,7 +7,7 @@ use labrinth::models::{ teams::{OrganizationPermissions, ProjectPermissions}, }; -use crate::common::{api_v2::ApiV2, api_v3::ApiV3, dummy_data::TestFile}; +use ariadne::{api_v2::ApiV2, api_v3::ApiV3, dummy_data::TestFile}; use super::{ models::{CommonProject, CommonVersion}, @@ -81,7 +81,7 @@ delegate_api_variant!( [add_gallery_item, ServiceResponse, id_or_slug: &str, image: ImageData, featured: bool, title: Option, description: Option, ordering: Option, pat: Option<&str>], [remove_gallery_item, ServiceResponse, id_or_slug: &str, image_url: &str, pat: Option<&str>], [edit_gallery_item, ServiceResponse, id_or_slug: &str, image_url: &str, patch: HashMap, pat: Option<&str>], - [create_report, ServiceResponse, report_type: &str, id: &str, item_type: crate::common::api_common::models::CommonItemType, body: &str, pat: Option<&str>], + [create_report, ServiceResponse, report_type: &str, id: &str, item_type: ariadne::api_common::models::CommonItemType, body: &str, pat: Option<&str>], [get_report, ServiceResponse, id: &str, pat: Option<&str>], [get_reports, ServiceResponse, ids: &[&str], pat: Option<&str>], [get_user_reports, ServiceResponse, pat: Option<&str>], @@ -100,9 +100,9 @@ delegate_api_variant!( #[async_trait(?Send)] impl ApiTags for GenericApi { [get_loaders, ServiceResponse,], - [get_loaders_deserialized_common, Vec,], + [get_loaders_deserialized_common, Vec,], [get_categories, ServiceResponse,], - [get_categories_deserialized_common, Vec,], + [get_categories_deserialized_common, Vec,], } ); @@ -110,18 +110,18 @@ delegate_api_variant!( #[async_trait(?Send)] impl ApiTeams for GenericApi { [get_team_members, ServiceResponse, team_id: &str, pat: Option<&str>], - [get_team_members_deserialized_common, Vec, team_id: &str, pat: Option<&str>], + [get_team_members_deserialized_common, Vec, team_id: &str, pat: Option<&str>], [get_teams_members, ServiceResponse, ids: &[&str], pat: Option<&str>], [get_project_members, ServiceResponse, id_or_slug: &str, pat: Option<&str>], - [get_project_members_deserialized_common, Vec, id_or_slug: &str, pat: Option<&str>], + [get_project_members_deserialized_common, Vec, id_or_slug: &str, pat: Option<&str>], [get_organization_members, ServiceResponse, id_or_title: &str, pat: Option<&str>], - [get_organization_members_deserialized_common, Vec, id_or_title: &str, pat: Option<&str>], + [get_organization_members_deserialized_common, Vec, id_or_title: &str, pat: Option<&str>], [join_team, ServiceResponse, team_id: &str, pat: Option<&str>], [remove_from_team, ServiceResponse, team_id: &str, user_id: &str, pat: Option<&str>], [edit_team_member, ServiceResponse, team_id: &str, user_id: &str, patch: serde_json::Value, pat: Option<&str>], [transfer_team_ownership, ServiceResponse, team_id: &str, user_id: &str, pat: Option<&str>], [get_user_notifications, ServiceResponse, user_id: &str, pat: Option<&str>], - [get_user_notifications_deserialized_common, Vec, user_id: &str, pat: Option<&str>], + [get_user_notifications_deserialized_common, Vec, user_id: &str, pat: Option<&str>], [get_notification, ServiceResponse, notification_id: &str, pat: Option<&str>], [get_notifications, ServiceResponse, ids: &[&str], pat: Option<&str>], [mark_notification_read, ServiceResponse, notification_id: &str, pat: Option<&str>], diff --git a/apps/labrinth/tests/common/api_common/request_data.rs b/apps/labrinth/tests/common/api_common/request_data.rs index eb3a7813..e04a381d 100644 --- a/apps/labrinth/tests/common/api_common/request_data.rs +++ b/apps/labrinth/tests/common/api_common/request_data.rs @@ -3,7 +3,7 @@ use labrinth::util::actix::MultipartSegment; -use crate::common::dummy_data::TestFile; +use ariadne::dummy_data::TestFile; #[allow(dead_code)] pub struct ProjectCreationRequestData { diff --git a/apps/labrinth/tests/common/api_v2/project.rs b/apps/labrinth/tests/common/api_v2/project.rs index df268fca..c4960dd0 100644 --- a/apps/labrinth/tests/common/api_v2/project.rs +++ b/apps/labrinth/tests/common/api_v2/project.rs @@ -24,7 +24,7 @@ use labrinth::{ }; use serde_json::json; -use crate::common::database::MOD_USER_PAT; +use ariadne::database::MOD_USER_PAT; use super::{ request_data::{self, get_public_project_creation_data}, diff --git a/apps/labrinth/tests/common/api_v2/request_data.rs b/apps/labrinth/tests/common/api_v2/request_data.rs index 8eced361..9deb6490 100644 --- a/apps/labrinth/tests/common/api_v2/request_data.rs +++ b/apps/labrinth/tests/common/api_v2/request_data.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use serde_json::json; -use crate::common::{ +use ariadne::{ api_common::request_data::{ ProjectCreationRequestData, VersionCreationRequestData, }, diff --git a/apps/labrinth/tests/common/api_v2/user.rs b/apps/labrinth/tests/common/api_v2/user.rs index 7031b66f..2202f94b 100644 --- a/apps/labrinth/tests/common/api_v2/user.rs +++ b/apps/labrinth/tests/common/api_v2/user.rs @@ -1,6 +1,6 @@ use super::ApiV2; -use crate::common::api_common::{Api, ApiUser, AppendsOptionalPat}; use actix_web::{dev::ServiceResponse, test}; +use ariadne::api_common::{Api, ApiUser, AppendsOptionalPat}; use async_trait::async_trait; #[async_trait(?Send)] diff --git a/apps/labrinth/tests/common/api_v3/request_data.rs b/apps/labrinth/tests/common/api_v3/request_data.rs index 790503b8..a18ebe63 100644 --- a/apps/labrinth/tests/common/api_v3/request_data.rs +++ b/apps/labrinth/tests/common/api_v3/request_data.rs @@ -1,7 +1,7 @@ #![allow(dead_code)] use serde_json::json; -use crate::common::{ +use ariadne::{ api_common::request_data::{ ProjectCreationRequestData, VersionCreationRequestData, }, diff --git a/apps/labrinth/tests/common/api_v3/user.rs b/apps/labrinth/tests/common/api_v3/user.rs index 9e2c9f7f..43a8b794 100644 --- a/apps/labrinth/tests/common/api_v3/user.rs +++ b/apps/labrinth/tests/common/api_v3/user.rs @@ -1,7 +1,7 @@ use actix_web::{dev::ServiceResponse, test}; use async_trait::async_trait; -use crate::common::api_common::{Api, ApiUser, AppendsOptionalPat}; +use ariadne::api_common::{Api, ApiUser, AppendsOptionalPat}; use super::ApiV3; diff --git a/apps/labrinth/tests/common/asserts.rs b/apps/labrinth/tests/common/asserts.rs index f4b7330e..0fac4b91 100644 --- a/apps/labrinth/tests/common/asserts.rs +++ b/apps/labrinth/tests/common/asserts.rs @@ -1,6 +1,6 @@ #![allow(dead_code)] -use crate::common::get_json_val_str; +use ariadne::get_json_val_str; use itertools::Itertools; use labrinth::models::v3::projects::Version; diff --git a/apps/labrinth/tests/common/database.rs b/apps/labrinth/tests/common/database.rs index f4d96fd5..cdef1684 100644 --- a/apps/labrinth/tests/common/database.rs +++ b/apps/labrinth/tests/common/database.rs @@ -5,7 +5,7 @@ use sqlx::{postgres::PgPoolOptions, PgPool}; use std::time::Duration; use url::Url; -use crate::common::{dummy_data, environment::TestEnvironment}; +use ariadne::{dummy_data, environment::TestEnvironment}; use super::{api_v3::ApiV3, dummy_data::DUMMY_DATA_UPDATE}; diff --git a/apps/labrinth/tests/common/permissions.rs b/apps/labrinth/tests/common/permissions.rs index 02b11935..ec8996ce 100644 --- a/apps/labrinth/tests/common/permissions.rs +++ b/apps/labrinth/tests/common/permissions.rs @@ -6,7 +6,7 @@ use itertools::Itertools; use labrinth::models::teams::{OrganizationPermissions, ProjectPermissions}; use serde_json::json; -use crate::common::{ +use ariadne::{ api_common::ApiTeams, database::{generate_random_name, ADMIN_USER_PAT}, }; diff --git a/apps/labrinth/tests/loader_fields.rs b/apps/labrinth/tests/loader_fields.rs index 78ee67a4..b4390cf5 100644 --- a/apps/labrinth/tests/loader_fields.rs +++ b/apps/labrinth/tests/loader_fields.rs @@ -9,13 +9,11 @@ use labrinth::database::models::legacy_loader_fields::MinecraftGameVersion; use labrinth::models::v3; use serde_json::json; -use crate::common::api_common::{ApiProject, ApiVersion}; -use crate::common::api_v3::request_data::get_public_project_creation_data; -use crate::common::database::*; +use ariadne::api_common::{ApiProject, ApiVersion}; +use ariadne::api_v3::request_data::get_public_project_creation_data; +use ariadne::database::*; -use crate::common::dummy_data::{ - DummyProjectAlpha, DummyProjectBeta, TestFile, -}; +use ariadne::dummy_data::{DummyProjectAlpha, DummyProjectBeta, TestFile}; // importing common module. mod common; diff --git a/apps/labrinth/tests/notifications.rs b/apps/labrinth/tests/notifications.rs index d63fc819..b314f247 100644 --- a/apps/labrinth/tests/notifications.rs +++ b/apps/labrinth/tests/notifications.rs @@ -3,7 +3,7 @@ use common::{ environment::with_test_environment_all, }; -use crate::common::api_common::ApiTeams; +use ariadne::api_common::ApiTeams; mod common; diff --git a/apps/labrinth/tests/organizations.rs b/apps/labrinth/tests/organizations.rs index 1a570b35..4e50c31d 100644 --- a/apps/labrinth/tests/organizations.rs +++ b/apps/labrinth/tests/organizations.rs @@ -1,4 +1,5 @@ -use crate::common::{ +use actix_http::StatusCode; +use ariadne::{ api_common::{ApiProject, ApiTeams}, database::{ generate_random_name, ADMIN_USER_PAT, ENEMY_USER_ID_PARSED, @@ -9,7 +10,6 @@ use crate::common::{ DummyImage, DummyOrganizationZeta, DummyProjectAlpha, DummyProjectBeta, }, }; -use actix_http::StatusCode; use common::{ api_v3::ApiV3, database::{FRIEND_USER_ID, FRIEND_USER_PAT, USER_USER_PAT}, diff --git a/apps/labrinth/tests/pats.rs b/apps/labrinth/tests/pats.rs index 07b130f9..2ef22a2e 100644 --- a/apps/labrinth/tests/pats.rs +++ b/apps/labrinth/tests/pats.rs @@ -6,7 +6,7 @@ use common::{database::*, environment::with_test_environment_all}; use labrinth::models::pats::Scopes; use serde_json::json; -use crate::common::api_common::AppendsOptionalPat; +use ariadne::api_common::AppendsOptionalPat; mod common; diff --git a/apps/labrinth/tests/project.rs b/apps/labrinth/tests/project.rs index 3b8c398f..1a9e4276 100644 --- a/apps/labrinth/tests/project.rs +++ b/apps/labrinth/tests/project.rs @@ -4,12 +4,12 @@ use common::api_v3::ApiV3; use common::database::*; use common::dummy_data::DUMMY_CATEGORIES; +use ariadne::ids::base62_impl::parse_base62; use common::environment::{ with_test_environment, with_test_environment_all, TestEnvironment, }; use common::permissions::{PermissionsTest, PermissionsTestContext}; use futures::StreamExt; -use labrinth::common::ids::base62_impl::parse_base62; use labrinth::database::models::project_item::{ PROJECTS_NAMESPACE, PROJECTS_SLUGS_NAMESPACE, }; @@ -18,10 +18,10 @@ use labrinth::models::teams::ProjectPermissions; use labrinth::util::actix::{MultipartSegment, MultipartSegmentData}; use serde_json::json; -use crate::common::api_common::models::CommonProject; -use crate::common::api_common::request_data::ProjectCreationRequestData; -use crate::common::api_common::{ApiProject, ApiTeams, ApiVersion}; -use crate::common::dummy_data::{ +use ariadne::api_common::models::CommonProject; +use ariadne::api_common::request_data::ProjectCreationRequestData; +use ariadne::api_common::{ApiProject, ApiTeams, ApiVersion}; +use ariadne::dummy_data::{ DummyImage, DummyOrganizationZeta, DummyProjectAlpha, DummyProjectBeta, TestFile, }; diff --git a/apps/labrinth/tests/scopes.rs b/apps/labrinth/tests/scopes.rs index 865629f9..b6c95008 100644 --- a/apps/labrinth/tests/scopes.rs +++ b/apps/labrinth/tests/scopes.rs @@ -1,13 +1,12 @@ use std::collections::HashMap; -use crate::common::api_common::{ - ApiProject, ApiTeams, ApiUser, ApiVersion, AppendsOptionalPat, -}; -use crate::common::dummy_data::{ - DummyImage, DummyProjectAlpha, DummyProjectBeta, -}; use actix_http::StatusCode; use actix_web::test; +use ariadne::api_common::{ + ApiProject, ApiTeams, ApiUser, ApiVersion, AppendsOptionalPat, +}; +use ariadne::dummy_data::{DummyImage, DummyProjectAlpha, DummyProjectBeta}; +use ariadne::ids::base62_impl::parse_base62; use chrono::{Duration, Utc}; use common::api_common::models::CommonItemType; use common::api_common::Api; @@ -18,7 +17,6 @@ use common::environment::{ with_test_environment, with_test_environment_all, TestEnvironment, }; use common::{database::*, scopes::ScopeTest}; -use labrinth::common::ids::base62_impl::parse_base62; use labrinth::models::pats::Scopes; use labrinth::models::projects::ProjectId; use labrinth::models::users::UserId; diff --git a/apps/labrinth/tests/search.rs b/apps/labrinth/tests/search.rs index 87465dc3..722e4189 100644 --- a/apps/labrinth/tests/search.rs +++ b/apps/labrinth/tests/search.rs @@ -4,11 +4,11 @@ use common::database::*; use common::dummy_data::DUMMY_CATEGORIES; +use ariadne::ids::base62_impl::parse_base62; use common::environment::with_test_environment; use common::environment::TestEnvironment; use common::search::setup_search_projects; use futures::stream::StreamExt; -use labrinth::common::ids::base62_impl::parse_base62; use serde_json::json; use crate::common::api_common::Api; diff --git a/apps/labrinth/tests/tags.rs b/apps/labrinth/tests/tags.rs index 264c7e29..283f6d78 100644 --- a/apps/labrinth/tests/tags.rs +++ b/apps/labrinth/tests/tags.rs @@ -7,7 +7,7 @@ use common::{ }, }; -use crate::common::api_common::ApiTags; +use ariadne::api_common::ApiTags; mod common; diff --git a/apps/labrinth/tests/teams.rs b/apps/labrinth/tests/teams.rs index 4743ecf4..73a6669d 100644 --- a/apps/labrinth/tests/teams.rs +++ b/apps/labrinth/tests/teams.rs @@ -1,5 +1,5 @@ -use crate::common::{api_common::ApiTeams, database::*}; use actix_http::StatusCode; +use ariadne::{api_common::ApiTeams, database::*}; use common::{ api_v3::ApiV3, environment::{ diff --git a/apps/labrinth/tests/user.rs b/apps/labrinth/tests/user.rs index b1b7bfd0..3939304c 100644 --- a/apps/labrinth/tests/user.rs +++ b/apps/labrinth/tests/user.rs @@ -1,4 +1,4 @@ -use crate::common::api_common::{ApiProject, ApiTeams}; +use ariadne::api_common::{ApiProject, ApiTeams}; use common::dummy_data::TestFile; use common::{ database::{FRIEND_USER_ID, FRIEND_USER_PAT, USER_USER_ID, USER_USER_PAT}, diff --git a/apps/labrinth/tests/v2/error.rs b/apps/labrinth/tests/v2/error.rs index 1ae56a71..ad6274b6 100644 --- a/apps/labrinth/tests/v2/error.rs +++ b/apps/labrinth/tests/v2/error.rs @@ -1,12 +1,12 @@ use crate::assert_status; -use crate::common::api_common::ApiProject; +use ariadne::api_common::ApiProject; use actix_http::StatusCode; use actix_web::test; use bytes::Bytes; -use crate::common::database::USER_USER_PAT; -use crate::common::{ +use ariadne::database::USER_USER_PAT; +use ariadne::{ api_v2::ApiV2, environment::{with_test_environment, TestEnvironment}, }; diff --git a/apps/labrinth/tests/v2/notifications.rs b/apps/labrinth/tests/v2/notifications.rs index 692ae138..5f9835cb 100644 --- a/apps/labrinth/tests/v2/notifications.rs +++ b/apps/labrinth/tests/v2/notifications.rs @@ -1,4 +1,4 @@ -use crate::common::{ +use ariadne::{ api_common::ApiTeams, api_v2::ApiV2, database::{FRIEND_USER_ID, FRIEND_USER_PAT, USER_USER_PAT}, diff --git a/apps/labrinth/tests/v2/project.rs b/apps/labrinth/tests/v2/project.rs index 597e265a..d81f263e 100644 --- a/apps/labrinth/tests/v2/project.rs +++ b/apps/labrinth/tests/v2/project.rs @@ -16,9 +16,9 @@ use crate::{ }; use actix_http::StatusCode; use actix_web::test; +use ariadne::ids::base62_impl::parse_base62; use futures::StreamExt; use itertools::Itertools; -use labrinth::common::ids::base62_impl::parse_base62; use labrinth::{ database::models::project_item::PROJECTS_SLUGS_NAMESPACE, models::{projects::ProjectId, teams::ProjectPermissions}, diff --git a/apps/labrinth/tests/v2/scopes.rs b/apps/labrinth/tests/v2/scopes.rs index 993c0cd7..a3a32d89 100644 --- a/apps/labrinth/tests/v2/scopes.rs +++ b/apps/labrinth/tests/v2/scopes.rs @@ -1,12 +1,12 @@ -use crate::common::api_common::ApiProject; -use crate::common::api_common::ApiVersion; -use crate::common::api_v2::request_data::get_public_project_creation_data; -use crate::common::api_v2::ApiV2; -use crate::common::dummy_data::TestFile; -use crate::common::environment::with_test_environment; -use crate::common::environment::TestEnvironment; -use crate::common::scopes::ScopeTest; -use labrinth::common::ids::base62_impl::parse_base62; +use ariadne::api_common::ApiProject; +use ariadne::api_common::ApiVersion; +use ariadne::api_v2::request_data::get_public_project_creation_data; +use ariadne::api_v2::ApiV2; +use ariadne::dummy_data::TestFile; +use ariadne::environment::with_test_environment; +use ariadne::environment::TestEnvironment; +use ariadne::ids::base62_impl::parse_base62; +use ariadne::scopes::ScopeTest; use labrinth::models::pats::Scopes; use labrinth::models::projects::ProjectId; diff --git a/apps/labrinth/tests/v2/search.rs b/apps/labrinth/tests/v2/search.rs index bfff82b0..b52f4055 100644 --- a/apps/labrinth/tests/v2/search.rs +++ b/apps/labrinth/tests/v2/search.rs @@ -1,17 +1,17 @@ use crate::assert_status; -use crate::common::api_common::Api; -use crate::common::api_common::ApiProject; -use crate::common::api_common::ApiVersion; -use crate::common::api_v2::ApiV2; +use ariadne::api_common::Api; +use ariadne::api_common::ApiProject; +use ariadne::api_common::ApiVersion; +use ariadne::api_v2::ApiV2; -use crate::common::database::*; -use crate::common::dummy_data::TestFile; -use crate::common::dummy_data::DUMMY_CATEGORIES; -use crate::common::environment::with_test_environment; -use crate::common::environment::TestEnvironment; use actix_http::StatusCode; +use ariadne::database::*; +use ariadne::dummy_data::TestFile; +use ariadne::dummy_data::DUMMY_CATEGORIES; +use ariadne::environment::with_test_environment; +use ariadne::environment::TestEnvironment; +use ariadne::ids::base62_impl::parse_base62; use futures::stream::StreamExt; -use labrinth::common::ids::base62_impl::parse_base62; use serde_json::json; use std::collections::HashMap; use std::sync::Arc; diff --git a/apps/labrinth/tests/v2/tags.rs b/apps/labrinth/tests/v2/tags.rs index 1171e650..70b292bc 100644 --- a/apps/labrinth/tests/v2/tags.rs +++ b/apps/labrinth/tests/v2/tags.rs @@ -3,7 +3,7 @@ use labrinth::routes::v2::tags::DonationPlatformQueryData; use std::collections::HashSet; -use crate::common::{ +use ariadne::{ api_v2::ApiV2, environment::{with_test_environment, TestEnvironment}, }; diff --git a/apps/labrinth/tests/v2/version.rs b/apps/labrinth/tests/v2/version.rs index b4195bef..31a386b5 100644 --- a/apps/labrinth/tests/v2/version.rs +++ b/apps/labrinth/tests/v2/version.rs @@ -9,13 +9,13 @@ use labrinth::{ use serde_json::json; use crate::assert_status; -use crate::common::api_common::{ApiProject, ApiVersion}; -use crate::common::api_v2::ApiV2; +use ariadne::api_common::{ApiProject, ApiVersion}; +use ariadne::api_v2::ApiV2; -use crate::common::api_v2::request_data::get_public_project_creation_data; -use crate::common::dummy_data::{DummyProjectAlpha, DummyProjectBeta}; -use crate::common::environment::{with_test_environment, TestEnvironment}; -use crate::common::{ +use ariadne::api_v2::request_data::get_public_project_creation_data; +use ariadne::dummy_data::{DummyProjectAlpha, DummyProjectBeta}; +use ariadne::environment::{with_test_environment, TestEnvironment}; +use ariadne::{ database::{ENEMY_USER_PAT, USER_USER_PAT}, dummy_data::TestFile, }; diff --git a/apps/labrinth/tests/version.rs b/apps/labrinth/tests/version.rs index 34a5dc6d..08d2dcd6 100644 --- a/apps/labrinth/tests/version.rs +++ b/apps/labrinth/tests/version.rs @@ -1,19 +1,17 @@ use std::collections::HashMap; -use crate::common::api_common::ApiVersion; -use crate::common::database::*; -use crate::common::dummy_data::{ - DummyProjectAlpha, DummyProjectBeta, TestFile, -}; -use crate::common::get_json_val_str; use actix_http::StatusCode; use actix_web::test; +use ariadne::api_common::ApiVersion; +use ariadne::database::*; +use ariadne::dummy_data::{DummyProjectAlpha, DummyProjectBeta, TestFile}; +use ariadne::get_json_val_str; +use ariadne::ids::base62_impl::parse_base62; use common::api_v3::ApiV3; use common::asserts::assert_common_version_ids; use common::database::USER_USER_PAT; use common::environment::{with_test_environment, with_test_environment_all}; use futures::StreamExt; -use labrinth::common::ids::base62_impl::parse_base62; use labrinth::database::models::version_item::VERSIONS_NAMESPACE; use labrinth::models::projects::{ Dependency, DependencyType, VersionId, VersionStatus, VersionType, diff --git a/packages/app-lib/Cargo.toml b/packages/app-lib/Cargo.toml index 4b980492..eb098779 100644 --- a/packages/app-lib/Cargo.toml +++ b/packages/app-lib/Cargo.toml @@ -63,7 +63,7 @@ base64 = "0.22.0" sqlx = { version = "0.8.2", features = [ "runtime-tokio", "sqlite", "macros" ] } -labrinth = { path = "../../apps/labrinth" } +ariadne = { path = "../ariadne" } [target.'cfg(windows)'.dependencies] winreg = "0.52.0" diff --git a/packages/app-lib/src/api/friends.rs b/packages/app-lib/src/api/friends.rs index 56b2e1cd..0fe883e0 100644 --- a/packages/app-lib/src/api/friends.rs +++ b/packages/app-lib/src/api/friends.rs @@ -1,5 +1,5 @@ use crate::state::{FriendsSocket, UserFriend}; -use labrinth::common::users::UserStatus; +use ariadne::users::UserStatus; #[tracing::instrument] pub async fn friends() -> crate::Result> { diff --git a/packages/app-lib/src/api/mod.rs b/packages/app-lib/src/api/mod.rs index ccdcdfc3..81e4c5e6 100644 --- a/packages/app-lib/src/api/mod.rs +++ b/packages/app-lib/src/api/mod.rs @@ -21,7 +21,7 @@ pub mod data { Project, ProjectType, SearchResult, SearchResults, Settings, TeamMember, Theme, User, UserFriend, Version, WindowSize, }; - pub use labrinth::common::users::UserStatus; + pub use ariadne::users::UserStatus; } pub mod prelude { diff --git a/packages/app-lib/src/error.rs b/packages/app-lib/src/error.rs index 90e0d52a..9eabe33a 100644 --- a/packages/app-lib/src/error.rs +++ b/packages/app-lib/src/error.rs @@ -15,7 +15,7 @@ pub enum ErrorKind { #[error("Serialization error (websocket): {0}")] WebsocketSerializationError( - #[from] labrinth::common::networking::serialization::SerializationError, + #[from] ariadne::networking::serialization::SerializationError, ), #[error("Error parsing UUID: {0}")] diff --git a/packages/app-lib/src/event/mod.rs b/packages/app-lib/src/event/mod.rs index 48211c45..0c0ac023 100644 --- a/packages/app-lib/src/event/mod.rs +++ b/packages/app-lib/src/event/mod.rs @@ -1,6 +1,6 @@ //! Theseus state management system +use ariadne::users::{UserId, UserStatus}; use dashmap::DashMap; -use labrinth::common::users::{UserId, UserStatus}; use serde::{Deserialize, Serialize}; use std::{path::PathBuf, sync::Arc}; #[cfg(feature = "tauri")] diff --git a/packages/app-lib/src/state/friends.rs b/packages/app-lib/src/state/friends.rs index 3b179540..0775b04d 100644 --- a/packages/app-lib/src/state/friends.rs +++ b/packages/app-lib/src/state/friends.rs @@ -5,6 +5,10 @@ use crate::event::FriendPayload; use crate::state::tunnel::InternalTunnelSocket; use crate::state::{ProcessManager, Profile, TunnelSocket}; use crate::util::fetch::{fetch_advanced, fetch_json, FetchSemaphore}; +use ariadne::networking::message::{ + ClientToServerMessage, ServerToClientMessage, +}; +use ariadne::users::{UserId, UserStatus}; use async_tungstenite::tokio::{connect_async, ConnectStream}; use async_tungstenite::tungstenite::client::IntoClientRequest; use async_tungstenite::tungstenite::Message; @@ -14,10 +18,6 @@ use dashmap::DashMap; use either::Either; use futures::stream::SplitSink; use futures::{SinkExt, StreamExt}; -use labrinth::common::networking::message::{ - ClientToServerMessage, ServerToClientMessage, -}; -use labrinth::common::users::{UserId, UserStatus}; use reqwest::header::HeaderValue; use reqwest::Method; use serde::{Deserialize, Serialize}; diff --git a/packages/app-lib/src/state/tunnel.rs b/packages/app-lib/src/state/tunnel.rs index c65c69ea..a6ff41ea 100644 --- a/packages/app-lib/src/state/tunnel.rs +++ b/packages/app-lib/src/state/tunnel.rs @@ -1,6 +1,6 @@ use crate::state::friends::{TunnelSockets, WriteSocket}; use crate::state::FriendsSocket; -use labrinth::common::networking::message::ClientToServerMessage; +use ariadne::networking::message::ClientToServerMessage; use std::net::SocketAddr; use std::sync::Arc; use tokio::io::AsyncWriteExt; diff --git a/packages/ariadne/Cargo.toml b/packages/ariadne/Cargo.toml new file mode 100644 index 00000000..7410fd31 --- /dev/null +++ b/packages/ariadne/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "ariadne" +version = "0.1.0" +edition = "2021" + +[dependencies] +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +thiserror = "1.0" +uuid = { version = "1.2.2", features = ["v4", "fast-rng", "serde"] } +serde_bytes = "0.11" +rand = "0.8.5" +either = "1.13" +chrono = { version = "0.4.26", features = ["serde"] } +serde_cbor = "0.11" diff --git a/apps/labrinth/src/common/ids.rs b/packages/ariadne/src/ids.rs similarity index 96% rename from apps/labrinth/src/common/ids.rs rename to packages/ariadne/src/ids.rs index 218ee9a8..c7baaa7e 100644 --- a/apps/labrinth/src/common/ids.rs +++ b/packages/ariadne/src/ids.rs @@ -94,9 +94,7 @@ macro_rules! impl_base62_display { ($struct:ty) => { impl std::fmt::Display for $struct { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - f.write_str(&$crate::common::ids::base62_impl::to_base62( - self.0, - )) + f.write_str(&$crate::ids::base62_impl::to_base62(self.0)) } } }; @@ -106,8 +104,8 @@ impl_base62_display!(Base62Id); #[macro_export] macro_rules! base62_id_impl { ($struct:ty, $cons:expr) => { - $crate::common::ids::from_base62id!($struct, $cons;); - $crate::common::ids::impl_base62_display!($struct); + $crate::ids::from_base62id!($struct, $cons;); + $crate::ids::impl_base62_display!($struct); } } base62_id_impl!(UserId, UserId); diff --git a/apps/labrinth/src/common/mod.rs b/packages/ariadne/src/lib.rs similarity index 100% rename from apps/labrinth/src/common/mod.rs rename to packages/ariadne/src/lib.rs diff --git a/packages/ariadne/src/mod.rs b/packages/ariadne/src/mod.rs new file mode 100644 index 00000000..4a4251a3 --- /dev/null +++ b/packages/ariadne/src/mod.rs @@ -0,0 +1,3 @@ +pub mod ids; +pub mod networking; +pub mod users; diff --git a/apps/labrinth/src/common/networking/message.rs b/packages/ariadne/src/networking/message.rs similarity index 94% rename from apps/labrinth/src/common/networking/message.rs rename to packages/ariadne/src/networking/message.rs index 96bc86a9..c7c9e5cb 100644 --- a/apps/labrinth/src/common/networking/message.rs +++ b/packages/ariadne/src/networking/message.rs @@ -1,5 +1,5 @@ -use crate::common::ids::UserId; -use crate::common::users::UserStatus; +use crate::ids::UserId; +use crate::users::UserStatus; use serde::{Deserialize, Serialize}; use uuid::Uuid; diff --git a/apps/labrinth/src/common/networking/mod.rs b/packages/ariadne/src/networking/mod.rs similarity index 100% rename from apps/labrinth/src/common/networking/mod.rs rename to packages/ariadne/src/networking/mod.rs diff --git a/apps/labrinth/src/common/networking/serialization.rs b/packages/ariadne/src/networking/serialization.rs similarity index 100% rename from apps/labrinth/src/common/networking/serialization.rs rename to packages/ariadne/src/networking/serialization.rs diff --git a/apps/labrinth/src/common/users.rs b/packages/ariadne/src/users.rs similarity index 100% rename from apps/labrinth/src/common/users.rs rename to packages/ariadne/src/users.rs