mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 20:31:12 +00:00
Adding rest of nested types.
This commit is contained in:
parent
91e8327b28
commit
12adf848cb
6 changed files with 142 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
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 { ListingType, SortType } from "../others";
|
||||
import { CommentReportView, CommentView } from "../views";
|
||||
|
@ -96,6 +97,7 @@ export class SaveComment {
|
|||
}
|
||||
|
||||
export class CommentResponse {
|
||||
@Type(() => CommentView)
|
||||
comment_view: CommentView;
|
||||
recipient_ids: number[];
|
||||
/**
|
||||
|
@ -163,6 +165,7 @@ export class GetComments {
|
|||
}
|
||||
|
||||
export class GetCommentsResponse {
|
||||
@Type(() => CommentView)
|
||||
comments: CommentView[];
|
||||
}
|
||||
|
||||
|
@ -177,6 +180,7 @@ export class CreateCommentReport {
|
|||
}
|
||||
|
||||
export class CommentReportResponse {
|
||||
@Type(() => CommentReportView)
|
||||
comment_report_view: CommentReportView;
|
||||
}
|
||||
|
||||
|
@ -225,5 +229,6 @@ export class ListCommentReports {
|
|||
}
|
||||
|
||||
export class ListCommentReportsResponse {
|
||||
@Type(() => CommentReportView)
|
||||
comment_reports: CommentReportView[];
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ export class GetCommunityResponse {
|
|||
@Expose()
|
||||
@Type(() => Site)
|
||||
site: Option<Site>;
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderators: CommunityModeratorView[];
|
||||
online: number;
|
||||
}
|
||||
|
@ -76,6 +77,7 @@ export class CreateCommunity {
|
|||
}
|
||||
|
||||
export class CommunityResponse {
|
||||
@Type(() => CommunityView)
|
||||
community_view: CommunityView;
|
||||
}
|
||||
|
||||
|
@ -107,6 +109,7 @@ export class ListCommunities {
|
|||
}
|
||||
|
||||
export class ListCommunitiesResponse {
|
||||
@Type(() => CommunityView)
|
||||
communities: CommunityView[];
|
||||
}
|
||||
|
||||
|
@ -141,6 +144,7 @@ export class BanFromCommunity {
|
|||
}
|
||||
|
||||
export class BanFromCommunityResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
person_view: PersonViewSafe;
|
||||
banned: boolean;
|
||||
}
|
||||
|
@ -157,6 +161,7 @@ export class AddModToCommunity {
|
|||
}
|
||||
|
||||
export class AddModToCommunityResponse {
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderators: CommunityModeratorView[];
|
||||
}
|
||||
|
||||
|
@ -261,6 +266,7 @@ export class BlockCommunity {
|
|||
}
|
||||
|
||||
export class BlockCommunityResponse {
|
||||
@Type(() => CommunityView)
|
||||
community_view: CommunityView;
|
||||
blocked: boolean;
|
||||
}
|
||||
|
|
|
@ -72,10 +72,10 @@ export class GetCaptchaResponse {
|
|||
/**
|
||||
* Will be undefined if captchas are disabled.
|
||||
*/
|
||||
@Type(() => CaptchaResponse)
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => CaptchaResponse)
|
||||
ok: Option<CaptchaResponse>;
|
||||
}
|
||||
|
||||
|
@ -264,17 +264,23 @@ export class GetPersonDetails {
|
|||
}
|
||||
|
||||
export class GetPersonDetailsResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
person_view: PersonViewSafe;
|
||||
@Type(() => CommentView)
|
||||
comments: CommentView[];
|
||||
@Type(() => PostView)
|
||||
posts: PostView[];
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderates: CommunityModeratorView[];
|
||||
}
|
||||
|
||||
export class GetRepliesResponse {
|
||||
@Type(() => CommentView)
|
||||
replies: CommentView[];
|
||||
}
|
||||
|
||||
export class GetPersonMentionsResponse {
|
||||
@Type(() => PersonMentionView)
|
||||
mentions: PersonMentionView[];
|
||||
}
|
||||
|
||||
|
@ -297,6 +303,7 @@ export class AddAdmin {
|
|||
}
|
||||
|
||||
export class AddAdminResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
admins: PersonViewSafe[];
|
||||
}
|
||||
|
||||
|
@ -330,6 +337,7 @@ export class BanPerson {
|
|||
}
|
||||
|
||||
export class BanPersonResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
person_view: PersonViewSafe;
|
||||
banned: boolean;
|
||||
}
|
||||
|
@ -393,6 +401,7 @@ export class MarkPersonMentionAsRead {
|
|||
}
|
||||
|
||||
export class PersonMentionResponse {
|
||||
@Type(() => PersonMentionView)
|
||||
person_mention_view: PersonMentionView;
|
||||
}
|
||||
|
||||
|
@ -491,10 +500,12 @@ export class GetPrivateMessages {
|
|||
}
|
||||
|
||||
export class PrivateMessagesResponse {
|
||||
@Type(() => PrivateMessageView)
|
||||
private_messages: PrivateMessageView[];
|
||||
}
|
||||
|
||||
export class PrivateMessageResponse {
|
||||
@Type(() => PrivateMessageView)
|
||||
private_message_view: PrivateMessageView;
|
||||
}
|
||||
|
||||
|
@ -557,6 +568,7 @@ export class BlockPerson {
|
|||
}
|
||||
|
||||
export class BlockPersonResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
person_view: PersonViewSafe;
|
||||
blocked: boolean;
|
||||
}
|
||||
|
@ -570,5 +582,6 @@ export class GetBannedPersons {
|
|||
}
|
||||
|
||||
export class BannedPersonsResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
banned: PersonViewSafe[];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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 { ListingType, SiteMetadata, SortType } from "../others";
|
||||
import {
|
||||
|
@ -37,6 +38,7 @@ export class CreatePost {
|
|||
}
|
||||
|
||||
export class PostResponse {
|
||||
@Type(() => PostView)
|
||||
post_view: PostView;
|
||||
}
|
||||
|
||||
|
@ -53,9 +55,13 @@ export class GetPost {
|
|||
}
|
||||
|
||||
export class GetPostResponse {
|
||||
@Type(() => PostView)
|
||||
post_view: PostView;
|
||||
@Type(() => CommunityView)
|
||||
community_view: CommunityView;
|
||||
@Type(() => CommentView)
|
||||
comments: CommentView[];
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderators: CommunityModeratorView[];
|
||||
online: number;
|
||||
}
|
||||
|
@ -103,6 +109,7 @@ export class GetPosts {
|
|||
}
|
||||
|
||||
export class GetPostsResponse {
|
||||
@Type(() => PostView)
|
||||
posts: PostView[];
|
||||
}
|
||||
|
||||
|
@ -232,6 +239,7 @@ export class CreatePostReport {
|
|||
}
|
||||
|
||||
export class PostReportResponse {
|
||||
@Type(() => PostReportView)
|
||||
post_report_view: PostReportView;
|
||||
}
|
||||
|
||||
|
@ -279,6 +287,7 @@ export class ListPostReports {
|
|||
}
|
||||
|
||||
export class ListPostReportsResponse {
|
||||
@Type(() => PostReportView)
|
||||
post_reports: PostReportView[];
|
||||
}
|
||||
|
||||
|
@ -291,5 +300,6 @@ export class GetSiteMetadata {
|
|||
}
|
||||
|
||||
export class GetSiteMetadataResponse {
|
||||
@Type(() => SiteMetadata)
|
||||
metadata: SiteMetadata;
|
||||
}
|
||||
|
|
|
@ -82,9 +82,13 @@ export class SearchResponse {
|
|||
* The [[SearchType]].
|
||||
*/
|
||||
type_: string;
|
||||
@Type(() => CommentView)
|
||||
comments: CommentView[];
|
||||
@Type(() => PostView)
|
||||
posts: PostView[];
|
||||
@Type(() => CommunityView)
|
||||
communities: CommunityView[];
|
||||
@Type(() => PersonViewSafe)
|
||||
users: PersonViewSafe[];
|
||||
}
|
||||
|
||||
|
@ -116,15 +120,25 @@ export class GetModlog {
|
|||
}
|
||||
|
||||
export class GetModlogResponse {
|
||||
@Type(() => ModRemovePostView)
|
||||
removed_posts: ModRemovePostView[];
|
||||
@Type(() => ModLockPostView)
|
||||
locked_posts: ModLockPostView[];
|
||||
@Type(() => ModStickyPostView)
|
||||
stickied_posts: ModStickyPostView[];
|
||||
@Type(() => ModRemoveCommentView)
|
||||
removed_comments: ModRemoveCommentView[];
|
||||
@Type(() => ModRemoveCommunityView)
|
||||
removed_communities: ModRemoveCommunityView[];
|
||||
@Type(() => ModBanFromCommunityView)
|
||||
banned_from_community: ModBanFromCommunityView[];
|
||||
@Type(() => ModBanView)
|
||||
banned: ModBanView[];
|
||||
@Type(() => ModAddCommunityView)
|
||||
added_to_community: ModAddCommunityView[];
|
||||
@Type(() => ModTransferCommunityView)
|
||||
transferred_to_community: ModTransferCommunityView[];
|
||||
@Type(() => ModAddView)
|
||||
added: ModAddView[];
|
||||
}
|
||||
|
||||
|
@ -277,6 +291,7 @@ export class GetSite {
|
|||
}
|
||||
|
||||
export class SiteResponse {
|
||||
@Type(() => SiteView)
|
||||
site_view: SiteView;
|
||||
}
|
||||
|
||||
|
@ -289,6 +304,7 @@ export class GetSiteResponse {
|
|||
@Expose()
|
||||
@Type(() => SiteView)
|
||||
site_view: Option<SiteView>;
|
||||
@Type(() => PersonViewSafe)
|
||||
admins: PersonViewSafe[];
|
||||
online: number;
|
||||
version: string;
|
||||
|
@ -311,10 +327,15 @@ export class GetSiteResponse {
|
|||
* Your user info, such as blocks, follows, etc.
|
||||
*/
|
||||
export class MyUserInfo {
|
||||
@Type(() => LocalUserSettingsView)
|
||||
local_user_view: LocalUserSettingsView;
|
||||
@Type(() => CommunityFollowerView)
|
||||
follows: CommunityFollowerView[];
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderates: CommunityModeratorView[];
|
||||
@Type(() => CommunityBlockView)
|
||||
community_blocks: CommunityBlockView[];
|
||||
@Type(() => PersonBlockView)
|
||||
person_blocks: PersonBlockView[];
|
||||
}
|
||||
|
||||
|
@ -440,6 +461,7 @@ export class ApproveRegistrationApplication {
|
|||
}
|
||||
|
||||
export class RegistrationApplicationResponse {
|
||||
@Type(() => RegistrationApplicationView)
|
||||
registration_application: RegistrationApplicationView;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,16 +34,23 @@ import {
|
|||
} from "./source";
|
||||
|
||||
export class PersonViewSafe {
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
counts: PersonAggregates;
|
||||
}
|
||||
|
||||
export class PersonMentionView {
|
||||
@Type(() => PersonMention)
|
||||
person_mention: PersonMention;
|
||||
@Type(() => Comment)
|
||||
comment: Comment;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
recipient: PersonSafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
|
@ -57,7 +64,9 @@ export class PersonMentionView {
|
|||
}
|
||||
|
||||
export class LocalUserSettingsView {
|
||||
@Type(() => LocalUserSettings)
|
||||
local_user: LocalUserSettings;
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
counts: PersonAggregates;
|
||||
}
|
||||
|
@ -69,14 +78,20 @@ export class SiteView {
|
|||
}
|
||||
|
||||
export class PrivateMessageView {
|
||||
@Type(() => PrivateMessage)
|
||||
private_message: PrivateMessage;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
recipient: PersonSafe;
|
||||
}
|
||||
|
||||
export class PostView {
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
creator_banned_from_community: boolean;
|
||||
counts: PostAggregates;
|
||||
|
@ -91,10 +106,15 @@ export class PostView {
|
|||
}
|
||||
|
||||
export class PostReportView {
|
||||
@Type(() => PostReport)
|
||||
post_report: PostReport;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
post_creator: PersonSafe;
|
||||
creator_banned_from_community: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
|
@ -110,14 +130,18 @@ export class PostReportView {
|
|||
}
|
||||
|
||||
export class CommentView {
|
||||
@Type(() => Comment)
|
||||
comment: Comment;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonSafe)
|
||||
recipient: Option<PersonSafe>;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
|
@ -131,11 +155,17 @@ export class CommentView {
|
|||
}
|
||||
|
||||
export class CommentReportView {
|
||||
@Type(() => CommentReport)
|
||||
comment_report: CommentReport;
|
||||
@Type(() => Comment)
|
||||
comment: Comment;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
comment_creator: PersonSafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
|
@ -151,100 +181,150 @@ export class CommentReportView {
|
|||
}
|
||||
|
||||
export class ModAddCommunityView {
|
||||
@Type(() => ModAddCommunity)
|
||||
mod_add_community: ModAddCommunity;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
modded_person: PersonSafe;
|
||||
}
|
||||
|
||||
export class ModTransferCommunityView {
|
||||
@Type(() => ModTransferCommunity)
|
||||
mod_transfer_community: ModTransferCommunity;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
modded_person: PersonSafe;
|
||||
}
|
||||
|
||||
export class ModAddView {
|
||||
@Type(() => ModAdd)
|
||||
mod_add: ModAdd;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
modded_person: PersonSafe;
|
||||
}
|
||||
|
||||
export class ModBanFromCommunityView {
|
||||
@Type(() => ModBanFromCommunity)
|
||||
mod_ban_from_community: ModBanFromCommunity;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
banned_person: PersonSafe;
|
||||
}
|
||||
|
||||
export class ModBanView {
|
||||
@Type(() => ModBan)
|
||||
mod_ban: ModBan;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
banned_person: PersonSafe;
|
||||
}
|
||||
|
||||
export class ModLockPostView {
|
||||
@Type(() => ModLockPost)
|
||||
mod_lock_post: ModLockPost;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export class ModRemoveCommentView {
|
||||
@Type(() => ModRemoveComment)
|
||||
mod_remove_comment: ModRemoveComment;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => Comment)
|
||||
comment: Comment;
|
||||
@Type(() => PersonSafe)
|
||||
commenter: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export class ModRemoveCommunityView {
|
||||
@Type(() => ModRemoveCommunity)
|
||||
mod_remove_community: ModRemoveCommunity;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export class ModRemovePostView {
|
||||
@Type(() => ModRemovePost)
|
||||
mod_remove_post: ModRemovePost;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export class ModStickyPostView {
|
||||
@Type(() => ModStickyPost)
|
||||
mod_sticky_post: ModStickyPost;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export class CommunityFollowerView {
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
follower: PersonSafe;
|
||||
}
|
||||
|
||||
export class CommunityBlockView {
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export class CommunityModeratorView {
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
}
|
||||
|
||||
export class CommunityPersonBanView {
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
}
|
||||
|
||||
export class PersonBlockView {
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
target: PersonSafe;
|
||||
}
|
||||
|
||||
export class CommunityView {
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
subscribed: boolean;
|
||||
blocked: boolean;
|
||||
|
@ -252,8 +332,11 @@ export class CommunityView {
|
|||
}
|
||||
|
||||
export class RegistrationApplicationView {
|
||||
@Type(() => RegistrationApplication)
|
||||
registration_application: RegistrationApplication;
|
||||
@Type(() => LocalUserSettings)
|
||||
creator_local_user: LocalUserSettings;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
|
|
Loading…
Reference in a new issue