Search combined (#457)

* Adding search combined types.

* 0.20.0-search-combined.0

* 0.20.0-search-combined.1
This commit is contained in:
Dessalines 2025-01-31 15:46:09 -05:00 committed by GitHub
parent 034e4a3b5a
commit e1bfcdcb81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 143 additions and 26 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "lemmy-js-client", "name": "lemmy-js-client",
"description": "A javascript / typescript client for Lemmy", "description": "A javascript / typescript client for Lemmy",
"version": "0.20.0-inbox-combined.1", "version": "0.20.0-search-combined.1",
"author": "Dessalines", "author": "Dessalines",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "./dist/index.js", "main": "./dist/index.js",

View file

@ -184,6 +184,7 @@ import { ListInboxResponse } from "./types/ListInboxResponse";
import { ListInbox } from "./types/ListInbox"; import { ListInbox } from "./types/ListInbox";
import { MarkPersonCommentMentionAsRead } from "./types/MarkPersonCommentMentionAsRead"; import { MarkPersonCommentMentionAsRead } from "./types/MarkPersonCommentMentionAsRead";
import { MarkPersonPostMentionAsRead } from "./types/MarkPersonPostMentionAsRead"; import { MarkPersonPostMentionAsRead } from "./types/MarkPersonPostMentionAsRead";
import { GetCommentsSlimResponse } from "./types/GetCommentsSlimResponse";
import { import {
Body, Body,
Controller, 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<GetComments, GetCommentsSlimResponse>(
HttpType.Get,
"/comment/list/slim",
form,
options,
);
}
/** /**
* Get / fetch comment. * Get / fetch comment.
*/ */

View file

@ -50,6 +50,7 @@ export { CommentReportId } from "./types/CommentReportId";
export { CommentReportResponse } from "./types/CommentReportResponse"; export { CommentReportResponse } from "./types/CommentReportResponse";
export { CommentReportView } from "./types/CommentReportView"; export { CommentReportView } from "./types/CommentReportView";
export { CommentResponse } from "./types/CommentResponse"; export { CommentResponse } from "./types/CommentResponse";
export { CommentSlimView } from "./types/CommentSlimView";
export { CommentSortType } from "./types/CommentSortType"; export { CommentSortType } from "./types/CommentSortType";
export { CommentView } from "./types/CommentView"; export { CommentView } from "./types/CommentView";
export { Community } from "./types/Community"; export { Community } from "./types/Community";
@ -112,6 +113,7 @@ export { GetCaptchaResponse } from "./types/GetCaptchaResponse";
export { GetComment } from "./types/GetComment"; export { GetComment } from "./types/GetComment";
export { GetComments } from "./types/GetComments"; export { GetComments } from "./types/GetComments";
export { GetCommentsResponse } from "./types/GetCommentsResponse"; export { GetCommentsResponse } from "./types/GetCommentsResponse";
export { GetCommentsSlimResponse } from "./types/GetCommentsSlimResponse";
export { GetCommunity } from "./types/GetCommunity"; export { GetCommunity } from "./types/GetCommunity";
export { GetCommunityPendingFollowsCount } from "./types/GetCommunityPendingFollowsCount"; export { GetCommunityPendingFollowsCount } from "./types/GetCommunityPendingFollowsCount";
export { GetCommunityPendingFollowsCountResponse } from "./types/GetCommunityPendingFollowsCountResponse"; export { GetCommunityPendingFollowsCountResponse } from "./types/GetCommunityPendingFollowsCountResponse";
@ -292,6 +294,7 @@ export { RemoveCommunity } from "./types/RemoveCommunity";
export { RemovePost } from "./types/RemovePost"; export { RemovePost } from "./types/RemovePost";
export { ReportCombinedPaginationCursor } from "./types/ReportCombinedPaginationCursor"; export { ReportCombinedPaginationCursor } from "./types/ReportCombinedPaginationCursor";
export { ReportCombinedView } from "./types/ReportCombinedView"; export { ReportCombinedView } from "./types/ReportCombinedView";
export { ReportType } from "./types/ReportType";
export { ResolveCommentReport } from "./types/ResolveCommentReport"; export { ResolveCommentReport } from "./types/ResolveCommentReport";
export { ResolveObject } from "./types/ResolveObject"; export { ResolveObject } from "./types/ResolveObject";
export { ResolveObjectResponse } from "./types/ResolveObjectResponse"; export { ResolveObjectResponse } from "./types/ResolveObjectResponse";
@ -301,7 +304,10 @@ export { SaveComment } from "./types/SaveComment";
export { SavePost } from "./types/SavePost"; export { SavePost } from "./types/SavePost";
export { SaveUserSettings } from "./types/SaveUserSettings"; export { SaveUserSettings } from "./types/SaveUserSettings";
export { Search } from "./types/Search"; export { Search } from "./types/Search";
export { SearchCombinedPaginationCursor } from "./types/SearchCombinedPaginationCursor";
export { SearchCombinedView } from "./types/SearchCombinedView";
export { SearchResponse } from "./types/SearchResponse"; export { SearchResponse } from "./types/SearchResponse";
export { SearchSortType } from "./types/SearchSortType";
export { SearchType } from "./types/SearchType"; export { SearchType } from "./types/SearchType";
export { SensitiveString } from "./types/SensitiveString"; export { SensitiveString } from "./types/SensitiveString";
export { Site } from "./types/Site"; export { Site } from "./types/Site";

View file

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

View file

@ -51,4 +51,5 @@ export type CreateSite = {
post_downvotes?: FederationMode; post_downvotes?: FederationMode;
comment_upvotes?: FederationMode; comment_upvotes?: FederationMode;
comment_downvotes?: FederationMode; comment_downvotes?: FederationMode;
disable_donation_dialog?: boolean;
}; };

View file

@ -156,4 +156,9 @@ export type EditSite = {
* What kind of comment downvotes your site allows. * What kind of comment downvotes your site allows.
*/ */
comment_downvotes?: FederationMode; comment_downvotes?: FederationMode;
/**
* If this is true, users will never see the dialog asking to support Lemmy development with
* donations.
*/
disable_donation_dialog?: boolean;
}; };

