Skip to content

Commit 64b6d58

Browse files
algolia-botmillotp
andcommitted
fix(clients): add batchSize to accountCopyIndex (generated)
algolia/api-clients-automation#5181 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent d461180 commit 64b6d58

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

packages/client-search/builds/fetch.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,17 @@ export function searchClient(appId: string, apiKey: string, options?: ClientOpti
107107
* @param accountCopyIndex.destinationAppID - The application ID to write the index to.
108108
* @param accountCopyIndex.destinationApiKey - The API Key of the `destinationAppID` to write the index to, must have write ACLs.
109109
* @param accountCopyIndex.destinationIndexName - The name of the index to write the copied index to.
110+
* @param accountCopyIndex.batchSize - The size of the chunk of `objects`. Defaults to 1000.
110111
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `setSettings`, `saveRules`, `saveSynonyms` and `saveObjects` method and merged with the transporter requestOptions.
111112
*/
112113
async accountCopyIndex(
113-
{ sourceIndexName, destinationAppID, destinationApiKey, destinationIndexName }: AccountCopyIndexOptions,
114+
{
115+
sourceIndexName,
116+
destinationAppID,
117+
destinationApiKey,
118+
destinationIndexName,
119+
batchSize,
120+
}: AccountCopyIndexOptions,
114121
requestOptions?: RequestOptions | undefined,
115122
): Promise<void> {
116123
const responses: Array<{ taskID: UpdatedAtResponse['taskID'] }> = [];
@@ -180,10 +187,11 @@ export function searchClient(appId: string, apiKey: string, options?: ClientOpti
180187

181188
await this.browseObjects({
182189
indexName: sourceIndexName,
190+
browseParams: batchSize ? { hitsPerPage: batchSize } : undefined,
183191
async aggregator(response: BrowseResponse) {
184192
responses.push(
185193
...(await destinationClient.saveObjects(
186-
{ indexName: destinationIndexName, objects: response.hits },
194+
{ indexName: destinationIndexName, objects: response.hits, batchSize },
187195
requestOptions,
188196
)),
189197
);

packages/client-search/builds/node.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,17 @@ export function searchClient(appId: string, apiKey: string, options?: ClientOpti
107107
* @param accountCopyIndex.destinationAppID - The application ID to write the index to.
108108
* @param accountCopyIndex.destinationApiKey - The API Key of the `destinationAppID` to write the index to, must have write ACLs.
109109
* @param accountCopyIndex.destinationIndexName - The name of the index to write the copied index to.
110+
* @param accountCopyIndex.batchSize - The size of the chunk of `objects`. Defaults to 1000.
110111
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `setSettings`, `saveRules`, `saveSynonyms` and `saveObjects` method and merged with the transporter requestOptions.
111112
*/
112113
async accountCopyIndex(
113-
{ sourceIndexName, destinationAppID, destinationApiKey, destinationIndexName }: AccountCopyIndexOptions,
114+
{
115+
sourceIndexName,
116+
destinationAppID,
117+
destinationApiKey,
118+
destinationIndexName,
119+
batchSize,
120+
}: AccountCopyIndexOptions,
114121
requestOptions?: RequestOptions | undefined,
115122
): Promise<void> {
116123
const responses: Array<{ taskID: UpdatedAtResponse['taskID'] }> = [];
@@ -180,10 +187,11 @@ export function searchClient(appId: string, apiKey: string, options?: ClientOpti
180187

181188
await this.browseObjects({
182189
indexName: sourceIndexName,
190+
browseParams: batchSize ? { hitsPerPage: batchSize } : undefined,
183191
async aggregator(response: BrowseResponse) {
184192
responses.push(
185193
...(await destinationClient.saveObjects(
186-
{ indexName: destinationIndexName, objects: response.hits },
194+
{ indexName: destinationIndexName, objects: response.hits, batchSize },
187195
requestOptions,
188196
)),
189197
);

packages/client-search/model/clientMethodProps.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,4 +899,9 @@ export type AccountCopyIndexOptions = {
899899
* The name of the index to write the copy in.
900900
*/
901901
destinationIndexName: string;
902+
903+
/**
904+
* The size of the chunk of `objects`. Defaults to 1000.
905+
*/
906+
batchSize?: number | undefined;
902907
};

0 commit comments

Comments
 (0)