Adding mark multiple posts as read, and other API changes. (#201)

* Adding mark multiple posts as read, and other API changes.

* v0.19.0-alpha.10

* Adding animated_images boolean.

* v0.19.0-alpha.11

* Updating successresponses.

* v0.19.0-alpha.12

* Adding a few missing routes.

* Revert "Updating successresponses."

This reverts commit 6de51027d4.

* v0.19.0-alpha.13

* update before rc.3.
This commit is contained in:
Dessalines 2023-10-19 20:22:35 -04:00 committed by GitHub
parent b58fbb51e0
commit 24eed9e7be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 226 additions and 159 deletions

View file

@ -1,6 +1,6 @@
{ {
"name": "lemmy-js-client", "name": "lemmy-js-client",
"version": "0.19.0-rc.13", "version": "0.19.0-alpha.13",
"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

@ -137,6 +137,8 @@ import { BlockInstanceResponse } from "./types/BlockInstanceResponse";
import { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse"; import { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse";
import { UpdateTotp } from "./types/UpdateTotp"; import { UpdateTotp } from "./types/UpdateTotp";
import { UpdateTotpResponse } from "./types/UpdateTotpResponse"; import { UpdateTotpResponse } from "./types/UpdateTotpResponse";
import { SuccessResponse } from "./types/SuccessResponse";
import { LoginToken } from "./types/LoginToken";
enum HttpType { enum HttpType {
Get = "GET", Get = "GET",
@ -235,6 +237,59 @@ export class LemmyHttp {
); );
} }
/**
* Export a backup of your user settings, including your saved content,
* followed communities, and blocks.
*
* `HTTP.GET /user/export_settings`
*/
exportSettings() {
return this.#wrapper<object, any>(
HttpType.Get,
"/user/export_settings",
{},
);
}
/**
* Import a backup of your user settings.
*
* `HTTP.POST /user/import_settings`
*/
importSettings(form: any) {
return this.#wrapper<object, SuccessResponse>(
HttpType.Post,
"/user/import_settings",
form,
);
}
/**
* List login tokens for your user
*
* `HTTP.GET /user/list_logins`
*/
listLogins() {
return this.#wrapper<object, LoginToken[]>(
HttpType.Get,
"/user/list_logins",
{},
);
}
/**
* Returns an error message if your auth token is invalid
*
* `HTTP.GET /user/validate_auth`
*/
validateAuth() {
return this.#wrapper<object, SuccessResponse>(
HttpType.Get,
"/user/validate_auth",
{},
);
}
/** /**
* Enable / Disable TOTP / two-factor authentication. * Enable / Disable TOTP / two-factor authentication.
* *
@ -379,7 +434,7 @@ export class LemmyHttp {
} }
/** /**
* Hide a community from public view. * Hide a community from public / "All" view. Admins only.
* *
* `HTTP.PUT /community/hide` * `HTTP.PUT /community/hide`
*/ */

View file

@ -139,6 +139,7 @@ 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 { LoginToken } from "./types/LoginToken";
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";

View file

@ -9,6 +9,4 @@ export interface CommentAggregates {
downvotes: /* integer */ number; downvotes: /* integer */ number;
published: string; published: string;
child_count: number; child_count: number;
hot_rank: number;
controversy_rank: number;
} }

View file

@ -12,5 +12,4 @@ export interface CommunityAggregates {
users_active_week: /* integer */ number; users_active_week: /* integer */ number;
users_active_month: /* integer */ number; users_active_month: /* integer */ number;
users_active_half_year: /* integer */ number; users_active_half_year: /* integer */ number;
hot_rank: number;
} }

View file

@ -1,139 +1,151 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type LemmyErrorType = export type LemmyErrorType =
| { error_type: "ReportReasonRequired" } | { error: "report_reason_required" }
| { error_type: "ReportTooLong" } | { error: "report_too_long" }
| { error_type: "NotAModerator" } | { error: "not_a_moderator" }
| { error_type: "NotAnAdmin" } | { error: "not_an_admin" }
| { error_type: "CannotBlockYourself" } | { error: "cant_block_yourself" }
| { error_type: "CannotBlockAdmin" } | { error: "cant_block_admin" }
| { error_type: "CouldNotUpdateUser" } | { error: "couldnt_update_user" }
| { error_type: "PasswordsDoNotMatch" } | { error: "passwords_do_not_match" }
| { error_type: "PasswordIncorrect" } | { error: "email_not_verified" }
| { error_type: "EmailNotVerified" } | { error: "email_required" }
| { error_type: "EmailRequired" } | { error: "couldnt_update_comment" }
| { error_type: "CouldNotUpdateComment" } | { error: "couldnt_update_private_message" }
| { error_type: "CouldNotUpdatePrivateMessage" } | { error: "cannot_leave_admin" }
| { error_type: "CannotLeaveAdmin" } | { error: "no_lines_in_html" }
| { error_type: "NoLinesInHtml" } | { error: "site_metadata_page_is_not_doctype_html" }
| { error_type: "SiteMetadataPageIsNotDoctypeHtml" } | { error: "pictrs_response_error"; message: string }
| { error_type: "PictrsResponseError"; message: string } | { error: "pictrs_purge_response_error"; message: string }
| { error_type: "PictrsPurgeResponseError"; message: string } | { error: "pictrs_caching_disabled" }
| { error_type: "ImageUrlMissingPathSegments" } | { error: "image_url_missing_path_segments" }
| { error_type: "ImageUrlMissingLastPathSegment" } | { error: "image_url_missing_last_path_segment" }
| { error_type: "PictrsApiKeyNotProvided" } | { error: "pictrs_api_key_not_provided" }
| { error_type: "NoContentTypeHeader" } | { error: "no_content_type_header" }
| { error_type: "NotAnImageType" } | { error: "not_an_image_type" }
| { error_type: "NotAModOrAdmin" } | { error: "not_a_mod_or_admin" }
| { error_type: "NoAdmins" } | { error: "no_admins" }
| { error_type: "NotTopAdmin" } | { error: "not_top_admin" }
| { error_type: "NotTopMod" } | { error: "not_top_mod" }
| { error_type: "NotLoggedIn" } | { error: "not_logged_in" }
| { error_type: "SiteBan" } | { error: "site_ban" }
| { error_type: "Deleted" } | { error: "deleted" }
| { error_type: "BannedFromCommunity" } | { error: "banned_from_community" }
| { error_type: "CouldNotFindCommunity" } | { error: "couldnt_find_community" }
| { error_type: "PersonIsBlocked" } | { error: "couldnt_find_person" }
| { error_type: "DownvotesAreDisabled" } | { error: "person_is_blocked" }
| { error_type: "InstanceIsPrivate" } | { error: "downvotes_are_disabled" }
| { error_type: "InvalidPassword" } | { error: "instance_is_private" }
| { error_type: "SiteDescriptionLengthOverflow" } | { error: "invalid_password" }
| { error_type: "HoneypotFailed" } | { error: "site_description_length_overflow" }
| { error_type: "RegistrationApplicationIsPending" } | { error: "honeypot_failed" }
| { error_type: "PrivateInstanceCannotHaveFederationEnabled" } | { error: "registration_application_is_pending" }
| { error_type: "Locked" } | { error: "cant_enable_private_instance_and_federation_together" }
| { error_type: "CouldNotCreateComment" } | { error: "locked" }
| { error_type: "MaxCommentDepthReached" } | { error: "couldnt_create_comment" }
| { error_type: "EditCommentNotAllowed" } | { error: "max_comment_depth_reached" }
| { error_type: "OnlyAdminsCanCreateCommunities" } | { error: "no_comment_edit_allowed" }
| { error_type: "CommunityAlreadyExists" } | { error: "only_admins_can_create_communities" }
| { error_type: "LanguageNotAllowed" } | { error: "community_already_exists" }
| { error_type: "OnlyModsCanPostInCommunity" } | { error: "language_not_allowed" }
| { error_type: "CouldNotUpdatePost" } | { error: "only_mods_can_post_in_community" }
| { error_type: "EditPostNotAllowed" } | { error: "couldnt_update_post" }
| { error_type: "CouldNotFindPost" } | { error: "no_post_edit_allowed" }
| { error_type: "EditPrivateMessageNotAllowed" } | { error: "couldnt_find_post" }
| { error_type: "SiteAlreadyExists" } | { error: "edit_private_message_not_allowed" }
| { error_type: "ApplicationQuestionRequired" } | { error: "site_already_exists" }
| { error_type: "InvalidDefaultPostListingType" } | { error: "application_question_required" }
| { error_type: "RegistrationClosed" } | { error: "invalid_default_post_listing_type" }
| { error_type: "RegistrationApplicationAnswerRequired" } | { error: "registration_closed" }
| { error_type: "EmailAlreadyExists" } | { error: "registration_application_answer_required" }
| { error_type: "FederationError"; message: string } | { error: "email_already_exists" }
| { error_type: "FederationForbiddenByStrictAllowList" } | { error: "federation_forbidden_by_strict_allow_list" }
| { error_type: "PersonIsBannedFromCommunity" } | { error: "person_is_banned_from_community" }
| { error_type: "ObjectIsNotPublic" } | { error: "object_is_not_public" }
| { error_type: "InvalidCommunity" } | { error: "invalid_community" }
| { error_type: "CannotCreatePostOrCommentInDeletedOrRemovedCommunity" } | { error: "cannot_create_post_or_comment_in_deleted_or_removed_community" }
| { error_type: "CannotReceivePage" } | { error: "cannot_receive_page" }
| { error_type: "NewPostCannotBeLocked" } | { error: "new_post_cannot_be_locked" }
| { error_type: "OnlyLocalAdminCanRemoveCommunity" } | { error: "only_local_admin_can_remove_community" }
| { error_type: "OnlyLocalAdminCanRestoreCommunity" } | { error: "only_local_admin_can_restore_community" }
| { error_type: "NoIdGiven" } | { error: "no_id_given" }
| { error_type: "CouldNotFindUsernameOrEmail" } | { error: "incorrect_login" }
| { error_type: "InvalidQuery" } | { error: "invalid_query" }
| { error_type: "ObjectNotLocal" } | { error: "object_not_local" }
| { error_type: "PostIsLocked" } | { error: "post_is_locked" }
| { error_type: "PersonIsBannedFromSite" } | { error: "person_is_banned_from_site"; message: string }
| { error_type: "InvalidVoteValue" } | { error: "invalid_vote_value" }
| { error_type: "PageDoesNotSpecifyCreator" } | { error: "page_does_not_specify_creator" }
| { error_type: "PageDoesNotSpecifyGroup" } | { error: "page_does_not_specify_group" }
| { error_type: "NoCommunityFoundInCC" } | { error: "no_community_found_in_cc" }
| { error_type: "NoEmailSetup" } | { error: "no_email_setup" }
| { error_type: "EmailSmtpServerNeedsAPort" } | { error: "email_smtp_server_needs_a_port" }
| { error_type: "MissingAnEmail" } | { error: "missing_an_email" }
| { error_type: "RateLimitError" } | { error: "rate_limit_error" }
| { error_type: "InvalidName" } | { error: "invalid_name" }
| { error_type: "InvalidDisplayName" } | { error: "invalid_display_name" }
| { error_type: "InvalidMatrixId" } | { error: "invalid_matrix_id" }
| { error_type: "InvalidPostTitle" } | { error: "invalid_post_title" }
| { error_type: "InvalidBodyField" } | { error: "invalid_body_field" }
| { error_type: "BioLengthOverflow" } | { error: "bio_length_overflow" }
| { error_type: "MissingTotpToken" } | { error: "missing_totp_token" }
| { error_type: "IncorrectTotpToken" } | { error: "missing_totp_secret" }
| { error_type: "CouldNotParseTotpSecret" } | { error: "incorrect_totp_token" }
| { error_type: "CouldNotLikeComment" } | { error: "couldnt_parse_totp_secret" }
| { error_type: "CouldNotSaveComment" } | { error: "couldnt_generate_totp" }
| { error_type: "CouldNotCreateReport" } | { error: "totp_already_enabled" }
| { error_type: "CouldNotResolveReport" } | { error: "couldnt_like_comment" }
| { error_type: "CommunityModeratorAlreadyExists" } | { error: "couldnt_save_comment" }
| { error_type: "CommunityUserIsAlreadyBanned" } | { error: "couldnt_create_report" }
| { error_type: "CommunityBlockAlreadyExists" } | { error: "couldnt_resolve_report" }
| { error_type: "CommunityFollowerAlreadyExists" } | { error: "community_moderator_already_exists" }
| { error_type: "CouldNotUpdateCommunityHiddenStatus" } | { error: "community_user_already_banned" }
| { error_type: "PersonBlockAlreadyExists" } | { error: "community_block_already_exists" }
| { error_type: "UserAlreadyExists" } | { error: "community_follower_already_exists" }
| { error_type: "TokenNotFound" } | { error: "couldnt_update_community_hidden_status" }
| { error_type: "CouldNotLikePost" } | { error: "person_block_already_exists" }
| { error_type: "CouldNotSavePost" } | { error: "user_already_exists" }
| { error_type: "CouldNotMarkPostAsRead" } | { error: "token_not_found" }
| { error_type: "CouldNotUpdateCommunity" } | { error: "couldnt_like_post" }
| { error_type: "CouldNotUpdateReplies" } | { error: "couldnt_save_post" }
| { error_type: "CouldNotUpdatePersonMentions" } | { error: "couldnt_mark_post_as_read" }
| { error_type: "PostTitleTooLong" } | { error: "couldnt_update_community" }
| { error_type: "CouldNotCreatePost" } | { error: "couldnt_update_replies" }
| { error_type: "CouldNotCreatePrivateMessage" } | { error: "couldnt_update_person_mentions" }
| { error_type: "CouldNotUpdatePrivate" } | { error: "post_title_too_long" }
| { error_type: "SystemErrLogin" } | { error: "couldnt_create_post" }
| { error_type: "CouldNotSetAllRegistrationsAccepted" } | { error: "couldnt_create_private_message" }
| { error_type: "CouldNotSetAllEmailVerified" } | { error: "couldnt_update_private" }
| { error_type: "Banned" } | { error: "system_err_login" }
| { error_type: "CouldNotGetComments" } | { error: "couldnt_set_all_registrations_accepted" }
| { error_type: "CouldNotGetPosts" } | { error: "couldnt_set_all_email_verified" }
| { error_type: "InvalidUrl" } | { error: "banned" }
| { error_type: "EmailSendFailed" } | { error: "couldnt_get_comments" }
| { error_type: "Slurs" } | { error: "couldnt_get_posts" }
| { error_type: "CouldNotGenerateTotp" } | { error: "invalid_url" }
| { error_type: "CouldNotFindObject" } | { error: "email_send_failed" }
| { error_type: "RegistrationDenied"; message: string } | { error: "slurs" }
| { error_type: "FederationDisabled" } | { error: "couldnt_find_object" }
| { error_type: "DomainBlocked" } | { error: "registration_denied"; message: string | null }
| { error_type: "DomainNotInAllowList" } | { error: "federation_disabled" }
| { error_type: "FederationDisabledByStrictAllowList" } | { error: "domain_blocked"; message: string }
| { error_type: "SiteNameRequired" } | { error: "domain_not_in_allow_list"; message: string }
| { error_type: "SiteNameLengthOverflow" } | { error: "federation_disabled_by_strict_allow_list" }
| { error_type: "PermissiveRegex" } | { error: "site_name_required" }
| { error_type: "InvalidRegex" } | { error: "site_name_length_overflow" }
| { error_type: "CaptchaIncorrect" } | { error: "permissive_regex" }
| { error_type: "PasswordResetLimitReached" } | { error: "invalid_regex" }
| { error_type: "CouldNotCreateAudioCaptcha" }; | { error: "captcha_incorrect" }
| { error: "password_reset_limit_reached" }
| { error: "couldnt_create_audio_captcha" }
| { error: "invalid_url_scheme" }
| { error: "couldnt_send_webmention" }
| { error: "contradicting_filters" }
| { error: "instance_block_already_exists" }
| { error: "auth_cookie_insecure" }
| { error: "too_many_items" }
| { error: "community_has_no_followers" }
| { error: "ban_expiration_in_past" }
| { error: "invalid_unix_time" }
| { error: "unknown"; message: string };

View file

@ -18,4 +18,6 @@ export interface LocalSiteRateLimit {
search_per_second: number; search_per_second: number;
published: string; published: string;
updated?: string; updated?: string;
import_user_settings: number;
import_user_settings_per_second: number;
} }

View file

@ -19,7 +19,6 @@ export interface LocalUser {
show_scores: boolean; show_scores: boolean;
show_bot_accounts: boolean; show_bot_accounts: boolean;
show_read_posts: boolean; show_read_posts: boolean;
show_new_post_notifs: boolean;
email_verified: boolean; email_verified: boolean;
accepted_application: boolean; accepted_application: boolean;
open_links_in_new_tab: boolean; open_links_in_new_tab: boolean;
@ -29,4 +28,6 @@ export interface LocalUser {
admin: boolean; admin: boolean;
post_listing_mode: PostListingMode; post_listing_mode: PostListingMode;
totp_2fa_enabled: boolean; totp_2fa_enabled: boolean;
enable_keyboard_navigation: boolean;
enable_animated_images: boolean;
} }

10
src/types/LoginToken.ts Normal file
View file

@ -0,0 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { LocalUserId } from "./LocalUserId";
export interface LoginToken {
id: number;
user_id: LocalUserId;
published: string;
ip?: string;
user_agent?: string;
}

