refactor: make database models accesible to napi

Co-authored-by: sup39 <dev@sup39.dev>
This commit is contained in:
naskya 2024-01-20 05:57:00 +09:00
parent 3bc2b7bcfb
commit 93b7396990
Signed by: naskya
GPG key ID: 712D413B3A9FED5C
84 changed files with 181 additions and 68 deletions

View file

@ -31,8 +31,11 @@ regenerate-entities:
cd packages/backend/native-utils && \ cd packages/backend/native-utils && \
sea-orm-cli generate entity \ sea-orm-cli generate entity \
--output-dir='src/model/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 .PHONY: update-index-js
update-index-js: update-index-js:

View file

@ -269,6 +269,18 @@ const {
EnvConfig, EnvConfig,
readEnvironmentConfig, readEnvironmentConfig,
readServerConfig, readServerConfig,
AntennaSrcEnum,
MetaSensitivemediadetectionEnum,
MetaSensitivemediadetectionsensitivityEnum,
MutedNoteReasonEnum,
NoteVisibilityEnum,
NotificationTypeEnum,
PageVisibilityEnum,
PollNotevisibilityEnum,
RelayStatusEnum,
UserEmojimodpermEnum,
UserProfileFfvisibilityEnum,
UserProfileMutingnotificationtypesEnum,
stringToAcct, stringToAcct,
acctToString, acctToString,
getFullApAccount, getFullApAccount,
@ -280,17 +292,32 @@ const {
sqlLikeEscape, sqlLikeEscape,
safeForSql, safeForSql,
formatMilliseconds, formatMilliseconds,
nativeInitIdGenerator,
nativeCreateId,
nativeGetTimestamp,
genString, genString,
IdConvertType, IdConvertType,
convertId, convertId,
nativeGetTimestamp,
nativeCreateId,
nativeInitIdGenerator,
} = nativeBinding; } = nativeBinding;
module.exports.EnvConfig = EnvConfig; module.exports.EnvConfig = EnvConfig;
module.exports.readEnvironmentConfig = readEnvironmentConfig; module.exports.readEnvironmentConfig = readEnvironmentConfig;
module.exports.readServerConfig = readServerConfig; 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.stringToAcct = stringToAcct;
module.exports.acctToString = acctToString; module.exports.acctToString = acctToString;
module.exports.getFullApAccount = getFullApAccount; module.exports.getFullApAccount = getFullApAccount;
@ -302,9 +329,9 @@ module.exports.convertToHiddenPost = convertToHiddenPost;
module.exports.sqlLikeEscape = sqlLikeEscape; module.exports.sqlLikeEscape = sqlLikeEscape;
module.exports.safeForSql = safeForSql; module.exports.safeForSql = safeForSql;
module.exports.formatMilliseconds = formatMilliseconds; module.exports.formatMilliseconds = formatMilliseconds;
module.exports.nativeInitIdGenerator = nativeInitIdGenerator;
module.exports.nativeCreateId = nativeCreateId;
module.exports.nativeGetTimestamp = nativeGetTimestamp;
module.exports.genString = genString; module.exports.genString = genString;
module.exports.IdConvertType = IdConvertType; module.exports.IdConvertType = IdConvertType;
module.exports.convertId = convertId; module.exports.convertId = convertId;
module.exports.nativeGetTimestamp = nativeGetTimestamp;
module.exports.nativeCreateId = nativeCreateId;
module.exports.nativeInitIdGenerator = nativeInitIdGenerator;

View file

@ -1351,10 +1351,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fc1cb00cde484640da9f01a124edbb013576a6ae9843b23857c940936b76d91" checksum = "2fc1cb00cde484640da9f01a124edbb013576a6ae9843b23857c940936b76d91"
dependencies = [ dependencies = [
"bitflags 2.4.2", "bitflags 2.4.2",
"chrono",
"ctor", "ctor",
"napi-derive", "napi-derive",
"napi-sys", "napi-sys",
"once_cell", "once_cell",
"serde",
"serde_json",
"tokio", "tokio",
] ]

View file

