Skip to content

Commit a2d776b

Browse files
feat(javascript): add search wrappers to lite client (generated)
algolia/api-clients-automation#3556 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent c176b39 commit a2d776b

File tree

3 files changed

+74
-39
lines changed

3 files changed

+74
-39
lines changed

bundlesize.config.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"files": [
33
{
44
"path": "packages/algoliasearch/dist/algoliasearch.umd.js",
5-
"maxSize": "8.65KB"
5+
"maxSize": "9.20KB"
66
},
77
{
88
"path": "packages/algoliasearch/dist/lite/lite.umd.js",
9-
"maxSize": "3.90KB"
9+
"maxSize": "3.95KB"
1010
},
1111
{
1212
"path": "packages/client-abtesting/dist/client-abtesting.umd.js",
13-
"maxSize": "4.05KB"
13+
"maxSize": "4.10KB"
1414
},
1515
{
1616
"path": "packages/client-analytics/dist/client-analytics.umd.js",
@@ -30,11 +30,11 @@
3030
},
3131
{
3232
"path": "packages/client-search/dist/client-search.umd.js",
33-
"maxSize": "7.05KB"
33+
"maxSize": "7.15KB"
3434
},
3535
{
3636
"path": "packages/ingestion/dist/ingestion.umd.js",
37-
"maxSize": "5.20KB"
37+
"maxSize": "5.90KB"
3838
},
3939
{
4040
"path": "packages/monitoring/dist/monitoring.umd.js",

packages/algoliasearch/lite/src/liteClient.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import type {
2222
} from '../model/clientMethodProps';
2323
import type { GetRecommendationsParams } from '../model/getRecommendationsParams';
2424
import type { GetRecommendationsResponse } from '../model/getRecommendationsResponse';
25+
import type { SearchForFacetValuesResponse } from '../model/searchForFacetValuesResponse';
2526
import type { SearchMethodParams } from '../model/searchMethodParams';
27+
import type { SearchResponse } from '../model/searchResponse';
2628
import type { SearchResponses } from '../model/searchResponses';
2729

2830
export const apiClientVersion = '5.0.2';
@@ -125,6 +127,39 @@ export function createLiteClient({
125127
transporter.algoliaAgent.add({ segment, version });
126128
},
127129

130+
/**
131+
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
132+
* 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.
133+
*
134+
* @summary Search multiple indices for `hits`.
135+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
136+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
137+
*/
138+
searchForHits<T>(
139+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
140+
requestOptions?: RequestOptions
141+
): Promise<{ results: Array<SearchResponse<T>> }> {
142+
return this.search(searchMethodParams, requestOptions) as Promise<{
143+
results: Array<SearchResponse<T>>;
144+
}>;
145+
},
146+
147+
/**
148+
* Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
149+
* 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.
150+
*
151+
* @summary Search multiple indices for `facets`.
152+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
153+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
154+
*/
155+
searchForFacets(
156+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
157+
requestOptions?: RequestOptions
158+
): Promise<{ results: SearchForFacetValuesResponse[] }> {
159+
return this.search(searchMethodParams, requestOptions) as Promise<{
160+
results: SearchForFacetValuesResponse[];
161+
}>;
162+
},
128163
/**
129164
* This method allow you to send requests to the Algolia REST API.
130165
*

packages/client-search/src/searchClient.ts

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -505,40 +505,6 @@ export function createSearchClient({
505505
});
506506
},
507507

508-
/**
509-
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
510-
* 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.
511-
*
512-
* @summary Search multiple indices for `hits`.
513-
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
514-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
515-
*/
516-
searchForHits<T>(
517-
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
518-
requestOptions?: RequestOptions
519-
): Promise<{ results: Array<SearchResponse<T>> }> {
520-
return this.search(searchMethodParams, requestOptions) as Promise<{
521-
results: Array<SearchResponse<T>>;
522-
}>;
523-
},
524-
525-
/**
526-
* Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
527-
* 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.
528-
*
529-
* @summary Search multiple indices for `facets`.
530-
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
531-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
532-
*/
533-
searchForFacets(
534-
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
535-
requestOptions?: RequestOptions
536-
): Promise<{ results: SearchForFacetValuesResponse[] }> {
537-
return this.search(searchMethodParams, requestOptions) as Promise<{
538-
results: SearchForFacetValuesResponse[];
539-
}>;
540-
},
541-
542508
/**
543509
* Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
544510
*
@@ -725,6 +691,40 @@ export function createSearchClient({
725691

726692
return { copyOperationResponse, batchResponses, moveOperationResponse };
727693
},
694+
695+
/**
696+
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
697+
* 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.
698+
*
699+
* @summary Search multiple indices for `hits`.
700+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
701+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
702+
*/
703+
searchForHits<T>(
704+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
705+
requestOptions?: RequestOptions
706+
): Promise<{ results: Array<SearchResponse<T>> }> {
707+
return this.search(searchMethodParams, requestOptions) as Promise<{
708+
results: Array<SearchResponse<T>>;
709+
}>;
710+
},
711+
712+
/**
713+
* Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
714+
* 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.
715+
*
716+
* @summary Search multiple indices for `facets`.
717+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
718+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
719+
*/
720+
searchForFacets(
721+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
722+
requestOptions?: RequestOptions
723+
): Promise<{ results: SearchForFacetValuesResponse[] }> {
724+
return this.search(searchMethodParams, requestOptions) as Promise<{
725+
results: SearchForFacetValuesResponse[];
726+
}>;
727+
},
728728
/**
729729
* Creates a new API key with specific permissions and restrictions.
730730
*

0 commit comments

Comments
 (0)