Skip to content

Commit 913443f

Browse files
authored
fix(recommend): update trending facets query props (RECO-1184) (#1434)
* fix: update trending facets query props * fix: add more descriptive docs for parameters
1 parent ffbfc05 commit 913443f

5 files changed

Lines changed: 66 additions & 55 deletions

File tree

‎packages/recommend/src/methods/getRecommendations.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ import { MethodEnum } from '@algolia/requester-common';
33
import{
44
BaseRecommendClient,
55
RecommendationsQuery,
6-
TrendingQuery,
6+
TrendingFacetsQuery,
7+
TrendingItemsQuery,
8+
TrendingModel,
79
WithRecommendMethods,
810
}from'../types';
911

1012
typeGetRecommendations=(
1113
base: BaseRecommendClient
1214
)=>WithRecommendMethods<BaseRecommendClient>['getRecommendations'];
1315

16+
typeTrendingQuery=
17+
|(TrendingItemsQuery&{readonlymodel: TrendingModel})
18+
|(TrendingFacetsQuery&{readonlymodel: TrendingModel});
19+
1420
exportconstgetRecommendations: GetRecommendations=base=>{
1521
return(queries: ReadonlyArray<RecommendationsQuery|TrendingQuery>,requestOptions)=>{
1622
constrequests: ReadonlyArray<RecommendationsQuery|TrendingQuery>=queries.map(query=>({
Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1-
import{TrendingQuery}from'./TrendingQuery';
1+
exporttypeTrendingFacetsQuery={
2+
/**
3+
* The name of the target index.
4+
*/
5+
readonlyindexName: string;
26

3-
exporttypeTrendingFacetsQuery=Omit<
4-
TrendingQuery,
5-
'model'|'facetValue'|'fallbackParameters'|'queryParameters'
6-
>;
7+
/**
8+
* Threshold for the recommendations confidence score (between 0 and 100). Only recommendations with a greater score are returned.
9+
*/
10+
readonlythreshold?: number;
11+
12+
/**
13+
* How many recommendations to retrieve.
14+
*/
15+
readonlymaxRecommendations?: number;
16+
17+
/**
18+
* The facet attribute to get recommendations for.
19+
*/
20+
readonlyfacetName: string;
21+
};
Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1-
import{TrendingQuery}from'./TrendingQuery';
1+
import{RecommendSearchOptions}from'@algolia/recommend';
22

3-
exporttypeTrendingItemsQuery=Omit<TrendingQuery,'model'>;
3+
exporttypeTrendingItemsQuery={
4+
/**
5+
* The name of the target index.
6+
*/
7+
readonlyindexName: string;
8+
9+
/**
10+
* Threshold for the recommendations confidence score (between 0 and 100). Only recommendations with a greater score are returned.
11+
*/
12+
readonlythreshold?: number;
13+
14+
/**
15+
* How many recommendations to retrieve.
16+
*/
17+
readonlymaxRecommendations?: number;
18+
19+
/**
20+
* List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
21+
*/
22+
readonlyqueryParameters?: RecommendSearchOptions;
23+
24+
/**
25+
* List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
26+
*
27+
* Additional filters to use as fallback when there aren’t enough recommendations.
28+
*/
29+
readonlyfallbackParameters?: RecommendSearchOptions;
30+
31+
/**
32+
* The facet attribute to get recommendations for.
33+
*/
34+
readonlyfacetName?: string;
35+
36+
/**
37+
* The value of the target facet.
38+
*/
39+
readonlyfacetValue?: string;
40+
};

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

Lines changed: 0 additions & 46 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@ export * from './RecommendSearchOptions';
1111
export*from'./RecommendationsQuery';
1212
export*from'./RelatedProductsQuery';
1313
export*from'./TrendingFacetsQuery';
14-
export*from'./TrendingQuery';
1514
export*from'./TrendingItemsQuery';
1615
export*from'./WithRecommendMethods';

0 commit comments

Comments
 (0)