View file

@ -2,6 +2,7 @@
import type { PostId } from "./PostId"; import type { PostId } from "./PostId";
export interface MarkPostAsRead { export interface MarkPostAsRead {
post_id: PostId; post_id?: PostId;
post_ids?: Array<PostId>;
read: boolean; read: boolean;
} }

View file

@ -8,6 +8,5 @@ export interface ModRemoveCommunity {
community_id: CommunityId; community_id: CommunityId;
reason?: string; reason?: string;
removed: boolean; removed: boolean;
expires?: string;
when_: string; when_: string;
} }

View file

@ -1,7 +1,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // 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";
import type { InstanceId } from "./InstanceId";
import type { PersonId } from "./PersonId";
import type { PostId } from "./PostId"; import type { PostId } from "./PostId";
export interface PostAggregates { export interface PostAggregates {
@ -12,15 +9,4 @@ export interface PostAggregates {
upvotes: /* integer */ number; upvotes: /* integer */ number;
downvotes: /* integer */ number; downvotes: /* integer */ number;
published: string; published: string;
newest_comment_time_necro: string;
newest_comment_time: string;
featured_community: boolean;
featured_local: boolean;
hot_rank: number;
hot_rank_active: number;
community_id: CommunityId;
creator_id: PersonId;
controversy_rank: number;
instance_id: InstanceId;
scaled_rank: number;
} }

View file

@ -5,5 +5,4 @@ export interface RemoveCommunity {
community_id: CommunityId; community_id: CommunityId;
removed: boolean; removed: boolean;
reason?: string; reason?: string;
expires?: /* integer */ number;
} }

View file

@ -1,6 +1,7 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { LanguageId } from "./LanguageId"; import type { LanguageId } from "./LanguageId";
import type { ListingType } from "./ListingType"; import type { ListingType } from "./ListingType";
import type { PostListingMode } from "./PostListingMode";
import type { SortType } from "./SortType"; import type { SortType } from "./SortType";
export interface SaveUserSettings { export interface SaveUserSettings {
@ -27,4 +28,7 @@ export interface SaveUserSettings {
discussion_languages?: Array<LanguageId>; discussion_languages?: Array<LanguageId>;
open_links_in_new_tab?: boolean; open_links_in_new_tab?: boolean;
infinite_scroll_enabled?: boolean; infinite_scroll_enabled?: boolean;
post_listing_mode?: PostListingMode;
enable_keyboard_navigation?: boolean;
enable_animated_images?: boolean;
} }