mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-11-22 20:31:12 +00:00
Add option types (#67)
* Testing some option types over the API. * v0.17.0-rc.6 * Removing a few to better test. * v0.17.0-rc.7 * Simpler again. * v0.17.0-rc.8 * Trying swan.io boxed * v0.17.0-rc.13 * Trying option-t * v0.17.0-rc.14 * Adding rust-style Options using @sniptt/monads - Also added serialization with class-transformer * v0.17.0-rc.15 * Trying to fix encodeGetParams. * v0.17.0-rc.16 * Trying to fix encodeGetParams 2. * v0.17.0-rc.17 * Using init constructors. * v0.17.0-rc.18 * v0.17.0-rc.19 * Add more type info. * v0.17.0-rc.20 * Adding reflect-metadata * v0.17.0-rc.21 * Adding type to siteview.site * v0.17.0-rc.22 * Adding rest of nested types. * v0.17.0-rc.23 * Adding toOption function. * v0.17.0-rc.24 * Trying to fix send. * v0.17.0-rc.25 * Try to stringify jsonres. * v0.17.0-rc.26 * Try to stringify jsonres 2. * v0.17.0-rc.27 * Adding toOption function. * v0.17.0-rc.28 * Forgot to type a communityview. * v0.17.0-rc.29 * Forgot to type a registrationapplicationview. * v0.17.0-rc.30
This commit is contained in:
parent
54a61241ce
commit
36103fbca0
15 changed files with 2146 additions and 651 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "lemmy-js-client",
|
"name": "lemmy-js-client",
|
||||||
"description": "A javascript / typescript client for Lemmy",
|
"description": "A javascript / typescript client for Lemmy",
|
||||||
"version": "0.16.4-rc.3",
|
"version": "0.17.0-rc.30",
|
||||||
"author": "Dessalines <tyhou13@gmx.com>",
|
"author": "Dessalines <tyhou13@gmx.com>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
@ -16,10 +16,12 @@
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@sniptt/monads": "^0.5.10",
|
||||||
"@types/node": "^17.0.33",
|
"@types/node": "^17.0.33",
|
||||||
"@types/node-fetch": "^3.0.3",
|
"@types/node-fetch": "^3.0.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
||||||
"@typescript-eslint/parser": "^5.23.0",
|
"@typescript-eslint/parser": "^5.23.0",
|
||||||
|
"class-transformer": "^0.5.1",
|
||||||
"eslint": "^8.15.0",
|
"eslint": "^8.15.0",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.1",
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
"prettier-plugin-import-sort": "^0.0.7",
|
"prettier-plugin-import-sort": "^0.0.7",
|
||||||
"prettier-plugin-organize-imports": "^2.3.4",
|
"prettier-plugin-organize-imports": "^2.3.4",
|
||||||
"prettier-plugin-packagejson": "^2.2.18",
|
"prettier-plugin-packagejson": "^2.2.18",
|
||||||
|
"reflect-metadata": "^0.1.13",
|
||||||
"sortpack": "^2.2.0",
|
"sortpack": "^2.2.0",
|
||||||
"typedoc": "^0.21.6",
|
"typedoc": "^0.21.6",
|
||||||
"typedoc-plugin-sourcefile-url": "^1.0.6",
|
"typedoc-plugin-sourcefile-url": "^1.0.6",
|
||||||
|
|
669
src/http.ts
669
src/http.ts
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,4 @@
|
||||||
export * from "./http";
|
export * from "./http";
|
||||||
export * from "./interfaces";
|
export * from "./interfaces";
|
||||||
|
export * from "./utils";
|
||||||
export * from "./websocket";
|
export * from "./websocket";
|
||||||
|
|
|
@ -1,74 +1,122 @@
|
||||||
|
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 { ListingType, SortType } from "../others";
|
||||||
import { CommentReportView, CommentView } from "../views";
|
import { CommentReportView, CommentView } from "../views";
|
||||||
|
|
||||||
export interface CreateComment {
|
export class CreateComment {
|
||||||
content: string;
|
content: string;
|
||||||
parent_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
parent_id: Option<number>;
|
||||||
post_id: number;
|
post_id: number;
|
||||||
/**
|
/**
|
||||||
* An optional front end ID, to tell which is comment is coming back.
|
* An optional front end ID, to tell which is comment is coming back.
|
||||||
*/
|
*/
|
||||||
form_id?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
form_id: Option<string>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: CreateComment) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditComment {
|
export class EditComment {
|
||||||
content: string;
|
content: string;
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
/**
|
/**
|
||||||
* An optional front end ID, to tell which is comment is coming back.
|
* An optional front end ID, to tell which is comment is coming back.
|
||||||
*/
|
*/
|
||||||
form_id?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
form_id: Option<string>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: EditComment) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only the creator can delete the comment.
|
* Only the creator can delete the comment.
|
||||||
*/
|
*/
|
||||||
export interface DeleteComment {
|
export class DeleteComment {
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: DeleteComment) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only a mod or admin can remove the comment.
|
* Only a mod or admin can remove the comment.
|
||||||
*/
|
*/
|
||||||
export interface RemoveComment {
|
export class RemoveComment {
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
removed: boolean;
|
removed: boolean;
|
||||||
reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: RemoveComment) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only the recipient can do this.
|
* Only the recipient can do this.
|
||||||
*/
|
*/
|
||||||
export interface MarkCommentAsRead {
|
export class MarkCommentAsRead {
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
read: boolean;
|
read: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: MarkCommentAsRead) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SaveComment {
|
export class SaveComment {
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
save: boolean;
|
save: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: SaveComment) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommentResponse {
|
export class CommentResponse {
|
||||||
|
@Type(() => CommentView)
|
||||||
comment_view: CommentView;
|
comment_view: CommentView;
|
||||||
recipient_ids: number[];
|
recipient_ids: number[];
|
||||||
/**
|
/**
|
||||||
* An optional front end ID, to tell which is comment is coming back.
|
* An optional front end ID, to tell which is comment is coming back.
|
||||||
*/
|
*/
|
||||||
form_id?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
form_id: Option<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateCommentLike {
|
export class CreateCommentLike {
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
score: number;
|
score: number;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: CreateCommentLike) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -77,55 +125,110 @@ export interface CreateCommentLike {
|
||||||
* You can use either `community_id` or `community_name` as an id.
|
* 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` .
|
* To get posts for a federated community by name, use `name@instance.tld` .
|
||||||
*/
|
*/
|
||||||
export interface GetComments {
|
export class GetComments {
|
||||||
type_?: ListingType;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
sort?: SortType;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
page?: number;
|
@Expose()
|
||||||
limit?: number;
|
type_: Option<ListingType>;
|
||||||
community_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
community_name?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
saved_only?: boolean;
|
@Expose()
|
||||||
auth?: string;
|
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()
|
||||||
|
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: GetComments) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetCommentsResponse {
|
export class GetCommentsResponse {
|
||||||
|
@Type(() => CommentView)
|
||||||
comments: CommentView[];
|
comments: CommentView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateCommentReport {
|
export class CreateCommentReport {
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
reason: string;
|
reason: string;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: CreateCommentReport) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommentReportResponse {
|
export class CommentReportResponse {
|
||||||
|
@Type(() => CommentReportView)
|
||||||
comment_report_view: CommentReportView;
|
comment_report_view: CommentReportView;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResolveCommentReport {
|
export class ResolveCommentReport {
|
||||||
report_id: number;
|
report_id: number;
|
||||||
/**
|
/**
|
||||||
* Either resolve or unresolve a report.
|
* Either resolve or unresolve a report.
|
||||||
*/
|
*/
|
||||||
resolved: boolean;
|
resolved: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: ResolveCommentReport) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListCommentReports {
|
export class ListCommentReports {
|
||||||
page?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
limit?: number;
|
@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>;
|
||||||
/**
|
/**
|
||||||
* if no community is given, it returns reports for all communities moderated by the auth user.
|
* if no community is given, it returns reports for all communities moderated by the auth user.
|
||||||
*/
|
*/
|
||||||
community_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
community_id: Option<number>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only shows the unresolved reports.
|
* Only shows the unresolved reports.
|
||||||
*/
|
*/
|
||||||
unresolved_only?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
unresolved_only: Option<boolean>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: ListCommentReports) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListCommentReportsResponse {
|
export class ListCommentReportsResponse {
|
||||||
|
@Type(() => CommentReportView)
|
||||||
comment_reports: CommentReportView[];
|
comment_reports: CommentReportView[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
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 { ListingType, SortType } from "../others";
|
||||||
import { Site } from "../source";
|
import { Site } from "../source";
|
||||||
import {
|
import {
|
||||||
|
@ -11,47 +15,106 @@ import {
|
||||||
*
|
*
|
||||||
* To get a federated community by name, use `name@instance.tld` .
|
* To get a federated community by name, use `name@instance.tld` .
|
||||||
*/
|
*/
|
||||||
export interface GetCommunity {
|
export class GetCommunity {
|
||||||
id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
name?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
auth?: string;
|
@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 GetCommunityResponse {
|
export class GetCommunityResponse {
|
||||||
|
@Type(() => CommunityView)
|
||||||
community_view: CommunityView;
|
community_view: CommunityView;
|
||||||
site?: Site;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
@Type(() => Site)
|
||||||
|
site: Option<Site>;
|
||||||
|
@Type(() => CommunityModeratorView)
|
||||||
moderators: CommunityModeratorView[];
|
moderators: CommunityModeratorView[];
|
||||||
online: number;
|
online: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateCommunity {
|
export class CreateCommunity {
|
||||||
name: string;
|
name: string;
|
||||||
title: string;
|
title: string;
|
||||||
description?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
icon?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
banner?: string;
|
@Expose()
|
||||||
nsfw?: boolean;
|
description: Option<string>;
|
||||||
posting_restricted_to_mods?: 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>;
|
||||||
|
@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>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: CreateCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommunityResponse {
|
export class CommunityResponse {
|
||||||
|
@Type(() => CommunityView)
|
||||||
community_view: CommunityView;
|
community_view: CommunityView;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListCommunities {
|
export class ListCommunities {
|
||||||
type_?: ListingType;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
sort?: SortType;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
page?: number;
|
@Expose()
|
||||||
limit?: number;
|
type_: Option<ListingType>;
|
||||||
auth?: 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()
|
||||||
|
auth: Option<string>;
|
||||||
|
|
||||||
|
constructor(init: ListCommunities) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListCommunitiesResponse {
|
export class ListCommunitiesResponse {
|
||||||
|
@Type(() => CommunityView)
|
||||||
communities: CommunityView[];
|
communities: CommunityView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BanFromCommunity {
|
export class BanFromCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
person_id: number;
|
person_id: number;
|
||||||
ban: boolean;
|
ban: boolean;
|
||||||
|
@ -59,84 +122,152 @@ export interface BanFromCommunity {
|
||||||
/**
|
/**
|
||||||
* Removes/Restores their comments and posts for that community.
|
* Removes/Restores their comments and posts for that community.
|
||||||
*/
|
*/
|
||||||
remove_data?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
reason?: string;
|
@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>;
|
||||||
/**
|
/**
|
||||||
* The expire time in Unix seconds
|
* The expire time in Unix seconds
|
||||||
*/
|
*/
|
||||||
expires?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
expires: Option<number>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: BanFromCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BanFromCommunityResponse {
|
export class BanFromCommunityResponse {
|
||||||
|
@Type(() => PersonViewSafe)
|
||||||
person_view: PersonViewSafe;
|
person_view: PersonViewSafe;
|
||||||
banned: boolean;
|
banned: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddModToCommunity {
|
export class AddModToCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
person_id: number;
|
person_id: number;
|
||||||
added: boolean;
|
added: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: AddModToCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddModToCommunityResponse {
|
export class AddModToCommunityResponse {
|
||||||
|
@Type(() => CommunityModeratorView)
|
||||||
moderators: CommunityModeratorView[];
|
moderators: CommunityModeratorView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only mods can edit a community.
|
* Only mods can edit a community.
|
||||||
*/
|
*/
|
||||||
export interface EditCommunity {
|
export class EditCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
title?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
description?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
icon?: string;
|
@Expose()
|
||||||
banner?: string;
|
title: Option<string>;
|
||||||
nsfw?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
posting_restricted_to_mods?: boolean;
|
@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>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: EditCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeleteCommunity {
|
export class DeleteCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: DeleteCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only admins can remove a community.
|
* Only admins can remove a community.
|
||||||
*/
|
*/
|
||||||
export interface RemoveCommunity {
|
export class RemoveCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
removed: boolean;
|
removed: boolean;
|
||||||
reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
/**
|
/**
|
||||||
* The expire time in Unix seconds
|
* The expire time in Unix seconds
|
||||||
*/
|
*/
|
||||||
expires?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
expires: Option<number>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: RemoveCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FollowCommunity {
|
export class FollowCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
follow: boolean;
|
follow: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: FollowCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TransferCommunity {
|
export class TransferCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
person_id: number;
|
person_id: number;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: TransferCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BlockCommunity {
|
export class BlockCommunity {
|
||||||
community_id: number;
|
community_id: number;
|
||||||
block: boolean;
|
block: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: BlockCommunity) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BlockCommunityResponse {
|
export class BlockCommunityResponse {
|
||||||
|
@Type(() => CommunityView)
|
||||||
community_view: CommunityView;
|
community_view: CommunityView;
|
||||||
blocked: boolean;
|
blocked: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import { Option } from "@sniptt/monads";
|
||||||
|
import { Expose, Transform, Type } from "class-transformer";
|
||||||
|
import "reflect-metadata";
|
||||||
|
import { toOption, toUndefined } from "../../utils";
|
||||||
import { SortType } from "../others";
|
import { SortType } from "../others";
|
||||||
import {
|
import {
|
||||||
CommentView,
|
CommentView,
|
||||||
|
@ -8,9 +12,13 @@ import {
|
||||||
PrivateMessageView,
|
PrivateMessageView,
|
||||||
} from "../views";
|
} from "../views";
|
||||||
|
|
||||||
export interface Login {
|
export class Login {
|
||||||
username_or_email: string;
|
username_or_email: string;
|
||||||
password: string;
|
password: string;
|
||||||
|
|
||||||
|
constructor(init: Login) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,37 +26,60 @@ export interface Login {
|
||||||
*
|
*
|
||||||
* Only the first user to register will be able to be the admin.
|
* Only the first user to register will be able to be the admin.
|
||||||
*/
|
*/
|
||||||
export interface Register {
|
export class Register {
|
||||||
username: string;
|
username: string;
|
||||||
/**
|
/**
|
||||||
* Email is mandatory if email verification is enabled on the server
|
* Email is mandatory if email verification is enabled on the server
|
||||||
*/
|
*/
|
||||||
email?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
email: Option<string>;
|
||||||
password: string;
|
password: string;
|
||||||
password_verify: string;
|
password_verify: string;
|
||||||
show_nsfw: boolean;
|
show_nsfw: boolean;
|
||||||
/**
|
/**
|
||||||
* Captcha is only checked if these are enabled in the server.
|
* Captcha is only checked if these are enabled in the server.
|
||||||
*/
|
*/
|
||||||
captcha_uuid?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
captcha_answer?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
honeypot?: string;
|
@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>;
|
||||||
/**
|
/**
|
||||||
* An answer is mandatory if require application is enabled on the server
|
* An answer is mandatory if require application is enabled on the server
|
||||||
*/
|
*/
|
||||||
answer?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
answer: Option<string>;
|
||||||
|
|
||||||
|
constructor(init: Register) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetCaptcha {}
|
export class GetCaptcha {}
|
||||||
|
|
||||||
export interface GetCaptchaResponse {
|
export class GetCaptchaResponse {
|
||||||
/**
|
/**
|
||||||
* Will be undefined if captchas are disabled.
|
* Will be undefined if captchas are disabled.
|
||||||
*/
|
*/
|
||||||
ok?: CaptchaResponse;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
@Type(() => CaptchaResponse)
|
||||||
|
ok: Option<CaptchaResponse>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CaptchaResponse {
|
export class CaptchaResponse {
|
||||||
/**
|
/**
|
||||||
* A Base64 encoded png.
|
* A Base64 encoded png.
|
||||||
*/
|
*/
|
||||||
|
@ -57,7 +88,10 @@ export interface CaptchaResponse {
|
||||||
/**
|
/**
|
||||||
* A Base64 encoded wav file.
|
* A Base64 encoded wav file.
|
||||||
*/
|
*/
|
||||||
wav?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
wav: Option<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A UUID to match the one given on request.
|
* A UUID to match the one given on request.
|
||||||
|
@ -65,259 +99,489 @@ export interface CaptchaResponse {
|
||||||
uuid: string;
|
uuid: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SaveUserSettings {
|
export class SaveUserSettings {
|
||||||
show_nsfw?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
show_nsfw: Option<boolean>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default for this is `browser`.
|
* Default for this is `browser`.
|
||||||
*/
|
*/
|
||||||
theme?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
theme: Option<string>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [[SortType]].
|
* The [[SortType]].
|
||||||
*
|
*
|
||||||
* The Sort types from above, zero indexed as a number
|
* The Sort types from above, zero indexed as a number
|
||||||
*/
|
*/
|
||||||
default_sort_type?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
default_sort_type: Option<number>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The [[ListingType]].
|
* The [[ListingType]].
|
||||||
*
|
*
|
||||||
* Post listing types are `All, Subscribed, Community`
|
* Post listing types are `All, Subscribed, Community`
|
||||||
*/
|
*/
|
||||||
default_listing_type?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
lang?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
avatar?: string;
|
@Expose()
|
||||||
banner?: string;
|
default_listing_type: Option<number>;
|
||||||
display_name?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
email?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
bio?: string;
|
@Expose()
|
||||||
matrix_user_id?: string;
|
lang: Option<string>;
|
||||||
show_avatars?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
show_scores?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
send_notifications_to_email?: boolean;
|
@Expose()
|
||||||
bot_account?: boolean;
|
avatar: Option<string>;
|
||||||
show_bot_accounts?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
show_read_posts?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
show_new_post_notifs?: boolean;
|
@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>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: SaveUserSettings) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ChangePassword {
|
export class ChangePassword {
|
||||||
new_password: string;
|
new_password: string;
|
||||||
new_password_verify: string;
|
new_password_verify: string;
|
||||||
old_password: string;
|
old_password: string;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: ChangePassword) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
||||||
*/
|
*/
|
||||||
export interface LoginResponse {
|
export class LoginResponse {
|
||||||
/**
|
/**
|
||||||
* This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
|
* This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
|
||||||
*/
|
*/
|
||||||
jwt?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
jwt: Option<string>;
|
||||||
verify_email_sent: boolean;
|
verify_email_sent: boolean;
|
||||||
registration_created: boolean;
|
registration_created: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetPersonDetails {
|
export class GetPersonDetails {
|
||||||
person_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
person_id: Option<number>;
|
||||||
/**
|
/**
|
||||||
* To get details for a federated user, use `person@instance.tld`.
|
* To get details for a federated user, use `person@instance.tld`.
|
||||||
*/
|
*/
|
||||||
username?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
sort?: SortType;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
page?: number;
|
@Expose()
|
||||||
limit?: number;
|
username: Option<string>;
|
||||||
community_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
saved_only?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
auth?: string;
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetPersonDetailsResponse {
|
export class GetPersonDetailsResponse {
|
||||||
|
@Type(() => PersonViewSafe)
|
||||||
person_view: PersonViewSafe;
|
person_view: PersonViewSafe;
|
||||||
|
@Type(() => CommentView)
|
||||||
comments: CommentView[];
|
comments: CommentView[];
|
||||||
|
@Type(() => PostView)
|
||||||
posts: PostView[];
|
posts: PostView[];
|
||||||
|
@Type(() => CommunityModeratorView)
|
||||||
moderates: CommunityModeratorView[];
|
moderates: CommunityModeratorView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetRepliesResponse {
|
export class GetRepliesResponse {
|
||||||
|
@Type(() => CommentView)
|
||||||
replies: CommentView[];
|
replies: CommentView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetPersonMentionsResponse {
|
export class GetPersonMentionsResponse {
|
||||||
|
@Type(() => PersonMentionView)
|
||||||
mentions: PersonMentionView[];
|
mentions: PersonMentionView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MarkAllAsRead {
|
export class MarkAllAsRead {
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(auth: string) {
|
||||||
|
this.auth = auth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddAdmin {
|
export class AddAdmin {
|
||||||
person_id: number;
|
person_id: number;
|
||||||
added: boolean;
|
added: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: AddAdmin) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AddAdminResponse {
|
export class AddAdminResponse {
|
||||||
|
@Type(() => PersonViewSafe)
|
||||||
admins: PersonViewSafe[];
|
admins: PersonViewSafe[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BanPerson {
|
export class BanPerson {
|
||||||
person_id: number;
|
person_id: number;
|
||||||
ban: boolean;
|
ban: boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes/Restores their comments, posts, and communities
|
* Removes/Restores their comments, posts, and communities
|
||||||
*/
|
*/
|
||||||
remove_data?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
reason?: string;
|
@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>;
|
||||||
/**
|
/**
|
||||||
* The expire time in Unix seconds
|
* The expire time in Unix seconds
|
||||||
*/
|
*/
|
||||||
expires?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
expires: Option<number>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: BanPerson) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BanPersonResponse {
|
export class BanPersonResponse {
|
||||||
|
@Type(() => PersonViewSafe)
|
||||||
person_view: PersonViewSafe;
|
person_view: PersonViewSafe;
|
||||||
banned: boolean;
|
banned: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetReplies {
|
export class GetReplies {
|
||||||
sort?: SortType;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
page?: number;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
limit?: number;
|
@Expose()
|
||||||
unread_only?: boolean;
|
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()
|
||||||
|
unread_only: Option<boolean>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: GetReplies) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetPersonMentions {
|
export class GetPersonMentions {
|
||||||
sort?: SortType;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
page?: number;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
limit?: number;
|
@Expose()
|
||||||
unread_only?: boolean;
|
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()
|
||||||
|
unread_only: Option<boolean>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: GetPersonMentions) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MarkPersonMentionAsRead {
|
export class MarkPersonMentionAsRead {
|
||||||
person_mention_id: number;
|
person_mention_id: number;
|
||||||
read: boolean;
|
read: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: MarkPersonMentionAsRead) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonMentionResponse {
|
export class PersonMentionResponse {
|
||||||
|
@Type(() => PersonMentionView)
|
||||||
person_mention_view: PersonMentionView;
|
person_mention_view: PersonMentionView;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Permanently deletes your posts and comments
|
* Permanently deletes your posts and comments
|
||||||
*/
|
*/
|
||||||
export interface DeleteAccount {
|
export class DeleteAccount {
|
||||||
password: string;
|
password: string;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: DeleteAccount) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeleteAccountResponse {}
|
export class DeleteAccountResponse {}
|
||||||
|
|
||||||
export interface PasswordReset {
|
export class PasswordReset {
|
||||||
email: string;
|
email: string;
|
||||||
|
|
||||||
|
constructor(init: PasswordReset) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PasswordResetResponse {}
|
export class PasswordResetResponse {}
|
||||||
|
|
||||||
export interface PasswordChange {
|
export class PasswordChange {
|
||||||
token: string;
|
token: string;
|
||||||
password: string;
|
password: string;
|
||||||
password_verify: string;
|
password_verify: string;
|
||||||
|
|
||||||
|
constructor(init: PasswordChange) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreatePrivateMessage {
|
export class CreatePrivateMessage {
|
||||||
content: string;
|
content: string;
|
||||||
recipient_id: number;
|
recipient_id: number;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: CreatePrivateMessage) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditPrivateMessage {
|
export class EditPrivateMessage {
|
||||||
private_message_id: number;
|
private_message_id: number;
|
||||||
content: string;
|
content: string;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: EditPrivateMessage) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeletePrivateMessage {
|
export class DeletePrivateMessage {
|
||||||
private_message_id: number;
|
private_message_id: number;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: DeletePrivateMessage) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MarkPrivateMessageAsRead {
|
export class MarkPrivateMessageAsRead {
|
||||||
private_message_id: number;
|
private_message_id: number;
|
||||||
read: boolean;
|
read: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: MarkPrivateMessageAsRead) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetPrivateMessages {
|
export class GetPrivateMessages {
|
||||||
unread_only?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
page?: number;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
limit?: number;
|
@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>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: GetPrivateMessages) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrivateMessagesResponse {
|
export class PrivateMessagesResponse {
|
||||||
|
@Type(() => PrivateMessageView)
|
||||||
private_messages: PrivateMessageView[];
|
private_messages: PrivateMessageView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrivateMessageResponse {
|
export class PrivateMessageResponse {
|
||||||
|
@Type(() => PrivateMessageView)
|
||||||
private_message_view: PrivateMessageView;
|
private_message_view: PrivateMessageView;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetReportCount {
|
export class GetReportCount {
|
||||||
/**
|
/**
|
||||||
* If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates.
|
* If a community is supplied, returns the report count for only that community, otherwise returns the report count for all communities the user moderates.
|
||||||
*/
|
*/
|
||||||
community_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
community_id: Option<number>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: GetReportCount) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetReportCountResponse {
|
export class GetReportCountResponse {
|
||||||
community_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
community_id: Option<number>;
|
||||||
comment_reports: number;
|
comment_reports: number;
|
||||||
post_reports: number;
|
post_reports: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetUnreadCount {
|
export class GetUnreadCount {
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: GetUnreadCount) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetUnreadCountResponse {
|
export class GetUnreadCountResponse {
|
||||||
replies: number;
|
replies: number;
|
||||||
mentions: number;
|
mentions: number;
|
||||||
private_messages: number;
|
private_messages: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VerifyEmail {
|
export class VerifyEmail {
|
||||||
token: string;
|
token: string;
|
||||||
|
|
||||||
|
constructor(init: VerifyEmail) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface VerifyEmailResponse {}
|
export class VerifyEmailResponse {}
|
||||||
|
|
||||||
export interface BlockPerson {
|
export class BlockPerson {
|
||||||
person_id: number;
|
person_id: number;
|
||||||
block: boolean;
|
block: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: BlockPerson) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BlockPersonResponse {
|
export class BlockPersonResponse {
|
||||||
|
@Type(() => PersonViewSafe)
|
||||||
person_view: PersonViewSafe;
|
person_view: PersonViewSafe;
|
||||||
blocked: boolean;
|
blocked: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetBannedPersons {
|
export class GetBannedPersons {
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: GetBannedPersons) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BannedPersonsResponse {
|
export class BannedPersonsResponse {
|
||||||
|
@Type(() => PersonViewSafe)
|
||||||
banned: PersonViewSafe[];
|
banned: PersonViewSafe[];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import { Option } from "@sniptt/monads";
|
||||||
|
import { Expose, Transform, Type } from "class-transformer";
|
||||||
|
import "reflect-metadata";
|
||||||
|
import { toOption, toUndefined } from "../../utils";
|
||||||
import { ListingType, SiteMetadata, SortType } from "../others";
|
import { ListingType, SiteMetadata, SortType } from "../others";
|
||||||
import {
|
import {
|
||||||
CommentView,
|
CommentView,
|
||||||
|
@ -7,52 +11,109 @@ import {
|
||||||
PostView,
|
PostView,
|
||||||
} from "../views";
|
} from "../views";
|
||||||
|
|
||||||
export interface CreatePost {
|
export class CreatePost {
|
||||||
name: string;
|
name: string;
|
||||||
url?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
body?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
nsfw?: boolean;
|
@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>;
|
||||||
community_id: number;
|
community_id: number;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
honeypot: Option<string>;
|
||||||
auth: string;
|
auth: string;
|
||||||
honeypot?: string;
|
|
||||||
|
constructor(init: CreatePost) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PostResponse {
|
export class PostResponse {
|
||||||
|
@Type(() => PostView)
|
||||||
post_view: PostView;
|
post_view: PostView;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetPost {
|
export class GetPost {
|
||||||
id: number;
|
id: number;
|
||||||
auth?: string;
|
@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 GetPostResponse {
|
export class GetPostResponse {
|
||||||
|
@Type(() => PostView)
|
||||||
post_view: PostView;
|
post_view: PostView;
|
||||||
|
@Type(() => CommunityView)
|
||||||
community_view: CommunityView;
|
community_view: CommunityView;
|
||||||
|
@Type(() => CommentView)
|
||||||
comments: CommentView[];
|
comments: CommentView[];
|
||||||
|
@Type(() => CommunityModeratorView)
|
||||||
moderators: CommunityModeratorView[];
|
moderators: CommunityModeratorView[];
|
||||||
online: number;
|
online: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetPosts {
|
export class GetPosts {
|
||||||
type_?: ListingType;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
sort?: SortType;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
page?: number;
|
@Expose()
|
||||||
limit?: number;
|
type_: Option<ListingType>;
|
||||||
community_id?: 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()
|
||||||
|
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>;
|
||||||
/**
|
/**
|
||||||
* To get posts for a federated community by name, use `name@instance.tld` .
|
* To get posts for a federated community by name, use `name@instance.tld` .
|
||||||
*/
|
*/
|
||||||
community_name?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
saved_only?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
auth?: string;
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetPostsResponse {
|
export class GetPostsResponse {
|
||||||
|
@Type(() => PostView)
|
||||||
posts: PostView[];
|
posts: PostView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreatePostLike {
|
export class CreatePostLike {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,107 +121,185 @@ export interface CreatePostLike {
|
||||||
*/
|
*/
|
||||||
score: number;
|
score: number;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: CreatePostLike) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditPost {
|
export class EditPost {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
name?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
url?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
body?: string;
|
@Expose()
|
||||||
nsfw?: boolean;
|
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>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: EditPost) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeletePost {
|
export class DeletePost {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: DeletePost) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only admins and mods can remove a post.
|
* Only admins and mods can remove a post.
|
||||||
*/
|
*/
|
||||||
export interface RemovePost {
|
export class RemovePost {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
removed: boolean;
|
removed: boolean;
|
||||||
reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
reason: Option<string>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: RemovePost) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Marks a post as read.
|
* Marks a post as read.
|
||||||
*/
|
*/
|
||||||
export interface MarkPostAsRead {
|
export class MarkPostAsRead {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
read: boolean;
|
read: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: MarkPostAsRead) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only admins and mods can lock a post.
|
* Only admins and mods can lock a post.
|
||||||
*/
|
*/
|
||||||
export interface LockPost {
|
export class LockPost {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
locked: boolean;
|
locked: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: LockPost) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only admins and mods can sticky a post.
|
* Only admins and mods can sticky a post.
|
||||||
*/
|
*/
|
||||||
export interface StickyPost {
|
export class StickyPost {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
stickied: boolean;
|
stickied: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: StickyPost) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SavePost {
|
export class SavePost {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
save: boolean;
|
save: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: SavePost) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreatePostReport {
|
export class CreatePostReport {
|
||||||
post_id: number;
|
post_id: number;
|
||||||
reason: string;
|
reason: string;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: CreatePostReport) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PostReportResponse {
|
export class PostReportResponse {
|
||||||
|
@Type(() => PostReportView)
|
||||||
post_report_view: PostReportView;
|
post_report_view: PostReportView;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResolvePostReport {
|
export class ResolvePostReport {
|
||||||
report_id: number;
|
report_id: number;
|
||||||
/**
|
/**
|
||||||
* Either resolve or unresolve a report.
|
* Either resolve or unresolve a report.
|
||||||
*/
|
*/
|
||||||
resolved: boolean;
|
resolved: boolean;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: ResolvePostReport) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListPostReports {
|
export class ListPostReports {
|
||||||
page?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
limit?: number;
|
@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>;
|
||||||
/**
|
/**
|
||||||
* if no community is given, it returns reports for all communities moderated by the auth user.
|
* if no community is given, it returns reports for all communities moderated by the auth user.
|
||||||
*/
|
*/
|
||||||
community_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
community_id: Option<number>;
|
||||||
/**
|
/**
|
||||||
* Only shows the unresolved reports.
|
* Only shows the unresolved reports.
|
||||||
*/
|
*/
|
||||||
unresolved_only?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
unresolved_only: Option<boolean>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: ListPostReports) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListPostReportsResponse {
|
export class ListPostReportsResponse {
|
||||||
|
@Type(() => PostReportView)
|
||||||
post_reports: PostReportView[];
|
post_reports: PostReportView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetSiteMetadata {
|
export class GetSiteMetadata {
|
||||||
url: string;
|
url: string;
|
||||||
|
|
||||||
|
constructor(init: GetSiteMetadata) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetSiteMetadataResponse {
|
export class GetSiteMetadataResponse {
|
||||||
|
@Type(() => SiteMetadata)
|
||||||
metadata: SiteMetadata;
|
metadata: SiteMetadata;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import { Option } from "@sniptt/monads";
|
||||||
|
import { Expose, Transform, Type } from "class-transformer";
|
||||||
|
import "reflect-metadata";
|
||||||
|
import { toOption, toUndefined } from "../../utils";
|
||||||
import { ListingType, SearchType, SortType } from "../others";
|
import { ListingType, SearchType, SortType } from "../others";
|
||||||
import {
|
import {
|
||||||
CommentView,
|
CommentView,
|
||||||
|
@ -26,191 +30,450 @@ import {
|
||||||
/**
|
/**
|
||||||
* Search lemmy for different types of data.
|
* Search lemmy for different types of data.
|
||||||
*/
|
*/
|
||||||
export interface Search {
|
export class Search {
|
||||||
/**
|
/**
|
||||||
* The search query string.
|
* The search query string.
|
||||||
*/
|
*/
|
||||||
q: string;
|
q: string;
|
||||||
type_?: SearchType;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
community_id?: number;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
community_name?: string;
|
@Expose()
|
||||||
creator_id?: number;
|
type_: Option<SearchType>;
|
||||||
sort?: SortType;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
listing_type?: ListingType;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
page?: number;
|
@Expose()
|
||||||
limit?: number;
|
community_id: Option<number>;
|
||||||
auth?: string;
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SearchResponse {
|
export class SearchResponse {
|
||||||
/**
|
/**
|
||||||
* The [[SearchType]].
|
* The [[SearchType]].
|
||||||
*/
|
*/
|
||||||
type_: string;
|
type_: string;
|
||||||
|
@Type(() => CommentView)
|
||||||
comments: CommentView[];
|
comments: CommentView[];
|
||||||
|
@Type(() => PostView)
|
||||||
posts: PostView[];
|
posts: PostView[];
|
||||||
|
@Type(() => CommunityView)
|
||||||
communities: CommunityView[];
|
communities: CommunityView[];
|
||||||
|
@Type(() => PersonViewSafe)
|
||||||
users: PersonViewSafe[];
|
users: PersonViewSafe[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetModlog {
|
export class GetModlog {
|
||||||
mod_person_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
community_id?: number;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
page?: number;
|
@Expose()
|
||||||
limit?: number;
|
mod_person_id: Option<number>;
|
||||||
auth?: string;
|
@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>;
|
||||||
|
|
||||||
|
constructor(init: GetModlog) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetModlogResponse {
|
export class GetModlogResponse {
|
||||||
|
@Type(() => ModRemovePostView)
|
||||||
removed_posts: ModRemovePostView[];
|
removed_posts: ModRemovePostView[];
|
||||||
|
@Type(() => ModLockPostView)
|
||||||
locked_posts: ModLockPostView[];
|
locked_posts: ModLockPostView[];
|
||||||
|
@Type(() => ModStickyPostView)
|
||||||
stickied_posts: ModStickyPostView[];
|
stickied_posts: ModStickyPostView[];
|
||||||
|
@Type(() => ModRemoveCommentView)
|
||||||
removed_comments: ModRemoveCommentView[];
|
removed_comments: ModRemoveCommentView[];
|
||||||
|
@Type(() => ModRemoveCommunityView)
|
||||||
removed_communities: ModRemoveCommunityView[];
|
removed_communities: ModRemoveCommunityView[];
|
||||||
|
@Type(() => ModBanFromCommunityView)
|
||||||
banned_from_community: ModBanFromCommunityView[];
|
banned_from_community: ModBanFromCommunityView[];
|
||||||
|
@Type(() => ModBanView)
|
||||||
banned: ModBanView[];
|
banned: ModBanView[];
|
||||||
|
@Type(() => ModAddCommunityView)
|
||||||
added_to_community: ModAddCommunityView[];
|
added_to_community: ModAddCommunityView[];
|
||||||
|
@Type(() => ModTransferCommunityView)
|
||||||
transferred_to_community: ModTransferCommunityView[];
|
transferred_to_community: ModTransferCommunityView[];
|
||||||
|
@Type(() => ModAddView)
|
||||||
added: ModAddView[];
|
added: ModAddView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateSite {
|
export class CreateSite {
|
||||||
name: string;
|
name: string;
|
||||||
sidebar?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
description?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
icon?: string;
|
@Expose()
|
||||||
banner?: string;
|
sidebar: Option<string>;
|
||||||
enable_downvotes?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
open_registration?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
enable_nsfw?: boolean;
|
@Expose()
|
||||||
community_creation_admin_only?: boolean;
|
description: Option<string>;
|
||||||
require_email_verification?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
require_application?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
application_question?: string;
|
@Expose()
|
||||||
private_instance?: boolean;
|
icon: Option<string>;
|
||||||
default_theme?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
default_post_listing_type?: string;
|
@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()
|
||||||
|
open_registration: 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()
|
||||||
|
require_application: Option<boolean>;
|
||||||
|
@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>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: CreateSite) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EditSite {
|
export class EditSite {
|
||||||
name?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
sidebar?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
description?: string;
|
@Expose()
|
||||||
icon?: string;
|
name: Option<string>;
|
||||||
banner?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
enable_downvotes?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
open_registration?: boolean;
|
@Expose()
|
||||||
enable_nsfw?: boolean;
|
sidebar: Option<string>;
|
||||||
community_creation_admin_only?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
require_email_verification?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
require_application?: boolean;
|
@Expose()
|
||||||
application_question?: string;
|
description: Option<string>;
|
||||||
private_instance?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
default_theme?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
legal_information?: string;
|
@Expose()
|
||||||
default_post_listing_type?: string;
|
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()
|
||||||
|
open_registration: 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()
|
||||||
|
require_application: Option<boolean>;
|
||||||
|
@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()
|
||||||
|
legal_information: Option<string>;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
default_post_listing_type: Option<string>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: EditSite) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetSite {
|
export class GetSite {
|
||||||
auth?: string;
|
@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 SiteResponse {
|
export class SiteResponse {
|
||||||
|
@Type(() => SiteView)
|
||||||
site_view: SiteView;
|
site_view: SiteView;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetSiteResponse {
|
export class GetSiteResponse {
|
||||||
/**
|
/**
|
||||||
* Optional, because the site might not be set up yet.
|
* Optional, because the site might not be set up yet.
|
||||||
*/
|
*/
|
||||||
site_view?: SiteView;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
@Type(() => SiteView)
|
||||||
|
site_view: Option<SiteView>;
|
||||||
|
@Type(() => PersonViewSafe)
|
||||||
admins: PersonViewSafe[];
|
admins: PersonViewSafe[];
|
||||||
online: number;
|
online: number;
|
||||||
version: string;
|
version: string;
|
||||||
/**
|
/**
|
||||||
* If you're logged in, you'll get back extra user info.
|
* If you're logged in, you'll get back extra user info.
|
||||||
*/
|
*/
|
||||||
my_user?: MyUserInfo;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
federated_instances?: FederatedInstances;
|
@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>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Your user info, such as blocks, follows, etc.
|
* Your user info, such as blocks, follows, etc.
|
||||||
*/
|
*/
|
||||||
export interface MyUserInfo {
|
export class MyUserInfo {
|
||||||
|
@Type(() => LocalUserSettingsView)
|
||||||
local_user_view: LocalUserSettingsView;
|
local_user_view: LocalUserSettingsView;
|
||||||
|
@Type(() => CommunityFollowerView)
|
||||||
follows: CommunityFollowerView[];
|
follows: CommunityFollowerView[];
|
||||||
|
@Type(() => CommunityModeratorView)
|
||||||
moderates: CommunityModeratorView[];
|
moderates: CommunityModeratorView[];
|
||||||
|
@Type(() => CommunityBlockView)
|
||||||
community_blocks: CommunityBlockView[];
|
community_blocks: CommunityBlockView[];
|
||||||
|
@Type(() => PersonBlockView)
|
||||||
person_blocks: PersonBlockView[];
|
person_blocks: PersonBlockView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LeaveAdmin {
|
export class LeaveAdmin {
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: LeaveAdmin) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetSiteConfig {
|
export class GetSiteConfig {
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: GetSiteConfig) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetSiteConfigResponse {
|
export class GetSiteConfigResponse {
|
||||||
config_hjson: string;
|
config_hjson: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SaveSiteConfig {
|
export class SaveSiteConfig {
|
||||||
config_hjson: string;
|
config_hjson: string;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: SaveSiteConfig) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FederatedInstances {
|
export class FederatedInstances {
|
||||||
linked: string[];
|
linked: string[];
|
||||||
allowed?: string[];
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
blocked?: string[];
|
@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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResolveObject {
|
export class ResolveObject {
|
||||||
q: string;
|
q: string;
|
||||||
auth?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
auth: Option<string>;
|
||||||
|
|
||||||
|
constructor(init: ResolveObject) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResolveObjectResponse {
|
export class ResolveObjectResponse {
|
||||||
comment?: CommentView;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
post?: PostView;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
community?: CommunityView;
|
@Expose()
|
||||||
person?: PersonViewSafe;
|
@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 ListRegistrationApplications {
|
export class ListRegistrationApplications {
|
||||||
/**
|
/**
|
||||||
* Only shows the unread applications (IE those without an admin actor)
|
* Only shows the unread applications (IE those without an admin actor)
|
||||||
*/
|
*/
|
||||||
unread_only?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
page?: number;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
limit?: number;
|
@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>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: ListRegistrationApplications) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListRegistrationApplicationsResponse {
|
export class ListRegistrationApplicationsResponse {
|
||||||
|
@Type(() => RegistrationApplicationView)
|
||||||
registration_applications: RegistrationApplicationView[];
|
registration_applications: RegistrationApplicationView[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ApproveRegistrationApplication {
|
export class ApproveRegistrationApplication {
|
||||||
id: number;
|
id: number;
|
||||||
approve: boolean;
|
approve: boolean;
|
||||||
deny_reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
deny_reason: Option<string>;
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: ApproveRegistrationApplication) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegistrationApplicationResponse {
|
export class RegistrationApplicationResponse {
|
||||||
|
@Type(() => RegistrationApplicationView)
|
||||||
registration_application: RegistrationApplicationView;
|
registration_application: RegistrationApplicationView;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetUnreadRegistrationApplicationCount {
|
export class GetUnreadRegistrationApplicationCount {
|
||||||
auth: string;
|
auth: string;
|
||||||
|
|
||||||
|
constructor(init: GetUnreadRegistrationApplicationCount) {
|
||||||
|
Object.assign(this, init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetUnreadRegistrationApplicationCountResponse {
|
export class GetUnreadRegistrationApplicationCountResponse {
|
||||||
registration_applications: number;
|
registration_applications: number;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import { Option } from "@sniptt/monads";
|
||||||
|
import { Expose, Transform } from "class-transformer";
|
||||||
|
import { toOption, toUndefined } from "../utils";
|
||||||
export const VERSION = "v3";
|
export const VERSION = "v3";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -148,48 +151,28 @@ export enum SearchType {
|
||||||
Url = "Url",
|
Url = "Url",
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A websocket response. Includes the return type.
|
|
||||||
* Can be used like:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* if (op == UserOperation.Search) {
|
|
||||||
* let data = wsJsonToRes<SearchResponse>(msg).data;
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export interface WebSocketResponse<ResponseType> {
|
|
||||||
op: UserOperation;
|
|
||||||
/**
|
|
||||||
* This contains the data for a websocket response.
|
|
||||||
*
|
|
||||||
* The correct response type if given is in [[LemmyHttp]].
|
|
||||||
*/
|
|
||||||
data: ResponseType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A websocket JSON response that includes the errors.
|
|
||||||
*/
|
|
||||||
export interface WebSocketJsonResponse<ResponseType> {
|
|
||||||
op?: string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This contains the data for a websocket response.
|
|
||||||
*
|
|
||||||
* The correct response type if given is in [[LemmyHttp]].
|
|
||||||
*/
|
|
||||||
data?: ResponseType;
|
|
||||||
error?: string;
|
|
||||||
reconnect?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A holder for a site's metadata ( such as opengraph tags ), used for post links.
|
* A holder for a site's metadata ( such as opengraph tags ), used for post links.
|
||||||
*/
|
*/
|
||||||
export interface SiteMetadata {
|
export class SiteMetadata {
|
||||||
title?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
description?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
image?: string;
|
@Expose()
|
||||||
html?: string;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
export interface LocalUserSettings {
|
import { Option } from "@sniptt/monads";
|
||||||
|
import { Expose, Transform } from "class-transformer";
|
||||||
|
import { toOption, toUndefined } from "../utils";
|
||||||
|
|
||||||
|
export class LocalUserSettings {
|
||||||
id: number;
|
id: number;
|
||||||
person_id: number;
|
person_id: number;
|
||||||
email?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
email: Option<string>;
|
||||||
show_nsfw: boolean;
|
show_nsfw: boolean;
|
||||||
theme: string;
|
theme: string;
|
||||||
default_sort_type: number;
|
default_sort_type: number;
|
||||||
|
@ -17,43 +24,82 @@ export interface LocalUserSettings {
|
||||||
accepted_application: boolean;
|
accepted_application: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonSafe {
|
export class PersonSafe {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
display_name?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
avatar?: string;
|
@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>;
|
||||||
banned: boolean;
|
banned: boolean;
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
actor_id: string;
|
actor_id: string;
|
||||||
bio?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
bio: Option<string>;
|
||||||
local: boolean;
|
local: boolean;
|
||||||
banner?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
banner: Option<string>;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
inbox_url: string;
|
inbox_url: string;
|
||||||
shared_inbox_url: string;
|
shared_inbox_url: string;
|
||||||
matrix_user_id?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
matrix_user_id: Option<string>;
|
||||||
admin: boolean;
|
admin: boolean;
|
||||||
bot_account: boolean;
|
bot_account: boolean;
|
||||||
ban_expires?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
ban_expires: Option<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Site {
|
export class Site {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
sidebar?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
sidebar: Option<string>;
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
enable_downvotes: boolean;
|
enable_downvotes: boolean;
|
||||||
open_registration: boolean;
|
open_registration: boolean;
|
||||||
enable_nsfw: boolean;
|
enable_nsfw: boolean;
|
||||||
icon?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
banner?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
description?: string;
|
@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>;
|
||||||
community_creation_admin_only: boolean;
|
community_creation_admin_only: boolean;
|
||||||
require_email_verification: boolean;
|
require_email_verification: boolean;
|
||||||
require_application: boolean;
|
require_application: boolean;
|
||||||
application_question?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
application_question: Option<string>;
|
||||||
private_instance: boolean;
|
private_instance: boolean;
|
||||||
default_theme: string;
|
default_theme: string;
|
||||||
default_post_listing_type: string;
|
default_post_listing_type: string;
|
||||||
|
@ -61,10 +107,13 @@ export interface Site {
|
||||||
last_refreshed_at: string;
|
last_refreshed_at: string;
|
||||||
inbox_url: string;
|
inbox_url: string;
|
||||||
public_key: string;
|
public_key: string;
|
||||||
legal_information?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
legal_information: Option<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrivateMessage {
|
export class PrivateMessage {
|
||||||
id: number;
|
id: number;
|
||||||
creator_id: number;
|
creator_id: number;
|
||||||
recipient_id: number;
|
recipient_id: number;
|
||||||
|
@ -72,190 +121,304 @@ export interface PrivateMessage {
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
read: boolean;
|
read: boolean;
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
ap_id: string;
|
ap_id: string;
|
||||||
local: boolean;
|
local: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PostReport {
|
export class PostReport {
|
||||||
id: number;
|
id: number;
|
||||||
creator_id: number;
|
creator_id: number;
|
||||||
post_id: number;
|
post_id: number;
|
||||||
original_post_name: string;
|
original_post_name: string;
|
||||||
original_post_url?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
original_post_body?: string;
|
@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>;
|
||||||
reason: string;
|
reason: string;
|
||||||
resolved: boolean;
|
resolved: boolean;
|
||||||
resolver_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
resolver_id: Option<number>;
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Post {
|
export class Post {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
url?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
body?: string;
|
@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>;
|
||||||
creator_id: number;
|
creator_id: number;
|
||||||
community_id: number;
|
community_id: number;
|
||||||
removed: boolean;
|
removed: boolean;
|
||||||
locked: boolean;
|
locked: boolean;
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
nsfw: boolean;
|
nsfw: boolean;
|
||||||
stickied: boolean;
|
stickied: boolean;
|
||||||
embed_title?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
embed_description?: string;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
embed_html?: string;
|
@Expose()
|
||||||
thumbnail_url?: string;
|
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_html: Option<string>;
|
||||||
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
thumbnail_url: Option<string>;
|
||||||
ap_id: string;
|
ap_id: string;
|
||||||
local: boolean;
|
local: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PasswordResetRequest {
|
export class PasswordResetRequest {
|
||||||
id: number;
|
id: number;
|
||||||
local_user_id: number;
|
local_user_id: number;
|
||||||
token_encrypted: string;
|
token_encrypted: string;
|
||||||
published: string;
|
published: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModRemovePost {
|
export class ModRemovePost {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
post_id: number;
|
post_id: number;
|
||||||
reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
removed?: boolean;
|
@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>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModLockPost {
|
export class ModLockPost {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
post_id: number;
|
post_id: number;
|
||||||
locked?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
locked: Option<boolean>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModStickyPost {
|
export class ModStickyPost {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
post_id: number;
|
post_id: number;
|
||||||
stickied?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
stickied: Option<boolean>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModRemoveComment {
|
export class ModRemoveComment {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
removed?: boolean;
|
@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>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModRemoveCommunity {
|
export class ModRemoveCommunity {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
community_id: number;
|
community_id: number;
|
||||||
reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
removed?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
expires?: string;
|
@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>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModBanFromCommunity {
|
export class ModBanFromCommunity {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
other_person_id: number;
|
other_person_id: number;
|
||||||
community_id: number;
|
community_id: number;
|
||||||
reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
banned?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
expires?: string;
|
@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>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModBan {
|
export class ModBan {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
other_person_id: number;
|
other_person_id: number;
|
||||||
reason?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
banned?: boolean;
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
expires?: string;
|
@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>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModAddCommunity {
|
export class ModAddCommunity {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
other_person_id: number;
|
other_person_id: number;
|
||||||
community_id: number;
|
community_id: number;
|
||||||
removed?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
removed: Option<boolean>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModTransferCommunity {
|
export class ModTransferCommunity {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
other_person_id: number;
|
other_person_id: number;
|
||||||
community_id: number;
|
community_id: number;
|
||||||
removed?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
removed: Option<boolean>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModAdd {
|
export class ModAdd {
|
||||||
id: number;
|
id: number;
|
||||||
mod_person_id: number;
|
mod_person_id: number;
|
||||||
other_person_id: number;
|
other_person_id: number;
|
||||||
removed?: boolean;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
removed: Option<boolean>;
|
||||||
when_: string;
|
when_: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommunitySafe {
|
export class CommunitySafe {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
title: string;
|
title: string;
|
||||||
description?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
description: Option<string>;
|
||||||
removed: boolean;
|
removed: boolean;
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
nsfw: boolean;
|
nsfw: boolean;
|
||||||
actor_id: string;
|
actor_id: string;
|
||||||
local: boolean;
|
local: boolean;
|
||||||
icon?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
banner?: string;
|
@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>;
|
||||||
posting_restricted_to_mods: boolean;
|
posting_restricted_to_mods: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommentReport {
|
export class CommentReport {
|
||||||
id: number;
|
id: number;
|
||||||
creator_id: number;
|
creator_id: number;
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
original_comment_text: string;
|
original_comment_text: string;
|
||||||
reason: string;
|
reason: string;
|
||||||
resolved: boolean;
|
resolved: boolean;
|
||||||
resolver_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
resolver_id: Option<number>;
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Comment {
|
export class Comment {
|
||||||
id: number;
|
id: number;
|
||||||
creator_id: number;
|
creator_id: number;
|
||||||
post_id: number;
|
post_id: number;
|
||||||
parent_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
parent_id: Option<number>;
|
||||||
content: string;
|
content: string;
|
||||||
removed: boolean;
|
removed: boolean;
|
||||||
read: boolean; // Whether the recipient has read the comment or not
|
read: boolean; // Whether the recipient has read the comment or not
|
||||||
published: string;
|
published: string;
|
||||||
updated?: string;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
updated: Option<string>;
|
||||||
deleted: boolean;
|
deleted: boolean;
|
||||||
ap_id: string;
|
ap_id: string;
|
||||||
local: boolean;
|
local: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonMention {
|
export class PersonMention {
|
||||||
id: number;
|
id: number;
|
||||||
recipient_id: number;
|
recipient_id: number;
|
||||||
comment_id: number;
|
comment_id: number;
|
||||||
|
@ -263,11 +426,17 @@ export interface PersonMention {
|
||||||
published: string;
|
published: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegistrationApplication {
|
export class RegistrationApplication {
|
||||||
id: number;
|
id: number;
|
||||||
local_user_id: number;
|
local_user_id: number;
|
||||||
answer: string;
|
answer: string;
|
||||||
admin_id?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
deny_reason?: string;
|
@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>;
|
||||||
published: string;
|
published: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import { Option } from "@sniptt/monads";
|
||||||
|
import { Expose, Transform, Type } from "class-transformer";
|
||||||
|
import "reflect-metadata";
|
||||||
|
import { toOption, toUndefined } from "../utils";
|
||||||
import {
|
import {
|
||||||
CommentAggregates,
|
CommentAggregates,
|
||||||
CommunityAggregates,
|
CommunityAggregates,
|
||||||
|
@ -29,46 +33,65 @@ import {
|
||||||
Site,
|
Site,
|
||||||
} from "./source";
|
} from "./source";
|
||||||
|
|
||||||
export interface PersonViewSafe {
|
export class PersonViewSafe {
|
||||||
|
@Type(() => PersonSafe)
|
||||||
person: PersonSafe;
|
person: PersonSafe;
|
||||||
counts: PersonAggregates;
|
counts: PersonAggregates;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonMentionView {
|
export class PersonMentionView {
|
||||||
|
@Type(() => PersonMention)
|
||||||
person_mention: PersonMention;
|
person_mention: PersonMention;
|
||||||
|
@Type(() => Comment)
|
||||||
comment: Comment;
|
comment: Comment;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
creator: PersonSafe;
|
creator: PersonSafe;
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
recipient: PersonSafe;
|
recipient: PersonSafe;
|
||||||
counts: CommentAggregates;
|
counts: CommentAggregates;
|
||||||
creator_banned_from_community: boolean;
|
creator_banned_from_community: boolean;
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
saved: boolean;
|
saved: boolean;
|
||||||
creator_blocked: boolean;
|
creator_blocked: boolean;
|
||||||
my_vote?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
my_vote: Option<number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface LocalUserSettingsView {
|
export class LocalUserSettingsView {
|
||||||
|
@Type(() => LocalUserSettings)
|
||||||
local_user: LocalUserSettings;
|
local_user: LocalUserSettings;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
person: PersonSafe;
|
person: PersonSafe;
|
||||||
counts: PersonAggregates;
|
counts: PersonAggregates;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SiteView {
|
export class SiteView {
|
||||||
|
@Type(() => Site)
|
||||||
site: Site;
|
site: Site;
|
||||||
counts: SiteAggregates;
|
counts: SiteAggregates;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PrivateMessageView {
|
export class PrivateMessageView {
|
||||||
|
@Type(() => PrivateMessage)
|
||||||
private_message: PrivateMessage;
|
private_message: PrivateMessage;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
creator: PersonSafe;
|
creator: PersonSafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
recipient: PersonSafe;
|
recipient: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PostView {
|
export class PostView {
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
creator: PersonSafe;
|
creator: PersonSafe;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
creator_banned_from_community: boolean;
|
creator_banned_from_community: boolean;
|
||||||
counts: PostAggregates;
|
counts: PostAggregates;
|
||||||
|
@ -76,152 +99,248 @@ export interface PostView {
|
||||||
saved: boolean;
|
saved: boolean;
|
||||||
read: boolean;
|
read: boolean;
|
||||||
creator_blocked: boolean;
|
creator_blocked: boolean;
|
||||||
my_vote?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
my_vote: Option<number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PostReportView {
|
export class PostReportView {
|
||||||
|
@Type(() => PostReport)
|
||||||
post_report: PostReport;
|
post_report: PostReport;
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
creator: PersonSafe;
|
creator: PersonSafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
post_creator: PersonSafe;
|
post_creator: PersonSafe;
|
||||||
creator_banned_from_community: boolean;
|
creator_banned_from_community: boolean;
|
||||||
my_vote?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
my_vote: Option<number>;
|
||||||
counts: PostAggregates;
|
counts: PostAggregates;
|
||||||
resolver?: PersonSafe;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
@Type(() => PersonSafe)
|
||||||
|
resolver: Option<PersonSafe>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommentView {
|
export class CommentView {
|
||||||
|
@Type(() => Comment)
|
||||||
comment: Comment;
|
comment: Comment;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
creator: PersonSafe;
|
creator: PersonSafe;
|
||||||
recipient?: PersonSafe;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
@Type(() => PersonSafe)
|
||||||
|
recipient: Option<PersonSafe>;
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
counts: CommentAggregates;
|
counts: CommentAggregates;
|
||||||
creator_banned_from_community: boolean;
|
creator_banned_from_community: boolean;
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
saved: boolean;
|
saved: boolean;
|
||||||
creator_blocked: boolean;
|
creator_blocked: boolean;
|
||||||
my_vote?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
my_vote: Option<number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommentReportView {
|
export class CommentReportView {
|
||||||
|
@Type(() => CommentReport)
|
||||||
comment_report: CommentReport;
|
comment_report: CommentReport;
|
||||||
|
@Type(() => Comment)
|
||||||
comment: Comment;
|
comment: Comment;
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
creator: PersonSafe;
|
creator: PersonSafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
comment_creator: PersonSafe;
|
comment_creator: PersonSafe;
|
||||||
counts: CommentAggregates;
|
counts: CommentAggregates;
|
||||||
creator_banned_from_community: boolean;
|
creator_banned_from_community: boolean;
|
||||||
my_vote?: number;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
resolver?: PersonSafe;
|
@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>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModAddCommunityView {
|
export class ModAddCommunityView {
|
||||||
|
@Type(() => ModAddCommunity)
|
||||||
mod_add_community: ModAddCommunity;
|
mod_add_community: ModAddCommunity;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
modded_person: PersonSafe;
|
modded_person: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModTransferCommunityView {
|
export class ModTransferCommunityView {
|
||||||
|
@Type(() => ModTransferCommunity)
|
||||||
mod_transfer_community: ModTransferCommunity;
|
mod_transfer_community: ModTransferCommunity;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
modded_person: PersonSafe;
|
modded_person: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModAddView {
|
export class ModAddView {
|
||||||
|
@Type(() => ModAdd)
|
||||||
mod_add: ModAdd;
|
mod_add: ModAdd;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
modded_person: PersonSafe;
|
modded_person: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModBanFromCommunityView {
|
export class ModBanFromCommunityView {
|
||||||
|
@Type(() => ModBanFromCommunity)
|
||||||
mod_ban_from_community: ModBanFromCommunity;
|
mod_ban_from_community: ModBanFromCommunity;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
banned_person: PersonSafe;
|
banned_person: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModBanView {
|
export class ModBanView {
|
||||||
|
@Type(() => ModBan)
|
||||||
mod_ban: ModBan;
|
mod_ban: ModBan;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
banned_person: PersonSafe;
|
banned_person: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModLockPostView {
|
export class ModLockPostView {
|
||||||
|
@Type(() => ModLockPost)
|
||||||
mod_lock_post: ModLockPost;
|
mod_lock_post: ModLockPost;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModRemoveCommentView {
|
export class ModRemoveCommentView {
|
||||||
|
@Type(() => ModRemoveComment)
|
||||||
mod_remove_comment: ModRemoveComment;
|
mod_remove_comment: ModRemoveComment;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => Comment)
|
||||||
comment: Comment;
|
comment: Comment;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
commenter: PersonSafe;
|
commenter: PersonSafe;
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModRemoveCommunityView {
|
export class ModRemoveCommunityView {
|
||||||
|
@Type(() => ModRemoveCommunity)
|
||||||
mod_remove_community: ModRemoveCommunity;
|
mod_remove_community: ModRemoveCommunity;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModRemovePostView {
|
export class ModRemovePostView {
|
||||||
|
@Type(() => ModRemovePost)
|
||||||
mod_remove_post: ModRemovePost;
|
mod_remove_post: ModRemovePost;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ModStickyPostView {
|
export class ModStickyPostView {
|
||||||
|
@Type(() => ModStickyPost)
|
||||||
mod_sticky_post: ModStickyPost;
|
mod_sticky_post: ModStickyPost;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
|
@Type(() => Post)
|
||||||
post: Post;
|
post: Post;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommunityFollowerView {
|
export class CommunityFollowerView {
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
follower: PersonSafe;
|
follower: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommunityBlockView {
|
export class CommunityBlockView {
|
||||||
|
@Type(() => PersonSafe)
|
||||||
person: PersonSafe;
|
person: PersonSafe;
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommunityModeratorView {
|
export class CommunityModeratorView {
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
moderator: PersonSafe;
|
moderator: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommunityPersonBanView {
|
export class CommunityPersonBanView {
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
person: PersonSafe;
|
person: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PersonBlockView {
|
export class PersonBlockView {
|
||||||
|
@Type(() => PersonSafe)
|
||||||
person: PersonSafe;
|
person: PersonSafe;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
target: PersonSafe;
|
target: PersonSafe;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CommunityView {
|
export class CommunityView {
|
||||||
|
@Type(() => CommunitySafe)
|
||||||
community: CommunitySafe;
|
community: CommunitySafe;
|
||||||
subscribed: boolean;
|
subscribed: boolean;
|
||||||
blocked: boolean;
|
blocked: boolean;
|
||||||
counts: CommunityAggregates;
|
counts: CommunityAggregates;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegistrationApplicationView {
|
export class RegistrationApplicationView {
|
||||||
|
@Type(() => RegistrationApplication)
|
||||||
registration_application: RegistrationApplication;
|
registration_application: RegistrationApplication;
|
||||||
|
@Type(() => LocalUserSettings)
|
||||||
creator_local_user: LocalUserSettings;
|
creator_local_user: LocalUserSettings;
|
||||||
|
@Type(() => PersonSafe)
|
||||||
creator: PersonSafe;
|
creator: PersonSafe;
|
||||||
admin?: PersonSafe;
|
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||||
|
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||||
|
@Expose()
|
||||||
|
@Type(() => PersonSafe)
|
||||||
|
admin: Option<PersonSafe>;
|
||||||
}
|
}
|
||||||
|
|
15
src/utils.ts
Normal file
15
src/utils.ts
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
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);
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { ClassConstructor, deserialize, serialize } from "class-transformer";
|
||||||
import {
|
import {
|
||||||
CreateComment,
|
CreateComment,
|
||||||
CreateCommentLike,
|
CreateCommentLike,
|
||||||
|
@ -499,7 +500,7 @@ export class LemmyWebsocket {
|
||||||
/**
|
/**
|
||||||
* Gets the site, and your user data.
|
* Gets the site, and your user data.
|
||||||
*/
|
*/
|
||||||
getSite(form: GetSite = {}) {
|
getSite(form: GetSite) {
|
||||||
return wrapper(UserOperation.GetSite, form);
|
return wrapper(UserOperation.GetSite, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -645,7 +646,22 @@ export class LemmyWebsocket {
|
||||||
}
|
}
|
||||||
|
|
||||||
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||||
let send = { op: UserOperation[op], data: data };
|
let send = serialize({ op: UserOperation[op], data });
|
||||||
console.log(send);
|
return send;
|
||||||
return JSON.stringify(send);
|
}
|
||||||
|
|
||||||
|
export function wsUserOp(msg: any): UserOperation {
|
||||||
|
let opStr: string = msg.op;
|
||||||
|
return UserOperation[opStr as keyof typeof UserOperation];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a websocket string response to a usable result
|
||||||
|
*/
|
||||||
|
export function wsJsonToRes<ResponseType>(
|
||||||
|
msg: any,
|
||||||
|
responseClass: ClassConstructor<ResponseType>
|
||||||
|
): ResponseType {
|
||||||
|
// Have to deserialize the response again into the correct class
|
||||||
|
return deserialize(responseClass, serialize(msg.data));
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
"lib": ["es2017", "es7", "es6", "dom"],
|
"lib": ["es2017", "es7", "es6", "dom"],
|
||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"target": "ES5",
|
"target": "ES5",
|
||||||
|
"experimentalDecorators": true,
|
||||||
"moduleResolution": "Node"
|
"moduleResolution": "Node"
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
|
|
15
yarn.lock
15
yarn.lock
|
@ -251,6 +251,11 @@
|
||||||
"@nodelib/fs.scandir" "2.1.4"
|
"@nodelib/fs.scandir" "2.1.4"
|
||||||
fastq "^1.6.0"
|
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":
|
"@types/glob@^7.1.1":
|
||||||
version "7.2.0"
|
version "7.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
|
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
|
||||||
|
@ -539,6 +544,11 @@ chalk@^4.0.0:
|
||||||
ansi-styles "^4.1.0"
|
ansi-styles "^4.1.0"
|
||||||
supports-color "^7.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:
|
clean-stack@^2.0.0:
|
||||||
version "2.2.0"
|
version "2.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
|
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
|
||||||
|
@ -1706,6 +1716,11 @@ punycode@^2.1.0:
|
||||||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
|
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
|
||||||
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
|
integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==
|
||||||
|
|
||||||
|
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:
|
regexpp@^3.2.0:
|
||||||
version "3.2.0"
|
version "3.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
|
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
|
||||||
|
|
Loading…
Reference in a new issue