Skip to content

Commit

Permalink
chore: generated code for commit 379fbc50. [skip ci]
Browse files Browse the repository at this point in the history
algolia/api-clients-automation@379fbc5

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Morgan Leroi <morgan.leroi@gmail.com>
Co-authored-by: shortcuts <vannicattec@gmail.com>
  • Loading branch information
3 people committed Jan 23, 2024
1 parent 71217c3 commit 749c6d9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 42 deletions.
13 changes: 0 additions & 13 deletions packages/client-search/model/clientMethodProps.ts
Expand Up @@ -25,7 +25,6 @@ import type { SearchRulesParams } from './searchRulesParams';
import type { SearchSynonymsParams } from './searchSynonymsParams';
import type { Source } from './source';
import type { SynonymHit } from './synonymHit';
import type { SynonymType } from './synonymType';

/**
* Properties for the `addOrUpdateObject` method.
Expand Down Expand Up @@ -684,18 +683,6 @@ export type SearchSynonymsProps = {
* Index on which to perform the request.
*/
indexName: string;
/**
* Search for specific [types of synonyms](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/#the-different-types-of-synonyms).
*/
type?: SynonymType;
/**
* Returns the requested page number (the first page is 0). Page size is set by `hitsPerPage`. When null, there\'s no pagination.
*/
page?: number;
/**
* Maximum number of hits per page.
*/
hitsPerPage?: number;
/**
* Body of the `searchSynonyms` operation.
*/
Expand Down
14 changes: 14 additions & 0 deletions packages/client-search/model/searchSynonymsParams.ts
@@ -1,8 +1,22 @@
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

import type { SynonymType } from './synonymType';

export type SearchSynonymsParams = {
/**
* Text to search for in an index.
*/
query?: string;

type?: SynonymType;

/**
* Page to retrieve (the first page is `0`, not `1`).
*/
page?: number;

/**
* Number of hits per page.
*/
hitsPerPage?: number;
};
40 changes: 11 additions & 29 deletions packages/client-search/src/searchClient.ts
Expand Up @@ -417,31 +417,34 @@ export function createSearchClient({
* @param browseObjects.indexName - The index in which to perform the request.
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
* @param browseObjects.searchSynonymsParams - The `searchSynonyms` method parameters.
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
*/
browseSynonyms(
{
indexName,
validate,
aggregator,
searchSynonymsParams,
...browseSynonymsOptions
}: BrowseOptions<SearchSynonymsResponse> & SearchSynonymsProps,
requestOptions?: RequestOptions
): Promise<SearchSynonymsResponse> {
const params = {
page: 0,
...searchSynonymsParams,
hitsPerPage: 1000,
...browseSynonymsOptions,
};

return createIterablePromise<SearchSynonymsResponse>({
func: (previousResponse) => {
return this.searchSynonyms(
{
...params,
indexName,
page: previousResponse
? previousResponse.page + 1
: browseSynonymsOptions.page || 0,
searchSynonymsParams: {
...params,
page: previousResponse
? previousResponse.page + 1
: params.page,
},
},
requestOptions
);
Expand Down Expand Up @@ -2768,20 +2771,11 @@ export function createSearchClient({
* @summary Search for synonyms.
* @param searchSynonyms - The searchSynonyms object.
* @param searchSynonyms.indexName - Index on which to perform the request.
* @param searchSynonyms.type - Search for specific [types of synonyms](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/#the-different-types-of-synonyms).
* @param searchSynonyms.page - Returns the requested page number (the first page is 0). Page size is set by `hitsPerPage`. When null, there\'s no pagination.
* @param searchSynonyms.hitsPerPage - Maximum number of hits per page.
* @param searchSynonyms.searchSynonymsParams - Body of the `searchSynonyms` operation.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
searchSynonyms(
{
indexName,
type,
page,
hitsPerPage,
searchSynonymsParams,
}: SearchSynonymsProps,
{ indexName, searchSynonymsParams }: SearchSynonymsProps,
requestOptions?: RequestOptions
): Promise<SearchSynonymsResponse> {
if (!indexName) {
Expand All @@ -2797,18 +2791,6 @@ export function createSearchClient({
const headers: Headers = {};
const queryParameters: QueryParameters = {};

if (type !== undefined) {
queryParameters.type = type.toString();
}

if (page !== undefined) {
queryParameters.page = page.toString();
}

if (hitsPerPage !== undefined) {
queryParameters.hitsPerPage = hitsPerPage.toString();
}

const request: Request = {
method: 'POST',
path: requestPath,
Expand Down

0 comments on commit 749c6d9

Please sign in to comment.