Skip to content

Commit 94b46b5

Browse files
authoredDec 7, 2023
fix(recommend): getTrendingFacets typing (#1494)
1 parent db9953c commit 94b46b5

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export type TrendingFacetHit<TObject> = {
2+
readonly _score: number;
3+
readonly facetName: string;
4+
readonly facetValue: TObject;
5+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { SearchResponse } from '@algolia/client-search';
2+
3+
import { TrendingFacetHit } from './TrendingFacetHit';
4+
5+
export type TrendingFacetsResponse<TObject> = Omit<SearchResponse<TObject>, 'hits'> & {
6+
readonly hits: ReadonlyArray<TrendingFacetHit<TObject>>;
7+
};

‎packages/recommend/src/types/WithRecommendMethods.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ import { LookingSimilarQuery } from './LookingSimilarQuery';
66
import { RecommendationsQuery } from './RecommendationsQuery';
77
import { RelatedProductsQuery } from './RelatedProductsQuery';
88
import { TrendingFacetsQuery } from './TrendingFacetsQuery';
9+
import { TrendingFacetsResponse } from './TrendingFacetsResponse';
910
import { TrendingItemsQuery } from './TrendingItemsQuery';
1011
import { TrendingQuery } from './TrendingQuery';
1112

13+
export type RecommendTrendingFacetsQueriesResponse<TObject> = {
14+
/**
15+
* The list of results.
16+
*/
17+
readonly results: ReadonlyArray<TrendingFacetsResponse<TObject>>;
18+
};
19+
1220
export type RecommendQueriesResponse<TObject> = {
1321
/**
1422
* The list of results.
@@ -55,7 +63,7 @@ export type WithRecommendMethods<TType> = TType & {
5563
readonly getTrendingFacets: <TObject>(
5664
queries: readonly TrendingFacetsQuery[],
5765
requestOptions?: RequestOptions & SearchOptions
58-
) => Readonly<Promise<RecommendQueriesResponse<TObject>>>;
66+
) => Readonly<Promise<RecommendTrendingFacetsQueriesResponse<TObject>>>;
5967

6068
/**
6169
* Returns Looking Similar

‎packages/recommend/src/types/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ export * from './TrendingItemsQuery';
1515
export * from './TrendingQuery';
1616
export * from './WithRecommendMethods';
1717
export * from './LookingSimilarQuery';
18+
export * from './TrendingFacetHit';
19+
export * from './TrendingFacetsResponse';

0 commit comments

Comments
 (0)
Please sign in to comment.