Merge branch 'main' into add_int_visibility

This commit is contained in:
Maarten Vercruysse 2023-09-26 13:24:06 +02:00 committed by GitHub
commit a4d56f1133
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 41 additions and 145 deletions

View file

@ -1,5 +1,10 @@
#!/bin/bash #!/bin/bash
# Remove the old bindings
pushd ../lemmy/crates
rm -rf **/bindings
popd
# First re-generate the types by running cargo test on lemmy # First re-generate the types by running cargo test on lemmy
pushd ../lemmy/scripts pushd ../lemmy/scripts
./test.sh ./test.sh
@ -24,5 +29,5 @@ find src/types -type f -name '*.ts' -exec sed -i 's/bigint/\/* integer *\/ numbe
node putTypesInIndex.js node putTypesInIndex.js
prettier -w src/types prettier -w src/types src/index.ts

View file

@ -1,6 +1,6 @@
{ {
"name": "lemmy-js-client", "name": "lemmy-js-client",
"version": "0.19.0-rc.9", "version": "0.19.0-rc.12",
"description": "A javascript / typescript client for Lemmy", "description": "A javascript / typescript client for Lemmy",
"repository": "https://github.com/LemmyNet/lemmy-js-client", "repository": "https://github.com/LemmyNet/lemmy-js-client",
"license": "AGPL-3.0", "license": "AGPL-3.0",

View file

@ -48,15 +48,12 @@ import { EditPrivateMessage } from "./types/EditPrivateMessage";
import { EditSite } from "./types/EditSite"; import { EditSite } from "./types/EditSite";
import { FeaturePost } from "./types/FeaturePost"; import { FeaturePost } from "./types/FeaturePost";
import { FollowCommunity } from "./types/FollowCommunity"; import { FollowCommunity } from "./types/FollowCommunity";
import { GetBannedPersons } from "./types/GetBannedPersons";
import { GetCaptcha } from "./types/GetCaptcha";
import { GetCaptchaResponse } from "./types/GetCaptchaResponse"; import { GetCaptchaResponse } from "./types/GetCaptchaResponse";
import { GetComment } from "./types/GetComment"; import { GetComment } from "./types/GetComment";
import { GetComments } from "./types/GetComments"; import { GetComments } from "./types/GetComments";
import { GetCommentsResponse } from "./types/GetCommentsResponse"; import { GetCommentsResponse } from "./types/GetCommentsResponse";
import { GetCommunity } from "./types/GetCommunity"; import { GetCommunity } from "./types/GetCommunity";
import { GetCommunityResponse } from "./types/GetCommunityResponse"; import { GetCommunityResponse } from "./types/GetCommunityResponse";
import { GetFederatedInstances } from "./types/GetFederatedInstances";
import { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse"; import { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse";
import { GetModlog } from "./types/GetModlog"; import { GetModlog } from "./types/GetModlog";
import { GetModlogResponse } from "./types/GetModlogResponse"; import { GetModlogResponse } from "./types/GetModlogResponse";
@ -73,15 +70,11 @@ import { GetReplies } from "./types/GetReplies";
import { GetRepliesResponse } from "./types/GetRepliesResponse"; import { GetRepliesResponse } from "./types/GetRepliesResponse";
import { GetReportCount } from "./types/GetReportCount"; import { GetReportCount } from "./types/GetReportCount";
import { GetReportCountResponse } from "./types/GetReportCountResponse"; import { GetReportCountResponse } from "./types/GetReportCountResponse";
import { GetSite } from "./types/GetSite";
import { GetSiteMetadata } from "./types/GetSiteMetadata"; import { GetSiteMetadata } from "./types/GetSiteMetadata";
import { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse"; import { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse";
import { GetSiteResponse } from "./types/GetSiteResponse"; import { GetSiteResponse } from "./types/GetSiteResponse";
import { GetUnreadCount } from "./types/GetUnreadCount";
import { GetUnreadCountResponse } from "./types/GetUnreadCountResponse"; import { GetUnreadCountResponse } from "./types/GetUnreadCountResponse";
import { GetUnreadRegistrationApplicationCount } from "./types/GetUnreadRegistrationApplicationCount";
import { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse"; import { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse";
import { LeaveAdmin } from "./types/LeaveAdmin";
import { ListCommentReports } from "./types/ListCommentReports"; import { ListCommentReports } from "./types/ListCommentReports";
import { ListCommentReportsResponse } from "./types/ListCommentReportsResponse"; import { ListCommentReportsResponse } from "./types/ListCommentReportsResponse";
import { ListCommunities } from "./types/ListCommunities"; import { ListCommunities } from "./types/ListCommunities";
@ -95,7 +88,6 @@ import { ListRegistrationApplicationsResponse } from "./types/ListRegistrationAp
import { LockPost } from "./types/LockPost"; import { LockPost } from "./types/LockPost";
import { Login } from "./types/Login"; import { Login } from "./types/Login";
import { LoginResponse } from "./types/LoginResponse"; import { LoginResponse } from "./types/LoginResponse";
import { MarkAllAsRead } from "./types/MarkAllAsRead";
import { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead"; import { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
import { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead"; import { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead";
import { MarkPostAsRead } from "./types/MarkPostAsRead"; import { MarkPostAsRead } from "./types/MarkPostAsRead";
@ -134,9 +126,9 @@ import { TransferCommunity } from "./types/TransferCommunity";
import { VerifyEmail } from "./types/VerifyEmail"; import { VerifyEmail } from "./types/VerifyEmail";
import { VerifyEmailResponse } from "./types/VerifyEmailResponse"; import { VerifyEmailResponse } from "./types/VerifyEmailResponse";
import { UploadImage, UploadImageResponse, VERSION } from "./types/others"; import { UploadImage, UploadImageResponse, VERSION } from "./types/others";
import { HideCommunity } from "./types/HideCommunity";
import { BlockInstance } from "./types/BlockInstance"; import { BlockInstance } from "./types/BlockInstance";
import { BlockInstanceResponse } from "./types/BlockInstanceResponse"; import { BlockInstanceResponse } from "./types/BlockInstanceResponse";
import { HideCommunity } from "./types/HideCommunity";
enum HttpType { enum HttpType {
Get = "GET", Get = "GET",
@ -181,8 +173,8 @@ export class LemmyHttp {
* *
* `HTTP.GET /site` * `HTTP.GET /site`
*/ */
getSite(form: GetSite = {}) { getSite() {
return this.#wrapper<GetSite, GetSiteResponse>(HttpType.Get, "/site", form); return this.#wrapper<object, GetSiteResponse>(HttpType.Get, "/site", {});
} }
/** /**
@ -212,11 +204,11 @@ export class LemmyHttp {
* *
* `HTTP.POST /user/leave_admin` * `HTTP.POST /user/leave_admin`
*/ */
leaveAdmin(form: LeaveAdmin) { leaveAdmin() {
return this.#wrapper<LeaveAdmin, GetSiteResponse>( return this.#wrapper<object, GetSiteResponse>(
HttpType.Post, HttpType.Post,
"/user/leave_admin", "/user/leave_admin",
form, {},
); );
} }
@ -964,11 +956,11 @@ export class LemmyHttp {
* *
* `HTTP.GET /user/banned` * `HTTP.GET /user/banned`
*/ */
getBannedPersons(form: GetBannedPersons) { getBannedPersons() {
return this.#wrapper<GetBannedPersons, BannedPersonsResponse>( return this.#wrapper<object, BannedPersonsResponse>(
HttpType.Get, HttpType.Get,
"/user/banned", "/user/banned",
form, {},
); );
} }
@ -990,11 +982,11 @@ export class LemmyHttp {
* *
* `HTTP.GET /user/get_captcha` * `HTTP.GET /user/get_captcha`
*/ */
getCaptcha(form: GetCaptcha = {}) { getCaptcha() {
return this.#wrapper<GetCaptcha, GetCaptchaResponse>( return this.#wrapper<object, GetCaptchaResponse>(
HttpType.Get, HttpType.Get,
"/user/get_captcha", "/user/get_captcha",
form, {},
); );
} }
@ -1042,11 +1034,11 @@ export class LemmyHttp {
* *
* `HTTP.POST /user/mark_all_as_read` * `HTTP.POST /user/mark_all_as_read`
*/ */
markAllAsRead(form: MarkAllAsRead) { markAllAsRead() {
return this.#wrapper<MarkAllAsRead, GetRepliesResponse>( return this.#wrapper<object, GetRepliesResponse>(
HttpType.Post, HttpType.Post,
"/user/mark_all_as_read", "/user/mark_all_as_read",
form, {},
); );
} }
@ -1094,11 +1086,11 @@ export class LemmyHttp {
* *
* `HTTP.GET /user/unread_count` * `HTTP.GET /user/unread_count`
*/ */
getUnreadCount(form: GetUnreadCount) { getUnreadCount() {
return this.#wrapper<GetUnreadCount, GetUnreadCountResponse>( return this.#wrapper<object, GetUnreadCountResponse>(
HttpType.Get, HttpType.Get,
"/user/unread_count", "/user/unread_count",
form, {},
); );
} }
@ -1133,13 +1125,12 @@ export class LemmyHttp {
* *
* `HTTP.GET /admin/registration_application/count` * `HTTP.GET /admin/registration_application/count`
*/ */
getUnreadRegistrationApplicationCount( getUnreadRegistrationApplicationCount() {
form: GetUnreadRegistrationApplicationCount, return this.#wrapper<object, GetUnreadRegistrationApplicationCountResponse>(
) { HttpType.Get,
return this.#wrapper< "/admin/registration_application/count",
GetUnreadRegistrationApplicationCount, {},
GetUnreadRegistrationApplicationCountResponse );
>(HttpType.Get, "/admin/registration_application/count", form);
} }
/** /**
@ -1262,18 +1253,18 @@ export class LemmyHttp {
* *
* `HTTP.Get /federated_instances` * `HTTP.Get /federated_instances`
*/ */
getFederatedInstances(form: GetFederatedInstances = {}) { getFederatedInstances() {
return this.#wrapper<GetFederatedInstances, GetFederatedInstancesResponse>( return this.#wrapper<object, GetFederatedInstancesResponse>(
HttpType.Get, HttpType.Get,
"/federated_instances", "/federated_instances",
form, {},
); );
} }
/** /**
* Block an instance * Block an instance.
* *
* `HTTP.POST /site/block` * `HTTP.Post /site/block`
*/ */
blockInstance(form: BlockInstance) { blockInstance(form: BlockInstance) {
return this.#wrapper<BlockInstance, BlockInstanceResponse>( return this.#wrapper<BlockInstance, BlockInstanceResponse>(
@ -1292,13 +1283,13 @@ export class LemmyHttp {
}: UploadImage): Promise<UploadImageResponse> { }: UploadImage): Promise<UploadImageResponse> {
const formData = createFormData(image); 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; const headers = {} as any;
if ( if (
!globalThis?.document?.cookie?.includes("jwt=") && !globalThis?.document?.cookie?.includes("auth=") &&
!this.#headers?.Cookie?.includes("jwt=") !this.#headers?.Cookie?.includes("auth=")
) { ) {
headers.Cookie = `jwt=${auth}`; headers.Cookie = `auth=${auth}`;
} }
let url: string | undefined = undefined; let url: string | undefined = undefined;

View file

@ -45,8 +45,6 @@ export { CommunityBlockId } from "./types/CommunityBlockId";
export { CommunityBlockView } from "./types/CommunityBlockView"; export { CommunityBlockView } from "./types/CommunityBlockView";
export { CommunityFollowerView } from "./types/CommunityFollowerView"; export { CommunityFollowerView } from "./types/CommunityFollowerView";
export { CommunityId } from "./types/CommunityId"; export { CommunityId } from "./types/CommunityId";
export { CommunityJoin } from "./types/CommunityJoin";
export { CommunityJoinResponse } from "./types/CommunityJoinResponse";
export { CommunityModeratorView } from "./types/CommunityModeratorView"; export { CommunityModeratorView } from "./types/CommunityModeratorView";
export { CommunityResponse } from "./types/CommunityResponse"; export { CommunityResponse } from "./types/CommunityResponse";
export { CommunityView } from "./types/CommunityView"; export { CommunityView } from "./types/CommunityView";
@ -93,7 +91,6 @@ export { GetComments } from "./types/GetComments";
export { GetCommentsResponse } from "./types/GetCommentsResponse"; export { GetCommentsResponse } from "./types/GetCommentsResponse";
export { GetCommunity } from "./types/GetCommunity"; export { GetCommunity } from "./types/GetCommunity";
export { GetCommunityResponse } from "./types/GetCommunityResponse"; export { GetCommunityResponse } from "./types/GetCommunityResponse";
export { GetFederatedInstances } from "./types/GetFederatedInstances";
export { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse"; export { GetFederatedInstancesResponse } from "./types/GetFederatedInstancesResponse";
export { GetModlog } from "./types/GetModlog"; export { GetModlog } from "./types/GetModlog";
export { GetModlogResponse } from "./types/GetModlogResponse"; export { GetModlogResponse } from "./types/GetModlogResponse";
@ -110,13 +107,10 @@ export { GetReplies } from "./types/GetReplies";
export { GetRepliesResponse } from "./types/GetRepliesResponse"; export { GetRepliesResponse } from "./types/GetRepliesResponse";
export { GetReportCount } from "./types/GetReportCount"; export { GetReportCount } from "./types/GetReportCount";
export { GetReportCountResponse } from "./types/GetReportCountResponse"; export { GetReportCountResponse } from "./types/GetReportCountResponse";
export { GetSite } from "./types/GetSite";
export { GetSiteMetadata } from "./types/GetSiteMetadata"; export { GetSiteMetadata } from "./types/GetSiteMetadata";
export { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse"; export { GetSiteMetadataResponse } from "./types/GetSiteMetadataResponse";
export { GetSiteResponse } from "./types/GetSiteResponse"; export { GetSiteResponse } from "./types/GetSiteResponse";
export { GetUnreadCount } from "./types/GetUnreadCount";
export { GetUnreadCountResponse } from "./types/GetUnreadCountResponse"; export { GetUnreadCountResponse } from "./types/GetUnreadCountResponse";
export { GetUnreadRegistrationApplicationCount } from "./types/GetUnreadRegistrationApplicationCount";
export { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse"; export { GetUnreadRegistrationApplicationCountResponse } from "./types/GetUnreadRegistrationApplicationCountResponse";
export { HideCommunity } from "./types/HideCommunity"; export { HideCommunity } from "./types/HideCommunity";
export { ImageUpload } from "./types/ImageUpload"; export { ImageUpload } from "./types/ImageUpload";
@ -126,7 +120,6 @@ export { InstanceBlockView } from "./types/InstanceBlockView";
export { InstanceId } from "./types/InstanceId"; export { InstanceId } from "./types/InstanceId";
export { Language } from "./types/Language"; export { Language } from "./types/Language";
export { LanguageId } from "./types/LanguageId"; export { LanguageId } from "./types/LanguageId";
export { LeaveAdmin } from "./types/LeaveAdmin";
export { LemmyErrorType } from "./types/LemmyErrorType"; export { LemmyErrorType } from "./types/LemmyErrorType";
export { ListCommentReports } from "./types/ListCommentReports"; export { ListCommentReports } from "./types/ListCommentReports";
export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse"; export { ListCommentReportsResponse } from "./types/ListCommentReportsResponse";
@ -148,7 +141,6 @@ export { LocalUserView } from "./types/LocalUserView";
export { LockPost } from "./types/LockPost"; export { LockPost } from "./types/LockPost";
export { Login } from "./types/Login"; export { Login } from "./types/Login";
export { LoginResponse } from "./types/LoginResponse"; export { LoginResponse } from "./types/LoginResponse";
export { MarkAllAsRead } from "./types/MarkAllAsRead";
export { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead"; export { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
export { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead"; export { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead";
export { MarkPostAsRead } from "./types/MarkPostAsRead"; export { MarkPostAsRead } from "./types/MarkPostAsRead";
@ -165,8 +157,6 @@ export { ModFeaturePost } from "./types/ModFeaturePost";
export { ModFeaturePostView } from "./types/ModFeaturePostView"; export { ModFeaturePostView } from "./types/ModFeaturePostView";
export { ModHideCommunity } from "./types/ModHideCommunity"; export { ModHideCommunity } from "./types/ModHideCommunity";
export { ModHideCommunityView } from "./types/ModHideCommunityView"; export { ModHideCommunityView } from "./types/ModHideCommunityView";
export { ModJoin } from "./types/ModJoin";
export { ModJoinResponse } from "./types/ModJoinResponse";
export { ModLockPost } from "./types/ModLockPost"; export { ModLockPost } from "./types/ModLockPost";
export { ModLockPostView } from "./types/ModLockPostView"; export { ModLockPostView } from "./types/ModLockPostView";
export { ModRemoveComment } from "./types/ModRemoveComment"; export { ModRemoveComment } from "./types/ModRemoveComment";
@ -199,10 +189,7 @@ export { Post } from "./types/Post";
export { PostAggregates } from "./types/PostAggregates"; export { PostAggregates } from "./types/PostAggregates";
export { PostFeatureType } from "./types/PostFeatureType"; export { PostFeatureType } from "./types/PostFeatureType";
export { PostId } from "./types/PostId"; export { PostId } from "./types/PostId";
export { PostJoin } from "./types/PostJoin";
export { PostJoinResponse } from "./types/PostJoinResponse";
export { PostListingMode } from "./types/PostListingMode"; export { PostListingMode } from "./types/PostListingMode";
export { PostOrCommentId } from "./types/PostOrCommentId";
export { PostReport } from "./types/PostReport"; export { PostReport } from "./types/PostReport";
export { PostReportId } from "./types/PostReportId"; export { PostReportId } from "./types/PostReportId";
export { PostReportResponse } from "./types/PostReportResponse"; export { PostReportResponse } from "./types/PostReportResponse";

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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 };

View file

@ -25,6 +25,7 @@ export interface SaveUserSettings {
show_read_posts?: boolean; show_read_posts?: boolean;
show_new_post_notifs?: boolean; show_new_post_notifs?: boolean;
discussion_languages?: Array<LanguageId>; discussion_languages?: Array<LanguageId>;
generate_totp_2fa?: boolean;
open_links_in_new_tab?: boolean; open_links_in_new_tab?: boolean;
infinite_scroll_enabled?: boolean; infinite_scroll_enabled?: boolean;
} }

View file

@ -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;
}

View file

@ -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;
}