diff --git a/Makefile b/Makefile index 7d6b1f8a..4b08955c 100644 --- a/Makefile +++ b/Makefile @@ -31,8 +31,11 @@ regenerate-entities: cd packages/backend/native-utils && \ sea-orm-cli generate entity \ --output-dir='src/model/entity' \ - --database-url='postgres://firefish:password@localhost:25432/firefish_db' - + --database-url='postgres://firefish:password@localhost:25432/firefish_db' \ + --date-time-crate='chrono' \ + --model-extra-attributes='napi_derive::napi(object)' + sed -i 's/#\[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)\]/#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]\n#[napi_derive::napi]/' \ + packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs .PHONY: update-index-js update-index-js: diff --git a/neko/index.js b/neko/index.js index ebfc5d97..56e51763 100644 --- a/neko/index.js +++ b/neko/index.js @@ -269,6 +269,18 @@ const { EnvConfig, readEnvironmentConfig, readServerConfig, + AntennaSrcEnum, + MetaSensitivemediadetectionEnum, + MetaSensitivemediadetectionsensitivityEnum, + MutedNoteReasonEnum, + NoteVisibilityEnum, + NotificationTypeEnum, + PageVisibilityEnum, + PollNotevisibilityEnum, + RelayStatusEnum, + UserEmojimodpermEnum, + UserProfileFfvisibilityEnum, + UserProfileMutingnotificationtypesEnum, stringToAcct, acctToString, getFullApAccount, @@ -280,17 +292,32 @@ const { sqlLikeEscape, safeForSql, formatMilliseconds, + nativeInitIdGenerator, + nativeCreateId, + nativeGetTimestamp, genString, IdConvertType, convertId, - nativeGetTimestamp, - nativeCreateId, - nativeInitIdGenerator, } = nativeBinding; module.exports.EnvConfig = EnvConfig; module.exports.readEnvironmentConfig = readEnvironmentConfig; module.exports.readServerConfig = readServerConfig; +module.exports.AntennaSrcEnum = AntennaSrcEnum; +module.exports.MetaSensitivemediadetectionEnum = + MetaSensitivemediadetectionEnum; +module.exports.MetaSensitivemediadetectionsensitivityEnum = + MetaSensitivemediadetectionsensitivityEnum; +module.exports.MutedNoteReasonEnum = MutedNoteReasonEnum; +module.exports.NoteVisibilityEnum = NoteVisibilityEnum; +module.exports.NotificationTypeEnum = NotificationTypeEnum; +module.exports.PageVisibilityEnum = PageVisibilityEnum; +module.exports.PollNotevisibilityEnum = PollNotevisibilityEnum; +module.exports.RelayStatusEnum = RelayStatusEnum; +module.exports.UserEmojimodpermEnum = UserEmojimodpermEnum; +module.exports.UserProfileFfvisibilityEnum = UserProfileFfvisibilityEnum; +module.exports.UserProfileMutingnotificationtypesEnum = + UserProfileMutingnotificationtypesEnum; module.exports.stringToAcct = stringToAcct; module.exports.acctToString = acctToString; module.exports.getFullApAccount = getFullApAccount; @@ -302,9 +329,9 @@ module.exports.convertToHiddenPost = convertToHiddenPost; module.exports.sqlLikeEscape = sqlLikeEscape; module.exports.safeForSql = safeForSql; module.exports.formatMilliseconds = formatMilliseconds; +module.exports.nativeInitIdGenerator = nativeInitIdGenerator; +module.exports.nativeCreateId = nativeCreateId; +module.exports.nativeGetTimestamp = nativeGetTimestamp; module.exports.genString = genString; module.exports.IdConvertType = IdConvertType; module.exports.convertId = convertId; -module.exports.nativeGetTimestamp = nativeGetTimestamp; -module.exports.nativeCreateId = nativeCreateId; -module.exports.nativeInitIdGenerator = nativeInitIdGenerator; diff --git a/packages/backend/native-utils/Cargo.lock b/packages/backend/native-utils/Cargo.lock index ad483e91..eb41326c 100644 --- a/packages/backend/native-utils/Cargo.lock +++ b/packages/backend/native-utils/Cargo.lock @@ -1351,10 +1351,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fc1cb00cde484640da9f01a124edbb013576a6ae9843b23857c940936b76d91" dependencies = [ "bitflags 2.4.2", + "chrono", "ctor", "napi-derive", "napi-sys", "once_cell", + "serde", + "serde_json", "tokio", ] diff --git a/packages/backend/native-utils/Cargo.toml b/packages/backend/native-utils/Cargo.toml index 0c7d3ac1..161d1820 100644 --- a/packages/backend/native-utils/Cargo.toml +++ b/packages/backend/native-utils/Cargo.toml @@ -7,7 +7,7 @@ version = "0.0.0" members = ["migration"] [features] -default = [] +default = ["napi"] napi = ["dep:napi-derive"] [lib] @@ -33,7 +33,7 @@ tokio = { version = "1.35.1", features = ["full"] } url = "2.5.0" # Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix -napi = { version = "2.14.2", default-features = false, features = ["napi9", "tokio_rt"] } +napi = { version = "2.14.2", default-features = false, features = ["napi9", "tokio_rt", "chrono_date", "serde-json"] } napi-derive = { version = "2.14.6", optional = true } basen = "0.1.0" diff --git a/packages/backend/native-utils/src/database/error.rs b/packages/backend/native-utils/src/database/error.rs index 68e959e0..f180870f 100644 --- a/packages/backend/native-utils/src/database/error.rs +++ b/packages/backend/native-utils/src/database/error.rs @@ -1,6 +1,6 @@ use sea_orm::error::DbErr; -use crate::impl_into_napi_error; +use crate::impl_napi_error_from; #[derive(thiserror::Error, Debug, PartialEq, Eq)] pub enum Error { @@ -10,4 +10,4 @@ pub enum Error { OrmError(#[from] DbErr), } -impl_into_napi_error!(Error); +impl_napi_error_from!(Error); diff --git a/packages/backend/native-utils/src/lib.rs b/packages/backend/native-utils/src/lib.rs index 9e0bd3ec..2c57743e 100644 --- a/packages/backend/native-utils/src/lib.rs +++ b/packages/backend/native-utils/src/lib.rs @@ -4,5 +4,5 @@ pub mod macros; pub mod model; pub mod util; -#[cfg(feature = "napi")] +// #[cfg(feature = "napi")] pub mod mastodon_api; diff --git a/packages/backend/native-utils/src/macros.rs b/packages/backend/native-utils/src/macros.rs index 49ab8263..b2549227 100644 --- a/packages/backend/native-utils/src/macros.rs +++ b/packages/backend/native-utils/src/macros.rs @@ -1,10 +1,10 @@ #[macro_export] -macro_rules! impl_into_napi_error { +macro_rules! impl_napi_error_from { ($a:ty) => { #[cfg(feature = "napi")] - impl Into for $a { - fn into(self) -> napi::Error { - napi::Error::from_reason(self.to_string()) + impl From<$a> for napi::Error { + fn from(reason: $a) -> napi::Error { + napi::Error::from_reason(reason.to_string()) } } }; diff --git a/packages/backend/native-utils/src/model/entity/abuse_user_report.rs b/packages/backend/native-utils/src/model/entity/abuse_user_report.rs index 72ec038f..cdea8b46 100644 --- a/packages/backend/native-utils/src/model/entity/abuse_user_report.rs +++ b/packages/backend/native-utils/src/model/entity/abuse_user_report.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "abuse_user_report")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/access_token.rs b/packages/backend/native-utils/src/model/entity/access_token.rs index 8609d569..65bcb211 100644 --- a/packages/backend/native-utils/src/model/entity/access_token.rs +++ b/packages/backend/native-utils/src/model/entity/access_token.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "access_token")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/ad.rs b/packages/backend/native-utils/src/model/entity/ad.rs index 74769685..cd06ebf0 100644 --- a/packages/backend/native-utils/src/model/entity/ad.rs +++ b/packages/backend/native-utils/src/model/entity/ad.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "ad")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/announcement.rs b/packages/backend/native-utils/src/model/entity/announcement.rs index 07c0f334..2fe42835 100644 --- a/packages/backend/native-utils/src/model/entity/announcement.rs +++ b/packages/backend/native-utils/src/model/entity/announcement.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "announcement")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/announcement_read.rs b/packages/backend/native-utils/src/model/entity/announcement_read.rs index 82317525..bb524a0f 100644 --- a/packages/backend/native-utils/src/model/entity/announcement_read.rs +++ b/packages/backend/native-utils/src/model/entity/announcement_read.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "announcement_read")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/antenna.rs b/packages/backend/native-utils/src/model/entity/antenna.rs index 66474b72..1a8d923f 100644 --- a/packages/backend/native-utils/src/model/entity/antenna.rs +++ b/packages/backend/native-utils/src/model/entity/antenna.rs @@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "antenna")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/app.rs b/packages/backend/native-utils/src/model/entity/app.rs index d7c7eedb..3d05eab2 100644 --- a/packages/backend/native-utils/src/model/entity/app.rs +++ b/packages/backend/native-utils/src/model/entity/app.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "app")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/attestation_challenge.rs b/packages/backend/native-utils/src/model/entity/attestation_challenge.rs index ca9b8cf3..d5242dff 100644 --- a/packages/backend/native-utils/src/model/entity/attestation_challenge.rs +++ b/packages/backend/native-utils/src/model/entity/attestation_challenge.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "attestation_challenge")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/auth_session.rs b/packages/backend/native-utils/src/model/entity/auth_session.rs index 63df331d..9ff792ec 100644 --- a/packages/backend/native-utils/src/model/entity/auth_session.rs +++ b/packages/backend/native-utils/src/model/entity/auth_session.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "auth_session")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/blocking.rs b/packages/backend/native-utils/src/model/entity/blocking.rs index 2a8ad366..f10039e7 100644 --- a/packages/backend/native-utils/src/model/entity/blocking.rs +++ b/packages/backend/native-utils/src/model/entity/blocking.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "blocking")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/channel.rs b/packages/backend/native-utils/src/model/entity/channel.rs index 64415405..785f0a4d 100644 --- a/packages/backend/native-utils/src/model/entity/channel.rs +++ b/packages/backend/native-utils/src/model/entity/channel.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "channel")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/channel_following.rs b/packages/backend/native-utils/src/model/entity/channel_following.rs index 67a0492e..ac1c8d13 100644 --- a/packages/backend/native-utils/src/model/entity/channel_following.rs +++ b/packages/backend/native-utils/src/model/entity/channel_following.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "channel_following")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/channel_note_pining.rs b/packages/backend/native-utils/src/model/entity/channel_note_pining.rs index bcd3f72e..f885400a 100644 --- a/packages/backend/native-utils/src/model/entity/channel_note_pining.rs +++ b/packages/backend/native-utils/src/model/entity/channel_note_pining.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "channel_note_pining")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/clip.rs b/packages/backend/native-utils/src/model/entity/clip.rs index 7838df9e..0f285879 100644 --- a/packages/backend/native-utils/src/model/entity/clip.rs +++ b/packages/backend/native-utils/src/model/entity/clip.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "clip")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/clip_note.rs b/packages/backend/native-utils/src/model/entity/clip_note.rs index 28f599a3..29c174f5 100644 --- a/packages/backend/native-utils/src/model/entity/clip_note.rs +++ b/packages/backend/native-utils/src/model/entity/clip_note.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "clip_note")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/drive_file.rs b/packages/backend/native-utils/src/model/entity/drive_file.rs index 406e3e1d..5ce766dc 100644 --- a/packages/backend/native-utils/src/model/entity/drive_file.rs +++ b/packages/backend/native-utils/src/model/entity/drive_file.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "drive_file")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/drive_folder.rs b/packages/backend/native-utils/src/model/entity/drive_folder.rs index 3906b401..48d39f2f 100644 --- a/packages/backend/native-utils/src/model/entity/drive_folder.rs +++ b/packages/backend/native-utils/src/model/entity/drive_folder.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "drive_folder")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/emoji.rs b/packages/backend/native-utils/src/model/entity/emoji.rs index fc479a2d..87835b30 100644 --- a/packages/backend/native-utils/src/model/entity/emoji.rs +++ b/packages/backend/native-utils/src/model/entity/emoji.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "emoji")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/follow_request.rs b/packages/backend/native-utils/src/model/entity/follow_request.rs index be2e3864..892327ed 100644 --- a/packages/backend/native-utils/src/model/entity/follow_request.rs +++ b/packages/backend/native-utils/src/model/entity/follow_request.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "follow_request")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/following.rs b/packages/backend/native-utils/src/model/entity/following.rs index c6313cd2..015896e8 100644 --- a/packages/backend/native-utils/src/model/entity/following.rs +++ b/packages/backend/native-utils/src/model/entity/following.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "following")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/gallery_like.rs b/packages/backend/native-utils/src/model/entity/gallery_like.rs index 0a41c09e..58673dc3 100644 --- a/packages/backend/native-utils/src/model/entity/gallery_like.rs +++ b/packages/backend/native-utils/src/model/entity/gallery_like.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "gallery_like")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/gallery_post.rs b/packages/backend/native-utils/src/model/entity/gallery_post.rs index 2a868929..98ff7a43 100644 --- a/packages/backend/native-utils/src/model/entity/gallery_post.rs +++ b/packages/backend/native-utils/src/model/entity/gallery_post.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "gallery_post")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/hashtag.rs b/packages/backend/native-utils/src/model/entity/hashtag.rs index 568e6a15..71aa49f6 100644 --- a/packages/backend/native-utils/src/model/entity/hashtag.rs +++ b/packages/backend/native-utils/src/model/entity/hashtag.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "hashtag")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/instance.rs b/packages/backend/native-utils/src/model/entity/instance.rs index b95ffbec..1f550436 100644 --- a/packages/backend/native-utils/src/model/entity/instance.rs +++ b/packages/backend/native-utils/src/model/entity/instance.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "instance")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/messaging_message.rs b/packages/backend/native-utils/src/model/entity/messaging_message.rs index 3e9bb864..02be149c 100644 --- a/packages/backend/native-utils/src/model/entity/messaging_message.rs +++ b/packages/backend/native-utils/src/model/entity/messaging_message.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "messaging_message")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/meta.rs b/packages/backend/native-utils/src/model/entity/meta.rs index 51b689c9..27a33fdd 100644 --- a/packages/backend/native-utils/src/model/entity/meta.rs +++ b/packages/backend/native-utils/src/model/entity/meta.rs @@ -6,6 +6,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "meta")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/migrations.rs b/packages/backend/native-utils/src/model/entity/migrations.rs index 4d67361c..2c591d70 100644 --- a/packages/backend/native-utils/src/model/entity/migrations.rs +++ b/packages/backend/native-utils/src/model/entity/migrations.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "migrations")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key)] pub id: i32, diff --git a/packages/backend/native-utils/src/model/entity/moderation_log.rs b/packages/backend/native-utils/src/model/entity/moderation_log.rs index 9e7003f0..fc642350 100644 --- a/packages/backend/native-utils/src/model/entity/moderation_log.rs +++ b/packages/backend/native-utils/src/model/entity/moderation_log.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "moderation_log")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/muted_note.rs b/packages/backend/native-utils/src/model/entity/muted_note.rs index 037f8fa8..99b648bd 100644 --- a/packages/backend/native-utils/src/model/entity/muted_note.rs +++ b/packages/backend/native-utils/src/model/entity/muted_note.rs @@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "muted_note")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/muting.rs b/packages/backend/native-utils/src/model/entity/muting.rs index e852391d..62617bf1 100644 --- a/packages/backend/native-utils/src/model/entity/muting.rs +++ b/packages/backend/native-utils/src/model/entity/muting.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "muting")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/note.rs b/packages/backend/native-utils/src/model/entity/note.rs index c5491915..b9292685 100644 --- a/packages/backend/native-utils/src/model/entity/note.rs +++ b/packages/backend/native-utils/src/model/entity/note.rs @@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "note")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/note_edit.rs b/packages/backend/native-utils/src/model/entity/note_edit.rs index 6b5e3f04..b619c069 100644 --- a/packages/backend/native-utils/src/model/entity/note_edit.rs +++ b/packages/backend/native-utils/src/model/entity/note_edit.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "note_edit")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/note_favorite.rs b/packages/backend/native-utils/src/model/entity/note_favorite.rs index e1b2c31d..f1e78cac 100644 --- a/packages/backend/native-utils/src/model/entity/note_favorite.rs +++ b/packages/backend/native-utils/src/model/entity/note_favorite.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "note_favorite")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/note_reaction.rs b/packages/backend/native-utils/src/model/entity/note_reaction.rs index ad6b385d..dd1bc266 100644 --- a/packages/backend/native-utils/src/model/entity/note_reaction.rs +++ b/packages/backend/native-utils/src/model/entity/note_reaction.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "note_reaction")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/note_thread_muting.rs b/packages/backend/native-utils/src/model/entity/note_thread_muting.rs index 84fd0f31..07883afa 100644 --- a/packages/backend/native-utils/src/model/entity/note_thread_muting.rs +++ b/packages/backend/native-utils/src/model/entity/note_thread_muting.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "note_thread_muting")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/note_unread.rs b/packages/backend/native-utils/src/model/entity/note_unread.rs index 6f6cb3d6..62a8dbde 100644 --- a/packages/backend/native-utils/src/model/entity/note_unread.rs +++ b/packages/backend/native-utils/src/model/entity/note_unread.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "note_unread")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/note_watching.rs b/packages/backend/native-utils/src/model/entity/note_watching.rs index 8febf363..aee1c0ea 100644 --- a/packages/backend/native-utils/src/model/entity/note_watching.rs +++ b/packages/backend/native-utils/src/model/entity/note_watching.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "note_watching")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/notification.rs b/packages/backend/native-utils/src/model/entity/notification.rs index 72f01f29..5da963a4 100644 --- a/packages/backend/native-utils/src/model/entity/notification.rs +++ b/packages/backend/native-utils/src/model/entity/notification.rs @@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "notification")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/page.rs b/packages/backend/native-utils/src/model/entity/page.rs index fe59a50b..ea5c4c13 100644 --- a/packages/backend/native-utils/src/model/entity/page.rs +++ b/packages/backend/native-utils/src/model/entity/page.rs @@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "page")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/page_like.rs b/packages/backend/native-utils/src/model/entity/page_like.rs index c608dcf4..dec0f5bf 100644 --- a/packages/backend/native-utils/src/model/entity/page_like.rs +++ b/packages/backend/native-utils/src/model/entity/page_like.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "page_like")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/password_reset_request.rs b/packages/backend/native-utils/src/model/entity/password_reset_request.rs index a4610b17..ac95ce67 100644 --- a/packages/backend/native-utils/src/model/entity/password_reset_request.rs +++ b/packages/backend/native-utils/src/model/entity/password_reset_request.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "password_reset_request")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/poll.rs b/packages/backend/native-utils/src/model/entity/poll.rs index 9418ad6a..eed95473 100644 --- a/packages/backend/native-utils/src/model/entity/poll.rs +++ b/packages/backend/native-utils/src/model/entity/poll.rs @@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "poll")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)] pub note_id: String, diff --git a/packages/backend/native-utils/src/model/entity/poll_vote.rs b/packages/backend/native-utils/src/model/entity/poll_vote.rs index 0990dab9..68040fcf 100644 --- a/packages/backend/native-utils/src/model/entity/poll_vote.rs +++ b/packages/backend/native-utils/src/model/entity/poll_vote.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "poll_vote")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/promo_note.rs b/packages/backend/native-utils/src/model/entity/promo_note.rs index 1ee07df3..6fd235e1 100644 --- a/packages/backend/native-utils/src/model/entity/promo_note.rs +++ b/packages/backend/native-utils/src/model/entity/promo_note.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "promo_note")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)] pub note_id: String, diff --git a/packages/backend/native-utils/src/model/entity/promo_read.rs b/packages/backend/native-utils/src/model/entity/promo_read.rs index a0015f87..5a802895 100644 --- a/packages/backend/native-utils/src/model/entity/promo_read.rs +++ b/packages/backend/native-utils/src/model/entity/promo_read.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "promo_read")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/registration_ticket.rs b/packages/backend/native-utils/src/model/entity/registration_ticket.rs index 577a9b36..c4bf3c68 100644 --- a/packages/backend/native-utils/src/model/entity/registration_ticket.rs +++ b/packages/backend/native-utils/src/model/entity/registration_ticket.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "registration_ticket")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/registry_item.rs b/packages/backend/native-utils/src/model/entity/registry_item.rs index a3bfdb8b..c35fba39 100644 --- a/packages/backend/native-utils/src/model/entity/registry_item.rs +++ b/packages/backend/native-utils/src/model/entity/registry_item.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "registry_item")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/relay.rs b/packages/backend/native-utils/src/model/entity/relay.rs index dbd2d325..884cf570 100644 --- a/packages/backend/native-utils/src/model/entity/relay.rs +++ b/packages/backend/native-utils/src/model/entity/relay.rs @@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "relay")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/renote_muting.rs b/packages/backend/native-utils/src/model/entity/renote_muting.rs index cf3312e6..fab315b8 100644 --- a/packages/backend/native-utils/src/model/entity/renote_muting.rs +++ b/packages/backend/native-utils/src/model/entity/renote_muting.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "renote_muting")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/reply_muting.rs b/packages/backend/native-utils/src/model/entity/reply_muting.rs index 67c0289e..a34d8a61 100644 --- a/packages/backend/native-utils/src/model/entity/reply_muting.rs +++ b/packages/backend/native-utils/src/model/entity/reply_muting.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "reply_muting")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs b/packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs index ec1a80d9..7439f0f5 100644 --- a/packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs +++ b/packages/backend/native-utils/src/model/entity/sea_orm_active_enums.rs @@ -2,7 +2,8 @@ use sea_orm::entity::prelude::*; -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")] pub enum AntennaSrcEnum { #[sea_orm(string_value = "all")] @@ -18,7 +19,8 @@ pub enum AntennaSrcEnum { #[sea_orm(string_value = "users")] Users, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -34,7 +36,8 @@ pub enum MetaSensitivemediadetectionEnum { #[sea_orm(string_value = "remote")] Remote, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -52,7 +55,8 @@ pub enum MetaSensitivemediadetectionsensitivityEnum { #[sea_orm(string_value = "veryLow")] VeryLow, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -68,7 +72,8 @@ pub enum MutedNoteReasonEnum { #[sea_orm(string_value = "word")] Word, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -86,7 +91,8 @@ pub enum NoteVisibilityEnum { #[sea_orm(string_value = "specified")] Specified, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -118,7 +124,8 @@ pub enum NotificationTypeEnum { #[sea_orm(string_value = "reply")] Reply, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -132,7 +139,8 @@ pub enum PageVisibilityEnum { #[sea_orm(string_value = "specified")] Specified, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -148,7 +156,8 @@ pub enum PollNotevisibilityEnum { #[sea_orm(string_value = "specified")] Specified, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "relay_status_enum")] pub enum RelayStatusEnum { #[sea_orm(string_value = "accepted")] @@ -158,7 +167,8 @@ pub enum RelayStatusEnum { #[sea_orm(string_value = "requesting")] Requesting, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -174,7 +184,8 @@ pub enum UserEmojimodpermEnum { #[sea_orm(string_value = "unauthorized")] Unauthorized, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", @@ -188,7 +199,8 @@ pub enum UserProfileFfvisibilityEnum { #[sea_orm(string_value = "public")] Public, } -#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)] +#[napi_derive::napi] #[sea_orm( rs_type = "String", db_type = "Enum", diff --git a/packages/backend/native-utils/src/model/entity/signin.rs b/packages/backend/native-utils/src/model/entity/signin.rs index 74be51c7..85396b5a 100644 --- a/packages/backend/native-utils/src/model/entity/signin.rs +++ b/packages/backend/native-utils/src/model/entity/signin.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "signin")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/sw_subscription.rs b/packages/backend/native-utils/src/model/entity/sw_subscription.rs index 480836e9..8899e6ed 100644 --- a/packages/backend/native-utils/src/model/entity/sw_subscription.rs +++ b/packages/backend/native-utils/src/model/entity/sw_subscription.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "sw_subscription")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/used_username.rs b/packages/backend/native-utils/src/model/entity/used_username.rs index 8509793a..f3ffb0f6 100644 --- a/packages/backend/native-utils/src/model/entity/used_username.rs +++ b/packages/backend/native-utils/src/model/entity/used_username.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "used_username")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub username: String, diff --git a/packages/backend/native-utils/src/model/entity/user.rs b/packages/backend/native-utils/src/model/entity/user.rs index 8ace9fc6..82a8e676 100644 --- a/packages/backend/native-utils/src/model/entity/user.rs +++ b/packages/backend/native-utils/src/model/entity/user.rs @@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_group.rs b/packages/backend/native-utils/src/model/entity/user_group.rs index 75d0a6ee..6d795886 100644 --- a/packages/backend/native-utils/src/model/entity/user_group.rs +++ b/packages/backend/native-utils/src/model/entity/user_group.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_group")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_group_invitation.rs b/packages/backend/native-utils/src/model/entity/user_group_invitation.rs index 2fd78d51..ee7edd8b 100644 --- a/packages/backend/native-utils/src/model/entity/user_group_invitation.rs +++ b/packages/backend/native-utils/src/model/entity/user_group_invitation.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_group_invitation")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_group_invite.rs b/packages/backend/native-utils/src/model/entity/user_group_invite.rs index a7d73b17..f49e40f1 100644 --- a/packages/backend/native-utils/src/model/entity/user_group_invite.rs +++ b/packages/backend/native-utils/src/model/entity/user_group_invite.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_group_invite")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_group_joining.rs b/packages/backend/native-utils/src/model/entity/user_group_joining.rs index 6f43fc9d..d34a3a6c 100644 --- a/packages/backend/native-utils/src/model/entity/user_group_joining.rs +++ b/packages/backend/native-utils/src/model/entity/user_group_joining.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_group_joining")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_ip.rs b/packages/backend/native-utils/src/model/entity/user_ip.rs index e4abec55..36ab2f9b 100644 --- a/packages/backend/native-utils/src/model/entity/user_ip.rs +++ b/packages/backend/native-utils/src/model/entity/user_ip.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_ip")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key)] pub id: i32, diff --git a/packages/backend/native-utils/src/model/entity/user_keypair.rs b/packages/backend/native-utils/src/model/entity/user_keypair.rs index 22a5054b..454f959a 100644 --- a/packages/backend/native-utils/src/model/entity/user_keypair.rs +++ b/packages/backend/native-utils/src/model/entity/user_keypair.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_keypair")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] pub user_id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_list.rs b/packages/backend/native-utils/src/model/entity/user_list.rs index 01411cb5..0e900ee8 100644 --- a/packages/backend/native-utils/src/model/entity/user_list.rs +++ b/packages/backend/native-utils/src/model/entity/user_list.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_list")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_list_joining.rs b/packages/backend/native-utils/src/model/entity/user_list_joining.rs index 63296dd6..c77ec392 100644 --- a/packages/backend/native-utils/src/model/entity/user_list_joining.rs +++ b/packages/backend/native-utils/src/model/entity/user_list_joining.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_list_joining")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_note_pining.rs b/packages/backend/native-utils/src/model/entity/user_note_pining.rs index b043b593..c29b5470 100644 --- a/packages/backend/native-utils/src/model/entity/user_note_pining.rs +++ b/packages/backend/native-utils/src/model/entity/user_note_pining.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_note_pining")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_pending.rs b/packages/backend/native-utils/src/model/entity/user_pending.rs index 863783b7..8a2f1806 100644 --- a/packages/backend/native-utils/src/model/entity/user_pending.rs +++ b/packages/backend/native-utils/src/model/entity/user_pending.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_pending")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_profile.rs b/packages/backend/native-utils/src/model/entity/user_profile.rs index 2b37ba02..7ff52bea 100644 --- a/packages/backend/native-utils/src/model/entity/user_profile.rs +++ b/packages/backend/native-utils/src/model/entity/user_profile.rs @@ -6,6 +6,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_profile")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] pub user_id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_publickey.rs b/packages/backend/native-utils/src/model/entity/user_publickey.rs index 97c433ff..994cfd33 100644 --- a/packages/backend/native-utils/src/model/entity/user_publickey.rs +++ b/packages/backend/native-utils/src/model/entity/user_publickey.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_publickey")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] pub user_id: String, diff --git a/packages/backend/native-utils/src/model/entity/user_security_key.rs b/packages/backend/native-utils/src/model/entity/user_security_key.rs index 28620229..67d43843 100644 --- a/packages/backend/native-utils/src/model/entity/user_security_key.rs +++ b/packages/backend/native-utils/src/model/entity/user_security_key.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "user_security_key")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/entity/webhook.rs b/packages/backend/native-utils/src/model/entity/webhook.rs index 06d41b9d..e4e2b14f 100644 --- a/packages/backend/native-utils/src/model/entity/webhook.rs +++ b/packages/backend/native-utils/src/model/entity/webhook.rs @@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*; #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[sea_orm(table_name = "webhook")] +#[napi_derive::napi(object)] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: String, diff --git a/packages/backend/native-utils/src/model/error.rs b/packages/backend/native-utils/src/model/error.rs index 8e921306..a9717263 100644 --- a/packages/backend/native-utils/src/model/error.rs +++ b/packages/backend/native-utils/src/model/error.rs @@ -1,4 +1,4 @@ -use crate::impl_into_napi_error; +use crate::impl_napi_error_from; #[derive(thiserror::Error, Debug, PartialEq, Eq)] pub enum Error { @@ -12,4 +12,4 @@ pub enum Error { NotFound, } -impl_into_napi_error!(Error); +impl_napi_error_from!(Error); diff --git a/packages/backend/native-utils/src/util/acct.rs b/packages/backend/native-utils/src/util/acct.rs index 2fcd0df8..cb50d159 100644 --- a/packages/backend/native-utils/src/util/acct.rs +++ b/packages/backend/native-utils/src/util/acct.rs @@ -1,10 +1,10 @@ -#[cfg_attr(feature = "napi", napi_derive::napi(object))] +#[napi_derive::napi(object)] pub struct Acct { pub username: String, pub host: Option, } -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn string_to_acct(acct: String) -> Acct { let split: Vec<&str> = if let Some(stripped) = acct.strip_prefix('@') { stripped @@ -24,7 +24,7 @@ pub fn string_to_acct(acct: String) -> Acct { } } -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn acct_to_string(acct: Acct) -> String { match acct.host { Some(host) => format!("{}@{}", acct.username, host), diff --git a/packages/backend/native-utils/src/util/convert_host.rs b/packages/backend/native-utils/src/util/convert_host.rs index d69201f6..9f3d47f4 100644 --- a/packages/backend/native-utils/src/util/convert_host.rs +++ b/packages/backend/native-utils/src/util/convert_host.rs @@ -2,7 +2,7 @@ use crate::config::server::read_server_config; use idna; use url::Url; -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn get_full_ap_account(username: String, host: Option) -> String { if host.is_none() { format!("{}@{}", username, extract_host(read_server_config().url)) @@ -11,7 +11,7 @@ pub fn get_full_ap_account(username: String, host: Option) -> String { } } -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn is_self_host(host: Option) -> bool { if let Some(x) = host { extract_host(read_server_config().url) == to_puny(x) @@ -20,7 +20,7 @@ pub fn is_self_host(host: Option) -> bool { } } -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn extract_host(uri: String) -> String { to_puny( Url::parse(uri.as_str()) @@ -31,12 +31,12 @@ pub fn extract_host(uri: String) -> String { ) } -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn to_puny(host: String) -> String { idna::domain_to_ascii(&host).expect("Failed to encode the host to punycode") } -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn to_puny_optional(host: Option) -> Option { host.map(to_puny) } diff --git a/packages/backend/native-utils/src/util/convert_to_hidden_post.rs b/packages/backend/native-utils/src/util/convert_to_hidden_post.rs index 3a713f68..d2cb3063 100644 --- a/packages/backend/native-utils/src/util/convert_to_hidden_post.rs +++ b/packages/backend/native-utils/src/util/convert_to_hidden_post.rs @@ -1,6 +1,6 @@ use napi; -#[cfg_attr(feature = "napi", napi_derive::napi(object))] +#[napi_derive::napi(object)] pub struct Post { pub text: Option, pub cw: Option, @@ -10,7 +10,7 @@ pub struct Post { pub visibility: String, } -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn convert_to_hidden_post(original_post: Post) -> Post { Post { text: match original_post.text { diff --git a/packages/backend/native-utils/src/util/escape_sql.rs b/packages/backend/native-utils/src/util/escape_sql.rs index 50bc6a64..21ec9a2e 100644 --- a/packages/backend/native-utils/src/util/escape_sql.rs +++ b/packages/backend/native-utils/src/util/escape_sql.rs @@ -1,9 +1,9 @@ -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn sql_like_escape(src: String) -> String { src.replace('%', r"\%").replace('_', r"\_") } -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn safe_for_sql(src: String) -> bool { !src.contains([ '\0', '\x08', '\x09', '\x1a', '\n', '\r', '"', '\'', '\\', '%', diff --git a/packages/backend/native-utils/src/util/format_milliseconds.rs b/packages/backend/native-utils/src/util/format_milliseconds.rs index b5fbb1e8..ff6389fb 100644 --- a/packages/backend/native-utils/src/util/format_milliseconds.rs +++ b/packages/backend/native-utils/src/util/format_milliseconds.rs @@ -1,5 +1,5 @@ /// Convert milliseconds to human readable string -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn format_milliseconds(milliseconds: i32) -> String { let mut seconds = milliseconds / 1000; let mut minutes = seconds / 60; diff --git a/packages/backend/native-utils/src/util/id.rs b/packages/backend/native-utils/src/util/id.rs index 9d1427e6..a5b0ad82 100644 --- a/packages/backend/native-utils/src/util/id.rs +++ b/packages/backend/native-utils/src/util/id.rs @@ -1,18 +1,18 @@ //! ID generation utility based on [cuid2] use basen::BASE36; -use cfg_if::cfg_if; +// use cfg_if::cfg_if; use chrono::Utc; use once_cell::sync::OnceCell; use std::cmp; -use crate::impl_into_napi_error; +use crate::impl_napi_error_from; #[derive(thiserror::Error, Debug, PartialEq, Eq)] #[error("ID generator has not been initialized yet")] pub struct ErrorUninitialized; -impl_into_napi_error!(ErrorUninitialized); +impl_napi_error_from!(ErrorUninitialized); static FINGERPRINT: OnceCell = OnceCell::new(); static GENERATOR: OnceCell = OnceCell::new(); @@ -61,29 +61,29 @@ pub fn get_timestamp(id: &str) -> i64 { } } -cfg_if! { - if #[cfg(feature = "napi")] { - use napi_derive::napi; +// cfg_if! { +// if #[cfg(feature = "napi")] { +use napi_derive::napi; - /// Calls [init_id] inside. Must be called before [native_create_id]. - #[napi] - pub fn native_init_id_generator(length: u16, fingerprint: String) { - init_id(length, &fingerprint); - } - - /// Generates - #[napi] - pub fn native_create_id(date_num: i64) -> String { - create_id(date_num).unwrap() - } - - #[napi] - pub fn native_get_timestamp(id: String) -> i64 { - get_timestamp(&id) - } - } +/// Calls [init_id] inside. Must be called before [native_create_id]. +#[napi] +pub fn native_init_id_generator(length: u16, fingerprint: String) { + init_id(length, &fingerprint); } +/// Generates +#[napi] +pub fn native_create_id(date_num: i64) -> String { + create_id(date_num).unwrap() +} + +#[napi] +pub fn native_get_timestamp(id: String) -> i64 { + get_timestamp(&id) +} +// } +// } + #[cfg(test)] mod unit_test { use crate::util::id; diff --git a/packages/backend/native-utils/src/util/random.rs b/packages/backend/native-utils/src/util/random.rs index 5be649c4..ce033220 100644 --- a/packages/backend/native-utils/src/util/random.rs +++ b/packages/backend/native-utils/src/util/random.rs @@ -1,7 +1,7 @@ use rand::{distributions::Alphanumeric, thread_rng, Rng}; /// Generate random string based on [thread_rng] and [Alphanumeric]. -#[cfg_attr(feature = "napi", napi_derive::napi)] +#[napi_derive::napi] pub fn gen_string(length: u16) -> String { thread_rng() .sample_iter(Alphanumeric)