Adding rest of nested types.

This commit is contained in:
Dessalines 2022-06-14 13:00:50 -04:00
parent 91e8327b28
commit 12adf848cb
6 changed files with 142 additions and 3 deletions

View file

@ -1,5 +1,6 @@
import { Option, Some } from "@sniptt/monads"; import { Option, Some } from "@sniptt/monads";
import { Expose, Transform } from "class-transformer"; import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toUndefined } from "../../utils"; import { toUndefined } from "../../utils";
import { ListingType, SortType } from "../others"; import { ListingType, SortType } from "../others";
import { CommentReportView, CommentView } from "../views"; import { CommentReportView, CommentView } from "../views";
@ -96,6 +97,7 @@ export class SaveComment {
} }
export class CommentResponse { export class CommentResponse {
@Type(() => CommentView)
comment_view: CommentView; comment_view: CommentView;
recipient_ids: number[]; recipient_ids: number[];
/** /**
@ -163,6 +165,7 @@ export class GetComments {
} }
export class GetCommentsResponse { export class GetCommentsResponse {
@Type(() => CommentView)
comments: CommentView[]; comments: CommentView[];
} }
@ -177,6 +180,7 @@ export class CreateCommentReport {
} }
export class CommentReportResponse { export class CommentReportResponse {
@Type(() => CommentReportView)
comment_report_view: CommentReportView; comment_report_view: CommentReportView;
} }
@ -225,5 +229,6 @@ export class ListCommentReports {
} }
export class ListCommentReportsResponse { export class ListCommentReportsResponse {
@Type(() => CommentReportView)
comment_reports: CommentReportView[]; comment_reports: CommentReportView[];
} }

View file

@ -41,6 +41,7 @@ export class GetCommunityResponse {
@Expose() @Expose()
@Type(() => Site) @Type(() => Site)
site: Option<Site>; site: Option<Site>;
@Type(() => CommunityModeratorView)
moderators: CommunityModeratorView[]; moderators: CommunityModeratorView[];
online: number; online: number;
} }
@ -76,6 +77,7 @@ export class CreateCommunity {
} }
export class CommunityResponse { export class CommunityResponse {
@Type(() => CommunityView)
community_view: CommunityView; community_view: CommunityView;
} }
@ -107,6 +109,7 @@ export class ListCommunities {
} }
export class ListCommunitiesResponse { export class ListCommunitiesResponse {
@Type(() => CommunityView)
communities: CommunityView[]; communities: CommunityView[];
} }
@ -141,6 +144,7 @@ export class BanFromCommunity {
} }
export class BanFromCommunityResponse { export class BanFromCommunityResponse {
@Type(() => PersonViewSafe)
person_view: PersonViewSafe; person_view: PersonViewSafe;
banned: boolean; banned: boolean;
} }
@ -157,6 +161,7 @@ export class AddModToCommunity {
} }
export class AddModToCommunityResponse { export class AddModToCommunityResponse {
@Type(() => CommunityModeratorView)
moderators: CommunityModeratorView[]; moderators: CommunityModeratorView[];
} }
@ -261,6 +266,7 @@ export class BlockCommunity {
} }
export class BlockCommunityResponse { export class BlockCommunityResponse {
@Type(() => CommunityView)
community_view: CommunityView; community_view: CommunityView;
blocked: boolean; blocked: boolean;
} }

View file

@ -72,10 +72,10 @@ export class GetCaptchaResponse {
/** /**
* Will be undefined if captchas are disabled. * Will be undefined if captchas are disabled.
*/ */
@Type(() => CaptchaResponse)
@Transform(({ value }) => Some(value), { toClassOnly: true }) @Transform(({ value }) => Some(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose() @Expose()
@Type(() => CaptchaResponse)
ok: Option<CaptchaResponse>; ok: Option<CaptchaResponse>;
} }
@ -264,17 +264,23 @@ export class GetPersonDetails {
} }
export class GetPersonDetailsResponse { export class GetPersonDetailsResponse {
@Type(() => PersonViewSafe)
person_view: PersonViewSafe; person_view: PersonViewSafe;
@Type(() => CommentView)
comments: CommentView[]; comments: CommentView[];
@Type(() => PostView)
posts: PostView[]; posts: PostView[];
@Type(() => CommunityModeratorView)
moderates: CommunityModeratorView[]; moderates: CommunityModeratorView[];
} }
export class GetRepliesResponse { export class GetRepliesResponse {
@Type(() => CommentView)
replies: CommentView[]; replies: CommentView[];
} }
export class GetPersonMentionsResponse { export class GetPersonMentionsResponse {
@Type(() => PersonMentionView)
mentions: PersonMentionView[]; mentions: PersonMentionView[];
} }
@ -297,6 +303,7 @@ export class AddAdmin {
} }
export class AddAdminResponse { export class AddAdminResponse {
@Type(() => PersonViewSafe)
admins: PersonViewSafe[]; admins: PersonViewSafe[];
} }
@ -330,6 +337,7 @@ export class BanPerson {
} }
export class BanPersonResponse { export class BanPersonResponse {
@Type(() => PersonViewSafe)
person_view: PersonViewSafe; person_view: PersonViewSafe;
banned: boolean; banned: boolean;
} }
@ -393,6 +401,7 @@ export class MarkPersonMentionAsRead {
} }
export class PersonMentionResponse { export class PersonMentionResponse {
@Type(() => PersonMentionView)
person_mention_view: PersonMentionView; person_mention_view: PersonMentionView;
} }
@ -491,10 +500,12 @@ export class GetPrivateMessages {
} }
export class PrivateMessagesResponse { export class PrivateMessagesResponse {
@Type(() => PrivateMessageView)
private_messages: PrivateMessageView[]; private_messages: PrivateMessageView[];
} }
export class PrivateMessageResponse { export class PrivateMessageResponse {
@Type(() => PrivateMessageView)
private_message_view: PrivateMessageView; private_message_view: PrivateMessageView;
} }
@ -557,6 +568,7 @@ export class BlockPerson {
} }
export class BlockPersonResponse { export class BlockPersonResponse {
@Type(() => PersonViewSafe)
person_view: PersonViewSafe; person_view: PersonViewSafe;
blocked: boolean; blocked: boolean;
} }
@ -570,5 +582,6 @@ export class GetBannedPersons {
} }
export class BannedPersonsResponse { export class BannedPersonsResponse {
@Type(() => PersonViewSafe)
banned: PersonViewSafe[]; banned: PersonViewSafe[];
} }

