mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-26 14:21:12 +00:00
Adding toOption function.
This commit is contained in:
parent
06a70b1caa
commit
0c451fe2b6
9 changed files with 262 additions and 258 deletions
|
@ -1,13 +1,13 @@
|
|||
import { Option, Some } from "@sniptt/monads";
|
||||
import { Option } from "@sniptt/monads";
|
||||
import { Expose, Transform, Type } from "class-transformer";
|
||||
import "reflect-metadata";
|
||||
import { toUndefined } from "../../utils";
|
||||
import { toOption, toUndefined } from "../../utils";
|
||||
import { ListingType, SortType } from "../others";
|
||||
import { CommentReportView, CommentView } from "../views";
|
||||
|
||||
export class CreateComment {
|
||||
content: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
parent_id: Option<number>;
|
||||
|
@ -15,7 +15,7 @@ export class CreateComment {
|
|||
/**
|
||||
* An optional front end ID, to tell which is comment is coming back.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
form_id: Option<string>;
|
||||
|
@ -32,7 +32,7 @@ export class EditComment {
|
|||
/**
|
||||
* An optional front end ID, to tell which is comment is coming back.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
form_id: Option<string>;
|
||||
|
@ -62,7 +62,7 @@ export class DeleteComment {
|
|||
export class RemoveComment {
|
||||
comment_id: number;
|
||||
removed: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
|
@ -103,7 +103,7 @@ export class CommentResponse {
|
|||
/**
|
||||
* An optional front end ID, to tell which is comment is coming back.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
form_id: Option<string>;
|
||||
|
@ -126,35 +126,35 @@ export class CreateCommentLike {
|
|||
* To get posts for a federated community by name, use `name@instance.tld` .
|
||||
*/
|
||||
export class GetComments {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
type_: Option<ListingType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_name: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
saved_only: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -198,18 +198,18 @@ export class ResolveCommentReport {
|
|||
}
|
||||
|
||||
export class ListCommentReports {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
/**
|
||||
* if no community is given, it returns reports for all communities moderated by the auth user.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
|
@ -217,7 +217,7 @@ export class ListCommentReports {
|
|||
/**
|
||||
* Only shows the unresolved reports.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unresolved_only: Option<boolean>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Option, Some } from "@sniptt/monads";
|
||||
import { Option } from "@sniptt/monads";
|
||||
import { Expose, Transform, Type } from "class-transformer";
|
||||
import "reflect-metadata";
|
||||
import { toUndefined } from "../../utils";
|
||||
import { toOption, toUndefined } from "../../utils";
|
||||
import { ListingType, SortType } from "../others";
|
||||
import { Site } from "../source";
|
||||
import {
|
||||
|
@ -16,15 +16,15 @@ import {
|
|||
* To get a federated community by name, use `name@instance.tld` .
|
||||
*/
|
||||
export class GetCommunity {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
id: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
name: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -36,7 +36,7 @@ export class GetCommunity {
|
|||
|
||||
export class GetCommunityResponse {
|
||||
community_view: CommunityView;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => Site)
|
||||
|
@ -49,23 +49,23 @@ export class GetCommunityResponse {
|
|||
export class CreateCommunity {
|
||||
name: string;
|
||||
title: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
nsfw: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
posting_restricted_to_mods: Option<boolean>;
|
||||
|
@ -82,23 +82,23 @@ export class CommunityResponse {
|
|||
}
|
||||
|
||||
export class ListCommunities {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
type_: Option<ListingType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -121,18 +121,18 @@ export class BanFromCommunity {
|
|||
/**
|
||||
* Removes/Restores their comments and posts for that community.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
remove_data: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
/**
|
||||
* The expire time in Unix seconds
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<number>;
|
||||
|
@ -170,27 +170,27 @@ export class AddModToCommunityResponse {
|
|||
*/
|
||||
export class EditCommunity {
|
||||
community_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
title: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
nsfw: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
posting_restricted_to_mods: Option<boolean>;
|
||||
|
@ -217,14 +217,14 @@ export class DeleteCommunity {
|
|||
export class RemoveCommunity {
|
||||
community_id: number;
|
||||
removed: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
/**
|
||||
* The expire time in Unix seconds
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<number>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Option, Some } from "@sniptt/monads";
|
||||
import { Option } from "@sniptt/monads";
|
||||
import { Expose, Transform, Type } from "class-transformer";
|
||||
import "reflect-metadata";
|
||||
import { toUndefined } from "../../utils";
|
||||
import { toOption, toUndefined } from "../../utils";
|
||||
import { SortType } from "../others";
|
||||
import {
|
||||
CommentView,
|
||||
|
@ -31,7 +31,7 @@ export class Register {
|
|||
/**
|
||||
* Email is mandatory if email verification is enabled on the server
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
email: Option<string>;
|
||||
|
@ -41,22 +41,22 @@ export class Register {
|
|||
/**
|
||||
* Captcha is only checked if these are enabled in the server.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
captcha_uuid: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
captcha_answer: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
honeypot: Option<string>;
|
||||
/**
|
||||
* An answer is mandatory if require application is enabled on the server
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
answer: Option<string>;
|
||||
|
@ -72,7 +72,7 @@ export class GetCaptchaResponse {
|
|||
/**
|
||||
* Will be undefined if captchas are disabled.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => CaptchaResponse)
|
||||
|
@ -88,7 +88,7 @@ export class CaptchaResponse {
|
|||
/**
|
||||
* A Base64 encoded wav file.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
wav: Option<string>;
|
||||
|
@ -100,7 +100,7 @@ export class CaptchaResponse {
|
|||
}
|
||||
|
||||
export class SaveUserSettings {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_nsfw: Option<boolean>;
|
||||
|
@ -108,7 +108,7 @@ export class SaveUserSettings {
|
|||
/**
|
||||
* Default for this is `browser`.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
theme: Option<string>;
|
||||
|
@ -118,7 +118,7 @@ export class SaveUserSettings {
|
|||
*
|
||||
* The Sort types from above, zero indexed as a number
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
default_sort_type: Option<number>;
|
||||
|
@ -128,63 +128,63 @@ export class SaveUserSettings {
|
|||
*
|
||||
* Post listing types are `All, Subscribed, Community`
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
default_listing_type: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
lang: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
avatar: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
display_name: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
email: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
bio: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
matrix_user_id: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_avatars: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_scores: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
send_notifications_to_email: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
bot_account: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_bot_accounts: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_read_posts: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_new_post_notifs: Option<boolean>;
|
||||
|
@ -213,7 +213,7 @@ export class LoginResponse {
|
|||
/**
|
||||
* This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
jwt: Option<string>;
|
||||
|
@ -222,38 +222,38 @@ export class LoginResponse {
|
|||
}
|
||||
|
||||
export class GetPersonDetails {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
person_id: Option<number>;
|
||||
/**
|
||||
* To get details for a federated user, use `person@instance.tld`.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
username: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
saved_only: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -314,18 +314,18 @@ export class BanPerson {
|
|||
/**
|
||||
* Removes/Restores their comments, posts, and communities
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
remove_data: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
/**
|
||||
* The expire time in Unix seconds
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<number>;
|
||||
|
@ -343,19 +343,19 @@ export class BanPersonResponse {
|
|||
}
|
||||
|
||||
export class GetReplies {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unread_only: Option<boolean>;
|
||||
|
@ -367,19 +367,19 @@ export class GetReplies {
|
|||
}
|
||||
|
||||
export class GetPersonMentions {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unread_only: Option<boolean>;
|
||||
|
@ -480,15 +480,15 @@ export class MarkPrivateMessageAsRead {
|
|||
}
|
||||
|
||||
export class GetPrivateMessages {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unread_only: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
|
@ -513,7 +513,7 @@ export class GetReportCount {
|
|||
/**
|
||||
* If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
|
@ -525,7 +525,7 @@ export class GetReportCount {
|
|||
}
|
||||
|
||||
export class GetReportCountResponse {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Option, Some } from "@sniptt/monads";
|
||||
import { Option } from "@sniptt/monads";
|
||||
import { Expose, Transform, Type } from "class-transformer";
|
||||
import "reflect-metadata";
|
||||
import { toUndefined } from "../../utils";
|
||||
import { toOption, toUndefined } from "../../utils";
|
||||
import { ListingType, SiteMetadata, SortType } from "../others";
|
||||
import {
|
||||
CommentView,
|
||||
|
@ -13,20 +13,20 @@ import {
|
|||
|
||||
export class CreatePost {
|
||||
name: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
url: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
body: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
nsfw: Option<boolean>;
|
||||
community_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
honeypot: Option<string>;
|
||||
|
@ -44,7 +44,7 @@ export class PostResponse {
|
|||
|
||||
export class GetPost {
|
||||
id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -67,38 +67,38 @@ export class GetPostResponse {
|
|||
}
|
||||
|
||||
export class GetPosts {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
type_: Option<ListingType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
/**
|
||||
* To get posts for a federated community by name, use `name@instance.tld` .
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_name: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
saved_only: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -129,19 +129,19 @@ export class CreatePostLike {
|
|||
|
||||
export class EditPost {
|
||||
post_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
name: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
url: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
body: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
nsfw: Option<boolean>;
|
||||
|
@ -168,7 +168,7 @@ export class DeletePost {
|
|||
export class RemovePost {
|
||||
post_id: number;
|
||||
removed: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
|
@ -257,25 +257,25 @@ export class ResolvePostReport {
|
|||
}
|
||||
|
||||
export class ListPostReports {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
/**
|
||||
* if no community is given, it returns reports for all communities moderated by the auth user.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
/**
|
||||
* Only shows the unresolved reports.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unresolved_only: Option<boolean>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Option, Some } from "@sniptt/monads";
|
||||
import { Option } from "@sniptt/monads";
|
||||
import { Expose, Transform, Type } from "class-transformer";
|
||||
import "reflect-metadata";
|
||||
import { toUndefined } from "../../utils";
|
||||
import { toOption, toUndefined } from "../../utils";
|
||||
import { ListingType, SearchType, SortType } from "../others";
|
||||
import {
|
||||
CommentView,
|
||||
|
@ -35,39 +35,39 @@ export class Search {
|
|||
* The search query string.
|
||||
*/
|
||||
q: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
type_: Option<SearchType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_name: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
creator_id: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
listing_type: Option<ListingType>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -93,23 +93,23 @@ export class SearchResponse {
|
|||
}
|
||||
|
||||
export class GetModlog {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
mod_person_id: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -144,59 +144,59 @@ export class GetModlogResponse {
|
|||
|
||||
export class CreateSite {
|
||||
name: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sidebar: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
enable_downvotes: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
open_registration: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
enable_nsfw: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_creation_admin_only: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
require_email_verification: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
require_application: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
application_question: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
private_instance: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
default_theme: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
default_post_listing_type: Option<string>;
|
||||
|
@ -208,67 +208,67 @@ export class CreateSite {
|
|||
}
|
||||
|
||||
export class EditSite {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
name: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sidebar: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
enable_downvotes: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
open_registration: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
enable_nsfw: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_creation_admin_only: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
require_email_verification: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
require_application: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
application_question: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
private_instance: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
default_theme: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
legal_information: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
default_post_listing_type: Option<string>;
|
||||
|
@ -280,7 +280,7 @@ export class EditSite {
|
|||
}
|
||||
|
||||
export class GetSite {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -299,7 +299,7 @@ export class GetSiteResponse {
|
|||
/**
|
||||
* Optional, because the site might not be set up yet.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => SiteView)
|
||||
|
@ -311,12 +311,12 @@ export class GetSiteResponse {
|
|||
/**
|
||||
* If you're logged in, you'll get back extra user info.
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => MyUserInfo)
|
||||
my_user: Option<MyUserInfo>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => FederatedInstances)
|
||||
|
@ -370,11 +370,11 @@ export class SaveSiteConfig {
|
|||
|
||||
export class FederatedInstances {
|
||||
linked: string[];
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
allowed: Option<string[]>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
blocked: Option<string[]>;
|
||||
|
@ -386,7 +386,7 @@ export class FederatedInstances {
|
|||
|
||||
export class ResolveObject {
|
||||
q: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
@ -397,22 +397,22 @@ export class ResolveObject {
|
|||
}
|
||||
|
||||
export class ResolveObjectResponse {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => CommentView)
|
||||
comment: Option<CommentView>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PostView)
|
||||
post: Option<PostView>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => CommunityView)
|
||||
community: Option<CommunityView>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonViewSafe)
|
||||
|
@ -423,15 +423,15 @@ export class ListRegistrationApplications {
|
|||
/**
|
||||
* Only shows the unread applications (IE those without an admin actor)
|
||||
*/
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unread_only: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
|
@ -449,7 +449,7 @@ export class ListRegistrationApplicationsResponse {
|
|||
export class ApproveRegistrationApplication {
|
||||
id: number;
|
||||
approve: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
deny_reason: Option<string>;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Option, Some } from "@sniptt/monads";
|
||||
import { Option } from "@sniptt/monads";
|
||||
import { Expose, Transform } from "class-transformer";
|
||||
import { toUndefined } from "../utils";
|
||||
import { toOption, toUndefined } from "../utils";
|
||||
export const VERSION = "v3";
|
||||
|
||||
/**
|
||||
|
@ -155,19 +155,19 @@ export enum SearchType {
|
|||
* A holder for a site's metadata ( such as opengraph tags ), used for post links.
|
||||
*/
|
||||
export class SiteMetadata {
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
title: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
image: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
html: Option<string>;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { Option, Some } from "@sniptt/monads";
|
||||
import { Option } from "@sniptt/monads";
|
||||
import { Expose, Transform } from "class-transformer";
|
||||
import { toUndefined } from "../utils";
|
||||
import { toOption, toUndefined } from "../utils";
|
||||
|
||||
export class LocalUserSettings {
|
||||
id: number;
|
||||
person_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
email: Option<string>;
|
||||
|
@ -27,40 +27,40 @@ export class LocalUserSettings {
|
|||
export class PersonSafe {
|
||||
id: number;
|
||||
name: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
display_name: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
avatar: Option<string>;
|
||||
banned: boolean;
|
||||
published: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
actor_id: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
bio: Option<string>;
|
||||
local: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
deleted: boolean;
|
||||
inbox_url: string;
|
||||
shared_inbox_url: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
matrix_user_id: Option<string>;
|
||||
admin: boolean;
|
||||
bot_account: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
ban_expires: Option<string>;
|
||||
|
@ -69,34 +69,34 @@ export class PersonSafe {
|
|||
export class Site {
|
||||
id: number;
|
||||
name: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sidebar: Option<string>;
|
||||
published: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
enable_downvotes: boolean;
|
||||
open_registration: boolean;
|
||||
enable_nsfw: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
community_creation_admin_only: boolean;
|
||||
require_email_verification: boolean;
|
||||
require_application: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
application_question: Option<string>;
|
||||
|
@ -107,7 +107,7 @@ export class Site {
|
|||
last_refreshed_at: string;
|
||||
inbox_url: string;
|
||||
public_key: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
legal_information: Option<string>;
|
||||
|
@ -121,7 +121,7 @@ export class PrivateMessage {
|
|||
deleted: boolean;
|
||||
read: boolean;
|
||||
published: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
|
@ -134,22 +134,22 @@ export class PostReport {
|
|||
creator_id: number;
|
||||
post_id: number;
|
||||
original_post_name: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
original_post_url: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
original_post_body: Option<string>;
|
||||
reason: string;
|
||||
resolved: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
resolver_id: Option<number>;
|
||||
published: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
|
@ -158,11 +158,11 @@ export class PostReport {
|
|||
export class Post {
|
||||
id: number;
|
||||
name: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
url: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
body: Option<string>;
|
||||
|
@ -171,26 +171,26 @@ export class Post {
|
|||
removed: boolean;
|
||||
locked: boolean;
|
||||
published: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
deleted: boolean;
|
||||
nsfw: boolean;
|
||||
stickied: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
embed_title: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
embed_description: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
embed_html: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
thumbnail_url: Option<string>;
|
||||
|
@ -209,11 +209,11 @@ export class ModRemovePost {
|
|||
id: number;
|
||||
mod_person_id: number;
|
||||
post_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
|
@ -224,7 +224,7 @@ export class ModLockPost {
|
|||
id: number;
|
||||
mod_person_id: number;
|
||||
post_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
locked: Option<boolean>;
|
||||
|
@ -235,7 +235,7 @@ export class ModStickyPost {
|
|||
id: number;
|
||||
mod_person_id: number;
|
||||
post_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
stickied: Option<boolean>;
|
||||
|
@ -246,11 +246,11 @@ export class ModRemoveComment {
|
|||
id: number;
|
||||
mod_person_id: number;
|
||||
comment_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
|
@ -261,15 +261,15 @@ export class ModRemoveCommunity {
|
|||
id: number;
|
||||
mod_person_id: number;
|
||||
community_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<string>;
|
||||
|
@ -281,15 +281,15 @@ export class ModBanFromCommunity {
|
|||
mod_person_id: number;
|
||||
other_person_id: number;
|
||||
community_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banned: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<string>;
|
||||
|
@ -300,15 +300,15 @@ export class ModBan {
|
|||
id: number;
|
||||
mod_person_id: number;
|
||||
other_person_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banned: Option<boolean>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<string>;
|
||||
|
@ -320,7 +320,7 @@ export class ModAddCommunity {
|
|||
mod_person_id: number;
|
||||
other_person_id: number;
|
||||
community_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
|
@ -332,7 +332,7 @@ export class ModTransferCommunity {
|
|||
mod_person_id: number;
|
||||
other_person_id: number;
|
||||
community_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
|
@ -343,7 +343,7 @@ export class ModAdd {
|
|||
id: number;
|
||||
mod_person_id: number;
|
||||
other_person_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
|
@ -354,13 +354,13 @@ export class CommunitySafe {
|
|||
id: number;
|
||||
name: string;
|
||||
title: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
removed: boolean;
|
||||
published: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
|
@ -368,11 +368,11 @@ export class CommunitySafe {
|
|||
nsfw: boolean;
|
||||
actor_id: string;
|
||||
local: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
|
@ -386,12 +386,12 @@ export class CommentReport {
|
|||
original_comment_text: string;
|
||||
reason: string;
|
||||
resolved: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
resolver_id: Option<number>;
|
||||
published: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
|
@ -401,7 +401,7 @@ export class Comment {
|
|||
id: number;
|
||||
creator_id: number;
|
||||
post_id: number;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
parent_id: Option<number>;
|
||||
|
@ -409,7 +409,7 @@ export class Comment {
|
|||
removed: boolean;
|
||||
read: boolean; // Whether the recipient has read the comment or not
|
||||
published: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
|
@ -430,11 +430,11 @@ export class RegistrationApplication {
|
|||
id: number;
|
||||
local_user_id: number;
|
||||
answer: string;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
admin_id: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
deny_reason: Option<string>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Option, Some } from "@sniptt/monads";
|
||||
import { Option } from "@sniptt/monads";
|
||||
import { Expose, Transform, Type } from "class-transformer";
|
||||
import "reflect-metadata";
|
||||
import { toUndefined } from "../utils";
|
||||
import { toOption, toUndefined } from "../utils";
|
||||
import {
|
||||
CommentAggregates,
|
||||
CommunityAggregates,
|
||||
|
@ -57,7 +57,7 @@ export class PersonMentionView {
|
|||
subscribed: boolean;
|
||||
saved: boolean;
|
||||
creator_blocked: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
my_vote: Option<number>;
|
||||
|
@ -99,7 +99,7 @@ export class PostView {
|
|||
saved: boolean;
|
||||
read: boolean;
|
||||
creator_blocked: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
my_vote: Option<number>;
|
||||
|
@ -117,12 +117,12 @@ export class PostReportView {
|
|||
@Type(() => PersonSafe)
|
||||
post_creator: PersonSafe;
|
||||
creator_banned_from_community: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
my_vote: Option<number>;
|
||||
counts: PostAggregates;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonSafe)
|
||||
|
@ -134,7 +134,7 @@ export class CommentView {
|
|||
comment: Comment;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonSafe)
|
||||
|
@ -148,7 +148,7 @@ export class CommentView {
|
|||
subscribed: boolean;
|
||||
saved: boolean;
|
||||
creator_blocked: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
my_vote: Option<number>;
|
||||
|
@ -169,11 +169,11 @@ export class CommentReportView {
|
|||
comment_creator: PersonSafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
my_vote: Option<number>;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonSafe)
|
||||
|
@ -338,7 +338,7 @@ export class RegistrationApplicationView {
|
|||
creator_local_user: LocalUserSettings;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Transform(({ value }) => Some(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonSafe)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Option } from "@sniptt/monads";
|
||||
import { Option, Some } from "@sniptt/monads";
|
||||
|
||||
/**
|
||||
* Converts an option to an undefined. Necessary for API requests.
|
||||
|
@ -6,3 +6,7 @@ import { Option } from "@sniptt/monads";
|
|||
export function toUndefined<T>(opt: Option<T>) {
|
||||
return opt.isSome() ? opt.unwrap() : undefined;
|
||||
}
|
||||
|
||||
export function toOption<T>(val: T): Option<T> {
|
||||
return Some(val || undefined);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue