Skip to content

Commit e534cd7

Browse files
chore: generated code for commit 98b40e8. [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 98b40e8 commit e534cd7

File tree

6 files changed

+130
-3
lines changed

6 files changed

+130
-3
lines changed

clients/algoliasearch-client-javascript/packages/algoliasearch-lite/model/clientMethodProps.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import type { SearchForFacetsOptions } from './searchForFacetsOptions';
2+
import type { SearchForHitsOptions } from './searchForHitsOptions';
3+
import type { SearchParamsObject } from './searchParamsObject';
4+
15
/**
26
* Properties for the `post` method.
37
*/
@@ -15,3 +19,35 @@ export type PostProps = {
1519
*/
1620
body?: Record<string, any>;
1721
};
22+
23+
/**
24+
* In v4, the search parameters are wrapped in a `params` parameter.
25+
*
26+
* @deprecated The `search` method now accepts flat `searchParams` at the root of the method.
27+
*/
28+
type LegacySearchParams = {
29+
params?: SearchParamsObject;
30+
};
31+
32+
/**
33+
* In v4, the search parameters are wrapped in a `params` parameter.
34+
*
35+
* @deprecated The `search` method now accepts flat `searchParams` at the root of the method.
36+
*/
37+
type LegacySearchForFacets = LegacySearchParams & SearchForFacetsOptions;
38+
39+
/**
40+
* In v4, the search parameters are wrapped in a `params` parameter.
41+
*
42+
* @deprecated The `search` method now accepts flat `searchParams` at the root of the method.
43+
*/
44+
type LegacySearchForHits = LegacySearchParams & SearchForHitsOptions;
45+
46+
type LegacySearchQuery = LegacySearchForFacets | LegacySearchForHits;
47+
48+
/**
49+
* Search method signature compatible with the `algoliasearch` v4 package. When using this signature, extra computation will be required to make it match the new signature.
50+
*
51+
* @deprecated This signature will be removed from the next major version, we recommend using the `SearchMethodParams` type for performances and future proof reasons.
52+
*/
53+
export type LegacySearchMethodProps = LegacySearchQuery[];

clients/algoliasearch-client-javascript/packages/algoliasearch-lite/src/algoliasearchLiteClient.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import type {
1313
QueryParameters,
1414
} from '@experimental-api-clients-automation/client-common';
1515

16-
import type { PostProps } from '../model/clientMethodProps';
16+
import type {
17+
PostProps,
18+
LegacySearchMethodProps,
19+
} from '../model/clientMethodProps';
1720
import type { SearchMethodParams } from '../model/searchMethodParams';
1821
import type { SearchResponses } from '../model/searchResponses';
1922

@@ -129,9 +132,34 @@ export function createAlgoliasearchLiteClient({
129132
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
130133
*/
131134
search(
132-
searchMethodParams: SearchMethodParams,
135+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
133136
requestOptions?: RequestOptions
134137
): Promise<SearchResponses> {
138+
if (searchMethodParams && Array.isArray(searchMethodParams)) {
139+
const newSignatureRequest: SearchMethodParams = {
140+
requests: searchMethodParams.map(({ params, ...legacyRequest }) => {
141+
if (legacyRequest.type === 'facet') {
142+
return {
143+
...legacyRequest,
144+
...params,
145+
type: 'facet',
146+
};
147+
}
148+
149+
return {
150+
...legacyRequest,
151+
...params,
152+
facet: undefined,
153+
maxFacetHits: undefined,
154+
facetQuery: undefined,
155+
};
156+
}),
157+
};
158+
159+
// eslint-disable-next-line no-param-reassign
160+
searchMethodParams = newSignatureRequest;
161+
}
162+
135163
if (!searchMethodParams) {
136164
throw new Error(
137165
'Parameter `searchMethodParams` is required when calling `search`.'

clients/algoliasearch-client-javascript/packages/client-search/model/clientMethodProps.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ import type { OperationIndexParams } from './operationIndexParams';
1212
import type { Rule } from './rule';
1313
import type { SearchDictionaryEntriesParams } from './searchDictionaryEntriesParams';
1414
import type { SearchForFacetValuesRequest } from './searchForFacetValuesRequest';
15+
import type { SearchForFacetsOptions } from './searchForFacetsOptions';
16+
import type { SearchForHitsOptions } from './searchForHitsOptions';
1517
import type { SearchParams } from './searchParams';
18+
import type { SearchParamsObject } from './searchParamsObject';
1619
import type { SearchRulesParams } from './searchRulesParams';
1720
import type { Source } from './source';
1821
import type { SynonymHit } from './synonymHit';
@@ -585,6 +588,38 @@ export type SaveSynonymsProps = {
585588
replaceExistingSynonyms?: boolean;
586589
};
587590

591+
/**
592+
* In v4, the search parameters are wrapped in a `params` parameter.
593+
*
594+
* @deprecated The `search` method now accepts flat `searchParams` at the root of the method.
595+
*/
596+
type LegacySearchParams = {
597+
params?: SearchParamsObject;
598+
};
599+
600+
/**
601+
* In v4, the search parameters are wrapped in a `params` parameter.
602+
*
603+
* @deprecated The `search` method now accepts flat `searchParams` at the root of the method.
604+
*/
605+
type LegacySearchForFacets = LegacySearchParams & SearchForFacetsOptions;
606+
607+
/**
608+
* In v4, the search parameters are wrapped in a `params` parameter.
609+
*
610+
* @deprecated The `search` method now accepts flat `searchParams` at the root of the method.
611+
*/
612+
type LegacySearchForHits = LegacySearchParams & SearchForHitsOptions;
613+
614+
type LegacySearchQuery = LegacySearchForFacets | LegacySearchForHits;
615+
616+
/**
617+
* Search method signature compatible with the `algoliasearch` v4 package. When using this signature, extra computation will be required to make it match the new signature.
618+
*
619+
* @deprecated This signature will be removed from the next major version, we recommend using the `SearchMethodParams` type for performances and future proof reasons.
620+
*/
621+
export type LegacySearchMethodProps = LegacySearchQuery[];
622+
588623
/**
589624
* Properties for the `searchDictionaryEntries` method.
590625
*/

clients/algoliasearch-client-javascript/packages/client-search/src/searchClient.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import type {
6262
SaveRulesProps,
6363
SaveSynonymProps,
6464
SaveSynonymsProps,
65+
LegacySearchMethodProps,
6566
SearchDictionaryEntriesProps,
6667
SearchForFacetValuesProps,
6768
SearchRulesProps,
@@ -2213,9 +2214,34 @@ export function createSearchClient({
22132214
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
22142215
*/
22152216
search(
2216-
searchMethodParams: SearchMethodParams,
2217+
searchMethodParams: LegacySearchMethodProps | SearchMethodParams,
22172218
requestOptions?: RequestOptions
22182219
): Promise<SearchResponses> {
2220+
if (searchMethodParams && Array.isArray(searchMethodParams)) {
2221+
const newSignatureRequest: SearchMethodParams = {
2222+
requests: searchMethodParams.map(({ params, ...legacyRequest }) => {
2223+
if (legacyRequest.type === 'facet') {
2224+
return {
2225+
...legacyRequest,
2226+
...params,
2227+
type: 'facet',
2228+
};
2229+
}
2230+
2231+
return {
2232+
...legacyRequest,
2233+
...params,
2234+
facet: undefined,
2235+
maxFacetHits: undefined,
2236+
facetQuery: undefined,
2237+
};
2238+
}),
2239+
};
2240+
2241+
// eslint-disable-next-line no-param-reassign
2242+
searchMethodParams = newSignatureRequest;
2243+
}
2244+
22192245
if (!searchMethodParams) {
22202246
throw new Error(
22212247
'Parameter `searchMethodParams` is required when calling `search`.'

specs/bundled/algoliasearch-lite.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,6 +2071,7 @@ paths:
20712071
operationId: search
20722072
x-use-read-transporter: true
20732073
x-cacheable: true
2074+
x-legacy-signature: true
20742075
summary: Search multiple indices.
20752076
description: Perform a search operation targeting one or many indices.
20762077
requestBody:

specs/bundled/search.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,7 @@ paths:
21812181
operationId: search
21822182
x-use-read-transporter: true
21832183
x-cacheable: true
2184+
x-legacy-signature: true
21842185
summary: Search multiple indices.
21852186
description: Perform a search operation targeting one or many indices.
21862187
requestBody:

0 commit comments

Comments
 (0)