mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
feat(api): return discovery category counts and banners for faceted search (#1686)
This commit is contained in:
1 parent
be69157811
commit
8a14281b87
11 files changed
+199
-22
No files matched your search
@@ -6,12 +6,16 @@ export interface SearchOptions {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
cursor?: Array<string>;
|
||||
facets?: Array<string>;
|
||||
}
|
||||
|
||||
export type SearchFacetCounts = Readonly<Record<string, Readonly<Record<string, number>>>>;
|
||||
|
||||
export interface SearchResult<TResult> {
|
||||
hits: Array<TResult>;
|
||||
total: number;
|
||||
cursor?: Array<string>;
|
||||
facetCounts?: SearchFacetCounts;
|
||||
}
|
||||
|
||||
export interface ISearchAdapter<TFilters, TResult> {
|
||||
|
||||
@@ -80,6 +80,7 @@ const DiscoveryGuildResponse = z.object({
|
||||
id: SnowflakeStringType.describe('Guild ID'),
|
||||
name: z.string().describe('Guild name'),
|
||||
icon: z.string().nullish().describe('Guild icon hash'),
|
||||
banner: z.string().nullish().describe('Guild banner hash'),
|
||||
description: z.string().nullish().describe('Discovery description'),
|
||||
category_type: z.number().describe('Discovery category type'),
|
||||
primary_language: z.string().nullish().describe('Primary community language'),
|
||||
@@ -90,9 +91,17 @@ const DiscoveryGuildResponse = z.object({
|
||||
verification_level: z.number().describe('Verification level'),
|
||||
});
|
||||
|
||||
const DiscoveryCategoryCountResponse = z.object({
|
||||
category_type: z.number().describe('Discovery category type'),
|
||||
count: z.number().describe('Number of matching guilds in this category'),
|
||||
});
|
||||
|
||||
export const DiscoveryGuildListResponse = z.object({
|
||||
guilds: z.array(DiscoveryGuildResponse).describe('Discovery guild results'),
|
||||
total: z.number().describe('Total number of matching guilds'),
|
||||
category_counts: z
|
||||
.array(DiscoveryCategoryCountResponse)
|
||||
.describe('Match counts per category for the current filters, ignoring the category filter'),
|
||||
});
|
||||
|
||||
export type DiscoveryGuildListResponse = z.infer<typeof DiscoveryGuildListResponse>;
|
||||
|
||||
Reference in new issue
Block a user