From a9964a23f95646cebbdb6d39bdefc469faf41ced Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Tue, 20 Aug 2024 12:01:01 +0000 Subject: [PATCH] feat(javascript): add search wrappers to lite client (generated) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/algolia/api-clients-automation/pull/3556 Co-authored-by: algolia-bot Co-authored-by: Clément Vannicatte --- bundlesize.config.json | 10 +-- packages/algoliasearch/lite/src/liteClient.ts | 35 ++++++++++ packages/client-search/src/searchClient.ts | 68 +++++++++---------- 3 files changed, 74 insertions(+), 39 deletions(-) diff --git a/bundlesize.config.json b/bundlesize.config.json index d59d6b53d..645aebd80 100644 --- a/bundlesize.config.json +++ b/bundlesize.config.json @@ -2,15 +2,15 @@ "files": [ { "path": "packages/algoliasearch/dist/algoliasearch.umd.js", - "maxSize": "8.65KB" + "maxSize": "9.20KB" }, { "path": "packages/algoliasearch/dist/lite/lite.umd.js", - "maxSize": "3.90KB" + "maxSize": "3.95KB" }, { "path": "packages/client-abtesting/dist/client-abtesting.umd.js", - "maxSize": "4.05KB" + "maxSize": "4.10KB" }, { "path": "packages/client-analytics/dist/client-analytics.umd.js", @@ -30,11 +30,11 @@ }, { "path": "packages/client-search/dist/client-search.umd.js", - "maxSize": "7.05KB" + "maxSize": "7.15KB" }, { "path": "packages/ingestion/dist/ingestion.umd.js", - "maxSize": "5.20KB" + "maxSize": "5.90KB" }, { "path": "packages/monitoring/dist/monitoring.umd.js", diff --git a/packages/algoliasearch/lite/src/liteClient.ts b/packages/algoliasearch/lite/src/liteClient.ts index d693bf450..170c54735 100644 --- a/packages/algoliasearch/lite/src/liteClient.ts +++ b/packages/algoliasearch/lite/src/liteClient.ts @@ -22,7 +22,9 @@ import type { } from '../model/clientMethodProps'; import type { GetRecommendationsParams } from '../model/getRecommendationsParams'; import type { GetRecommendationsResponse } from '../model/getRecommendationsResponse'; +import type { SearchForFacetValuesResponse } from '../model/searchForFacetValuesResponse'; import type { SearchMethodParams } from '../model/searchMethodParams'; +import type { SearchResponse } from '../model/searchResponse'; import type { SearchResponses } from '../model/searchResponses'; export const apiClientVersion = '5.0.2'; @@ -125,6 +127,39 @@ export function createLiteClient({ transporter.algoliaAgent.add({ segment, version }); }, + /** + * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets. + * Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes. + * + * @summary Search multiple indices for `hits`. + * @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries. + * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. + */ + searchForHits( + searchMethodParams: LegacySearchMethodProps | SearchMethodParams, + requestOptions?: RequestOptions + ): Promise<{ results: Array> }> { + return this.search(searchMethodParams, requestOptions) as Promise<{ + results: Array>; + }>; + }, + + /** + * Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits). + * Disclaimer: We don't assert that the parameters you pass to this method only contains `facets` requests to prevent impacting search performances, this helper is purely for typing purposes. + * + * @summary Search multiple indices for `facets`. + * @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries. + * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. + */ + searchForFacets( + searchMethodParams: LegacySearchMethodProps | SearchMethodParams, + requestOptions?: RequestOptions + ): Promise<{ results: SearchForFacetValuesResponse[] }> { + return this.search(searchMethodParams, requestOptions) as Promise<{ + results: SearchForFacetValuesResponse[]; + }>; + }, /** * This method allow you to send requests to the Algolia REST API. * diff --git a/packages/client-search/src/searchClient.ts b/packages/client-search/src/searchClient.ts index 57a5febb6..3b5f8a215 100644 --- a/packages/client-search/src/searchClient.ts +++ b/packages/client-search/src/searchClient.ts @@ -505,40 +505,6 @@ export function createSearchClient({ }); }, - /** - * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets. - * Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes. - * - * @summary Search multiple indices for `hits`. - * @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries. - * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. - */ - searchForHits( - searchMethodParams: LegacySearchMethodProps | SearchMethodParams, - requestOptions?: RequestOptions - ): Promise<{ results: Array> }> { - return this.search(searchMethodParams, requestOptions) as Promise<{ - results: Array>; - }>; - }, - - /** - * Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits). - * Disclaimer: We don't assert that the parameters you pass to this method only contains `facets` requests to prevent impacting search performances, this helper is purely for typing purposes. - * - * @summary Search multiple indices for `facets`. - * @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries. - * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. - */ - searchForFacets( - searchMethodParams: LegacySearchMethodProps | SearchMethodParams, - requestOptions?: RequestOptions - ): Promise<{ results: SearchForFacetValuesResponse[] }> { - return this.search(searchMethodParams, requestOptions) as Promise<{ - results: SearchForFacetValuesResponse[]; - }>; - }, - /** * Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests. * @@ -725,6 +691,40 @@ export function createSearchClient({ return { copyOperationResponse, batchResponses, moveOperationResponse }; }, + + /** + * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets. + * Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes. + * + * @summary Search multiple indices for `hits`. + * @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries. + * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. + */ + searchForHits( + searchMethodParams: LegacySearchMethodProps | SearchMethodParams, + requestOptions?: RequestOptions + ): Promise<{ results: Array> }> { + return this.search(searchMethodParams, requestOptions) as Promise<{ + results: Array>; + }>; + }, + + /** + * Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits). + * Disclaimer: We don't assert that the parameters you pass to this method only contains `facets` requests to prevent impacting search performances, this helper is purely for typing purposes. + * + * @summary Search multiple indices for `facets`. + * @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries. + * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. + */ + searchForFacets( + searchMethodParams: LegacySearchMethodProps | SearchMethodParams, + requestOptions?: RequestOptions + ): Promise<{ results: SearchForFacetValuesResponse[] }> { + return this.search(searchMethodParams, requestOptions) as Promise<{ + results: SearchForFacetValuesResponse[]; + }>; + }, /** * Creates a new API key with specific permissions and restrictions. *