@ -7,7 +7,7 @@ version = "0.0.0"
members = ["migration"] members = ["migration"]
[features] [features]
default = [] default = ["napi"]
napi = ["dep:napi-derive"] napi = ["dep:napi-derive"]
[lib] [lib]
@ -33,7 +33,7 @@ tokio = { version = "1.35.1", features = ["full"] }
url = "2.5.0" url = "2.5.0"
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix # 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 } napi-derive = { version = "2.14.6", optional = true }
basen = "0.1.0" basen = "0.1.0"

View file

@ -1,6 +1,6 @@
use sea_orm::error::DbErr; use sea_orm::error::DbErr;
use crate::impl_into_napi_error; use crate::impl_napi_error_from;
#[derive(thiserror::Error, Debug, PartialEq, Eq)] #[derive(thiserror::Error, Debug, PartialEq, Eq)]
pub enum Error { pub enum Error {
@ -10,4 +10,4 @@ pub enum Error {
OrmError(#[from] DbErr), OrmError(#[from] DbErr),
} }
impl_into_napi_error!(Error); impl_napi_error_from!(Error);

View file

@ -4,5 +4,5 @@ pub mod macros;
pub mod model; pub mod model;
pub mod util; pub mod util;
#[cfg(feature = "napi")] // #[cfg(feature = "napi")]
pub mod mastodon_api; pub mod mastodon_api;

View file

@ -1,10 +1,10 @@
#[macro_export] #[macro_export]
macro_rules! impl_into_napi_error { macro_rules! impl_napi_error_from {
($a:ty) => { ($a:ty) => {
#[cfg(feature = "napi")] #[cfg(feature = "napi")]
impl Into<napi::Error> for $a { impl From<$a> for napi::Error {
fn into(self) -> napi::Error { fn from(reason: $a) -> napi::Error {
napi::Error::from_reason(self.to_string()) napi::Error::from_reason(reason.to_string())
} }
} }
}; };

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "abuse_user_report")] #[sea_orm(table_name = "abuse_user_report")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "access_token")] #[sea_orm(table_name = "access_token")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "ad")] #[sea_orm(table_name = "ad")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "announcement")] #[sea_orm(table_name = "announcement")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "announcement_read")] #[sea_orm(table_name = "announcement_read")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "antenna")] #[sea_orm(table_name = "antenna")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "app")] #[sea_orm(table_name = "app")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "attestation_challenge")] #[sea_orm(table_name = "attestation_challenge")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "auth_session")] #[sea_orm(table_name = "auth_session")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "blocking")] #[sea_orm(table_name = "blocking")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel")] #[sea_orm(table_name = "channel")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel_following")] #[sea_orm(table_name = "channel_following")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "channel_note_pining")] #[sea_orm(table_name = "channel_note_pining")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "clip")] #[sea_orm(table_name = "clip")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "clip_note")] #[sea_orm(table_name = "clip_note")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "drive_file")] #[sea_orm(table_name = "drive_file")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "drive_folder")] #[sea_orm(table_name = "drive_folder")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "emoji")] #[sea_orm(table_name = "emoji")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "follow_request")] #[sea_orm(table_name = "follow_request")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "following")] #[sea_orm(table_name = "following")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "gallery_like")] #[sea_orm(table_name = "gallery_like")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "gallery_post")] #[sea_orm(table_name = "gallery_post")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "hashtag")] #[sea_orm(table_name = "hashtag")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "instance")] #[sea_orm(table_name = "instance")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "messaging_message")] #[sea_orm(table_name = "messaging_message")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -6,6 +6,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "meta")] #[sea_orm(table_name = "meta")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "migrations")] #[sea_orm(table_name = "migrations")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
pub id: i32, pub id: i32,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "moderation_log")] #[sea_orm(table_name = "moderation_log")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "muted_note")] #[sea_orm(table_name = "muted_note")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "muting")] #[sea_orm(table_name = "muting")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note")] #[sea_orm(table_name = "note")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_edit")] #[sea_orm(table_name = "note_edit")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_favorite")] #[sea_orm(table_name = "note_favorite")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_reaction")] #[sea_orm(table_name = "note_reaction")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_thread_muting")] #[sea_orm(table_name = "note_thread_muting")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_unread")] #[sea_orm(table_name = "note_unread")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "note_watching")] #[sea_orm(table_name = "note_watching")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "notification")] #[sea_orm(table_name = "notification")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "page")] #[sea_orm(table_name = "page")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "page_like")] #[sea_orm(table_name = "page_like")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "password_reset_request")] #[sea_orm(table_name = "password_reset_request")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "poll")] #[sea_orm(table_name = "poll")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)]
pub note_id: String, pub note_id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "poll_vote")] #[sea_orm(table_name = "poll_vote")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "promo_note")] #[sea_orm(table_name = "promo_note")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "noteId", primary_key, auto_increment = false, unique)]
pub note_id: String, pub note_id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "promo_read")] #[sea_orm(table_name = "promo_read")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "registration_ticket")] #[sea_orm(table_name = "registration_ticket")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "registry_item")] #[sea_orm(table_name = "registry_item")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "relay")] #[sea_orm(table_name = "relay")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "renote_muting")] #[sea_orm(table_name = "renote_muting")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "reply_muting")] #[sea_orm(table_name = "reply_muting")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -2,7 +2,8 @@
use sea_orm::entity::prelude::*; 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")] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "antenna_src_enum")]
pub enum AntennaSrcEnum { pub enum AntennaSrcEnum {
#[sea_orm(string_value = "all")] #[sea_orm(string_value = "all")]
@ -18,7 +19,8 @@ pub enum AntennaSrcEnum {
#[sea_orm(string_value = "users")] #[sea_orm(string_value = "users")]
Users, Users,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -34,7 +36,8 @@ pub enum MetaSensitivemediadetectionEnum {
#[sea_orm(string_value = "remote")] #[sea_orm(string_value = "remote")]
Remote, Remote,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -52,7 +55,8 @@ pub enum MetaSensitivemediadetectionsensitivityEnum {
#[sea_orm(string_value = "veryLow")] #[sea_orm(string_value = "veryLow")]
VeryLow, VeryLow,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -68,7 +72,8 @@ pub enum MutedNoteReasonEnum {
#[sea_orm(string_value = "word")] #[sea_orm(string_value = "word")]
Word, Word,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -86,7 +91,8 @@ pub enum NoteVisibilityEnum {
#[sea_orm(string_value = "specified")] #[sea_orm(string_value = "specified")]
Specified, Specified,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -118,7 +124,8 @@ pub enum NotificationTypeEnum {
#[sea_orm(string_value = "reply")] #[sea_orm(string_value = "reply")]
Reply, Reply,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -132,7 +139,8 @@ pub enum PageVisibilityEnum {
#[sea_orm(string_value = "specified")] #[sea_orm(string_value = "specified")]
Specified, Specified,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -148,7 +156,8 @@ pub enum PollNotevisibilityEnum {
#[sea_orm(string_value = "specified")] #[sea_orm(string_value = "specified")]
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")] #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "relay_status_enum")]
pub enum RelayStatusEnum { pub enum RelayStatusEnum {
#[sea_orm(string_value = "accepted")] #[sea_orm(string_value = "accepted")]
@ -158,7 +167,8 @@ pub enum RelayStatusEnum {
#[sea_orm(string_value = "requesting")] #[sea_orm(string_value = "requesting")]
Requesting, Requesting,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -174,7 +184,8 @@ pub enum UserEmojimodpermEnum {
#[sea_orm(string_value = "unauthorized")] #[sea_orm(string_value = "unauthorized")]
Unauthorized, Unauthorized,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",
@ -188,7 +199,8 @@ pub enum UserProfileFfvisibilityEnum {
#[sea_orm(string_value = "public")] #[sea_orm(string_value = "public")]
Public, Public,
} }
#[derive(Debug, Clone, PartialEq, Eq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum)]
#[napi_derive::napi]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = "Enum", db_type = "Enum",

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "signin")] #[sea_orm(table_name = "signin")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "sw_subscription")] #[sea_orm(table_name = "sw_subscription")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "used_username")] #[sea_orm(table_name = "used_username")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub username: String, pub username: String,

View file

@ -5,6 +5,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user")] #[sea_orm(table_name = "user")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group")] #[sea_orm(table_name = "user_group")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_invitation")] #[sea_orm(table_name = "user_group_invitation")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_invite")] #[sea_orm(table_name = "user_group_invite")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_group_joining")] #[sea_orm(table_name = "user_group_joining")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_ip")] #[sea_orm(table_name = "user_ip")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]
pub id: i32, pub id: i32,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_keypair")] #[sea_orm(table_name = "user_keypair")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String, pub user_id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_list")] #[sea_orm(table_name = "user_list")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_list_joining")] #[sea_orm(table_name = "user_list_joining")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_note_pining")] #[sea_orm(table_name = "user_note_pining")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_pending")] #[sea_orm(table_name = "user_pending")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -6,6 +6,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_profile")] #[sea_orm(table_name = "user_profile")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String, pub user_id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_publickey")] #[sea_orm(table_name = "user_publickey")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)] #[sea_orm(column_name = "userId", primary_key, auto_increment = false, unique)]
pub user_id: String, pub user_id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "user_security_key")] #[sea_orm(table_name = "user_security_key")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -4,6 +4,7 @@ use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "webhook")] #[sea_orm(table_name = "webhook")]
#[napi_derive::napi(object)]
pub struct Model { pub struct Model {
#[sea_orm(primary_key, auto_increment = false)] #[sea_orm(primary_key, auto_increment = false)]
pub id: String, pub id: String,

View file

@ -1,4 +1,4 @@
use crate::impl_into_napi_error; use crate::impl_napi_error_from;
#[derive(thiserror::Error, Debug, PartialEq, Eq)] #[derive(thiserror::Error, Debug, PartialEq, Eq)]
pub enum Error { pub enum Error {
@ -12,4 +12,4 @@ pub enum Error {
NotFound, NotFound,
} }
impl_into_napi_error!(Error); impl_napi_error_from!(Error);

View file

@ -1,10 +1,10 @@
#[cfg_attr(feature = "napi", napi_derive::napi(object))] #[napi_derive::napi(object)]
pub struct Acct { pub struct Acct {
pub username: String, pub username: String,
pub host: Option<String>, pub host: Option<String>,
} }
#[cfg_attr(feature = "napi", napi_derive::napi)] #[napi_derive::napi]
pub fn string_to_acct(acct: String) -> Acct { pub fn string_to_acct(acct: String) -> Acct {
let split: Vec<&str> = if let Some(stripped) = acct.strip_prefix('@') { let split: Vec<&str> = if let Some(stripped) = acct.strip_prefix('@') {
stripped 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 { pub fn acct_to_string(acct: Acct) -> String {
match acct.host { match acct.host {
Some(host) => format!("{}@{}", acct.username, host), Some(host) => format!("{}@{}", acct.username, host),

View file

@ -2,7 +2,7 @@ use crate::config::server::read_server_config;
use idna; use idna;
use url::Url; use url::Url;
#[cfg_attr(feature = "napi", napi_derive::napi)] #[napi_derive::napi]
pub fn get_full_ap_account(username: String, host: Option<String>) -> String { pub fn get_full_ap_account(username: String, host: Option<String>) -> String {
if host.is_none() { if host.is_none() {
format!("{}@{}", username, extract_host(read_server_config().url)) format!("{}@{}", username, extract_host(read_server_config().url))
@ -11,7 +11,7 @@ pub fn get_full_ap_account(username: String, host: Option<String>) -> String {
} }
} }
#[cfg_attr(feature = "napi", napi_derive::napi)] #[napi_derive::napi]
pub fn is_self_host(host: Option<String>) -> bool { pub fn is_self_host(host: Option<String>) -> bool {
if let Some(x) = host { if let Some(x) = host {
extract_host(read_server_config().url) == to_puny(x) extract_host(read_server_config().url) == to_puny(x)
@ -20,7 +20,7 @@ pub fn is_self_host(host: Option<String>) -> bool {
} }
} }
#[cfg_attr(feature = "napi", napi_derive::napi)] #[napi_derive::napi]
pub fn extract_host(uri: String) -> String { pub fn extract_host(uri: String) -> String {
to_puny( to_puny(
Url::parse(uri.as_str()) 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 { pub fn to_puny(host: String) -> String {
idna::domain_to_ascii(&host).expect("Failed to encode the host to punycode") 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<String>) -> Option<String> { pub fn to_puny_optional(host: Option<String>) -> Option<String> {
host.map(to_puny) host.map(to_puny)
} }

View file

@ -1,6 +1,6 @@
use napi; use napi;
#[cfg_attr(feature = "napi", napi_derive::napi(object))] #[napi_derive::napi(object)]
pub struct Post { pub struct Post {
pub text: Option<String>, pub text: Option<String>,
pub cw: Option<String>, pub cw: Option<String>,
@ -10,7 +10,7 @@ pub struct Post {
pub visibility: String, pub visibility: String,
} }
#[cfg_attr(feature = "napi", napi_derive::napi)] #[napi_derive::napi]
pub fn convert_to_hidden_post(original_post: Post) -> Post { pub fn convert_to_hidden_post(original_post: Post) -> Post {
Post { Post {
text: match original_post.text { text: match original_post.text {

View file

@ -1,9 +1,9 @@
#[cfg_attr(feature = "napi", napi_derive::napi)] #[napi_derive::napi]
pub fn sql_like_escape(src: String) -> String { pub fn sql_like_escape(src: String) -> String {
src.replace('%', r"\%").replace('_', r"\_") src.replace('%', r"\%").replace('_', r"\_")
} }
#[cfg_attr(feature = "napi", napi_derive::napi)] #[napi_derive::napi]
pub fn safe_for_sql(src: String) -> bool { pub fn safe_for_sql(src: String) -> bool {
!src.contains([ !src.contains([
'\0', '\x08', '\x09', '\x1a', '\n', '\r', '"', '\'', '\\', '%', '\0', '\x08', '\x09', '\x1a', '\n', '\r', '"', '\'', '\\', '%',

View file

@ -1,5 +1,5 @@
/// Convert milliseconds to human readable string /// Convert milliseconds to human readable string
#[cfg_attr(feature = "napi", napi_derive::napi)] #[napi_derive::napi]
pub fn format_milliseconds(milliseconds: i32) -> String { pub fn format_milliseconds(milliseconds: i32) -> String {
let mut seconds = milliseconds / 1000; let mut seconds = milliseconds / 1000;
let mut minutes = seconds / 60; let mut minutes = seconds / 60;

View file

@ -1,18 +1,18 @@
//! ID generation utility based on [cuid2] //! ID generation utility based on [cuid2]
use basen::BASE36; use basen::BASE36;
use cfg_if::cfg_if; // use cfg_if::cfg_if;
use chrono::Utc; use chrono::Utc;
use once_cell::sync::OnceCell; use once_cell::sync::OnceCell;
use std::cmp; use std::cmp;
use crate::impl_into_napi_error; use crate::impl_napi_error_from;
#[derive(thiserror::Error, Debug, PartialEq, Eq)] #[derive(thiserror::Error, Debug, PartialEq, Eq)]
#[error("ID generator has not been initialized yet")] #[error("ID generator has not been initialized yet")]
pub struct ErrorUninitialized; pub struct ErrorUninitialized;
impl_into_napi_error!(ErrorUninitialized); impl_napi_error_from!(ErrorUninitialized);
static FINGERPRINT: OnceCell<String> = OnceCell::new(); static FINGERPRINT: OnceCell<String> = OnceCell::new();
static GENERATOR: OnceCell<cuid2::CuidConstructor> = OnceCell::new(); static GENERATOR: OnceCell<cuid2::CuidConstructor> = OnceCell::new();
@ -61,29 +61,29 @@ pub fn get_timestamp(id: &str) -> i64 {
} }
} }
cfg_if! { // cfg_if! {
if #[cfg(feature = "napi")] { // if #[cfg(feature = "napi")] {
use napi_derive::napi; use napi_derive::napi;
/// Calls [init_id] inside. Must be called before [native_create_id]. /// Calls [init_id] inside. Must be called before [native_create_id].
#[napi] #[napi]
pub fn native_init_id_generator(length: u16, fingerprint: String) { pub fn native_init_id_generator(length: u16, fingerprint: String) {
init_id(length, &fingerprint); 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)
}
}
} }
/// 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)] #[cfg(test)]
mod unit_test { mod unit_test {
use crate::util::id; use crate::util::id;

View file

@ -1,7 +1,7 @@
use rand::{distributions::Alphanumeric, thread_rng, Rng}; use rand::{distributions::Alphanumeric, thread_rng, Rng};
/// Generate random string based on [thread_rng] and [Alphanumeric]. /// 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 { pub fn gen_string(length: u16) -> String {
thread_rng() thread_rng()
.sample_iter(Alphanumeric) .sample_iter(Alphanumeric)