diff --git a/copy_generated_types_from_lemmy.sh b/copy_generated_types_from_lemmy.sh index a873226..0d4e12f 100644 --- a/copy_generated_types_from_lemmy.sh +++ b/copy_generated_types_from_lemmy.sh @@ -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 diff --git a/package.json b/package.json index 6e9b104..eff47d1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/http.ts b/src/http.ts index b443f1e..8ec7c51 100644 --- a/src/http.ts +++ b/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(HttpType.Get, "/site", form); + getSite() { + return this.#wrapper(HttpType.Get, "/site", {}); } /** @@ -212,11 +204,11 @@ export class LemmyHttp { * * `HTTP.POST /user/leave_admin` */ - leaveAdmin(form: LeaveAdmin) { - return this.#wrapper( + leaveAdmin() { + return this.#wrapper( HttpType.Post, "/user/leave_admin", - form, + {}, ); } @@ -964,11 +956,11 @@ export class LemmyHttp { * * `HTTP.GET /user/banned` */ - getBannedPersons(form: GetBannedPersons) { - return this.#wrapper( + getBannedPersons() { + return this.#wrapper( HttpType.Get, "/user/banned", - form, + {}, ); } @@ -990,11 +982,11 @@ export class LemmyHttp { * * `HTTP.GET /user/get_captcha` */ - getCaptcha(form: GetCaptcha = {}) { - return this.#wrapper( + getCaptcha() { + return this.#wrapper( 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() { + return this.#wrapper( 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() { + return this.#wrapper( 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( + HttpType.Get, + "/admin/registration_application/count", + {}, + ); } /** @@ -1262,18 +1253,18 @@ export class LemmyHttp { * * `HTTP.Get /federated_instances` */ - getFederatedInstances(form: GetFederatedInstances = {}) { - return this.#wrapper( + getFederatedInstances() { + return this.#wrapper( 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( @@ -1292,13 +1283,13 @@ export class LemmyHttp { }: UploadImage): Promise { 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; diff --git a/src/index.ts b/src/index.ts index 727675b..6804644 100644 --- a/src/index.ts +++ b/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"; diff --git a/src/types/CommunityJoin.ts b/src/types/CommunityJoin.ts deleted file mode 100644 index c1b0b65..0000000 --- a/src/types/CommunityJoin.ts +++ /dev/null @@ -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; -} diff --git a/src/types/CommunityJoinResponse.ts b/src/types/CommunityJoinResponse.ts deleted file mode 100644 index cf0212f..0000000 --- a/src/types/CommunityJoinResponse.ts +++ /dev/null @@ -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; -} diff --git a/src/types/GetBannedPersons.ts b/src/types/GetBannedPersons.ts deleted file mode 100644 index 112547a..0000000 --- a/src/types/GetBannedPersons.ts +++ /dev/null @@ -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; -} diff --git a/src/types/GetCaptcha.ts b/src/types/GetCaptcha.ts deleted file mode 100644 index faaf6cb..0000000 --- a/src/types/GetCaptcha.ts +++ /dev/null @@ -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; -} diff --git a/src/types/GetFederatedInstances.ts b/src/types/GetFederatedInstances.ts deleted file mode 100644 index bf3b6c7..0000000 --- a/src/types/GetFederatedInstances.ts +++ /dev/null @@ -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; -} diff --git a/src/types/GetSite.ts b/src/types/GetSite.ts deleted file mode 100644 index 6001bd9..0000000 --- a/src/types/GetSite.ts +++ /dev/null @@ -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; -} diff --git a/src/types/GetUnreadCount.ts b/src/types/GetUnreadCount.ts deleted file mode 100644 index 383cf9a..0000000 --- a/src/types/GetUnreadCount.ts +++ /dev/null @@ -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; -} diff --git a/src/types/GetUnreadRegistrationApplicationCount.ts b/src/types/GetUnreadRegistrationApplicationCount.ts deleted file mode 100644 index df01278..0000000 --- a/src/types/GetUnreadRegistrationApplicationCount.ts +++ /dev/null @@ -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; -} diff --git a/src/types/LeaveAdmin.ts b/src/types/LeaveAdmin.ts deleted file mode 100644 index c2ad908..0000000 --- a/src/types/LeaveAdmin.ts +++ /dev/null @@ -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; -} diff --git a/src/types/MarkAllAsRead.ts b/src/types/MarkAllAsRead.ts deleted file mode 100644 index 8941b9e..0000000 --- a/src/types/MarkAllAsRead.ts +++ /dev/null @@ -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; -} diff --git a/src/types/ModJoin.ts b/src/types/ModJoin.ts deleted file mode 100644 index 115a213..0000000 --- a/src/types/ModJoin.ts +++ /dev/null @@ -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; -} diff --git a/src/types/ModJoinResponse.ts b/src/types/ModJoinResponse.ts deleted file mode 100644 index 90e83b9..0000000 --- a/src/types/ModJoinResponse.ts +++ /dev/null @@ -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; -} diff --git a/src/types/PostJoin.ts b/src/types/PostJoin.ts deleted file mode 100644 index cab8217..0000000 --- a/src/types/PostJoin.ts +++ /dev/null @@ -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; -} diff --git a/src/types/PostJoinResponse.ts b/src/types/PostJoinResponse.ts deleted file mode 100644 index 4640e33..0000000 --- a/src/types/PostJoinResponse.ts +++ /dev/null @@ -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; -} diff --git a/src/types/PostOrCommentId.ts b/src/types/PostOrCommentId.ts deleted file mode 100644 index 918a94b..0000000 --- a/src/types/PostOrCommentId.ts +++ /dev/null @@ -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 }; diff --git a/src/types/SaveUserSettings.ts b/src/types/SaveUserSettings.ts index fb9e89f..31182a3 100644 --- a/src/types/SaveUserSettings.ts +++ b/src/types/SaveUserSettings.ts @@ -25,6 +25,7 @@ export interface SaveUserSettings { show_read_posts?: boolean; show_new_post_notifs?: boolean; discussion_languages?: Array; + generate_totp_2fa?: boolean; open_links_in_new_tab?: boolean; infinite_scroll_enabled?: boolean; } diff --git a/src/types/UserJoin.ts b/src/types/UserJoin.ts deleted file mode 100644 index 497449b..0000000 --- a/src/types/UserJoin.ts +++ /dev/null @@ -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; -} diff --git a/src/types/UserJoinResponse.ts b/src/types/UserJoinResponse.ts deleted file mode 100644 index 2b41aef..0000000 --- a/src/types/UserJoinResponse.ts +++ /dev/null @@ -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; -}