View file

@ -1,5 +1,6 @@
import { Option, Some } from "@sniptt/monads"; import { Option, Some } from "@sniptt/monads";
import { Expose, Transform } from "class-transformer"; import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toUndefined } from "../../utils"; import { toUndefined } from "../../utils";
import { ListingType, SiteMetadata, SortType } from "../others"; import { ListingType, SiteMetadata, SortType } from "../others";
import { import {
@ -37,6 +38,7 @@ export class CreatePost {
} }
export class PostResponse { export class PostResponse {
@Type(() => PostView)
post_view: PostView; post_view: PostView;
} }
@ -53,9 +55,13 @@ export class GetPost {
} }
export class GetPostResponse { export class GetPostResponse {
@Type(() => PostView)
post_view: PostView; post_view: PostView;
@Type(() => CommunityView)
community_view: CommunityView; community_view: CommunityView;
@Type(() => CommentView)
comments: CommentView[]; comments: CommentView[];
@Type(() => CommunityModeratorView)
moderators: CommunityModeratorView[]; moderators: CommunityModeratorView[];
online: number; online: number;
} }
@ -103,6 +109,7 @@ export class GetPosts {
} }
export class GetPostsResponse { export class GetPostsResponse {
@Type(() => PostView)
posts: PostView[]; posts: PostView[];
} }
@ -232,6 +239,7 @@ export class CreatePostReport {
} }
export class PostReportResponse { export class PostReportResponse {
@Type(() => PostReportView)
post_report_view: PostReportView; post_report_view: PostReportView;
} }
@ -279,6 +287,7 @@ export class ListPostReports {
} }
export class ListPostReportsResponse { export class ListPostReportsResponse {
@Type(() => PostReportView)
post_reports: PostReportView[]; post_reports: PostReportView[];
} }
@ -291,5 +300,6 @@ export class GetSiteMetadata {
} }
export class GetSiteMetadataResponse { export class GetSiteMetadataResponse {
@Type(() => SiteMetadata)
metadata: SiteMetadata; metadata: SiteMetadata;
} }

