Skip to content

Commit 0d304e6

Browse files
fix: remove items for facet as in the search and use it within trending-item
1 parent 4014f29 commit 0d304e6

12 files changed

+20
-112
lines changed

packages/recommend/src/__tests__/getTrendingGlobalItems.test.ts renamed to packages/recommend/src/__tests__/getTrendingItems.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ function createMockedClient() {
99
return client;
1010
}
1111

12-
describe('getTrendingGlobalItems', () => {
12+
describe('getTrendingItems', () => {
1313
test('builds the request', async () => {
1414
const client = createMockedClient();
1515

16-
await client.getTrendingGlobalItems(
16+
await client.getTrendingItems(
1717
[
1818
{
1919
indexName: 'products',

packages/recommend/src/__tests__/getTrendingItemsForFacet.test.ts

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

packages/recommend/src/builds/browser.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ import {
1313
getRecommendations,
1414
getRelatedProducts,
1515
getTrendingFacets,
16-
getTrendingGlobalItems,
17-
getTrendingItemsForFacet,
16+
getTrendingItems,
1817
} from '../methods';
1918
import { BaseRecommendClient, RecommendOptions, WithRecommendMethods } from '../types';
2019

@@ -55,8 +54,7 @@ export default function recommend(
5554
getRecommendations,
5655
getRelatedProducts,
5756
getTrendingFacets,
58-
getTrendingGlobalItems,
59-
getTrendingItemsForFacet,
57+
getTrendingItems,
6058
},
6159
});
6260
}

packages/recommend/src/builds/node.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {
1212
getRecommendations,
1313
getRelatedProducts,
1414
getTrendingFacets,
15-
getTrendingGlobalItems,
16-
getTrendingItemsForFacet,
15+
getTrendingItems,
1716
} from '../methods';
1817
import { BaseRecommendClient, RecommendOptions, WithRecommendMethods } from '../types';
1918

@@ -49,8 +48,7 @@ export default function recommend(
4948
getRecommendations,
5049
getRelatedProducts,
5150
getTrendingFacets,
52-
getTrendingGlobalItems,
53-
getTrendingItemsForFacet,
51+
getTrendingItems,
5452
},
5553
});
5654
}

packages/recommend/src/methods/getTrendingGlobalItems.ts renamed to packages/recommend/src/methods/getTrendingItems.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { MethodEnum } from '@algolia/requester-common';
22

3-
import { BaseRecommendClient, TrendingGlobalItemsQuery, WithRecommendMethods } from '../types';
3+
import { BaseRecommendClient, TrendingItemsQuery, WithRecommendMethods } from '../types';
44

5-
type GetTrendingGlobalItems = (
5+
type GetTrendingItems = (
66
base: BaseRecommendClient
7-
) => WithRecommendMethods<BaseRecommendClient>['getTrendingGlobalItems'];
7+
) => WithRecommendMethods<BaseRecommendClient>['getTrendingItems'];
88

9-
export const getTrendingGlobalItems: GetTrendingGlobalItems = base => {
10-
return (queries: readonly TrendingGlobalItemsQuery[], requestOptions) => {
11-
const requests: readonly TrendingGlobalItemsQuery[] = queries.map(query => ({
9+
export const getTrendingItems: GetTrendingItems = base => {
10+
return (queries: readonly TrendingItemsQuery[], requestOptions) => {
11+
const requests: readonly TrendingItemsQuery[] = queries.map(query => ({
1212
...query,
1313
model: 'trending-items',
1414
// The `threshold` param is required by the endpoint to make it easier

packages/recommend/src/methods/getTrendingItemsForFacet.ts

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

packages/recommend/src/methods/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ export * from './getFrequentlyBoughtTogether';
66
export * from './getRecommendations';
77
export * from './getRelatedProducts';
88
export * from './getTrendingFacets';
9-
export * from './getTrendingGlobalItems';
10-
export * from './getTrendingItemsForFacet';
9+
export * from './getTrendingItems';

packages/recommend/src/types/TrendingGlobalItemsQuery.ts

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

packages/recommend/src/types/TrendingItemsForFacetQuery.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { RecommendationsQuery } from './RecommendationsQuery';
2+
3+
export type TrendingItemsQuery = Omit<RecommendationsQuery, 'model' | 'objectID'>;

packages/recommend/src/types/WithRecommendMethods.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import { FrequentlyBoughtTogetherQuery } from './FrequentlyBoughtTogetherQuery';
55
import { RecommendationsQuery } from './RecommendationsQuery';
66
import { RelatedProductsQuery } from './RelatedProductsQuery';
77
import { TrendingFacetsQuery } from './TrendingFacetsQuery';
8-
import { TrendingGlobalItemsQuery } from './TrendingGlobalItemsQuery';
9-
import { TrendingItemsForFacetQuery } from './TrendingItemsForFacetQuery';
8+
import { TrendingItemsQuery } from './TrendingItemsQuery';
109

1110
export type WithRecommendMethods<TType> = TType & {
1211
/**
@@ -36,16 +35,8 @@ export type WithRecommendMethods<TType> = TType & {
3635
/**
3736
* Returns trending items
3837
*/
39-
readonly getTrendingGlobalItems: <TObject>(
40-
queries: readonly TrendingGlobalItemsQuery[],
41-
requestOptions?: RequestOptions & SearchOptions
42-
) => Readonly<Promise<MultipleQueriesResponse<TObject>>>;
43-
44-
/**
45-
* Returns trending items per facet
46-
*/
47-
readonly getTrendingItemsForFacet: <TObject>(
48-
queries: readonly TrendingItemsForFacetQuery[],
38+
readonly getTrendingItems: <TObject>(
39+
queries: readonly TrendingItemsQuery[],
4940
requestOptions?: RequestOptions & SearchOptions
5041
) => Readonly<Promise<MultipleQueriesResponse<TObject>>>;
5142

packages/recommend/src/types/index.ts

Lines changed: 1 addition & 2 deletions
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 './TrendingGlobalItemsQuery';
15-
export * from './TrendingItemsForFacetQuery';
14+
export * from './TrendingItemsQuery';
1615
export * from './WithRecommendMethods';

0 commit comments

Comments
 (0)