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",
"version": "0.19.0-rc.13",
"version": "0.19.0-alpha.13",
"description": "A javascript / typescript client for Lemmy",
"repository": "https://github.com/LemmyNet/lemmy-js-client",
"license": "AGPL-3.0",

View file

@ -137,6 +137,8 @@ import { BlockInstanceResponse } from "./types/BlockInstanceResponse";
import { GenerateTotpSecretResponse } from "./types/GenerateTotpSecretResponse";
import { UpdateTotp } from "./types/UpdateTotp";
import { UpdateTotpResponse } from "./types/UpdateTotpResponse";
import { SuccessResponse } from "./types/SuccessResponse";
import { LoginToken } from "./types/LoginToken";
enum HttpType {
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.
*
@ -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`
*/

View file

@ -139,6 +139,7 @@ export { LocalUserView } from "./types/LocalUserView";
export { LockPost } from "./types/LockPost";
export { Login } from "./types/Login";
export { LoginResponse } from "./types/LoginResponse";
export { LoginToken } from "./types/LoginToken";
export { MarkCommentReplyAsRead } from "./types/MarkCommentReplyAsRead";
export { MarkPersonMentionAsRead } from "./types/MarkPersonMentionAsRead";
export { MarkPostAsRead } from "./types/MarkPostAsRead";

View file

@ -9,6 +9,4 @@ export interface CommentAggregates {
downvotes: /* integer */ number;
published: string;
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_month: /* 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.
export type LemmyErrorType =
| { error_type: "ReportReasonRequired" }
| { error_type: "ReportTooLong" }
| { error_type: "NotAModerator" }
| { error_type: "NotAnAdmin" }
| { error_type: "CannotBlockYourself" }
| { error_type: "CannotBlockAdmin" }
| { error_type: "CouldNotUpdateUser" }
| { error_type: "PasswordsDoNotMatch" }
| { error_type: "PasswordIncorrect" }
| { error_type: "EmailNotVerified" }
| { error_type: "EmailRequired" }
| { error_type: "CouldNotUpdateComment" }
| { error_type: "CouldNotUpdatePrivateMessage" }
| { error_type: "CannotLeaveAdmin" }
| { error_type: "NoLinesInHtml" }
| { error_type: "SiteMetadataPageIsNotDoctypeHtml" }
| { error_type: "PictrsResponseError"; message: string }
| { error_type: "PictrsPurgeResponseError"; message: string }
| { error_type: "ImageUrlMissingPathSegments" }
| { error_type: "ImageUrlMissingLastPathSegment" }
| { error_type: "PictrsApiKeyNotProvided" }
| { error_type: "NoContentTypeHeader" }
| { error_type: "NotAnImageType" }
| { error_type: "NotAModOrAdmin" }
| { error_type: "NoAdmins" }
| { error_type: "NotTopAdmin" }
| { error_type: "NotTopMod" }
| { error_type: "NotLoggedIn" }
| { error_type: "SiteBan" }
| { error_type: "Deleted" }
| { error_type: "BannedFromCommunity" }
| { error_type: "CouldNotFindCommunity" }
| { error_type: "PersonIsBlocked" }
| { error_type: "DownvotesAreDisabled" }
| { error_type: "InstanceIsPrivate" }
| { error_type: "InvalidPassword" }
| { error_type: "SiteDescriptionLengthOverflow" }
| { error_type: "HoneypotFailed" }
| { error_type: "RegistrationApplicationIsPending" }
| { error_type: "PrivateInstanceCannotHaveFederationEnabled" }
| { error_type: "Locked" }
| { error_type: "CouldNotCreateComment" }
| { error_type: "MaxCommentDepthReached" }
| { error_type: "EditCommentNotAllowed" }
| { error_type: "OnlyAdminsCanCreateCommunities" }
| { error_type: "CommunityAlreadyExists" }
| { error_type: "LanguageNotAllowed" }
| { error_type: "OnlyModsCanPostInCommunity" }
| { error_type: "CouldNotUpdatePost" }
| { error_type: "EditPostNotAllowed" }
| { error_type: "CouldNotFindPost" }
| { error_type: "EditPrivateMessageNotAllowed" }
| { error_type: "SiteAlreadyExists" }
| { error_type: "ApplicationQuestionRequired" }
| { error_type: "InvalidDefaultPostListingType" }
| { error_type: "RegistrationClosed" }
| { error_type: "RegistrationApplicationAnswerRequired" }
| { error_type: "EmailAlreadyExists" }
| { error_type: "FederationError"; message: string }
| { error_type: "FederationForbiddenByStrictAllowList" }
| { error_type: "PersonIsBannedFromCommunity" }
| { error_type: "ObjectIsNotPublic" }
| { error_type: "InvalidCommunity" }
| { error_type: "CannotCreatePostOrCommentInDeletedOrRemovedCommunity" }
| { error_type: "CannotReceivePage" }
| { error_type: "NewPostCannotBeLocked" }
| { error_type: "OnlyLocalAdminCanRemoveCommunity" }
| { error_type: "OnlyLocalAdminCanRestoreCommunity" }
| { error_type: "NoIdGiven" }
| { error_type: "CouldNotFindUsernameOrEmail" }
| { error_type: "InvalidQuery" }
| { error_type: "ObjectNotLocal" }
| { error_type: "PostIsLocked" }
| { error_type: "PersonIsBannedFromSite" }
| { error_type: "InvalidVoteValue" }
| { error_type: "PageDoesNotSpecifyCreator" }
| { error_type: "PageDoesNotSpecifyGroup" }
| { error_type: "NoCommunityFoundInCC" }
| { error_type: "NoEmailSetup" }
| { error_type: "EmailSmtpServerNeedsAPort" }
| { error_type: "MissingAnEmail" }
| { error_type: "RateLimitError" }
| { error_type: "InvalidName" }
| { error_type: "InvalidDisplayName" }
| { error_type: "InvalidMatrixId" }
| { error_type: "InvalidPostTitle" }
| { error_type: "InvalidBodyField" }
| { error_type: "BioLengthOverflow" }
| { error_type: "MissingTotpToken" }
| { error_type: "IncorrectTotpToken" }
| { error_type: "CouldNotParseTotpSecret" }
| { error_type: "CouldNotLikeComment" }
| { error_type: "CouldNotSaveComment" }
| { error_type: "CouldNotCreateReport" }
| { error_type: "CouldNotResolveReport" }
| { error_type: "CommunityModeratorAlreadyExists" }
| { error_type: "CommunityUserIsAlreadyBanned" }
| { error_type: "CommunityBlockAlreadyExists" }
| { error_type: "CommunityFollowerAlreadyExists" }
| { error_type: "CouldNotUpdateCommunityHiddenStatus" }
| { error_type: "PersonBlockAlreadyExists" }
| { error_type: "UserAlreadyExists" }
| { error_type: "TokenNotFound" }
| { error_type: "CouldNotLikePost" }
| { error_type: "CouldNotSavePost" }
| { error_type: "CouldNotMarkPostAsRead" }
| { error_type: "CouldNotUpdateCommunity" }
| { error_type: "CouldNotUpdateReplies" }
| { error_type: "CouldNotUpdatePersonMentions" }
| { error_type: "PostTitleTooLong" }
| { error_type: "CouldNotCreatePost" }
| { error_type: "CouldNotCreatePrivateMessage" }
| { error_type: "CouldNotUpdatePrivate" }
| { error_type: "SystemErrLogin" }
| { error_type: "CouldNotSetAllRegistrationsAccepted" }
| { error_type: "CouldNotSetAllEmailVerified" }
| { error_type: "Banned" }
| { error_type: "CouldNotGetComments" }
| { error_type: "CouldNotGetPosts" }
| { error_type: "InvalidUrl" }
| { error_type: "EmailSendFailed" }
| { error_type: "Slurs" }
| { error_type: "CouldNotGenerateTotp" }
| { error_type: "CouldNotFindObject" }
| { error_type: "RegistrationDenied"; message: string }
| { error_type: "FederationDisabled" }
| { error_type: "DomainBlocked" }
| { error_type: "DomainNotInAllowList" }
| { error_type: "FederationDisabledByStrictAllowList" }
| { error_type: "SiteNameRequired" }
| { error_type: "SiteNameLengthOverflow" }
| { error_type: "PermissiveRegex" }
| { error_type: "InvalidRegex" }
| { error_type: "CaptchaIncorrect" }
| { error_type: "PasswordResetLimitReached" }
| { error_type: "CouldNotCreateAudioCaptcha" };
| { error: "report_reason_required" }
| { error: "report_too_long" }
| { error: "not_a_moderator" }
| { error: "not_an_admin" }
| { error: "cant_block_yourself" }
| { error: "cant_block_admin" }
| { error: "couldnt_update_user" }
| { error: "passwords_do_not_match" }
| { error: "email_not_verified" }
| { error: "email_required" }
| { error: "couldnt_update_comment" }
| { error: "couldnt_update_private_message" }
| { error: "cannot_leave_admin" }
| { error: "no_lines_in_html" }
| { error: "site_metadata_page_is_not_doctype_html" }
| { error: "pictrs_response_error"; message: string }
| { error: "pictrs_purge_response_error"; message: string }
| { error: "pictrs_caching_disabled" }
| { error: "image_url_missing_path_segments" }
| { error: "image_url_missing_last_path_segment" }
| { error: "pictrs_api_key_not_provided" }
| { error: "no_content_type_header" }
| { error: "not_an_image_type" }
| { error: "not_a_mod_or_admin" }
| { error: "no_admins" }
| { error: "not_top_admin" }
| { error: "not_top_mod" }
| { error: "not_logged_in" }
| { error: "site_ban" }
| { error: "deleted" }
| { error: "banned_from_community" }
| { error: "couldnt_find_community" }
| { error: "couldnt_find_person" }
| { error: "person_is_blocked" }
| { error: "downvotes_are_disabled" }
| { error: "instance_is_private" }
| { error: "invalid_password" }
| { error: "site_description_length_overflow" }
| { error: "honeypot_failed" }
| { error: "registration_application_is_pending" }
| { error: "cant_enable_private_instance_and_federation_together" }
| { error: "locked" }
| { error: "couldnt_create_comment" }
| { error: "max_comment_depth_reached" }
| { error: "no_comment_edit_allowed" }
| { error: "only_admins_can_create_communities" }
| { error: "community_already_exists" }
| { error: "language_not_allowed" }
| { error: "only_mods_can_post_in_community" }
| { error: "couldnt_update_post" }
| { error: "no_post_edit_allowed" }
| { error: "couldnt_find_post" }
| { error: "edit_private_message_not_allowed" }
| { error: "site_already_exists" }
| { error: "application_question_required" }
| { error: "invalid_default_post_listing_type" }
| { error: "registration_closed" }
| { error: "registration_application_answer_required" }
| { error: "email_already_exists" }
| { error: "federation_forbidden_by_strict_allow_list" }
| { error: "person_is_banned_from_community" }
| { error: "object_is_not_public" }
| { error: "invalid_community" }
| { error: "cannot_create_post_or_comment_in_deleted_or_removed_community" }
| { error: "cannot_receive_page" }
| { error: "new_post_cannot_be_locked" }
| { error: "only_local_admin_can_remove_community" }
| { error: "only_local_admin_can_restore_community" }
| { error: "no_id_given" }
| { error: "incorrect_login" }
| { error: "invalid_query" }
| { error: "object_not_local" }
| { error: "post_is_locked" }
| { error: "person_is_banned_from_site"; message: string }
| { error: "invalid_vote_value" }
| { error: "page_does_not_specify_creator" }
| { error: "page_does_not_specify_group" }
| { error: "no_community_found_in_cc" }
| { error: "no_email_setup" }
| { error: "email_smtp_server_needs_a_port" }
| { error: "missing_an_email" }
| { error: "rate_limit_error" }
| { error: "invalid_name" }
| { error: "invalid_display_name" }
| { error: "invalid_matrix_id" }
| { error: "invalid_post_title" }
| { error: "invalid_body_field" }
| { error: "bio_length_overflow" }
| { error: "missing_totp_token" }
| { error: "missing_totp_secret" }
| { error: "incorrect_totp_token" }
| { error: "couldnt_parse_totp_secret" }
| { error: "couldnt_generate_totp" }
| { error: "totp_already_enabled" }
| { error: "couldnt_like_comment" }
| { error: "couldnt_save_comment" }
| { error: "couldnt_create_report" }
| { error: "couldnt_resolve_report" }
| { error: "community_moderator_already_exists" }
| { error: "community_user_already_banned" }
| { error: "community_block_already_exists" }
| { error: "community_follower_already_exists" }
| { error: "couldnt_update_community_hidden_status" }
| { error: "person_block_already_exists" }
| { error: "user_already_exists" }
| { error: "token_not_found" }
| { error: "couldnt_like_post" }
| { error: "couldnt_save_post" }
| { error: "couldnt_mark_post_as_read" }
| { error: "couldnt_update_community" }
| { error: "couldnt_update_replies" }
| { error: "couldnt_update_person_mentions" }
| { error: "post_title_too_long" }
| { error: "couldnt_create_post" }
| { error: "couldnt_create_private_message" }
| { error: "couldnt_update_private" }
| { error: "system_err_login" }
| { error: "couldnt_set_all_registrations_accepted" }
| { error: "couldnt_set_all_email_verified" }
| { error: "banned" }
| { error: "couldnt_get_comments" }
| { error: "couldnt_get_posts" }
| { error: "invalid_url" }
| { error: "email_send_failed" }
| { error: "slurs" }
| { error: "couldnt_find_object" }
| { error: "registration_denied"; message: string | null }
| { error: "federation_disabled" }
| { error: "domain_blocked"; message: string }
| { error: "domain_not_in_allow_list"; message: string }
| { error: "federation_disabled_by_strict_allow_list" }
| { error: "site_name_required" }
| { error: "site_name_length_overflow" }
| { error: "permissive_regex" }
| { error: "invalid_regex" }
| { 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;
published: 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_bot_accounts: boolean;
show_read_posts: boolean;
show_new_post_notifs: boolean;
email_verified: boolean;
accepted_application: boolean;
open_links_in_new_tab: boolean;
@ -29,4 +28,6 @@ export interface LocalUser {
admin: boolean;
post_listing_mode: PostListingMode;
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";
export interface MarkPostAsRead {
post_id: PostId;
post_id?: PostId;
post_ids?: Array<PostId>;
read: boolean;
}

View file

@ -8,6 +8,5 @@ export interface ModRemoveCommunity {
community_id: CommunityId;
reason?: string;
removed: boolean;
expires?: 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.
import type { CommunityId } from "./CommunityId";
import type { InstanceId } from "./InstanceId";
import type { PersonId } from "./PersonId";
import type { PostId } from "./PostId";
export interface PostAggregates {
@ -12,15 +9,4 @@ export interface PostAggregates {
upvotes: /* integer */ number;
downvotes: /* integer */ number;
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;
removed: boolean;
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.
import type { LanguageId } from "./LanguageId";
import type { ListingType } from "./ListingType";
import type { PostListingMode } from "./PostListingMode";
import type { SortType } from "./SortType";
export interface SaveUserSettings {
@ -27,4 +28,7 @@ export interface SaveUserSettings {
discussion_languages?: Array<LanguageId>;
open_links_in_new_tab?: boolean;
infinite_scroll_enabled?: boolean;
post_listing_mode?: PostListingMode;
enable_keyboard_navigation?: boolean;
enable_animated_images?: boolean;
}