@algolia/client-search 5.56.0 → 5.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fetch.d.ts CHANGED
@@ -3242,7 +3242,7 @@ type AccountCopyIndexOptions = ChunkedHelperOptions & {
3242
3242
  batchSize?: number | undefined;
3243
3243
  };
3244
3244
 
3245
- declare const apiClientVersion = "5.56.0";
3245
+ declare const apiClientVersion = "5.57.0";
3246
3246
  declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
3247
3247
  transporter: _algolia_client_common.TransporterWithHttpInfo;
3248
3248
  /**
@@ -3407,6 +3407,8 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
3407
3407
  * Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
3408
3408
  * See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
3409
3409
  *
3410
+ * Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
3411
+ *
3410
3412
  * @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
3411
3413
  * @param replaceAllObjects - The `replaceAllObjects` object.
3412
3414
  * @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
@@ -3417,7 +3419,7 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
3417
3419
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
3418
3420
  */
3419
3421
  replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries, }: ReplaceAllObjectsOptions, requestOptions?: RequestOptions | undefined): Promise<ReplaceAllObjectsResponse>;
3420
- indexExists({ indexName }: GetSettingsProps): Promise<boolean>;
3422
+ indexExists({ indexName }: GetSettingsProps, requestOptions?: RequestOptions | undefined): Promise<boolean>;
3421
3423
  /**
3422
3424
  * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
3423
3425
  * 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.
package/dist/node.d.cts CHANGED
@@ -3242,7 +3242,7 @@ type AccountCopyIndexOptions = ChunkedHelperOptions & {
3242
3242
  batchSize?: number | undefined;
3243
3243
  };
3244
3244
 
3245
- declare const apiClientVersion = "5.56.0";
3245
+ declare const apiClientVersion = "5.57.0";
3246
3246
  declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
3247
3247
  transporter: _algolia_client_common.TransporterWithHttpInfo;
3248
3248
  /**
@@ -3407,6 +3407,8 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
3407
3407
  * Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
3408
3408
  * See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
3409
3409
  *
3410
+ * Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
3411
+ *
3410
3412
  * @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
3411
3413
  * @param replaceAllObjects - The `replaceAllObjects` object.
3412
3414
  * @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
@@ -3417,7 +3419,7 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
3417
3419
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
3418
3420
  */
3419
3421
  replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries, }: ReplaceAllObjectsOptions, requestOptions?: RequestOptions | undefined): Promise<ReplaceAllObjectsResponse>;
3420
- indexExists({ indexName }: GetSettingsProps): Promise<boolean>;
3422
+ indexExists({ indexName }: GetSettingsProps, requestOptions?: RequestOptions | undefined): Promise<boolean>;
3421
3423
  /**
3422
3424
  * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
3423
3425
  * 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.
package/dist/node.d.ts CHANGED
@@ -3242,7 +3242,7 @@ type AccountCopyIndexOptions = ChunkedHelperOptions & {
3242
3242
  batchSize?: number | undefined;
3243
3243
  };
3244
3244
 
3245
- declare const apiClientVersion = "5.56.0";
3245
+ declare const apiClientVersion = "5.57.0";
3246
3246
  declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
3247
3247
  transporter: _algolia_client_common.TransporterWithHttpInfo;
3248
3248
  /**
@@ -3407,6 +3407,8 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
3407
3407
  * Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
3408
3408
  * See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
3409
3409
  *
3410
+ * Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
3411
+ *
3410
3412
  * @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
3411
3413
  * @param replaceAllObjects - The `replaceAllObjects` object.
3412
3414
  * @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
@@ -3417,7 +3419,7 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
3417
3419
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
3418
3420
  */
3419
3421
  replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries, }: ReplaceAllObjectsOptions, requestOptions?: RequestOptions | undefined): Promise<ReplaceAllObjectsResponse>;
3420
- indexExists({ indexName }: GetSettingsProps): Promise<boolean>;
3422
+ indexExists({ indexName }: GetSettingsProps, requestOptions?: RequestOptions | undefined): Promise<boolean>;
3421
3423
  /**
3422
3424
  * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
3423
3425
  * 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.
@@ -25,7 +25,7 @@ __export(searchClient_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(searchClient_exports);
27
27
  var import_client_common = require("@algolia/client-common");
28
- var apiClientVersion = "5.56.0";
28
+ var apiClientVersion = "5.57.0";
29
29
  function getDefaultHosts(appId) {
30
30
  return [
31
31
  {
@@ -145,6 +145,7 @@ function createSearchClient({
145
145
  maxRetries = 100,
146
146
  timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
147
147
  }, requestOptions) {
148
+ requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
148
149
  let retryCount = 0;
149
150
  return (0, import_client_common.createIterablePromise)({
150
151
  func: () => this.getTask({ indexName, taskID }, requestOptions),
@@ -172,6 +173,7 @@ function createSearchClient({
172
173
  maxRetries = 100,
173
174
  timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
174
175
  }, requestOptions) {
176
+ requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
175
177
  let retryCount = 0;
176
178
  return (0, import_client_common.createIterablePromise)({
177
179
  func: () => this.getAppTask({ taskID }, requestOptions),
@@ -203,6 +205,7 @@ function createSearchClient({
203
205
  maxRetries = 100,
204
206
  timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
205
207
  }, requestOptions) {
208
+ requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
206
209
  let retryCount = 0;
207
210
  const baseIteratorOptions = {
208
211
  aggregator: () => retryCount += 1,
@@ -258,6 +261,7 @@ function createSearchClient({
258
261
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
259
262
  */
