mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-12-22 19:01:27 +00:00
Merge branch 'main' into add_int_visibility
This commit is contained in:
commit
a4d56f1133
22 changed files with 41 additions and 145 deletions
|
@ -1,5 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Remove the old bindings
|
||||
pushd ../lemmy/crates
|
||||
rm -rf **/bindings
|
||||
popd
|
||||
|
||||
# First re-generate the types by running cargo test on lemmy
|
||||
pushd ../lemmy/scripts
|
||||
./test.sh
|
||||
|
@ -24,5 +29,5 @@ find src/types -type f -name '*.ts' -exec sed -i 's/bigint/\/* integer *\/ numbe
|
|||
|
||||
node putTypesInIndex.js
|
||||
|
||||
prettier -w src/types
|
||||
prettier -w src/types src/index.ts
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "lemmy-js-client",
|
||||
"version": "0.19.0-rc.9",
|
||||
"version": "0.19.0-rc.12",
|
||||
"description": "A javascript / typescript client for Lemmy",
|
||||
"repository": "https://github.com/LemmyNet/lemmy-js-client",
|
||||
"license": "AGPL-3.0",
|
||||
|
|
75
src/http.ts
75
src/http.ts
|
@ -48,15 +48,12 @@ import { EditPrivateMessage } from "./types/EditPrivateMessage";
|
|||
import { EditSite } from "./types/EditSite";
|
||||
import { FeaturePost } from "./types/FeaturePost";
|
||||
import { FollowCommunity } from "./types/FollowCommunity";
|
||||
import { GetBannedPersons } from "./types/GetBannedPersons";
|
||||
import { GetCaptcha } from "./types/GetCaptcha";
|
||||
import { GetCaptchaResponse } from "./types/GetCaptchaResponse";
|
||||
import { GetComment } from "./types/GetComment";
|
||||
import { GetComments } from "./types/GetComments";
|
||||
import { GetCommentsResponse } from "./types/GetCommentsResponse";
|
||||
import { GetCommunity } from "./types/GetCommunity";
|
||||
import { GetCommunityResponse } from "./types/GetCommunityResponse";
|
||||
import { GetFederatedInstances } from "./types/GetFederatedInstances";
|
||||
import { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse";
|
||||
import { GetModlog } from "./types/GetModlog";
|
||||
import { GetModlogResponse } from "./types/GetModlogResponse";
|
||||
|
@ -73,15 +70,11 @@ import { GetReplies } from "./types/GetReplies";
|
|||
import { GetRepliesResponse } from "./types/GetRepliesResponse";
|
||||
import { GetReportCount } from "./types/GetReportCount";
|
||||
import { GetReportCountResponse } from "./types/GetReportCountResponse";
|
||||
import { GetSite } from "./types/GetSite";
|
||||
import { GetSiteMetadata } from "./types/GetSiteMetadata";
|
||||
import { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse";
|
||||
import { GetSiteResponse } from "./types/GetSiteResponse";
|
||||
import { GetUnreadCount } from "./types/GetUnreadCount";
|
||||
import { GetUnreadCountResponse } from "./types/GetUnreadCountResponse";
|
||||
import { GetUnreadRegistrationApplicationCount } from "./types/GetUnreadRegistrationApplicationCount";
|
||||
import { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse";
|
||||
import { LeaveAdmin } from "./types/LeaveAdmin";
|
||||
import { ListCommentReports } from "./types/ListCommentReports";
|
||||
import { ListCommentReportsResponse } from "./types/ListCommentReportsResponse";
|
||||
import { ListCommunities } from "./types/ListCommunities";
|
||||
|
@ -95,7 +88,6 @@ import { ListRegistrationApplicationsResponse } from "./types/ListRegistrationAp
|
|||
import { LockPost } from "./types/LockPost";
|
||||
import { Login } from "./types/Login";
|
||||
import { LoginResponse } from "./types/LoginResponse";
|
||||
import { MarkAllAsRead } from "./types/MarkAllAsRead";
|
||||
import { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
|
||||
import { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead";
|
||||
import { MarkPostAsRead } from "./types/MarkPostAsRead";
|
||||
|
@ -134,9 +126,9 @@ import { TransferCommunity } from "./types/TransferCommunity";
|
|||
import { VerifyEmail } from "./types/VerifyEmail";
|
||||
import { VerifyEmailResponse } from "./types/VerifyEmailResponse";
|
||||
import { UploadImage, UploadImageResponse, VERSION } from "./types/others";
|
||||
import { HideCommunity } from "./types/HideCommunity";
|
||||
import { BlockInstance } from "./types/BlockInstance";
|
||||
import { BlockInstanceResponse } from "./types/BlockInstanceResponse";
|
||||
import { HideCommunity } from "./types/HideCommunity";
|
||||
|
||||
enum HttpType {
|
||||
Get = "GET",
|
||||
|
@ -181,8 +173,8 @@ export class LemmyHttp {
|
|||
*
|
||||
* `HTTP.GET /site`
|
||||
*/
|
||||
getSite(form: GetSite = {}) {
|
||||
return this.#wrapper<GetSite, GetSiteResponse>(HttpType.Get, "/site", form);
|
||||
getSite() {
|
||||
return this.#wrapper<object, GetSiteResponse>(HttpType.Get, "/site", {});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -212,11 +204,11 @@ export class LemmyHttp {
|
|||
*
|
||||
* `HTTP.POST /user/leave_admin`
|
||||
*/
|
||||
leaveAdmin(form: LeaveAdmin) {
|
||||
return this.#wrapper<LeaveAdmin, GetSiteResponse>(
|
||||
leaveAdmin() {
|
||||
return this.#wrapper<object, GetSiteResponse>(
|
||||
HttpType.Post,
|
||||
"/user/leave_admin",
|
||||
form,
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -964,11 +956,11 @@ export class LemmyHttp {
|
|||
*
|
||||
* `HTTP.GET /user/banned`
|
||||
*/
|
||||
getBannedPersons(form: GetBannedPersons) {
|
||||
return this.#wrapper<GetBannedPersons, BannedPersonsResponse>(
|
||||
getBannedPersons() {
|
||||
return this.#wrapper<object, BannedPersonsResponse>(
|
||||
HttpType.Get,
|
||||
"/user/banned",
|
||||
form,
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -990,11 +982,11 @@ export class LemmyHttp {
|
|||
*
|
||||
* `HTTP.GET /user/get_captcha`
|
||||
*/
|
||||
getCaptcha(form: GetCaptcha = {}) {
|
||||
return this.#wrapper<GetCaptcha, GetCaptchaResponse>(
|
||||
getCaptcha() {
|
||||
return this.#wrapper<object, GetCaptchaResponse>(
|
||||
HttpType.Get,
|
||||
"/user/get_captcha",
|
||||
form,
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1042,11 +1034,11 @@ export class LemmyHttp {
|
|||
*
|
||||
* `HTTP.POST /user/mark_all_as_read`
|
||||
*/
|
||||
markAllAsRead(form: MarkAllAsRead) {
|
||||
return this.#wrapper<MarkAllAsRead, GetRepliesResponse>(
|
||||
markAllAsRead() {
|
||||
return this.#wrapper<object, GetRepliesResponse>(
|
||||
HttpType.Post,
|
||||
"/user/mark_all_as_read",
|
||||
form,
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1094,11 +1086,11 @@ export class LemmyHttp {
|
|||
*
|
||||
* `HTTP.GET /user/unread_count`
|
||||
*/
|
||||
getUnreadCount(form: GetUnreadCount) {
|
||||
return this.#wrapper<GetUnreadCount, GetUnreadCountResponse>(
|
||||
getUnreadCount() {
|
||||
return this.#wrapper<object, GetUnreadCountResponse>(
|
||||
HttpType.Get,
|
||||
"/user/unread_count",
|
||||
form,
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1133,13 +1125,12 @@ export class LemmyHttp {
|
|||
*
|
||||
* `HTTP.GET /admin/registration_application/count`
|
||||
*/
|
||||
getUnreadRegistrationApplicationCount(
|
||||
form: GetUnreadRegistrationApplicationCount,
|
||||
) {
|
||||
return this.#wrapper<
|
||||
GetUnreadRegistrationApplicationCount,
|
||||
GetUnreadRegistrationApplicationCountResponse
|
||||
>(HttpType.Get, "/admin/registration_application/count", form);
|
||||
getUnreadRegistrationApplicationCount() {
|
||||
return this.#wrapper<object, GetUnreadRegistrationApplicationCountResponse>(
|
||||
HttpType.Get,
|
||||
"/admin/registration_application/count",
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1262,18 +1253,18 @@ export class LemmyHttp {
|
|||
*
|
||||
* `HTTP.Get /federated_instances`
|
||||
*/
|
||||
getFederatedInstances(form: GetFederatedInstances = {}) {
|
||||
return this.#wrapper<GetFederatedInstances, GetFederatedInstancesResponse>(
|
||||
getFederatedInstances() {
|
||||
return this.#wrapper<object, GetFederatedInstancesResponse>(
|
||||
HttpType.Get,
|
||||
"/federated_instances",
|
||||
form,
|
||||
{},
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Block an instance
|
||||
* Block an instance.
|
||||
*
|
||||
* `HTTP.POST /site/block`
|
||||
* `HTTP.Post /site/block`
|
||||
*/
|
||||
blockInstance(form: BlockInstance) {
|
||||
return this.#wrapper<BlockInstance, BlockInstanceResponse>(
|
||||
|
@ -1292,13 +1283,13 @@ export class LemmyHttp {
|
|||
}: UploadImage): Promise<UploadImageResponse> {
|
||||
const formData = createFormData(image);
|
||||
|
||||
// If jwt cookie not already set by browser, set it with passed in auth
|
||||
// If auth cookie not already set by browser, set it with passed in auth
|
||||
const headers = {} as any;
|
||||
if (
|
||||
!globalThis?.document?.cookie?.includes("jwt=") &&
|
||||
!this.#headers?.Cookie?.includes("jwt=")
|
||||
!globalThis?.document?.cookie?.includes("auth=") &&
|
||||
!this.#headers?.Cookie?.includes("auth=")
|
||||
) {
|
||||
headers.Cookie = `jwt=${auth}`;
|
||||
headers.Cookie = `auth=${auth}`;
|
||||
}
|
||||
|
||||
let url: string | undefined = undefined;
|
||||
|
|
13
src/index.ts
13
src/index.ts
|
@ -45,8 +45,6 @@ export { CommunityBlockId } from "./types/CommunityBlockId";
|
|||
export { CommunityBlockView } from "./types/CommunityBlockView";
|
||||
export { CommunityFollowerView } from "./types/CommunityFollowerView";
|
||||
export { CommunityId } from "./types/CommunityId";
|
||||
export { CommunityJoin } from "./types/CommunityJoin";
|
||||
export { CommunityJoinResponse } from "./types/CommunityJoinResponse";
|
||||
export { CommunityModeratorView } from "./types/CommunityModeratorView";
|
||||
export { CommunityResponse } from "./types/CommunityResponse";
|
||||
export { CommunityView } from "./types/CommunityView";
|
||||
|
@ -93,7 +91,6 @@ export { GetComments } from "./types/GetComments";
|
|||
export { GetCommentsResponse } from "./types/GetCommentsResponse";
|
||||
export { GetCommunity } from "./types/GetCommunity";
|
||||
export { GetCommunityResponse } from "./types/GetCommunityResponse";
|
||||
export { GetFederatedInstances } from "./types/GetFederatedInstances";
|
||||
export { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse";
|
||||
export { GetModlog } from "./types/GetModlog";
|
||||
export { GetModlogResponse } from "./types/GetModlogResponse";
|
||||
|
@ -110,13 +107,10 @@ export { GetReplies } from "./types/GetReplies";
|
|||
export { GetRepliesResponse } from "./types/GetRepliesResponse";
|
||||
export { GetReportCount } from "./types/GetReportCount";
|
||||
export { GetReportCountResponse } from "./types/GetReportCountResponse";
|
||||
export { GetSite } from "./types/GetSite";
|
||||
export { GetSiteMetadata } from "./types/GetSiteMetadata";
|
||||
export { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse";
|
||||
export { GetSiteResponse } from "./types/GetSiteResponse";
|
||||
export { GetUnreadCount } from "./types/GetUnreadCount";
|
||||
export { GetUnreadCountResponse } from "./types/GetUnreadCountResponse";
|
||||
export { GetUnreadRegistrationApplicationCount } from "./types/GetUnreadRegistrationApplicationCount";
|
||||
export { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse";
|
||||
export { HideCommunity } from "./types/HideCommunity";
|
||||
export { ImageUpload } from "./types/ImageUpload";
|
||||
|
@ -126,7 +120,6 @@ export { InstanceBlockView } from "./types/InstanceBlockView";
|
|||
export { InstanceId } from "./types/InstanceId";
|
||||
export { Language } from "./types/Language";
|
||||
export { LanguageId } from "./types/LanguageId";
|
||||
export { LeaveAdmin } from "./types/LeaveAdmin";
|
||||
export { LemmyErrorType } from "./types/LemmyErrorType";
|
||||
export { ListCommentReports } from "./types/ListCommentReports";
|
||||
export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse";
|
||||
|
@ -148,7 +141,6 @@ export { LocalUserView } from "./types/LocalUserView";
|
|||
export { LockPost } from "./types/LockPost";
|
||||
export { Login } from "./types/Login";
|
||||
export { LoginResponse } from "./types/LoginResponse";
|
||||
export { MarkAllAsRead } from "./types/MarkAllAsRead";
|
||||
export { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
|
||||
export { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead";
|
||||
export { MarkPostAsRead } from "./types/MarkPostAsRead";
|
||||
|
@ -165,8 +157,6 @@ export { ModFeaturePost } from "./types/ModFeaturePost";
|
|||
export { ModFeaturePostView } from "./types/ModFeaturePostView";
|
||||
export { ModHideCommunity } from "./types/ModHideCommunity";
|
||||
export { ModHideCommunityView } from "./types/ModHideCommunityView";
|
||||
export { ModJoin } from "./types/ModJoin";
|
||||
export { ModJoinResponse } from "./types/ModJoinResponse";
|
||||
export { ModLockPost } from "./types/ModLockPost";
|
||||
export { ModLockPostView } from "./types/ModLockPostView";
|
||||
export { ModRemoveComment } from "./types/ModRemoveComment";
|
||||
|
@ -199,10 +189,7 @@ export { Post } from "./types/Post";
|
|||
export { PostAggregates } from "./types/PostAggregates";
|
||||
export { PostFeatureType } from "./types/PostFeatureType";
|
||||
export { PostId } from "./types/PostId";
|
||||
export { PostJoin } from "./types/PostJoin";
|
||||
export { PostJoinResponse } from "./types/PostJoinResponse";
|
||||
export { PostListingMode } from "./types/PostListingMode";
|
||||
export { PostOrCommentId } from "./types/PostOrCommentId";
|
||||
export { PostReport } from "./types/PostReport";
|
||||
export { PostReportId } from "./types/PostReportId";
|
||||
export { PostReportResponse } from "./types/PostReportResponse";
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { CommunityId } from "./CommunityId";
|
||||
|
||||
export interface CommunityJoin {
|
||||
community_id: CommunityId;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface CommunityJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface GetBannedPersons {
|
||||
auth: string;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface GetCaptcha {
|
||||
auth?: string;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface GetFederatedInstances {
|
||||
auth?: string;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface GetSite {
|
||||
auth?: string;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface GetUnreadCount {
|
||||
auth: string;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface GetUnreadRegistrationApplicationCount {
|
||||
auth: string;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface LeaveAdmin {
|
||||
auth: string;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface MarkAllAsRead {
|
||||
auth: string;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { CommunityId } from "./CommunityId";
|
||||
|
||||
export interface ModJoin {
|
||||
community_id: CommunityId;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface ModJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { PostId } from "./PostId";
|
||||
|
||||
export interface PostJoin {
|
||||
post_id: PostId;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface PostJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { CommentId } from "./CommentId";
|
||||
import type { PostId } from "./PostId";
|
||||
|
||||
export type PostOrCommentId = { Post: PostId } | { Comment: CommentId };
|
|
@ -25,6 +25,7 @@ export interface SaveUserSettings {
|
|||
show_read_posts?: boolean;
|
||||
show_new_post_notifs?: boolean;
|
||||
discussion_languages?: Array<LanguageId>;
|
||||
generate_totp_2fa?: boolean;
|
||||
open_links_in_new_tab?: boolean;
|
||||
infinite_scroll_enabled?: boolean;
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface UserJoin {
|
||||
auth: string;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export interface UserJoinResponse {
|
||||
joined: boolean;
|
||||
}
|
Loading…
Reference in a new issue