Skip to content

Commit c834388

Browse files
authoredAug 20, 2024
feat(javascript): add search wrappers to lite client (#3556)
1 parent 99aac2a commit c834388

File tree

6 files changed

+45
-37
lines changed

6 files changed

+45
-37
lines changed
 

‎.github/workflows/check.yml

-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ jobs:
220220
run: cd clients/algoliasearch-client-javascript && yarn test ${{ !contains(fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).toRun, 'algoliasearch') && '--ignore algoliasearch' || '' }}
221221

222222
- name: Test JavaScript bundle size
223-
if: ${{ startsWith(env.head_ref, 'chore/prepare-release-') }}
224223
run: cd clients/algoliasearch-client-javascript && yarn test:size
225224

226225
- name: Remove previous CTS output

‎clients/algoliasearch-client-javascript/bundlesize.config.json

+5-5
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",

‎generators/src/main/java/com/algolia/codegen/AlgoliaJavascriptGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ private void setDefaultGeneratorOptions() {
145145

146146
additionalProperties.put("apiName", apiName);
147147
additionalProperties.put("algoliaAgent", Helpers.capitalize(CLIENT));
148-
additionalProperties.put("isSearchClient", CLIENT.equals("search"));
148+
additionalProperties.put("isSearchClient", CLIENT.equals("search") || isAlgoliasearchClient);
149149
additionalProperties.put("isIngestionClient", CLIENT.equals("ingestion"));
150150
additionalProperties.put("isAlgoliasearchClient", isAlgoliasearchClient);
151151
additionalProperties.put("packageVersion", Helpers.getPackageJsonVersion(packageName));

‎templates/javascript/clients/client/api/helpers.mustache

+32-30
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{{^isAlgoliasearchClient}}
12
/**
23
* Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
34
*
@@ -275,36 +276,6 @@ browseSynonyms(
275276
});
276277
},
277278

278-
/**
279-
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
280-
* 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.
281-
*
282-
* @summary Search multiple indices for `hits`.
283-
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
284-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
285-
*/
286-
searchForHits<T>(
287-
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
288-
requestOptions?: RequestOptions
289-
): Promise<{results: Array<SearchResponse<T>>}> {
290-
return this.search(searchMethodParams, requestOptions) as Promise<{results: Array<SearchResponse<T>>}>;
291-
},
292-
293-
/**
294-
* Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
295-
* 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.
296-
*
297-
* @summary Search multiple indices for `facets`.
298-
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
299-
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
300-
*/
301-
searchForFacets(
302-
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
303-
requestOptions?: RequestOptions
304-
): Promise<{results: Array<SearchForFacetValuesResponse>}> {
305-
return this.search(searchMethodParams, requestOptions) as Promise<{results: Array<SearchForFacetValuesResponse>}>;
306-
},
307-
308279
/**
309280
* Helper: Chunks the given `objects` list in subset of 1000 elements max in order to make it fit in `batch` requests.
310281
*
@@ -476,4 +447,35 @@ async replaceAllObjects(
476447
});
477448

478449
return { copyOperationResponse, batchResponses, moveOperationResponse };
450+
},
451+
{{/isAlgoliasearchClient}}
452+
453+
/**
454+
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
455+
* 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.
456+
*
457+
* @summary Search multiple indices for `hits`.
458+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
459+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
460+
*/
461+
searchForHits<T>(
462+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
463+
requestOptions?: RequestOptions
464+
): Promise<{results: Array<SearchResponse<T>>}> {
465+
return this.search(searchMethodParams, requestOptions) as Promise<{results: Array<SearchResponse<T>>}>;
466+
},
467+
468+
/**
469+
* Helper: calls the `search` method but with certainty that we will only request Algolia facets and not records (hits).
470+
* 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.
471+
*
472+
* @summary Search multiple indices for `facets`.
473+
* @param searchMethodParams - Query requests and strategies. Results will be received in the same order as the queries.
474+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
475+
*/
476+
searchForFacets(
477+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
478+
requestOptions?: RequestOptions
479+
): Promise<{results: Array<SearchForFacetValuesResponse>}> {
480+
return this.search(searchMethodParams, requestOptions) as Promise<{results: Array<SearchForFacetValuesResponse>}>;
479481
},

‎templates/javascript/clients/client/api/imports.mustache

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ import type {
5858
import type { BatchRequest } from '../model/batchRequest';
5959
{{/isSearchClient}}
6060

61+
{{#isAlgoliasearchClient}}
62+
import type { SearchResponse } from '../model/searchResponse';
63+
import type { SearchForFacetValuesResponse } from '../model/searchForFacetValuesResponse';
64+
{{/isAlgoliasearchClient}}
65+
6166
{{#isIngestionClient}}
6267
import type { OnDemandTrigger } from '../model/onDemandTrigger';
6368
import type { ScheduleTrigger } from '../model/scheduleTrigger';

‎templates/javascript/clients/client/model/clientMethodProps.mustache

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export type {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props = {
4747
{{/operations}}
4848

4949
{{#isSearchClient}}
50+
{{^isAlgoliasearchClient}}
5051
/**
5152
* The `browseObjects`, `browseRules`, `browseSynonyms` options.
5253
*/
@@ -175,6 +176,7 @@ export type ReplaceAllObjectsOptions = {
175176
*/
176177
batchSize?: number;
177178
}
179+
{{/isAlgoliasearchClient}}
178180
{{/isSearchClient}}
179181

180182
{{/apiInfo.apis.0}}

0 commit comments

Comments
 (0)
Please sign in to comment.