From 94b46b582d164822194cce01aae07b83fe081cbe Mon Sep 17 00:00:00 2001 From: Maria Lungu Date: Thu, 7 Dec 2023 11:08:47 +0100 Subject: [PATCH] fix(recommend): getTrendingFacets typing (#1494) --- packages/recommend/src/types/TrendingFacetHit.ts | 5 +++++ packages/recommend/src/types/TrendingFacetsResponse.ts | 7 +++++++ packages/recommend/src/types/WithRecommendMethods.ts | 10 +++++++++- packages/recommend/src/types/index.ts | 2 ++ 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 packages/recommend/src/types/TrendingFacetHit.ts create mode 100644 packages/recommend/src/types/TrendingFacetsResponse.ts diff --git a/packages/recommend/src/types/TrendingFacetHit.ts b/packages/recommend/src/types/TrendingFacetHit.ts new file mode 100644 index 000000000..5b152f032 --- /dev/null +++ b/packages/recommend/src/types/TrendingFacetHit.ts @@ -0,0 +1,5 @@ +export type TrendingFacetHit = { + readonly _score: number; + readonly facetName: string; + readonly facetValue: TObject; +}; diff --git a/packages/recommend/src/types/TrendingFacetsResponse.ts b/packages/recommend/src/types/TrendingFacetsResponse.ts new file mode 100644 index 000000000..db074bd4a --- /dev/null +++ b/packages/recommend/src/types/TrendingFacetsResponse.ts @@ -0,0 +1,7 @@ +import { SearchResponse } from '@algolia/client-search'; + +import { TrendingFacetHit } from './TrendingFacetHit'; + +export type TrendingFacetsResponse = Omit, 'hits'> & { + readonly hits: ReadonlyArray>; +}; diff --git a/packages/recommend/src/types/WithRecommendMethods.ts b/packages/recommend/src/types/WithRecommendMethods.ts index a2833670f..1647e2f67 100644 --- a/packages/recommend/src/types/WithRecommendMethods.ts +++ b/packages/recommend/src/types/WithRecommendMethods.ts @@ -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 = { + /** + * The list of results. + */ + readonly results: ReadonlyArray>; +}; + export type RecommendQueriesResponse = { /** * The list of results. @@ -55,7 +63,7 @@ export type WithRecommendMethods = TType & { readonly getTrendingFacets: ( queries: readonly TrendingFacetsQuery[], requestOptions?: RequestOptions & SearchOptions - ) => Readonly>>; + ) => Readonly>>; /** * Returns Looking Similar diff --git a/packages/recommend/src/types/index.ts b/packages/recommend/src/types/index.ts index f99bee2ad..8c73656da 100644 --- a/packages/recommend/src/types/index.ts +++ b/packages/recommend/src/types/index.ts @@ -15,3 +15,5 @@ export * from './TrendingItemsQuery'; export * from './TrendingQuery'; export * from './WithRecommendMethods'; export * from './LookingSimilarQuery'; +export * from './TrendingFacetHit'; +export * from './TrendingFacetsResponse';