260
263
  browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
264
+ requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
261
265
  return (0, import_client_common.createIterablePromise)({
262
266
  func: (previousResponse) => {
263
267
  return this.browse(
@@ -288,6 +292,7 @@ function createSearchClient({
288
292
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
289
293
  */
290
294
  browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
295
+ requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
291
296
  const params = {
292
297
  ...searchRulesParams,
293
298
  hitsPerPage: (searchRulesParams == null ? void 0 : searchRulesParams.hitsPerPage) || 1e3
@@ -325,6 +330,7 @@ function createSearchClient({
325
330
  searchSynonymsParams,
326
331
  ...browseSynonymsOptions
327
332
  }, requestOptions) {
333
+ requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
328
334
  const params = {
329
335
  ...searchSynonymsParams,
330
336
  page: (searchSynonymsParams == null ? void 0 : searchSynonymsParams.page) || 0,
@@ -370,6 +376,7 @@ function createSearchClient({
370
376
  batchSize = 1e3,
371
377
  maxRetries = 100
372
378
  }, requestOptions) {
379
+ requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
373
380
  let requests = [];
374
381
  const responses = [];
375
382
  const objectEntries = objects.entries();
@@ -382,7 +389,7 @@ function createSearchClient({
382
389
  }
383
390
  if (waitForTasks) {
384
391
  for (const resp of responses) {
385
- await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
392
+ await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries }, requestOptions);
386
393
  }
387
394
  }
388
395
  return responses;
@@ -460,6 +467,8 @@ function createSearchClient({
460
467
  * Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
461
468
  * See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
462
469
  *
470
+ * Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
471
+ *
463
472
  * @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
464
473
  * @param replaceAllObjects - The `replaceAllObjects` object.
465
474
  * @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
@@ -476,6 +485,13 @@ function createSearchClient({
476
485
  scopes,
477
486
  maxRetries = import_client_common.DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES
478
487
  }, requestOptions) {
488
+ requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
489
+ if (objects.length === 0) {
490
+ (0, import_client_common.logWarning)(
491
+ transporter.logger,
492
+ `replaceAllObjects was called with an empty list of objects, which will delete all records currently in the "${indexName}" index.`
493
+ );
494
+ }
479
495
  const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
480
496
  const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
481
497
  if (scopes === void 0) {
@@ -497,11 +513,14 @@ function createSearchClient({
497
513
  { indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
498
514
  requestOptions
499
515
  );
500
- await this.waitForTask({
501
- indexName: tmpIndexName,
502
- taskID: copyOperationResponse.taskID,
503
- maxRetries
504
- });
516
+ await this.waitForTask(
517
+ {
518
+ indexName: tmpIndexName,
519
+ taskID: copyOperationResponse.taskID,
520
+ maxRetries
521
+ },
522
+ requestOptions
523
+ );
505
524
  copyOperationResponse = await this.operationIndex(
506
525
  {
507
526
  indexName,
@@ -513,11 +532,14 @@ function createSearchClient({
513
532
  },
514
533
  requestOptions
515
534
  );
516
- await this.waitForTask({
517
- indexName: tmpIndexName,
518
- taskID: copyOperationResponse.taskID,
519
- maxRetries
520
- });
535
+ await this.waitForTask(
536
+ {
537
+ indexName: tmpIndexName,
538
+ taskID: copyOperationResponse.taskID,
539
+ maxRetries
540
+ },
541
+ requestOptions
542
+ );
521
543
  const moveOperationResponse = await this.operationIndex(
522
544
  {
523
545
  indexName: tmpIndexName,
@@ -525,20 +547,23 @@ function createSearchClient({
525
547
  },
526
548
  requestOptions
527
549
  );
528
- await this.waitForTask({
529
- indexName: tmpIndexName,
530
- taskID: moveOperationResponse.taskID,
531
- maxRetries
532
- });
550
+ await this.waitForTask(
551
+ {
552
+ indexName: tmpIndexName,
553
+ taskID: moveOperationResponse.taskID,
554
+ maxRetries
555
+ },
556
+ requestOptions
557
+ );
533
558
  return { copyOperationResponse, batchResponses, moveOperationResponse };
534
559
  } catch (error) {
535
- await this.deleteIndex({ indexName: tmpIndexName });
560
+ await this.deleteIndex({ indexName: tmpIndexName }, requestOptions);
536
561
  throw error;
537
562
  }
538
563
  },
539
- async indexExists({ indexName }) {
564
+ async indexExists({ indexName }, requestOptions) {
540
565
  try {
541
- await this.getSettings({ indexName });
566
+ await this.getSettings({ indexName }, requestOptions);
542
567
  } catch (error) {
543
568
  if (error instanceof import_client_common.ApiError && error.status === 404) {
544
569
  return false;