mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-12-22 19:01:27 +00:00
Adding private instance related endpoints. (#38)
* Adding private instance related endpoints.
* Running prettier.
* v0.15.0-rc.1
* v0.15.0-rc.2
* Remove VerifyEmailResponse
* v0.15.0-rc.3
* Revert "Remove VerifyEmailResponse"
This reverts commit 49713c23c6
.
* Add optional auth to modlog.
* v0.15.0-rc.6
This commit is contained in:
parent
5e4ff291c5
commit
c4827a62c0
8 changed files with 185 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "lemmy-js-client",
|
||||
"description": "A javascript / typescript client for Lemmy",
|
||||
"version": "0.14.0-rc.1",
|
||||
"version": "0.15.0-rc.6",
|
||||
"author": "Dessalines <tyhou13@gmx.com>",
|
||||
"license": "AGPL-3.0",
|
||||
"main": "./dist/index.js",
|
||||
|
|
57
src/http.ts
57
src/http.ts
|
@ -45,6 +45,7 @@ import {
|
|||
ChangePassword,
|
||||
CreatePrivateMessage,
|
||||
DeleteAccount,
|
||||
DeleteAccountResponse,
|
||||
DeletePrivateMessage,
|
||||
EditPrivateMessage,
|
||||
GetCaptchaResponse,
|
||||
|
@ -72,6 +73,8 @@ import {
|
|||
PrivateMessagesResponse,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
VerifyEmail,
|
||||
VerifyEmailResponse,
|
||||
} from "./interfaces/api/person";
|
||||
import {
|
||||
CreatePost,
|
||||
|
@ -96,6 +99,7 @@ import {
|
|||
StickyPost,
|
||||
} from "./interfaces/api/post";
|
||||
import {
|
||||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetModlog,
|
||||
|
@ -104,6 +108,11 @@ import {
|
|||
GetSiteConfig,
|
||||
GetSiteConfigResponse,
|
||||
GetSiteResponse,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
GetUnreadRegistrationApplicationCountResponse,
|
||||
ListRegistrationApplications,
|
||||
ListRegistrationApplicationsResponse,
|
||||
RegistrationApplicationResponse,
|
||||
ResolveObject,
|
||||
ResolveObjectResponse,
|
||||
SaveSiteConfig,
|
||||
|
@ -592,7 +601,7 @@ export class LemmyHttp {
|
|||
/**
|
||||
* Delete your account.
|
||||
*/
|
||||
async deleteAccount(form: DeleteAccount): Promise<LoginResponse> {
|
||||
async deleteAccount(form: DeleteAccount): Promise<DeleteAccountResponse> {
|
||||
return this.wrapper(HttpType.Post, "/user/delete_account", form);
|
||||
}
|
||||
|
||||
|
@ -645,6 +654,13 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Get, "/user/unread_count", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify your email
|
||||
*/
|
||||
async verifyEmail(form: VerifyEmail): Promise<VerifyEmailResponse> {
|
||||
return this.wrapper(HttpType.Post, "/user/verify_email", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an admin to your site.
|
||||
*/
|
||||
|
@ -652,6 +668,45 @@ export class LemmyHttp {
|
|||
return this.wrapper(HttpType.Post, "/admin/add", form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unread registration applications count.
|
||||
*/
|
||||
async getUnreadRegistrationApplicationCount(
|
||||
form: GetUnreadRegistrationApplicationCount
|
||||
): Promise<GetUnreadRegistrationApplicationCountResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Get,
|
||||
"/admin/registration_application/count",
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the unread registration applications.
|
||||
*/
|
||||
async listRegistrationApplications(
|
||||
form: ListRegistrationApplications
|
||||
): Promise<ListRegistrationApplicationsResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Get,
|
||||
"/admin/registration_application/list",
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a registration application
|
||||
*/
|
||||
async approveRegistrationApplication(
|
||||
form: ApproveRegistrationApplication
|
||||
): Promise<RegistrationApplicationResponse> {
|
||||
return this.wrapper(
|
||||
HttpType.Put,
|
||||
"/admin/registration_application/approve",
|
||||
form
|
||||
);
|
||||
}
|
||||
|
||||
private buildFullUrl(endpoint: string): string {
|
||||
return `${this.apiUrl}${endpoint}`;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@ export interface Login {
|
|||
*/
|
||||
export interface Register {
|
||||
username: string;
|
||||
/**
|
||||
* Email is mandatory if email verification is enabled on the server
|
||||
*/
|
||||
email?: string;
|
||||
password: string;
|
||||
password_verify: string;
|
||||
|
@ -29,6 +32,10 @@ export interface Register {
|
|||
captcha_uuid?: string;
|
||||
captcha_answer?: string;
|
||||
honeypot?: string;
|
||||
/**
|
||||
* An answer is mandatory if require application is enabled on the server
|
||||
*/
|
||||
answer?: string;
|
||||
}
|
||||
|
||||
export interface GetCaptcha {}
|
||||
|
@ -106,7 +113,12 @@ export interface ChangePassword {
|
|||
* The `jwt` string should be stored and used anywhere `auth` is called for.
|
||||
*/
|
||||
export interface LoginResponse {
|
||||
jwt: string;
|
||||
/**
|
||||
* This is None in response to `Register` if email verification is enabled, or the server requires registration applications.
|
||||
*/
|
||||
jwt?: string;
|
||||
verify_email_sent: boolean;
|
||||
registration_created: boolean;
|
||||
}
|
||||
|
||||
export interface GetPersonDetails {
|
||||
|
@ -210,6 +222,8 @@ export interface DeleteAccount {
|
|||
auth: string;
|
||||
}
|
||||
|
||||
export interface DeleteAccountResponse {}
|
||||
|
||||
export interface PasswordReset {
|
||||
email: string;
|
||||
}
|
||||
|
@ -285,6 +299,12 @@ export interface GetUnreadCountResponse {
|
|||
private_messages: number;
|
||||
}
|
||||
|
||||
export interface VerifyEmail {
|
||||
token: string;
|
||||
}
|
||||
|
||||
export interface VerifyEmailResponse {}
|
||||
|
||||
export interface BlockPerson {
|
||||
person_id: number;
|
||||
block: boolean;
|
||||
|
|
|
@ -18,6 +18,7 @@ import {
|
|||
PersonBlockView,
|
||||
PersonViewSafe,
|
||||
PostView,
|
||||
RegistrationApplicationView,
|
||||
SiteView,
|
||||
} from "../views";
|
||||
|
||||
|
@ -66,6 +67,7 @@ export interface GetModlog {
|
|||
community_id?: number;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth?: string;
|
||||
}
|
||||
|
||||
export interface GetModlogResponse {
|
||||
|
@ -91,6 +93,10 @@ export interface CreateSite {
|
|||
open_registration?: boolean;
|
||||
enable_nsfw?: boolean;
|
||||
community_creation_admin_only?: boolean;
|
||||
require_email_verification?: boolean;
|
||||
require_application?: boolean;
|
||||
application_question?: string;
|
||||
private_instance?: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -104,6 +110,10 @@ export interface EditSite {
|
|||
open_registration?: boolean;
|
||||
enable_nsfw?: boolean;
|
||||
community_creation_admin_only?: boolean;
|
||||
require_email_verification?: boolean;
|
||||
require_application?: boolean;
|
||||
application_question?: string;
|
||||
private_instance?: boolean;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
|
@ -177,3 +187,36 @@ export interface ResolveObjectResponse {
|
|||
community?: CommunityView;
|
||||
person?: PersonViewSafe;
|
||||
}
|
||||
|
||||
export interface ListRegistrationApplications {
|
||||
/**
|
||||
* Only shows the unread applications (IE those without an admin actor)
|
||||
*/
|
||||
unread_only?: boolean;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface ListRegistrationApplicationsResponse {
|
||||
registration_applications: RegistrationApplicationView[];
|
||||
}
|
||||
|
||||
export interface ApproveRegistrationApplication {
|
||||
id: number;
|
||||
approve: boolean;
|
||||
deny_reason?: string;
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface RegistrationApplicationResponse {
|
||||
registration_application: RegistrationApplicationView;
|
||||
}
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCount {
|
||||
auth: string;
|
||||
}
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCountResponse {
|
||||
registration_applications: number;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@ export enum UserOperation {
|
|||
EditSite,
|
||||
GetSite,
|
||||
AddAdmin,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
ListRegistrationApplications,
|
||||
ApproveRegistrationApplication,
|
||||
BanPerson,
|
||||
Search,
|
||||
ResolveObject,
|
||||
|
@ -75,6 +78,7 @@ export enum UserOperation {
|
|||
ListPostReports,
|
||||
GetReportCount,
|
||||
GetUnreadCount,
|
||||
VerifyEmail,
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,6 +13,8 @@ export interface LocalUserSettings {
|
|||
show_scores: boolean;
|
||||
show_read_posts: boolean;
|
||||
show_new_post_notifs: boolean;
|
||||
email_verified: boolean;
|
||||
accepted_application: boolean;
|
||||
}
|
||||
|
||||
export interface PersonSafe {
|
||||
|
@ -39,16 +41,20 @@ export interface Site {
|
|||
id: number;
|
||||
name: string;
|
||||
sidebar?: string;
|
||||
description?: string;
|
||||
creator_id: number;
|
||||
published: string;
|
||||
updated?: string;
|
||||
enable_downvotes: boolean;
|
||||
open_registration: boolean;
|
||||
enable_nsfw: boolean;
|
||||
community_creation_admin_only: boolean;
|
||||
icon?: string;
|
||||
banner?: string;
|
||||
description?: string;
|
||||
community_creation_admin_only: boolean;
|
||||
require_email_verification: boolean;
|
||||
require_application: boolean;
|
||||
application_question?: string;
|
||||
private_instance: boolean;
|
||||
}
|
||||
|
||||
export interface PrivateMessage {
|
||||
|
@ -248,3 +254,12 @@ export interface PersonMention {
|
|||
read: boolean;
|
||||
published: string;
|
||||
}
|
||||
|
||||
export interface RegistrationApplication {
|
||||
id: number;
|
||||
local_user_id: number;
|
||||
answer: string;
|
||||
admin_id?: number;
|
||||
deny_reason?: string;
|
||||
published: string;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import {
|
|||
Post,
|
||||
PostReport,
|
||||
PrivateMessage,
|
||||
RegistrationApplication,
|
||||
Site,
|
||||
} from "./source";
|
||||
|
||||
|
@ -218,3 +219,10 @@ export interface CommunityView {
|
|||
blocked: boolean;
|
||||
counts: CommunityAggregates;
|
||||
}
|
||||
|
||||
export interface RegistrationApplicationView {
|
||||
registration_application: RegistrationApplication;
|
||||
creator_local_user: LocalUserSettings;
|
||||
creator: PersonSafe;
|
||||
admin?: PersonSafe;
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import {
|
|||
PasswordReset,
|
||||
Register,
|
||||
SaveUserSettings,
|
||||
VerifyEmail,
|
||||
} from "./interfaces/api/person";
|
||||
import {
|
||||
CreatePost,
|
||||
|
@ -65,11 +66,14 @@ import {
|
|||
StickyPost,
|
||||
} from "./interfaces/api/post";
|
||||
import {
|
||||
ApproveRegistrationApplication,
|
||||
CreateSite,
|
||||
EditSite,
|
||||
GetModlog,
|
||||
GetSite,
|
||||
GetSiteConfig,
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
ListRegistrationApplications,
|
||||
ResolveObject,
|
||||
SaveSiteConfig,
|
||||
Search,
|
||||
|
@ -404,6 +408,29 @@ export class LemmyWebsocket {
|
|||
return wrapper(UserOperation.AddAdmin, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unread registration applications count.
|
||||
*/
|
||||
getUnreadRegistrationApplicationCount(
|
||||
form: GetUnreadRegistrationApplicationCount
|
||||
) {
|
||||
return wrapper(UserOperation.GetUnreadRegistrationApplicationCount, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* List the unread registration applications.
|
||||
*/
|
||||
listRegistrationApplications(form: ListRegistrationApplications) {
|
||||
return wrapper(UserOperation.ListRegistrationApplications, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approve a registration application
|
||||
*/
|
||||
approveRegistrationApplication(form: ApproveRegistrationApplication) {
|
||||
return wrapper(UserOperation.ApproveRegistrationApplication, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the details for a person.
|
||||
*/
|
||||
|
@ -515,6 +542,14 @@ export class LemmyWebsocket {
|
|||
getUnreadCount(form: GetUnreadCount) {
|
||||
return wrapper(UserOperation.GetUnreadCount, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify your email
|
||||
*/
|
||||
verifyEmail(form: VerifyEmail) {
|
||||
return wrapper(UserOperation.VerifyEmail, form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete your account.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue