mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-12-22 19:01:27 +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",
|
||||
"description": "A javascript / typescript client for Lemmy",
|
||||
"version": "0.16.4-rc.3",
|
||||
"version": "0.17.0-rc.30",
|
||||
"author": "Dessalines <tyhou13@gmx.com>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/index.js",
|
||||
|
@ -16,10 +16,12 @@
|
|||
},
|
||||
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
||||
"devDependencies": {
|
||||
"@sniptt/monads": "^0.5.10",
|
||||
"@types/node": "^17.0.33",
|
||||
"@types/node-fetch": "^3.0.3",
|
||||
"@typescript-eslint/eslint-plugin": "^5.23.0",
|
||||
"@typescript-eslint/parser": "^5.23.0",
|
||||
"class-transformer": "^0.5.1",
|
||||
"eslint": "^8.15.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"husky": "^8.0.1",
|
||||
|
@ -29,6 +31,7 @@
|
|||
"prettier-plugin-import-sort": "^0.0.7",
|
||||
"prettier-plugin-organize-imports": "^2.3.4",
|
||||
"prettier-plugin-packagejson": "^2.2.18",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"sortpack": "^2.2.0",
|
||||
"typedoc": "^0.21.6",
|
||||
"typedoc-plugin-sourcefile-url": "^1.0.6",
|
||||
|
|
675
src/http.ts
675
src/http.ts
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,4 @@
|
|||
export * from "./http";
|
||||
export * from "./interfaces";
|
||||
export * from "./utils";
|
||||
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 { CommentReportView, CommentView } from "../views";
|
||||
|
||||
export interface CreateComment {
|
||||
export class CreateComment {
|
||||
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;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
constructor(init: CreateComment) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface EditComment {
|
||||
export class EditComment {
|
||||
content: string;
|
||||
comment_id: number;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
constructor(init: EditComment) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the creator can delete the comment.
|
||||
*/
|
||||
export interface DeleteComment {
|
||||
export class DeleteComment {
|
||||
comment_id: number;
|
||||
deleted: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: DeleteComment) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only a mod or admin can remove the comment.
|
||||
*/
|
||||
export interface RemoveComment {
|
||||
export class RemoveComment {
|
||||
comment_id: number;
|
||||
removed: boolean;
|
||||
reason?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: RemoveComment) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only the recipient can do this.
|
||||
*/
|
||||
export interface MarkCommentAsRead {
|
||||
export class MarkCommentAsRead {
|
||||
comment_id: number;
|
||||
read: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: MarkCommentAsRead) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface SaveComment {
|
||||
export class SaveComment {
|
||||
comment_id: number;
|
||||
save: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: SaveComment) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommentResponse {
|
||||
export class CommentResponse {
|
||||
@Type(() => CommentView)
|
||||
comment_view: CommentView;
|
||||
recipient_ids: number[];
|
||||
/**
|
||||
* 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;
|
||||
score: number;
|
||||
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.
|
||||
* To get posts for a federated community by name, use `name@instance.tld` .
|
||||
*/
|
||||
export interface GetComments {
|
||||
type_?: ListingType;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
community_name?: string;
|
||||
saved_only?: boolean;
|
||||
auth?: string;
|
||||
export class GetComments {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
type_: Option<ListingType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<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[];
|
||||
}
|
||||
|
||||
export interface CreateCommentReport {
|
||||
export class CreateCommentReport {
|
||||
comment_id: number;
|
||||
reason: string;
|
||||
auth: string;
|
||||
|
||||
constructor(init: CreateCommentReport) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommentReportResponse {
|
||||
export class CommentReportResponse {
|
||||
@Type(() => CommentReportView)
|
||||
comment_report_view: CommentReportView;
|
||||
}
|
||||
|
||||
export interface ResolveCommentReport {
|
||||
export class ResolveCommentReport {
|
||||
report_id: number;
|
||||
/**
|
||||
* Either resolve or unresolve a report.
|
||||
*/
|
||||
resolved: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ResolveCommentReport) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ListCommentReports {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
export class ListCommentReports {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
unresolved_only?: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unresolved_only: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ListCommentReports) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ListCommentReportsResponse {
|
||||
export class ListCommentReportsResponse {
|
||||
@Type(() => 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 { Site } from "../source";
|
||||
import {
|
||||
|
@ -11,47 +15,106 @@ import {
|
|||
*
|
||||
* To get a federated community by name, use `name@instance.tld` .
|
||||
*/
|
||||
export interface GetCommunity {
|
||||
id?: number;
|
||||
name?: string;
|
||||
auth?: string;
|
||||
export class GetCommunity {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
id: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
name: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
||||
constructor(init: GetCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetCommunityResponse {
|
||||
export class GetCommunityResponse {
|
||||
@Type(() => 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[];
|
||||
online: number;
|
||||
}
|
||||
|
||||
export interface CreateCommunity {
|
||||
export class CreateCommunity {
|
||||
name: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
nsfw?: boolean;
|
||||
posting_restricted_to_mods?: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
nsfw: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
posting_restricted_to_mods: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: CreateCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface CommunityResponse {
|
||||
export class CommunityResponse {
|
||||
@Type(() => CommunityView)
|
||||
community_view: CommunityView;
|
||||
}
|
||||
|
||||
export interface ListCommunities {
|
||||
type_?: ListingType;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
export class ListCommunities {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
type_: Option<ListingType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
||||
constructor(init: ListCommunities) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ListCommunitiesResponse {
|
||||
export class ListCommunitiesResponse {
|
||||
@Type(() => CommunityView)
|
||||
communities: CommunityView[];
|
||||
}
|
||||
|
||||
export interface BanFromCommunity {
|
||||
export class BanFromCommunity {
|
||||
community_id: number;
|
||||
person_id: number;
|
||||
ban: boolean;
|
||||
|
@ -59,84 +122,152 @@ export interface BanFromCommunity {
|
|||
/**
|
||||
* Removes/Restores their comments and posts for that community.
|
||||
*/
|
||||
remove_data?: boolean;
|
||||
reason?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
remove_data: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
constructor(init: BanFromCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface BanFromCommunityResponse {
|
||||
export class BanFromCommunityResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
person_view: PersonViewSafe;
|
||||
banned: boolean;
|
||||
}
|
||||
|
||||
export interface AddModToCommunity {
|
||||
export class AddModToCommunity {
|
||||
community_id: number;
|
||||
person_id: number;
|
||||
added: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: AddModToCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface AddModToCommunityResponse {
|
||||
export class AddModToCommunityResponse {
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderators: CommunityModeratorView[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Only mods can edit a community.
|
||||
*/
|
||||
export interface EditCommunity {
|
||||
export class EditCommunity {
|
||||
community_id: number;
|
||||
title?: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
nsfw?: boolean;
|
||||
posting_restricted_to_mods?: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
title: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
nsfw: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
posting_restricted_to_mods: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: EditCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface DeleteCommunity {
|
||||
export class DeleteCommunity {
|
||||
community_id: number;
|
||||
deleted: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: DeleteCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins can remove a community.
|
||||
*/
|
||||
export interface RemoveCommunity {
|
||||
export class RemoveCommunity {
|
||||
community_id: number;
|
||||
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
|
||||
*/
|
||||
expires?: number;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<number>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: RemoveCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface FollowCommunity {
|
||||
export class FollowCommunity {
|
||||
community_id: number;
|
||||
follow: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: FollowCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface TransferCommunity {
|
||||
export class TransferCommunity {
|
||||
community_id: number;
|
||||
person_id: number;
|
||||
auth: string;
|
||||
|
||||
constructor(init: TransferCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface BlockCommunity {
|
||||
export class BlockCommunity {
|
||||
community_id: number;
|
||||
block: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: BlockCommunity) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface BlockCommunityResponse {
|
||||
export class BlockCommunityResponse {
|
||||
@Type(() => CommunityView)
|
||||
community_view: CommunityView;
|
||||
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 {
|
||||
CommentView,
|
||||
|
@ -8,9 +12,13 @@ import {
|
|||
PrivateMessageView,
|
||||
} from "../views";
|
||||
|
||||
export interface Login {
|
||||
export class Login {
|
||||
username_or_email: 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.
|
||||
*/
|
||||
export interface Register {
|
||||
export class Register {
|
||||
username: string;
|
||||
/**
|
||||
* 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_verify: string;
|
||||
show_nsfw: boolean;
|
||||
/**
|
||||
* Captcha is only checked if these are enabled in the server.
|
||||
*/
|
||||
captcha_uuid?: string;
|
||||
captcha_answer?: string;
|
||||
honeypot?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
captcha_uuid: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
captcha_answer: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
honeypot: Option<string>;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -57,7 +88,10 @@ export interface CaptchaResponse {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -65,259 +99,489 @@ export interface CaptchaResponse {
|
|||
uuid: string;
|
||||
}
|
||||
|
||||
export interface SaveUserSettings {
|
||||
show_nsfw?: boolean;
|
||||
export class SaveUserSettings {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_nsfw: Option<boolean>;
|
||||
|
||||
/**
|
||||
* 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 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]].
|
||||
*
|
||||
* Post listing types are `All, Subscribed, Community`
|
||||
*/
|
||||
default_listing_type?: number;
|
||||
lang?: string;
|
||||
avatar?: string;
|
||||
banner?: string;
|
||||
display_name?: string;
|
||||
email?: string;
|
||||
bio?: string;
|
||||
matrix_user_id?: string;
|
||||
show_avatars?: boolean;
|
||||
show_scores?: boolean;
|
||||
send_notifications_to_email?: boolean;
|
||||
bot_account?: boolean;
|
||||
show_bot_accounts?: boolean;
|
||||
show_read_posts?: boolean;
|
||||
show_new_post_notifs?: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
default_listing_type: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
lang: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
avatar: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
display_name: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
email: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
bio: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
matrix_user_id: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_avatars: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_scores: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
send_notifications_to_email: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
bot_account: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_bot_accounts: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_read_posts: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
show_new_post_notifs: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: SaveUserSettings) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ChangePassword {
|
||||
export class ChangePassword {
|
||||
new_password: string;
|
||||
new_password_verify: string;
|
||||
old_password: string;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ChangePassword) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
||||
*/
|
||||
export interface LoginResponse {
|
||||
export class LoginResponse {
|
||||
/**
|
||||
* 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;
|
||||
registration_created: boolean;
|
||||
}
|
||||
|
||||
export interface GetPersonDetails {
|
||||
person_id?: number;
|
||||
export class GetPersonDetails {
|
||||
@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`.
|
||||
*/
|
||||
username?: string;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
saved_only?: boolean;
|
||||
auth?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
username: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
saved_only: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
||||
constructor(init: GetPersonDetails) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetPersonDetailsResponse {
|
||||
export class GetPersonDetailsResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
person_view: PersonViewSafe;
|
||||
@Type(() => CommentView)
|
||||
comments: CommentView[];
|
||||
@Type(() => PostView)
|
||||
posts: PostView[];
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderates: CommunityModeratorView[];
|
||||
}
|
||||
|
||||
export interface GetRepliesResponse {
|
||||
export class GetRepliesResponse {
|
||||
@Type(() => CommentView)
|
||||
replies: CommentView[];
|
||||
}
|
||||
|
||||
export interface GetPersonMentionsResponse {
|
||||
export class GetPersonMentionsResponse {
|
||||
@Type(() => PersonMentionView)
|
||||
mentions: PersonMentionView[];
|
||||
}
|
||||
|
||||
export interface MarkAllAsRead {
|
||||
export class MarkAllAsRead {
|
||||
auth: string;
|
||||
|
||||
constructor(auth: string) {
|
||||
this.auth = auth;
|
||||
}
|
||||
}
|
||||
|
||||
export interface AddAdmin {
|
||||
export class AddAdmin {
|
||||
person_id: number;
|
||||
added: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: AddAdmin) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface AddAdminResponse {
|
||||
export class AddAdminResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
admins: PersonViewSafe[];
|
||||
}
|
||||
|
||||
export interface BanPerson {
|
||||
export class BanPerson {
|
||||
person_id: number;
|
||||
ban: boolean;
|
||||
|
||||
/**
|
||||
* Removes/Restores their comments, posts, and communities
|
||||
*/
|
||||
remove_data?: boolean;
|
||||
reason?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
remove_data: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
/**
|
||||
* 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;
|
||||
|
||||
constructor(init: BanPerson) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface BanPersonResponse {
|
||||
export class BanPersonResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
person_view: PersonViewSafe;
|
||||
banned: boolean;
|
||||
}
|
||||
|
||||
export interface GetReplies {
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
unread_only?: boolean;
|
||||
export class GetReplies {
|
||||
@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()
|
||||
unread_only: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: GetReplies) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetPersonMentions {
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
unread_only?: boolean;
|
||||
export class GetPersonMentions {
|
||||
@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()
|
||||
unread_only: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: GetPersonMentions) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface MarkPersonMentionAsRead {
|
||||
export class MarkPersonMentionAsRead {
|
||||
person_mention_id: number;
|
||||
read: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: MarkPersonMentionAsRead) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface PersonMentionResponse {
|
||||
export class PersonMentionResponse {
|
||||
@Type(() => PersonMentionView)
|
||||
person_mention_view: PersonMentionView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permanently deletes your posts and comments
|
||||
*/
|
||||
export interface DeleteAccount {
|
||||
export class DeleteAccount {
|
||||
password: string;
|
||||
auth: string;
|
||||
|
||||
constructor(init: DeleteAccount) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface DeleteAccountResponse {}
|
||||
export class DeleteAccountResponse {}
|
||||
|
||||
export interface PasswordReset {
|
||||
export class PasswordReset {
|
||||
email: string;
|
||||
|
||||
constructor(init: PasswordReset) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface PasswordResetResponse {}
|
||||
export class PasswordResetResponse {}
|
||||
|
||||
export interface PasswordChange {
|
||||
export class PasswordChange {
|
||||
token: string;
|
||||
password: string;
|
||||
password_verify: string;
|
||||
|
||||
constructor(init: PasswordChange) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface CreatePrivateMessage {
|
||||
export class CreatePrivateMessage {
|
||||
content: string;
|
||||
recipient_id: number;
|
||||
auth: string;
|
||||
|
||||
constructor(init: CreatePrivateMessage) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface EditPrivateMessage {
|
||||
export class EditPrivateMessage {
|
||||
private_message_id: number;
|
||||
content: string;
|
||||
auth: string;
|
||||
|
||||
constructor(init: EditPrivateMessage) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface DeletePrivateMessage {
|
||||
export class DeletePrivateMessage {
|
||||
private_message_id: number;
|
||||
deleted: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: DeletePrivateMessage) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface MarkPrivateMessageAsRead {
|
||||
export class MarkPrivateMessageAsRead {
|
||||
private_message_id: number;
|
||||
read: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: MarkPrivateMessageAsRead) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetPrivateMessages {
|
||||
unread_only?: boolean;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
export class GetPrivateMessages {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unread_only: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: GetPrivateMessages) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface PrivateMessagesResponse {
|
||||
export class PrivateMessagesResponse {
|
||||
@Type(() => PrivateMessageView)
|
||||
private_messages: PrivateMessageView[];
|
||||
}
|
||||
|
||||
export interface PrivateMessageResponse {
|
||||
export class PrivateMessageResponse {
|
||||
@Type(() => 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.
|
||||
*/
|
||||
community_id?: number;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: GetReportCount) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetReportCountResponse {
|
||||
community_id?: number;
|
||||
export class GetReportCountResponse {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
comment_reports: number;
|
||||
post_reports: number;
|
||||
}
|
||||
|
||||
export interface GetUnreadCount {
|
||||
export class GetUnreadCount {
|
||||
auth: string;
|
||||
|
||||
constructor(init: GetUnreadCount) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetUnreadCountResponse {
|
||||
export class GetUnreadCountResponse {
|
||||
replies: number;
|
||||
mentions: number;
|
||||
private_messages: number;
|
||||
}
|
||||
|
||||
export interface VerifyEmail {
|
||||
export class VerifyEmail {
|
||||
token: string;
|
||||
|
||||
constructor(init: VerifyEmail) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface VerifyEmailResponse {}
|
||||
export class VerifyEmailResponse {}
|
||||
|
||||
export interface BlockPerson {
|
||||
export class BlockPerson {
|
||||
person_id: number;
|
||||
block: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: BlockPerson) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface BlockPersonResponse {
|
||||
export class BlockPersonResponse {
|
||||
@Type(() => PersonViewSafe)
|
||||
person_view: PersonViewSafe;
|
||||
blocked: boolean;
|
||||
}
|
||||
|
||||
export interface GetBannedPersons {
|
||||
export class GetBannedPersons {
|
||||
auth: string;
|
||||
|
||||
constructor(init: GetBannedPersons) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface BannedPersonsResponse {
|
||||
export class BannedPersonsResponse {
|
||||
@Type(() => 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 {
|
||||
CommentView,
|
||||
|
@ -7,52 +11,109 @@ import {
|
|||
PostView,
|
||||
} from "../views";
|
||||
|
||||
export interface CreatePost {
|
||||
export class CreatePost {
|
||||
name: string;
|
||||
url?: string;
|
||||
body?: string;
|
||||
nsfw?: boolean;
|
||||
@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>;
|
||||
community_id: number;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
honeypot: Option<string>;
|
||||
auth: string;
|
||||
honeypot?: string;
|
||||
|
||||
constructor(init: CreatePost) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface PostResponse {
|
||||
export class PostResponse {
|
||||
@Type(() => PostView)
|
||||
post_view: PostView;
|
||||
}
|
||||
|
||||
export interface GetPost {
|
||||
export class GetPost {
|
||||
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;
|
||||
@Type(() => CommunityView)
|
||||
community_view: CommunityView;
|
||||
@Type(() => CommentView)
|
||||
comments: CommentView[];
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderators: CommunityModeratorView[];
|
||||
online: number;
|
||||
}
|
||||
|
||||
export interface GetPosts {
|
||||
type_?: ListingType;
|
||||
sort?: SortType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
community_id?: number;
|
||||
export class GetPosts {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
type_: Option<ListingType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
/**
|
||||
* To get posts for a federated community by name, use `name@instance.tld` .
|
||||
*/
|
||||
community_name?: string;
|
||||
saved_only?: boolean;
|
||||
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()
|
||||
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[];
|
||||
}
|
||||
|
||||
export interface CreatePostLike {
|
||||
export class CreatePostLike {
|
||||
post_id: number;
|
||||
|
||||
/**
|
||||
|
@ -60,107 +121,185 @@ export interface CreatePostLike {
|
|||
*/
|
||||
score: number;
|
||||
auth: string;
|
||||
|
||||
constructor(init: CreatePostLike) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface EditPost {
|
||||
export class EditPost {
|
||||
post_id: number;
|
||||
name?: string;
|
||||
url?: string;
|
||||
body?: string;
|
||||
nsfw?: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
name: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
url: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
body: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
nsfw: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: EditPost) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface DeletePost {
|
||||
export class DeletePost {
|
||||
post_id: number;
|
||||
deleted: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: DeletePost) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins and mods can remove a post.
|
||||
*/
|
||||
export interface RemovePost {
|
||||
export class RemovePost {
|
||||
post_id: number;
|
||||
removed: boolean;
|
||||
reason?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: RemovePost) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks a post as read.
|
||||
*/
|
||||
export interface MarkPostAsRead {
|
||||
export class MarkPostAsRead {
|
||||
post_id: number;
|
||||
read: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: MarkPostAsRead) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins and mods can lock a post.
|
||||
*/
|
||||
export interface LockPost {
|
||||
export class LockPost {
|
||||
post_id: number;
|
||||
locked: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: LockPost) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only admins and mods can sticky a post.
|
||||
*/
|
||||
export interface StickyPost {
|
||||
export class StickyPost {
|
||||
post_id: number;
|
||||
stickied: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: StickyPost) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface SavePost {
|
||||
export class SavePost {
|
||||
post_id: number;
|
||||
save: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: SavePost) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface CreatePostReport {
|
||||
export class CreatePostReport {
|
||||
post_id: number;
|
||||
reason: string;
|
||||
auth: string;
|
||||
|
||||
constructor(init: CreatePostReport) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface PostReportResponse {
|
||||
export class PostReportResponse {
|
||||
@Type(() => PostReportView)
|
||||
post_report_view: PostReportView;
|
||||
}
|
||||
|
||||
export interface ResolvePostReport {
|
||||
export class ResolvePostReport {
|
||||
report_id: number;
|
||||
/**
|
||||
* Either resolve or unresolve a report.
|
||||
*/
|
||||
resolved: boolean;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ResolvePostReport) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ListPostReports {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
export class ListPostReports {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
unresolved_only?: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unresolved_only: Option<boolean>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ListPostReports) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ListPostReportsResponse {
|
||||
export class ListPostReportsResponse {
|
||||
@Type(() => PostReportView)
|
||||
post_reports: PostReportView[];
|
||||
}
|
||||
|
||||
export interface GetSiteMetadata {
|
||||
export class GetSiteMetadata {
|
||||
url: string;
|
||||
|
||||
constructor(init: GetSiteMetadata) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetSiteMetadataResponse {
|
||||
export class GetSiteMetadataResponse {
|
||||
@Type(() => 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 {
|
||||
CommentView,
|
||||
|
@ -26,191 +30,450 @@ import {
|
|||
/**
|
||||
* Search lemmy for different types of data.
|
||||
*/
|
||||
export interface Search {
|
||||
export class Search {
|
||||
/**
|
||||
* The search query string.
|
||||
*/
|
||||
q: string;
|
||||
type_?: SearchType;
|
||||
community_id?: number;
|
||||
community_name?: string;
|
||||
creator_id?: number;
|
||||
sort?: SortType;
|
||||
listing_type?: ListingType;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
type_: Option<SearchType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_name: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
creator_id: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sort: Option<SortType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
listing_type: Option<ListingType>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
||||
constructor(init: Search) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface SearchResponse {
|
||||
export class SearchResponse {
|
||||
/**
|
||||
* The [[SearchType]].
|
||||
*/
|
||||
type_: string;
|
||||
@Type(() => CommentView)
|
||||
comments: CommentView[];
|
||||
@Type(() => PostView)
|
||||
posts: PostView[];
|
||||
@Type(() => CommunityView)
|
||||
communities: CommunityView[];
|
||||
@Type(() => PersonViewSafe)
|
||||
users: PersonViewSafe[];
|
||||
}
|
||||
|
||||
export interface GetModlog {
|
||||
mod_person_id?: number;
|
||||
community_id?: number;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
export class GetModlog {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
mod_person_id: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
community_id: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
||||
constructor(init: GetModlog) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetModlogResponse {
|
||||
export class GetModlogResponse {
|
||||
@Type(() => ModRemovePostView)
|
||||
removed_posts: ModRemovePostView[];
|
||||
@Type(() => ModLockPostView)
|
||||
locked_posts: ModLockPostView[];
|
||||
@Type(() => ModStickyPostView)
|
||||
stickied_posts: ModStickyPostView[];
|
||||
@Type(() => ModRemoveCommentView)
|
||||
removed_comments: ModRemoveCommentView[];
|
||||
@Type(() => ModRemoveCommunityView)
|
||||
removed_communities: ModRemoveCommunityView[];
|
||||
@Type(() => ModBanFromCommunityView)
|
||||
banned_from_community: ModBanFromCommunityView[];
|
||||
@Type(() => ModBanView)
|
||||
banned: ModBanView[];
|
||||
@Type(() => ModAddCommunityView)
|
||||
added_to_community: ModAddCommunityView[];
|
||||
@Type(() => ModTransferCommunityView)
|
||||
transferred_to_community: ModTransferCommunityView[];
|
||||
@Type(() => ModAddView)
|
||||
added: ModAddView[];
|
||||
}
|
||||
|
||||
export interface CreateSite {
|
||||
export class CreateSite {
|
||||
name: string;
|
||||
sidebar?: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
enable_downvotes?: boolean;
|
||||
open_registration?: boolean;
|
||||
enable_nsfw?: boolean;
|
||||
community_creation_admin_only?: boolean;
|
||||
require_email_verification?: boolean;
|
||||
require_application?: boolean;
|
||||
application_question?: string;
|
||||
private_instance?: boolean;
|
||||
default_theme?: string;
|
||||
default_post_listing_type?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sidebar: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
enable_downvotes: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
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;
|
||||
|
||||
constructor(init: CreateSite) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface EditSite {
|
||||
name?: string;
|
||||
sidebar?: string;
|
||||
description?: string;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
enable_downvotes?: boolean;
|
||||
open_registration?: boolean;
|
||||
enable_nsfw?: boolean;
|
||||
community_creation_admin_only?: boolean;
|
||||
require_email_verification?: boolean;
|
||||
require_application?: boolean;
|
||||
application_question?: string;
|
||||
private_instance?: boolean;
|
||||
default_theme?: string;
|
||||
legal_information?: string;
|
||||
default_post_listing_type?: string;
|
||||
export class EditSite {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
name: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sidebar: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
enable_downvotes: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
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;
|
||||
|
||||
constructor(init: EditSite) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetSite {
|
||||
auth?: string;
|
||||
export class GetSite {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
auth: Option<string>;
|
||||
|
||||
constructor(init: GetSite) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface SiteResponse {
|
||||
export class SiteResponse {
|
||||
@Type(() => SiteView)
|
||||
site_view: SiteView;
|
||||
}
|
||||
|
||||
export interface GetSiteResponse {
|
||||
export class GetSiteResponse {
|
||||
/**
|
||||
* 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[];
|
||||
online: number;
|
||||
version: string;
|
||||
/**
|
||||
* If you're logged in, you'll get back extra user info.
|
||||
*/
|
||||
my_user?: MyUserInfo;
|
||||
federated_instances?: FederatedInstances;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => MyUserInfo)
|
||||
my_user: Option<MyUserInfo>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => FederatedInstances)
|
||||
federated_instances: Option<FederatedInstances>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Your user info, such as blocks, follows, etc.
|
||||
*/
|
||||
export interface MyUserInfo {
|
||||
export class MyUserInfo {
|
||||
@Type(() => LocalUserSettingsView)
|
||||
local_user_view: LocalUserSettingsView;
|
||||
@Type(() => CommunityFollowerView)
|
||||
follows: CommunityFollowerView[];
|
||||
@Type(() => CommunityModeratorView)
|
||||
moderates: CommunityModeratorView[];
|
||||
@Type(() => CommunityBlockView)
|
||||
community_blocks: CommunityBlockView[];
|
||||
@Type(() => PersonBlockView)
|
||||
person_blocks: PersonBlockView[];
|
||||
}
|
||||
|
||||
export interface LeaveAdmin {
|
||||
export class LeaveAdmin {
|
||||
auth: string;
|
||||
|
||||
constructor(init: LeaveAdmin) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetSiteConfig {
|
||||
export class GetSiteConfig {
|
||||
auth: string;
|
||||
|
||||
constructor(init: GetSiteConfig) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetSiteConfigResponse {
|
||||
export class GetSiteConfigResponse {
|
||||
config_hjson: string;
|
||||
}
|
||||
|
||||
export interface SaveSiteConfig {
|
||||
export class SaveSiteConfig {
|
||||
config_hjson: string;
|
||||
auth: string;
|
||||
|
||||
constructor(init: SaveSiteConfig) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface FederatedInstances {
|
||||
export class FederatedInstances {
|
||||
linked: string[];
|
||||
allowed?: string[];
|
||||
blocked?: string[];
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
allowed: Option<string[]>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
blocked: Option<string[]>;
|
||||
|
||||
constructor(init: FederatedInstances) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ResolveObject {
|
||||
export class ResolveObject {
|
||||
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 {
|
||||
comment?: CommentView;
|
||||
post?: PostView;
|
||||
community?: CommunityView;
|
||||
person?: PersonViewSafe;
|
||||
export class ResolveObjectResponse {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => CommentView)
|
||||
comment: Option<CommentView>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PostView)
|
||||
post: Option<PostView>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => CommunityView)
|
||||
community: Option<CommunityView>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonViewSafe)
|
||||
person: Option<PersonViewSafe>;
|
||||
}
|
||||
|
||||
export interface ListRegistrationApplications {
|
||||
export class ListRegistrationApplications {
|
||||
/**
|
||||
* Only shows the unread applications (IE those without an admin actor)
|
||||
*/
|
||||
unread_only?: boolean;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
unread_only: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
page: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
limit: Option<number>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ListRegistrationApplications) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface ListRegistrationApplicationsResponse {
|
||||
export class ListRegistrationApplicationsResponse {
|
||||
@Type(() => RegistrationApplicationView)
|
||||
registration_applications: RegistrationApplicationView[];
|
||||
}
|
||||
|
||||
export interface ApproveRegistrationApplication {
|
||||
export class ApproveRegistrationApplication {
|
||||
id: number;
|
||||
approve: boolean;
|
||||
deny_reason?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
deny_reason: Option<string>;
|
||||
auth: string;
|
||||
|
||||
constructor(init: ApproveRegistrationApplication) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface RegistrationApplicationResponse {
|
||||
export class RegistrationApplicationResponse {
|
||||
@Type(() => RegistrationApplicationView)
|
||||
registration_application: RegistrationApplicationView;
|
||||
}
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCount {
|
||||
export class GetUnreadRegistrationApplicationCount {
|
||||
auth: string;
|
||||
|
||||
constructor(init: GetUnreadRegistrationApplicationCount) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCountResponse {
|
||||
export class GetUnreadRegistrationApplicationCountResponse {
|
||||
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";
|
||||
|
||||
/**
|
||||
|
@ -148,48 +151,28 @@ export enum SearchType {
|
|||
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.
|
||||
*/
|
||||
export interface SiteMetadata {
|
||||
title?: string;
|
||||
description?: string;
|
||||
image?: string;
|
||||
html?: string;
|
||||
export class SiteMetadata {
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
title: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
image: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
html: Option<string>;
|
||||
|
||||
constructor(init: SiteMetadata) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
person_id: number;
|
||||
email?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
email: Option<string>;
|
||||
show_nsfw: boolean;
|
||||
theme: string;
|
||||
default_sort_type: number;
|
||||
|
@ -17,43 +24,82 @@ export interface LocalUserSettings {
|
|||
accepted_application: boolean;
|
||||
}
|
||||
|
||||
export interface PersonSafe {
|
||||
export class PersonSafe {
|
||||
id: number;
|
||||
name: string;
|
||||
display_name?: string;
|
||||
avatar?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
display_name: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
avatar: Option<string>;
|
||||
banned: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
actor_id: string;
|
||||
bio?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
bio: Option<string>;
|
||||
local: boolean;
|
||||
banner?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
deleted: boolean;
|
||||
inbox_url: string;
|
||||
shared_inbox_url: string;
|
||||
matrix_user_id?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
matrix_user_id: Option<string>;
|
||||
admin: 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;
|
||||
name: string;
|
||||
sidebar?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
sidebar: Option<string>;
|
||||
published: string;
|
||||
updated?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
enable_downvotes: boolean;
|
||||
open_registration: boolean;
|
||||
enable_nsfw: boolean;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
description?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
icon: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banner: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
community_creation_admin_only: boolean;
|
||||
require_email_verification: 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;
|
||||
default_theme: string;
|
||||
default_post_listing_type: string;
|
||||
|
@ -61,10 +107,13 @@ export interface Site {
|
|||
last_refreshed_at: string;
|
||||
inbox_url: 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;
|
||||
creator_id: number;
|
||||
recipient_id: number;
|
||||
|
@ -72,190 +121,304 @@ export interface PrivateMessage {
|
|||
deleted: boolean;
|
||||
read: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
ap_id: string;
|
||||
local: boolean;
|
||||
}
|
||||
|
||||
export interface PostReport {
|
||||
export class PostReport {
|
||||
id: number;
|
||||
creator_id: number;
|
||||
post_id: number;
|
||||
original_post_name: string;
|
||||
original_post_url?: string;
|
||||
original_post_body?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
original_post_url: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
original_post_body: Option<string>;
|
||||
reason: string;
|
||||
resolved: boolean;
|
||||
resolver_id?: number;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
resolver_id: Option<number>;
|
||||
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;
|
||||
name: string;
|
||||
url?: string;
|
||||
body?: 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>;
|
||||
creator_id: number;
|
||||
community_id: number;
|
||||
removed: boolean;
|
||||
locked: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
deleted: boolean;
|
||||
nsfw: boolean;
|
||||
stickied: boolean;
|
||||
embed_title?: string;
|
||||
embed_description?: string;
|
||||
embed_html?: string;
|
||||
thumbnail_url?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
embed_title: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
embed_description: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
embed_html: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
thumbnail_url: Option<string>;
|
||||
ap_id: string;
|
||||
local: boolean;
|
||||
}
|
||||
|
||||
export interface PasswordResetRequest {
|
||||
export class PasswordResetRequest {
|
||||
id: number;
|
||||
local_user_id: number;
|
||||
token_encrypted: string;
|
||||
published: string;
|
||||
}
|
||||
|
||||
export interface ModRemovePost {
|
||||
export class ModRemovePost {
|
||||
id: number;
|
||||
mod_person_id: number;
|
||||
post_id: number;
|
||||
reason?: string;
|
||||
removed?: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModLockPost {
|
||||
export class ModLockPost {
|
||||
id: number;
|
||||
mod_person_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;
|
||||
}
|
||||
|
||||
export interface ModStickyPost {
|
||||
export class ModStickyPost {
|
||||
id: number;
|
||||
mod_person_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;
|
||||
}
|
||||
|
||||
export interface ModRemoveComment {
|
||||
export class ModRemoveComment {
|
||||
id: number;
|
||||
mod_person_id: number;
|
||||
comment_id: number;
|
||||
reason?: string;
|
||||
removed?: boolean;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModRemoveCommunity {
|
||||
export class ModRemoveCommunity {
|
||||
id: number;
|
||||
mod_person_id: number;
|
||||
community_id: number;
|
||||
reason?: string;
|
||||
removed?: boolean;
|
||||
expires?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
removed: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<string>;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModBanFromCommunity {
|
||||
export class ModBanFromCommunity {
|
||||
id: number;
|
||||
mod_person_id: number;
|
||||
other_person_id: number;
|
||||
community_id: number;
|
||||
reason?: string;
|
||||
banned?: boolean;
|
||||
expires?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banned: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<string>;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModBan {
|
||||
export class ModBan {
|
||||
id: number;
|
||||
mod_person_id: number;
|
||||
other_person_id: number;
|
||||
reason?: string;
|
||||
banned?: boolean;
|
||||
expires?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
reason: Option<string>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
banned: Option<boolean>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
expires: Option<string>;
|
||||
when_: string;
|
||||
}
|
||||
|
||||
export interface ModAddCommunity {
|
||||
export class ModAddCommunity {
|
||||
id: number;
|
||||
mod_person_id: number;
|
||||
other_person_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;
|
||||
}
|
||||
|
||||
export interface ModTransferCommunity {
|
||||
export class ModTransferCommunity {
|
||||
id: number;
|
||||
mod_person_id: number;
|
||||
other_person_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;
|
||||
}
|
||||
|
||||
export interface ModAdd {
|
||||
export class ModAdd {
|
||||
id: number;
|
||||
mod_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;
|
||||
}
|
||||
|
||||
export interface CommunitySafe {
|
||||
export class CommunitySafe {
|
||||
id: number;
|
||||
name: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
description: Option<string>;
|
||||
removed: boolean;
|
||||
published: string;
|
||||
updated?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
deleted: boolean;
|
||||
nsfw: boolean;
|
||||
actor_id: string;
|
||||
local: boolean;
|
||||
icon?: string;
|
||||
banner?: 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>;
|
||||
posting_restricted_to_mods: boolean;
|
||||
}
|
||||
|
||||
export interface CommentReport {
|
||||
export class CommentReport {
|
||||
id: number;
|
||||
creator_id: number;
|
||||
comment_id: number;
|
||||
original_comment_text: string;
|
||||
reason: string;
|
||||
resolved: boolean;
|
||||
resolver_id?: number;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
resolver_id: Option<number>;
|
||||
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;
|
||||
creator_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;
|
||||
removed: boolean;
|
||||
read: boolean; // Whether the recipient has read the comment or not
|
||||
published: string;
|
||||
updated?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
updated: Option<string>;
|
||||
deleted: boolean;
|
||||
ap_id: string;
|
||||
local: boolean;
|
||||
}
|
||||
|
||||
export interface PersonMention {
|
||||
export class PersonMention {
|
||||
id: number;
|
||||
recipient_id: number;
|
||||
comment_id: number;
|
||||
|
@ -263,11 +426,17 @@ export interface PersonMention {
|
|||
published: string;
|
||||
}
|
||||
|
||||
export interface RegistrationApplication {
|
||||
export class RegistrationApplication {
|
||||
id: number;
|
||||
local_user_id: number;
|
||||
answer: string;
|
||||
admin_id?: number;
|
||||
deny_reason?: string;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
admin_id: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
deny_reason: Option<string>;
|
||||
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 {
|
||||
CommentAggregates,
|
||||
CommunityAggregates,
|
||||
|
@ -29,46 +33,65 @@ import {
|
|||
Site,
|
||||
} from "./source";
|
||||
|
||||
export interface PersonViewSafe {
|
||||
export class PersonViewSafe {
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
counts: PersonAggregates;
|
||||
}
|
||||
|
||||
export interface PersonMentionView {
|
||||
export class PersonMentionView {
|
||||
@Type(() => PersonMention)
|
||||
person_mention: PersonMention;
|
||||
@Type(() => Comment)
|
||||
comment: Comment;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
recipient: PersonSafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
subscribed: boolean;
|
||||
saved: 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;
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
counts: PersonAggregates;
|
||||
}
|
||||
|
||||
export interface SiteView {
|
||||
export class SiteView {
|
||||
@Type(() => Site)
|
||||
site: Site;
|
||||
counts: SiteAggregates;
|
||||
}
|
||||
|
||||
export interface PrivateMessageView {
|
||||
export class PrivateMessageView {
|
||||
@Type(() => PrivateMessage)
|
||||
private_message: PrivateMessage;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
recipient: PersonSafe;
|
||||
}
|
||||
|
||||
export interface PostView {
|
||||
export class PostView {
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
creator_banned_from_community: boolean;
|
||||
counts: PostAggregates;
|
||||
|
@ -76,152 +99,248 @@ export interface PostView {
|
|||
saved: boolean;
|
||||
read: 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;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
post_creator: PersonSafe;
|
||||
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;
|
||||
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;
|
||||
@Type(() => 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;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
subscribed: boolean;
|
||||
saved: 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;
|
||||
@Type(() => Comment)
|
||||
comment: Comment;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
creator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
comment_creator: PersonSafe;
|
||||
counts: CommentAggregates;
|
||||
creator_banned_from_community: boolean;
|
||||
my_vote?: number;
|
||||
resolver?: PersonSafe;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
my_vote: Option<number>;
|
||||
@Transform(({ value }) => toOption(value), { toClassOnly: true })
|
||||
@Transform(({ value }) => toUndefined(value), { toPlainOnly: true })
|
||||
@Expose()
|
||||
@Type(() => PersonSafe)
|
||||
resolver: Option<PersonSafe>;
|
||||
}
|
||||
|
||||
export interface ModAddCommunityView {
|
||||
export class ModAddCommunityView {
|
||||
@Type(() => ModAddCommunity)
|
||||
mod_add_community: ModAddCommunity;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
modded_person: PersonSafe;
|
||||
}
|
||||
|
||||
export interface ModTransferCommunityView {
|
||||
export class ModTransferCommunityView {
|
||||
@Type(() => ModTransferCommunity)
|
||||
mod_transfer_community: ModTransferCommunity;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
modded_person: PersonSafe;
|
||||
}
|
||||
|
||||
export interface ModAddView {
|
||||
export class ModAddView {
|
||||
@Type(() => ModAdd)
|
||||
mod_add: ModAdd;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
modded_person: PersonSafe;
|
||||
}
|
||||
|
||||
export interface ModBanFromCommunityView {
|
||||
export class ModBanFromCommunityView {
|
||||
@Type(() => ModBanFromCommunity)
|
||||
mod_ban_from_community: ModBanFromCommunity;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
banned_person: PersonSafe;
|
||||
}
|
||||
|
||||
export interface ModBanView {
|
||||
export class ModBanView {
|
||||
@Type(() => ModBan)
|
||||
mod_ban: ModBan;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
banned_person: PersonSafe;
|
||||
}
|
||||
|
||||
export interface ModLockPostView {
|
||||
export class ModLockPostView {
|
||||
@Type(() => ModLockPost)
|
||||
mod_lock_post: ModLockPost;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface ModRemoveCommentView {
|
||||
export class ModRemoveCommentView {
|
||||
@Type(() => ModRemoveComment)
|
||||
mod_remove_comment: ModRemoveComment;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => Comment)
|
||||
comment: Comment;
|
||||
@Type(() => PersonSafe)
|
||||
commenter: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface ModRemoveCommunityView {
|
||||
export class ModRemoveCommunityView {
|
||||
@Type(() => ModRemoveCommunity)
|
||||
mod_remove_community: ModRemoveCommunity;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface ModRemovePostView {
|
||||
export class ModRemovePostView {
|
||||
@Type(() => ModRemovePost)
|
||||
mod_remove_post: ModRemovePost;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface ModStickyPostView {
|
||||
export class ModStickyPostView {
|
||||
@Type(() => ModStickyPost)
|
||||
mod_sticky_post: ModStickyPost;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
@Type(() => Post)
|
||||
post: Post;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface CommunityFollowerView {
|
||||
export class CommunityFollowerView {
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
follower: PersonSafe;
|
||||
}
|
||||
|
||||
export interface CommunityBlockView {
|
||||
export class CommunityBlockView {
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
}
|
||||
|
||||
export interface CommunityModeratorView {
|
||||
export class CommunityModeratorView {
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
moderator: PersonSafe;
|
||||
}
|
||||
|
||||
export interface CommunityPersonBanView {
|
||||
export class CommunityPersonBanView {
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
}
|
||||
|
||||
export interface PersonBlockView {
|
||||
export class PersonBlockView {
|
||||
@Type(() => PersonSafe)
|
||||
person: PersonSafe;
|
||||
@Type(() => PersonSafe)
|
||||
target: PersonSafe;
|
||||
}
|
||||
|
||||
export interface CommunityView {
|
||||
export class CommunityView {
|
||||
@Type(() => CommunitySafe)
|
||||
community: CommunitySafe;
|
||||
subscribed: boolean;
|
||||
blocked: boolean;
|
||||
counts: CommunityAggregates;
|
||||
}
|
||||
|
||||
export interface RegistrationApplicationView {
|
||||
export class RegistrationApplicationView {
|
||||
@Type(() => RegistrationApplication)
|
||||
registration_application: RegistrationApplication;
|
||||
@Type(() => LocalUserSettings)
|
||||
creator_local_user: LocalUserSettings;
|
||||
@Type(() => 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 {
|
||||
CreateComment,
|
||||
CreateCommentLike,
|
||||
|
@ -499,7 +500,7 @@ export class LemmyWebsocket {
|
|||
/**
|
||||
* Gets the site, and your user data.
|
||||
*/
|
||||
getSite(form: GetSite = {}) {
|
||||
getSite(form: GetSite) {
|
||||
return wrapper(UserOperation.GetSite, form);
|
||||
}
|
||||
|
||||
|
@ -645,7 +646,22 @@ export class LemmyWebsocket {
|
|||
}
|
||||
|
||||
function wrapper<MessageType>(op: UserOperation, data: MessageType) {
|
||||
let send = { op: UserOperation[op], data: data };
|
||||
console.log(send);
|
||||
return JSON.stringify(send);
|
||||
let send = serialize({ op: UserOperation[op], data });
|
||||
return 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"],
|
||||
"outDir": "./dist",
|
||||
"target": "ES5",
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "Node"
|
||||
},
|
||||
"include": [
|
||||
|
|
15
yarn.lock
15
yarn.lock
|
@ -251,6 +251,11 @@
|
|||
"@nodelib/fs.scandir" "2.1.4"
|
||||
fastq "^1.6.0"
|
||||
|
||||
"@sniptt/monads@^0.5.10":
|
||||
version "0.5.10"
|
||||
resolved "https://registry.yarnpkg.com/@sniptt/monads/-/monads-0.5.10.tgz#a80cd00738bbd682d36d36dd36bdc0bddc96eb76"
|
||||
integrity sha512-+agDOv9DpDV+9e2zN/Vmdk+XaqGx5Sykl0fqhqgiJ90r18nsBkxe44DmZ2sA1HYK+MSsBeZBiAr6pq4w+5uhfw==
|
||||
|
||||
"@types/glob@^7.1.1":
|
||||
version "7.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
|
||||
|
@ -539,6 +544,11 @@ chalk@^4.0.0:
|
|||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
class-transformer@^0.5.1:
|
||||
version "0.5.1"
|
||||
resolved "https://registry.yarnpkg.com/class-transformer/-/class-transformer-0.5.1.tgz#24147d5dffd2a6cea930a3250a677addf96ab336"
|
||||
integrity sha512-SQa1Ws6hUbfC98vKGxZH3KFY0Y1lm5Zm0SY8XX9zbK7FJCyVEac3ATW0RIpwzW+oOfmHE5PMPufDG9hCfoEOMw==
|
||||
|
||||
clean-stack@^2.0.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
|
||||
|
@ -1706,6 +1716,11 @@ punycode@^2.1.0:
|
|||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec"
|
||||
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:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.2.0.tgz#0425a2768d8f23bad70ca4b90461fa2f1213e1b2"
|
||||
|
|
Loading…
Reference in a new issue