Skip to content

Commit d18391b

Browse files
authored
fix(recommend): Align getRecommendations type with actual implementation (#1459)
1 parent 9a0a94e commit d18391b

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

packages/recommend/src/methods/getRecommendations.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
import { MethodEnum } from '@algolia/requester-common';
22

3-
import {
4-
BaseRecommendClient,
5-
RecommendationsQuery,
6-
TrendingFacetsQuery,
7-
TrendingItemsQuery,
8-
TrendingModel,
9-
WithRecommendMethods,
10-
} from '../types';
3+
import { BaseRecommendClient, RecommendationsQuery, WithRecommendMethods } from '../types';
4+
import { TrendingQuery } from '../types/TrendingQuery';
115

126
type GetRecommendations = (
137
base: BaseRecommendClient
148
) => WithRecommendMethods<BaseRecommendClient>['getRecommendations'];
159

16-
type TrendingQuery =
17-
| (TrendingItemsQuery & { readonly model: TrendingModel })
18-
| (TrendingFacetsQuery & { readonly model: TrendingModel });
19-
2010
export const getRecommendations: GetRecommendations = base => {
2111
return (queries: ReadonlyArray<RecommendationsQuery | TrendingQuery>, requestOptions) => {
2212
const requests: ReadonlyArray<RecommendationsQuery | TrendingQuery> = queries.map(query => ({
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { TrendingFacetsQuery } from '../types/TrendingFacetsQuery';
2+
import { TrendingItemsQuery } from '../types/TrendingItemsQuery';
3+
import { TrendingModel } from './RecommendModel';
4+
5+
export type TrendingQuery =
6+
| (TrendingItemsQuery & { readonly model: TrendingModel })
7+
| (TrendingFacetsQuery & { readonly model: TrendingModel });

packages/recommend/src/types/WithRecommendMethods.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import { RecommendationsQuery } from './RecommendationsQuery';
66
import { RelatedProductsQuery } from './RelatedProductsQuery';
77
import { TrendingFacetsQuery } from './TrendingFacetsQuery';
88
import { TrendingItemsQuery } from './TrendingItemsQuery';
9+
import { TrendingQuery } from './TrendingQuery';
910

1011
export type WithRecommendMethods<TType> = TType & {
1112
/**
1213
* Returns recommendations.
1314
*/
1415
readonly getRecommendations: <TObject>(
15-
queries: readonly RecommendationsQuery[],
16+
queries: ReadonlyArray<RecommendationsQuery | TrendingQuery>,
1617
requestOptions?: RequestOptions & SearchOptions
1718
) => Readonly<Promise<MultipleQueriesResponse<TObject>>>;
1819

packages/recommend/src/types/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ export * from './RecommendationsQuery';
1212
export * from './RelatedProductsQuery';
1313
export * from './TrendingFacetsQuery';
1414
export * from './TrendingItemsQuery';
15+
export * from './TrendingQuery';
1516
export * from './WithRecommendMethods';

0 commit comments

Comments
 (0)