From 5a8dc049152d9b7567746167f109656bbc4ee3de Mon Sep 17 00:00:00 2001 From: Natty Date: Thu, 2 Nov 2023 20:40:12 +0100 Subject: [PATCH 1/7] Fixed TS_RS --- magnetar_sdk/macros/src/lib.rs | 172 +++++++++++++++++++++---- magnetar_sdk/src/endpoints/note.rs | 4 +- magnetar_sdk/src/endpoints/timeline.rs | 10 +- magnetar_sdk/src/endpoints/user.rs | 12 +- magnetar_sdk/src/lib.rs | 78 ++++++++++- magnetar_sdk/src/types/note.rs | 8 +- magnetar_sdk/src/types/user.rs | 40 ++++-- magnetar_sdk/src/util_types.rs | 2 +- src/model/data/user.rs | 3 - src/model/processing/note.rs | 10 +- src/nodeinfo.rs | 1 + 11 files changed, 272 insertions(+), 68 deletions(-) diff --git a/magnetar_sdk/macros/src/lib.rs b/magnetar_sdk/macros/src/lib.rs index 34b07c1..4792975 100644 --- a/magnetar_sdk/macros/src/lib.rs +++ b/magnetar_sdk/macros/src/lib.rs @@ -1,8 +1,11 @@ use proc_macro::TokenStream; +use quote::ToTokens; use std::collections::HashSet; use syn::parse::Parse; use syn::punctuated::Punctuated; -use syn::{Expr, ExprLit, ExprPath, Ident, Lit, Meta, MetaNameValue, Token, Type}; +use syn::{ + Expr, ExprLit, ExprPath, Ident, Lit, Meta, MetaNameValue, PathArguments, Token, Type, TypePath, +}; struct Field { name: Ident, @@ -49,7 +52,9 @@ pub fn pack(item: TokenStream) -> TokenStream { let fields = &parsed.fields; let names = fields.iter().map(|f| &f.name); - let types = fields.iter().map(|f| &f.ty); + let types_decl = fields.iter().map(|f| &f.ty); + let types_struct = fields.iter().map(|f| &f.ty); + let types_deps = fields.iter().map(|f| &f.ty); let types_packed = fields.iter().map(|f| &f.ty); let names_packed = fields.iter().map(|f| &f.name); @@ -61,13 +66,19 @@ pub fn pack(item: TokenStream) -> TokenStream { (#(#types_packed,)*) }; + let name = struct_name.to_string(); + + let export_name = Ident::new( + &format!("export_bindings_{}", struct_name.to_string().to_lowercase()), + struct_name.span(), + ); + let expanded = quote::quote! { - #[derive(Clone, Debug, Deserialize, Serialize, TS)] - #[ts(export, export_to = #export_path)] + #[derive(Clone, Debug, Deserialize, Serialize)] pub struct #struct_name { #( #[serde(flatten)] - pub #names: #types + pub #names: #types_struct ),* } @@ -82,6 +93,40 @@ pub fn pack(item: TokenStream) -> TokenStream { } } } + + #[cfg(test)] + #[test] + fn #export_name() { + #struct_name::export().expect("could not export type"); + } + + impl TS for #struct_name { + const EXPORT_TO: Option<&'static str> = Some(#export_path); + + fn decl() -> String { + format!( + "type {} = {};", + Self::name(), + vec![#(<#types_decl as TS>::inline()),*].join(" & ") + ) + } + + fn name() -> String { + #name.to_string() + } + + fn dependencies() -> Vec { + vec![ + #( + <#types_deps as TS>::dependencies() + ),* + ].into_iter().flatten().collect::>() + } + + fn transparent() -> bool { + false + } + } }; TokenStream::from(expanded) @@ -109,6 +154,8 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { let mut method = None; let mut request = None; let mut response = None; + let mut request_args = None; + let mut response_args = None; let mut found = HashSet::new(); @@ -145,39 +192,73 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { match key.to_string().as_ref() { "name" => { - let Expr::Lit(ExprLit { lit: Lit::Str(new_name), .. }) = value else { - panic!("expected a string literal"); - }; + let Expr::Lit(ExprLit { + lit: Lit::Str(new_name), + .. + }) = value + else { + panic!("expected a string literal"); + }; name = new_name.value(); } "endpoint" => { - let Expr::Lit(ExprLit { lit: Lit::Str(endpoint_val), .. }) = value else { - panic!("expected a string literal"); - }; + let Expr::Lit(ExprLit { + lit: Lit::Str(endpoint_val), + .. + }) = value + else { + panic!("expected a string literal"); + }; endpoint = Some(endpoint_val.value()); } "method" => { let Expr::Path(ExprPath { path, .. }) = value else { - panic!("expected a an identifier"); - }; + panic!("expected a an identifier"); + }; method = Some(path); } "request" => { - let Expr::Path(ExprPath { path, .. }) = value else { - panic!("expected a an identifier"); - }; + let Expr::Lit(ExprLit { + lit: Lit::Str(str_lit), + .. + }) = value + else { + panic!("expected a an identifier"); + }; - request = Some(path); + let type_tok: TokenStream = str_lit.value().parse().unwrap(); + let req_typ = syn::parse::(type_tok).unwrap(); + + if let Some(seg_last) = req_typ.path.segments.last() { + if let PathArguments::AngleBracketed(args) = &seg_last.arguments { + let args_res = args.args.iter().cloned().collect::>(); + request_args = Some(args_res); + } + } + + request = Some(req_typ); } "response" => { - let Expr::Path(ExprPath { path, .. }) = value else { - panic!("expected an identifier") - }; + let Expr::Lit(ExprLit { + lit: Lit::Str(str_lit), + .. + }) = value + else { + panic!("expected a an identifier"); + }; - response = Some(path); + let type_tok: TokenStream = str_lit.value().parse().unwrap(); + let res_typ = syn::parse::(type_tok).unwrap(); + if let Some(seg_last) = res_typ.path.segments.last() { + if let PathArguments::AngleBracketed(args) = &seg_last.arguments { + let args_res = args.args.iter().cloned().collect::>(); + response_args = Some(args_res); + } + } + response = Some(res_typ); } _ => panic!("unknown attribute: {}", key), } @@ -197,6 +278,39 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { struct_name.span(), ); + let call_name_req = if let Some(ref args) = request_args { + let args_str = args + .iter() + .map(|a| a.into_token_stream().to_string()) + .collect::>(); + + quote::quote! { + <#struct_name as Endpoint>::Request::name_with_type_args(vec![#( #args_str.to_string() ),*]) + } + } else { + quote::quote! { + <#struct_name as Endpoint>::Request::name() + } + }; + + let call_name_res = if let Some(ref args) = response_args { + let args_str = args + .iter() + .map(|a| a.into_token_stream().to_string()) + .collect::>(); + + quote::quote! { + <#struct_name as Endpoint>::Response::name_with_type_args(vec![#( #args_str.to_string() ),*]) + } + } else { + quote::quote! { + <#struct_name as Endpoint>::Response::name() + } + }; + + let req_args_flat = request_args.unwrap_or_default(); + let res_args_flat = response_args.unwrap_or_default(); + let expanded = quote::quote! { impl Default for #struct_name { fn default() -> Self { @@ -234,8 +348,8 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { Self::name(), Self::ENDPOINT, Self::METHOD, - <#struct_name as Endpoint>::Request::name(), - <#struct_name as Endpoint>::Response::name() + #call_name_req, + #call_name_res ) } @@ -245,9 +359,15 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { fn dependencies() -> Vec { vec![ - ts_rs::Dependency::from_ty::<<#struct_name as Endpoint>::Request>().unwrap(), - ts_rs::Dependency::from_ty::<<#struct_name as Endpoint>::Response>().unwrap(), - ] + ts_rs::Dependency::from_ty::<<#struct_name as Endpoint>::Request>(), + ts_rs::Dependency::from_ty::<<#struct_name as Endpoint>::Response>(), + #( + ts_rs::Dependency::from_ty::<#req_args_flat>(), + )* + #( + ts_rs::Dependency::from_ty::<#res_args_flat>(), + )* + ].into_iter().flatten().collect::>() } fn transparent() -> bool { diff --git a/magnetar_sdk/src/endpoints/note.rs b/magnetar_sdk/src/endpoints/note.rs index 9766294..a80671a 100644 --- a/magnetar_sdk/src/endpoints/note.rs +++ b/magnetar_sdk/src/endpoints/note.rs @@ -19,7 +19,7 @@ pub struct NoteByIdReq { #[endpoint( endpoint = "/notes/:id", method = Method::GET, - request = NoteByIdReq, - response = PackNoteMaybeFull + request = "NoteByIdReq", + response = "PackNoteMaybeFull" )] pub struct GetNoteById; diff --git a/magnetar_sdk/src/endpoints/timeline.rs b/magnetar_sdk/src/endpoints/timeline.rs index addeb36..680097f 100644 --- a/magnetar_sdk/src/endpoints/timeline.rs +++ b/magnetar_sdk/src/endpoints/timeline.rs @@ -12,7 +12,6 @@ use ts_rs::TS; pub struct GetTimelineReq { #[serde(default = "default_timeline_limit")] pub limit: U64Range<1, 100>, - #[serde(flatten)] pub filter: Option, } @@ -20,16 +19,11 @@ fn default_timeline_limit() -> U64Range); - #[derive(Endpoint)] #[endpoint( endpoint = "/timeline", method = Method::GET, - request = GetTimelineReq, - response = Vec::, + request = "GetTimelineReq", + response = "Vec", )] pub struct GetTimeline; diff --git a/magnetar_sdk/src/endpoints/user.rs b/magnetar_sdk/src/endpoints/user.rs index 540b3c6..5c89be0 100644 --- a/magnetar_sdk/src/endpoints/user.rs +++ b/magnetar_sdk/src/endpoints/user.rs @@ -24,8 +24,8 @@ pub struct UserSelfReq { #[endpoint( endpoint = "/users/@self", method = Method::GET, - request = UserSelfReq, - response = PackUserSelfMaybeAll + request = "UserSelfReq", + response = "PackUserSelfMaybeAll" )] pub struct GetUserSelf; @@ -49,8 +49,8 @@ pub struct UserByIdReq { #[endpoint( endpoint = "/users/:user_id", method = Method::GET, - request = UserByIdReq, - response = PackUserMaybeAll + request = "UserByIdReq", + response = "PackUserMaybeAll" )] pub struct GetUserById; @@ -60,7 +60,7 @@ pub struct GetUserById; #[endpoint( endpoint = "/users/by-acct/:user_id", method = Method::GET, - request = UserByIdReq, - response = PackUserMaybeAll + request = "UserByIdReq", + response = "PackUserMaybeAll" )] pub struct GetUserByAcct; diff --git a/magnetar_sdk/src/lib.rs b/magnetar_sdk/src/lib.rs index 79189ff..f2a954d 100644 --- a/magnetar_sdk/src/lib.rs +++ b/magnetar_sdk/src/lib.rs @@ -1,4 +1,6 @@ +use chrono::format; use serde::{Deserialize, Serialize}; +use std::ops::{Deref, DerefMut}; use ts_rs::TS; pub use magnetar_mmm_parser as mmm; @@ -6,10 +8,84 @@ pub mod endpoints; pub mod types; pub mod util_types; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)] #[repr(transparent)] pub struct Required(pub T); +impl TS for Required { + const EXPORT_TO: Option<&'static str> = None; + + fn decl() -> String { + unimplemented!() + } + + fn name() -> String { + T::name() + } + + fn inline() -> String { + T::name() + } + + fn inline_flattened() -> String { + unimplemented!() + } + + fn dependencies() -> Vec { + ts_rs::Dependency::from_ty::().into_iter().collect() + } + + fn transparent() -> bool { + false + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)] +#[repr(transparent)] +pub struct Optional(pub Option); + +impl TS for Optional { + const EXPORT_TO: Option<&'static str> = None; + + fn decl() -> String { + unimplemented!() + } + + fn name() -> String { + T::name() + } + + fn inline() -> String { + format!("Partial<{}>", T::name()) + } + + fn inline_flattened() -> String { + unimplemented!() + } + + fn dependencies() -> Vec { + ts_rs::Dependency::from_ty::().into_iter().collect() + } + + fn transparent() -> bool { + false + } +} + +impl Deref for Optional { + type Target = Option; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl DerefMut for Optional { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } +} + pub trait Packed: 'static { type Input: 'static; diff --git a/magnetar_sdk/src/types/note.rs b/magnetar_sdk/src/types/note.rs index da569f3..30de780 100644 --- a/magnetar_sdk/src/types/note.rs +++ b/magnetar_sdk/src/types/note.rs @@ -1,7 +1,7 @@ use crate::types::emoji::EmojiContext; use crate::types::user::PackUserBase; use crate::types::{Id, MmXml}; -use crate::{Packed, Required}; +use crate::{Optional, Packed, Required}; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use ts_rs::TS; @@ -89,7 +89,7 @@ pub struct NoteAttachmentExt { pack!( PackNoteMaybeAttachments, - Required as id & Required as note & Option as user_context & Option as attachment + Required as id & Required as note & Optional as user_context & Optional as attachment ); #[derive(Clone, Debug, Deserialize, Serialize, TS)] @@ -100,10 +100,11 @@ pub struct NoteDetailExt { pack!( PackNoteMaybeFull, - Required as id & Required as note & Option as user_context & Option as attachment & Option as detail + Required as id & Required as note & Optional as user_context & Optional as attachment & Optional as detail ); #[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] #[serde(untagged)] pub enum Reaction { Unicode(String), @@ -118,6 +119,7 @@ pub enum Reaction { } #[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] #[serde(untagged)] pub enum ReactionPair { WithoutContext(Reaction, u64), diff --git a/magnetar_sdk/src/types/user.rs b/magnetar_sdk/src/types/user.rs index bcfdaa2..d4ee9bd 100644 --- a/magnetar_sdk/src/types/user.rs +++ b/magnetar_sdk/src/types/user.rs @@ -1,6 +1,6 @@ use crate::types::emoji::EmojiContext; use crate::types::{Id, MmXml, NotificationSettings}; -use crate::{Packed, Required}; +use crate::{Optional, Packed, Required}; use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use ts_rs::TS; @@ -82,7 +82,6 @@ pub struct UserProfileExt { pub banner_blurhash: Option, pub has_public_reactions: bool, - pub emojis: EmojiContext, } #[derive(Clone, Debug, Deserialize, Serialize, TS)] @@ -164,16 +163,24 @@ pack!( PackUserMaybeAll, Required as id & Required as user - & Option as profile - & Option as pins - & Option as detail - & Option as relation - & Option as auth + & Optional as profile + & Optional as pins + & Optional as detail + & Optional as relation + & Optional as auth ); impl From for PackUserMaybeAll { fn from(value: PackUserBase) -> Self { - Self::pack_from((value.id, value.user, None, None, None, None, None)) + Self::pack_from(( + value.id, + value.user, + Optional(None), + Optional(None), + Optional(None), + Optional(None), + Optional(None), + )) } } @@ -181,14 +188,21 @@ pack!( PackUserSelfMaybeAll, Required as id & Required as user - & Option as profile - & Option as pins - & Option as detail - & Option as secrets + & Optional as profile + & Optional as pins + & Optional as detail + & Optional as secrets ); impl From for PackUserSelfMaybeAll { fn from(value: PackUserBase) -> Self { - Self::pack_from((value.id, value.user, None, None, None, None)) + Self::pack_from(( + value.id, + value.user, + Optional(None), + Optional(None), + Optional(None), + Optional(None), + )) } } diff --git a/magnetar_sdk/src/util_types.rs b/magnetar_sdk/src/util_types.rs index 220c207..d8547a1 100644 --- a/magnetar_sdk/src/util_types.rs +++ b/magnetar_sdk/src/util_types.rs @@ -17,7 +17,7 @@ impl TS for U64Range { } fn dependencies() -> Vec { - vec![ts_rs::Dependency::from_ty::().unwrap()] + vec![] } fn transparent() -> bool { diff --git a/src/model/data/user.rs b/src/model/data/user.rs index 608d07a..a49ea80 100644 --- a/src/model/data/user.rs +++ b/src/model/data/user.rs @@ -71,7 +71,6 @@ pub struct UserProfileExtSource<'a> { pub profile_fields: &'a Vec, pub description_mm: Option<&'a MmXml>, pub relation: Option<&'a UserRelationExt>, - pub emoji_context: &'a EmojiContext, } impl PackType> for UserProfileExt { @@ -83,7 +82,6 @@ impl PackType> for UserProfileExt { profile_fields, description_mm, relation, - emoji_context, }: UserProfileExtSource, ) -> Self { let follow_visibility = match profile.ff_visibility { @@ -114,7 +112,6 @@ impl PackType> for UserProfileExt { banner_color: None, banner_blurhash: None, has_public_reactions: profile.public_reactions, - emojis: emoji_context.clone(), } } } diff --git a/src/model/processing/note.rs b/src/model/processing/note.rs index 270d269..cc7dda5 100644 --- a/src/model/processing/note.rs +++ b/src/model/processing/note.rs @@ -27,7 +27,7 @@ use magnetar_sdk::types::note::{ PackNoteMaybeAttachments, PackNoteMaybeFull, PackPollBase, PollBase, Reaction, ReactionPair, }; use magnetar_sdk::types::{Id, MmXml}; -use magnetar_sdk::{mmm, Packed, Required}; +use magnetar_sdk::{mmm, Optional, Packed, Required}; use serde::Deserialize; use tokio::try_join; @@ -412,8 +412,8 @@ impl NoteModel { Ok(PackNoteMaybeAttachments::pack_from(( id, note, - self.extract_interaction(ctx, note_data)?, - attachments_pack.map(|attachments| { + Optional(self.extract_interaction(ctx, note_data)?), + Optional(attachments_pack.map(|attachments| { NoteAttachmentExt::extract( ctx, NoteAttachmentSource { @@ -421,7 +421,7 @@ impl NoteModel { poll: poll_pack.as_ref(), }, ) - }), + })), ))) } @@ -505,7 +505,7 @@ impl NoteModel { note, user_context, attachment, - detail, + Optional(detail), )))) } } diff --git a/src/nodeinfo.rs b/src/nodeinfo.rs index c82153d..6111307 100644 --- a/src/nodeinfo.rs +++ b/src/nodeinfo.rs @@ -104,6 +104,7 @@ mod tests { async fn test_nodeinfo() { std::env::set_var("MAG_C_HOST", "nattyarch.local"); std::env::set_var("MAG_C_DATABASE_URL", "dummy"); + std::env::set_var("MAG_C_REDIS_URL", "dummy"); let config = MagnetarConfig::default(); let config_ref = Box::leak(Box::new(config)); From 2c3d675392f9c8f4a3186fc632891f4783b41892 Mon Sep 17 00:00:00 2001 From: Natty Date: Fri, 3 Nov 2023 13:17:53 +0100 Subject: [PATCH 2/7] First attempt at TS_RS --- .cargo/config.toml | 6 +- .../frontend/magnetar-common/src/be-api.ts | 112 ++++++++++++++++++ .../src/types/AvatarDecoration.ts | 3 + .../src/types/DriveFileBase.ts | 4 + .../src/types/DriveFileFolderExt.ts | 4 + .../src/types/DriveFileUserExt.ts | 4 + .../src/types/DriveFolderBase.ts | 3 + .../src/types/DriveFolderParentExt.ts | 4 + .../magnetar-common/src/types/EmojiBase.ts | 3 + .../magnetar-common/src/types/EmojiContext.ts | 4 + .../src/types/FollowVisibility.ts | 3 + .../src/types/GetTimelineReq.ts | 4 + .../frontend/magnetar-common/src/types/Id.ts | 3 + .../magnetar-common/src/types/ImageMeta.ts | 3 + .../magnetar-common/src/types/MmXml.ts | 3 + .../src/types/NoteAttachmentExt.ts | 5 + .../magnetar-common/src/types/NoteBase.ts | 8 ++ .../magnetar-common/src/types/NoteByIdReq.ts | 3 + .../src/types/NoteListFilter.ts | 3 + .../src/types/NoteSelfContextExt.ts | 3 + .../src/types/NoteVisibility.ts | 3 + .../src/types/NotificationSettings.ts | 4 + .../src/types/NotificationType.ts | 3 + .../magnetar-common/src/types/PollBase.ts | 4 + .../magnetar-common/src/types/PollChoice.ts | 3 + .../magnetar-common/src/types/ProfileField.ts | 4 + .../magnetar-common/src/types/Reaction.ts | 3 + .../magnetar-common/src/types/ReactionPair.ts | 4 + .../src/types/SecurityKeyBase.ts | 3 + .../src/types/SpeechTransform.ts | 3 + .../src/types/UserAuthOverviewExt.ts | 3 + .../magnetar-common/src/types/UserBase.ts | 7 ++ .../magnetar-common/src/types/UserByIdReq.ts | 3 + .../src/types/UserDetailExt.ts | 3 + .../src/types/UserProfileExt.ts | 5 + .../src/types/UserProfilePinsEx.ts | 4 + .../src/types/UserRelationExt.ts | 3 + .../src/types/UserSecretsExt.ts | 4 + .../magnetar-common/src/types/UserSelfExt.ts | 4 + .../magnetar-common/src/types/UserSelfReq.ts | 3 + .../src/types/endpoints/GetNoteById.ts | 11 ++ .../src/types/endpoints/GetTimeline.ts | 12 ++ .../src/types/endpoints/GetUserByAcct.ts | 12 ++ .../src/types/endpoints/GetUserById.ts | 12 ++ .../src/types/endpoints/GetUserSelf.ts | 12 ++ .../src/types/packed/PackDriveFileBase.ts | 5 + .../src/types/packed/PackDriveFileFull.ts | 7 ++ .../types/packed/PackDriveFileWithFolder.ts | 6 + .../src/types/packed/PackDriveFileWithUser.ts | 6 + .../src/types/packed/PackDriveFolderBase.ts | 5 + .../types/packed/PackDriveFolderWithParent.ts | 6 + .../src/types/packed/PackEmojiBase.ts | 5 + .../src/types/packed/PackNoteBase.ts | 5 + .../types/packed/PackNoteMaybeAttachments.ts | 7 ++ .../src/types/packed/PackNoteMaybeFull.ts | 8 ++ .../src/types/packed/PackPollBase.ts | 5 + .../src/types/packed/PackSecurityKeyBase.ts | 5 + .../src/types/packed/PackUserBase.ts | 5 + .../src/types/packed/PackUserMaybeAll.ts | 10 ++ .../src/types/packed/PackUserSelf.ts | 6 + .../src/types/packed/PackUserSelfMaybeAll.ts | 9 ++ fe_calckey/frontend/package.json | 5 +- fe_calckey/frontend/scripts/magnetar-types.js | 33 ++++++ magnetar_sdk/macros/src/lib.rs | 20 ++++ magnetar_sdk/src/types/note.rs | 1 + 65 files changed, 473 insertions(+), 3 deletions(-) create mode 100644 fe_calckey/frontend/magnetar-common/src/be-api.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/AvatarDecoration.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/DriveFileBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/DriveFileFolderExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/DriveFileUserExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/DriveFolderBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/DriveFolderParentExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/EmojiBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/EmojiContext.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/FollowVisibility.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/GetTimelineReq.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/Id.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/ImageMeta.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/MmXml.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NoteAttachmentExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NoteBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NoteByIdReq.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NoteListFilter.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NoteSelfContextExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NoteVisibility.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NotificationSettings.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NotificationType.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/PollBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/PollChoice.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/ProfileField.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/Reaction.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/ReactionPair.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/SecurityKeyBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/SpeechTransform.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserAuthOverviewExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserByIdReq.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserDetailExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserProfileExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserProfilePinsEx.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserRelationExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserSecretsExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserSelfExt.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/UserSelfReq.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/endpoints/GetNoteById.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserByAcct.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserById.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserSelf.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileFull.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileWithFolder.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileWithUser.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFolderBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFolderWithParent.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackEmojiBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteMaybeAttachments.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteMaybeFull.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackPollBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackSecurityKeyBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackUserBase.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackUserMaybeAll.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackUserSelf.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/packed/PackUserSelfMaybeAll.ts create mode 100644 fe_calckey/frontend/scripts/magnetar-types.js diff --git a/.cargo/config.toml b/.cargo/config.toml index b23105b..ba0a868 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,6 @@ [registries.crates-io] -protocol = "sparse" \ No newline at end of file +protocol = "sparse" + +[target.x86_64-unknown-linux-gnu] +linker = "clang" +rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold"] diff --git a/fe_calckey/frontend/magnetar-common/src/be-api.ts b/fe_calckey/frontend/magnetar-common/src/be-api.ts new file mode 100644 index 0000000..063c0cc --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/be-api.ts @@ -0,0 +1,112 @@ +import {FrontendApiEndpoint, FrontendApiEndpoints} from "./fe-api"; +import {GetNoteById} from "./types/endpoints/GetNoteById"; + +type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; + +export interface BackendApiEndpoint { + method: M; + endpoint: string; + pathParams: [string], + request?: T; + response?: R; +} + +function nestedUrlSearchParams(data: any, topLevel: boolean = true): string { + switch (typeof data) { + case "string": + case "bigint": + case "boolean": + case "number": + case "symbol": + if (topLevel) + return encodeURIComponent(data.toString()) + "="; + + return data.toString(); + case "object": + if (data === null) + return "null"; + + if (Array.isArray(data)) + return data.map(d => nestedUrlSearchParams(d, true)) + .map(encodeURIComponent) + .join("&"); + + const inner = Object.entries(data) + .map(([k, v]) => [k, nestedUrlSearchParams(v, false)]); + + return new URLSearchParams(inner).toString(); + + default: + return ""; + } +} + +type MagApiErrorCode = "Client:GenericApiError" | string; + +export interface MagApiError { + status: number; + code: MagApiErrorCode, + message: string, +} + +export class MagApiClient { + private readonly baseUrl: string; + + constructor(baseUrl: string) { + this.baseUrl = baseUrl; + } + + async call>( + endpoint: T["endpoint"], + method: M, + data: T["request"], + pathParams: Record, + token?: string | null | undefined + ): Promise { + type Response = T["response"]; + + const authorizationToken = token ?? undefined; + const authorization = authorizationToken + ? `Bearer ${authorizationToken}` + : undefined; + + let url = `${this.baseUrl}/${endpoint}`; + + if (method === "GET") { + const query = nestedUrlSearchParams(data as any); + if (query) { + url += `?${query}`; + } + } + + return await fetch(url, { + method, + body: method !== "GET" ? JSON.stringify(data) : undefined, + credentials: "omit", + cache: "no-cache", + headers: authorization ? {authorization} : {}, + }) + .then(async (res) => { + const body = res.status === 204 ? null : await res.json(); + + if (res.status === 200) { + return body as Response; + } else if (res.status === 204) { + return null as any as Response; + } else { + throw body as MagApiError; + } + }) + .catch((e) => { + throw ({ + status: -1, + code: "Client:GenericApiError", + message: e + }) as MagApiError; + }); + } +} + + +const a = new MagApiClient("https://aaa"); +a.call<"GET", GetNoteById>("", "",{}, {}) diff --git a/fe_calckey/frontend/magnetar-common/src/types/AvatarDecoration.ts b/fe_calckey/frontend/magnetar-common/src/types/AvatarDecoration.ts new file mode 100644 index 0000000..8121ee6 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/AvatarDecoration.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type AvatarDecoration = "None" | "CatEars"; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/DriveFileBase.ts b/fe_calckey/frontend/magnetar-common/src/types/DriveFileBase.ts new file mode 100644 index 0000000..8662b0a --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/DriveFileBase.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { ImageMeta } from "./ImageMeta"; + +export interface DriveFileBase { name: string, created_at: string, size: bigint, hash: string | null, mime_type: string, media_metadata: ImageMeta, url: string | null, thumbnail_url: string | null, sensitive: boolean, comment: string | null, folder_id: string | null, user_id: string | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/DriveFileFolderExt.ts b/fe_calckey/frontend/magnetar-common/src/types/DriveFileFolderExt.ts new file mode 100644 index 0000000..0f209f5 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/DriveFileFolderExt.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackDriveFolderBase } from "./packed/PackDriveFolderBase"; + +export interface DriveFileFolderExt { folder: PackDriveFolderBase, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/DriveFileUserExt.ts b/fe_calckey/frontend/magnetar-common/src/types/DriveFileUserExt.ts new file mode 100644 index 0000000..c5e96a5 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/DriveFileUserExt.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackUserBase } from "./packed/PackUserBase"; + +export interface DriveFileUserExt { user: PackUserBase, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/DriveFolderBase.ts b/fe_calckey/frontend/magnetar-common/src/types/DriveFolderBase.ts new file mode 100644 index 0000000..4ab23d2 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/DriveFolderBase.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface DriveFolderBase { name: string, created_at: string, comment: string | null, file_count: bigint, folder_count: bigint, parent_id: string | null, user_id: string, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/DriveFolderParentExt.ts b/fe_calckey/frontend/magnetar-common/src/types/DriveFolderParentExt.ts new file mode 100644 index 0000000..86ef03b --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/DriveFolderParentExt.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DriveFolderBase } from "./DriveFolderBase"; + +export interface DriveFolderParentExt { folder: DriveFolderBase, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/EmojiBase.ts b/fe_calckey/frontend/magnetar-common/src/types/EmojiBase.ts new file mode 100644 index 0000000..b7e2704 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/EmojiBase.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface EmojiBase { shortcode: string, url: string, category: string | null, width: number | null, height: number | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/EmojiContext.ts b/fe_calckey/frontend/magnetar-common/src/types/EmojiContext.ts new file mode 100644 index 0000000..a1ee4b6 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/EmojiContext.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackEmojiBase } from "./packed/PackEmojiBase"; + +export type EmojiContext = Array; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/FollowVisibility.ts b/fe_calckey/frontend/magnetar-common/src/types/FollowVisibility.ts new file mode 100644 index 0000000..a04d682 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/FollowVisibility.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type FollowVisibility = "Public" | "Followers" | "Private"; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/GetTimelineReq.ts b/fe_calckey/frontend/magnetar-common/src/types/GetTimelineReq.ts new file mode 100644 index 0000000..f084102 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/GetTimelineReq.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NoteListFilter } from "./NoteListFilter"; + +export interface GetTimelineReq { limit: bigint, filter: NoteListFilter | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/Id.ts b/fe_calckey/frontend/magnetar-common/src/types/Id.ts new file mode 100644 index 0000000..14270f1 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/Id.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface Id { id: string, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/ImageMeta.ts b/fe_calckey/frontend/magnetar-common/src/types/ImageMeta.ts new file mode 100644 index 0000000..e7fefb6 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/ImageMeta.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface ImageMeta { width: bigint | null, height: bigint | null, orientation: bigint | null, color: string | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/MmXml.ts b/fe_calckey/frontend/magnetar-common/src/types/MmXml.ts new file mode 100644 index 0000000..2addd37 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/MmXml.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type MmXml = string; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteAttachmentExt.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteAttachmentExt.ts new file mode 100644 index 0000000..35efeeb --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteAttachmentExt.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackDriveFileBase } from "./packed/PackDriveFileBase"; +import type { PackPollBase } from "./packed/PackPollBase"; + +export interface NoteAttachmentExt { poll: PackPollBase | null, attachments: Array, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteBase.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteBase.ts new file mode 100644 index 0000000..99aca93 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteBase.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { EmojiContext } from "./EmojiContext"; +import type { MmXml } from "./MmXml"; +import type { NoteVisibility } from "./NoteVisibility"; +import type { PackUserBase } from "./packed/PackUserBase"; +import type { ReactionPair } from "./ReactionPair"; + +export interface NoteBase { created_at: string, cw: string | null, cw_mm: MmXml | null, uri: string | null, url: string | null, text: string, text_mm: MmXml | null, visibility: NoteVisibility, user: PackUserBase, parent_note_id: string | null, renoted_note_id: string | null, reply_count: bigint, renote_count: bigint, mentions: Array, hashtags: Array, reactions: Array, local_only: boolean, has_poll: boolean, file_ids: Array, emojis: EmojiContext, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteByIdReq.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteByIdReq.ts new file mode 100644 index 0000000..afa4fa8 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteByIdReq.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface NoteByIdReq { context: boolean, attachments: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteListFilter.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteListFilter.ts new file mode 100644 index 0000000..7cc828b --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteListFilter.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface NoteListFilter { show_renotes: boolean | null, show_replies: boolean | null, show_files_only: boolean | null, uncwed_sensitive: boolean | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteSelfContextExt.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteSelfContextExt.ts new file mode 100644 index 0000000..f14a08a --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteSelfContextExt.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface NoteSelfContextExt { self_renote_count: bigint | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteVisibility.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteVisibility.ts new file mode 100644 index 0000000..06ce891 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteVisibility.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type NoteVisibility = "Public" | "Home" | "Followers" | "Direct"; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NotificationSettings.ts b/fe_calckey/frontend/magnetar-common/src/types/NotificationSettings.ts new file mode 100644 index 0000000..d7e440c --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NotificationSettings.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NotificationType } from "./NotificationType"; + +export interface NotificationSettings { enabled: Array, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NotificationType.ts b/fe_calckey/frontend/magnetar-common/src/types/NotificationType.ts new file mode 100644 index 0000000..8a53267 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NotificationType.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type NotificationType = "Follow" | "Mention" | "Reply" | "Renote" | "Quote" | "Reaction" | "PollVote" | "PollEnded" | "FollowRequest" | "FollowRequestAccepted" | "App"; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/PollBase.ts b/fe_calckey/frontend/magnetar-common/src/types/PollBase.ts new file mode 100644 index 0000000..5547095 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/PollBase.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PollChoice } from "./PollChoice"; + +export interface PollBase { expires_at: string | null, expired: boolean, multiple_choice: boolean, options: Array, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/PollChoice.ts b/fe_calckey/frontend/magnetar-common/src/types/PollChoice.ts new file mode 100644 index 0000000..5a3677e --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/PollChoice.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface PollChoice { title: string, votes_count: bigint, voted: boolean | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/ProfileField.ts b/fe_calckey/frontend/magnetar-common/src/types/ProfileField.ts new file mode 100644 index 0000000..d174e42 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/ProfileField.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { MmXml } from "./MmXml"; + +export interface ProfileField { name: string, value: string, value_mm: MmXml | null, verified_at: string | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/Reaction.ts b/fe_calckey/frontend/magnetar-common/src/types/Reaction.ts new file mode 100644 index 0000000..f78902e --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/Reaction.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type Reaction = string | { name: string, host: string | null, url: string, } | { raw: string, }; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/ReactionPair.ts b/fe_calckey/frontend/magnetar-common/src/types/ReactionPair.ts new file mode 100644 index 0000000..5cb8f91 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/ReactionPair.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Reaction } from "./Reaction"; + +export type ReactionPair = [Reaction, bigint] | [Reaction, bigint, boolean]; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/SecurityKeyBase.ts b/fe_calckey/frontend/magnetar-common/src/types/SecurityKeyBase.ts new file mode 100644 index 0000000..4c43089 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/SecurityKeyBase.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface SecurityKeyBase { name: string, last_used_at: string | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/SpeechTransform.ts b/fe_calckey/frontend/magnetar-common/src/types/SpeechTransform.ts new file mode 100644 index 0000000..dfd5930 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/SpeechTransform.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export type SpeechTransform = "None" | "Cat"; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserAuthOverviewExt.ts b/fe_calckey/frontend/magnetar-common/src/types/UserAuthOverviewExt.ts new file mode 100644 index 0000000..7aa93fa --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserAuthOverviewExt.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface UserAuthOverviewExt { has_two_factor_enabled: boolean, has_passwordless_login: boolean, has_security_keys: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserBase.ts b/fe_calckey/frontend/magnetar-common/src/types/UserBase.ts new file mode 100644 index 0000000..ee510e6 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserBase.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { AvatarDecoration } from "./AvatarDecoration"; +import type { EmojiContext } from "./EmojiContext"; +import type { MmXml } from "./MmXml"; +import type { SpeechTransform } from "./SpeechTransform"; + +export interface UserBase { acct: string, username: string, display_name: string, display_name_mm: MmXml | null, host: string | null, speech_transform: SpeechTransform, created_at: string, avatar_url: string | null, avatar_blurhash: string | null, avatar_color: string | null, avatar_decoration: AvatarDecoration, is_admin: boolean, is_moderator: boolean, is_bot: boolean, emojis: EmojiContext, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserByIdReq.ts b/fe_calckey/frontend/magnetar-common/src/types/UserByIdReq.ts new file mode 100644 index 0000000..1da49a6 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserByIdReq.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface UserByIdReq { profile: boolean, pins: boolean, detail: boolean, relation: boolean, auth: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserDetailExt.ts b/fe_calckey/frontend/magnetar-common/src/types/UserDetailExt.ts new file mode 100644 index 0000000..adfd2bb --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserDetailExt.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface UserDetailExt { last_fetched_at: string | null, uri: string | null, updated_at: string | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserProfileExt.ts b/fe_calckey/frontend/magnetar-common/src/types/UserProfileExt.ts new file mode 100644 index 0000000..37976c0 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserProfileExt.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { MmXml } from "./MmXml"; +import type { ProfileField } from "./ProfileField"; + +export interface UserProfileExt { is_locked: boolean, is_silenced: boolean, is_suspended: boolean, description: string | null, description_mm: MmXml | null, location: string | null, birthday: string | null, fields: Array, follower_count: bigint | null, following_count: bigint | null, note_count: bigint | null, url: string | null, moved_to_uri: string | null, also_known_as: string | null, banner_url: string | null, banner_color: string | null, banner_blurhash: string | null, has_public_reactions: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserProfilePinsEx.ts b/fe_calckey/frontend/magnetar-common/src/types/UserProfilePinsEx.ts new file mode 100644 index 0000000..18f6842 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserProfilePinsEx.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackNoteMaybeFull } from "./packed/PackNoteMaybeFull"; + +export interface UserProfilePinsEx { pinned_notes: Array, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserRelationExt.ts b/fe_calckey/frontend/magnetar-common/src/types/UserRelationExt.ts new file mode 100644 index 0000000..04b9e29 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserRelationExt.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface UserRelationExt { follows_you: boolean, you_follow: boolean, blocks_you: boolean, you_block: boolean, mute: boolean, mute_renotes: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserSecretsExt.ts b/fe_calckey/frontend/magnetar-common/src/types/UserSecretsExt.ts new file mode 100644 index 0000000..4ba1e2c --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserSecretsExt.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackSecurityKeyBase } from "./packed/PackSecurityKeyBase"; + +export interface UserSecretsExt { email: string | null, email_verified: boolean, security_keys: Array, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserSelfExt.ts b/fe_calckey/frontend/magnetar-common/src/types/UserSelfExt.ts new file mode 100644 index 0000000..64c179c --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserSelfExt.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NotificationSettings } from "./NotificationSettings"; + +export interface UserSelfExt { avatar_id: string | null, banner_id: string | null, email_announcements: boolean, always_mark_sensitive: boolean, reject_bot_follow_requests: boolean, reject_crawlers: boolean, reject_ai_training: boolean, has_unread_announcements: boolean, has_unread_antenna: boolean, has_unread_notifications: boolean, has_pending_follow_requests: boolean, word_mutes: Array, instance_mutes: Array, notification_settings: NotificationSettings, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserSelfReq.ts b/fe_calckey/frontend/magnetar-common/src/types/UserSelfReq.ts new file mode 100644 index 0000000..b0527fc --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/UserSelfReq.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface UserSelfReq { profile: boolean, pins: boolean, detail: boolean, secrets: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetNoteById.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetNoteById.ts new file mode 100644 index 0000000..6c96a1f --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetNoteById.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { NoteByIdReq } from "../NoteByIdReq"; +import type { PackNoteMaybeFull } from "../packed/PackNoteMaybeFull"; + +interface GetNoteById { + endpoint: "/notes/:id", + pathParams: ["id"], + method: "GET", + request: NoteByIdReq, + response: PackNoteMaybeFull +} diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts new file mode 100644 index 0000000..6ef7183 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { GetTimelineReq } from "../GetTimelineReq"; +import type { PackNoteMaybeFull } from "../packed/PackNoteMaybeFull"; + +export interface GetTimeline { + endpoint: "/timeline"; + pathParams: []; + method: "GET"; + request: GetTimelineReq; + response: Array; +} + \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserByAcct.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserByAcct.ts new file mode 100644 index 0000000..5846031 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserByAcct.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackUserMaybeAll } from "../packed/PackUserMaybeAll"; +import type { UserByIdReq } from "../UserByIdReq"; + +export interface GetUserByAcct { + endpoint: "/users/by-acct/:user_id"; + pathParams: ["user_id"]; + method: "GET"; + request: UserByIdReq; + response: PackUserMaybeAll; +} + \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserById.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserById.ts new file mode 100644 index 0000000..b951f3f --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserById.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackUserMaybeAll } from "../packed/PackUserMaybeAll"; +import type { UserByIdReq } from "../UserByIdReq"; + +export interface GetUserById { + endpoint: "/users/:user_id"; + pathParams: ["user_id"]; + method: "GET"; + request: UserByIdReq; + response: PackUserMaybeAll; +} + \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserSelf.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserSelf.ts new file mode 100644 index 0000000..2702509 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserSelf.ts @@ -0,0 +1,12 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackUserSelfMaybeAll } from "../packed/PackUserSelfMaybeAll"; +import type { UserSelfReq } from "../UserSelfReq"; + +export interface GetUserSelf { + endpoint: "/users/@self"; + pathParams: []; + method: "GET"; + request: UserSelfReq; + response: PackUserSelfMaybeAll; +} + \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileBase.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileBase.ts new file mode 100644 index 0000000..187eec5 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileBase.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DriveFileBase } from "../DriveFileBase"; +import type { Id } from "../Id"; + +export type PackDriveFileBase = Id & DriveFileBase; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileFull.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileFull.ts new file mode 100644 index 0000000..5536c92 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileFull.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DriveFileBase } from "../DriveFileBase"; +import type { DriveFileFolderExt } from "../DriveFileFolderExt"; +import type { DriveFileUserExt } from "../DriveFileUserExt"; +import type { Id } from "../Id"; + +export type PackDriveFileFull = Id & DriveFileBase & DriveFileFolderExt & DriveFileUserExt; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileWithFolder.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileWithFolder.ts new file mode 100644 index 0000000..c888ebf --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileWithFolder.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DriveFileBase } from "../DriveFileBase"; +import type { DriveFileFolderExt } from "../DriveFileFolderExt"; +import type { Id } from "../Id"; + +export type PackDriveFileWithFolder = Id & DriveFileBase & DriveFileFolderExt; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileWithUser.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileWithUser.ts new file mode 100644 index 0000000..65baaab --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFileWithUser.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DriveFileBase } from "../DriveFileBase"; +import type { DriveFileUserExt } from "../DriveFileUserExt"; +import type { Id } from "../Id"; + +export type PackDriveFileWithUser = Id & DriveFileBase & DriveFileUserExt; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFolderBase.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFolderBase.ts new file mode 100644 index 0000000..4a9429d --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFolderBase.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DriveFolderBase } from "../DriveFolderBase"; +import type { Id } from "../Id"; + +export type PackDriveFolderBase = Id & DriveFolderBase; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFolderWithParent.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFolderWithParent.ts new file mode 100644 index 0000000..2b6af70 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackDriveFolderWithParent.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { DriveFolderBase } from "../DriveFolderBase"; +import type { DriveFolderParentExt } from "../DriveFolderParentExt"; +import type { Id } from "../Id"; + +export type PackDriveFolderWithParent = Id & DriveFolderBase & DriveFolderParentExt; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackEmojiBase.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackEmojiBase.ts new file mode 100644 index 0000000..7ad8c7a --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackEmojiBase.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { EmojiBase } from "../EmojiBase"; +import type { Id } from "../Id"; + +export type PackEmojiBase = Id & EmojiBase; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteBase.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteBase.ts new file mode 100644 index 0000000..2586669 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteBase.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { NoteBase } from "../NoteBase"; + +export type PackNoteBase = Id & NoteBase; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteMaybeAttachments.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteMaybeAttachments.ts new file mode 100644 index 0000000..1b7f8bf --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteMaybeAttachments.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { NoteAttachmentExt } from "../NoteAttachmentExt"; +import type { NoteBase } from "../NoteBase"; +import type { NoteSelfContextExt } from "../NoteSelfContextExt"; + +export type PackNoteMaybeAttachments = Id & NoteBase & Partial & Partial; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteMaybeFull.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteMaybeFull.ts new file mode 100644 index 0000000..bb834c7 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackNoteMaybeFull.ts @@ -0,0 +1,8 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { NoteAttachmentExt } from "../NoteAttachmentExt"; +import type { NoteBase } from "../NoteBase"; +import type { NoteDetailExt } from "../NoteDetailExt"; +import type { NoteSelfContextExt } from "../NoteSelfContextExt"; + +export type PackNoteMaybeFull = Id & NoteBase & Partial & Partial & Partial; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackPollBase.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackPollBase.ts new file mode 100644 index 0000000..4a28cf3 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackPollBase.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { PollBase } from "../PollBase"; + +export type PackPollBase = Id & PollBase; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackSecurityKeyBase.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackSecurityKeyBase.ts new file mode 100644 index 0000000..db208c8 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackSecurityKeyBase.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { SecurityKeyBase } from "../SecurityKeyBase"; + +export type PackSecurityKeyBase = Id & SecurityKeyBase; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserBase.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserBase.ts new file mode 100644 index 0000000..d00fac6 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserBase.ts @@ -0,0 +1,5 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { UserBase } from "../UserBase"; + +export type PackUserBase = Id & UserBase; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserMaybeAll.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserMaybeAll.ts new file mode 100644 index 0000000..7869d9d --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserMaybeAll.ts @@ -0,0 +1,10 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { UserAuthOverviewExt } from "../UserAuthOverviewExt"; +import type { UserBase } from "../UserBase"; +import type { UserDetailExt } from "../UserDetailExt"; +import type { UserProfileExt } from "../UserProfileExt"; +import type { UserProfilePinsEx } from "../UserProfilePinsEx"; +import type { UserRelationExt } from "../UserRelationExt"; + +export type PackUserMaybeAll = Id & UserBase & Partial & Partial & Partial & Partial & Partial; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserSelf.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserSelf.ts new file mode 100644 index 0000000..477f13e --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserSelf.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { UserBase } from "../UserBase"; +import type { UserSelfExt } from "../UserSelfExt"; + +export type PackUserSelf = Id & UserBase & UserSelfExt; \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserSelfMaybeAll.ts b/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserSelfMaybeAll.ts new file mode 100644 index 0000000..0b4169b --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/packed/PackUserSelfMaybeAll.ts @@ -0,0 +1,9 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Id } from "../Id"; +import type { UserBase } from "../UserBase"; +import type { UserDetailExt } from "../UserDetailExt"; +import type { UserProfileExt } from "../UserProfileExt"; +import type { UserProfilePinsEx } from "../UserProfilePinsEx"; +import type { UserSecretsExt } from "../UserSecretsExt"; + +export type PackUserSelfMaybeAll = Id & UserBase & Partial & Partial & Partial & Partial; \ No newline at end of file diff --git a/fe_calckey/frontend/package.json b/fe_calckey/frontend/package.json index 22c0e0f..0e18aa3 100644 --- a/fe_calckey/frontend/package.json +++ b/fe_calckey/frontend/package.json @@ -9,8 +9,9 @@ "packageManager": "pnpm@8.6.3", "private": true, "scripts": { - "rebuild": "pnpm run clean && pnpm -r run build && pnpm run gulp", - "build": "pnpm -r run build && pnpm run gulp", + "magnetar-types": "pnpm node ./scripts/magnetar-types.js", + "rebuild": "pnpm run clean && pnpm run magnetar-types && pnpm -r run build && pnpm run gulp", + "build": "pnpm run magnetar-types && pnpm -r run build && pnpm run gulp", "gulp": "gulp build", "dev:staging": "NODE_OPTIONS=--max_old_space_size=3072 NODE_ENV=development pnpm run build && pnpm run start", "lint": "pnpm -r run lint", diff --git a/fe_calckey/frontend/scripts/magnetar-types.js b/fe_calckey/frontend/scripts/magnetar-types.js new file mode 100644 index 0000000..b9af35d --- /dev/null +++ b/fe_calckey/frontend/scripts/magnetar-types.js @@ -0,0 +1,33 @@ +const fs = require("node:fs"); +const execa = require("execa"); +const chalk = require("chalk"); +const { join } = require("node:path"); + +(async () => { + console.log(chalk.italic`Generating Magnetar types, this may take a while...`) + + const { failed } = await execa.command("cargo test --release --package magnetar_sdk", { + cwd: "../../magnetar_sdk", + stdout: "inherit" + }); + + if (failed) { + console.error(chalk.red`Type generation failed.`); + return; + } + + console.log(chalk.green`Successfully generated Magnetar types`); + + const srcPath = "../../magnetar_sdk/bindings"; + const destPath = "magnetar-common/src/types"; + + + console.log(chalk.italic`Deleting old`, `"${destPath}"`); + fs.rmSync(destPath, { recursive: true, force: true }); + console.log(chalk.italic`Copying generated Magnetar types...`); + console.log(chalk.italic`From`, `"${srcPath}"`, chalk.italic`to`, `"${destPath}"`); + fs.cpSync(`${srcPath}/`, `${destPath}/`, { recursive: true }); + console.log(chalk.italic`Deleting`, `"${srcPath}"`); + fs.rmSync(srcPath, { recursive: true, force: true }); + +})(); diff --git a/magnetar_sdk/macros/src/lib.rs b/magnetar_sdk/macros/src/lib.rs index 4792975..be482da 100644 --- a/magnetar_sdk/macros/src/lib.rs +++ b/magnetar_sdk/macros/src/lib.rs @@ -272,6 +272,24 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { let request = request.expect("missing request attribute"); let response = response.expect("missing response attribute"); + let mut endpoint_chars = endpoint.chars(); + let mut path_params = String::from("["); + while let Some(c) = endpoint_chars.next() { + if c == ':' { + if !path_params.ends_with('[') { + path_params += ", "; + } + + path_params += "\""; + path_params += &endpoint_chars + .clone() + .take_while(|c| c.is_ascii_alphanumeric() || *c == '_') + .collect::(); + path_params += "\""; + } + } + path_params += "]"; + let ts_path = format!("bindings/endpoints/{}.ts", name); let export_name = Ident::new( &format!("export_bindings_{}", struct_name.to_string().to_lowercase()), @@ -340,6 +358,7 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { format!( "interface {} {{\n \ endpoint: \"{}\";\n \ + pathParams: {};\n \ method: \"{}\";\n \ request: {};\n \ response: {};\n\ @@ -347,6 +366,7 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { ", Self::name(), Self::ENDPOINT, + #path_params, Self::METHOD, #call_name_req, #call_name_res diff --git a/magnetar_sdk/src/types/note.rs b/magnetar_sdk/src/types/note.rs index 30de780..3c43b76 100644 --- a/magnetar_sdk/src/types/note.rs +++ b/magnetar_sdk/src/types/note.rs @@ -93,6 +93,7 @@ pack!( ); #[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] pub struct NoteDetailExt { pub parent_note: Option>, pub renoted_note: Option>, From c8627a996c159cb10dc2ccd485ef27fdec9e5247 Mon Sep 17 00:00:00 2001 From: Natty Date: Fri, 3 Nov 2023 19:56:29 +0100 Subject: [PATCH 3/7] Undo an accidental commit of the linker setting --- .cargo/config.toml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index ba0a868..70f9eae 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,6 +1,2 @@ [registries.crates-io] protocol = "sparse" - -[target.x86_64-unknown-linux-gnu] -linker = "clang" -rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold"] From a5ab2acca059799919943b1094a45300d70a39fa Mon Sep 17 00:00:00 2001 From: Natty Date: Fri, 3 Nov 2023 21:14:17 +0100 Subject: [PATCH 4/7] TS_RS Rust and TypeScript types should now be in parity --- .../frontend/magnetar-common/src/be-api.ts | 64 ++++++++++++------- .../src/types/GetTimelineReq.ts | 2 +- .../magnetar-common/src/types/NoteByIdReq.ts | 2 +- .../src/types/NoteDetailExt.ts | 4 ++ .../magnetar-common/src/types/UserByIdReq.ts | 2 +- .../magnetar-common/src/types/UserSelfReq.ts | 2 +- .../src/types/endpoints/GetNoteById.ts | 11 ++-- .../src/types/endpoints/GetTimeline.ts | 15 ++--- .../src/types/endpoints/GetUserByAcct.ts | 12 ++-- .../src/types/endpoints/GetUserById.ts | 12 ++-- .../src/types/endpoints/GetUserSelf.ts | 12 ++-- magnetar_sdk/macros/src/lib.rs | 13 ++-- magnetar_sdk/src/endpoints/note.rs | 8 +-- magnetar_sdk/src/endpoints/timeline.rs | 9 +-- magnetar_sdk/src/endpoints/user.rs | 36 +++++------ src/api_v1/note.rs | 4 +- 16 files changed, 116 insertions(+), 92 deletions(-) create mode 100644 fe_calckey/frontend/magnetar-common/src/types/NoteDetailExt.ts diff --git a/fe_calckey/frontend/magnetar-common/src/be-api.ts b/fe_calckey/frontend/magnetar-common/src/be-api.ts index 063c0cc..620c062 100644 --- a/fe_calckey/frontend/magnetar-common/src/be-api.ts +++ b/fe_calckey/frontend/magnetar-common/src/be-api.ts @@ -1,12 +1,16 @@ -import {FrontendApiEndpoint, FrontendApiEndpoints} from "./fe-api"; -import {GetNoteById} from "./types/endpoints/GetNoteById"; +import { GetNoteById } from "./types/endpoints/GetNoteById"; type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; -export interface BackendApiEndpoint { +export interface BackendApiEndpoint< + M extends Method, + PP extends string[], + T, + R +> { method: M; endpoint: string; - pathParams: [string], + pathParams: PP; request?: T; response?: R; } @@ -18,21 +22,22 @@ function nestedUrlSearchParams(data: any, topLevel: boolean = true): string { case "boolean": case "number": case "symbol": - if (topLevel) - return encodeURIComponent(data.toString()) + "="; + if (topLevel) return encodeURIComponent(data.toString()) + "="; return data.toString(); case "object": - if (data === null) - return "null"; + if (data === null) return "null"; if (Array.isArray(data)) - return data.map(d => nestedUrlSearchParams(d, true)) + return data + .map((d) => nestedUrlSearchParams(d, true)) .map(encodeURIComponent) .join("&"); - const inner = Object.entries(data) - .map(([k, v]) => [k, nestedUrlSearchParams(v, false)]); + const inner = Object.entries(data).map(([k, v]) => [ + k, + nestedUrlSearchParams(v, false), + ]); return new URLSearchParams(inner).toString(); @@ -45,8 +50,8 @@ type MagApiErrorCode = "Client:GenericApiError" | string; export interface MagApiError { status: number; - code: MagApiErrorCode, - message: string, + code: MagApiErrorCode; + message: string; } export class MagApiClient { @@ -56,11 +61,21 @@ export class MagApiClient { this.baseUrl = baseUrl; } - async call>( - endpoint: T["endpoint"], - method: M, + async call< + T extends BackendApiEndpoint< + T["method"] & Method, + T["pathParams"] & string[], + T["request"], + T["response"] + > + >( + { endpoint, method }: T, data: T["request"], - pathParams: Record, + pathParams: { + [K in keyof T["pathParams"] as T["pathParams"][K] & string]: + | string + | number; + }, token?: string | null | undefined ): Promise { type Response = T["response"]; @@ -70,6 +85,10 @@ export class MagApiClient { ? `Bearer ${authorizationToken}` : undefined; + for (const name in pathParams) { + endpoint = endpoint.replace(`:${name}`, `${pathParams[name]}`); + } + let url = `${this.baseUrl}/${endpoint}`; if (method === "GET") { @@ -84,7 +103,7 @@ export class MagApiClient { body: method !== "GET" ? JSON.stringify(data) : undefined, credentials: "omit", cache: "no-cache", - headers: authorization ? {authorization} : {}, + headers: authorization ? { authorization } : {}, }) .then(async (res) => { const body = res.status === 204 ? null : await res.json(); @@ -98,15 +117,14 @@ export class MagApiClient { } }) .catch((e) => { - throw ({ + throw { status: -1, code: "Client:GenericApiError", - message: e - }) as MagApiError; + message: e, + } as MagApiError; }); } } - const a = new MagApiClient("https://aaa"); -a.call<"GET", GetNoteById>("", "",{}, {}) +const result = await a.call(GetNoteById, { attachments: true }, { id: "aaaa" }); diff --git a/fe_calckey/frontend/magnetar-common/src/types/GetTimelineReq.ts b/fe_calckey/frontend/magnetar-common/src/types/GetTimelineReq.ts index f084102..00b3b07 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/GetTimelineReq.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/GetTimelineReq.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { NoteListFilter } from "./NoteListFilter"; -export interface GetTimelineReq { limit: bigint, filter: NoteListFilter | null, } \ No newline at end of file +export interface GetTimelineReq { limit?: bigint, filter?: NoteListFilter, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteByIdReq.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteByIdReq.ts index afa4fa8..89c08ba 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/NoteByIdReq.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteByIdReq.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface NoteByIdReq { context: boolean, attachments: boolean, } \ No newline at end of file +export interface NoteByIdReq { context?: boolean, attachments?: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteDetailExt.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteDetailExt.ts new file mode 100644 index 0000000..3482627 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteDetailExt.ts @@ -0,0 +1,4 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { PackNoteMaybeAttachments } from "./packed/PackNoteMaybeAttachments"; + +export interface NoteDetailExt { parent_note: PackNoteMaybeAttachments | null, renoted_note: PackNoteMaybeAttachments | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserByIdReq.ts b/fe_calckey/frontend/magnetar-common/src/types/UserByIdReq.ts index 1da49a6..91ba28b 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/UserByIdReq.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/UserByIdReq.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface UserByIdReq { profile: boolean, pins: boolean, detail: boolean, relation: boolean, auth: boolean, } \ No newline at end of file +export interface UserByIdReq { profile?: boolean, pins?: boolean, detail?: boolean, relation?: boolean, auth?: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserSelfReq.ts b/fe_calckey/frontend/magnetar-common/src/types/UserSelfReq.ts index b0527fc..20202e8 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/UserSelfReq.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/UserSelfReq.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface UserSelfReq { profile: boolean, pins: boolean, detail: boolean, secrets: boolean, } \ No newline at end of file +export interface UserSelfReq { profile?: boolean, pins?: boolean, detail?: boolean, secrets?: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetNoteById.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetNoteById.ts index 6c96a1f..d292e2f 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetNoteById.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetNoteById.ts @@ -2,10 +2,11 @@ import type { NoteByIdReq } from "../NoteByIdReq"; import type { PackNoteMaybeFull } from "../packed/PackNoteMaybeFull"; -interface GetNoteById { +export const GetNoteById = { endpoint: "/notes/:id", - pathParams: ["id"], - method: "GET", - request: NoteByIdReq, - response: PackNoteMaybeFull + pathParams: ["id"] as ["id"], + method: "GET" as "GET" | "POST" | "PUT" | "DELETE" | "PATCH", + request: undefined as unknown as NoteByIdReq, + response: undefined as unknown as PackNoteMaybeFull } + \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts index 6ef7183..148c7a3 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts @@ -2,11 +2,10 @@ import type { GetTimelineReq } from "../GetTimelineReq"; import type { PackNoteMaybeFull } from "../packed/PackNoteMaybeFull"; -export interface GetTimeline { - endpoint: "/timeline"; - pathParams: []; - method: "GET"; - request: GetTimelineReq; - response: Array; -} - \ No newline at end of file +export const GetTimeline = { + endpoint: "/timeline", + pathParams: [] as [], + method: "GET" as "GET" | "POST" | "PUT" | "DELETE" | "PATCH", + request: undefined as unknown as GetTimelineReq, + response: undefined as unknown as Array, +}; diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserByAcct.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserByAcct.ts index 5846031..561116a 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserByAcct.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserByAcct.ts @@ -2,11 +2,11 @@ import type { PackUserMaybeAll } from "../packed/PackUserMaybeAll"; import type { UserByIdReq } from "../UserByIdReq"; -export interface GetUserByAcct { - endpoint: "/users/by-acct/:user_id"; - pathParams: ["user_id"]; - method: "GET"; - request: UserByIdReq; - response: PackUserMaybeAll; +export const GetUserByAcct = { + endpoint: "/users/by-acct/:user_id", + pathParams: ["user_id"] as ["user_id"], + method: "GET" as "GET" | "POST" | "PUT" | "DELETE" | "PATCH", + request: undefined as unknown as UserByIdReq, + response: undefined as unknown as PackUserMaybeAll } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserById.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserById.ts index b951f3f..fd203be 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserById.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserById.ts @@ -2,11 +2,11 @@ import type { PackUserMaybeAll } from "../packed/PackUserMaybeAll"; import type { UserByIdReq } from "../UserByIdReq"; -export interface GetUserById { - endpoint: "/users/:user_id"; - pathParams: ["user_id"]; - method: "GET"; - request: UserByIdReq; - response: PackUserMaybeAll; +export const GetUserById = { + endpoint: "/users/:user_id", + pathParams: ["user_id"] as ["user_id"], + method: "GET" as "GET" | "POST" | "PUT" | "DELETE" | "PATCH", + request: undefined as unknown as UserByIdReq, + response: undefined as unknown as PackUserMaybeAll } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserSelf.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserSelf.ts index 2702509..40303ef 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserSelf.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetUserSelf.ts @@ -2,11 +2,11 @@ import type { PackUserSelfMaybeAll } from "../packed/PackUserSelfMaybeAll"; import type { UserSelfReq } from "../UserSelfReq"; -export interface GetUserSelf { - endpoint: "/users/@self"; - pathParams: []; - method: "GET"; - request: UserSelfReq; - response: PackUserSelfMaybeAll; +export const GetUserSelf = { + endpoint: "/users/@self", + pathParams: [] as [], + method: "GET" as "GET" | "POST" | "PUT" | "DELETE" | "PATCH", + request: undefined as unknown as UserSelfReq, + response: undefined as unknown as PackUserSelfMaybeAll } \ No newline at end of file diff --git a/magnetar_sdk/macros/src/lib.rs b/magnetar_sdk/macros/src/lib.rs index be482da..a323b44 100644 --- a/magnetar_sdk/macros/src/lib.rs +++ b/magnetar_sdk/macros/src/lib.rs @@ -356,17 +356,18 @@ pub fn derive_endpoint(item: TokenStream) -> TokenStream { fn decl() -> String { format!( - "interface {} {{\n \ - endpoint: \"{}\";\n \ - pathParams: {};\n \ - method: \"{}\";\n \ - request: {};\n \ - response: {};\n\ + "const {} = {{\n \ + endpoint: \"{}\",\n \ + pathParams: {} as {},\n \ + method: \"{}\" as \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\",\n \ + request: undefined as unknown as {},\n \ + response: undefined as unknown as {}\n\ }} ", Self::name(), Self::ENDPOINT, #path_params, + #path_params, Self::METHOD, #call_name_req, #call_name_res diff --git a/magnetar_sdk/src/endpoints/note.rs b/magnetar_sdk/src/endpoints/note.rs index a80671a..fe52f99 100644 --- a/magnetar_sdk/src/endpoints/note.rs +++ b/magnetar_sdk/src/endpoints/note.rs @@ -9,10 +9,10 @@ use ts_rs::TS; #[derive(Serialize, Deserialize, TS)] #[ts(export)] pub struct NoteByIdReq { - #[serde(default)] - pub context: bool, - #[serde(default)] - pub attachments: bool, + #[ts(optional)] + pub context: Option, + #[ts(optional)] + pub attachments: Option, } #[derive(Endpoint)] diff --git a/magnetar_sdk/src/endpoints/timeline.rs b/magnetar_sdk/src/endpoints/timeline.rs index 680097f..d1e7c1e 100644 --- a/magnetar_sdk/src/endpoints/timeline.rs +++ b/magnetar_sdk/src/endpoints/timeline.rs @@ -10,13 +10,14 @@ use ts_rs::TS; #[derive(Serialize, Deserialize, TS)] #[ts(export)] pub struct GetTimelineReq { - #[serde(default = "default_timeline_limit")] - pub limit: U64Range<1, 100>, + #[ts(optional)] + pub limit: Option>, + #[ts(optional)] pub filter: Option, } -fn default_timeline_limit() -> U64Range { - 15.try_into().unwrap() +pub fn default_timeline_limit() -> U64Range { + 30.try_into().unwrap() } #[derive(Endpoint)] diff --git a/magnetar_sdk/src/endpoints/user.rs b/magnetar_sdk/src/endpoints/user.rs index 5c89be0..436715f 100644 --- a/magnetar_sdk/src/endpoints/user.rs +++ b/magnetar_sdk/src/endpoints/user.rs @@ -10,14 +10,14 @@ use crate::types::user::{PackUserMaybeAll, PackUserSelfMaybeAll}; #[derive(Serialize, Deserialize, TS)] #[ts(export)] pub struct UserSelfReq { - #[serde(default)] - pub profile: bool, - #[serde(default)] - pub pins: bool, - #[serde(default)] - pub detail: bool, - #[serde(default)] - pub secrets: bool, + #[ts(optional)] + pub profile: Option, + #[ts(optional)] + pub pins: Option, + #[ts(optional)] + pub detail: Option, + #[ts(optional)] + pub secrets: Option, } #[derive(Endpoint)] @@ -33,16 +33,16 @@ pub struct GetUserSelf; #[derive(Serialize, Deserialize, TS)] #[ts(export)] pub struct UserByIdReq { - #[serde(default)] - pub profile: bool, - #[serde(default)] - pub pins: bool, - #[serde(default)] - pub detail: bool, - #[serde(default)] - pub relation: bool, - #[serde(default)] - pub auth: bool, + #[ts(optional)] + pub profile: Option, + #[ts(optional)] + pub pins: Option, + #[ts(optional)] + pub detail: Option, + #[ts(optional)] + pub relation: Option, + #[ts(optional)] + pub auth: Option, } #[derive(Endpoint)] diff --git a/src/api_v1/note.rs b/src/api_v1/note.rs index d27d453..b2ca4e0 100644 --- a/src/api_v1/note.rs +++ b/src/api_v1/note.rs @@ -22,8 +22,8 @@ pub async fn handle_note( ) -> Result>, ApiError> { let ctx = PackingContext::new(service, self_user.clone()).await?; let note = NoteModel { - attachments, - with_context: context, + attachments: attachments.unwrap_or_default(), + with_context: context.unwrap_or_default(), } .fetch_single(&ctx, self_user.as_deref(), &id) .await? From 6908a2f350c4475c0e25fa3fdf72de9c8e60d2b9 Mon Sep 17 00:00:00 2001 From: Natty Date: Sun, 5 Nov 2023 15:23:48 +0100 Subject: [PATCH 5/7] Proxied images and user instance meta resolving --- Cargo.lock | 7 +- Cargo.toml | 1 + config/default.toml | 13 +++ ext_calckey_model/src/lib.rs | 13 +++ ext_calckey_model/src/note_model.rs | 1 - magnetar_common/Cargo.toml | 2 + magnetar_common/src/config.rs | 33 +++++++- magnetar_sdk/src/lib.rs | 1 - magnetar_sdk/src/types/drive.rs | 2 + magnetar_sdk/src/types/instance.rs | 13 +++ magnetar_sdk/src/types/mod.rs | 1 + magnetar_sdk/src/types/note.rs | 2 + magnetar_sdk/src/types/user.rs | 8 +- src/model/data/drive.rs | 25 +++++- src/model/data/instance.rs | 16 ++++ src/model/data/mod.rs | 1 + src/model/data/note.rs | 3 + src/model/data/user.rs | 40 +++++++-- src/model/processing/drive.rs | 125 +++++++++++++++++++++++++++- src/model/processing/mod.rs | 5 ++ src/model/processing/user.rs | 54 +++++++++++- src/service/instance_cache.rs | 89 ++++++++++++++++++++ src/service/mod.rs | 10 +++ 23 files changed, 443 insertions(+), 22 deletions(-) create mode 100644 magnetar_sdk/src/types/instance.rs create mode 100644 src/model/data/instance.rs create mode 100644 src/service/instance_cache.rs diff --git a/Cargo.lock b/Cargo.lock index 136912d..295c786 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1482,6 +1482,7 @@ dependencies = [ "tracing", "tracing-subscriber", "unicode-segmentation", + "url", ] [[package]] @@ -1537,12 +1538,14 @@ dependencies = [ name = "magnetar_common" version = "0.2.1-alpha" dependencies = [ + "idna", "magnetar_core", "magnetar_sdk", "percent-encoding", "serde", "thiserror", "toml 0.8.1", + "url", ] [[package]] @@ -3670,9 +3673,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", diff --git a/Cargo.toml b/Cargo.toml index e6a68d0..2af3aae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,6 +88,7 @@ hyper = { workspace = true, features = ["full"] } tokio = { workspace = true, features = ["full"] } tower = { workspace = true } tower-http = { workspace = true, features = ["cors", "trace", "fs"] } +url = { workspace = true } idna = { workspace = true } diff --git a/config/default.toml b/config/default.toml index 07cd085..a855fba 100644 --- a/config/default.toml +++ b/config/default.toml @@ -47,6 +47,19 @@ # Environment variable: MAG_C_BIND_ADDR # networking.bind_addr = "::" +# [Optional] +# The URL of a media proxy +# Default: null +# Environment variable: MAG_C_MEDIA_PROXY +# networking.media_proxy = "" + +# [Optional] +# Whether to proxy remote files through this instance +# Default: false +# Environment variable: MAG_C_PROXY_REMOTE_FILES +# networking.proxy_remote_files = false + + # -----------------------------[ CALCKEY FRONTEND ]---------------------------- # [Optional] diff --git a/ext_calckey_model/src/lib.rs b/ext_calckey_model/src/lib.rs index 1afba36..573c749 100644 --- a/ext_calckey_model/src/lib.rs +++ b/ext_calckey_model/src/lib.rs @@ -61,6 +61,7 @@ impl CalckeyModel { .sqlx_logging_level(LevelFilter::Debug) .to_owned(); + info!("Attempting database connection..."); Ok(CalckeyModel(sea_orm::Database::connect(opt).await?)) } @@ -224,6 +225,18 @@ impl CalckeyModel { .await?) } + pub async fn get_instance( + &self, + host: &str, + ) -> Result, CalckeyDbError> { + let instance = instance::Entity::find() + .filter(instance::Column::Host.eq(host)) + .one(&self.0) + .await?; + + Ok(instance) + } + pub async fn get_instance_meta(&self) -> Result { let txn = self.0.begin().await?; diff --git a/ext_calckey_model/src/note_model.rs b/ext_calckey_model/src/note_model.rs index 006b7e8..8dfa9e4 100644 --- a/ext_calckey_model/src/note_model.rs +++ b/ext_calckey_model/src/note_model.rs @@ -5,7 +5,6 @@ use sea_orm::{ QueryFilter, QueryResult, QuerySelect, QueryTrait, RelationTrait, Select, }; use serde::{Deserialize, Serialize}; -use tracing::info; use ck::{drive_file, note, note_reaction, user}; use magnetar_sdk::types::RangeFilter; diff --git a/magnetar_common/Cargo.toml b/magnetar_common/Cargo.toml index 0aa0726..d6acd8d 100644 --- a/magnetar_common/Cargo.toml +++ b/magnetar_common/Cargo.toml @@ -10,7 +10,9 @@ crate-type = ["rlib"] magnetar_core = { path = "../core" } magnetar_sdk = { path = "../magnetar_sdk" } +idna = { workspace = true } percent-encoding = { workspace = true } serde = { workspace = true, features = ["derive"] } toml = { workspace = true } thiserror = { workspace = true } +url = { workspace = true } diff --git a/magnetar_common/src/config.rs b/magnetar_common/src/config.rs index a1d6946..77b5c09 100644 --- a/magnetar_common/src/config.rs +++ b/magnetar_common/src/config.rs @@ -10,6 +10,8 @@ pub struct MagnetarNetworking { pub port: u16, pub bind_addr: IpAddr, pub protocol: MagnetarNetworkingProtocol, + pub media_proxy: Option, + pub proxy_remote_files: bool, } #[derive(Deserialize, Debug)] @@ -66,6 +68,19 @@ fn env_protocol() -> MagnetarNetworkingProtocol { } } +fn env_media_proxy() -> Option { + std::env::var("MAG_C_MEDIA_PROXY") + .ok() + .filter(String::is_empty) +} + +fn env_proxy_remote_files() -> bool { + std::env::var("MAG_C_PROXY_REMOTE_FILES") + .unwrap_or_else(|_| "false".to_string()) + .parse() + .expect("MAG_C_PROXY_REMOTE_FILES must be a boolean") +} + impl Default for MagnetarNetworking { fn default() -> Self { MagnetarNetworking { @@ -73,6 +88,8 @@ impl Default for MagnetarNetworking { bind_addr: env_bind_addr(), port: env_port(), protocol: env_protocol(), + media_proxy: env_media_proxy(), + proxy_remote_files: env_proxy_remote_files(), } } } @@ -192,6 +209,8 @@ pub enum MagnetarConfigError { IoError(#[from] std::io::Error), #[error("Failed to parse configuration: {0}")] DeserializeError(#[from] toml::de::Error), + #[error("Configuration error: Not a valid hostname")] + ConfigHostnameError(#[from] idna::Errors), } pub fn load_config() -> Result { @@ -200,7 +219,19 @@ pub fn load_config() -> Result { let str_cfg = std::fs::read_to_string(path)?; - let config = toml::from_str(&str_cfg)?; + let mut config: MagnetarConfig = toml::from_str(&str_cfg)?; + + // Validate the host + idna::domain_to_unicode(&config.networking.host).1?; + + if config + .networking + .media_proxy + .as_deref() + .is_some_and(str::is_empty) + { + config.networking.media_proxy = None; + } Ok(config) } diff --git a/magnetar_sdk/src/lib.rs b/magnetar_sdk/src/lib.rs index f2a954d..c2ba37a 100644 --- a/magnetar_sdk/src/lib.rs +++ b/magnetar_sdk/src/lib.rs @@ -1,4 +1,3 @@ -use chrono::format; use serde::{Deserialize, Serialize}; use std::ops::{Deref, DerefMut}; use ts_rs::TS; diff --git a/magnetar_sdk/src/types/drive.rs b/magnetar_sdk/src/types/drive.rs index 49a8abd..691d3b6 100644 --- a/magnetar_sdk/src/types/drive.rs +++ b/magnetar_sdk/src/types/drive.rs @@ -53,7 +53,9 @@ pub struct DriveFileBase { pub mime_type: String, pub media_metadata: ImageMeta, pub url: Option, + pub source_url: String, pub thumbnail_url: Option, + pub blurhash: Option, pub sensitive: bool, pub comment: Option, pub folder_id: Option, diff --git a/magnetar_sdk/src/types/instance.rs b/magnetar_sdk/src/types/instance.rs new file mode 100644 index 0000000..1153e2c --- /dev/null +++ b/magnetar_sdk/src/types/instance.rs @@ -0,0 +1,13 @@ +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +#[derive(Clone, Debug, Deserialize, Serialize, TS)] +#[ts(export)] +pub struct InstanceTicker { + pub name: Option, + pub software_name: Option, + pub software_version: Option, + pub icon_url: Option, + pub favicon_url: Option, + pub theme_color: Option, +} diff --git a/magnetar_sdk/src/types/mod.rs b/magnetar_sdk/src/types/mod.rs index 215c045..126625a 100644 --- a/magnetar_sdk/src/types/mod.rs +++ b/magnetar_sdk/src/types/mod.rs @@ -1,5 +1,6 @@ pub mod drive; pub mod emoji; +pub mod instance; pub mod note; pub mod timeline; pub mod user; diff --git a/magnetar_sdk/src/types/note.rs b/magnetar_sdk/src/types/note.rs index 3c43b76..d8c89b7 100644 --- a/magnetar_sdk/src/types/note.rs +++ b/magnetar_sdk/src/types/note.rs @@ -51,6 +51,7 @@ pack!(PackPollBase, Required as id & Required as poll); #[ts(export)] pub struct NoteBase { pub created_at: DateTime, + pub updated_at: Option>, pub cw: Option, pub cw_mm: Option, pub uri: Option, @@ -64,6 +65,7 @@ pub struct NoteBase { pub reply_count: u64, pub renote_count: u64, pub mentions: Vec, + pub visible_user_ids: Option>, pub hashtags: Vec, pub reactions: Vec, pub local_only: bool, diff --git a/magnetar_sdk/src/types/user.rs b/magnetar_sdk/src/types/user.rs index d4ee9bd..b03657a 100644 --- a/magnetar_sdk/src/types/user.rs +++ b/magnetar_sdk/src/types/user.rs @@ -5,6 +5,7 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use ts_rs::TS; +use crate::types::instance::InstanceTicker; use crate::types::note::PackNoteMaybeFull; use magnetar_sdk_macros::pack; @@ -43,14 +44,14 @@ pub struct UserBase { pub host: Option, pub speech_transform: SpeechTransform, pub created_at: DateTime, - pub avatar_url: Option, + pub avatar_url: String, pub avatar_blurhash: Option, - pub avatar_color: Option, pub avatar_decoration: AvatarDecoration, pub is_admin: bool, pub is_moderator: bool, pub is_bot: bool, pub emojis: EmojiContext, + pub instance: Option, } pack!(PackUserBase, Required as id & Required as user); @@ -78,7 +79,6 @@ pub struct UserProfileExt { pub also_known_as: Option, pub banner_url: Option, - pub banner_color: Option, pub banner_blurhash: Option, pub has_public_reactions: bool, @@ -96,6 +96,8 @@ pub struct UserProfilePinsEx { pub struct UserRelationExt { pub follows_you: bool, pub you_follow: bool, + pub you_request_follow: bool, + pub they_request_follow: bool, pub blocks_you: bool, pub you_block: bool, pub mute: bool, diff --git a/src/model/data/drive.rs b/src/model/data/drive.rs index c994ae8..25f386c 100644 --- a/src/model/data/drive.rs +++ b/src/model/data/drive.rs @@ -1,11 +1,26 @@ use magnetar_calckey_model::ck; use magnetar_sdk::types::drive::{DriveFileBase, ImageMeta}; use serde::Deserialize; +use url::Url; use crate::model::{PackType, PackingContext}; -impl PackType<&ck::drive_file::Model> for DriveFileBase { - fn extract(_context: &PackingContext, file: &ck::drive_file::Model) -> Self { +#[derive(Debug)] +pub struct PackFileBaseInput<'a> { + pub file: &'a ck::drive_file::Model, + pub effective_url: Option<&'a Url>, + pub effective_thumbnail_url: Option<&'a Url>, +} + +impl PackType> for DriveFileBase { + fn extract( + _context: &PackingContext, + PackFileBaseInput { + file, + effective_url, + effective_thumbnail_url, + }: PackFileBaseInput<'_>, + ) -> Self { let media_metadata = ImageMeta::deserialize(file.properties.clone()).unwrap_or_default(); DriveFileBase { @@ -15,8 +30,10 @@ impl PackType<&ck::drive_file::Model> for DriveFileBase { hash: None, // TODO: blake3 mime_type: file.r#type.clone(), media_metadata, - url: Some(file.url.clone()), - thumbnail_url: file.thumbnail_url.clone(), + url: effective_url.map(Url::to_string), + source_url: file.url.clone(), + thumbnail_url: effective_thumbnail_url.map(Url::to_string), + blurhash: file.blurhash.clone(), sensitive: file.is_sensitive, comment: file.comment.clone(), folder_id: file.folder_id.clone(), diff --git a/src/model/data/instance.rs b/src/model/data/instance.rs new file mode 100644 index 0000000..d74a00f --- /dev/null +++ b/src/model/data/instance.rs @@ -0,0 +1,16 @@ +use crate::model::{PackType, PackingContext}; +use magnetar_calckey_model::ck; +use magnetar_sdk::types::instance::InstanceTicker; + +impl<'a> PackType<&'a ck::instance::Model> for InstanceTicker { + fn extract(_context: &PackingContext, data: &'a ck::instance::Model) -> Self { + InstanceTicker { + name: data.name.clone(), + software_name: data.software_name.clone(), + software_version: data.software_version.clone(), + icon_url: data.icon_url.clone(), + favicon_url: data.favicon_url.clone(), + theme_color: data.theme_color.clone(), + } + } +} diff --git a/src/model/data/mod.rs b/src/model/data/mod.rs index 0b1c42c..8dc31f4 100644 --- a/src/model/data/mod.rs +++ b/src/model/data/mod.rs @@ -1,6 +1,7 @@ pub mod drive; pub mod emoji; pub mod id; +pub mod instance; pub mod note; pub mod poll; pub mod user; diff --git a/src/model/data/note.rs b/src/model/data/note.rs index d4bd760..2a2e0f0 100644 --- a/src/model/data/note.rs +++ b/src/model/data/note.rs @@ -39,6 +39,7 @@ impl PackType> for NoteBase { use ck::sea_orm_active_enums::NoteVisibilityEnum as NVE; NoteBase { created_at: note.created_at.into(), + updated_at: note.updated_at.map(|d| d.into()), cw: note.cw.clone(), cw_mm: cw_mm.cloned(), uri: note.uri.clone(), @@ -62,6 +63,8 @@ impl PackType> for NoteBase { renote_count: note.renote_count as u64, mentions: note.mentions.clone(), hashtags: note.tags.clone(), + visible_user_ids: matches!(note.visibility, NVE::Specified) + .then(|| note.visible_user_ids.clone()), reactions: reactions.clone(), local_only: note.local_only, has_poll: note.has_poll, diff --git a/src/model/data/user.rs b/src/model/data/user.rs index a49ea80..373b39a 100644 --- a/src/model/data/user.rs +++ b/src/model/data/user.rs @@ -1,12 +1,15 @@ use magnetar_calckey_model::ck; use magnetar_calckey_model::ck::sea_orm_active_enums::UserProfileFfvisibilityEnum; +use magnetar_sdk::types::drive::PackDriveFileBase; use magnetar_sdk::types::emoji::{EmojiContext, PackEmojiBase}; +use magnetar_sdk::types::instance::InstanceTicker; use magnetar_sdk::types::note::PackNoteMaybeFull; use magnetar_sdk::types::user::{ AvatarDecoration, PackSecurityKeyBase, ProfileField, SecurityKeyBase, SpeechTransform, UserBase, UserDetailExt, UserProfileExt, UserProfilePinsEx, UserRelationExt, UserSecretsExt, }; use magnetar_sdk::types::MmXml; +use url::Url; use crate::model::{PackType, PackingContext}; @@ -19,8 +22,10 @@ impl PackType<&[PackEmojiBase]> for EmojiContext { pub struct UserBaseSource<'a> { pub user: &'a ck::user::Model, pub username_mm: Option<&'a MmXml>, - pub avatar: Option<&'a ck::drive_file::Model>, + pub avatar_url: &'a Url, + pub avatar: Option<&'a PackDriveFileBase>, pub emoji_context: &'a EmojiContext, + pub instance: Option<&'a InstanceTicker>, } impl PackType> for UserBase { @@ -29,8 +34,10 @@ impl PackType> for UserBase { UserBaseSource { user, username_mm, + avatar_url, avatar, emoji_context, + instance, }: UserBaseSource, ) -> Self { UserBase { @@ -49,9 +56,8 @@ impl PackType> for UserBase { SpeechTransform::None }, created_at: user.created_at.into(), - avatar_url: avatar.map(|v| v.url.clone()), - avatar_blurhash: avatar.and_then(|v| v.blurhash.clone()), - avatar_color: None, + avatar_url: avatar_url.to_string(), + avatar_blurhash: avatar.and_then(|v| v.file.0.blurhash.clone()), avatar_decoration: if user.is_cat { AvatarDecoration::CatEars } else { @@ -61,6 +67,7 @@ impl PackType> for UserBase { is_moderator: user.is_moderator, is_bot: user.is_bot, emojis: emoji_context.clone(), + instance: instance.map(|i| i.clone()), } } } @@ -69,6 +76,8 @@ pub struct UserProfileExtSource<'a> { pub user: &'a ck::user::Model, pub profile: &'a ck::user_profile::Model, pub profile_fields: &'a Vec, + pub banner_url: Option<&'a Url>, + pub banner: Option<&'a ck::drive_file::Model>, pub description_mm: Option<&'a MmXml>, pub relation: Option<&'a UserRelationExt>, } @@ -80,6 +89,8 @@ impl PackType> for UserProfileExt { user, profile, profile_fields, + banner_url, + banner, description_mm, relation, }: UserProfileExtSource, @@ -108,9 +119,8 @@ impl PackType> for UserProfileExt { url: profile.url.clone(), moved_to_uri: user.moved_to_uri.clone(), also_known_as: user.also_known_as.clone(), - banner_url: None, - banner_color: None, - banner_blurhash: None, + banner_url: banner_url.map(Url::to_string), + banner_blurhash: banner.and_then(|b| b.blurhash.clone()), has_public_reactions: profile.public_reactions, } } @@ -133,6 +143,8 @@ struct UserRelationExtSource<'a> { pub block_in: Option<&'a ck::blocking::Model>, pub mute: Option<&'a ck::muting::Model>, pub renote_mute: Option<&'a ck::renote_muting::Model>, + pub follow_request_out: Option<&'a ck::follow_request::Model>, + pub follow_request_in: Option<&'a ck::follow_request::Model>, } impl PackType> for UserRelationExt { @@ -145,6 +157,8 @@ impl PackType> for UserRelationExt { block_in, mute, renote_mute, + follow_request_in, + follow_request_out, }: UserRelationExtSource, ) -> Self { let self_user = context.self_user(); @@ -180,6 +194,18 @@ impl PackType> for UserRelationExt { self_user.id == renote_mute.muter_id && self_user.id != renote_mute.mutee_id }) }), + you_request_follow: self_user.is_some_and(|self_user| { + follow_request_in.is_some_and(|follow_req_in| { + self_user.id == follow_req_in.followee_id + && self_user.id != follow_req_in.follower_id + }) + }), + they_request_follow: self_user.is_some_and(|self_user| { + follow_request_out.is_some_and(|follow_req_out| { + self_user.id == follow_req_out.follower_id + && self_user.id != follow_req_out.followee_id + }) + }), } } } diff --git a/src/model/processing/drive.rs b/src/model/processing/drive.rs index 2e383d0..c400dd5 100644 --- a/src/model/processing/drive.rs +++ b/src/model/processing/drive.rs @@ -1,21 +1,144 @@ +use crate::model::data::drive::PackFileBaseInput; use crate::model::processing::PackResult; use crate::model::{PackType, PackingContext}; use magnetar_calckey_model::ck; use magnetar_sdk::types::drive::{DriveFileBase, PackDriveFileBase}; use magnetar_sdk::types::Id; use magnetar_sdk::{Packed, Required}; +use tracing::warn; +use url::Url; pub struct DriveModel; impl DriveModel { + pub fn media_proxy_url( + &self, + ctx: &PackingContext, + url: &str, + is_thumbnail: bool, + ) -> Option { + if let Some(proxy) = &ctx.service.config.networking.media_proxy { + let params = if is_thumbnail { + vec![("url", url), ("thumbnail", "1")] + } else { + vec![("url", url)] + }; + + let url = Url::parse_with_params(proxy, ¶ms); + + if let Err(e) = url { + warn!("Url parse error: {e}"); + } + + return url.ok(); + } + + None + } + + pub fn builtin_proxy_file( + &self, + ctx: &PackingContext, + file: &ck::drive_file::Model, + is_thumbnail: bool, + ) -> Option { + let key = if is_thumbnail { + file.thumbnail_access_key.as_deref() + } else { + file.webpublic_access_key.as_deref() + }; + + if let Some(k) = key { + if k != "/" { + let url_raw = format!( + "{}://{}/files/{}", + ctx.service.config.networking.protocol.as_ref(), + &ctx.service.config.networking.host, + k + ); + let url = Url::parse(&url_raw); + + if let Err(e) = url { + warn!("Url parse error: {e}"); + } + + return url.ok(); + } + } + + None + } + + pub fn get_public_url( + &self, + ctx: &PackingContext, + file: &ck::drive_file::Model, + is_thumbnail: bool, + ) -> Option { + if let Some(uri) = &file.uri { + if file.user_host.is_none() { + if let Some(media_proxy_url) = self.media_proxy_url(ctx, uri, is_thumbnail) { + return Some(media_proxy_url); + } + + if file.is_link && ctx.service.config.networking.proxy_remote_files { + if let Some(proxy_url) = self.builtin_proxy_file(ctx, file, is_thumbnail) { + return Some(proxy_url); + } + } + } + } + + let is_image = matches!( + file.r#type.as_str(), + "image/png" + | "image/apng" + | "image/gif" + | "image/jpeg" + | "image/webp" + | "image/svg+xml" + | "image/avif" + ); + + let url_raw = if is_thumbnail { + file.thumbnail_url + .as_deref() + .or(is_image.then_some(file.webpublic_url.as_deref().unwrap_or(file.url.as_str()))) + } else { + file.webpublic_url.as_deref().or(Some(file.url.as_str())) + }; + + if let Some(u) = url_raw { + let url = Url::parse(u); + + if let Err(e) = url { + warn!("Url parse error: {e}"); + } + + return url.ok(); + } + + None + } + pub fn pack_existing( &self, ctx: &PackingContext, file: &ck::drive_file::Model, ) -> PackDriveFileBase { + let url = self.get_public_url(ctx, file, false); + let thumbnail_url = self.get_public_url(ctx, file, false); + PackDriveFileBase::pack_from(( Required(Id::from(&file.id)), - Required(DriveFileBase::extract(ctx, &file)), + Required(DriveFileBase::extract( + ctx, + PackFileBaseInput { + file: &file, + effective_url: url.as_ref(), + effective_thumbnail_url: thumbnail_url.as_ref(), + }, + )), )) } diff --git a/src/model/processing/mod.rs b/src/model/processing/mod.rs index 33d2fc3..e678d80 100644 --- a/src/model/processing/mod.rs +++ b/src/model/processing/mod.rs @@ -1,5 +1,6 @@ use crate::service::emoji_cache::EmojiCacheError; use crate::service::generic_id_cache::GenericIdCacheError; +use crate::service::instance_cache::RemoteInstanceCacheError; use crate::service::instance_meta_cache::InstanceMetaCacheError; use magnetar_calckey_model::sea_orm::DbErr; use magnetar_calckey_model::CalckeyDbError; @@ -23,8 +24,12 @@ pub enum PackError { InstanceMetaCacheError(#[from] InstanceMetaCacheError), #[error("Generic cache error: {0}")] GenericCacheError(#[from] GenericIdCacheError), + #[error("Remote instance cache error: {0}")] + RemoteInstanceCacheError(#[from] RemoteInstanceCacheError), #[error("Deserializer error: {0}")] DeserializerError(#[from] serde_json::Error), + #[error("URL parse error: {0}")] + UrlParseError(#[from] url::ParseError), } pub type PackResult = Result; diff --git a/src/model/processing/user.rs b/src/model/processing/user.rs index 5243857..b244cae 100644 --- a/src/model/processing/user.rs +++ b/src/model/processing/user.rs @@ -1,13 +1,18 @@ use crate::model::data::user::UserBaseSource; +use crate::model::processing::drive::DriveModel; use crate::model::processing::emoji::EmojiModel; use crate::model::processing::{get_mm_token_emoji, PackResult}; use crate::model::{PackType, PackingContext}; use magnetar_calckey_model::ck; use magnetar_sdk::mmm::Token; +use magnetar_sdk::types::drive::PackDriveFileBase; use magnetar_sdk::types::emoji::EmojiContext; +use magnetar_sdk::types::instance::InstanceTicker; use magnetar_sdk::types::user::{PackUserBase, UserBase}; use magnetar_sdk::types::{Id, MmXml}; use magnetar_sdk::{mmm, Packed, Required}; +use tracing::warn; +use url::Url; pub struct UserModel; @@ -16,15 +21,48 @@ impl UserModel { mmm::Context::default().parse_ui(user.name.as_deref().unwrap_or(&user.username)) } + pub fn get_effective_avatar_url( + &self, + ctx: &PackingContext, + user: &ck::user::Model, + avatar: Option<&PackDriveFileBase>, + ) -> PackResult { + Ok(avatar + .and_then( + |PackDriveFileBase { + file: Required(base), + .. + }| base.thumbnail_url.as_deref(), + ) + .map(Url::parse) + .and_then(|r| { + if let Err(e) = r { + warn!("Failed to parse avatar URL: {e}"); + } + + r.ok().map(Ok) + }) + .unwrap_or_else(|| { + Url::parse(&format!( + "{}://{}/identicon/{}", + ctx.service.config.networking.protocol, + ctx.service.config.networking.host, + user.id + )) + })?) + } + pub async fn base_from_existing( &self, ctx: &PackingContext, user: &ck::user::Model, ) -> PackResult { + let drive_file_pack = DriveModel; let avatar = match &user.avatar_id { - Some(av_id) => ctx.service.drive_file_cache.get(av_id).await?, + Some(av_id) => drive_file_pack.get_cached_base(ctx, av_id).await?, None => None, }; + let avatar_url = &self.get_effective_avatar_url(ctx, user, avatar.as_ref())?; let username_mm = self.tokenize_username(&user); @@ -33,6 +71,16 @@ impl UserModel { let emojis = emoji_model .fetch_many_emojis(ctx, &shortcodes, user.host.as_deref()) .await?; + let instance = ctx + .service + .remote_instance_cache + .get( + user.host + .as_deref() + .unwrap_or(&ctx.service.config.networking.host), + ) + .await? + .map(|i| InstanceTicker::extract(ctx, i.as_ref())); let emoji_context = EmojiContext(emojis); let base = UserBase::extract( @@ -40,8 +88,10 @@ impl UserModel { UserBaseSource { user, username_mm: mmm::to_xml_string(&username_mm).map(MmXml).as_ref().ok(), - avatar: avatar.as_deref(), + avatar_url, + avatar: avatar.as_ref(), emoji_context: &emoji_context, + instance: instance.as_ref(), }, ); diff --git a/src/service/instance_cache.rs b/src/service/instance_cache.rs new file mode 100644 index 0000000..592ead3 --- /dev/null +++ b/src/service/instance_cache.rs @@ -0,0 +1,89 @@ +use crate::web::ApiError; +use lru::LruCache; +use magnetar_calckey_model::{ck, CalckeyDbError, CalckeyModel}; +use std::sync::Arc; +use std::time::{Duration, Instant}; +use strum::EnumVariantNames; +use thiserror::Error; +use tokio::sync::Mutex; + +#[derive(Debug, Error, EnumVariantNames)] +pub enum RemoteInstanceCacheError { + #[error("Database error: {0}")] + DbError(#[from] CalckeyDbError), +} + +impl From for ApiError { + fn from(err: RemoteInstanceCacheError) -> Self { + let mut api_error: ApiError = match err { + RemoteInstanceCacheError::DbError(err) => err.into(), + }; + + api_error.message = format!("Remote instance cache error: {}", api_error.message); + + api_error + } +} + +#[derive(Debug)] +struct CacheEntry { + created: Instant, + data: Arc, +} + +impl CacheEntry { + fn new(data: Arc) -> Self { + Self { + created: Instant::now(), + data, + } + } +} + +pub struct RemoteInstanceCacheService { + cache: Mutex>, + lifetime_max: Duration, + db: CalckeyModel, +} + +impl RemoteInstanceCacheService { + pub(super) fn new(db: CalckeyModel, cache_size: usize, entry_lifetime: Duration) -> Self { + const CACHE_SIZE: usize = 256; + + Self { + cache: Mutex::new(LruCache::new( + cache_size + .try_into() + .unwrap_or(CACHE_SIZE.try_into().unwrap()), + )), + lifetime_max: entry_lifetime, + db, + } + } + + pub async fn get( + &self, + host: &str, + ) -> Result>, RemoteInstanceCacheError> { + let mut read = self.cache.lock().await; + if let Some(item) = read.peek(host) { + if item.created + self.lifetime_max >= Instant::now() { + let data = item.data.clone(); + read.promote(host); + return Ok(Some(data)); + } + } + drop(read); + + let val = self.db.get_instance(host).await?; + + if val.is_none() { + return Ok(None); + } + + let mut write = self.cache.lock().await; + let data = Arc::new(val.unwrap()); + write.put(host.to_string(), CacheEntry::new(data.clone())); + Ok(Some(data)) + } +} diff --git a/src/service/mod.rs b/src/service/mod.rs index 74a091e..91c0cc3 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -6,15 +6,19 @@ use thiserror::Error; pub mod emoji_cache; pub mod generic_id_cache; +pub mod instance_cache; pub mod instance_meta_cache; pub mod local_user_cache; +#[non_exhaustive] + pub struct MagnetarService { pub db: CalckeyModel, pub cache: CalckeyCache, pub config: &'static MagnetarConfig, pub local_user_cache: local_user_cache::LocalUserCacheService, pub instance_meta_cache: instance_meta_cache::InstanceMetaCacheService, + pub remote_instance_cache: instance_cache::RemoteInstanceCacheService, pub emoji_cache: emoji_cache::EmojiCacheService, pub drive_file_cache: generic_id_cache::GenericIdCacheService, } @@ -45,6 +49,11 @@ impl MagnetarService { local_user_cache::LocalUserCacheService::new(config, db.clone(), cache.clone()).await?; let instance_meta_cache = instance_meta_cache::InstanceMetaCacheService::new(db.clone()); let emoji_cache = emoji_cache::EmojiCacheService::new(db.clone()); + let remote_instance_cache = instance_cache::RemoteInstanceCacheService::new( + db.clone(), + 256, + Duration::from_secs(100), + ); let drive_file_cache = generic_id_cache::GenericIdCacheService::new(db.clone(), 128, Duration::from_secs(10)); @@ -54,6 +63,7 @@ impl MagnetarService { config, local_user_cache, instance_meta_cache, + remote_instance_cache, emoji_cache, drive_file_cache, }) From 0ad015cd68a9c18a5519741242a7ad7658ecaeb5 Mon Sep 17 00:00:00 2001 From: Natty Date: Sun, 5 Nov 2023 15:28:55 +0100 Subject: [PATCH 6/7] Frontend: Initial BE API client integration --- fe_calckey/frontend/calckey-js/package.json | 2 +- .../frontend/calckey-js/src/entities.ts | 2 + fe_calckey/frontend/client/src/os.ts | 38 +- .../frontend/magnetar-common/package.json | 3 +- .../frontend/magnetar-common/src/be-api.ts | 9 +- .../frontend/magnetar-common/src/endpoints.ts | 5 + .../frontend/magnetar-common/src/index.ts | 28 + .../frontend/magnetar-common/src/packed.ts | 16 + .../frontend/magnetar-common/src/types.ts | 40 ++ .../src/types/DriveFileBase.ts | 2 +- .../src/types/InstanceTicker.ts | 3 + .../magnetar-common/src/types/NoteBase.ts | 2 +- .../magnetar-common/src/types/UserBase.ts | 3 +- .../src/types/UserProfileExt.ts | 2 +- .../src/types/UserRelationExt.ts | 2 +- .../src/types/endpoints/GetTimeline.ts | 5 +- .../frontend/magnetar-common/tsconfig.json | 2 +- fe_calckey/frontend/package.json | 1 - fe_calckey/frontend/pnpm-lock.yaml | 491 ++++++++++++------ 19 files changed, 491 insertions(+), 165 deletions(-) create mode 100644 fe_calckey/frontend/magnetar-common/src/endpoints.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/index.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/packed.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types.ts create mode 100644 fe_calckey/frontend/magnetar-common/src/types/InstanceTicker.ts diff --git a/fe_calckey/frontend/calckey-js/package.json b/fe_calckey/frontend/calckey-js/package.json index b4993d7..b78963c 100644 --- a/fe_calckey/frontend/calckey-js/package.json +++ b/fe_calckey/frontend/calckey-js/package.json @@ -15,7 +15,7 @@ "devDependencies": { "@swc/cli": "^0.1.62", "@swc/core": "^1.3.62", - "@types/node": "20.3.1", + "@types/node": "20.8.10", "ts-node": "10.4.0", "tsd": "^0.28.1", "typescript": "5.1.3" diff --git a/fe_calckey/frontend/calckey-js/src/entities.ts b/fe_calckey/frontend/calckey-js/src/entities.ts index 19e9fa3..cc157fb 100644 --- a/fe_calckey/frontend/calckey-js/src/entities.ts +++ b/fe_calckey/frontend/calckey-js/src/entities.ts @@ -15,6 +15,8 @@ export type UserLite = { avatarUrl: string; avatarBlurhash: string; alsoKnownAs: string[]; + isCat?: boolean; + isBot?: boolean; movedToUri: any; emojis: { name: string; diff --git a/fe_calckey/frontend/client/src/os.ts b/fe_calckey/frontend/client/src/os.ts index 58145e5..85004c1 100644 --- a/fe_calckey/frontend/client/src/os.ts +++ b/fe_calckey/frontend/client/src/os.ts @@ -13,9 +13,12 @@ import { MenuItem } from "@/types/menu"; import { $i } from "@/account"; import { i18n } from "./i18n"; import { + BackendApiEndpoint, FrontendApiEndpoint, FrontendApiEndpoints, -} from "magnetar-common/built/fe-api"; + MagApiClient, + Method, +} from "magnetar-common"; export const pendingApiRequestsCount = ref(0); @@ -23,6 +26,39 @@ const apiClient = new Misskey.api.APIClient({ origin: url, }); +const magnetarApiClient = new MagApiClient(url); + +export async function magApi< + T extends BackendApiEndpoint< + T["method"] & Method, + T["pathParams"] & string[], + T["request"], + T["response"] + > +>( + endpoint: T, + data: T["request"], + pathParams: { + [K in keyof T["pathParams"] as T["pathParams"][K] & string]: + | string + | number; + }, + token?: string | null | undefined +): Promise { + pendingApiRequestsCount.value++; + + try { + return await magnetarApiClient.call( + endpoint, + data, + pathParams, + token || $i?.token + ); + } finally { + pendingApiRequestsCount.value--; + } +} + export async function feApi( endpointDef: FrontendApiEndpoint< FrontendApiEndpoints[T]["method"], diff --git a/fe_calckey/frontend/magnetar-common/package.json b/fe_calckey/frontend/magnetar-common/package.json index 9546eca..32dfc4c 100644 --- a/fe_calckey/frontend/magnetar-common/package.json +++ b/fe_calckey/frontend/magnetar-common/package.json @@ -1,7 +1,8 @@ { "name": "magnetar-common", "version": "0.0.1", - "main": "index.js", + "main": "./built/index.js", + "types": "./built/index.d.ts", "scripts": { "build": "tsc" }, diff --git a/fe_calckey/frontend/magnetar-common/src/be-api.ts b/fe_calckey/frontend/magnetar-common/src/be-api.ts index 620c062..4ff41cf 100644 --- a/fe_calckey/frontend/magnetar-common/src/be-api.ts +++ b/fe_calckey/frontend/magnetar-common/src/be-api.ts @@ -1,6 +1,4 @@ -import { GetNoteById } from "./types/endpoints/GetNoteById"; - -type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; +export type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; export interface BackendApiEndpoint< M extends Method, @@ -46,7 +44,7 @@ function nestedUrlSearchParams(data: any, topLevel: boolean = true): string { } } -type MagApiErrorCode = "Client:GenericApiError" | string; +export type MagApiErrorCode = "Client:GenericApiError" | string; export interface MagApiError { status: number; @@ -125,6 +123,3 @@ export class MagApiClient { }); } } - -const a = new MagApiClient("https://aaa"); -const result = await a.call(GetNoteById, { attachments: true }, { id: "aaaa" }); diff --git a/fe_calckey/frontend/magnetar-common/src/endpoints.ts b/fe_calckey/frontend/magnetar-common/src/endpoints.ts new file mode 100644 index 0000000..6528afd --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/endpoints.ts @@ -0,0 +1,5 @@ +export { GetNoteById } from "./types/endpoints/GetNoteById"; +export { GetTimeline } from "./types/endpoints/GetTimeline"; +export { GetUserById } from "./types/endpoints/GetUserById"; +export { GetUserByAcct } from "./types/endpoints/GetUserByAcct"; +export { GetUserSelf } from "./types/endpoints/GetUserSelf"; diff --git a/fe_calckey/frontend/magnetar-common/src/index.ts b/fe_calckey/frontend/magnetar-common/src/index.ts new file mode 100644 index 0000000..163b955 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/index.ts @@ -0,0 +1,28 @@ +import { + BackendApiEndpoint, + MagApiClient, + MagApiError, + MagApiErrorCode, + Method, +} from "./be-api"; + +import { + feEndpoints, + FrontendApiEndpoint, + FrontendApiEndpoints, +} from "./fe-api"; + +export * as types from "./types"; +export * as packed from "./packed"; +export * as endpoints from "./endpoints"; + +export { + Method, + BackendApiEndpoint, + MagApiError, + MagApiClient, + MagApiErrorCode, + feEndpoints, + FrontendApiEndpoint, + FrontendApiEndpoints, +}; diff --git a/fe_calckey/frontend/magnetar-common/src/packed.ts b/fe_calckey/frontend/magnetar-common/src/packed.ts new file mode 100644 index 0000000..f8e2b94 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/packed.ts @@ -0,0 +1,16 @@ +export { PackDriveFileBase } from "./types/packed/PackDriveFileBase"; +export { PackDriveFileFull } from "./types/packed/PackDriveFileFull"; +export { PackDriveFileWithFolder } from "./types/packed/PackDriveFileWithFolder"; +export { PackDriveFileWithUser } from "./types/packed/PackDriveFileWithUser"; +export { PackDriveFolderBase } from "./types/packed/PackDriveFolderBase"; +export { PackEmojiBase } from "./types/packed/PackEmojiBase"; +export { PackDriveFolderWithParent } from "./types/packed/PackDriveFolderWithParent"; +export { PackNoteBase } from "./types/packed/PackNoteBase"; +export { PackNoteMaybeFull } from "./types/packed/PackNoteMaybeFull"; +export { PackPollBase } from "./types/packed/PackPollBase"; +export { PackNoteMaybeAttachments } from "./types/packed/PackNoteMaybeAttachments"; +export { PackSecurityKeyBase } from "./types/packed/PackSecurityKeyBase"; +export { PackUserBase } from "./types/packed/PackUserBase"; +export { PackUserMaybeAll } from "./types/packed/PackUserMaybeAll"; +export { PackUserSelf } from "./types/packed/PackUserSelf"; +export { PackUserSelfMaybeAll } from "./types/packed/PackUserSelfMaybeAll"; diff --git a/fe_calckey/frontend/magnetar-common/src/types.ts b/fe_calckey/frontend/magnetar-common/src/types.ts new file mode 100644 index 0000000..462375d --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types.ts @@ -0,0 +1,40 @@ +export { EmojiContext } from "./types/EmojiContext"; +export { FollowVisibility } from "./types/FollowVisibility"; +export { Id } from "./types/Id"; +export { NotificationSettings } from "./types/NotificationSettings"; +export { EmojiBase } from "./types/EmojiBase"; +export { MmXml } from "./types/MmXml"; +export { NotificationType } from "./types/NotificationType"; +export { NoteBase } from "./types/NoteBase"; +export { NoteAttachmentExt } from "./types/NoteAttachmentExt"; +export { NoteDetailExt } from "./types/NoteDetailExt"; +export { NoteListFilter } from "./types/NoteListFilter"; +export { NoteSelfContextExt } from "./types/NoteSelfContextExt"; +export { NoteVisibility } from "./types/NoteVisibility"; +export { PollBase } from "./types/PollBase"; +export { PollChoice } from "./types/PollChoice"; +export { Reaction } from "./types/Reaction"; +export { ReactionPair } from "./types/ReactionPair"; +export { AvatarDecoration } from "./types/AvatarDecoration"; +export { ProfileField } from "./types/ProfileField"; +export { SecurityKeyBase } from "./types/SecurityKeyBase"; +export { SpeechTransform } from "./types/SpeechTransform"; +export { UserAuthOverviewExt } from "./types/UserAuthOverviewExt"; +export { UserBase } from "./types/UserBase"; +export { UserDetailExt } from "./types/UserDetailExt"; +export { UserProfileExt } from "./types/UserProfileExt"; +export { UserProfilePinsEx } from "./types/UserProfilePinsEx"; +export { UserSecretsExt } from "./types/UserSecretsExt"; +export { UserRelationExt } from "./types/UserRelationExt"; +export { UserSelfExt } from "./types/UserSelfExt"; +export { NoteByIdReq } from "./types/NoteByIdReq"; +export { GetTimelineReq } from "./types/GetTimelineReq"; +export { UserByIdReq } from "./types/UserByIdReq"; +export { UserSelfReq } from "./types/UserSelfReq"; +export { DriveFileBase } from "./types/DriveFileBase"; +export { DriveFileFolderExt } from "./types/DriveFileFolderExt"; +export { DriveFileUserExt } from "./types/DriveFileUserExt"; +export { DriveFolderBase } from "./types/DriveFolderBase"; +export { DriveFolderParentExt } from "./types/DriveFolderParentExt"; +export { ImageMeta } from "./types/ImageMeta"; +export { InstanceTicker } from "./types/InstanceTicker"; diff --git a/fe_calckey/frontend/magnetar-common/src/types/DriveFileBase.ts b/fe_calckey/frontend/magnetar-common/src/types/DriveFileBase.ts index 8662b0a..84538be 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/DriveFileBase.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/DriveFileBase.ts @@ -1,4 +1,4 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { ImageMeta } from "./ImageMeta"; -export interface DriveFileBase { name: string, created_at: string, size: bigint, hash: string | null, mime_type: string, media_metadata: ImageMeta, url: string | null, thumbnail_url: string | null, sensitive: boolean, comment: string | null, folder_id: string | null, user_id: string | null, } \ No newline at end of file +export interface DriveFileBase { name: string, created_at: string, size: bigint, hash: string | null, mime_type: string, media_metadata: ImageMeta, url: string | null, source_url: string, thumbnail_url: string | null, blurhash: string | null, sensitive: boolean, comment: string | null, folder_id: string | null, user_id: string | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/InstanceTicker.ts b/fe_calckey/frontend/magnetar-common/src/types/InstanceTicker.ts new file mode 100644 index 0000000..1da0912 --- /dev/null +++ b/fe_calckey/frontend/magnetar-common/src/types/InstanceTicker.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface InstanceTicker { name: string | null, software_name: string | null, software_version: string | null, icon_url: string | null, favicon_url: string | null, theme_color: string | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/NoteBase.ts b/fe_calckey/frontend/magnetar-common/src/types/NoteBase.ts index 99aca93..f860116 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/NoteBase.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/NoteBase.ts @@ -5,4 +5,4 @@ import type { NoteVisibility } from "./NoteVisibility"; import type { PackUserBase } from "./packed/PackUserBase"; import type { ReactionPair } from "./ReactionPair"; -export interface NoteBase { created_at: string, cw: string | null, cw_mm: MmXml | null, uri: string | null, url: string | null, text: string, text_mm: MmXml | null, visibility: NoteVisibility, user: PackUserBase, parent_note_id: string | null, renoted_note_id: string | null, reply_count: bigint, renote_count: bigint, mentions: Array, hashtags: Array, reactions: Array, local_only: boolean, has_poll: boolean, file_ids: Array, emojis: EmojiContext, } \ No newline at end of file +export interface NoteBase { created_at: string, updated_at: string | null, cw: string | null, cw_mm: MmXml | null, uri: string | null, url: string | null, text: string, text_mm: MmXml | null, visibility: NoteVisibility, user: PackUserBase, parent_note_id: string | null, renoted_note_id: string | null, reply_count: bigint, renote_count: bigint, mentions: Array, visible_user_ids: Array | null, hashtags: Array, reactions: Array, local_only: boolean, has_poll: boolean, file_ids: Array, emojis: EmojiContext, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserBase.ts b/fe_calckey/frontend/magnetar-common/src/types/UserBase.ts index ee510e6..c61ff8a 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/UserBase.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/UserBase.ts @@ -1,7 +1,8 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. import type { AvatarDecoration } from "./AvatarDecoration"; import type { EmojiContext } from "./EmojiContext"; +import type { InstanceTicker } from "./InstanceTicker"; import type { MmXml } from "./MmXml"; import type { SpeechTransform } from "./SpeechTransform"; -export interface UserBase { acct: string, username: string, display_name: string, display_name_mm: MmXml | null, host: string | null, speech_transform: SpeechTransform, created_at: string, avatar_url: string | null, avatar_blurhash: string | null, avatar_color: string | null, avatar_decoration: AvatarDecoration, is_admin: boolean, is_moderator: boolean, is_bot: boolean, emojis: EmojiContext, } \ No newline at end of file +export interface UserBase { acct: string, username: string, display_name: string, display_name_mm: MmXml | null, host: string | null, speech_transform: SpeechTransform, created_at: string, avatar_url: string, avatar_blurhash: string | null, avatar_decoration: AvatarDecoration, is_admin: boolean, is_moderator: boolean, is_bot: boolean, emojis: EmojiContext, instance: InstanceTicker | null, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserProfileExt.ts b/fe_calckey/frontend/magnetar-common/src/types/UserProfileExt.ts index 37976c0..2720442 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/UserProfileExt.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/UserProfileExt.ts @@ -2,4 +2,4 @@ import type { MmXml } from "./MmXml"; import type { ProfileField } from "./ProfileField"; -export interface UserProfileExt { is_locked: boolean, is_silenced: boolean, is_suspended: boolean, description: string | null, description_mm: MmXml | null, location: string | null, birthday: string | null, fields: Array, follower_count: bigint | null, following_count: bigint | null, note_count: bigint | null, url: string | null, moved_to_uri: string | null, also_known_as: string | null, banner_url: string | null, banner_color: string | null, banner_blurhash: string | null, has_public_reactions: boolean, } \ No newline at end of file +export interface UserProfileExt { is_locked: boolean, is_silenced: boolean, is_suspended: boolean, description: string | null, description_mm: MmXml | null, location: string | null, birthday: string | null, fields: Array, follower_count: bigint | null, following_count: bigint | null, note_count: bigint | null, url: string | null, moved_to_uri: string | null, also_known_as: string | null, banner_url: string | null, banner_blurhash: string | null, has_public_reactions: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/UserRelationExt.ts b/fe_calckey/frontend/magnetar-common/src/types/UserRelationExt.ts index 04b9e29..4aa3da8 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/UserRelationExt.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/UserRelationExt.ts @@ -1,3 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export interface UserRelationExt { follows_you: boolean, you_follow: boolean, blocks_you: boolean, you_block: boolean, mute: boolean, mute_renotes: boolean, } \ No newline at end of file +export interface UserRelationExt { follows_you: boolean, you_follow: boolean, you_request_follow: boolean, they_request_follow: boolean, blocks_you: boolean, you_block: boolean, mute: boolean, mute_renotes: boolean, } \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts index 148c7a3..d2b6375 100644 --- a/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts +++ b/fe_calckey/frontend/magnetar-common/src/types/endpoints/GetTimeline.ts @@ -7,5 +7,6 @@ export const GetTimeline = { pathParams: [] as [], method: "GET" as "GET" | "POST" | "PUT" | "DELETE" | "PATCH", request: undefined as unknown as GetTimelineReq, - response: undefined as unknown as Array, -}; + response: undefined as unknown as Array +} + \ No newline at end of file diff --git a/fe_calckey/frontend/magnetar-common/tsconfig.json b/fe_calckey/frontend/magnetar-common/tsconfig.json index 47f57ab..c6908e1 100644 --- a/fe_calckey/frontend/magnetar-common/tsconfig.json +++ b/fe_calckey/frontend/magnetar-common/tsconfig.json @@ -19,4 +19,4 @@ "node_modules", "built", ] -} \ No newline at end of file +} diff --git a/fe_calckey/frontend/package.json b/fe_calckey/frontend/package.json index 0e18aa3..6940923 100644 --- a/fe_calckey/frontend/package.json +++ b/fe_calckey/frontend/package.json @@ -26,7 +26,6 @@ "dependencies": { "@bull-board/api": "5.2.0", "@bull-board/ui": "5.2.0", - "@napi-rs/cli": "^2.16.1", "js-yaml": "4.1.0", "seedrandom": "^3.0.5" }, diff --git a/fe_calckey/frontend/pnpm-lock.yaml b/fe_calckey/frontend/pnpm-lock.yaml index a8852f4..fa035de 100644 --- a/fe_calckey/frontend/pnpm-lock.yaml +++ b/fe_calckey/frontend/pnpm-lock.yaml @@ -17,9 +17,6 @@ importers: '@bull-board/ui': specifier: 5.2.0 version: 5.2.0 - '@napi-rs/cli': - specifier: ^2.16.1 - version: 2.16.1 js-yaml: specifier: 4.1.0 version: 4.1.0 @@ -96,11 +93,11 @@ importers: specifier: ^1.3.62 version: 1.3.62 '@types/node': - specifier: 20.3.1 - version: 20.3.1 + specifier: 20.8.10 + version: 20.8.10 ts-node: specifier: 10.4.0 - version: 10.4.0(@swc/core@1.3.62)(@types/node@20.3.1)(typescript@5.1.3) + version: 10.4.0(@swc/core@1.3.62)(@types/node@20.8.10)(typescript@5.1.3) tsd: specifier: ^0.28.1 version: 0.28.1 @@ -181,7 +178,7 @@ importers: version: 4.19.1 browser-image-resizer: specifier: github:misskey-dev/browser-image-resizer - version: github.com/misskey-dev/browser-image-resizer/56f504427ad7f6500e141a6d9f3aee42023d7f3e + version: github.com/misskey-dev/browser-image-resizer/5a70660c2ac8aad3d436bfa67a5e7f7c8946cac4 calckey-js: specifier: workspace:* version: link:../calckey-js @@ -220,7 +217,7 @@ importers: version: 2.30.0 emojilib: specifier: github:thatonecalculator/emojilib - version: github.com/thatonecalculator/emojilib/d3c8c6a77d4362b3b3180099f1d2eac344ce245c + version: github.com/thatonecalculator/emojilib/b962bd997e8c600b0b020ff0dd78ae1000a1f0c8 escape-regexp: specifier: 0.0.1 version: 0.0.1 @@ -577,8 +574,8 @@ packages: '@cspotcode/source-map-consumer': 0.8.0 dev: true - /@cypress/request@2.88.11: - resolution: {integrity: sha512-M83/wfQ1EkspjkE2lNWNV5ui2Cv7UCv1swW1DqljahbzLVWltcsexQh8jYtuS/vzFXP+HySntGM83ZXA9fn17w==} + /@cypress/request@2.88.12: + resolution: {integrity: sha512-tOn+0mDZxASFM+cuAP9szGUGPI1HwWVSvdzm7V4cCsPdFTx6qMj29CwaQmRAMIEhORIUBFBsYROYJcveK4uOjA==} engines: {node: '>= 6'} dependencies: aws-sign2: 0.7.0 @@ -596,7 +593,7 @@ packages: performance-now: 2.1.0 qs: 6.10.4 safe-buffer: 5.2.1 - tough-cookie: 2.5.0 + tough-cookie: 4.1.3 tunnel-agent: 0.6.0 uuid: 8.3.2 dev: true @@ -853,6 +850,11 @@ packages: engines: {node: '>=6.0.0'} dev: true + /@jridgewell/resolve-uri@3.1.1: + resolution: {integrity: sha512-dSYZh7HhCDtCKm4QakX0xFpsRDqjjtZf/kjI/v3T3Nwt5r8/qz/M19F9ySyOqU94SXBmeG9ttTul+YnR4LOxFA==} + engines: {node: '>=6.0.0'} + dev: true + /@jridgewell/set-array@1.1.2: resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} engines: {node: '>=6.0.0'} @@ -865,6 +867,13 @@ packages: '@jridgewell/trace-mapping': 0.3.18 dev: true + /@jridgewell/source-map@0.3.5: + resolution: {integrity: sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==} + dependencies: + '@jridgewell/gen-mapping': 0.3.3 + '@jridgewell/trace-mapping': 0.3.20 + dev: true + /@jridgewell/sourcemap-codec@1.4.14: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} dev: true @@ -880,6 +889,13 @@ packages: '@jridgewell/sourcemap-codec': 1.4.14 dev: true + /@jridgewell/trace-mapping@0.3.20: + resolution: {integrity: sha512-R8LcPeWZol2zR8mmH3JeKQ6QRCFb7XgUhV9ZlGhHLGyg4wpPiPZNQOOWhFZhxKw8u//yTbNGI42Bx/3paXEQ+Q==} + dependencies: + '@jridgewell/resolve-uri': 3.1.1 + '@jridgewell/sourcemap-codec': 1.4.15 + dev: true + /@kurkle/color@0.3.2: resolution: {integrity: sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==} dev: true @@ -898,12 +914,6 @@ packages: os-filter-obj: 2.0.0 dev: true - /@napi-rs/cli@2.16.1: - resolution: {integrity: sha512-L0Gr5iEQIDEbvWdDr1HUaBOxBSHL1VZhWSk1oryawoT8qJIY+KGfLFelU+Qma64ivCPbxYpkfPoKYVG3rcoGIA==} - engines: {node: '>= 10'} - hasBin: true - dev: false - /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1180,7 +1190,7 @@ packages: dependencies: '@types/http-cache-semantics': 4.0.1 '@types/keyv': 3.1.4 - '@types/node': 20.3.1 + '@types/node': 20.8.10 '@types/responselike': 1.0.0 dev: true @@ -1224,38 +1234,46 @@ packages: /@types/glob-stream@8.0.0: resolution: {integrity: sha512-fxTWwdQmX9LWSHD7ZLlv3BHR992mKcVcDnT/2v+l/QZZo7TfDdyasqlSYVzOnMGWhRbrWeWkbj/mgezFjKynhw==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.8.10 '@types/picomatch': 2.3.0 '@types/streamx': 2.9.1 dev: true + /@types/glob-stream@8.0.1: + resolution: {integrity: sha512-sR8FnsG9sEkjKasMSYbRmzaSVYmY76ui0t+T+9BE2Wr/ansAKfNsu+xT0JvZL+7DDQDO/MPTg6g8hfNdhYWT2g==} + dependencies: + '@types/node': 20.8.10 + '@types/picomatch': 2.3.2 + '@types/streamx': 2.9.3 + dev: true + /@types/glob@8.1.0: resolution: {integrity: sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==} dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.3.1 + '@types/node': 20.8.10 dev: true /@types/gulp-rename@2.0.1: resolution: {integrity: sha512-9ZjeS2RHEnmBmTcyi2+oeye3BgCsWhvi4uv3qCnAg8i6plOuRdaeNxjOves0ELysEXYLBl7bCl5fbVs7AZtgTA==} dependencies: - '@types/node': 20.3.1 - '@types/vinyl': 2.0.7 + '@types/node': 20.8.10 + '@types/vinyl': 2.0.9 dev: true /@types/gulp-rename@2.0.2: resolution: {integrity: sha512-CQsXqTVtAXqrPd4IbrrlJEEzRkUR3RXsyZbrVoOVqjlchDDmnyRDatAUisjpQjjCg/wjJrSiNg8T1uAbJ/7Qqg==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.8.10 '@types/vinyl': 2.0.7 dev: true /@types/gulp@4.0.10: resolution: {integrity: sha512-spgZHJFqiEJGwqGlf7T/k4nkBpBcLgP7T0EfN6G2vvnhUfvd4uO1h8RwpXOE8x/54DVYUs1XCAtBHkX/R3axAQ==} dependencies: - '@types/undertaker': 1.2.8 - '@types/vinyl-fs': 3.0.2 - chokidar: 3.3.1 + '@types/undertaker': 1.2.10 + '@types/vinyl-fs': 3.0.4 + chokidar: 3.5.3 dev: true /@types/gulp@4.0.11: @@ -1281,7 +1299,7 @@ packages: /@types/keyv@3.1.4: resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.8.10 dev: true /@types/matter-js@0.18.2: @@ -1296,12 +1314,14 @@ packages: resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} dev: true - /@types/node@14.18.51: - resolution: {integrity: sha512-P9bsdGFPpVtofEKlhWMVS2qqx1A/rt9QBfihWlklfHHpUpjtYse5AzFz6j4DWrARLYh6gRnw9+5+DJcrq3KvBA==} + /@types/node@14.18.63: + resolution: {integrity: sha512-fAtCfv4jJg+ExtXhvCkCqUKZ+4ok/JQk01qDKhL5BDDoS3AxKXhV5/MAVUZyQnSEd2GT92fkgZl0pz0Q0AzcIQ==} dev: true - /@types/node@20.3.1: - resolution: {integrity: sha512-EhcH/wvidPy1WeML3TtYFGR83UzjxeWRen9V402T8aUGYsCHOmfoisV3ZSg03gAFIbLq8TnWOJ0f4cALtnSEUg==} + /@types/node@20.8.10: + resolution: {integrity: sha512-TlgT8JntpcbmKUFzjhsyhGfP2fsiz1Mv56im6enJ905xG1DAYesxJaeSbGqQmAw8OWPdhyJGhGSQGKRNJ45u9w==} + dependencies: + undici-types: 5.26.5 dev: true /@types/normalize-package-data@2.4.1: @@ -1312,6 +1332,10 @@ packages: resolution: {integrity: sha512-O397rnSS9iQI4OirieAtsDqvCj4+3eY1J+EPdNTKuHuRWIfUoGyzX294o8C4KJYaLqgSrd2o60c5EqCU8Zv02g==} dev: true + /@types/picomatch@2.3.2: + resolution: {integrity: sha512-I+BytjxOlNYA285zP/3dVCRcE+OAvgHQZQt26MP7T7JbZ9DM/3W2WfViU1XuLypCzAx8PTC+MlYO3WLqjTyZ3g==} + dev: true + /@types/punycode@2.1.0: resolution: {integrity: sha512-PG5aLpW6PJOeV2fHRslP4IOMWn+G+Uq8CfnyJ+PDS8ndCbU+soO+fB3NKCKo0p/Jh2Y4aPaiQZsrOXFdzpcA6g==} dev: true @@ -1319,7 +1343,7 @@ packages: /@types/responselike@1.0.0: resolution: {integrity: sha512-85Y2BjiufFzaMIlvJDvTTB8Fxl2xfLo4HgmHzVBz08w4wDePCTjYw66PdrolO0kzli3yam/YCgRufyo1DdQVTA==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.8.10 dev: true /@types/seedrandom@3.0.5: @@ -1330,14 +1354,20 @@ packages: resolution: {integrity: sha512-0kSuKjAS0TrGLJ0M/+8MaFkGsQhZpB6pxOmvS3K8FYI72K//YmdfoW9X2qPsAKh1mkwxGD5zib9s1FIFed6E8g==} dev: true - /@types/sizzle@2.3.3: - resolution: {integrity: sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==} + /@types/sizzle@2.3.5: + resolution: {integrity: sha512-tAe4Q+OLFOA/AMD+0lq8ovp8t3ysxAOeaScnfNdZpUxaGl51ZMDEITxkvFl1STudQ58mz6gzVGl9VhMKhwRnZQ==} dev: true /@types/streamx@2.9.1: resolution: {integrity: sha512-9bywzhouyedmci7WCIPFwJ8zASDnxt2gaVUy52X0p0Tt085IJSAEP0L6j4SSNeDMSLzpYu6cPz0GrJZ7kPJ6Bg==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.8.10 + dev: true + + /@types/streamx@2.9.3: + resolution: {integrity: sha512-D2eONMpz0JX15eA4pxylNVzq4kyqRRGqsMIxIjbfjDGaHMaoCvgFWn2+EkrL8/gODCvbNcPIVp7Eecr/+PX61g==} + dependencies: + '@types/node': 20.8.10 dev: true /@types/throttle-debounce@5.0.0: @@ -1352,10 +1382,22 @@ packages: resolution: {integrity: sha512-Z4TYuEKn9+RbNVk1Ll2SS4x1JeLHecolIbM/a8gveaHsW0Hr+RQMraZACwTO2VD7JvepgA6UO1A1VrbktQrIbQ==} dev: true + /@types/undertaker-registry@1.0.3: + resolution: {integrity: sha512-9wabQxkMB6Nb6FuPxvLQiMLBT2KkJXxgC9RoehnSSCvVzrag5GKxI5pekcgnMcZaGupuJOd0CLT+8ZwHHlG5vQ==} + dev: true + + /@types/undertaker@1.2.10: + resolution: {integrity: sha512-UzbgxdP5Zn0UlaLGF8CxXGpP7MCu/Y/b/24Kj3dK0J3+xOSmAGJw4JJKi21avFNuUviG59BMBUdrcL+KX+z7BA==} + dependencies: + '@types/node': 20.8.10 + '@types/undertaker-registry': 1.0.3 + async-done: 1.3.2 + dev: true + /@types/undertaker@1.2.8: resolution: {integrity: sha512-gW3PRqCHYpo45XFQHJBhch7L6hytPsIe0QeLujlnFsjHPnXLhJcPdN6a9368d7aIQgH2I/dUTPFBlGeSNA3qOg==} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.8.10 '@types/undertaker-registry': 1.0.1 async-done: 1.3.2 dev: true @@ -1368,22 +1410,37 @@ packages: resolution: {integrity: sha512-ctNcmmzbMIKooXjRkyyUCOu2Z4AyqibL+RhXoF3pb7K7j+ezItnakmpm31LymkYHSIM5ey0tjIFzTvFOTSBCGw==} dependencies: '@types/glob-stream': 8.0.0 - '@types/node': 20.3.1 + '@types/node': 20.8.10 '@types/vinyl': 2.0.7 dev: true + /@types/vinyl-fs@3.0.4: + resolution: {integrity: sha512-UIdM4bMUcWky41J0glmBx4WnCiF48J7Q2S0LJ8heFmZiB7vHeLOHoLx1ABxu4lY6eD2FswVp47cSIc1GFFJkbw==} + dependencies: + '@types/glob-stream': 8.0.1 + '@types/node': 20.8.10 + '@types/vinyl': 2.0.9 + dev: true + /@types/vinyl@2.0.7: resolution: {integrity: sha512-4UqPv+2567NhMQuMLdKAyK4yzrfCqwaTt6bLhHEs8PFcxbHILsrxaY63n4wgE/BRLDWDQeI+WcTmkXKExh9hQg==} dependencies: '@types/expect': 1.20.4 - '@types/node': 20.3.1 + '@types/node': 20.8.10 dev: true - /@types/yauzl@2.10.0: - resolution: {integrity: sha512-Cn6WYCm0tXv8p6k+A8PvbDG763EDpBoTzHdA+Q/MF6H3sapGjCm9NzoaJncJS9tUKSuCoDs9XHxYYsQDgxR6kw==} + /@types/vinyl@2.0.9: + resolution: {integrity: sha512-KCr4aTEUkzSF89qw09e2oxsC/RXXT3K5ZPv4gvj3XTiWVrxNoi7WrqNTahNE/Hul5C9z3B8w+yWNTQgua12oag==} + dependencies: + '@types/expect': 1.20.4 + '@types/node': 20.8.10 + dev: true + + /@types/yauzl@2.10.2: + resolution: {integrity: sha512-Km7XAtUIduROw7QPgvcft0lIupeG8a8rdKL8RiSyKvlE7dYY31fEn41HVuQsRFDuROA8tA4K2UVL+WdfFmErBA==} requiresBuild: true dependencies: - '@types/node': 20.3.1 + '@types/node': 20.8.10 dev: true optional: true @@ -1653,6 +1710,12 @@ packages: engines: {node: '>=0.4.0'} dev: true + /acorn@8.11.2: + resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==} + engines: {node: '>=0.4.0'} + hasBin: true + dev: true + /acorn@8.8.2: resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==} engines: {node: '>=0.4.0'} @@ -1947,7 +2010,7 @@ packages: resolution: {integrity: sha512-WKExI/eSGgGAkWAO+wMVdFObZV7hQen54UpD1kCCTN3tvlL3W1jL4+lPP/M7MwoP7Q4RHzKtO3JQ4HxYEcd+xQ==} dependencies: browserslist: 1.7.7 - caniuse-db: 1.0.30001502 + caniuse-db: 1.0.30001559 normalize-range: 0.1.2 num2fraction: 1.2.2 postcss: 5.2.18 @@ -2114,8 +2177,8 @@ packages: deprecated: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools. hasBin: true dependencies: - caniuse-db: 1.0.30001502 - electron-to-chromium: 1.4.430 + caniuse-db: 1.0.30001559 + electron-to-chromium: 1.4.576 dev: true /browserslist@4.21.9: @@ -2182,8 +2245,8 @@ packages: responselike: 2.0.1 dev: true - /cachedir@2.3.0: - resolution: {integrity: sha512-A+Fezp4zxnit6FanDmv9EqXNAi3vt9DWp51/71UEhXukb7QUuvtv9344h91dyAxuTLoSYJFU299qzR3tzwPAhw==} + /cachedir@2.4.0: + resolution: {integrity: sha512-9EtFOZR8g22CL7BWjJ9BUx1+A/djkofnyW3aOXZORNW2kxoUpx2h+uN2cOqwPmFhnpVmxg+KW2OjOSgChTEvsQ==} engines: {node: '>=6'} dev: true @@ -2194,6 +2257,14 @@ packages: get-intrinsic: 1.2.1 dev: true + /call-bind@1.0.5: + resolution: {integrity: sha512-C3nQxfFZxFRVoJoGKKI8y3MOEo129NQ+FgQ08iye+Mk4zNZZGdjfs06bVTr+DBSlA66Q2VEcMki/cUCP4SercQ==} + dependencies: + function-bind: 1.1.2 + get-intrinsic: 1.2.2 + set-function-length: 1.1.1 + dev: true + /camelcase-keys@6.2.2: resolution: {integrity: sha512-YrwaA0vEKazPBkn0ipTiMpSajYDSe+KjQfrjhcBMxJt/znbvlHd8Pw/Vamaz5EB4Wfhs3SUR3Z9mwRu/P3s3Yg==} engines: {node: '>=8'} @@ -2217,13 +2288,13 @@ packages: resolution: {integrity: sha512-SBTl70K0PkDUIebbkXrxWqZlHNs0wRgRD6QZ8guctShjbh63gEPfF+Wj0Yw+75f5Y8tSzqAI/NcisYv/cCah2Q==} dependencies: browserslist: 1.7.7 - caniuse-db: 1.0.30001502 + caniuse-db: 1.0.30001559 lodash.memoize: 4.1.2 lodash.uniq: 4.5.0 dev: true - /caniuse-db@1.0.30001502: - resolution: {integrity: sha512-nNj61ClInBeMsDqHo20wgMJ40Jhyg9l6W0Z9tipmsc99g43TGvlJky4LP3TlrXbLrVCzRWVS4Gox606M6Hw9Ow==} + /caniuse-db@1.0.30001559: + resolution: {integrity: sha512-v0gHDJ0eR+mhzYeQK9e488H2FPOYJvMo7uSDzZMj67wKGI9oGMu4ARAVtqqqYTHqvWUMa7NtJfzkiBD8tTs4Jg==} dev: true /caniuse-lite@1.0.30001513: @@ -2341,6 +2412,21 @@ packages: fsevents: 2.1.3 dev: true + /chokidar@3.5.3: + resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} + engines: {node: '>= 8.10.0'} + dependencies: + anymatch: 3.1.3 + braces: 3.0.2 + glob-parent: 5.1.2 + is-binary-path: 2.1.0 + is-glob: 4.0.3 + normalize-path: 3.0.0 + readdirp: 3.6.0 + optionalDependencies: + fsevents: 2.3.3 + dev: true + /chrome-trace-event@1.0.3: resolution: {integrity: sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==} engines: {node: '>=6.0'} @@ -2531,7 +2617,7 @@ packages: dependencies: color: 0.11.4 css-color-names: 0.0.4 - has: 1.0.3 + has: 1.0.4 dev: true /colors@1.1.2: @@ -2625,8 +2711,8 @@ packages: is-plain-object: 5.0.0 dev: true - /core-js@3.31.1: - resolution: {integrity: sha512-2sKLtfq1eFST7l7v62zaqXacPc7uG8ZAya8ogijLhTtaKNcpzpB4TMoTw2Si+8GYKRwFPMMtUT0263QFWFfqyQ==} + /core-js@3.33.2: + resolution: {integrity: sha512-XeBzWI6QL3nJQiHmdzbAOiMYqjrb7hwU7A39Qhvd/POSa/t9E1AeZyEZx3fNvp/vtM8zXwhoL0FsiS0hD0pruQ==} requiresBuild: true dev: true @@ -2688,7 +2774,7 @@ packages: autoprefixer: 6.7.7 decamelize: 1.2.0 defined: 1.0.1 - has: 1.0.3 + has: 1.0.4 object-assign: 4.1.1 postcss: 5.2.18 postcss-calc: 5.3.1 @@ -2742,25 +2828,25 @@ packages: hasBin: true requiresBuild: true dependencies: - '@cypress/request': 2.88.11 + '@cypress/request': 2.88.12 '@cypress/xvfb': 1.2.4(supports-color@8.1.1) - '@types/node': 14.18.51 + '@types/node': 14.18.63 '@types/sinonjs__fake-timers': 8.1.1 - '@types/sizzle': 2.3.3 + '@types/sizzle': 2.3.5 arch: 2.2.0 blob-util: 2.0.2 bluebird: 3.7.2 buffer: 5.7.1 - cachedir: 2.3.0 + cachedir: 2.4.0 chalk: 4.1.2 check-more-types: 2.24.0 cli-cursor: 3.1.0 cli-table3: 0.6.3 commander: 5.1.0 common-tags: 1.8.2 - dayjs: 1.11.8 + dayjs: 1.11.10 debug: 4.3.4(supports-color@8.1.1) - enquirer: 2.3.6 + enquirer: 2.4.1 eventemitter2: 6.4.7 execa: 4.1.0 executable: 4.1.1 @@ -2771,7 +2857,7 @@ packages: is-ci: 3.0.1 is-installed-globally: 0.4.0 lazy-ass: 1.6.0 - listr2: 3.14.0(enquirer@2.3.6) + listr2: 3.14.0(enquirer@2.4.1) lodash: 4.17.21 log-symbols: 4.1.0 minimist: 1.2.8 @@ -2779,7 +2865,7 @@ packages: pretty-bytes: 5.6.0 proxy-from-env: 1.0.0 request-progress: 3.0.0 - semver: 7.3.8 + semver: 7.5.4 supports-color: 8.1.1 tmp: 0.2.1 untildify: 4.0.0 @@ -2807,8 +2893,8 @@ packages: '@babel/runtime': 7.22.6 dev: true - /dayjs@1.11.8: - resolution: {integrity: sha512-LcgxzFoWMEPO7ggRv1Y2N31hUf2R0Vj7fuy/m+Bg1K8rr+KAs1AEy4y9jd5DXe8pbHgX+srkHNS7TH6Q6ZhYeQ==} + /dayjs@1.11.10: + resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==} dev: true /debug@2.6.9: @@ -2889,11 +2975,21 @@ packages: engines: {node: '>=10'} dev: true - /define-properties@1.2.0: - resolution: {integrity: sha512-xvqAVKGfT1+UAvPwKTVw/njhdQ8ZhXK4lI0bCIuCMrp2up9nPnaDftrLtmpTazqd1o+UY4zgzU+avtMbDP+ldA==} + /define-data-property@1.1.1: + resolution: {integrity: sha512-E7uGkTzkk1d0ByLeSc6ZsFS79Axg+m1P/VsgYsxHgiuc3tFSj+MjMIwe90FC4lOAZzNBdY7kkO2P2wKdsQ1vgQ==} engines: {node: '>= 0.4'} dependencies: - has-property-descriptors: 1.0.0 + get-intrinsic: 1.2.2 + gopd: 1.0.1 + has-property-descriptors: 1.0.1 + dev: true + + /define-properties@1.2.1: + resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.1 + has-property-descriptors: 1.0.1 object-keys: 1.1.1 dev: true @@ -2901,21 +2997,21 @@ packages: resolution: {integrity: sha512-Rr7ADjQZenceVOAKop6ALkkRAmH1A4Gx9hV/7ZujPUN2rkATqFO0JZLZInbAjpZYoJ1gUx8MRMQVkYemcbMSTA==} engines: {node: '>=0.10.0'} dependencies: - is-descriptor: 0.1.6 + is-descriptor: 0.1.7 dev: true /define-property@1.0.0: resolution: {integrity: sha512-cZTYKFWspt9jZsMscWo8sc/5lbPC9Q0N5nBLgb+Yd915iL3udB1uFgS3B8YCx66UVHq018DAVFoee7x+gxggeA==} engines: {node: '>=0.10.0'} dependencies: - is-descriptor: 1.0.2 + is-descriptor: 1.0.3 dev: true /define-property@2.0.2: resolution: {integrity: sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==} engines: {node: '>=0.10.0'} dependencies: - is-descriptor: 1.0.2 + is-descriptor: 1.0.3 isobject: 3.0.1 dev: true @@ -2977,14 +3073,14 @@ packages: safer-buffer: 2.1.2 dev: true - /electron-to-chromium@1.4.430: - resolution: {integrity: sha512-FytjTbGwz///F+ToZ5XSeXbbSaXalsVRXsz2mHityI5gfxft7ieW3HqFLkU5V1aIrY42aflICqbmFoDxW10etg==} - dev: true - /electron-to-chromium@1.4.453: resolution: {integrity: sha512-BU8UtQz6CB3T7RIGhId4BjmjJVXQDujb0+amGL8jpcluFJr6lwspBOvkUbnttfpZCm4zFMHmjrX1QrdPWBBMjQ==} dev: true + /electron-to-chromium@1.4.576: + resolution: {integrity: sha512-yXsZyXJfAqzWk1WKryr0Wl0MN2D47xodPvEEwlVePBnhU5E7raevLQR+E6b9JAD3GfL/7MbAL9ZtWQQPcLx7wA==} + dev: true + /emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true @@ -3003,11 +3099,12 @@ packages: tapable: 2.2.1 dev: true - /enquirer@2.3.6: - resolution: {integrity: sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==} + /enquirer@2.4.1: + resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} dependencies: ansi-colors: 4.1.3 + strip-ansi: 6.0.1 dev: true /envinfo@7.10.0: @@ -3333,7 +3430,7 @@ packages: get-stream: 5.2.0 yauzl: 2.10.0 optionalDependencies: - '@types/yauzl': 2.10.0 + '@types/yauzl': 2.10.2 transitivePeerDependencies: - supports-color dev: true @@ -3604,7 +3701,7 @@ packages: at-least-node: 1.0.0 graceful-fs: 4.2.11 jsonfile: 6.1.0 - universalify: 2.0.0 + universalify: 2.0.1 dev: true /fs-mkdirp-stream@1.0.0: @@ -3628,8 +3725,8 @@ packages: dev: true optional: true - /fsevents@2.3.2: - resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==} + /fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} os: [darwin] requiresBuild: true @@ -3645,6 +3742,10 @@ packages: resolution: {integrity: sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==} dev: true + /function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + dev: true + /get-caller-file@1.0.3: resolution: {integrity: sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==} dev: true @@ -3658,6 +3759,15 @@ packages: has-symbols: 1.0.3 dev: true + /get-intrinsic@1.2.2: + resolution: {integrity: sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==} + dependencies: + function-bind: 1.1.2 + has-proto: 1.0.1 + has-symbols: 1.0.3 + hasown: 2.0.0 + dev: true + /get-stream@3.0.0: resolution: {integrity: sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==} engines: {node: '>=4'} @@ -3732,7 +3842,7 @@ packages: dependencies: anymatch: 2.0.0 async-done: 1.3.2 - chokidar: 3.3.1 + chokidar: 3.5.3 is-negated-glob: 1.0.0 just-debounce: 1.1.0 normalize-path: 3.0.0 @@ -3798,6 +3908,12 @@ packages: sparkles: 1.0.1 dev: true + /gopd@1.0.1: + resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==} + dependencies: + get-intrinsic: 1.2.2 + dev: true + /got@11.8.6: resolution: {integrity: sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==} engines: {node: '>=10.19.0'} @@ -3869,8 +3985,8 @@ packages: resolution: {integrity: sha512-SVSF7ikuWKhpAW4l4wapAqPPSToJoiNKsbDoUnRrSgwZHH7lH8pbPeQj1aOVYQrbZKhfSVBxVW+Py7vtulRktw==} engines: {node: '>=10'} dependencies: - '@types/node': 20.3.1 - '@types/vinyl': 2.0.7 + '@types/node': 20.8.10 + '@types/vinyl': 2.0.9 istextorbinary: 3.3.0 replacestream: 4.0.3 yargs-parser: 21.1.1 @@ -3881,7 +3997,7 @@ packages: engines: {node: '>=10'} dependencies: plugin-error: 1.0.1 - terser: 5.18.0 + terser: 5.24.0 through2: 4.0.2 vinyl-sourcemaps-apply: 0.2.1 dev: true @@ -3938,10 +4054,10 @@ packages: engines: {node: '>=8'} dev: true - /has-property-descriptors@1.0.0: - resolution: {integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==} + /has-property-descriptors@1.0.1: + resolution: {integrity: sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==} dependencies: - get-intrinsic: 1.2.1 + get-intrinsic: 1.2.2 dev: true /has-proto@1.0.1: @@ -3992,6 +4108,18 @@ packages: function-bind: 1.1.1 dev: true + /has@1.0.4: + resolution: {integrity: sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==} + engines: {node: '>= 0.4.0'} + dev: true + + /hasown@2.0.0: + resolution: {integrity: sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==} + engines: {node: '>= 0.4'} + dependencies: + function-bind: 1.1.2 + dev: true + /homedir-polyfill@1.0.3: resolution: {integrity: sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==} engines: {node: '>=0.10.0'} @@ -4144,18 +4272,11 @@ packages: is-windows: 1.0.2 dev: true - /is-accessor-descriptor@0.1.6: - resolution: {integrity: sha512-e1BM1qnDbMRG3ll2U9dSK0UMHuWOs3pY3AtcFsmvwPtKL3MML/Q86i+GilLfvqEs4GW+ExB91tQ3Ig9noDIZ+A==} - engines: {node: '>=0.10.0'} + /is-accessor-descriptor@1.0.1: + resolution: {integrity: sha512-YBUanLI8Yoihw923YeFUS5fs0fF2f5TSFTNiYAAzhhDscDa3lEqYuz1pDOEP5KvX94I9ey3vsqjJcLVFVU+3QA==} + engines: {node: '>= 0.10'} dependencies: - kind-of: 3.2.2 - dev: true - - /is-accessor-descriptor@1.0.0: - resolution: {integrity: sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==} - engines: {node: '>=0.10.0'} - dependencies: - kind-of: 6.0.3 + hasown: 2.0.0 dev: true /is-arrayish@0.2.1: @@ -4186,36 +4307,33 @@ packages: has: 1.0.3 dev: true - /is-data-descriptor@0.1.4: - resolution: {integrity: sha512-+w9D5ulSoBNlmw9OHn3U2v51SyoCd0he+bB3xMl62oijhrspxowjU+AIcDY0N3iEJbUEkB15IlMASQsxYigvXg==} - engines: {node: '>=0.10.0'} + /is-core-module@2.13.1: + resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} dependencies: - kind-of: 3.2.2 + hasown: 2.0.0 dev: true - /is-data-descriptor@1.0.0: - resolution: {integrity: sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==} - engines: {node: '>=0.10.0'} + /is-data-descriptor@1.0.1: + resolution: {integrity: sha512-bc4NlCDiCr28U4aEsQ3Qs2491gVq4V8G7MQyws968ImqjKuYtTJXrl7Vq7jsN7Ly/C3xj5KWFrY7sHNeDkAzXw==} + engines: {node: '>= 0.4'} dependencies: - kind-of: 6.0.3 + hasown: 2.0.0 dev: true - /is-descriptor@0.1.6: - resolution: {integrity: sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==} - engines: {node: '>=0.10.0'} + /is-descriptor@0.1.7: + resolution: {integrity: sha512-C3grZTvObeN1xud4cRWl366OMXZTj0+HGyk4hvfpx4ZHt1Pb60ANSXqCK7pdOTeUQpRzECBSTphqvD7U+l22Eg==} + engines: {node: '>= 0.4'} dependencies: - is-accessor-descriptor: 0.1.6 - is-data-descriptor: 0.1.4 - kind-of: 5.1.0 + is-accessor-descriptor: 1.0.1 + is-data-descriptor: 1.0.1 dev: true - /is-descriptor@1.0.2: - resolution: {integrity: sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==} - engines: {node: '>=0.10.0'} + /is-descriptor@1.0.3: + resolution: {integrity: sha512-JCNNGbwWZEVaSPtS45mdtrneRWJFp07LLmykxeFV5F6oBvNF8vHSfJuJgoT472pSfk+Mf8VnlrspaFBHWM8JAw==} + engines: {node: '>= 0.4'} dependencies: - is-accessor-descriptor: 1.0.0 - is-data-descriptor: 1.0.0 - kind-of: 6.0.3 + is-accessor-descriptor: 1.0.1 + is-data-descriptor: 1.0.1 dev: true /is-extendable@0.1.1: @@ -4418,7 +4536,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 20.3.1 + '@types/node': 20.8.10 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -4507,7 +4625,7 @@ packages: /jsonfile@6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} dependencies: - universalify: 2.0.0 + universalify: 2.0.1 optionalDependencies: graceful-fs: 4.2.11 dev: true @@ -4608,7 +4726,7 @@ packages: is-plain-object: 2.0.4 object.map: 1.0.1 rechoir: 0.6.2 - resolve: 1.22.2 + resolve: 1.22.8 transitivePeerDependencies: - supports-color dev: true @@ -4617,7 +4735,7 @@ packages: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} dev: true - /listr2@3.14.0(enquirer@2.3.6): + /listr2@3.14.0(enquirer@2.4.1): resolution: {integrity: sha512-TyWI8G99GX9GjE54cJ+RrNMcIFBfwMPxc3XTFiAYGN4s10hWROGtOg7+O6u6LE3mNkyld7RSLE6nrKBvTfcs3g==} engines: {node: '>=10.0.0'} peerDependencies: @@ -4628,7 +4746,7 @@ packages: dependencies: cli-truncate: 2.1.0 colorette: 2.0.20 - enquirer: 2.3.6 + enquirer: 2.4.1 log-update: 4.0.0 p-map: 4.0.0 rfdc: 1.3.0 @@ -4765,7 +4883,7 @@ packages: dependencies: findup-sync: 2.0.0 micromatch: 3.1.10 - resolve: 1.22.2 + resolve: 1.22.8 stack-trace: 0.0.10 transitivePeerDependencies: - supports-color @@ -5088,8 +5206,8 @@ packages: resolution: {integrity: sha512-1mxKf0e58bvyjSCtKYY4sRe9itRk3PJpquJOjeIkz885CczcI4IvJJDLPS72oowuSh+pBxUFROpX+TU++hxhZQ==} engines: {node: '>= 0.4'} dependencies: - call-bind: 1.0.2 - define-properties: 1.2.0 + call-bind: 1.0.5 + define-properties: 1.2.1 has-symbols: 1.0.3 object-keys: 1.1.1 dev: true @@ -5469,7 +5587,7 @@ packages: /postcss-merge-idents@2.1.7: resolution: {integrity: sha512-9DHmfCZ7/hNHhIKnNkz4CU0ejtGen5BbTRJc13Z2uHfCedeCUsK2WEQoAJRBL+phs68iWK6Qf8Jze71anuysWA==} dependencies: - has: 1.0.3 + has: 1.0.4 postcss: 5.2.18 postcss-value-parser: 3.3.1 dev: true @@ -5522,7 +5640,7 @@ packages: resolution: {integrity: sha512-e13vxPBSo3ZaPne43KVgM+UETkx3Bs4/Qvm6yXI9HQpQp4nyb7HZ0gKpkF+Wn2x+/dbQ+swNpCdZSbMOT7+TIA==} dependencies: alphanum-sort: 1.0.2 - has: 1.0.3 + has: 1.0.4 postcss: 5.2.18 postcss-selector-parser: 2.2.3 dev: true @@ -5565,7 +5683,7 @@ packages: /postcss-reduce-transforms@1.0.4: resolution: {integrity: sha512-lGgRqnSuAR5i5uUg1TA33r9UngfTadWxOyL2qx1KuPoCQzfmtaHjp9PuwX7yVyRxG3BWBzeFUaS5uV9eVgnEgQ==} dependencies: - has: 1.0.3 + has: 1.0.4 postcss: 5.2.18 postcss-value-parser: 3.3.1 dev: true @@ -5602,7 +5720,7 @@ packages: /postcss-zindex@2.2.0: resolution: {integrity: sha512-uhRZ2hRgj0lorxm9cr62B01YzpUe63h0RXMXQ4gWW3oa2rpJh+FJAiEAytaFCPU/VgaBS+uW2SJ1XKyDNz1h4w==} dependencies: - has: 1.0.3 + has: 1.0.4 postcss: 5.2.18 uniqs: 2.0.0 dev: true @@ -5718,6 +5836,11 @@ packages: engines: {node: '>=6'} dev: true + /punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + dev: true + /q@1.5.1: resolution: {integrity: sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==} engines: {node: '>=0.6.0', teleport: '>=0.2.0'} @@ -5744,6 +5867,10 @@ packages: deprecated: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. dev: true + /querystringify@2.2.0: + resolution: {integrity: sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==} + dev: true + /queue-lit@1.5.0: resolution: {integrity: sha512-IslToJ4eiCEE9xwMzq3viOO5nH8sUWUCwoElrhNMozzr9IIt2qqvB4I+uHu/zJTQVqc9R5DFwok4ijNK1pU3fA==} dev: true @@ -5851,11 +5978,18 @@ packages: picomatch: 2.3.1 dev: true + /readdirp@3.6.0: + resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} + engines: {node: '>=8.10.0'} + dependencies: + picomatch: 2.3.1 + dev: true + /rechoir@0.6.2: resolution: {integrity: sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==} engines: {node: '>= 0.10'} dependencies: - resolve: 1.22.2 + resolve: 1.22.8 dev: true /rechoir@0.8.0: @@ -5977,6 +6111,10 @@ packages: resolution: {integrity: sha512-IqSUtOVP4ksd1C/ej5zeEh/BIP2ajqpn8c5x+q99gvcIG/Qf0cud5raVnE/Dwd0ua9TXYDoDc0RE5hBSdz22Ug==} dev: true + /requires-port@1.0.0: + resolution: {integrity: sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==} + dev: true + /resolve-alpn@1.2.1: resolution: {integrity: sha512-0a1F4l73/ZFZOakJnQ3FvkJ2+gSTQWz/r2KE5OdDY0TxPm5h4GkqkWWfM47T7HsbnOtcJVEF4epCVy6u7Q3K+g==} dev: true @@ -6022,6 +6160,15 @@ packages: supports-preserve-symlinks-flag: 1.0.0 dev: true + /resolve@1.22.8: + resolution: {integrity: sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==} + hasBin: true + dependencies: + is-core-module: 2.13.1 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + dev: true + /responselike@2.0.1: resolution: {integrity: sha512-4gl03wn3hj1HP3yzgdI7d3lCkF95F21Pz4BPGvKHinyQzALR5CapwC8yIi0Rh58DEMQ/SguC03wFj2k0M/mHhw==} dependencies: @@ -6069,7 +6216,7 @@ packages: engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: - fsevents: 2.3.2 + fsevents: 2.3.3 dev: true /run-parallel@1.2.0: @@ -6175,6 +6322,14 @@ packages: lru-cache: 6.0.0 dev: true + /semver@7.5.4: + resolution: {integrity: sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==} + engines: {node: '>=10'} + hasBin: true + dependencies: + lru-cache: 6.0.0 + dev: true + /serialize-javascript@6.0.1: resolution: {integrity: sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==} dependencies: @@ -6185,6 +6340,16 @@ packages: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} dev: true + /set-function-length@1.1.1: + resolution: {integrity: sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==} + engines: {node: '>= 0.4'} + dependencies: + define-data-property: 1.1.1 + get-intrinsic: 1.2.2 + gopd: 1.0.1 + has-property-descriptors: 1.0.1 + dev: true + /set-value@2.0.1: resolution: {integrity: sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==} engines: {node: '>=0.10.0'} @@ -6703,6 +6868,17 @@ packages: source-map-support: 0.5.21 dev: true + /terser@5.24.0: + resolution: {integrity: sha512-ZpGR4Hy3+wBEzVEnHvstMvqpD/nABNelQn/z2r0fjVWGQsN3bpOLzQlqDxmb4CDZnXq5lpjnQ+mHQLAOpfM5iw==} + engines: {node: '>=10'} + hasBin: true + dependencies: + '@jridgewell/source-map': 0.3.5 + acorn: 8.11.2 + commander: 2.20.3 + source-map-support: 0.5.21 + dev: true + /textarea-caret@3.1.0: resolution: {integrity: sha512-cXAvzO9pP5CGa6NKx0WYHl+8CHKZs8byMkt3PCJBCmq2a34YA9pO1NrQET5pzeqnBjBdToF5No4rrmkDUgQC2Q==} dev: true @@ -6825,12 +7001,14 @@ packages: ieee754: 1.2.1 dev: true - /tough-cookie@2.5.0: - resolution: {integrity: sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==} - engines: {node: '>=0.8'} + /tough-cookie@4.1.3: + resolution: {integrity: sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==} + engines: {node: '>=6'} dependencies: psl: 1.9.0 - punycode: 2.1.1 + punycode: 2.3.1 + universalify: 0.2.0 + url-parse: 1.5.10 dev: true /trim-newlines@3.0.1: @@ -6845,7 +7023,7 @@ packages: escape-string-regexp: 5.0.0 dev: true - /ts-node@10.4.0(@swc/core@1.3.62)(@types/node@20.3.1)(typescript@5.1.3): + /ts-node@10.4.0(@swc/core@1.3.62)(@types/node@20.8.10)(typescript@5.1.3): resolution: {integrity: sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==} hasBin: true peerDependencies: @@ -6865,7 +7043,7 @@ packages: '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.3.1 + '@types/node': 20.8.10 acorn: 8.8.2 acorn-walk: 8.2.0 arg: 4.1.3 @@ -7005,6 +7183,10 @@ packages: undertaker-registry: 1.0.1 dev: true + /undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + dev: true + /unicode-emoji-json@0.4.0: resolution: {integrity: sha512-lVNOwh2AnmbwqtSrEVjAWKQoVzWgyWmXVqPuPkPfKb0tnA0+uYN/4ILCTdy9IRj/+3drAVhmjwjNJQr2dhCwnA==} dev: true @@ -7039,11 +7221,21 @@ packages: engines: {node: '>= 4.0.0'} dev: true + /universalify@0.2.0: + resolution: {integrity: sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==} + engines: {node: '>= 4.0.0'} + dev: true + /universalify@2.0.0: resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==} engines: {node: '>= 10.0.0'} dev: true + /universalify@2.0.1: + resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} + engines: {node: '>= 10.0.0'} + dev: true + /unload@2.4.1: resolution: {integrity: sha512-IViSAm8Z3sRBYA+9wc0fLQmU9Nrxb16rcDmIiR6Y9LJSZzI7QY5QsDhqPpKOjAn0O9/kfK1TfNEMMAGPTIraPw==} dev: true @@ -7083,6 +7275,13 @@ packages: deprecated: Please see https://github.com/lydell/urix#deprecated dev: true + /url-parse@1.5.10: + resolution: {integrity: sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==} + dependencies: + querystringify: 2.2.0 + requires-port: 1.0.0 + dev: true + /url-polyfill@1.1.12: resolution: {integrity: sha512-mYFmBHCapZjtcNHW0MDq9967t+z4Dmg5CJ0KqysK3+ZbyoNOWQHksGCTWwDhxGXllkWlOc10Xfko6v4a3ucM6A==} dev: true @@ -7244,7 +7443,7 @@ packages: rollup: 3.23.1 sass: 1.62.1 optionalDependencies: - fsevents: 2.3.2 + fsevents: 2.3.3 dev: true /vue-isyourpasswordsafe@2.0.0: @@ -7534,10 +7733,10 @@ packages: engines: {node: '>=6'} dev: true - github.com/misskey-dev/browser-image-resizer/56f504427ad7f6500e141a6d9f3aee42023d7f3e: - resolution: {tarball: https://codeload.github.com/misskey-dev/browser-image-resizer/tar.gz/56f504427ad7f6500e141a6d9f3aee42023d7f3e} - name: browser-image-resizer - version: 2.2.1-misskey.4 + github.com/misskey-dev/browser-image-resizer/5a70660c2ac8aad3d436bfa67a5e7f7c8946cac4: + resolution: {tarball: https://codeload.github.com/misskey-dev/browser-image-resizer/tar.gz/5a70660c2ac8aad3d436bfa67a5e7f7c8946cac4} + name: '@misskey-dev/browser-image-resizer' + version: 2.2.1-misskey.10 dev: true github.com/sampotts/plyr/d434c9af16e641400aaee93188594208d88f2658: @@ -7545,15 +7744,15 @@ packages: name: plyr version: 3.7.0 dependencies: - core-js: 3.31.1 + core-js: 3.33.2 custom-event-polyfill: 1.0.7 loadjs: 4.2.0 rangetouch: 2.0.1 url-polyfill: 1.1.12 dev: true - github.com/thatonecalculator/emojilib/d3c8c6a77d4362b3b3180099f1d2eac344ce245c: - resolution: {tarball: https://codeload.github.com/thatonecalculator/emojilib/tar.gz/d3c8c6a77d4362b3b3180099f1d2eac344ce245c} + github.com/thatonecalculator/emojilib/b962bd997e8c600b0b020ff0dd78ae1000a1f0c8: + resolution: {tarball: https://codeload.github.com/thatonecalculator/emojilib/tar.gz/b962bd997e8c600b0b020ff0dd78ae1000a1f0c8} name: emojilib - version: 3.0.10 + version: 3.0.11 dev: true From e7812a816b67d8f69251987aef44781d852a7210 Mon Sep 17 00:00:00 2001 From: Natty Date: Sun, 5 Nov 2023 20:31:50 +0100 Subject: [PATCH 7/7] Note fetching from Magnetar! --- Cargo.lock | 24 +- Cargo.toml | 2 +- .../client/src/components/MagNote.vue | 937 ++++++++++++++++++ ...MkNoteDetailed.vue => MagNoteDetailed.vue} | 69 +- .../client/src/components/MkAvatars.vue | 2 +- .../client/src/components/MkCwButton.vue | 13 +- .../client/src/components/MkFollowButton.vue | 60 +- .../src/components/MkInstanceTicker.vue | 46 +- .../client/src/components/MkMediaBanner.vue | 10 +- .../client/src/components/MkMediaCaption.vue | 9 +- .../client/src/components/MkMediaImage.vue | 31 +- .../client/src/components/MkMediaList.vue | 74 +- .../client/src/components/MkMediaVideo.vue | 16 +- .../frontend/client/src/components/MkNote.vue | 16 +- .../client/src/components/MkNoteHeader.vue | 49 +- .../client/src/components/MkNoteSimple.vue | 4 +- .../client/src/components/MkNoteSub.vue | 95 +- .../frontend/client/src/components/MkPoll.vue | 75 +- .../client/src/components/MkPostForm.vue | 77 +- .../src/components/MkPostFormAttaches.vue | 22 +- .../src/components/MkPostFormDialog.vue | 8 +- .../components/MkReactionsViewer.reaction.vue | 8 +- .../src/components/MkReactionsViewer.vue | 18 +- .../client/src/components/MkRenoteButton.vue | 47 +- .../client/src/components/MkStarButton.vue | 3 +- .../src/components/MkStarButtonNoEmoji.vue | 4 +- .../src/components/MkSubNoteContent.vue | 89 +- .../src/components/MkUserOnlineIndicator.vue | 49 - .../client/src/components/global/MkAcct.vue | 3 +- .../client/src/components/global/MkAvatar.vue | 53 +- .../src/components/global/MkUserName.vue | 7 +- .../client/src/components/page/page.note.vue | 21 +- fe_calckey/frontend/client/src/config.ts | 2 +- .../frontend/client/src/filters/note.ts | 7 +- fe_calckey/frontend/client/src/init.ts | 29 +- fe_calckey/frontend/client/src/os.ts | 2 +- fe_calckey/frontend/client/src/pages/note.vue | 40 +- .../page-editor/els/page-editor.el.note.vue | 28 +- .../client/src/pages/settings/reaction.vue | 6 +- .../pages/settings/statusbar.statusbar.vue | 12 +- fe_calckey/frontend/client/src/plugin.ts | 10 +- .../client/src/scripts-mag/mag-util.ts | 240 +++++ .../client/src/scripts/check-word-mute.ts | 37 +- .../frontend/client/src/scripts/clone.ts | 24 - .../extract-avg-color-from-blurhash.ts | 4 +- .../client/src/scripts/get-note-menu.ts | 53 +- .../client/src/scripts/get-note-summary.ts | 12 +- .../client/src/scripts/page-metadata.ts | 3 +- .../frontend/client/src/scripts/theme.ts | 8 +- .../client/src/scripts/use-note-capture.ts | 238 +++-- fe_calckey/frontend/client/src/store.ts | 15 +- .../frontend/client/src/ui/deck/deck-store.ts | 41 +- .../frontend/client/src/widgets/job-queue.vue | 16 +- .../frontend/client/src/widgets/widget.ts | 7 +- fe_calckey/frontend/client/tsconfig.json | 3 +- .../frontend/magnetar-common/src/be-api.ts | 3 +- .../src/types/DriveFileBase.ts | 2 +- .../src/types/DriveFolderBase.ts | 2 +- .../magnetar-common/src/types/ImageMeta.ts | 2 +- .../magnetar-common/src/types/NoteBase.ts | 2 +- .../src/types/NoteSelfContextExt.ts | 2 +- .../magnetar-common/src/types/PollChoice.ts | 2 +- .../magnetar-common/src/types/ReactionPair.ts | 2 +- .../src/types/UserProfileExt.ts | 2 +- fe_calckey/frontend/package.json | 2 +- fe_calckey/frontend/pnpm-lock.yaml | 10 +- magnetar_sdk/src/types/drive.rs | 12 +- magnetar_sdk/src/types/note.rs | 12 +- magnetar_sdk/src/types/user.rs | 6 +- src/model/data/drive.rs | 2 +- src/model/data/note.rs | 6 +- src/model/data/poll.rs | 2 +- src/model/data/user.rs | 6 +- src/model/processing/note.rs | 2 +- 74 files changed, 2217 insertions(+), 640 deletions(-) create mode 100644 fe_calckey/frontend/client/src/components/MagNote.vue rename fe_calckey/frontend/client/src/components/{MkNoteDetailed.vue => MagNoteDetailed.vue} (91%) delete mode 100644 fe_calckey/frontend/client/src/components/MkUserOnlineIndicator.vue create mode 100644 fe_calckey/frontend/client/src/scripts-mag/mag-util.ts delete mode 100644 fe_calckey/frontend/client/src/scripts/clone.ts diff --git a/Cargo.lock b/Cargo.lock index 295c786..1ff71a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -535,7 +535,7 @@ dependencies = [ [[package]] name = "ck" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "sea-orm", "serde", @@ -835,7 +835,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "ext_calckey_model_migration" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "sea-orm-migration", "tokio", @@ -1446,7 +1446,7 @@ dependencies = [ [[package]] name = "magnetar" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "axum", "cached", @@ -1487,7 +1487,7 @@ dependencies = [ [[package]] name = "magnetar_calckey_fe" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "axum", "chrono", @@ -1511,7 +1511,7 @@ dependencies = [ [[package]] name = "magnetar_calckey_model" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "chrono", "ck", @@ -1536,7 +1536,7 @@ dependencies = [ [[package]] name = "magnetar_common" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "idna", "magnetar_core", @@ -1550,7 +1550,7 @@ dependencies = [ [[package]] name = "magnetar_core" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "serde", "serde_json", @@ -1558,7 +1558,7 @@ dependencies = [ [[package]] name = "magnetar_mmm_parser" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "compact_str", "either", @@ -1574,7 +1574,7 @@ dependencies = [ [[package]] name = "magnetar_nodeinfo" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "serde", "serde_json", @@ -1582,7 +1582,7 @@ dependencies = [ [[package]] name = "magnetar_sdk" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "chrono", "http", @@ -1596,7 +1596,7 @@ dependencies = [ [[package]] name = "magnetar_sdk_macros" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "quote", "syn 2.0.28", @@ -1604,7 +1604,7 @@ dependencies = [ [[package]] name = "magnetar_webfinger" -version = "0.2.1-alpha" +version = "0.3.0-alpha" dependencies = [ "magnetar_core", "serde", diff --git a/Cargo.toml b/Cargo.toml index 2af3aae..f13447f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ members = [ ] [workspace.package] -version = "0.2.1-alpha" +version = "0.3.0-alpha" edition = "2021" [workspace.dependencies] diff --git a/fe_calckey/frontend/client/src/components/MagNote.vue b/fe_calckey/frontend/client/src/components/MagNote.vue new file mode 100644 index 0000000..5c4791a --- /dev/null +++ b/fe_calckey/frontend/client/src/components/MagNote.vue @@ -0,0 +1,937 @@ + + + + + diff --git a/fe_calckey/frontend/client/src/components/MkNoteDetailed.vue b/fe_calckey/frontend/client/src/components/MagNoteDetailed.vue similarity index 91% rename from fe_calckey/frontend/client/src/components/MkNoteDetailed.vue rename to fe_calckey/frontend/client/src/components/MagNoteDetailed.vue index 443ac7b..d16f097 100644 --- a/fe_calckey/frontend/client/src/components/MkNoteDetailed.vue +++ b/fe_calckey/frontend/client/src/components/MagNoteDetailed.vue @@ -7,7 +7,7 @@ v-size="{ max: [500, 350, 300] }" class="lxwezrsl _block" :tabindex="!isDeleted ? '-1' : null" - :class="{ renote: isRenote }" + :class="{ renote: magIsRenote(note) }" > - + - + > - -