@algolia/client-search 5.52.1 → 5.54.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.
@@ -31,7 +31,7 @@ var import_requester_node_http = require("@algolia/requester-node-http");
31
31
 
32
32
  // src/searchClient.ts
33
33
  var import_client_common = require("@algolia/client-common");
34
- var apiClientVersion = "5.52.1";
34
+ var apiClientVersion = "5.54.0";
35
35
  function getDefaultHosts(appId) {
36
36
  return [
37
37
  {
@@ -365,9 +365,17 @@ function createSearchClient({
365
365
  * @param chunkedBatch.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`.
366
366
  * @param chunkedBatch.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
367
367
  * @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
368
+ * @param chunkedBatch.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
368
369
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
369
370
  */
370
- async chunkedBatch({ indexName, objects, action = "addObject", waitForTasks, batchSize = 1e3 }, requestOptions) {
371
+ async chunkedBatch({
372
+ indexName,
373
+ objects,
374
+ action = "addObject",
375
+ waitForTasks,
376
+ batchSize = 1e3,
377
+ maxRetries = 100
378
+ }, requestOptions) {
371
379
  let requests = [];
372
380
  const responses = [];
373
381
  const objectEntries = objects.entries();
@@ -380,7 +388,7 @@ function createSearchClient({
380
388
  }
381
389
  if (waitForTasks) {
382
390
  for (const resp of responses) {
383
- await this.waitForTask({ indexName, taskID: resp.taskID });
391
+ await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
384
392
  }
385
393
  }
386
394
  return responses;
@@ -394,11 +402,12 @@ function createSearchClient({
394
402
  * @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
395
403
  * @param saveObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
396
404
  * @param saveObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
405
+ * @param saveObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
397
406
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
398
407
  */
399
- async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
408
+ async saveObjects({ indexName, objects, waitForTasks, batchSize, maxRetries }, requestOptions) {
400
409
  return await this.chunkedBatch(
401
- { indexName, objects, action: "addObject", waitForTasks, batchSize },
410
+ { indexName, objects, action: "addObject", waitForTasks, batchSize, maxRetries },
402
411
  requestOptions
403
412
  );
404
413
  },
@@ -411,16 +420,18 @@ function createSearchClient({
411
420
  * @param deleteObjects.objectIDs - The objectIDs to delete.
412
421
  * @param deleteObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
413
422
  * @param deleteObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
423
+ * @param deleteObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
414
424
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
415
425
  */
416
- async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
426
+ async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize, maxRetries }, requestOptions) {
417
427
  return await this.chunkedBatch(
418
428
  {
419
429
  indexName,
420
430
  objects: objectIDs.map((objectID) => ({ objectID })),
421
431
  action: "deleteObject",
422
432
  waitForTasks,
423
- batchSize
433
+ batchSize,
434
+ maxRetries
424
435
  },
425
436
  requestOptions
426
437
  );
@@ -435,16 +446,18 @@ function createSearchClient({
435
446
  * @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail.
436
447
  * @param partialUpdateObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
437
448
  * @param partialUpdateObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
449
+ * @param partialUpdateObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
438
450
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
439
451
  */
440
- async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
452
+ async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize, maxRetries }, requestOptions) {
441
453
  return await this.chunkedBatch(
442
454
  {
443
455
  indexName,
444
456
  objects,
445
457
  action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
446
458
  batchSize,
447
- waitForTasks
459
+ waitForTasks,
460
+ maxRetries
448
461
  },
449
462
  requestOptions
450
463
  );
@@ -459,9 +472,10 @@ function createSearchClient({
459
472
  * @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
460
473
  * @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `objects.length / batchSize`. Defaults to 1000.
461
474
  * @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
475
+ * @param replaceAllObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
462
476
  * @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.
463
477
  */
464
- async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
478
+ async replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries = 100 }, requestOptions) {
465
479
  const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
466
480
  const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
467
481
  if (scopes === void 0) {
@@ -480,12 +494,13 @@ function createSearchClient({
480
494
  requestOptions
481
495
  );
482
496
  const batchResponses = await this.chunkedBatch(
483
- { indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
497
+ { indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
484
498
  requestOptions
485
499
  );
486
500
  await this.waitForTask({
487
501
  indexName: tmpIndexName,
488
- taskID: copyOperationResponse.taskID
502
+ taskID: copyOperationResponse.taskID,
503
+ maxRetries
489
504
  });
490
505
  copyOperationResponse = await this.operationIndex(
491
506
  {
@@ -500,7 +515,8 @@ function createSearchClient({
500
515
  );
501
516
  await this.waitForTask({
502
517
  indexName: tmpIndexName,
503
- taskID: copyOperationResponse.taskID
518
+ taskID: copyOperationResponse.taskID,
519
+ maxRetries
504
520
  });
505
521
  const moveOperationResponse = await this.operationIndex(
506
522
  {
@@ -511,7 +527,8 @@ function createSearchClient({
511
527
  );
512
528
  await this.waitForTask({
513
529
  indexName: tmpIndexName,
514
- taskID: moveOperationResponse.taskID
530
+ taskID: moveOperationResponse.taskID,
531
+ maxRetries
515
532
  });
516
533
  return { copyOperationResponse, batchResponses, moveOperationResponse };
517
534
  } catch (error) {
@@ -561,12 +578,8 @@ function createSearchClient({
561
578
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
562
579
  */
563
580
  addApiKey(apiKey, requestOptions) {
564
- if (!apiKey) {
565
- throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");
566
- }
567
- if (!apiKey.acl) {
568
- throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");
569
- }
581
+ (0, import_client_common.validateRequired)("apiKey", "addApiKey", apiKey);
582
+ (0, import_client_common.validateRequired)("apiKey.acl", "addApiKey", apiKey.acl);
570
583
  const requestPath = "/1/keys";
571
584
  const headers = {};
572
585
  const queryParameters = {};
@@ -591,15 +604,9 @@ function createSearchClient({
591
604
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
592
605
  */
593
606
  addOrUpdateObject({ indexName, objectID, body }, requestOptions) {
594
- if (!indexName) {
595
- throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");
596
- }
597
- if (!objectID) {
598
- throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");
599
- }
600
- if (!body) {
601
- throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");
602
- }
607
+ (0, import_client_common.validateRequired)("indexName", "addOrUpdateObject", indexName);
608
+ (0, import_client_common.validateRequired)("objectID", "addOrUpdateObject", objectID);
609
+ (0, import_client_common.validateRequired)("body", "addOrUpdateObject", body);
603
610
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
604
611
  const headers = {};
605
612
  const queryParameters = {};
@@ -621,12 +628,8 @@ function createSearchClient({
621
628
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
622
629
  */
623
630
  appendSource(source, requestOptions) {
624
- if (!source) {
625
- throw new Error("Parameter `source` is required when calling `appendSource`.");
626
- }
627
- if (!source.source) {
628
- throw new Error("Parameter `source.source` is required when calling `appendSource`.");
629
- }
631
+ (0, import_client_common.validateRequired)("source", "appendSource", source);
632
+ (0, import_client_common.validateRequired)("source.source", "appendSource", source.source);
630
633
  const requestPath = "/1/security/sources/append";
631
634
  const headers = {};
632
635
  const queryParameters = {};
@@ -652,15 +655,9 @@ function createSearchClient({
652
655
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
653
656
  */
654
657
  assignUserId({ xAlgoliaUserID, assignUserIdParams }, requestOptions) {
655
- if (!xAlgoliaUserID) {
656
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");
657
- }
658
- if (!assignUserIdParams) {
659
- throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");
660
- }
661
- if (!assignUserIdParams.cluster) {
662
- throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");
663
- }
658
+ (0, import_client_common.validateRequired)("xAlgoliaUserID", "assignUserId", xAlgoliaUserID);
659
+ (0, import_client_common.validateRequired)("assignUserIdParams", "assignUserId", assignUserIdParams);
660
+ (0, import_client_common.validateRequired)("assignUserIdParams.cluster", "assignUserId", assignUserIdParams.cluster);
664
661
  const requestPath = "/1/clusters/mapping";
665
662
  const headers = {};
666
663
  const queryParameters = {};
@@ -687,15 +684,9 @@ function createSearchClient({
687
684
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
688
685
  */
689
686
  batch({ indexName, batchWriteParams }, requestOptions) {
690
- if (!indexName) {
691
- throw new Error("Parameter `indexName` is required when calling `batch`.");
692
- }
693
- if (!batchWriteParams) {
694
- throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");
695
- }
696
- if (!batchWriteParams.requests) {
697
- throw new Error("Parameter `batchWriteParams.requests` is required when calling `batch`.");
698
- }
687
+ (0, import_client_common.validateRequired)("indexName", "batch", indexName);
688
+ (0, import_client_common.validateRequired)("batchWriteParams", "batch", batchWriteParams);
689
+ (0, import_client_common.validateRequired)("batchWriteParams.requests", "batch", batchWriteParams.requests);
699
690
  const requestPath = "/1/indexes/{indexName}/batch".replace("{indexName}", encodeURIComponent(indexName));
700
691
  const headers = {};
701
692
  const queryParameters = {};
@@ -721,18 +712,10 @@ function createSearchClient({
721
712
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
722
713
  */
723
714
  batchAssignUserIds({ xAlgoliaUserID, batchAssignUserIdsParams }, requestOptions) {
724
- if (!xAlgoliaUserID) {
725
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");
726
- }
727
- if (!batchAssignUserIdsParams) {
728
- throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");
729
- }
730
- if (!batchAssignUserIdsParams.cluster) {
731
- throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");
732
- }
733
- if (!batchAssignUserIdsParams.users) {
734
- throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");
735
- }
715
+ (0, import_client_common.validateRequired)("xAlgoliaUserID", "batchAssignUserIds", xAlgoliaUserID);
716
+ (0, import_client_common.validateRequired)("batchAssignUserIdsParams", "batchAssignUserIds", batchAssignUserIdsParams);
717
+ (0, import_client_common.validateRequired)("batchAssignUserIdsParams.cluster", "batchAssignUserIds", batchAssignUserIdsParams.cluster);
718
+ (0, import_client_common.validateRequired)("batchAssignUserIdsParams.users", "batchAssignUserIds", batchAssignUserIdsParams.users);
736
719
  const requestPath = "/1/clusters/mapping/batch";
737
720
  const headers = {};
738
721
  const queryParameters = {};
@@ -759,17 +742,13 @@ function createSearchClient({
759
742
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
760
743
  */
761
744
  batchDictionaryEntries({ dictionaryName, batchDictionaryEntriesParams }, requestOptions) {
762
- if (!dictionaryName) {
763
- throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");
764
- }
765
- if (!batchDictionaryEntriesParams) {
766
- throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");
767
- }
768
- if (!batchDictionaryEntriesParams.requests) {
769
- throw new Error(
770
- "Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`."
771
- );
772
- }
745
+ (0, import_client_common.validateRequired)("dictionaryName", "batchDictionaryEntries", dictionaryName);
746
+ (0, import_client_common.validateRequired)("batchDictionaryEntriesParams", "batchDictionaryEntries", batchDictionaryEntriesParams);
747
+ (0, import_client_common.validateRequired)(
748
+ "batchDictionaryEntriesParams.requests",
749
+ "batchDictionaryEntries",
750
+ batchDictionaryEntriesParams.requests
751
+ );
773
752
  const requestPath = "/1/dictionaries/{dictionaryName}/batch".replace(
774
753
  "{dictionaryName}",
775
754
  encodeURIComponent(dictionaryName)
@@ -796,9 +775,7 @@ function createSearchClient({
796
775
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
797
776
  */
798
777
  browse({ indexName, browseParams }, requestOptions) {
799
- if (!indexName) {
800
- throw new Error("Parameter `indexName` is required when calling `browse`.");
801
- }
778
+ (0, import_client_common.validateRequired)("indexName", "browse", indexName);
802
779
  const requestPath = "/1/indexes/{indexName}/browse".replace("{indexName}", encodeURIComponent(indexName));
803
780
  const headers = {};
804
781
  const queryParameters = {};
@@ -822,9 +799,7 @@ function createSearchClient({
822
799
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
823
800
  */
824
801
  clearObjects({ indexName }, requestOptions) {
825
- if (!indexName) {
826
- throw new Error("Parameter `indexName` is required when calling `clearObjects`.");
827
- }
802
+ (0, import_client_common.validateRequired)("indexName", "clearObjects", indexName);
828
803
  const requestPath = "/1/indexes/{indexName}/clear".replace("{indexName}", encodeURIComponent(indexName));
829
804
  const headers = {};
830
805
  const queryParameters = {};
@@ -847,9 +822,7 @@ function createSearchClient({
847
822
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
848
823
  */
849
824
  clearRules({ indexName, forwardToReplicas }, requestOptions) {
850
- if (!indexName) {
851
- throw new Error("Parameter `indexName` is required when calling `clearRules`.");
852
- }
825
+ (0, import_client_common.validateRequired)("indexName", "clearRules", indexName);
853
826
  const requestPath = "/1/indexes/{indexName}/rules/clear".replace("{indexName}", encodeURIComponent(indexName));
854
827
  const headers = {};
855
828
  const queryParameters = {};
@@ -875,9 +848,7 @@ function createSearchClient({
875
848
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
876
849
  */
877
850
  clearSynonyms({ indexName, forwardToReplicas }, requestOptions) {
878
- if (!indexName) {
879
- throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");
880
- }
851
+ (0, import_client_common.validateRequired)("indexName", "clearSynonyms", indexName);
881
852
  const requestPath = "/1/indexes/{indexName}/synonyms/clear".replace("{indexName}", encodeURIComponent(indexName));
882
853
  const headers = {};
883
854
  const queryParameters = {};
@@ -900,9 +871,7 @@ function createSearchClient({
900
871
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
901
872
  */
902
873
  customDelete({ path, parameters }, requestOptions) {
903
- if (!path) {
904
- throw new Error("Parameter `path` is required when calling `customDelete`.");
905
- }
874
+ (0, import_client_common.validateRequired)("path", "customDelete", path);
906
875
  const requestPath = "/{path}".replace("{path}", path);
907
876
  const headers = {};
908
877
  const queryParameters = parameters ? parameters : {};
@@ -922,9 +891,7 @@ function createSearchClient({
922
891
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
923
892
  */
924
893
  customGet({ path, parameters }, requestOptions) {
925
- if (!path) {
926
- throw new Error("Parameter `path` is required when calling `customGet`.");
927
- }
894
+ (0, import_client_common.validateRequired)("path", "customGet", path);
928
895
  const requestPath = "/{path}".replace("{path}", path);
929
896
  const headers = {};
930
897
  const queryParameters = parameters ? parameters : {};
@@ -945,9 +912,7 @@ function createSearchClient({
945
912
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
946
913
  */
947
914
  customPost({ path, parameters, body }, requestOptions) {
948
- if (!path) {
949
- throw new Error("Parameter `path` is required when calling `customPost`.");
950
- }
915
+ (0, import_client_common.validateRequired)("path", "customPost", path);
951
916
  const requestPath = "/{path}".replace("{path}", path);
952
917
  const headers = {};
953
918
  const queryParameters = parameters ? parameters : {};
@@ -969,9 +934,7 @@ function createSearchClient({
969
934
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
970
935
  */
971
936
  customPut({ path, parameters, body }, requestOptions) {
972
- if (!path) {
973
- throw new Error("Parameter `path` is required when calling `customPut`.");
974
- }
937
+ (0, import_client_common.validateRequired)("path", "customPut", path);
975
938
  const requestPath = "/{path}".replace("{path}", path);
976
939
  const headers = {};
977
940
  const queryParameters = parameters ? parameters : {};
@@ -994,9 +957,7 @@ function createSearchClient({
994
957
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
995
958
  */
996
959
  deleteApiKey({ key }, requestOptions) {
997
- if (!key) {
998
- throw new Error("Parameter `key` is required when calling `deleteApiKey`.");
999
- }
960
+ (0, import_client_common.validateRequired)("key", "deleteApiKey", key);
1000
961
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1001
962
  const headers = {};
1002
963
  const queryParameters = {};
@@ -1019,12 +980,8 @@ function createSearchClient({
1019
980
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1020
981
  */
1021
982
  deleteBy({ indexName, deleteByParams }, requestOptions) {
1022
- if (!indexName) {
1023
- throw new Error("Parameter `indexName` is required when calling `deleteBy`.");
1024
- }
1025
- if (!deleteByParams) {
1026
- throw new Error("Parameter `deleteByParams` is required when calling `deleteBy`.");
1027
- }
983
+ (0, import_client_common.validateRequired)("indexName", "deleteBy", indexName);
984
+ (0, import_client_common.validateRequired)("deleteByParams", "deleteBy", deleteByParams);
1028
985
  const requestPath = "/1/indexes/{indexName}/deleteByQuery".replace("{indexName}", encodeURIComponent(indexName));
1029
986
  const headers = {};
1030
987
  const queryParameters = {};
@@ -1047,9 +1004,7 @@ function createSearchClient({
1047
1004
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1048
1005
  */
1049
1006
  deleteIndex({ indexName }, requestOptions) {
1050
- if (!indexName) {
1051
- throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");
1052
- }
1007
+ (0, import_client_common.validateRequired)("indexName", "deleteIndex", indexName);
1053
1008
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1054
1009
  const headers = {};
1055
1010
  const queryParameters = {};
@@ -1072,12 +1027,8 @@ function createSearchClient({
1072
1027
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1073
1028
  */
1074
1029
  deleteObject({ indexName, objectID }, requestOptions) {
1075
- if (!indexName) {
1076
- throw new Error("Parameter `indexName` is required when calling `deleteObject`.");
1077
- }
1078
- if (!objectID) {
1079
- throw new Error("Parameter `objectID` is required when calling `deleteObject`.");
1080
- }
1030
+ (0, import_client_common.validateRequired)("indexName", "deleteObject", indexName);
1031
+ (0, import_client_common.validateRequired)("objectID", "deleteObject", objectID);
1081
1032
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1082
1033
  const headers = {};
1083
1034
  const queryParameters = {};
@@ -1101,12 +1052,8 @@ function createSearchClient({
1101
1052
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1102
1053
  */
1103
1054
  deleteRule({ indexName, objectID, forwardToReplicas }, requestOptions) {
1104
- if (!indexName) {
1105
- throw new Error("Parameter `indexName` is required when calling `deleteRule`.");
1106
- }
1107
- if (!objectID) {
1108
- throw new Error("Parameter `objectID` is required when calling `deleteRule`.");
1109
- }
1055
+ (0, import_client_common.validateRequired)("indexName", "deleteRule", indexName);
1056
+ (0, import_client_common.validateRequired)("objectID", "deleteRule", objectID);
1110
1057
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1111
1058
  const headers = {};
1112
1059
  const queryParameters = {};
@@ -1131,9 +1078,7 @@ function createSearchClient({
1131
1078
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1132
1079
  */
1133
1080
  deleteSource({ source }, requestOptions) {
1134
- if (!source) {
1135
- throw new Error("Parameter `source` is required when calling `deleteSource`.");
1136
- }
1081
+ (0, import_client_common.validateRequired)("source", "deleteSource", source);
1137
1082
  const requestPath = "/1/security/sources/{source}".replace("{source}", encodeURIComponent(source));
1138
1083
  const headers = {};
1139
1084
  const queryParameters = {};
@@ -1157,12 +1102,8 @@ function createSearchClient({
1157
1102
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1158
1103
  */
1159
1104
  deleteSynonym({ indexName, objectID, forwardToReplicas }, requestOptions) {
1160
- if (!indexName) {
1161
- throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");
1162
- }
1163
- if (!objectID) {
1164
- throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");
1165
- }
1105
+ (0, import_client_common.validateRequired)("indexName", "deleteSynonym", indexName);
1106
+ (0, import_client_common.validateRequired)("objectID", "deleteSynonym", objectID);
1166
1107
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1167
1108
  const headers = {};
1168
1109
  const queryParameters = {};
@@ -1187,9 +1128,7 @@ function createSearchClient({
1187
1128
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1188
1129
  */
1189
1130
  getApiKey({ key }, requestOptions) {
1190
- if (!key) {
1191
- throw new Error("Parameter `key` is required when calling `getApiKey`.");
1192
- }
1131
+ (0, import_client_common.validateRequired)("key", "getApiKey", key);
1193
1132
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1194
1133
  const headers = {};
1195
1134
  const queryParameters = {};
@@ -1211,9 +1150,7 @@ function createSearchClient({
1211
1150
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1212
1151
  */
1213
1152
  getAppTask({ taskID }, requestOptions) {
1214
- if (!taskID) {
1215
- throw new Error("Parameter `taskID` is required when calling `getAppTask`.");
1216
- }
1153
+ (0, import_client_common.validateRequired)("taskID", "getAppTask", taskID);
1217
1154
  const requestPath = "/1/task/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1218
1155
  const headers = {};
1219
1156
  const queryParameters = {};
@@ -1311,12 +1248,8 @@ function createSearchClient({
1311
1248
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1312
1249
  */
1313
1250
  getObject({ indexName, objectID, attributesToRetrieve }, requestOptions) {
1314
- if (!indexName) {
1315
- throw new Error("Parameter `indexName` is required when calling `getObject`.");
1316
- }
1317
- if (!objectID) {
1318
- throw new Error("Parameter `objectID` is required when calling `getObject`.");
1319
- }
1251
+ (0, import_client_common.validateRequired)("indexName", "getObject", indexName);
1252
+ (0, import_client_common.validateRequired)("objectID", "getObject", objectID);
1320
1253
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1321
1254
  const headers = {};
1322
1255
  const queryParameters = {};
@@ -1340,12 +1273,8 @@ function createSearchClient({
1340
1273
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1341
1274
  */
1342
1275
  getObjects(getObjectsParams, requestOptions) {
1343
- if (!getObjectsParams) {
1344
- throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");
1345
- }
1346
- if (!getObjectsParams.requests) {
1347
- throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");
1348
- }
1276
+ (0, import_client_common.validateRequired)("getObjectsParams", "getObjects", getObjectsParams);
1277
+ (0, import_client_common.validateRequired)("getObjectsParams.requests", "getObjects", getObjectsParams.requests);
1349
1278
  const requestPath = "/1/indexes/*/objects";
1350
1279
  const headers = {};
1351
1280
  const queryParameters = {};
@@ -1371,12 +1300,8 @@ function createSearchClient({
1371
1300
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1372
1301
  */
1373
1302
  getRule({ indexName, objectID }, requestOptions) {
1374
- if (!indexName) {
1375
- throw new Error("Parameter `indexName` is required when calling `getRule`.");
1376
- }
1377
- if (!objectID) {
1378
- throw new Error("Parameter `objectID` is required when calling `getRule`.");
1379
- }
1303
+ (0, import_client_common.validateRequired)("indexName", "getRule", indexName);
1304
+ (0, import_client_common.validateRequired)("objectID", "getRule", objectID);
1380
1305
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1381
1306
  const headers = {};
1382
1307
  const queryParameters = {};
@@ -1399,9 +1324,7 @@ function createSearchClient({
1399
1324
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1400
1325
  */
1401
1326
  getSettings({ indexName, getVersion }, requestOptions) {
1402
- if (!indexName) {
1403
- throw new Error("Parameter `indexName` is required when calling `getSettings`.");
1404
- }
1327
+ (0, import_client_common.validateRequired)("indexName", "getSettings", indexName);
1405
1328
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
1406
1329
  const headers = {};
1407
1330
  const queryParameters = {};
@@ -1446,12 +1369,8 @@ function createSearchClient({
1446
1369
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1447
1370
  */
1448
1371
  getSynonym({ indexName, objectID }, requestOptions) {
1449
- if (!indexName) {
1450
- throw new Error("Parameter `indexName` is required when calling `getSynonym`.");
1451
- }
1452
- if (!objectID) {
1453
- throw new Error("Parameter `objectID` is required when calling `getSynonym`.");
1454
- }
1372
+ (0, import_client_common.validateRequired)("indexName", "getSynonym", indexName);
1373
+ (0, import_client_common.validateRequired)("objectID", "getSynonym", objectID);
1455
1374
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1456
1375
  const headers = {};
1457
1376
  const queryParameters = {};
@@ -1474,12 +1393,8 @@ function createSearchClient({
1474
1393
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1475
1394
  */
1476
1395
  getTask({ indexName, taskID }, requestOptions) {
1477
- if (!indexName) {
1478
- throw new Error("Parameter `indexName` is required when calling `getTask`.");
1479
- }
1480
- if (!taskID) {
1481
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
1482
- }
1396
+ (0, import_client_common.validateRequired)("indexName", "getTask", indexName);
1397
+ (0, import_client_common.validateRequired)("taskID", "getTask", taskID);
1483
1398
  const requestPath = "/1/indexes/{indexName}/task/{taskID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{taskID}", encodeURIComponent(taskID));
1484
1399
  const headers = {};
1485
1400
  const queryParameters = {};
@@ -1524,9 +1439,7 @@ function createSearchClient({
1524
1439
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1525
1440
  */
1526
1441
  getUserId({ userID }, requestOptions) {
1527
- if (!userID) {
1528
- throw new Error("Parameter `userID` is required when calling `getUserId`.");
1529
- }
1442
+ (0, import_client_common.validateRequired)("userID", "getUserId", userID);
1530
1443
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1531
1444
  const headers = {};
1532
1445
  const queryParameters = {};
@@ -1671,12 +1584,8 @@ function createSearchClient({
1671
1584
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1672
1585
  */
1673
1586
  multipleBatch(batchParams, requestOptions) {
1674
- if (!batchParams) {
1675
- throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");
1676
- }
1677
- if (!batchParams.requests) {
1678
- throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");
1679
- }
1587
+ (0, import_client_common.validateRequired)("batchParams", "multipleBatch", batchParams);
1588
+ (0, import_client_common.validateRequired)("batchParams.requests", "multipleBatch", batchParams.requests);
1680
1589
  const requestPath = "/1/indexes/*/batch";
1681
1590
  const headers = {};
1682
1591
  const queryParameters = {};
@@ -1700,18 +1609,10 @@ function createSearchClient({
1700
1609
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1701
1610
  */
1702
1611
  operationIndex({ indexName, operationIndexParams }, requestOptions) {
1703
- if (!indexName) {
1704
- throw new Error("Parameter `indexName` is required when calling `operationIndex`.");
1705
- }
1706
- if (!operationIndexParams) {
1707
- throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");
1708
- }
1709
- if (!operationIndexParams.operation) {
1710
- throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");
1711
- }
1712
- if (!operationIndexParams.destination) {
1713
- throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");
1714
- }
1612
+ (0, import_client_common.validateRequired)("indexName", "operationIndex", indexName);
1613
+ (0, import_client_common.validateRequired)("operationIndexParams", "operationIndex", operationIndexParams);
1614
+ (0, import_client_common.validateRequired)("operationIndexParams.operation", "operationIndex", operationIndexParams.operation);
1615
+ (0, import_client_common.validateRequired)("operationIndexParams.destination", "operationIndex", operationIndexParams.destination);
1715
1616
  const requestPath = "/1/indexes/{indexName}/operation".replace("{indexName}", encodeURIComponent(indexName));
1716
1617
  const headers = {};
1717
1618
  const queryParameters = {};
@@ -1737,15 +1638,9 @@ function createSearchClient({
1737
1638
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1738
1639
  */
1739
1640
  partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists }, requestOptions) {
1740
- if (!indexName) {
1741
- throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");
1742
- }
1743
- if (!objectID) {
1744
- throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");
1745
- }
1746
- if (!attributesToUpdate) {
1747
- throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");
1748
- }
1641
+ (0, import_client_common.validateRequired)("indexName", "partialUpdateObject", indexName);
1642
+ (0, import_client_common.validateRequired)("objectID", "partialUpdateObject", objectID);
1643
+ (0, import_client_common.validateRequired)("attributesToUpdate", "partialUpdateObject", attributesToUpdate);
1749
1644
  const requestPath = "/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1750
1645
  const headers = {};
1751
1646
  const queryParameters = {};
@@ -1773,9 +1668,7 @@ function createSearchClient({
1773
1668
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1774
1669
  */
1775
1670
  removeUserId({ userID }, requestOptions) {
1776
- if (!userID) {
1777
- throw new Error("Parameter `userID` is required when calling `removeUserId`.");
1778
- }
1671
+ (0, import_client_common.validateRequired)("userID", "removeUserId", userID);
1779
1672
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1780
1673
  const headers = {};
1781
1674
  const queryParameters = {};
@@ -1797,9 +1690,7 @@ function createSearchClient({
1797
1690
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1798
1691
  */
1799
1692
  replaceSources({ source }, requestOptions) {
1800
- if (!source) {
1801
- throw new Error("Parameter `source` is required when calling `replaceSources`.");
1802
- }
1693
+ (0, import_client_common.validateRequired)("source", "replaceSources", source);
1803
1694
  const requestPath = "/1/security/sources";
1804
1695
  const headers = {};
1805
1696
  const queryParameters = {};
@@ -1822,9 +1713,7 @@ function createSearchClient({
1822
1713
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1823
1714
  */
1824
1715
  restoreApiKey({ key }, requestOptions) {
1825
- if (!key) {
1826
- throw new Error("Parameter `key` is required when calling `restoreApiKey`.");
1827
- }
1716
+ (0, import_client_common.validateRequired)("key", "restoreApiKey", key);
1828
1717
  const requestPath = "/1/keys/{key}/restore".replace("{key}", encodeURIComponent(key));
1829
1718
  const headers = {};
1830
1719
  const queryParameters = {};
@@ -1847,12 +1736,8 @@ function createSearchClient({
1847
1736
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1848
1737
  */
1849
1738
  saveObject({ indexName, body }, requestOptions) {
1850
- if (!indexName) {
1851
- throw new Error("Parameter `indexName` is required when calling `saveObject`.");
1852
- }
1853
- if (!body) {
1854
- throw new Error("Parameter `body` is required when calling `saveObject`.");
1855
- }
1739
+ (0, import_client_common.validateRequired)("indexName", "saveObject", indexName);
1740
+ (0, import_client_common.validateRequired)("body", "saveObject", body);
1856
1741
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1857
1742
  const headers = {};
1858
1743
  const queryParameters = {};
@@ -1878,21 +1763,11 @@ function createSearchClient({
1878
1763
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1879
1764
  */
1880
1765
  saveRule({ indexName, objectID, rule, forwardToReplicas }, requestOptions) {
1881
- if (!indexName) {
1882
- throw new Error("Parameter `indexName` is required when calling `saveRule`.");
1883
- }
1884
- if (!objectID) {
1885
- throw new Error("Parameter `objectID` is required when calling `saveRule`.");
1886
- }
1887
- if (!rule) {
1888
- throw new Error("Parameter `rule` is required when calling `saveRule`.");
1889
- }
1890
- if (!rule.objectID) {
1891
- throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
1892
- }
1893
- if (!rule.consequence) {
1894
- throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
1895
- }
1766
+ (0, import_client_common.validateRequired)("indexName", "saveRule", indexName);
1767
+ (0, import_client_common.validateRequired)("objectID", "saveRule", objectID);
1768
+ (0, import_client_common.validateRequired)("rule", "saveRule", rule);
1769
+ (0, import_client_common.validateRequired)("rule.objectID", "saveRule", rule.objectID);
1770
+ (0, import_client_common.validateRequired)("rule.consequence", "saveRule", rule.consequence);
1896
1771
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1897
1772
  const headers = {};
1898
1773
  const queryParameters = {};
@@ -1921,12 +1796,8 @@ function createSearchClient({
1921
1796
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1922
1797
  */
1923
1798
  saveRules({ indexName, rules, forwardToReplicas, clearExistingRules }, requestOptions) {
1924
- if (!indexName) {
1925
- throw new Error("Parameter `indexName` is required when calling `saveRules`.");
1926
- }
1927
- if (!rules) {
1928
- throw new Error("Parameter `rules` is required when calling `saveRules`.");
1929
- }
1799
+ (0, import_client_common.validateRequired)("indexName", "saveRules", indexName);
1800
+ (0, import_client_common.validateRequired)("rules", "saveRules", rules);
1930
1801
  const requestPath = "/1/indexes/{indexName}/rules/batch".replace("{indexName}", encodeURIComponent(indexName));
1931
1802
  const headers = {};
1932
1803
  const queryParameters = {};
@@ -1958,21 +1829,11 @@ function createSearchClient({
1958
1829
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1959
1830
  */
1960
1831
  saveSynonym({ indexName, objectID, synonymHit, forwardToReplicas }, requestOptions) {
1961
- if (!indexName) {
1962
- throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");
1963
- }
1964
- if (!objectID) {
1965
- throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");
1966
- }
1967
- if (!synonymHit) {
1968
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");
1969
- }
1970
- if (!synonymHit.objectID) {
1971
- throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");
1972
- }
1973
- if (!synonymHit.type) {
1974
- throw new Error("Parameter `synonymHit.type` is required when calling `saveSynonym`.");
1975
- }
1832
+ (0, import_client_common.validateRequired)("indexName", "saveSynonym", indexName);
1833
+ (0, import_client_common.validateRequired)("objectID", "saveSynonym", objectID);
1834
+ (0, import_client_common.validateRequired)("synonymHit", "saveSynonym", synonymHit);
1835
+ (0, import_client_common.validateRequired)("synonymHit.objectID", "saveSynonym", synonymHit.objectID);
1836
+ (0, import_client_common.validateRequired)("synonymHit.type", "saveSynonym", synonymHit.type);
1976
1837
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1977
1838
  const headers = {};
1978
1839
  const queryParameters = {};
@@ -2001,12 +1862,8 @@ function createSearchClient({
2001
1862
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2002
1863
  */
2003
1864
  saveSynonyms({ indexName, synonymHit, forwardToReplicas, replaceExistingSynonyms }, requestOptions) {
2004
- if (!indexName) {
2005
- throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");
2006
- }
2007
- if (!synonymHit) {
2008
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");
2009
- }
1865
+ (0, import_client_common.validateRequired)("indexName", "saveSynonyms", indexName);
1866
+ (0, import_client_common.validateRequired)("synonymHit", "saveSynonyms", synonymHit);
2010
1867
  const requestPath = "/1/indexes/{indexName}/synonyms/batch".replace("{indexName}", encodeURIComponent(indexName));
2011
1868
  const headers = {};
2012
1869
  const queryParameters = {};
@@ -2055,12 +1912,8 @@ function createSearchClient({
2055
1912
  };
2056
1913
  searchMethodParams = newSignatureRequest;
2057
1914
  }
2058
- if (!searchMethodParams) {
2059
- throw new Error("Parameter `searchMethodParams` is required when calling `search`.");
2060
- }
2061
- if (!searchMethodParams.requests) {
2062
- throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");
2063
- }
1915
+ (0, import_client_common.validateRequired)("searchMethodParams", "search", searchMethodParams);
1916
+ (0, import_client_common.validateRequired)("searchMethodParams.requests", "search", searchMethodParams.requests);
2064
1917
  const requestPath = "/1/indexes/*/queries";
2065
1918
  const headers = {};
2066
1919
  const queryParameters = {};
@@ -2086,19 +1939,13 @@ function createSearchClient({
2086
1939
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2087
1940
  */
2088
1941
  searchDictionaryEntries({ dictionaryName, searchDictionaryEntriesParams }, requestOptions) {
2089
- if (!dictionaryName) {
2090
- throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");
2091
- }
2092
- if (!searchDictionaryEntriesParams) {
2093
- throw new Error(
2094
- "Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`."
2095
- );
2096
- }
2097
- if (!searchDictionaryEntriesParams.query) {
2098
- throw new Error(
2099
- "Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`."
2100
- );
2101
- }
1942
+ (0, import_client_common.validateRequired)("dictionaryName", "searchDictionaryEntries", dictionaryName);
1943
+ (0, import_client_common.validateRequired)("searchDictionaryEntriesParams", "searchDictionaryEntries", searchDictionaryEntriesParams);
1944
+ (0, import_client_common.validateRequired)(
1945
+ "searchDictionaryEntriesParams.query",
1946
+ "searchDictionaryEntries",
1947
+ searchDictionaryEntriesParams.query
1948
+ );
2102
1949
  const requestPath = "/1/dictionaries/{dictionaryName}/search".replace(
2103
1950
  "{dictionaryName}",
2104
1951
  encodeURIComponent(dictionaryName)
@@ -2128,12 +1975,8 @@ function createSearchClient({
2128
1975
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2129
1976
  */
2130
1977
  searchForFacetValues({ indexName, facetName, searchForFacetValuesRequest }, requestOptions) {
2131
- if (!indexName) {
2132
- throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");
2133
- }
2134
- if (!facetName) {
2135
- throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");
2136
- }
1978
+ (0, import_client_common.validateRequired)("indexName", "searchForFacetValues", indexName);
1979
+ (0, import_client_common.validateRequired)("facetName", "searchForFacetValues", facetName);
2137
1980
  const requestPath = "/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}", encodeURIComponent(indexName)).replace("{facetName}", encodeURIComponent(facetName));
2138
1981
  const headers = {};
2139
1982
  const queryParameters = {};
@@ -2159,9 +2002,7 @@ function createSearchClient({
2159
2002
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2160
2003
  */
2161
2004
  searchRules({ indexName, searchRulesParams }, requestOptions) {
2162
- if (!indexName) {
2163
- throw new Error("Parameter `indexName` is required when calling `searchRules`.");
2164
- }
2005
+ (0, import_client_common.validateRequired)("indexName", "searchRules", indexName);
2165
2006
  const requestPath = "/1/indexes/{indexName}/rules/search".replace("{indexName}", encodeURIComponent(indexName));
2166
2007
  const headers = {};
2167
2008
  const queryParameters = {};
@@ -2187,9 +2028,7 @@ function createSearchClient({
2187
2028
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2188
2029
  */
2189
2030
  searchSingleIndex({ indexName, searchParams }, requestOptions) {
2190
- if (!indexName) {
2191
- throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");
2192
- }
2031
+ (0, import_client_common.validateRequired)("indexName", "searchSingleIndex", indexName);
2193
2032
  const requestPath = "/1/indexes/{indexName}/query".replace("{indexName}", encodeURIComponent(indexName));
2194
2033
  const headers = {};
2195
2034
  const queryParameters = {};
@@ -2215,9 +2054,7 @@ function createSearchClient({
2215
2054
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2216
2055
  */
2217
2056
  searchSynonyms({ indexName, searchSynonymsParams }, requestOptions) {
2218
- if (!indexName) {
2219
- throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");
2220
- }
2057
+ (0, import_client_common.validateRequired)("indexName", "searchSynonyms", indexName);
2221
2058
  const requestPath = "/1/indexes/{indexName}/synonyms/search".replace(
2222
2059
  "{indexName}",
2223
2060
  encodeURIComponent(indexName)
@@ -2246,12 +2083,8 @@ function createSearchClient({
2246
2083
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2247
2084
  */
2248
2085
  searchUserIds(searchUserIdsParams, requestOptions) {
2249
- if (!searchUserIdsParams) {
2250
- throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");
2251
- }
2252
- if (!searchUserIdsParams.query) {
2253
- throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");
2254
- }
2086
+ (0, import_client_common.validateRequired)("searchUserIdsParams", "searchUserIds", searchUserIdsParams);
2087
+ (0, import_client_common.validateRequired)("searchUserIdsParams.query", "searchUserIds", searchUserIdsParams.query);
2255
2088
  const requestPath = "/1/clusters/mapping/search";
2256
2089
  const headers = {};
2257
2090
  const queryParameters = {};
@@ -2275,14 +2108,12 @@ function createSearchClient({
2275
2108
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2276
2109
  */
2277
2110
  setDictionarySettings(dictionarySettingsParams, requestOptions) {
2278
- if (!dictionarySettingsParams) {
2279
- throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");
2280
- }
2281
- if (!dictionarySettingsParams.disableStandardEntries) {
2282
- throw new Error(
2283
- "Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`."
2284
- );
2285
- }
2111
+ (0, import_client_common.validateRequired)("dictionarySettingsParams", "setDictionarySettings", dictionarySettingsParams);
2112
+ (0, import_client_common.validateRequired)(
2113
+ "dictionarySettingsParams.disableStandardEntries",
2114
+ "setDictionarySettings",
2115
+ dictionarySettingsParams.disableStandardEntries
2116
+ );
2286
2117
  const requestPath = "/1/dictionaries/*/settings";
2287
2118
  const headers = {};
2288
2119
  const queryParameters = {};
@@ -2307,12 +2138,8 @@ function createSearchClient({
2307
2138
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2308
2139
  */
2309
2140
  setSettings({ indexName, indexSettings, forwardToReplicas }, requestOptions) {
2310
- if (!indexName) {
2311
- throw new Error("Parameter `indexName` is required when calling `setSettings`.");
2312
- }
2313
- if (!indexSettings) {
2314
- throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");
2315
- }
2141
+ (0, import_client_common.validateRequired)("indexName", "setSettings", indexName);
2142
+ (0, import_client_common.validateRequired)("indexSettings", "setSettings", indexSettings);
2316
2143
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
2317
2144
  const headers = {};
2318
2145
  const queryParameters = {};
@@ -2339,15 +2166,9 @@ function createSearchClient({
2339
2166
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2340
2167
  */
2341
2168
  updateApiKey({ key, apiKey }, requestOptions) {
2342
- if (!key) {
2343
- throw new Error("Parameter `key` is required when calling `updateApiKey`.");
2344
- }
2345
- if (!apiKey) {
2346
- throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");
2347
- }
2348
- if (!apiKey.acl) {
2349
- throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");
2350
- }
2169
+ (0, import_client_common.validateRequired)("key", "updateApiKey", key);
2170
+ (0, import_client_common.validateRequired)("apiKey", "updateApiKey", apiKey);
2171
+ (0, import_client_common.validateRequired)("apiKey.acl", "updateApiKey", apiKey.acl);
2351
2172
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
2352
2173
  const headers = {};
2353
2174
  const queryParameters = {};
@@ -2429,6 +2250,7 @@ function searchClient(appId, apiKey, options) {
2429
2250
  * @param accountCopyIndex.destinationApiKey - The API Key of the `destinationAppID` to write the index to, must have write ACLs.
2430
2251
  * @param accountCopyIndex.destinationIndexName - The name of the index to write the copied index to.
2431
2252
  * @param accountCopyIndex.batchSize - The size of the chunk of `objects`. Defaults to 1000.
2253
+ * @param accountCopyIndex.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
2432
2254
  * @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.
2433
2255
  */
2434
2256
  async accountCopyIndex({
@@ -2436,7 +2258,8 @@ function searchClient(appId, apiKey, options) {
2436
2258
  destinationAppID,
2437
2259
  destinationApiKey,
2438
2260
  destinationIndexName,
2439
- batchSize
2261
+ batchSize,
2262
+ maxRetries = 100
2440
2263
  }, requestOptions) {
2441
2264
  const responses = [];
2442
2265
  if (this.appId === destinationAppID) {
@@ -2508,7 +2331,7 @@ function searchClient(appId, apiKey, options) {
2508
2331
  }
2509
2332
  });
2510
2333
  for (const response of responses) {
2511
- await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID });
2334
+ await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID, maxRetries });
2512
2335
  }
2513
2336
  },
2514
2337
  /**