File tree 4 files changed +31
-8
lines changed
4 files changed +31
-8
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { MethodEnum } from '@algolia/requester-common';
3
3
import {
4
4
BaseRecommendClient ,
5
5
RecommendationsQuery ,
6
- RecommendedForYouQuery ,
6
+ RecommendationsQueryWithoutObjectID ,
7
7
WithRecommendMethods ,
8
8
} from '../types' ;
9
9
import { TrendingQuery } from '../types/TrendingQuery' ;
@@ -13,9 +13,14 @@ type GetRecommendations = (
13
13
) => WithRecommendMethods < BaseRecommendClient > [ 'getRecommendations' ] ;
14
14
15
15
export const getRecommendations : GetRecommendations = base => {
16
- return ( queries : ReadonlyArray < RecommendationsQuery | TrendingQuery > , requestOptions ) => {
16
+ return (
17
+ queries : ReadonlyArray <
18
+ RecommendationsQuery | TrendingQuery | RecommendationsQueryWithoutObjectID
19
+ > ,
20
+ requestOptions
21
+ ) => {
17
22
const requests : ReadonlyArray <
18
- RecommendationsQuery | TrendingQuery | RecommendedForYouQuery
23
+ RecommendationsQuery | TrendingQuery | RecommendationsQueryWithoutObjectID
19
24
> = queries . map ( query => ( {
20
25
...query ,
21
26
// The `threshold` param is required by the endpoint to make it easier
Original file line number Diff line number Diff line change @@ -39,3 +39,18 @@ export type RecommendationsQuery = {
39
39
*/
40
40
readonly fallbackParameters ?: RecommendSearchOptions ;
41
41
} ;
42
+
43
+ /**
44
+ * Base type for models that don't require an `objectID`.
45
+ *
46
+ * Currently the only model that doesn't require an `objectID` is `recommended-for-you`.
47
+ */
48
+ export type RecommendationsQueryWithoutObjectID = Omit <
49
+ RecommendationsQuery ,
50
+ 'objectID' | 'model'
51
+ > & {
52
+ /**
53
+ * The name of the Recommendation model to use.
54
+ */
55
+ readonly model : 'recommended-for-you' ;
56
+ } ;
Original file line number Diff line number Diff line change 1
- import { RecommendationsQuery } from './RecommendationsQuery' ;
1
+ import { RecommendationsQueryWithoutObjectID } from './RecommendationsQuery' ;
2
2
import { RecommendSearchOptions } from './RecommendSearchOptions' ;
3
3
4
4
export type RecommendedForYouQuery = Omit <
5
- RecommendationsQuery ,
6
- 'model' | 'objectID' | ' queryParameters'
5
+ RecommendationsQueryWithoutObjectID ,
6
+ 'model' | 'queryParameters'
7
7
> & {
8
+ readonly model : 'recommended-for-you' ;
8
9
/**
9
10
* List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
10
11
*/
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { RequestOptions } from '@algolia/transporter';
4
4
import { RecommendedForYouQuery } from '../builds/node' ;
5
5
import { FrequentlyBoughtTogetherQuery } from './FrequentlyBoughtTogetherQuery' ;
6
6
import { LookingSimilarQuery } from './LookingSimilarQuery' ;
7
- import { RecommendationsQuery } from './RecommendationsQuery' ;
7
+ import { RecommendationsQuery , RecommendationsQueryWithoutObjectID } from './RecommendationsQuery' ;
8
8
import { RelatedProductsQuery } from './RelatedProductsQuery' ;
9
9
import { TrendingFacetsQuery } from './TrendingFacetsQuery' ;
10
10
import { TrendingFacetsResponse } from './TrendingFacetsResponse' ;
@@ -30,7 +30,9 @@ export type WithRecommendMethods<TType> = TType & {
30
30
* Returns recommendations.
31
31
*/
32
32
readonly getRecommendations : < TObject > (
33
- queries : ReadonlyArray < RecommendationsQuery | TrendingQuery > ,
33
+ queries : ReadonlyArray <
34
+ RecommendationsQuery | TrendingQuery | RecommendationsQueryWithoutObjectID
35
+ > ,
34
36
requestOptions ?: RequestOptions & SearchOptions
35
37
) => Readonly < Promise < RecommendQueriesResponse < TObject > > > ;
36
38
You can’t perform that action at this time.
0 commit comments