From e1bfcdcb8147718023af991c8706c99e6d423e38 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Fri, 31 Jan 2025 15:46:09 -0500 Subject: [PATCH] Search combined (#457) * Adding search combined types. * 0.20.0-search-combined.0 * 0.20.0-search-combined.1 --- package.json | 2 +- src/http.ts | 20 +++++++++++++++++++ src/index.ts | 6 ++++++ src/types/CommentSlimView.ts | 22 +++++++++++++++++++++ src/types/CreateSite.ts | 1 + src/types/EditSite.ts | 5 +++++ src/types/GetCommentsSlimResponse.ts | 7 +++++++ src/types/GetPosts.ts | 4 ++++ src/types/GetRandomCommunity.ts | 2 +- src/types/ListReports.ts | 10 ++++++++++ src/types/LocalSite.ts | 5 +++++ src/types/LocalUser.ts | 9 +++++++++ src/types/PersonContentType.ts | 2 +- src/types/PersonPostMentionView.ts | 2 ++ src/types/ReportType.ts | 11 +++++++++++ src/types/SaveUserSettings.ts | 4 ++++ src/types/Search.ts | 13 ++++++------ src/types/SearchCombinedPaginationCursor.ts | 6 ++++++ src/types/SearchCombinedView.ts | 11 +++++++++++ src/types/SearchResponse.ts | 14 ++----------- src/types/SearchSortType.ts | 6 ++++++ src/types/SuccessResponse.ts | 2 +- src/types/UploadImageResponse.ts | 5 +---- 23 files changed, 143 insertions(+), 26 deletions(-) create mode 100644 src/types/CommentSlimView.ts create mode 100644 src/types/GetCommentsSlimResponse.ts create mode 100644 src/types/ReportType.ts create mode 100644 src/types/SearchCombinedPaginationCursor.ts create mode 100644 src/types/SearchCombinedView.ts create mode 100644 src/types/SearchSortType.ts diff --git a/package.json b/package.json index 1a481a8..1775d92 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "lemmy-js-client", "description": "A javascript / typescript client for Lemmy", - "version": "0.20.0-inbox-combined.1", + "version": "0.20.0-search-combined.1", "author": "Dessalines", "license": "AGPL-3.0", "main": "./dist/index.js", diff --git a/src/http.ts b/src/http.ts index d6a1bbb..d76040a 100644 --- a/src/http.ts +++ b/src/http.ts @@ -184,6 +184,7 @@ import { ListInboxResponse } from "./types/ListInboxResponse"; import { ListInbox } from "./types/ListInbox"; import { MarkPersonCommentMentionAsRead } from "./types/MarkPersonCommentMentionAsRead"; import { MarkPersonPostMentionAsRead } from "./types/MarkPersonPostMentionAsRead"; +import { GetCommentsSlimResponse } from "./types/GetCommentsSlimResponse"; import { Body, Controller, @@ -1244,6 +1245,25 @@ export class LemmyHttp extends Controller { ); } + /** + * Get / fetch comments, but without the post or community. + */ + @Security("bearerAuth") + @Security({}) + @Get("/comment/list/slim") + @Tags("Comment") + getCommentsSlim( + @Queries() form: GetCommentsI = {}, + @Inject() options?: RequestOptions, + ) { + return this.#wrapper( + HttpType.Get, + "/comment/list/slim", + form, + options, + ); + } + /** * Get / fetch comment. */ diff --git a/src/index.ts b/src/index.ts index edca287..e6f5c5b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,6 +50,7 @@ export { CommentReportId } from "./types/CommentReportId"; export { CommentReportResponse } from "./types/CommentReportResponse"; export { CommentReportView } from "./types/CommentReportView"; export { CommentResponse } from "./types/CommentResponse"; +export { CommentSlimView } from "./types/CommentSlimView"; export { CommentSortType } from "./types/CommentSortType"; export { CommentView } from "./types/CommentView"; export { Community } from "./types/Community"; @@ -112,6 +113,7 @@ export { GetCaptchaResponse } from "./types/GetCaptchaResponse"; export { GetComment } from "./types/GetComment"; export { GetComments } from "./types/GetComments"; export { GetCommentsResponse } from "./types/GetCommentsResponse"; +export { GetCommentsSlimResponse } from "./types/GetCommentsSlimResponse"; export { GetCommunity } from "./types/GetCommunity"; export { GetCommunityPendingFollowsCount } from "./types/GetCommunityPendingFollowsCount"; export { GetCommunityPendingFollowsCountResponse } from "./types/GetCommunityPendingFollowsCountResponse"; @@ -292,6 +294,7 @@ export { RemoveCommunity } from "./types/RemoveCommunity"; export { RemovePost } from "./types/RemovePost"; export { ReportCombinedPaginationCursor } from "./types/ReportCombinedPaginationCursor"; export { ReportCombinedView } from "./types/ReportCombinedView"; +export { ReportType } from "./types/ReportType"; export { ResolveCommentReport } from "./types/ResolveCommentReport"; export { ResolveObject } from "./types/ResolveObject"; export { ResolveObjectResponse } from "./types/ResolveObjectResponse"; @@ -301,7 +304,10 @@ export { SaveComment } from "./types/SaveComment"; export { SavePost } from "./types/SavePost"; export { SaveUserSettings } from "./types/SaveUserSettings"; export { Search } from "./types/Search"; +export { SearchCombinedPaginationCursor } from "./types/SearchCombinedPaginationCursor"; +export { SearchCombinedView } from "./types/SearchCombinedView"; export { SearchResponse } from "./types/SearchResponse"; +export { SearchSortType } from "./types/SearchSortType"; export { SearchType } from "./types/SearchType"; export { SensitiveString } from "./types/SensitiveString"; export { Site } from "./types/Site"; diff --git a/src/types/CommentSlimView.ts b/src/types/CommentSlimView.ts new file mode 100644 index 0000000..f2bf00d --- /dev/null +++ b/src/types/CommentSlimView.ts @@ -0,0 +1,22 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { Comment } from "./Comment"; +import type { CommentAggregates } from "./CommentAggregates"; +import type { Person } from "./Person"; +import type { SubscribedType } from "./SubscribedType"; + +/** + * A slimmer comment view, without the post, or community. + */ +export type CommentSlimView = { + comment: Comment; + creator: Person; + counts: CommentAggregates; + creator_banned_from_community: boolean; + banned_from_community: boolean; + creator_is_moderator: boolean; + creator_is_admin: boolean; + subscribed: SubscribedType; + saved: boolean; + creator_blocked: boolean; + my_vote?: number; +}; diff --git a/src/types/CreateSite.ts b/src/types/CreateSite.ts index 966a739..1babd55 100644 --- a/src/types/CreateSite.ts +++ b/src/types/CreateSite.ts @@ -51,4 +51,5 @@ export type CreateSite = { post_downvotes?: FederationMode; comment_upvotes?: FederationMode; comment_downvotes?: FederationMode; + disable_donation_dialog?: boolean; }; diff --git a/src/types/EditSite.ts b/src/types/EditSite.ts index 85fecac..4b1196a 100644 --- a/src/types/EditSite.ts +++ b/src/types/EditSite.ts @@ -156,4 +156,9 @@ export type EditSite = { * What kind of comment downvotes your site allows. */ comment_downvotes?: FederationMode; + /** + * If this is true, users will never see the dialog asking to support Lemmy development with + * donations. + */ + disable_donation_dialog?: boolean; }; diff --git a/src/types/GetCommentsSlimResponse.ts b/src/types/GetCommentsSlimResponse.ts new file mode 100644 index 0000000..3f5c0c2 --- /dev/null +++ b/src/types/GetCommentsSlimResponse.ts @@ -0,0 +1,7 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CommentSlimView } from "./CommentSlimView"; + +/** + * A slimmer comment list response, without the post or community. + */ +export type GetCommentsSlimResponse = { comments: Array }; diff --git a/src/types/GetPosts.ts b/src/types/GetPosts.ts index f5dbff7..d1af197 100644 --- a/src/types/GetPosts.ts +++ b/src/types/GetPosts.ts @@ -30,6 +30,10 @@ export type GetPosts = { * If true, then show the nsfw posts (even if your user setting is to hide them) */ show_nsfw?: boolean; + /** + * If false, then show posts with media attached (even if your user setting is to hide them) + */ + hide_media?: boolean; /** * Whether to automatically mark fetched posts as read. */ diff --git a/src/types/GetRandomCommunity.ts b/src/types/GetRandomCommunity.ts index ece9d1a..0377d6b 100644 --- a/src/types/GetRandomCommunity.ts +++ b/src/types/GetRandomCommunity.ts @@ -4,4 +4,4 @@ import type { ListingType } from "./ListingType"; /** * Fetches a random community */ -export type GetRandomCommunity = { type_?: ListingType }; +export type GetRandomCommunity = { type_?: ListingType; show_nsfw?: boolean }; diff --git a/src/types/ListReports.ts b/src/types/ListReports.ts index 00f8838..45d5a76 100644 --- a/src/types/ListReports.ts +++ b/src/types/ListReports.ts @@ -1,6 +1,8 @@ // 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 { PostId } from "./PostId"; import type { ReportCombinedPaginationCursor } from "./ReportCombinedPaginationCursor"; +import type { ReportType } from "./ReportType"; /** * List reports. @@ -10,6 +12,14 @@ export type ListReports = { * Only shows the unresolved reports */ unresolved_only?: boolean; + /** + * Filter the type of report. + */ + type_?: ReportType; + /** + * Filter by the post id. Can return either comment or post reports. + */ + post_id?: PostId; /** * if no community is given, it returns reports for all communities moderated by the auth user */ diff --git a/src/types/LocalSite.ts b/src/types/LocalSite.ts index 9f719c6..36b8124 100644 --- a/src/types/LocalSite.ts +++ b/src/types/LocalSite.ts @@ -115,4 +115,9 @@ export type LocalSite = { * What kind of comment downvotes your site allows. */ comment_downvotes: FederationMode; + /** + * If this is true, users will never see the dialog asking to support Lemmy development with + * donations. + */ + disable_donation_dialog: boolean; }; diff --git a/src/types/LocalUser.ts b/src/types/LocalUser.ts index dc9a4a3..386bb40 100644 --- a/src/types/LocalUser.ts +++ b/src/types/LocalUser.ts @@ -86,4 +86,13 @@ export type LocalUser = { * Whether to automatically mark fetched posts as read. */ auto_mark_fetched_posts_as_read: boolean; + /** + * The last time a donation request was shown to this user. If this is more than a year ago, + * a new notification request should be shown. + */ + last_donation_notification: string; + /** + * Whether to hide posts containing images/videos + */ + hide_media: boolean; }; diff --git a/src/types/PersonContentType.ts b/src/types/PersonContentType.ts index 1f61ba1..4e2577c 100644 --- a/src/types/PersonContentType.ts +++ b/src/types/PersonContentType.ts @@ -1,6 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. /** - * A list of possible types for the various modlog actions. + * A list of possible types for a person's content. */ export type PersonContentType = "All" | "Comments" | "Posts"; diff --git a/src/types/PersonPostMentionView.ts b/src/types/PersonPostMentionView.ts index 8626208..385dd56 100644 --- a/src/types/PersonPostMentionView.ts +++ b/src/types/PersonPostMentionView.ts @@ -5,6 +5,7 @@ import type { Person } from "./Person"; import type { PersonPostMention } from "./PersonPostMention"; import type { Post } from "./Post"; import type { PostAggregates } from "./PostAggregates"; +import type { PostTags } from "./PostTags"; import type { SubscribedType } from "./SubscribedType"; /** @@ -29,4 +30,5 @@ export type PersonPostMentionView = { creator_blocked: boolean; my_vote?: number; unread_comments: number; + post_tags: PostTags; }; diff --git a/src/types/ReportType.ts b/src/types/ReportType.ts new file mode 100644 index 0000000..26615e1 --- /dev/null +++ b/src/types/ReportType.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * A list of possible types for reports. + */ +export type ReportType = + | "All" + | "Posts" + | "Comments" + | "PrivateMessages" + | "Communities"; diff --git a/src/types/SaveUserSettings.ts b/src/types/SaveUserSettings.ts index 78a3769..4cb8ded 100644 --- a/src/types/SaveUserSettings.ts +++ b/src/types/SaveUserSettings.ts @@ -118,4 +118,8 @@ export type SaveUserSettings = { * Whether to automatically mark fetched posts as read. */ auto_mark_fetched_posts_as_read?: boolean; + /** + * Whether to hide posts containing images/videos. + */ + hide_media?: boolean; }; diff --git a/src/types/Search.ts b/src/types/Search.ts index e867ae4..ecb7490 100644 --- a/src/types/Search.ts +++ b/src/types/Search.ts @@ -2,24 +2,25 @@ import type { CommunityId } from "./CommunityId"; import type { ListingType } from "./ListingType"; import type { PersonId } from "./PersonId"; -import type { PostSortType } from "./PostSortType"; +import type { SearchCombinedPaginationCursor } from "./SearchCombinedPaginationCursor"; +import type { SearchSortType } from "./SearchSortType"; import type { SearchType } from "./SearchType"; /** - * Searches the site, given a query string, and some optional filters. + * Searches the site, given a search term, and some optional filters. */ export type Search = { - q: string; + search_term?: string; community_id?: CommunityId; community_name?: string; creator_id?: PersonId; type_?: SearchType; - sort?: PostSortType; + sort?: SearchSortType; listing_type?: ListingType; - page?: number; - limit?: number; title_only?: boolean; post_url_only?: boolean; liked_only?: boolean; disliked_only?: boolean; + page_cursor?: SearchCombinedPaginationCursor; + page_back?: boolean; }; diff --git a/src/types/SearchCombinedPaginationCursor.ts b/src/types/SearchCombinedPaginationCursor.ts new file mode 100644 index 0000000..39716cc --- /dev/null +++ b/src/types/SearchCombinedPaginationCursor.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * like PaginationCursor but for the modlog_combined + */ +export type SearchCombinedPaginationCursor = string; diff --git a/src/types/SearchCombinedView.ts b/src/types/SearchCombinedView.ts new file mode 100644 index 0000000..df2940c --- /dev/null +++ b/src/types/SearchCombinedView.ts @@ -0,0 +1,11 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. +import type { CommentView } from "./CommentView"; +import type { CommunityView } from "./CommunityView"; +import type { PersonView } from "./PersonView"; +import type { PostView } from "./PostView"; + +export type SearchCombinedView = + | ({ type_: "Post" } & PostView) + | ({ type_: "Comment" } & CommentView) + | ({ type_: "Community" } & CommunityView) + | ({ type_: "Person" } & PersonView); diff --git a/src/types/SearchResponse.ts b/src/types/SearchResponse.ts index f1be9fe..04ab8d8 100644 --- a/src/types/SearchResponse.ts +++ b/src/types/SearchResponse.ts @@ -1,17 +1,7 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -import type { CommentView } from "./CommentView"; -import type { CommunityView } from "./CommunityView"; -import type { PersonView } from "./PersonView"; -import type { PostView } from "./PostView"; -import type { SearchType } from "./SearchType"; +import type { SearchCombinedView } from "./SearchCombinedView"; /** * The search response, containing lists of the return type possibilities */ -export type SearchResponse = { - type_: SearchType; - comments: Array; - posts: Array; - communities: Array; - users: Array; -}; +export type SearchResponse = { results: Array }; diff --git a/src/types/SearchSortType.ts b/src/types/SearchSortType.ts new file mode 100644 index 0000000..62f08ec --- /dev/null +++ b/src/types/SearchSortType.ts @@ -0,0 +1,6 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +/** + * The search sort types. + */ +export type SearchSortType = "New" | "Top" | "Old"; diff --git a/src/types/SuccessResponse.ts b/src/types/SuccessResponse.ts index a52239f..641d334 100644 --- a/src/types/SuccessResponse.ts +++ b/src/types/SuccessResponse.ts @@ -1,6 +1,6 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. /** - * Saves settings for your user. + * A response that completes successfully. */ export type SuccessResponse = { success: boolean }; diff --git a/src/types/UploadImageResponse.ts b/src/types/UploadImageResponse.ts index c27b321..666a6b9 100644 --- a/src/types/UploadImageResponse.ts +++ b/src/types/UploadImageResponse.ts @@ -1,6 +1,3 @@ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. -export type UploadImageResponse = { - image_url: string; - filename: string; -}; +export type UploadImageResponse = { image_url: string; filename: string };