File tree Expand file tree Collapse file tree 4 files changed +31
-8
lines changed Expand file tree Collapse file tree 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';
33import {
44 BaseRecommendClient ,
55 RecommendationsQuery ,
6- RecommendedForYouQuery ,
6+ RecommendationsQueryWithoutObjectID ,
77 WithRecommendMethods ,
88} from '../types' ;
99import { TrendingQuery } from '../types/TrendingQuery' ;
@@ -13,9 +13,14 @@ type GetRecommendations = (
1313) => WithRecommendMethods < BaseRecommendClient > [ 'getRecommendations' ] ;
1414
1515export const getRecommendations : GetRecommendations = base => {
16- return ( queries : ReadonlyArray < RecommendationsQuery | TrendingQuery > , requestOptions ) => {
16+ return (
17+ queries : ReadonlyArray <
18+ RecommendationsQuery | TrendingQuery | RecommendationsQueryWithoutObjectID
19+ > ,
20+ requestOptions
21+ ) => {
1722 const requests : ReadonlyArray <
18- RecommendationsQuery | TrendingQuery | RecommendedForYouQuery
23+ RecommendationsQuery | TrendingQuery | RecommendationsQueryWithoutObjectID
1924 > = queries . map ( query => ( {
2025 ...query ,
2126 // 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 = {
3939 */
4040 readonly fallbackParameters ?: RecommendSearchOptions ;
4141} ;
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' ;
22import { RecommendSearchOptions } from './RecommendSearchOptions' ;
33
44export type RecommendedForYouQuery = Omit <
5- RecommendationsQuery ,
6- 'model' | 'objectID' | ' queryParameters'
5+ RecommendationsQueryWithoutObjectID ,
6+ 'model' | 'queryParameters'
77> & {
8+ readonly model : 'recommended-for-you' ;
89 /**
910 * List of [search parameters](https://www.algolia.com/doc/api-reference/search-api-parameters/) to send.
1011 */
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { RequestOptions } from '@algolia/transporter';
44import { RecommendedForYouQuery } from '../builds/node' ;
55import { FrequentlyBoughtTogetherQuery } from './FrequentlyBoughtTogetherQuery' ;
66import { LookingSimilarQuery } from './LookingSimilarQuery' ;
7- import { RecommendationsQuery } from './RecommendationsQuery' ;
7+ import { RecommendationsQuery , RecommendationsQueryWithoutObjectID } from './RecommendationsQuery' ;
88import { RelatedProductsQuery } from './RelatedProductsQuery' ;
99import { TrendingFacetsQuery } from './TrendingFacetsQuery' ;
1010import { TrendingFacetsResponse } from './TrendingFacetsResponse' ;
@@ -30,7 +30,9 @@ export type WithRecommendMethods<TType> = TType & {
3030 * Returns recommendations.
3131 */
3232 readonly getRecommendations : < TObject > (
33- queries : ReadonlyArray < RecommendationsQuery | TrendingQuery > ,
33+ queries : ReadonlyArray <
34+ RecommendationsQuery | TrendingQuery | RecommendationsQueryWithoutObjectID
35+ > ,
3436 requestOptions ?: RequestOptions & SearchOptions
3537 ) => Readonly < Promise < RecommendQueriesResponse < TObject > > > ;
3638
You can’t perform that action at this time.
0 commit comments