Skip to content

Commit

Permalink
fix(recommend): getTrendingFacets typing (#1494)
Browse files Browse the repository at this point in the history
  • Loading branch information
marialungu authored Dec 7, 2023
1 parent db9953c commit 94b46b5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/recommend/src/types/TrendingFacetHit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export type TrendingFacetHit<TObject> = {
readonly _score: number;
readonly facetName: string;
readonly facetValue: TObject;
};
7 changes: 7 additions & 0 deletions packages/recommend/src/types/TrendingFacetsResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { SearchResponse } from '@algolia/client-search';

import { TrendingFacetHit } from './TrendingFacetHit';

export type TrendingFacetsResponse<TObject> = Omit<SearchResponse<TObject>, 'hits'> & {
readonly hits: ReadonlyArray<TrendingFacetHit<TObject>>;
};
10 changes: 9 additions & 1 deletion packages/recommend/src/types/WithRecommendMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ import { LookingSimilarQuery } from './LookingSimilarQuery';
import { RecommendationsQuery } from './RecommendationsQuery';
import { RelatedProductsQuery } from './RelatedProductsQuery';
import { TrendingFacetsQuery } from './TrendingFacetsQuery';
import { TrendingFacetsResponse } from './TrendingFacetsResponse';
import { TrendingItemsQuery } from './TrendingItemsQuery';
import { TrendingQuery } from './TrendingQuery';

export type RecommendTrendingFacetsQueriesResponse<TObject> = {
/**
* The list of results.
*/
readonly results: ReadonlyArray<TrendingFacetsResponse<TObject>>;
};

export type RecommendQueriesResponse<TObject> = {
/**
* The list of results.
Expand Down Expand Up @@ -55,7 +63,7 @@ export type WithRecommendMethods<TType> = TType & {
readonly getTrendingFacets: <TObject>(
queries: readonly TrendingFacetsQuery[],
requestOptions?: RequestOptions & SearchOptions
) => Readonly<Promise<RecommendQueriesResponse<TObject>>>;
) => Readonly<Promise<RecommendTrendingFacetsQueriesResponse<TObject>>>;

/**
* Returns Looking Similar
Expand Down
2 changes: 2 additions & 0 deletions packages/recommend/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export * from './TrendingItemsQuery';
export * from './TrendingQuery';
export * from './WithRecommendMethods';
export * from './LookingSimilarQuery';
export * from './TrendingFacetHit';
export * from './TrendingFacetsResponse';

0 comments on commit 94b46b5

Please sign in to comment.