Removing monads. Fixes #98 (#99)

* Removing monads. Fixes #98

* Fixing http get params

* In encode get params, dont serialize the undefineds.

* v0.17.0-rc.60
This commit is contained in:
Dessalines 2023-01-04 11:29:06 -05:00 committed by GitHub
parent f1d164fca3
commit 8065620cb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 764 additions and 2340 deletions

View file

@ -1,6 +1,6 @@
{
"name": "lemmy-js-client",
"version": "0.17.0-rc.59",
"version": "0.17.0-rc.60",
"description": "A javascript / typescript client for Lemmy",
"repository": "https://github.com/LemmyNet/lemmy-js-client",
"license": "AGPL-3.0",
@ -26,10 +26,7 @@
]
},
"dependencies": {
"@sniptt/monads": "^0.5.10",
"class-transformer": "^0.5.1",
"node-fetch": "2.6.6",
"reflect-metadata": "^0.1.13"
"node-fetch": "2.6.6"
},
"devDependencies": {
"@types/node": "^18.6.2",

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,3 @@
export * from "./http";
export * from "./interfaces";
export * from "./utils";
export * from "./websocket";

View file

@ -1,127 +1,71 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toOption, toUndefined } from "../../utils";
import { CommentSortType, ListingType } from "../others";
import { CommentReportView, CommentView } from "../views";
export class CreateComment {
export interface CreateComment {
content: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
parent_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
language_id: Option<number>;
parent_id?: number;
language_id?: number;
post_id: number;
/**
* An optional front end ID, to tell which is comment is coming back.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
form_id: Option<string>;
form_id?: string;
auth: string;
constructor(init: CreateComment) {
Object.assign(this, init);
}
}
export class EditComment {
export interface EditComment {
comment_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
content: Option<string>;
content?: string;
/**
* "Distinguishes" a comment, or speak officially. Only doable by community mods or admins.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
distinguished: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
language_id: Option<number>;
distinguished?: boolean;
language_id?: number;
/**
* An optional front end ID, to tell which is comment is coming back.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
form_id: Option<string>;
form_id?: string;
auth: string;
constructor(init: EditComment) {
Object.assign(this, init);
}
}
/**
* Only the creator can delete the comment.
*/
export class DeleteComment {
export interface DeleteComment {
comment_id: number;
deleted: boolean;
auth: string;
constructor(init: DeleteComment) {
Object.assign(this, init);
}
}
/**
* Only a mod or admin can remove the comment.
*/
export class RemoveComment {
export interface RemoveComment {
comment_id: number;
removed: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
auth: string;
constructor(init: RemoveComment) {
Object.assign(this, init);
}
}
export class SaveComment {
export interface SaveComment {
comment_id: number;
save: boolean;
auth: string;
constructor(init: SaveComment) {
Object.assign(this, init);
}
}
export class CommentResponse {
@Type(() => CommentView)
export interface CommentResponse {
comment_view: CommentView;
recipient_ids: number[];
/**
* An optional front end ID, to tell which is comment is coming back.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
form_id: Option<string>;
form_id?: string;
}
export class CreateCommentLike {
export interface CreateCommentLike {
comment_id: number;
score: number;
auth: string;
constructor(init: CreateCommentLike) {
Object.assign(this, init);
}
}
/**
@ -130,122 +74,58 @@ export class CreateCommentLike {
* You can use either `community_id` or `community_name` as an id.
* To get posts for a federated community by name, use `name@instance.tld` .
*/
export class GetComments {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
type_: Option<ListingType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<CommentSortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
max_depth: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_name: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
post_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
parent_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
saved_only: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: GetComments) {
Object.assign(this, init);
}
export interface GetComments {
type_?: ListingType;
sort?: CommentSortType;
max_depth?: number;
page?: number;
limit?: number;
community_id?: number;
community_name?: string;
post_id?: number;
parent_id?: number;
saved_only?: boolean;
auth?: string;
}
export class GetCommentsResponse {
@Type(() => CommentView)
export interface GetCommentsResponse {
comments: CommentView[];
}
export class CreateCommentReport {
export interface CreateCommentReport {
comment_id: number;
reason: string;
auth: string;
constructor(init: CreateCommentReport) {
Object.assign(this, init);
}
}
export class CommentReportResponse {
@Type(() => CommentReportView)
export interface CommentReportResponse {
comment_report_view: CommentReportView;
}
export class ResolveCommentReport {
export interface ResolveCommentReport {
report_id: number;
/**
* Either resolve or unresolve a report.
*/
resolved: boolean;
auth: string;
constructor(init: ResolveCommentReport) {
Object.assign(this, init);
}
}
export class ListCommentReports {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
export interface ListCommentReports {
page?: number;
limit?: number;
/**
* if no community is given, it returns reports for all communities moderated by the auth user.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
community_id?: number;
/**
* Only shows the unresolved reports.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
unresolved_only: Option<boolean>;
unresolved_only?: boolean;
auth: string;
constructor(init: ListCommentReports) {
Object.assign(this, init);
}
}
export class ListCommentReportsResponse {
@Type(() => CommentReportView)
export interface ListCommentReportsResponse {
comment_reports: CommentReportView[];
}

View file

@ -1,7 +1,3 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toOption, toUndefined } from "../../utils";
import { ListingType, SortType } from "../others";
import { Site } from "../source";
import {
@ -15,116 +11,51 @@ import {
*
* To get a federated community by name, use `name@instance.tld` .
*/
export class GetCommunity {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
name: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: GetCommunity) {
Object.assign(this, init);
}
export interface GetCommunity {
id?: number;
name?: string;
auth?: string;
}
export class GetCommunityResponse {
@Type(() => CommunityView)
export interface GetCommunityResponse {
community_view: CommunityView;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => Site)
site: Option<Site>;
@Type(() => CommunityModeratorView)
site?: Site;
moderators: CommunityModeratorView[];
online: number;
discussion_languages: number[];
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
default_post_language: Option<number>;
default_post_language?: number;
}
export class CreateCommunity {
export interface CreateCommunity {
name: string;
title: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
description: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
icon: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banner: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
nsfw: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
posting_restricted_to_mods: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
discussion_languages: Option<number[]>;
description?: string;
icon?: string;
banner?: string;
nsfw?: boolean;
posting_restricted_to_mods?: boolean;
discussion_languages?: number[];
auth: string;
constructor(init: CreateCommunity) {
Object.assign(this, init);
}
}
export class CommunityResponse {
@Type(() => CommunityView)
export interface CommunityResponse {
community_view: CommunityView;
discussion_languages: number[];
}
export class ListCommunities {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
type_: Option<ListingType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<SortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: ListCommunities) {
Object.assign(this, init);
}
export interface ListCommunities {
type_?: ListingType;
sort?: SortType;
page?: number;
limit?: number;
auth?: string;
}
export class ListCommunitiesResponse {
@Type(() => CommunityView)
export interface ListCommunitiesResponse {
communities: CommunityView[];
}
export class BanFromCommunity {
export interface BanFromCommunity {
community_id: number;
person_id: number;
ban: boolean;
@ -132,156 +63,85 @@ export class BanFromCommunity {
/**
* Removes/Restores their comments and posts for that community.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
remove_data: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
remove_data?: boolean;
reason?: string;
/**
* The expire time in Unix seconds
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
expires: Option<number>;
expires?: number;
auth: string;
constructor(init: BanFromCommunity) {
Object.assign(this, init);
}
}
export class BanFromCommunityResponse {
@Type(() => PersonViewSafe)
export interface BanFromCommunityResponse {
person_view: PersonViewSafe;
banned: boolean;
}
export class AddModToCommunity {
export interface AddModToCommunity {
community_id: number;
person_id: number;
added: boolean;
auth: string;
constructor(init: AddModToCommunity) {
Object.assign(this, init);
}
}
export class AddModToCommunityResponse {
@Type(() => CommunityModeratorView)
export interface AddModToCommunityResponse {
moderators: CommunityModeratorView[];
}
/**
* Only mods can edit a community.
*/
export class EditCommunity {
export interface EditCommunity {
community_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
title: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
description: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
icon: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banner: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
nsfw: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
posting_restricted_to_mods: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
discussion_languages: Option<number[]>;
title?: string;
description?: string;
icon?: string;
banner?: string;
nsfw?: boolean;
posting_restricted_to_mods?: boolean;
discussion_languages?: number[];
auth: string;
constructor(init: EditCommunity) {
Object.assign(this, init);
}
}
export class DeleteCommunity {
export interface DeleteCommunity {
community_id: number;
deleted: boolean;
auth: string;
constructor(init: DeleteCommunity) {
Object.assign(this, init);
}
}
/**
* Only admins can remove a community.
*/
export class RemoveCommunity {
export interface RemoveCommunity {
community_id: number;
removed: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
/**
* The expire time in Unix seconds
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
expires: Option<number>;
expires?: number;
auth: string;
constructor(init: RemoveCommunity) {
Object.assign(this, init);
}
}
export class FollowCommunity {
export interface FollowCommunity {
community_id: number;
follow: boolean;
auth: string;
constructor(init: FollowCommunity) {
Object.assign(this, init);
}
}
export class TransferCommunity {
export interface TransferCommunity {
community_id: number;
person_id: number;
auth: string;
constructor(init: TransferCommunity) {
Object.assign(this, init);
}
}
export class BlockCommunity {
export interface BlockCommunity {
community_id: number;
block: boolean;
auth: string;
constructor(init: BlockCommunity) {
Object.assign(this, init);
}
}
export class BlockCommunityResponse {
@Type(() => CommunityView)
export interface BlockCommunityResponse {
community_view: CommunityView;
blocked: boolean;
}

View file

@ -1,7 +1,3 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toOption, toUndefined } from "../../utils";
import { CommentSortType, SortType } from "../others";
import {
CommentReplyView,
@ -14,13 +10,9 @@ import {
PrivateMessageView,
} from "../views";
export class Login {
export interface Login {
username_or_email: string;
password: string;
constructor(init: Login) {
Object.assign(this, init);
}
}
/**
@ -28,60 +20,37 @@ export class Login {
*
* Only the first user to register will be able to be the admin.
*/
export class Register {
export interface Register {
username: string;
/**
* Email is mandatory if email verification is enabled on the server
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
email: Option<string>;
email?: string;
password: string;
password_verify: string;
show_nsfw: boolean;
/**
* Captcha is only checked if these are enabled in the server.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
captcha_uuid: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
captcha_answer: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
honeypot: Option<string>;
captcha_uuid?: string;
captcha_answer?: string;
honeypot?: string;
/**
* An answer is mandatory if require application is enabled on the server
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
answer: Option<string>;
constructor(init: Register) {
Object.assign(this, init);
}
answer?: string;
}
export class GetCaptcha {}
export interface GetCaptcha {}
export class GetCaptchaResponse {
export interface GetCaptchaResponse {
/**
* Will be undefined if captchas are disabled.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => CaptchaResponse)
ok: Option<CaptchaResponse>;
ok?: CaptchaResponse;
}
export class CaptchaResponse {
export interface CaptchaResponse {
/**
* A Base64 encoded png.
*/
@ -90,10 +59,7 @@ export class CaptchaResponse {
/**
* A Base64 encoded wav file.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
wav: Option<string>;
wav?: string;
/**
* A UUID to match the one given on request.
@ -101,563 +67,299 @@ export class CaptchaResponse {
uuid: string;
}
export class SaveUserSettings {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
show_nsfw: Option<boolean>;
export interface SaveUserSettings {
show_nsfw?: boolean;
/**
* Default for this is `browser`.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
theme: Option<string>;
theme?: string;
/**
* The [[SortType]].
*
* The Sort types from above, zero indexed as a number
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
default_sort_type: Option<number>;
default_sort_type?: number;
/**
* The [[ListingType]].
*
* Post listing types are `All, Subscribed, Community`
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
default_listing_type: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
interface_language: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
avatar: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banner: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
display_name: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
email: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
bio: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
matrix_user_id: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
show_avatars: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
show_scores: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
send_notifications_to_email: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
bot_account: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
show_bot_accounts: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
show_read_posts: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
show_new_post_notifs: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
discussion_languages: Option<number[]>;
default_listing_type?: number;
interface_language?: string;
avatar?: string;
banner?: string;
display_name?: string;
email?: string;
bio?: string;
matrix_user_id?: string;
show_avatars?: boolean;
show_scores?: boolean;
send_notifications_to_email?: boolean;
bot_account?: boolean;
show_bot_accounts?: boolean;
show_read_posts?: boolean;
show_new_post_notifs?: boolean;
discussion_languages?: number[];
auth: string;
constructor(init: SaveUserSettings) {
Object.assign(this, init);
}
}
export class ChangePassword {
export interface ChangePassword {
new_password: string;
new_password_verify: string;
old_password: string;
auth: string;
constructor(init: ChangePassword) {
Object.assign(this, init);
}
}
/**
* The `jwt` string should be stored and used anywhere `auth` is called for.
*/
export class LoginResponse {
export interface LoginResponse {
/**
* This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
jwt: Option<string>;
jwt?: string;
verify_email_sent: boolean;
registration_created: boolean;
}
export class GetPersonDetails {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
person_id: Option<number>;
export interface GetPersonDetails {
person_id?: number;
/**
* To get details for a federated user, use `person@instance.tld`.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
username: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<SortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
saved_only: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: GetPersonDetails) {
Object.assign(this, init);
}
username?: string;
sort?: SortType;
page?: number;
limit?: number;
community_id?: number;
saved_only?: boolean;
auth?: string;
}
export class GetPersonDetailsResponse {
@Type(() => PersonViewSafe)
export interface GetPersonDetailsResponse {
person_view: PersonViewSafe;
@Type(() => CommentView)
comments: CommentView[];
@Type(() => PostView)
posts: PostView[];
@Type(() => CommunityModeratorView)
moderates: CommunityModeratorView[];
}
export class GetRepliesResponse {
@Type(() => CommentReplyView)
export interface GetRepliesResponse {
replies: CommentReplyView[];
}
export class GetPersonMentionsResponse {
@Type(() => PersonMentionView)
export interface GetPersonMentionsResponse {
mentions: PersonMentionView[];
}
export class MarkAllAsRead {
export interface MarkAllAsRead {
auth: string;
constructor(auth: string) {
this.auth = auth;
}
}
export class AddAdmin {
export interface AddAdmin {
person_id: number;
added: boolean;
auth: string;
constructor(init: AddAdmin) {
Object.assign(this, init);
}
}
export class AddAdminResponse {
@Type(() => PersonViewSafe)
export interface AddAdminResponse {
admins: PersonViewSafe[];
}
export class BanPerson {
export interface BanPerson {
person_id: number;
ban: boolean;
/**
* Removes/Restores their comments, posts, and communities
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
remove_data: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
remove_data?: boolean;
reason?: string;
/**
* The expire time in Unix seconds
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
expires: Option<number>;
expires?: number;
auth: string;
constructor(init: BanPerson) {
Object.assign(this, init);
}
}
export class BanPersonResponse {
@Type(() => PersonViewSafe)
export interface BanPersonResponse {
person_view: PersonViewSafe;
banned: boolean;
}
export class GetReplies {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<CommentSortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
unread_only: Option<boolean>;
export interface GetReplies {
sort?: CommentSortType;
page?: number;
limit?: number;
unread_only?: boolean;
auth: string;
constructor(init: GetReplies) {
Object.assign(this, init);
}
}
export class GetPersonMentions {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<CommentSortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
unread_only: Option<boolean>;
export interface GetPersonMentions {
sort?: CommentSortType;
page?: number;
limit?: number;
unread_only?: boolean;
auth: string;
constructor(init: GetPersonMentions) {
Object.assign(this, init);
}
}
export class MarkPersonMentionAsRead {
export interface MarkPersonMentionAsRead {
person_mention_id: number;
read: boolean;
auth: string;
constructor(init: MarkPersonMentionAsRead) {
Object.assign(this, init);
}
}
export class PersonMentionResponse {
@Type(() => PersonMentionView)
export interface PersonMentionResponse {
person_mention_view: PersonMentionView;
}
export class MarkCommentReplyAsRead {
export interface MarkCommentReplyAsRead {
comment_reply_id: number;
read: boolean;
auth: string;
constructor(init: MarkCommentReplyAsRead) {
Object.assign(this, init);
}
}
export class CommentReplyResponse {
@Type(() => CommentReplyView)
export interface CommentReplyResponse {
comment_reply_view: CommentReplyView;
}
/**
* Permanently deletes your posts and comments
*/
export class DeleteAccount {
export interface DeleteAccount {
password: string;
auth: string;
constructor(init: DeleteAccount) {
Object.assign(this, init);
}
}
export class DeleteAccountResponse {}
export interface DeleteAccountResponse {}
export class PasswordReset {
export interface PasswordReset {
email: string;
constructor(init: PasswordReset) {
Object.assign(this, init);
}
}
export class PasswordResetResponse {}
export interface PasswordResetResponse {}
export class PasswordChange {
export interface PasswordChange {
token: string;
password: string;
password_verify: string;
constructor(init: PasswordChange) {
Object.assign(this, init);
}
}
export class CreatePrivateMessage {
export interface CreatePrivateMessage {
content: string;
recipient_id: number;
auth: string;
constructor(init: CreatePrivateMessage) {
Object.assign(this, init);
}
}
export class EditPrivateMessage {
export interface EditPrivateMessage {
private_message_id: number;
content: string;
auth: string;
constructor(init: EditPrivateMessage) {
Object.assign(this, init);
}
}
export class DeletePrivateMessage {
export interface DeletePrivateMessage {
private_message_id: number;
deleted: boolean;
auth: string;
constructor(init: DeletePrivateMessage) {
Object.assign(this, init);
}
}
export class MarkPrivateMessageAsRead {
export interface MarkPrivateMessageAsRead {
private_message_id: number;
read: boolean;
auth: string;
constructor(init: MarkPrivateMessageAsRead) {
Object.assign(this, init);
}
}
export class GetPrivateMessages {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
unread_only: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
export interface GetPrivateMessages {
unread_only?: boolean;
page?: number;
limit?: number;
auth: string;
constructor(init: GetPrivateMessages) {
Object.assign(this, init);
}
}
export class PrivateMessagesResponse {
@Type(() => PrivateMessageView)
export interface PrivateMessagesResponse {
private_messages: PrivateMessageView[];
}
export class PrivateMessageResponse {
@Type(() => PrivateMessageView)
export interface PrivateMessageResponse {
private_message_view: PrivateMessageView;
}
export class CreatePrivateMessageReport {
export interface CreatePrivateMessageReport {
private_message_id: number;
reason: string;
auth: string;
constructor(init: CreatePrivateMessageReport) {
Object.assign(this, init);
}
}
export class PrivateMessageReportResponse {
@Type(() => PrivateMessageReportView)
export interface PrivateMessageReportResponse {
private_message_report_view: PrivateMessageReportView;
}
export class ResolvePrivateMessageReport {
export interface ResolvePrivateMessageReport {
report_id: number;
resolved: boolean;
auth: string;
constructor(init: ResolvePrivateMessageReport) {
Object.assign(this, init);
}
}
export class ListPrivateMessageReports {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
export interface ListPrivateMessageReports {
page?: number;
limit?: number;
/// Only shows the unresolved reports
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
unresolved_only: Option<boolean>;
unresolved_only?: boolean;
auth: string;
constructor(init: ListPrivateMessageReports) {
Object.assign(this, init);
}
}
export class ListPrivateMessageReportsResponse {
@Type(() => PrivateMessageReportView)
export interface ListPrivateMessageReportsResponse {
private_message_reports: PrivateMessageReportView[];
}
export class GetReportCount {
export interface 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 }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
community_id?: number;
auth: string;
constructor(init: GetReportCount) {
Object.assign(this, init);
}
}
export class GetReportCountResponse {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
export interface GetReportCountResponse {
community_id?: number;
comment_reports: number;
post_reports: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
private_message_reports: Option<number>;
private_message_reports?: number;
}
export class GetUnreadCount {
export interface GetUnreadCount {
auth: string;
constructor(init: GetUnreadCount) {
Object.assign(this, init);
}
}
export class GetUnreadCountResponse {
export interface GetUnreadCountResponse {
replies: number;
mentions: number;
private_messages: number;
}
export class VerifyEmail {
export interface VerifyEmail {
token: string;
constructor(init: VerifyEmail) {
Object.assign(this, init);
}
}
export class VerifyEmailResponse {}
export interface VerifyEmailResponse {}
export class BlockPerson {
export interface BlockPerson {
person_id: number;
block: boolean;
auth: string;
constructor(init: BlockPerson) {
Object.assign(this, init);
}
}
export class BlockPersonResponse {
@Type(() => PersonViewSafe)
export interface BlockPersonResponse {
person_view: PersonViewSafe;
blocked: boolean;
}
export class GetBannedPersons {
export interface GetBannedPersons {
auth: string;
constructor(init: GetBannedPersons) {
Object.assign(this, init);
}
}
export class BannedPersonsResponse {
@Type(() => PersonViewSafe)
export interface BannedPersonsResponse {
banned: PersonViewSafe[];
}

View file

@ -1,7 +1,3 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toOption, toUndefined } from "../../utils";
import {
ListingType,
PostFeatureType,
@ -15,118 +11,53 @@ import {
PostView,
} from "../views";
export class CreatePost {
export interface CreatePost {
name: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
url: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
body: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
nsfw: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
language_id: Option<number>;
url?: string;
body?: string;
nsfw?: boolean;
language_id?: number;
community_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
honeypot: Option<string>;
honeypot?: string;
auth: string;
constructor(init: CreatePost) {
Object.assign(this, init);
}
}
export class PostResponse {
@Type(() => PostView)
export interface PostResponse {
post_view: PostView;
}
export class GetPost {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
comment_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: GetPost) {
Object.assign(this, init);
}
export interface GetPost {
id?: number;
comment_id?: number;
auth?: string;
}
export class GetPostResponse {
@Type(() => PostView)
export interface GetPostResponse {
post_view: PostView;
@Type(() => CommunityView)
community_view: CommunityView;
@Type(() => CommunityModeratorView)
moderators: CommunityModeratorView[];
online: number;
}
export class GetPosts {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
type_: Option<ListingType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<SortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
export interface GetPosts {
type_?: ListingType;
sort?: SortType;
page?: number;
limit?: number;
community_id?: number;
/**
* To get posts for a federated community by name, use `name@instance.tld` .
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_name: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
saved_only: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: GetPosts) {
Object.assign(this, init);
}
community_name?: string;
saved_only?: boolean;
auth?: string;
}
export class GetPostsResponse {
@Type(() => PostView)
export interface GetPostsResponse {
posts: PostView[];
}
export class CreatePostLike {
export interface CreatePostLike {
post_id: number;
/**
@ -134,190 +65,109 @@ export class CreatePostLike {
*/
score: number;
auth: string;
constructor(init: CreatePostLike) {
Object.assign(this, init);
}
}
export class EditPost {
export interface EditPost {
post_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
name: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
url: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
body: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
nsfw: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
language_id: Option<number>;
name?: string;
url?: string;
body?: string;
nsfw?: boolean;
language_id?: number;
auth: string;
constructor(init: EditPost) {
Object.assign(this, init);
}
}
export class DeletePost {
export interface DeletePost {
post_id: number;
deleted: boolean;
auth: string;
constructor(init: DeletePost) {
Object.assign(this, init);
}
}
/**
* Only admins and mods can remove a post.
*/
export class RemovePost {
export interface RemovePost {
post_id: number;
removed: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
auth: string;
constructor(init: RemovePost) {
Object.assign(this, init);
}
}
/**
* Marks a post as read.
*/
export class MarkPostAsRead {
export interface MarkPostAsRead {
post_id: number;
read: boolean;
auth: string;
constructor(init: MarkPostAsRead) {
Object.assign(this, init);
}
}
/**
* Only admins and mods can lock a post.
*/
export class LockPost {
export interface LockPost {
post_id: number;
locked: boolean;
auth: string;
constructor(init: LockPost) {
Object.assign(this, init);
}
}
/**
* Only admins and mods can feature a community post.
*/
export class FeaturePost {
export interface FeaturePost {
post_id: number;
featured: boolean;
feature_type: PostFeatureType;
auth: string;
constructor(init: FeaturePost) {
Object.assign(this, init);
}
}
export class SavePost {
export interface SavePost {
post_id: number;
save: boolean;
auth: string;
constructor(init: SavePost) {
Object.assign(this, init);
}
}
export class CreatePostReport {
export interface CreatePostReport {
post_id: number;
reason: string;
auth: string;
constructor(init: CreatePostReport) {
Object.assign(this, init);
}
}
export class PostReportResponse {
@Type(() => PostReportView)
export interface PostReportResponse {
post_report_view: PostReportView;
}
export class ResolvePostReport {
export interface ResolvePostReport {
report_id: number;
/**
* Either resolve or unresolve a report.
*/
resolved: boolean;
auth: string;
constructor(init: ResolvePostReport) {
Object.assign(this, init);
}
}
export class ListPostReports {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
export interface ListPostReports {
page?: number;
limit?: number;
/**
* if no community is given, it returns reports for all communities moderated by the auth user.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
community_id?: number;
/**
* Only shows the unresolved reports.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
unresolved_only: Option<boolean>;
unresolved_only?: boolean;
auth: string;
constructor(init: ListPostReports) {
Object.assign(this, init);
}
}
export class ListPostReportsResponse {
@Type(() => PostReportView)
export interface ListPostReportsResponse {
post_reports: PostReportView[];
}
export class GetSiteMetadata {
export interface GetSiteMetadata {
url: string;
constructor(init: GetSiteMetadata) {
Object.assign(this, init);
}
}
export class GetSiteMetadataResponse {
@Type(() => SiteMetadata)
export interface GetSiteMetadataResponse {
metadata: SiteMetadata;
}

View file

@ -1,7 +1,3 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toOption, toUndefined } from "../../utils";
import { ListingType, ModlogActionType, SearchType, SortType } from "../others";
import { Language, RegistrationMode, Tagline } from "../source";
import {
@ -35,695 +31,262 @@ import {
/**
* Search lemmy for different types of data.
*/
export class Search {
export interface Search {
/**
* The search query string.
*/
q: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
type_: Option<SearchType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_name: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
creator_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sort: Option<SortType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
listing_type: Option<ListingType>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: Search) {
Object.assign(this, init);
}
type_?: SearchType;
community_id?: number;
community_name?: string;
creator_id?: number;
sort?: SortType;
listing_type?: ListingType;
page?: number;
limit?: number;
auth?: string;
}
export class SearchResponse {
export interface SearchResponse {
/**
* The [[SearchType]].
*/
type_: string;
@Type(() => CommentView)
comments: CommentView[];
@Type(() => PostView)
posts: PostView[];
@Type(() => CommunityView)
communities: CommunityView[];
@Type(() => PersonViewSafe)
users: PersonViewSafe[];
}
export class GetModlog {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
mod_person_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
export interface GetModlog {
mod_person_id?: number;
community_id?: number;
page?: number;
limit?: number;
auth?: string;
type_: ModlogActionType;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
other_person_id: Option<number>;
constructor(init: GetModlog) {
Object.assign(this, init);
}
other_person_id?: number;
}
export class GetModlogResponse {
@Type(() => ModRemovePostView)
export interface GetModlogResponse {
removed_posts: ModRemovePostView[];
@Type(() => ModLockPostView)
locked_posts: ModLockPostView[];
@Type(() => ModFeaturePostView)
featured_posts: ModFeaturePostView[];
@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[];
@Type(() => AdminPurgePersonView)
admin_purged_persons: AdminPurgePersonView[];
@Type(() => AdminPurgeCommunityView)
admin_purged_communities: AdminPurgeCommunityView[];
@Type(() => AdminPurgePostView)
admin_purged_posts: AdminPurgePostView[];
@Type(() => AdminPurgeCommentView)
admin_purged_comments: AdminPurgeCommentView[];
}
export class CreateSite {
export interface CreateSite {
name: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sidebar: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
description: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
icon: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banner: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
enable_downvotes: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
enable_nsfw: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_creation_admin_only: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
require_email_verification: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
registration_mode: Option<RegistrationMode>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
application_question: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
private_instance: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
default_theme: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
default_post_listing_type: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
application_email_admins: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
hide_modlog_mod_names: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
discussion_languages: Option<number[]>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
legal_information: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
slur_filter_regex: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
actor_name_max_length: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_message: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_message_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_post: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_post_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_register: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_register_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_image: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_image_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_comment: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_comment_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_search: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_search_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
federation_enabled: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
federation_debug: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
federation_worker_count: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
captcha_enabled: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
captcha_difficulty: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
allowed_instances: Option<string[]>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
blocked_instances: Option<string[]>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
taglines: Option<string[]>;
sidebar?: string;
description?: string;
icon?: string;
banner?: string;
enable_downvotes?: boolean;
enable_nsfw?: boolean;
community_creation_admin_only?: boolean;
require_email_verification?: boolean;
registration_mode?: RegistrationMode;
application_question?: string;
private_instance?: boolean;
default_theme?: string;
default_post_listing_type?: string;
application_email_admins?: boolean;
hide_modlog_mod_names?: boolean;
discussion_languages?: number[];
legal_information?: string;
slur_filter_regex?: string;
actor_name_max_length?: number;
rate_limit_message?: number;
rate_limit_message_per_second?: number;
rate_limit_post?: number;
rate_limit_post_per_second?: number;
rate_limit_register?: number;
rate_limit_register_per_second?: number;
rate_limit_image?: number;
rate_limit_image_per_second?: number;
rate_limit_comment?: number;
rate_limit_comment_per_second?: number;
rate_limit_search?: number;
rate_limit_search_per_second?: number;
federation_enabled?: boolean;
federation_debug?: boolean;
federation_worker_count?: number;
captcha_enabled?: boolean;
captcha_difficulty?: string;
allowed_instances?: string[];
blocked_instances?: string[];
taglines?: string[];
auth: string;
constructor(init: CreateSite) {
Object.assign(this, init);
}
}
export class EditSite {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
name: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sidebar: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
description: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
icon: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banner: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
enable_downvotes: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
enable_nsfw: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
community_creation_admin_only: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
require_email_verification: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
registration_mode: Option<RegistrationMode>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
application_question: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
private_instance: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
default_theme: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
default_post_listing_type: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
legal_information: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
application_email_admins: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
hide_modlog_mod_names: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
discussion_languages: Option<number[]>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
slur_filter_regex: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
actor_name_max_length: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_message: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_message_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_post: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_post_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_register: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_register_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_image: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_image_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_comment: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_comment_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_search: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
rate_limit_search_per_second: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
federation_enabled: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
federation_debug: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
federation_worker_count: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
captcha_enabled: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
captcha_difficulty: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
allowed_instances: Option<string[]>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
blocked_instances: Option<string[]>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
taglines: Option<string[]>;
export interface EditSite {
name?: string;
sidebar?: string;
description?: string;
icon?: string;
banner?: string;
enable_downvotes?: boolean;
enable_nsfw?: boolean;
community_creation_admin_only?: boolean;
require_email_verification?: boolean;
registration_mode?: RegistrationMode;
application_question?: string;
private_instance?: boolean;
default_theme?: string;
default_post_listing_type?: string;
legal_information?: string;
application_email_admins?: boolean;
hide_modlog_mod_names?: boolean;
discussion_languages?: number[];
slur_filter_regex?: string;
actor_name_max_length?: number;
rate_limit_message?: number;
rate_limit_message_per_second?: number;
rate_limit_post?: number;
rate_limit_post_per_second?: number;
rate_limit_register?: number;
rate_limit_register_per_second?: number;
rate_limit_image?: number;
rate_limit_image_per_second?: number;
rate_limit_comment?: number;
rate_limit_comment_per_second?: number;
rate_limit_search?: number;
rate_limit_search_per_second?: number;
federation_enabled?: boolean;
federation_debug?: boolean;
federation_worker_count?: number;
captcha_enabled?: boolean;
captcha_difficulty?: string;
allowed_instances?: string[];
blocked_instances?: string[];
taglines?: string[];
auth: string;
constructor(init: EditSite) {
Object.assign(this, init);
}
}
export class GetSite {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: GetSite) {
Object.assign(this, init);
}
export interface GetSite {
auth?: string;
}
export class SiteResponse {
@Type(() => SiteView)
export interface SiteResponse {
site_view: SiteView;
}
export class GetSiteResponse {
@Type(() => SiteView)
export interface GetSiteResponse {
site_view: SiteView;
@Type(() => PersonViewSafe)
admins: PersonViewSafe[];
online: number;
version: string;
/**
* If you're logged in, you'll get back extra user info.
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => MyUserInfo)
my_user: Option<MyUserInfo>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => FederatedInstances)
federated_instances: Option<FederatedInstances>;
@Type(() => Language)
my_user?: MyUserInfo;
federated_instances?: FederatedInstances;
all_languages: Language[];
discussion_languages: number[];
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => Tagline)
taglines: Option<Tagline[]>;
taglines?: Tagline[];
}
/**
* Your user info, such as blocks, follows, etc.
*/
export class MyUserInfo {
@Type(() => LocalUserSettingsView)
export interface MyUserInfo {
local_user_view: LocalUserSettingsView;
@Type(() => CommunityFollowerView)
follows: CommunityFollowerView[];
@Type(() => CommunityModeratorView)
moderates: CommunityModeratorView[];
@Type(() => CommunityBlockView)
community_blocks: CommunityBlockView[];
@Type(() => PersonBlockView)
person_blocks: PersonBlockView[];
discussion_languages: number[];
}
export class LeaveAdmin {
export interface LeaveAdmin {
auth: string;
constructor(init: LeaveAdmin) {
Object.assign(this, init);
}
}
export class FederatedInstances {
export interface FederatedInstances {
linked: string[];
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
allowed: Option<string[]>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
blocked: Option<string[]>;
constructor(init: FederatedInstances) {
Object.assign(this, init);
}
allowed?: string[];
blocked?: string[];
}
export class ResolveObject {
export interface ResolveObject {
q: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
auth: Option<string>;
constructor(init: ResolveObject) {
Object.assign(this, init);
}
auth?: string;
}
export class ResolveObjectResponse {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => CommentView)
comment: Option<CommentView>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PostView)
post: Option<PostView>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => CommunityView)
community: Option<CommunityView>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonViewSafe)
person: Option<PersonViewSafe>;
export interface ResolveObjectResponse {
comment?: CommentView;
post?: PostView;
community?: CommunityView;
person?: PersonViewSafe;
}
export class PurgePerson {
export interface PurgePerson {
person_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
auth: string;
constructor(init: PurgePerson) {
Object.assign(this, init);
}
}
export class PurgeCommunity {
export interface PurgeCommunity {
community_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
auth: string;
constructor(init: PurgeCommunity) {
Object.assign(this, init);
}
}
export class PurgePost {
export interface PurgePost {
post_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
auth: string;
constructor(init: PurgePost) {
Object.assign(this, init);
}
}
export class PurgeComment {
export interface PurgeComment {
comment_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
auth: string;
constructor(init: PurgeComment) {
Object.assign(this, init);
}
}
export class PurgeItemResponse {
export interface PurgeItemResponse {
success: boolean;
}
export class ListRegistrationApplications {
export interface ListRegistrationApplications {
/**
* Only shows the unread applications (IE those without an admin actor)
*/
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
unread_only: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
page: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
limit: Option<number>;
unread_only?: boolean;
page?: number;
limit?: number;
auth: string;
constructor(init: ListRegistrationApplications) {
Object.assign(this, init);
}
}
export class ListRegistrationApplicationsResponse {
@Type(() => RegistrationApplicationView)
export interface ListRegistrationApplicationsResponse {
registration_applications: RegistrationApplicationView[];
}
export class ApproveRegistrationApplication {
export interface ApproveRegistrationApplication {
id: number;
approve: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
deny_reason: Option<string>;
deny_reason?: string;
auth: string;
constructor(init: ApproveRegistrationApplication) {
Object.assign(this, init);
}
}
export class RegistrationApplicationResponse {
@Type(() => RegistrationApplicationView)
export interface RegistrationApplicationResponse {
registration_application: RegistrationApplicationView;
}
export class GetUnreadRegistrationApplicationCount {
export interface GetUnreadRegistrationApplicationCount {
auth: string;
constructor(init: GetUnreadRegistrationApplicationCount) {
Object.assign(this, init);
}
}
export class GetUnreadRegistrationApplicationCountResponse {
export interface GetUnreadRegistrationApplicationCountResponse {
registration_applications: number;
}

View file

@ -1,6 +1,3 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform } from "class-transformer";
import { toOption, toUndefined } from "../utils";
export const VERSION = "v3";
/**
@ -227,25 +224,9 @@ export enum PostFeatureType {
/**
* A holder for a site's metadata ( such as opengraph tags ), used for post links.
*/
export class SiteMetadata {
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
title: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
description: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
image: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
html: Option<string>;
constructor(init: SiteMetadata) {
Object.assign(this, init);
}
export interface SiteMetadata {
title?: string;
description?: string;
image?: string;
html?: string;
}

View file

@ -1,14 +1,7 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform } from "class-transformer";
import { toOption, toUndefined } from "../utils";
export class LocalUserSettings {
export interface LocalUserSettings {
id: number;
person_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
email: Option<string>;
email?: string;
show_nsfw: boolean;
theme: string;
default_sort_type: number;
@ -25,80 +18,41 @@ export class LocalUserSettings {
accepted_application: boolean;
}
export class PersonSafe {
export interface PersonSafe {
id: number;
name: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
display_name: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
avatar: Option<string>;
display_name?: string;
avatar?: string;
banned: boolean;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
actor_id: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
bio: Option<string>;
bio?: string;
local: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banner: Option<string>;
banner?: string;
deleted: boolean;
inbox_url: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
shared_inbox_url: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
matrix_user_id: Option<string>;
shared_inbox_url?: string;
matrix_user_id?: string;
admin: boolean;
bot_account: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
ban_expires: Option<string>;
ban_expires?: string;
instance_id: number;
}
export class Site {
export interface Site {
id: number;
name: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
sidebar: Option<string>;
sidebar?: string;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
icon: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banner: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
description: Option<string>;
updated?: string;
icon?: string;
banner?: string;
description?: string;
actor_id: string;
last_refreshed_at: string;
inbox_url: string;
private_key: Option<string>;
private_key?: string;
public_key: string;
instance_id: number;
}
@ -109,7 +63,7 @@ export enum RegistrationMode {
Open = "open",
}
export class LocalSite {
export interface LocalSite {
id: number;
site_id: number;
site_setup: boolean;
@ -118,23 +72,14 @@ export class LocalSite {
enable_nsfw: boolean;
community_creation_admin_only: boolean;
require_email_verification: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
application_question: Option<string>;
application_question?: string;
private_instance: boolean;
default_theme: string;
default_post_listing_type: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
legal_information: Option<string>;
legal_information?: string;
hide_modlog_mod_names: boolean;
application_email_admins: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
slur_filter_regex: Option<string>;
slur_filter_regex?: string;
actor_name_max_length: number;
federation_enabled: boolean;
federation_debug: boolean;
@ -142,13 +87,10 @@ export class LocalSite {
captcha_enabled: boolean;
captcha_difficulty: string;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
}
export class LocalSiteRateLimit {
export interface LocalSiteRateLimit {
id: number;
local_site_id: number;
message: number;
@ -164,13 +106,10 @@ export class LocalSiteRateLimit {
search: number;
search_per_second: number;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
}
export class PrivateMessage {
export interface PrivateMessage {
id: number;
creator_id: number;
recipient_id: number;
@ -178,78 +117,42 @@ export class PrivateMessage {
deleted: boolean;
read: boolean;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
ap_id: string;
local: boolean;
}
export class PostReport {
export interface PostReport {
id: number;
creator_id: number;
post_id: number;
original_post_name: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
original_post_url: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
original_post_body: Option<string>;
original_post_url?: string;
original_post_body?: string;
reason: string;
resolved: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
resolver_id: Option<number>;
resolver_id?: number;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
}
export class Post {
export interface Post {
id: number;
name: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
url: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
body: Option<string>;
url?: string;
body?: string;
creator_id: number;
community_id: number;
removed: boolean;
locked: boolean;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
deleted: boolean;
nsfw: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
embed_title: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
embed_description: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
embed_video_url: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
thumbnail_url: Option<string>;
embed_title?: string;
embed_description?: string;
embed_video_url?: string;
thumbnail_url?: string;
ap_id: string;
local: boolean;
language_id: number;
@ -257,40 +160,31 @@ export class Post {
featured_local: boolean;
}
export class PasswordResetRequest {
export interface PasswordResetRequest {
id: number;
local_user_id: number;
token_encrypted: string;
published: string;
}
export class ModRemovePost {
export interface ModRemovePost {
id: number;
mod_person_id: number;
post_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
removed: Option<boolean>;
reason?: string;
removed?: boolean;
when_: string;
}
export class ModLockPost {
export interface ModLockPost {
id: number;
mod_person_id: number;
post_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
locked: Option<boolean>;
locked?: boolean;
when_: string;
}
export class ModFeaturePost {
export interface ModFeaturePost {
id: number;
mod_person_id: number;
post_id: number;
@ -299,216 +193,141 @@ export class ModFeaturePost {
when_: string;
}
export class ModRemoveComment {
export interface ModRemoveComment {
id: number;
mod_person_id: number;
comment_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
removed: Option<boolean>;
reason?: string;
removed?: boolean;
when_: string;
}
export class ModRemoveCommunity {
export interface ModRemoveCommunity {
id: number;
mod_person_id: number;
community_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
removed: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
expires: Option<string>;
reason?: string;
removed?: boolean;
expires?: string;
when_: string;
}
export class ModBanFromCommunity {
export interface ModBanFromCommunity {
id: number;
mod_person_id: number;
other_person_id: number;
community_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banned: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
expires: Option<string>;
reason?: string;
banned?: boolean;
expires?: string;
when_: string;
}
export class ModBan {
export interface ModBan {
id: number;
mod_person_id: number;
other_person_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banned: Option<boolean>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
expires: Option<string>;
reason?: string;
banned?: boolean;
expires?: string;
when_: string;
}
export class ModAddCommunity {
export interface ModAddCommunity {
id: number;
mod_person_id: number;
other_person_id: number;
community_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
removed: Option<boolean>;
removed?: boolean;
when_: string;
}
export class ModTransferCommunity {
export interface ModTransferCommunity {
id: number;
mod_person_id: number;
other_person_id: number;
community_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
removed: Option<boolean>;
removed?: boolean;
when_: string;
}
export class ModAdd {
export interface ModAdd {
id: number;
mod_person_id: number;
other_person_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
removed: Option<boolean>;
removed?: boolean;
when_: string;
}
export class AdminPurgePerson {
export interface AdminPurgePerson {
id: number;
admin_person_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
when_: string;
}
export class AdminPurgeCommunity {
export interface AdminPurgeCommunity {
id: number;
admin_person_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
when_: string;
}
export class AdminPurgePost {
export interface AdminPurgePost {
id: number;
admin_person_id: number;
community_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
when_: string;
}
export class AdminPurgeComment {
export interface AdminPurgeComment {
id: number;
admin_person_id: number;
post_id: number;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
reason: Option<string>;
reason?: string;
when_: string;
}
export class CommunitySafe {
export interface CommunitySafe {
id: number;
name: string;
title: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
description: Option<string>;
description?: string;
removed: boolean;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
deleted: boolean;
nsfw: boolean;
actor_id: string;
local: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
icon: Option<string>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
banner: Option<string>;
icon?: string;
banner?: string;
hidden: boolean;
posting_restricted_to_mods: boolean;
instance_id: number;
}
export class CommentReport {
export interface CommentReport {
id: number;
creator_id: number;
comment_id: number;
original_comment_text: string;
reason: string;
resolved: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
resolver_id: Option<number>;
resolver_id?: number;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
}
export class Comment {
export interface Comment {
id: number;
creator_id: number;
post_id: number;
content: string;
removed: boolean;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
deleted: boolean;
ap_id: string;
local: boolean;
@ -517,7 +336,7 @@ export class Comment {
language_id: number;
}
export class PersonMention {
export interface PersonMention {
id: number;
recipient_id: number;
comment_id: number;
@ -525,7 +344,7 @@ export class PersonMention {
published: string;
}
export class CommentReply {
export interface CommentReply {
id: number;
recipient_id: number;
comment_id: number;
@ -533,52 +352,37 @@ export class CommentReply {
published: string;
}
export class RegistrationApplication {
export interface RegistrationApplication {
id: number;
local_user_id: number;
answer: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
admin_id: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
deny_reason: Option<string>;
admin_id?: number;
deny_reason?: string;
published: string;
}
export class Language {
export interface Language {
id: number;
code: string;
name: string;
}
export class PrivateMessageReport {
export interface PrivateMessageReport {
id: number;
creator_id: number;
private_message_id: number;
original_pm_text: string;
reason: string;
resolved: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
resolver_id: Option<number>;
resolver_id?: number;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
}
export class Tagline {
export interface Tagline {
id: number;
local_site_id: number;
content: string;
published: string;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
updated: Option<string>;
updated?: string;
}

View file

@ -1,7 +1,3 @@
import { Option } from "@sniptt/monads";
import { Expose, Transform, Type } from "class-transformer";
import "reflect-metadata";
import { toOption, toUndefined } from "../utils";
import {
CommentAggregates,
CommunityAggregates,
@ -43,73 +39,49 @@ import {
Tagline,
} from "./source";
export class PersonViewSafe {
@Type(() => PersonSafe)
export interface PersonViewSafe {
person: PersonSafe;
counts: PersonAggregates;
}
export class PersonMentionView {
@Type(() => PersonMention)
export interface PersonMentionView {
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;
subscribed: SubscribedType;
saved: boolean;
creator_blocked: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
my_vote: Option<number>;
my_vote?: number;
}
export class LocalUserSettingsView {
@Type(() => LocalUserSettings)
export interface LocalUserSettingsView {
local_user: LocalUserSettings;
@Type(() => PersonSafe)
person: PersonSafe;
counts: PersonAggregates;
}
export class SiteView {
@Type(() => Site)
export interface SiteView {
site: Site;
@Type(() => LocalSite)
local_site: LocalSite;
@Type(() => LocalSiteRateLimit)
local_site_rate_limit: LocalSiteRateLimit;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
taglines: Option<Tagline[]>;
taglines?: Tagline[];
counts: SiteAggregates;
}
export class PrivateMessageView {
@Type(() => PrivateMessage)
export interface PrivateMessageView {
private_message: PrivateMessage;
@Type(() => PersonSafe)
creator: PersonSafe;
@Type(() => PersonSafe)
recipient: PersonSafe;
}
export class PostView {
@Type(() => Post)
export interface PostView {
post: Post;
@Type(() => PersonSafe)
creator: PersonSafe;
@Type(() => CommunitySafe)
community: CommunitySafe;
creator_banned_from_community: boolean;
counts: PostAggregates;
@ -117,344 +89,191 @@ export class PostView {
saved: boolean;
read: boolean;
creator_blocked: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
my_vote: Option<number>;
my_vote?: number;
unread_comments: number;
}
export class PostReportView {
@Type(() => PostReport)
export interface PostReportView {
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 }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
my_vote: Option<number>;
my_vote?: number;
counts: PostAggregates;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
resolver: Option<PersonSafe>;
resolver?: PersonSafe;
}
export class CommentView {
@Type(() => Comment)
export interface CommentView {
comment: Comment;
@Type(() => PersonSafe)
creator: PersonSafe;
@Type(() => Post)
post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe;
counts: CommentAggregates;
creator_banned_from_community: boolean;
subscribed: SubscribedType;
saved: boolean;
creator_blocked: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
my_vote: Option<number>;
my_vote?: number;
}
export class CommentReplyView {
@Type(() => CommentReply)
export interface CommentReplyView {
comment_reply: CommentReply;
@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;
subscribed: SubscribedType;
saved: boolean;
creator_blocked: boolean;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
my_vote: Option<number>;
my_vote?: number;
}
export class CommentReportView {
@Type(() => CommentReport)
export interface CommentReportView {
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;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
my_vote: Option<number>;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
resolver: Option<PersonSafe>;
my_vote?: number;
resolver?: PersonSafe;
}
export class ModAddCommunityView {
@Type(() => ModAddCommunity)
export interface ModAddCommunityView {
mod_add_community: ModAddCommunity;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => CommunitySafe)
moderator?: PersonSafe;
community: CommunitySafe;
@Type(() => PersonSafe)
modded_person: PersonSafe;
}
export class ModTransferCommunityView {
@Type(() => ModTransferCommunity)
export interface ModTransferCommunityView {
mod_transfer_community: ModTransferCommunity;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => CommunitySafe)
moderator?: PersonSafe;
community: CommunitySafe;
@Type(() => PersonSafe)
modded_person: PersonSafe;
}
export class ModAddView {
@Type(() => ModAdd)
export interface ModAddView {
mod_add: ModAdd;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => PersonSafe)
moderator?: PersonSafe;
modded_person: PersonSafe;
}
export class ModBanFromCommunityView {
@Type(() => ModBanFromCommunity)
export interface ModBanFromCommunityView {
mod_ban_from_community: ModBanFromCommunity;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => CommunitySafe)
moderator?: PersonSafe;
community: CommunitySafe;
@Type(() => PersonSafe)
banned_person: PersonSafe;
}
export class ModBanView {
@Type(() => ModBan)
export interface ModBanView {
mod_ban: ModBan;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => PersonSafe)
moderator?: PersonSafe;
banned_person: PersonSafe;
}
export class ModLockPostView {
@Type(() => ModLockPost)
export interface ModLockPostView {
mod_lock_post: ModLockPost;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => Post)
moderator?: PersonSafe;
post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe;
}
export class ModRemoveCommentView {
@Type(() => ModRemoveComment)
export interface ModRemoveCommentView {
mod_remove_comment: ModRemoveComment;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => Comment)
moderator?: PersonSafe;
comment: Comment;
@Type(() => PersonSafe)
commenter: PersonSafe;
@Type(() => Post)
post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe;
}
export class ModRemoveCommunityView {
@Type(() => ModRemoveCommunity)
export interface ModRemoveCommunityView {
mod_remove_community: ModRemoveCommunity;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => CommunitySafe)
moderator?: PersonSafe;
community: CommunitySafe;
}
export class ModRemovePostView {
@Type(() => ModRemovePost)
export interface ModRemovePostView {
mod_remove_post: ModRemovePost;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => Post)
moderator?: PersonSafe;
post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe;
}
export class ModFeaturePostView {
@Type(() => ModFeaturePost)
export interface ModFeaturePostView {
mod_feature_post: ModFeaturePost;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
moderator: Option<PersonSafe>;
@Type(() => Post)
moderator?: PersonSafe;
post: Post;
@Type(() => CommunitySafe)
community: CommunitySafe;
}
export class AdminPurgeCommunityView {
@Type(() => AdminPurgeCommunity)
export interface AdminPurgeCommunityView {
admin_purge_community: AdminPurgeCommunity;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
admin: Option<PersonSafe>;
admin?: PersonSafe;
}
export class AdminPurgePersonView {
@Type(() => AdminPurgePerson)
export interface AdminPurgePersonView {
admin_purge_person: AdminPurgePerson;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
admin: Option<PersonSafe>;
admin?: PersonSafe;
}
export class AdminPurgePostView {
@Type(() => AdminPurgePost)
export interface AdminPurgePostView {
admin_purge_post: AdminPurgePost;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
admin: Option<PersonSafe>;
@Type(() => CommunitySafe)
admin?: PersonSafe;
community: CommunitySafe;
}
export class AdminPurgeCommentView {
@Type(() => AdminPurgeComment)
export interface AdminPurgeCommentView {
admin_purge_comment: AdminPurgeComment;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
admin: Option<PersonSafe>;
@Type(() => Post)
admin?: PersonSafe;
post: Post;
}
export class CommunityFollowerView {
@Type(() => CommunitySafe)
export interface CommunityFollowerView {
community: CommunitySafe;
@Type(() => PersonSafe)
follower: PersonSafe;
}
export class CommunityBlockView {
@Type(() => PersonSafe)
export interface CommunityBlockView {
person: PersonSafe;
@Type(() => CommunitySafe)
community: CommunitySafe;
}
export class CommunityModeratorView {
@Type(() => CommunitySafe)
export interface CommunityModeratorView {
community: CommunitySafe;
@Type(() => PersonSafe)
moderator: PersonSafe;
}
export class CommunityPersonBanView {
@Type(() => CommunitySafe)
export interface CommunityPersonBanView {
community: CommunitySafe;
@Type(() => PersonSafe)
person: PersonSafe;
}
export class PersonBlockView {
@Type(() => PersonSafe)
export interface PersonBlockView {
person: PersonSafe;
@Type(() => PersonSafe)
target: PersonSafe;
}
export class CommunityView {
@Type(() => CommunitySafe)
export interface CommunityView {
community: CommunitySafe;
subscribed: SubscribedType;
blocked: boolean;
counts: CommunityAggregates;
}
export class RegistrationApplicationView {
@Type(() => RegistrationApplication)
export interface RegistrationApplicationView {
registration_application: RegistrationApplication;
@Type(() => LocalUserSettings)
creator_local_user: LocalUserSettings;
@Type(() => PersonSafe)
creator: PersonSafe;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
admin: Option<PersonSafe>;
admin?: PersonSafe;
}
export interface CommentNode {
@ -463,18 +282,10 @@ export interface CommentNode {
depth: number;
}
export class PrivateMessageReportView {
@Type(() => PrivateMessageReport)
export interface PrivateMessageReportView {
private_message_report: PrivateMessageReport;
@Type(() => PrivateMessage)
private_message: PrivateMessage;
@Type(() => PersonSafe)
private_message_creator: PersonSafe;
@Type(() => PersonSafe)
creator: PersonSafe;
@Transform(({ value }) => toOption(value), { toClassOnly: true })
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
@Expose()
@Type(() => PersonSafe)
resolver: Option<PersonSafe>;
resolver?: PersonSafe;
}

View file

@ -1,15 +0,0 @@
import { Option, Some } from "@sniptt/monads";
/**
* Converts an option to an undefined. Necessary for API requests.
*/
export function toUndefined<T>(opt: Option<T>) {
return opt.isSome() ? opt.unwrap() : undefined;
}
/**
* Converts a null value to an option.
*/
export function toOption<T>(val: T): Option<T> {
return Some(val || undefined);
}

View file

@ -1,4 +1,3 @@
import { ClassConstructor, deserialize, serialize } from "class-transformer";
import {
CreateComment,
CreateCommentLike,
@ -686,7 +685,7 @@ export class LemmyWebsocket {
}
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
let send = serialize({ op: UserOperation[op], data });
let send = JSON.stringify({ op: UserOperation[op], data });
return send;
}
@ -698,10 +697,8 @@ export function wsUserOp(msg: any): UserOperation {
/**
* Converts a websocket string response to a usable result
*/
export function wsJsonToRes<ResponseType>(
msg: any,
responseClass: ClassConstructor<ResponseType>
): ResponseType {
// TODO is this still necessary?
export function wsJsonToRes<ResponseType>(msg: any): ResponseType {
// Have to deserialize the response again into the correct class
return deserialize(responseClass, serialize(msg.data));
return msg.data as ResponseType;
}

View file

@ -8,6 +8,7 @@
"outDir": "./dist",
"target": "ES5",
"experimentalDecorators": true,
"strictNullChecks": true,
"moduleResolution": "Node"
},
"include": [

View file

@ -285,11 +285,6 @@
"@nodelib/fs.scandir" "2.1.5"
fastq "^1.6.0"
"@sniptt/monads@^0.5.10":
version "0.5.10"
resolved "https://registry.yarnpkg.com/@sniptt/monads/-/monads-0.5.10.tgz#a80cd00738bbd682d36d36dd36bdc0bddc96eb76"
integrity sha512-+agDOv9DpDV+9e2zN/Vmdk+XaqGx5Sykl0fqhqgiJ90r18nsBkxe44DmZ2sA1HYK+MSsBeZBiAr6pq4w+5uhfw==
"@types/glob@^7.1.1":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
@ -581,11 +576,6 @@ chalk@^4.0.0:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
class-transformer@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/class-transformer/-/class-transformer-0.5.1.tgz#24147d5dffd2a6cea930a3250a677addf96ab336"
integrity sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==
clean-stack@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
@ -1720,11 +1710,6 @@ queue-microtask@^1.2.2:
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
reflect-metadata@^0.1.13:
version "0.1.13"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==
regexpp@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"