View file

@ -82,9 +82,13 @@ export class SearchResponse {
* The [[SearchType]]. * The [[SearchType]].
*/ */
type_: string; type_: string;
@Type(() => CommentView)
comments: CommentView[]; comments: CommentView[];
@Type(() => PostView)
posts: PostView[]; posts: PostView[];
@Type(() => CommunityView)
communities: CommunityView[]; communities: CommunityView[];
@Type(() => PersonViewSafe)
users: PersonViewSafe[]; users: PersonViewSafe[];
} }
@ -116,15 +120,25 @@ export class GetModlog {
} }
export class GetModlogResponse { export class GetModlogResponse {
@Type(() => ModRemovePostView)
removed_posts: ModRemovePostView[]; removed_posts: ModRemovePostView[];
@Type(() => ModLockPostView)
locked_posts: ModLockPostView[]; locked_posts: ModLockPostView[];
@Type(() => ModStickyPostView)
stickied_posts: ModStickyPostView[]; stickied_posts: ModStickyPostView[];
@Type(() => ModRemoveCommentView)
removed_comments: ModRemoveCommentView[]; removed_comments: ModRemoveCommentView[];
@Type(() => ModRemoveCommunityView)
removed_communities: ModRemoveCommunityView[]; removed_communities: ModRemoveCommunityView[];
@Type(() => ModBanFromCommunityView)
banned_from_community: ModBanFromCommunityView[]; banned_from_community: ModBanFromCommunityView[];
@Type(() => ModBanView)
banned: ModBanView[]; banned: ModBanView[];
@Type(() => ModAddCommunityView)
added_to_community: ModAddCommunityView[]; added_to_community: ModAddCommunityView[];
@Type(() => ModTransferCommunityView)
transferred_to_community: ModTransferCommunityView[]; transferred_to_community: ModTransferCommunityView[];
@Type(() => ModAddView)
added: ModAddView[]; added: ModAddView[];
} }
@ -277,6 +291,7 @@ export class GetSite {
} }
export class SiteResponse { export class SiteResponse {
@Type(() => SiteView)
site_view: SiteView; site_view: SiteView;
} }
@ -289,6 +304,7 @@ export class GetSiteResponse {
@Expose() @Expose()
@Type(() => SiteView) @Type(() => SiteView)
site_view: Option<SiteView>; site_view: Option<SiteView>;
@Type(() => PersonViewSafe)
admins: PersonViewSafe[]; admins: PersonViewSafe[];
online: number; online: number;
version: string; version: string;
@ -311,10 +327,15 @@ export class GetSiteResponse {
* Your user info, such as blocks, follows, etc. * Your user info, such as blocks, follows, etc.
*/ */
export class MyUserInfo { export class MyUserInfo {
@Type(() => LocalUserSettingsView)
local_user_view: LocalUserSettingsView; local_user_view: LocalUserSettingsView;
@Type(() => CommunityFollowerView)
follows: CommunityFollowerView[]; follows: CommunityFollowerView[];
@Type(() => CommunityModeratorView)
moderates: CommunityModeratorView[]; moderates: CommunityModeratorView[];
@Type(() => CommunityBlockView)
community_blocks: CommunityBlockView[]; community_blocks: CommunityBlockView[];
@Type(() => PersonBlockView)
person_blocks: PersonBlockView[]; person_blocks: PersonBlockView[];
} }
@ -440,6 +461,7 @@ export class ApproveRegistrationApplication {
} }
export class RegistrationApplicationResponse { export class RegistrationApplicationResponse {
@Type(() => RegistrationApplicationView)
registration_application: RegistrationApplicationView; registration_application: RegistrationApplicationView;
} }

View file

@ -34,16 +34,23 @@ import {
} from "./source"; } from "./source";
export class PersonViewSafe { export class PersonViewSafe {
@Type(() => PersonSafe)
person: PersonSafe; person: PersonSafe;
counts: PersonAggregates; counts: PersonAggregates;
} }
export class PersonMentionView { export class PersonMentionView {
@Type(() => PersonMention)
person_mention: PersonMention; person_mention: PersonMention;
@Type(() => Comment)
comment: Comment; comment: Comment;
@Type(() => PersonSafe)
creator: PersonSafe; creator: PersonSafe;
@Type(() => Post)
post: Post; post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
recipient: PersonSafe; recipient: PersonSafe;
counts: CommentAggregates; counts: CommentAggregates;
creator_banned_from_community: boolean; creator_banned_from_community: boolean;
@ -57,7 +64,9 @@ export class PersonMentionView {
} }
export class LocalUserSettingsView { export class LocalUserSettingsView {
@Type(() => LocalUserSettings)
local_user: LocalUserSettings; local_user: LocalUserSettings;
@Type(() => PersonSafe)
person: PersonSafe; person: PersonSafe;
counts: PersonAggregates; counts: PersonAggregates;
} }
@ -69,14 +78,20 @@ export class SiteView {
} }
export class PrivateMessageView { export class PrivateMessageView {
@Type(() => PrivateMessage)
private_message: PrivateMessage; private_message: PrivateMessage;
@Type(() => PersonSafe)
creator: PersonSafe; creator: PersonSafe;
@Type(() => PersonSafe)
recipient: PersonSafe; recipient: PersonSafe;
} }
export class PostView { export class PostView {
@Type(() => Post)
post: Post; post: Post;
@Type(() => PersonSafe)
creator: PersonSafe; creator: PersonSafe;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
creator_banned_from_community: boolean; creator_banned_from_community: boolean;
counts: PostAggregates; counts: PostAggregates;
@ -91,10 +106,15 @@ export class PostView {
} }
export class PostReportView { export class PostReportView {
@Type(() => PostReport)
post_report: PostReport; post_report: PostReport;
@Type(() => Post)
post: Post; post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
creator: PersonSafe; creator: PersonSafe;
@Type(() => PersonSafe)
post_creator: PersonSafe; post_creator: PersonSafe;
creator_banned_from_community: boolean; creator_banned_from_community: boolean;
@Transform(({ value }) => Some(value), { toClassOnly: true }) @Transform(({ value }) => Some(value), { toClassOnly: true })
@ -110,14 +130,18 @@ export class PostReportView {
} }
export class CommentView { export class CommentView {
@Type(() => Comment)
comment: Comment; comment: Comment;
@Type(() => PersonSafe)
creator: PersonSafe; creator: PersonSafe;
@Transform(({ value }) => Some(value), { toClassOnly: true }) @Transform(({ value }) => Some(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose() @Expose()
@Type(() => PersonSafe) @Type(() => PersonSafe)
recipient: Option<PersonSafe>; recipient: Option<PersonSafe>;
@Type(() => Post)
post: Post; post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
counts: CommentAggregates; counts: CommentAggregates;
creator_banned_from_community: boolean; creator_banned_from_community: boolean;
@ -131,11 +155,17 @@ export class CommentView {
} }
export class CommentReportView { export class CommentReportView {
@Type(() => CommentReport)
comment_report: CommentReport; comment_report: CommentReport;
@Type(() => Comment)
comment: Comment; comment: Comment;
@Type(() => Post)
post: Post; post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
creator: PersonSafe; creator: PersonSafe;
@Type(() => PersonSafe)
comment_creator: PersonSafe; comment_creator: PersonSafe;
counts: CommentAggregates; counts: CommentAggregates;
creator_banned_from_community: boolean; creator_banned_from_community: boolean;
@ -151,100 +181,150 @@ export class CommentReportView {
} }
export class ModAddCommunityView { export class ModAddCommunityView {
@Type(() => ModAddCommunity)
mod_add_community: ModAddCommunity; mod_add_community: ModAddCommunity;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
modded_person: PersonSafe; modded_person: PersonSafe;
} }
export class ModTransferCommunityView { export class ModTransferCommunityView {
@Type(() => ModTransferCommunity)
mod_transfer_community: ModTransferCommunity; mod_transfer_community: ModTransferCommunity;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
modded_person: PersonSafe; modded_person: PersonSafe;
} }
export class ModAddView { export class ModAddView {
@Type(() => ModAdd)
mod_add: ModAdd; mod_add: ModAdd;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => PersonSafe)
modded_person: PersonSafe; modded_person: PersonSafe;
} }
export class ModBanFromCommunityView { export class ModBanFromCommunityView {
@Type(() => ModBanFromCommunity)
mod_ban_from_community: ModBanFromCommunity; mod_ban_from_community: ModBanFromCommunity;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
banned_person: PersonSafe; banned_person: PersonSafe;
} }
export class ModBanView { export class ModBanView {
@Type(() => ModBan)
mod_ban: ModBan; mod_ban: ModBan;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => PersonSafe)
banned_person: PersonSafe; banned_person: PersonSafe;
} }
export class ModLockPostView { export class ModLockPostView {
@Type(() => ModLockPost)
mod_lock_post: ModLockPost; mod_lock_post: ModLockPost;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => Post)
post: Post; post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
} }
export class ModRemoveCommentView { export class ModRemoveCommentView {
@Type(() => ModRemoveComment)
mod_remove_comment: ModRemoveComment; mod_remove_comment: ModRemoveComment;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => Comment)
comment: Comment; comment: Comment;
@Type(() => PersonSafe)
commenter: PersonSafe; commenter: PersonSafe;
@Type(() => Post)
post: Post; post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
} }
export class ModRemoveCommunityView { export class ModRemoveCommunityView {
@Type(() => ModRemoveCommunity)
mod_remove_community: ModRemoveCommunity; mod_remove_community: ModRemoveCommunity;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
} }
export class ModRemovePostView { export class ModRemovePostView {
@Type(() => ModRemovePost)
mod_remove_post: ModRemovePost; mod_remove_post: ModRemovePost;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => Post)
post: Post; post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
} }
export class ModStickyPostView { export class ModStickyPostView {
@Type(() => ModStickyPost)
mod_sticky_post: ModStickyPost; mod_sticky_post: ModStickyPost;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
@Type(() => Post)
post: Post; post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
} }
export class CommunityFollowerView { export class CommunityFollowerView {
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
follower: PersonSafe; follower: PersonSafe;
} }
export class CommunityBlockView { export class CommunityBlockView {
@Type(() => PersonSafe)
person: PersonSafe; person: PersonSafe;
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
} }
export class CommunityModeratorView { export class CommunityModeratorView {
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
moderator: PersonSafe; moderator: PersonSafe;
} }
export class CommunityPersonBanView { export class CommunityPersonBanView {
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
@Type(() => PersonSafe)
person: PersonSafe; person: PersonSafe;
} }
export class PersonBlockView { export class PersonBlockView {
@Type(() => PersonSafe)
person: PersonSafe; person: PersonSafe;
@Type(() => PersonSafe)
target: PersonSafe; target: PersonSafe;
} }
export class CommunityView { export class CommunityView {
@Type(() => CommunitySafe)
community: CommunitySafe; community: CommunitySafe;
subscribed: boolean; subscribed: boolean;
blocked: boolean; blocked: boolean;
@ -252,8 +332,11 @@ export class CommunityView {
} }
export class RegistrationApplicationView { export class RegistrationApplicationView {
@Type(() => RegistrationApplication)
registration_application: RegistrationApplication; registration_application: RegistrationApplication;
@Type(() => LocalUserSettings)
creator_local_user: LocalUserSettings; creator_local_user: LocalUserSettings;
@Type(() => PersonSafe)
creator: PersonSafe; creator: PersonSafe;
@Transform(({ value }) => Some(value), { toClassOnly: true }) @Transform(({ value }) => Some(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true }) @Transform(({ value }) => toUndefined(value), { toPlainOnly: true })