From 148dbbe56d578a8b0fbceb246f6588276cabce7b Mon Sep 17 00:00:00 2001 From: Namekuji Date: Fri, 2 Jun 2023 08:48:12 -0400 Subject: [PATCH] move files out from crate --- packages/backend/native-utils/Cargo.toml | 33 ++++++++++++++--- .../native-utils/crates/database/Cargo.toml | 12 ------- .../native-utils/crates/model/Cargo.toml | 35 ------------------- .../native-utils/crates/util/Cargo.toml | 15 -------- .../{crates => }/migration/Cargo.toml | 0 .../{crates => }/migration/README.md | 0 .../{crates => }/migration/src/lib.rs | 0 .../src/m20230531_180824_drop_reversi.rs | 0 .../{crates => }/migration/src/main.rs | 0 .../{crates => }/migration/src/vec_to_json.rs | 0 .../database/src => src/database}/error.rs | 0 .../src/lib.rs => src/database/mod.rs} | 6 ++-- packages/backend/native-utils/src/lib.rs | 5 +++ .../{crates/model/src => src/model}/entity.rs | 0 .../model}/entity/abuse_user_report.rs | 0 .../src => src/model}/entity/access_token.rs | 0 .../model/src => src/model}/entity/ad.rs | 0 .../src => src/model}/entity/announcement.rs | 0 .../model}/entity/announcement_read.rs | 0 .../model/src => src/model}/entity/antenna.rs | 0 .../src => src/model}/entity/antenna_note.rs | 0 .../model/src => src/model}/entity/app.rs | 0 .../model}/entity/attestation_challenge.rs | 0 .../src => src/model}/entity/auth_session.rs | 0 .../src => src/model}/entity/blocking.rs | 0 .../model/src => src/model}/entity/channel.rs | 0 .../model}/entity/channel_following.rs | 0 .../model}/entity/channel_note_pining.rs | 0 .../model/src => src/model}/entity/clip.rs | 0 .../src => src/model}/entity/clip_note.rs | 0 .../src => src/model}/entity/drive_file.rs | 0 .../src => src/model}/entity/drive_folder.rs | 0 .../model/src => src/model}/entity/emoji.rs | 0 .../model}/entity/follow_request.rs | 0 .../src => src/model}/entity/following.rs | 0 .../src => src/model}/entity/gallery_like.rs | 0 .../src => src/model}/entity/gallery_post.rs | 0 .../model/src => src/model}/entity/hashtag.rs | 0 .../src => src/model}/entity/instance.rs | 0 .../model}/entity/messaging_message.rs | 0 .../model/src => src/model}/entity/meta.rs | 0 .../src => src/model}/entity/migrations.rs | 0 .../model}/entity/moderation_log.rs | 0 .../src => src/model}/entity/muted_note.rs | 0 .../model/src => src/model}/entity/muting.rs | 0 .../model}/entity/newtype/macros.rs | 0 .../src => src/model}/entity/newtype/mod.rs | 0 .../model/src => src/model}/entity/note.rs | 0 .../src => src/model}/entity/note_edit.rs | 0 .../src => src/model}/entity/note_favorite.rs | 0 .../src => src/model}/entity/note_reaction.rs | 0 .../model}/entity/note_thread_muting.rs | 0 .../src => src/model}/entity/note_unread.rs | 0 .../src => src/model}/entity/note_watching.rs | 0 .../src => src/model}/entity/notification.rs | 0 .../model/src => src/model}/entity/page.rs | 0 .../src => src/model}/entity/page_like.rs | 0 .../model}/entity/password_reset_request.rs | 0 .../model/src => src/model}/entity/poll.rs | 0 .../src => src/model}/entity/poll_vote.rs | 0 .../model/src => src/model}/entity/prelude.rs | 0 .../src => src/model}/entity/promo_note.rs | 0 .../src => src/model}/entity/promo_read.rs | 0 .../model}/entity/registration_ticket.rs | 0 .../src => src/model}/entity/registry_item.rs | 0 .../model/src => src/model}/entity/relay.rs | 0 .../src => src/model}/entity/renote_muting.rs | 0 .../model}/entity/sea_orm_active_enums.rs | 0 .../model/src => src/model}/entity/signin.rs | 0 .../model}/entity/sw_subscription.rs | 0 .../src => src/model}/entity/used_username.rs | 0 .../model/src => src/model}/entity/user.rs | 0 .../src => src/model}/entity/user_group.rs | 0 .../model}/entity/user_group_invitation.rs | 0 .../model}/entity/user_group_invite.rs | 0 .../model}/entity/user_group_joining.rs | 0 .../model/src => src/model}/entity/user_ip.rs | 0 .../src => src/model}/entity/user_keypair.rs | 0 .../src => src/model}/entity/user_list.rs | 0 .../model}/entity/user_list_joining.rs | 0 .../model}/entity/user_note_pining.rs | 0 .../src => src/model}/entity/user_pending.rs | 0 .../src => src/model}/entity/user_profile.rs | 0 .../model}/entity/user_publickey.rs | 0 .../model}/entity/user_security_key.rs | 0 .../model/src => src/model}/entity/webhook.rs | 0 .../{crates/model/src => src/model}/error.rs | 9 ++++- .../model/src/lib.rs => src/model/mod.rs} | 0 .../model/src => src/model}/repository.rs | 7 ++-- .../src => src/model}/repository/antenna.rs | 7 ++-- .../{crates/model/src => src/model}/schema.rs | 0 .../model/src => src/model}/schema/antenna.rs | 9 ++--- .../model/src => src/model}/schema/app.rs | 0 .../model/src => src/model}/schema/napi.rs | 0 .../src => src/model}/schema/napi/antenna.rs | 13 ++++++- .../{crates/util/src => src/util}/id.rs | 2 +- .../util/src/lib.rs => src/util/mod.rs} | 0 .../{crates/util/src => src/util}/random.rs | 0 .../{crates/model => }/tests/common.rs | 17 +++++---- .../backend/native-utils/tests/model/mod.rs | 1 + .../mod.rs => tests/model/repository.rs} | 0 .../model}/repository/antenna.rs | 2 ++ 102 files changed, 82 insertions(+), 91 deletions(-) delete mode 100644 packages/backend/native-utils/crates/database/Cargo.toml delete mode 100644 packages/backend/native-utils/crates/model/Cargo.toml delete mode 100644 packages/backend/native-utils/crates/util/Cargo.toml rename packages/backend/native-utils/{crates => }/migration/Cargo.toml (100%) rename packages/backend/native-utils/{crates => }/migration/README.md (100%) rename packages/backend/native-utils/{crates => }/migration/src/lib.rs (100%) rename packages/backend/native-utils/{crates => }/migration/src/m20230531_180824_drop_reversi.rs (100%) rename packages/backend/native-utils/{crates => }/migration/src/main.rs (100%) rename packages/backend/native-utils/{crates => }/migration/src/vec_to_json.rs (100%) rename packages/backend/native-utils/{crates/database/src => src/database}/error.rs (100%) rename packages/backend/native-utils/{crates/database/src/lib.rs => src/database/mod.rs} (87%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/abuse_user_report.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/access_token.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/ad.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/announcement.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/announcement_read.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/antenna.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/antenna_note.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/app.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/attestation_challenge.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/auth_session.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/blocking.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/channel.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/channel_following.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/channel_note_pining.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/clip.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/clip_note.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/drive_file.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/drive_folder.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/emoji.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/follow_request.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/following.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/gallery_like.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/gallery_post.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/hashtag.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/instance.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/messaging_message.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/meta.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/migrations.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/moderation_log.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/muted_note.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/muting.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/newtype/macros.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/newtype/mod.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/note.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/note_edit.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/note_favorite.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/note_reaction.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/note_thread_muting.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/note_unread.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/note_watching.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/notification.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/page.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/page_like.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/password_reset_request.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/poll.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/poll_vote.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/prelude.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/promo_note.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/promo_read.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/registration_ticket.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/registry_item.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/relay.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/renote_muting.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/sea_orm_active_enums.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/signin.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/sw_subscription.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/used_username.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_group.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_group_invitation.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_group_invite.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_group_joining.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_ip.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_keypair.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_list.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_list_joining.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_note_pining.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_pending.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_profile.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_publickey.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/user_security_key.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/entity/webhook.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/error.rs (62%) rename packages/backend/native-utils/{crates/model/src/lib.rs => src/model/mod.rs} (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/repository.rs (75%) rename packages/backend/native-utils/{crates/model/src => src/model}/repository/antenna.rs (92%) rename packages/backend/native-utils/{crates/model/src => src/model}/schema.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/schema/antenna.rs (93%) rename packages/backend/native-utils/{crates/model/src => src/model}/schema/app.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/schema/napi.rs (100%) rename packages/backend/native-utils/{crates/model/src => src/model}/schema/napi/antenna.rs (78%) rename packages/backend/native-utils/{crates/util/src => src/util}/id.rs (97%) rename packages/backend/native-utils/{crates/util/src/lib.rs => src/util/mod.rs} (100%) rename packages/backend/native-utils/{crates/util/src => src/util}/random.rs (100%) rename packages/backend/native-utils/{crates/model => }/tests/common.rs (96%) create mode 100644 packages/backend/native-utils/tests/model/mod.rs rename packages/backend/native-utils/{crates/model/tests/repository/mod.rs => tests/model/repository.rs} (100%) rename packages/backend/native-utils/{crates/model/tests => tests/model}/repository/antenna.rs (97%) diff --git a/packages/backend/native-utils/Cargo.toml b/packages/backend/native-utils/Cargo.toml index 6f3c0e23f8..3c70a0209b 100644 --- a/packages/backend/native-utils/Cargo.toml +++ b/packages/backend/native-utils/Cargo.toml @@ -4,15 +4,40 @@ name = "native-utils" version = "0.0.0" [workspace] -members = ["crates/*"] +members = ["migration/Cargo.toml"] + +[features] +default = ["napi"] +noarray = [] +napi = ["dep:napi", "dep:napi-derive"] [lib] -crate-type = ["cdylib"] +crate-type = ["cdylib", "lib"] [dependencies] +async-trait = "0.1.68" +cfg-if = "1.0.0" +chrono = "0.4.24" +cuid2 = "0.1.0" +derive_more = "0.99.17" +jsonschema = "0.17.0" +once_cell = "1.17.1" +parse-display = "0.8.0" +rand = "0.8.5" +schemars = { version = "0.8.12", features = ["chrono"] } +sea-orm = { version = "0.11.3", features = ["sqlx-postgres", "postgres-array", "sqlx-sqlite", "runtime-tokio-rustls"] } +serde = { version = "1.0.163", features = ["derive"] } +serde_json = "1.0.96" +thiserror = "1.0.40" +tokio = { version = "1.28.1", features = ["full"] } +utoipa = "3.3.0" + # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix -napi = { version = "2.12.0", default-features = false, features = ["napi4"] } -napi-derive = "2.12.0" +napi = { version = "2.12.0", default-features = false, features = ["napi4", "tokio_rt"], optional = true } +napi-derive = { version = "2.12.0", optional = true } + +[dev-dependencies] +pretty_assertions = "1.3.0" [build-dependencies] napi-build = "2.0.1" diff --git a/packages/backend/native-utils/crates/database/Cargo.toml b/packages/backend/native-utils/crates/database/Cargo.toml deleted file mode 100644 index 440a76cf58..0000000000 --- a/packages/backend/native-utils/crates/database/Cargo.toml +++ /dev/null @@ -1,12 +0,0 @@ -[package] -name = "database" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -once_cell = "1.17.1" -sea-orm = { version = "0.11.3", features = ["sqlx-postgres", "runtime-tokio-rustls"] } -thiserror = "1.0.40" -tokio = { version = "1.28.1", features = ["macros"] } diff --git a/packages/backend/native-utils/crates/model/Cargo.toml b/packages/backend/native-utils/crates/model/Cargo.toml deleted file mode 100644 index 4925fb702f..0000000000 --- a/packages/backend/native-utils/crates/model/Cargo.toml +++ /dev/null @@ -1,35 +0,0 @@ -[package] -name = "model" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[features] -default = ["napi"] -noarray = [] -napi = ["dep:napi", "dep:napi-derive"] - -[dependencies] -async-trait = "0.1.68" -cfg-if = "1.0.0" -chrono = "0.4.24" -database = { path = "../database" } -derive_more = "0.99.17" -jsonschema = "0.17.0" -once_cell = "1.17.1" -parse-display = "0.8.0" -schemars = { version = "0.8.12", features = ["chrono"] } -sea-orm = { version = "0.11.3", features = ["sqlx-postgres", "postgres-array", "sqlx-sqlite", "runtime-tokio-rustls"] } -serde = { version = "1.0.163", features = ["derive"] } -serde_json = "1.0.96" -thiserror = "1.0.40" -tokio = { version = "1.28.1", features = ["sync"] } -util = { path = "../util" } -utoipa = "3.3.0" - -# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix -napi = { version = "2.12.0", default-features = false, features = ["napi4"], optional = true } -napi-derive = { version = "2.12.0", optional = true } - -[dev-dependencies] -pretty_assertions = "1.3.0" diff --git a/packages/backend/native-utils/crates/util/Cargo.toml b/packages/backend/native-utils/crates/util/Cargo.toml deleted file mode 100644 index 6050342dd9..0000000000 --- a/packages/backend/native-utils/crates/util/Cargo.toml +++ /dev/null @@ -1,15 +0,0 @@ -[package] -name = "util" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -cuid2 = "0.1.0" -once_cell = "1.17.1" -rand = "0.8.5" -thiserror = "1.0.40" - -[dev-dependencies] -pretty_assertions = "1.3.0" diff --git a/packages/backend/native-utils/crates/migration/Cargo.toml b/packages/backend/native-utils/migration/Cargo.toml similarity index 100% rename from packages/backend/native-utils/crates/migration/Cargo.toml rename to packages/backend/native-utils/migration/Cargo.toml diff --git a/packages/backend/native-utils/crates/migration/README.md b/packages/backend/native-utils/migration/README.md similarity index 100% rename from packages/backend/native-utils/crates/migration/README.md rename to packages/backend/native-utils/migration/README.md diff --git a/packages/backend/native-utils/crates/migration/src/lib.rs b/packages/backend/native-utils/migration/src/lib.rs similarity index 100% rename from packages/backend/native-utils/crates/migration/src/lib.rs rename to packages/backend/native-utils/migration/src/lib.rs diff --git a/packages/backend/native-utils/crates/migration/src/m20230531_180824_drop_reversi.rs b/packages/backend/native-utils/migration/src/m20230531_180824_drop_reversi.rs similarity index 100% rename from packages/backend/native-utils/crates/migration/src/m20230531_180824_drop_reversi.rs rename to packages/backend/native-utils/migration/src/m20230531_180824_drop_reversi.rs diff --git a/packages/backend/native-utils/crates/migration/src/main.rs b/packages/backend/native-utils/migration/src/main.rs similarity index 100% rename from packages/backend/native-utils/crates/migration/src/main.rs rename to packages/backend/native-utils/migration/src/main.rs diff --git a/packages/backend/native-utils/crates/migration/src/vec_to_json.rs b/packages/backend/native-utils/migration/src/vec_to_json.rs similarity index 100% rename from packages/backend/native-utils/crates/migration/src/vec_to_json.rs rename to packages/backend/native-utils/migration/src/vec_to_json.rs diff --git a/packages/backend/native-utils/crates/database/src/error.rs b/packages/backend/native-utils/src/database/error.rs similarity index 100% rename from packages/backend/native-utils/crates/database/src/error.rs rename to packages/backend/native-utils/src/database/error.rs diff --git a/packages/backend/native-utils/crates/database/src/lib.rs b/packages/backend/native-utils/src/database/mod.rs similarity index 87% rename from packages/backend/native-utils/crates/database/src/lib.rs rename to packages/backend/native-utils/src/database/mod.rs index 0012d2292f..c3cdea7278 100644 --- a/packages/backend/native-utils/crates/database/src/lib.rs +++ b/packages/backend/native-utils/src/database/mod.rs @@ -1,9 +1,8 @@ pub mod error; +use error::Error; use sea_orm::{Database, DbConn}; -use crate::error::Error; - static DB_CONN: once_cell::sync::OnceCell = once_cell::sync::OnceCell::new(); pub async fn init_database(connection_uri: impl Into) -> Result<(), Error> { @@ -18,8 +17,7 @@ pub fn get_database() -> Result<&'static DbConn, Error> { #[cfg(test)] mod unit_test { - use super::get_database; - use crate::error::Error; + use super::{error::Error, get_database}; #[test] fn error_uninitialized() { diff --git a/packages/backend/native-utils/src/lib.rs b/packages/backend/native-utils/src/lib.rs index e131901406..6a5e3f7f2c 100644 --- a/packages/backend/native-utils/src/lib.rs +++ b/packages/backend/native-utils/src/lib.rs @@ -1 +1,6 @@ +pub mod database; +pub mod model; +pub mod util; + +#[cfg(feature = "napi")] pub mod mastodon_api; diff --git a/packages/backend/native-utils/crates/model/src/entity.rs b/packages/backend/native-utils/src/model/entity.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity.rs rename to packages/backend/native-utils/src/model/entity.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/abuse_user_report.rs b/packages/backend/native-utils/src/model/entity/abuse_user_report.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/abuse_user_report.rs rename to packages/backend/native-utils/src/model/entity/abuse_user_report.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/access_token.rs b/packages/backend/native-utils/src/model/entity/access_token.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/access_token.rs rename to packages/backend/native-utils/src/model/entity/access_token.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/ad.rs b/packages/backend/native-utils/src/model/entity/ad.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/ad.rs rename to packages/backend/native-utils/src/model/entity/ad.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/announcement.rs b/packages/backend/native-utils/src/model/entity/announcement.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/announcement.rs rename to packages/backend/native-utils/src/model/entity/announcement.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/announcement_read.rs b/packages/backend/native-utils/src/model/entity/announcement_read.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/announcement_read.rs rename to packages/backend/native-utils/src/model/entity/announcement_read.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/antenna.rs b/packages/backend/native-utils/src/model/entity/antenna.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/antenna.rs rename to packages/backend/native-utils/src/model/entity/antenna.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/antenna_note.rs b/packages/backend/native-utils/src/model/entity/antenna_note.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/antenna_note.rs rename to packages/backend/native-utils/src/model/entity/antenna_note.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/app.rs b/packages/backend/native-utils/src/model/entity/app.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/app.rs rename to packages/backend/native-utils/src/model/entity/app.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/attestation_challenge.rs b/packages/backend/native-utils/src/model/entity/attestation_challenge.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/attestation_challenge.rs rename to packages/backend/native-utils/src/model/entity/attestation_challenge.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/auth_session.rs b/packages/backend/native-utils/src/model/entity/auth_session.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/auth_session.rs rename to packages/backend/native-utils/src/model/entity/auth_session.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/blocking.rs b/packages/backend/native-utils/src/model/entity/blocking.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/blocking.rs rename to packages/backend/native-utils/src/model/entity/blocking.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/channel.rs b/packages/backend/native-utils/src/model/entity/channel.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/channel.rs rename to packages/backend/native-utils/src/model/entity/channel.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/channel_following.rs b/packages/backend/native-utils/src/model/entity/channel_following.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/channel_following.rs rename to packages/backend/native-utils/src/model/entity/channel_following.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/channel_note_pining.rs b/packages/backend/native-utils/src/model/entity/channel_note_pining.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/channel_note_pining.rs rename to packages/backend/native-utils/src/model/entity/channel_note_pining.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/clip.rs b/packages/backend/native-utils/src/model/entity/clip.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/clip.rs rename to packages/backend/native-utils/src/model/entity/clip.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/clip_note.rs b/packages/backend/native-utils/src/model/entity/clip_note.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/clip_note.rs rename to packages/backend/native-utils/src/model/entity/clip_note.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/drive_file.rs b/packages/backend/native-utils/src/model/entity/drive_file.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/drive_file.rs rename to packages/backend/native-utils/src/model/entity/drive_file.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/drive_folder.rs b/packages/backend/native-utils/src/model/entity/drive_folder.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/drive_folder.rs rename to packages/backend/native-utils/src/model/entity/drive_folder.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/emoji.rs b/packages/backend/native-utils/src/model/entity/emoji.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/emoji.rs rename to packages/backend/native-utils/src/model/entity/emoji.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/follow_request.rs b/packages/backend/native-utils/src/model/entity/follow_request.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/follow_request.rs rename to packages/backend/native-utils/src/model/entity/follow_request.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/following.rs b/packages/backend/native-utils/src/model/entity/following.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/following.rs rename to packages/backend/native-utils/src/model/entity/following.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/gallery_like.rs b/packages/backend/native-utils/src/model/entity/gallery_like.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/gallery_like.rs rename to packages/backend/native-utils/src/model/entity/gallery_like.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/gallery_post.rs b/packages/backend/native-utils/src/model/entity/gallery_post.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/gallery_post.rs rename to packages/backend/native-utils/src/model/entity/gallery_post.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/hashtag.rs b/packages/backend/native-utils/src/model/entity/hashtag.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/hashtag.rs rename to packages/backend/native-utils/src/model/entity/hashtag.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/instance.rs b/packages/backend/native-utils/src/model/entity/instance.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/instance.rs rename to packages/backend/native-utils/src/model/entity/instance.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/messaging_message.rs b/packages/backend/native-utils/src/model/entity/messaging_message.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/messaging_message.rs rename to packages/backend/native-utils/src/model/entity/messaging_message.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/meta.rs b/packages/backend/native-utils/src/model/entity/meta.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/meta.rs rename to packages/backend/native-utils/src/model/entity/meta.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/migrations.rs b/packages/backend/native-utils/src/model/entity/migrations.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/migrations.rs rename to packages/backend/native-utils/src/model/entity/migrations.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/moderation_log.rs b/packages/backend/native-utils/src/model/entity/moderation_log.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/moderation_log.rs rename to packages/backend/native-utils/src/model/entity/moderation_log.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/muted_note.rs b/packages/backend/native-utils/src/model/entity/muted_note.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/muted_note.rs rename to packages/backend/native-utils/src/model/entity/muted_note.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/muting.rs b/packages/backend/native-utils/src/model/entity/muting.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/muting.rs rename to packages/backend/native-utils/src/model/entity/muting.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/newtype/macros.rs b/packages/backend/native-utils/src/model/entity/newtype/macros.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/newtype/macros.rs rename to packages/backend/native-utils/src/model/entity/newtype/macros.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/newtype/mod.rs b/packages/backend/native-utils/src/model/entity/newtype/mod.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/newtype/mod.rs rename to packages/backend/native-utils/src/model/entity/newtype/mod.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/note.rs b/packages/backend/native-utils/src/model/entity/note.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/note.rs rename to packages/backend/native-utils/src/model/entity/note.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/note_edit.rs b/packages/backend/native-utils/src/model/entity/note_edit.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/note_edit.rs rename to packages/backend/native-utils/src/model/entity/note_edit.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/note_favorite.rs b/packages/backend/native-utils/src/model/entity/note_favorite.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/note_favorite.rs rename to packages/backend/native-utils/src/model/entity/note_favorite.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/note_reaction.rs b/packages/backend/native-utils/src/model/entity/note_reaction.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/note_reaction.rs rename to packages/backend/native-utils/src/model/entity/note_reaction.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/note_thread_muting.rs b/packages/backend/native-utils/src/model/entity/note_thread_muting.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/note_thread_muting.rs rename to packages/backend/native-utils/src/model/entity/note_thread_muting.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/note_unread.rs b/packages/backend/native-utils/src/model/entity/note_unread.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/note_unread.rs rename to packages/backend/native-utils/src/model/entity/note_unread.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/note_watching.rs b/packages/backend/native-utils/src/model/entity/note_watching.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/note_watching.rs rename to packages/backend/native-utils/src/model/entity/note_watching.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/notification.rs b/packages/backend/native-utils/src/model/entity/notification.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/notification.rs rename to packages/backend/native-utils/src/model/entity/notification.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/page.rs b/packages/backend/native-utils/src/model/entity/page.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/page.rs rename to packages/backend/native-utils/src/model/entity/page.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/page_like.rs b/packages/backend/native-utils/src/model/entity/page_like.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/page_like.rs rename to packages/backend/native-utils/src/model/entity/page_like.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/password_reset_request.rs b/packages/backend/native-utils/src/model/entity/password_reset_request.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/password_reset_request.rs rename to packages/backend/native-utils/src/model/entity/password_reset_request.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/poll.rs b/packages/backend/native-utils/src/model/entity/poll.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/poll.rs rename to packages/backend/native-utils/src/model/entity/poll.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/poll_vote.rs b/packages/backend/native-utils/src/model/entity/poll_vote.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/poll_vote.rs rename to packages/backend/native-utils/src/model/entity/poll_vote.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/prelude.rs b/packages/backend/native-utils/src/model/entity/prelude.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/prelude.rs rename to packages/backend/native-utils/src/model/entity/prelude.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/promo_note.rs b/packages/backend/native-utils/src/model/entity/promo_note.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/promo_note.rs rename to packages/backend/native-utils/src/model/entity/promo_note.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/promo_read.rs b/packages/backend/native-utils/src/model/entity/promo_read.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/promo_read.rs rename to packages/backend/native-utils/src/model/entity/promo_read.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/registration_ticket.rs b/packages/backend/native-utils/src/model/entity/registration_ticket.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/registration_ticket.rs rename to packages/backend/native-utils/src/model/entity/registration_ticket.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/registry_item.rs b/packages/backend/native-utils/src/model/entity/registry_item.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/registry_item.rs rename to packages/backend/native-utils/src/model/entity/registry_item.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/relay.rs b/packages/backend/native-utils/src/model/entity/relay.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/relay.rs rename to packages/backend/native-utils/src/model/entity/relay.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/renote_muting.rs b/packages/backend/native-utils/src/model/entity/renote_muting.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/renote_muting.rs rename to packages/backend/native-utils/src/model/entity/renote_muting.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/sea_orm_active_enums.rs b/packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/sea_orm_active_enums.rs rename to packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/signin.rs b/packages/backend/native-utils/src/model/entity/signin.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/signin.rs rename to packages/backend/native-utils/src/model/entity/signin.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/sw_subscription.rs b/packages/backend/native-utils/src/model/entity/sw_subscription.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/sw_subscription.rs rename to packages/backend/native-utils/src/model/entity/sw_subscription.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/used_username.rs b/packages/backend/native-utils/src/model/entity/used_username.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/used_username.rs rename to packages/backend/native-utils/src/model/entity/used_username.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user.rs b/packages/backend/native-utils/src/model/entity/user.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user.rs rename to packages/backend/native-utils/src/model/entity/user.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_group.rs b/packages/backend/native-utils/src/model/entity/user_group.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_group.rs rename to packages/backend/native-utils/src/model/entity/user_group.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_group_invitation.rs b/packages/backend/native-utils/src/model/entity/user_group_invitation.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_group_invitation.rs rename to packages/backend/native-utils/src/model/entity/user_group_invitation.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_group_invite.rs b/packages/backend/native-utils/src/model/entity/user_group_invite.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_group_invite.rs rename to packages/backend/native-utils/src/model/entity/user_group_invite.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_group_joining.rs b/packages/backend/native-utils/src/model/entity/user_group_joining.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_group_joining.rs rename to packages/backend/native-utils/src/model/entity/user_group_joining.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_ip.rs b/packages/backend/native-utils/src/model/entity/user_ip.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_ip.rs rename to packages/backend/native-utils/src/model/entity/user_ip.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_keypair.rs b/packages/backend/native-utils/src/model/entity/user_keypair.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_keypair.rs rename to packages/backend/native-utils/src/model/entity/user_keypair.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_list.rs b/packages/backend/native-utils/src/model/entity/user_list.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_list.rs rename to packages/backend/native-utils/src/model/entity/user_list.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_list_joining.rs b/packages/backend/native-utils/src/model/entity/user_list_joining.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_list_joining.rs rename to packages/backend/native-utils/src/model/entity/user_list_joining.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_note_pining.rs b/packages/backend/native-utils/src/model/entity/user_note_pining.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_note_pining.rs rename to packages/backend/native-utils/src/model/entity/user_note_pining.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_pending.rs b/packages/backend/native-utils/src/model/entity/user_pending.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_pending.rs rename to packages/backend/native-utils/src/model/entity/user_pending.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_profile.rs b/packages/backend/native-utils/src/model/entity/user_profile.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_profile.rs rename to packages/backend/native-utils/src/model/entity/user_profile.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_publickey.rs b/packages/backend/native-utils/src/model/entity/user_publickey.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_publickey.rs rename to packages/backend/native-utils/src/model/entity/user_publickey.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/user_security_key.rs b/packages/backend/native-utils/src/model/entity/user_security_key.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/user_security_key.rs rename to packages/backend/native-utils/src/model/entity/user_security_key.rs diff --git a/packages/backend/native-utils/crates/model/src/entity/webhook.rs b/packages/backend/native-utils/src/model/entity/webhook.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/entity/webhook.rs rename to packages/backend/native-utils/src/model/entity/webhook.rs diff --git a/packages/backend/native-utils/crates/model/src/error.rs b/packages/backend/native-utils/src/model/error.rs similarity index 62% rename from packages/backend/native-utils/crates/model/src/error.rs rename to packages/backend/native-utils/src/model/error.rs index c90f3f5a32..2292246aed 100644 --- a/packages/backend/native-utils/crates/model/src/error.rs +++ b/packages/backend/native-utils/src/model/error.rs @@ -3,9 +3,16 @@ pub enum Error { #[error("Failed to parse string")] ParseError(#[from] parse_display::ParseError), #[error("Failed to get database connection")] - DbConnError(#[from] database::error::Error), + DbConnError(#[from] crate::database::error::Error), #[error("Database operation error: {0}")] DbOperationError(#[from] sea_orm::DbErr), #[error("Requested entity not found")] NotFound, } + +#[cfg(feature = "napi")] +impl Into for Error { + fn into(self) -> napi::Error { + napi::Error::from_reason(self.to_string()) + } +} diff --git a/packages/backend/native-utils/crates/model/src/lib.rs b/packages/backend/native-utils/src/model/mod.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/lib.rs rename to packages/backend/native-utils/src/model/mod.rs diff --git a/packages/backend/native-utils/crates/model/src/repository.rs b/packages/backend/native-utils/src/model/repository.rs similarity index 75% rename from packages/backend/native-utils/crates/model/src/repository.rs rename to packages/backend/native-utils/src/model/repository.rs index 83573ab160..0f9f7de329 100644 --- a/packages/backend/native-utils/crates/model/src/repository.rs +++ b/packages/backend/native-utils/src/model/repository.rs @@ -3,7 +3,7 @@ pub mod antenna; use async_trait::async_trait; use schemars::JsonSchema; -use crate::error::Error; +use super::error::Error; #[async_trait] pub trait Repository { @@ -14,7 +14,10 @@ pub trait Repository { mod macros { macro_rules! impl_pack_by_id { ($a:ty, $b:ident) => { - match <$a>::find_by_id($b).one(database::get_database()?).await? { + match <$a>::find_by_id($b) + .one(crate::database::get_database()?) + .await? + { None => Err(Error::NotFound), Some(m) => m.pack().await, } diff --git a/packages/backend/native-utils/crates/model/src/repository/antenna.rs b/packages/backend/native-utils/src/model/repository/antenna.rs similarity index 92% rename from packages/backend/native-utils/crates/model/src/repository/antenna.rs rename to packages/backend/native-utils/src/model/repository/antenna.rs index c8324edd34..7c614b954b 100644 --- a/packages/backend/native-utils/crates/model/src/repository/antenna.rs +++ b/packages/backend/native-utils/src/model/repository/antenna.rs @@ -2,9 +2,10 @@ use async_trait::async_trait; use cfg_if::cfg_if; use sea_orm::{ColumnTrait, EntityTrait, QueryFilter}; -use crate::entity::{antenna, antenna_note, user_group_joining}; -use crate::error::Error; -use crate::schema::Antenna; +use crate::database; +use crate::model::entity::{antenna, antenna_note, user_group_joining}; +use crate::model::error::Error; +use crate::model::schema::Antenna; use super::macros::impl_pack_by_id; use super::Repository; diff --git a/packages/backend/native-utils/crates/model/src/schema.rs b/packages/backend/native-utils/src/model/schema.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/schema.rs rename to packages/backend/native-utils/src/model/schema.rs diff --git a/packages/backend/native-utils/crates/model/src/schema/antenna.rs b/packages/backend/native-utils/src/model/schema/antenna.rs similarity index 93% rename from packages/backend/native-utils/crates/model/src/schema/antenna.rs rename to packages/backend/native-utils/src/model/schema/antenna.rs index 338998019c..6376b3bc73 100644 --- a/packages/backend/native-utils/crates/model/src/schema/antenna.rs +++ b/packages/backend/native-utils/src/model/schema/antenna.rs @@ -5,7 +5,8 @@ use schemars::JsonSchema; use utoipa::ToSchema; use super::Schema; -use crate::entity::sea_orm_active_enums::AntennaSrcEnum; +use crate::model; +use crate::model::entity::sea_orm_active_enums::AntennaSrcEnum; #[derive(Clone, Debug, PartialEq, Eq, JsonSchema, ToSchema)] #[serde(rename_all = "camelCase")] @@ -47,10 +48,10 @@ pub enum AntennaSrc { } impl TryFrom for super::AntennaSrc { - type Error = crate::error::Error; + type Error = model::error::Error; fn try_from(value: AntennaSrcEnum) -> Result { - value.to_string().parse().map_err(crate::error::Error::from) + value.to_string().parse().map_err(model::error::Error::from) } } @@ -64,7 +65,7 @@ mod unit_test { use pretty_assertions::assert_eq; use serde_json::json; - use crate::{entity::sea_orm_active_enums::AntennaSrcEnum, schema::AntennaSrc}; + use crate::model::{entity::sea_orm_active_enums::AntennaSrcEnum, schema::AntennaSrc}; use super::VALIDATOR; diff --git a/packages/backend/native-utils/crates/model/src/schema/app.rs b/packages/backend/native-utils/src/model/schema/app.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/schema/app.rs rename to packages/backend/native-utils/src/model/schema/app.rs diff --git a/packages/backend/native-utils/crates/model/src/schema/napi.rs b/packages/backend/native-utils/src/model/schema/napi.rs similarity index 100% rename from packages/backend/native-utils/crates/model/src/schema/napi.rs rename to packages/backend/native-utils/src/model/schema/napi.rs diff --git a/packages/backend/native-utils/crates/model/src/schema/napi/antenna.rs b/packages/backend/native-utils/src/model/schema/napi/antenna.rs similarity index 78% rename from packages/backend/native-utils/crates/model/src/schema/napi/antenna.rs rename to packages/backend/native-utils/src/model/schema/napi/antenna.rs index ffb817c123..e5c156efad 100644 --- a/packages/backend/native-utils/crates/model/src/schema/napi/antenna.rs +++ b/packages/backend/native-utils/src/model/schema/napi/antenna.rs @@ -1,9 +1,12 @@ -use napi::bindgen_prelude::{FromNapiValue, ToNapiValue}; +use napi::bindgen_prelude::*; use napi_derive::napi; use parse_display::FromStr; use schemars::JsonSchema; use utoipa::ToSchema; +use crate::model::entity::antenna::Model; +use crate::model::repository::Repository; + #[napi] #[derive(Clone, Debug, PartialEq, Eq, JsonSchema, ToSchema)] #[serde(rename_all = "camelCase")] @@ -44,3 +47,11 @@ pub enum AntennaSrc { Group, Instances, } + +#[napi] +impl Antenna { + #[napi] + pub async fn pack_by_id(id: String) -> napi::Result { + Model::pack_by_id(id).await.map_err(Into::into) + } +} diff --git a/packages/backend/native-utils/crates/util/src/id.rs b/packages/backend/native-utils/src/util/id.rs similarity index 97% rename from packages/backend/native-utils/crates/util/src/id.rs rename to packages/backend/native-utils/src/util/id.rs index d3c5809ea5..98dd63c4e5 100644 --- a/packages/backend/native-utils/crates/util/src/id.rs +++ b/packages/backend/native-utils/src/util/id.rs @@ -25,7 +25,7 @@ mod unit_test { use pretty_assertions::{assert_eq, assert_ne}; use std::thread; - use crate::id; + use crate::util::id; #[test] fn can_generate_unique_ids() { diff --git a/packages/backend/native-utils/crates/util/src/lib.rs b/packages/backend/native-utils/src/util/mod.rs similarity index 100% rename from packages/backend/native-utils/crates/util/src/lib.rs rename to packages/backend/native-utils/src/util/mod.rs diff --git a/packages/backend/native-utils/crates/util/src/random.rs b/packages/backend/native-utils/src/util/random.rs similarity index 100% rename from packages/backend/native-utils/crates/util/src/random.rs rename to packages/backend/native-utils/src/util/random.rs diff --git a/packages/backend/native-utils/crates/model/tests/common.rs b/packages/backend/native-utils/tests/common.rs similarity index 96% rename from packages/backend/native-utils/crates/model/tests/common.rs rename to packages/backend/native-utils/tests/common.rs index 554a8ca735..775b372126 100644 --- a/packages/backend/native-utils/crates/model/tests/common.rs +++ b/packages/backend/native-utils/tests/common.rs @@ -1,20 +1,19 @@ #![cfg(not(feature = "napi"))] -extern crate model; - -mod repository; +mod model; use chrono::Utc; -use model::entity; -use model::entity::sea_orm_active_enums::AntennaSrcEnum; +use native_utils::database; +use native_utils::model::entity; +use native_utils::model::entity::sea_orm_active_enums::AntennaSrcEnum; +use native_utils::util::{ + id::{create_id, init_id}, + random::gen_string, +}; use sea_orm::{ sea_query::TableCreateStatement, ActiveModelTrait, ConnectionTrait, DbBackend, DbConn, DbErr, EntityTrait, IntoActiveModel, TransactionTrait, }; -use util::{ - id::{create_id, init_id}, - random::gen_string, -}; /// Insert predefined entries in the database. async fn prepare() { diff --git a/packages/backend/native-utils/tests/model/mod.rs b/packages/backend/native-utils/tests/model/mod.rs new file mode 100644 index 0000000000..a35bac056b --- /dev/null +++ b/packages/backend/native-utils/tests/model/mod.rs @@ -0,0 +1 @@ +mod repository; diff --git a/packages/backend/native-utils/crates/model/tests/repository/mod.rs b/packages/backend/native-utils/tests/model/repository.rs similarity index 100% rename from packages/backend/native-utils/crates/model/tests/repository/mod.rs rename to packages/backend/native-utils/tests/model/repository.rs diff --git a/packages/backend/native-utils/crates/model/tests/repository/antenna.rs b/packages/backend/native-utils/tests/model/repository/antenna.rs similarity index 97% rename from packages/backend/native-utils/crates/model/tests/repository/antenna.rs rename to packages/backend/native-utils/tests/model/repository/antenna.rs index 2da1e59d44..a370073987 100644 --- a/packages/backend/native-utils/crates/model/tests/repository/antenna.rs +++ b/packages/backend/native-utils/tests/model/repository/antenna.rs @@ -1,4 +1,6 @@ mod int_test { + use native_utils::{database, model}; + use model::{ entity::{antenna, user}, repository::Repository,