View file

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

View file

@ -30,6 +30,10 @@ export type GetPosts = {
* If true, then show the nsfw posts (even if your user setting is to hide them) * If true, then show the nsfw posts (even if your user setting is to hide them)
*/ */
show_nsfw?: boolean; 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. * Whether to automatically mark fetched posts as read.
*/ */

View file

@ -4,4 +4,4 @@ import type { ListingType } from "./ListingType";
/** /**
* Fetches a random community * Fetches a random community
*/ */
export type GetRandomCommunity = { type_?: ListingType }; export type GetRandomCommunity = { type_?: ListingType; show_nsfw?: boolean };

View file

@ -1,6 +1,8 @@
// 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 { CommunityId } from "./CommunityId";
import type { PostId } from "./PostId";
import type { ReportCombinedPaginationCursor } from "./ReportCombinedPaginationCursor"; import type { ReportCombinedPaginationCursor } from "./ReportCombinedPaginationCursor";
import type { ReportType } from "./ReportType";
/** /**
* List reports. * List reports.
@ -10,6 +12,14 @@ export type ListReports = {
* Only shows the unresolved reports * Only shows the unresolved reports
*/ */
unresolved_only?: boolean; 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 * if no community is given, it returns reports for all communities moderated by the auth user
*/ */

View file

@ -115,4 +115,9 @@ export type LocalSite = {
* What kind of comment downvotes your site allows. * What kind of comment downvotes your site allows.
*/ */
comment_downvotes: FederationMode; comment_downvotes: FederationMode;
/**
* If this is true, users will never see the dialog asking to support Lemmy development with
* donations.
*/
disable_donation_dialog: boolean;
}; };

View file

@ -86,4 +86,13 @@ export type LocalUser = {
* Whether to automatically mark fetched posts as read. * Whether to automatically mark fetched posts as read.
*/ */
auto_mark_fetched_posts_as_read: boolean; 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;
}; };

View file

@ -1,6 +1,6 @@
// 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.
/** /**
* 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"; export type PersonContentType = "All" | "Comments" | "Posts";

View file

@ -5,6 +5,7 @@ import type { Person } from "./Person";
import type { PersonPostMention } from "./PersonPostMention"; import type { PersonPostMention } from "./PersonPostMention";
import type { Post } from "./Post"; import type { Post } from "./Post";
import type { PostAggregates } from "./PostAggregates"; import type { PostAggregates } from "./PostAggregates";
import type { PostTags } from "./PostTags";
import type { SubscribedType } from "./SubscribedType"; import type { SubscribedType } from "./SubscribedType";
/** /**
@ -29,4 +30,5 @@ export type PersonPostMentionView = {
creator_blocked: boolean; creator_blocked: boolean;
my_vote?: number; my_vote?: number;
unread_comments: number; unread_comments: number;
post_tags: PostTags;
}; };

11
src/types/ReportType.ts Normal file
View file

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

View file

@ -118,4 +118,8 @@ export type SaveUserSettings = {
* Whether to automatically mark fetched posts as read. * Whether to automatically mark fetched posts as read.
*/ */
auto_mark_fetched_posts_as_read?: boolean; auto_mark_fetched_posts_as_read?: boolean;
/**
* Whether to hide posts containing images/videos.
*/
hide_media?: boolean;
}; };

View file

@ -2,24 +2,25 @@
import type { CommunityId } from "./CommunityId"; import type { CommunityId } from "./CommunityId";
import type { ListingType } from "./ListingType"; import type { ListingType } from "./ListingType";
import type { PersonId } from "./PersonId"; 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"; 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 = { export type Search = {
q: string; search_term?: string;
community_id?: CommunityId; community_id?: CommunityId;
community_name?: string; community_name?: string;
creator_id?: PersonId; creator_id?: PersonId;
type_?: SearchType; type_?: SearchType;
sort?: PostSortType; sort?: SearchSortType;
listing_type?: ListingType; listing_type?: ListingType;
page?: number;
limit?: number;
title_only?: boolean; title_only?: boolean;
post_url_only?: boolean; post_url_only?: boolean;
liked_only?: boolean; liked_only?: boolean;
disliked_only?: boolean; disliked_only?: boolean;
page_cursor?: SearchCombinedPaginationCursor;
page_back?: boolean;
}; };

View file

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

View file

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

View file

@ -1,17 +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 { CommentView } from "./CommentView"; import type { SearchCombinedView } from "./SearchCombinedView";
import type { CommunityView } from "./CommunityView";
import type { PersonView } from "./PersonView";
import type { PostView } from "./PostView";
import type { SearchType } from "./SearchType";
/** /**
* The search response, containing lists of the return type possibilities * The search response, containing lists of the return type possibilities
*/ */
export type SearchResponse = { export type SearchResponse = { results: Array<SearchCombinedView> };
type_: SearchType;
comments: Array<CommentView>;
posts: Array<PostView>;
communities: Array<CommunityView>;
users: Array<PersonView>;
};

View file

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

View file

@ -1,6 +1,6 @@
// 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.
/** /**
* Saves settings for your user. * A response that completes successfully.
*/ */
export type SuccessResponse = { success: boolean }; export type SuccessResponse = { success: boolean };

View file

@ -1,6 +1,3 @@
// 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 UploadImageResponse = { export type UploadImageResponse = { image_url: string; filename: string };
image_url: string;
filename: string;
};