@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.
@@ -19,9 +19,10 @@ import {
19
19
  createIterablePromise,
20
20
  createTransporter,
21
21
  getAlgoliaAgent,
22
- shuffle
22
+ shuffle,
23
+ validateRequired
23
24
  } from "@algolia/client-common";
24
- var apiClientVersion = "5.52.1";
25
+ var apiClientVersion = "5.54.0";
25
26
  function getDefaultHosts(appId) {
26
27
  return [
27
28
  {
@@ -355,9 +356,17 @@ function createSearchClient({
355
356
  * @param chunkedBatch.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`.
356
357
  * @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.
357
358
  * @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.
359
+ * @param chunkedBatch.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
358
360
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
359
361
  */
360
- async chunkedBatch({ indexName, objects, action = "addObject", waitForTasks, batchSize = 1e3 }, requestOptions) {
362
+ async chunkedBatch({
363
+ indexName,
364
+ objects,
365
+ action = "addObject",
366
+ waitForTasks,
367
+ batchSize = 1e3,
368
+ maxRetries = 100
369
+ }, requestOptions) {
361
370
  let requests = [];
362
371
  const responses = [];
363
372
  const objectEntries = objects.entries();
@@ -370,7 +379,7 @@ function createSearchClient({
370
379
  }
371
380
  if (waitForTasks) {
372
381
  for (const resp of responses) {
373
- await this.waitForTask({ indexName, taskID: resp.taskID });
382
+ await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
374
383
  }
375
384
  }
376
385
  return responses;
@@ -384,11 +393,12 @@ function createSearchClient({
384
393
  * @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
385
394
  * @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.
386
395
  * @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.
396
+ * @param saveObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
387
397
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
388
398
  */
389
- async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
399
+ async saveObjects({ indexName, objects, waitForTasks, batchSize, maxRetries }, requestOptions) {
390
400
  return await this.chunkedBatch(
391
- { indexName, objects, action: "addObject", waitForTasks, batchSize },
401
+ { indexName, objects, action: "addObject", waitForTasks, batchSize, maxRetries },
392
402
  requestOptions
393
403
  );
394
404
  },
@@ -401,16 +411,18 @@ function createSearchClient({
401
411
  * @param deleteObjects.objectIDs - The objectIDs to delete.
402
412
  * @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.
403
413
  * @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.
414
+ * @param deleteObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
404
415
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
405
416
  */
406
- async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
417
+ async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize, maxRetries }, requestOptions) {
407
418
  return await this.chunkedBatch(
408
419
  {
409
420
  indexName,
410
421
  objects: objectIDs.map((objectID) => ({ objectID })),
411
422
  action: "deleteObject",
412
423
  waitForTasks,
413
- batchSize
424
+ batchSize,
425
+ maxRetries
414
426
  },
415
427
  requestOptions
416
428
  );
@@ -425,16 +437,18 @@ function createSearchClient({
425
437
  * @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail.
426
438
  * @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.
427
439
  * @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.
440
+ * @param partialUpdateObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
428
441
  * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
429
442
  */
430
- async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
443
+ async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize, maxRetries }, requestOptions) {
431
444
  return await this.chunkedBatch(
432
445
  {
433
446
  indexName,
434
447
  objects,
435
448
  action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
436
449
  batchSize,
437
- waitForTasks
450
+ waitForTasks,
451
+ maxRetries
438
452
  },
439
453
  requestOptions
440
454
  );
@@ -449,9 +463,10 @@ function createSearchClient({
449
463
  * @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
450
464
  * @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.
451
465
  * @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
466
+ * @param replaceAllObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
452
467
  * @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.
453
468
  */
454
- async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
469
+ async replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries = 100 }, requestOptions) {
455
470
  const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
456
471
  const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
457
472
  if (scopes === void 0) {
@@ -470,12 +485,13 @@ function createSearchClient({
470
485
  requestOptions
471
486
  );
472
487
  const batchResponses = await this.chunkedBatch(
473
- { indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
488
+ { indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
474
489
  requestOptions
475
490
  );
476
491
  await this.waitForTask({
477
492
  indexName: tmpIndexName,
478
- taskID: copyOperationResponse.taskID
493
+ taskID: copyOperationResponse.taskID,
494
+ maxRetries
479
495
  });
480
496
  copyOperationResponse = await this.operationIndex(
481
497
  {
@@ -490,7 +506,8 @@ function createSearchClient({
490
506
  );
491
507
  await this.waitForTask({
492
508
  indexName: tmpIndexName,
493
- taskID: copyOperationResponse.taskID
509
+ taskID: copyOperationResponse.taskID,
510
+ maxRetries
494
511
  });
495
512
  const moveOperationResponse = await this.operationIndex(
496
513
  {
@@ -501,7 +518,8 @@ function createSearchClient({
501
518
  );
502
519
  await this.waitForTask({
503
520
  indexName: tmpIndexName,
504
- taskID: moveOperationResponse.taskID
521
+ taskID: moveOperationResponse.taskID,
522
+ maxRetries
505
523
  });
506
524
  return { copyOperationResponse, batchResponses, moveOperationResponse };
507
525
  } catch (error) {
@@ -551,12 +569,8 @@ function createSearchClient({
551
569
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
552
570
  */
553
571
  addApiKey(apiKey, requestOptions) {
554
- if (!apiKey) {
555
- throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");
556
- }
557
- if (!apiKey.acl) {
558
- throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");
559
- }
572
+ validateRequired("apiKey", "addApiKey", apiKey);
573
+ validateRequired("apiKey.acl", "addApiKey", apiKey.acl);
560
574
  const requestPath = "/1/keys";
561
575
  const headers = {};
562
576
  const queryParameters = {};
@@ -581,15 +595,9 @@ function createSearchClient({
581
595
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
582
596
  */
583
597
  addOrUpdateObject({ indexName, objectID, body }, requestOptions) {
584
- if (!indexName) {
585
- throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");
586
- }
587
- if (!objectID) {
588
- throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");
589
- }
590
- if (!body) {
591
- throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");
592
- }
598
+ validateRequired("indexName", "addOrUpdateObject", indexName);
599
+ validateRequired("objectID", "addOrUpdateObject", objectID);
600
+ validateRequired("body", "addOrUpdateObject", body);
593
601
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
594
602
  const headers = {};
595
603
  const queryParameters = {};
@@ -611,12 +619,8 @@ function createSearchClient({
611
619
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
612
620
  */
613
621
  appendSource(source, requestOptions) {
614
- if (!source) {
615
- throw new Error("Parameter `source` is required when calling `appendSource`.");
616
- }
617
- if (!source.source) {
618
- throw new Error("Parameter `source.source` is required when calling `appendSource`.");
619
- }
622
+ validateRequired("source", "appendSource", source);
623
+ validateRequired("source.source", "appendSource", source.source);
620
624
  const requestPath = "/1/security/sources/append";
621
625
  const headers = {};
622
626
  const queryParameters = {};
@@ -642,15 +646,9 @@ function createSearchClient({
642
646
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
643
647
  */
644
648
  assignUserId({ xAlgoliaUserID, assignUserIdParams }, requestOptions) {
645
- if (!xAlgoliaUserID) {
646
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");
647
- }
648
- if (!assignUserIdParams) {
649
- throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");
650
- }
651
- if (!assignUserIdParams.cluster) {
652
- throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");
653
- }
649
+ validateRequired("xAlgoliaUserID", "assignUserId", xAlgoliaUserID);
650
+ validateRequired("assignUserIdParams", "assignUserId", assignUserIdParams);
651
+ validateRequired("assignUserIdParams.cluster", "assignUserId", assignUserIdParams.cluster);
654
652
  const requestPath = "/1/clusters/mapping";
655
653
  const headers = {};
656
654
  const queryParameters = {};
@@ -677,15 +675,9 @@ function createSearchClient({
677
675
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
678
676
  */
679
677
  batch({ indexName, batchWriteParams }, requestOptions) {
680
- if (!indexName) {
681
- throw new Error("Parameter `indexName` is required when calling `batch`.");
682
- }
683
- if (!batchWriteParams) {
684
- throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");
685
- }
686
- if (!batchWriteParams.requests) {
687
- throw new Error("Parameter `batchWriteParams.requests` is required when calling `batch`.");
688
- }
678
+ validateRequired("indexName", "batch", indexName);
679
+ validateRequired("batchWriteParams", "batch", batchWriteParams);
680
+ validateRequired("batchWriteParams.requests", "batch", batchWriteParams.requests);
689
681
  const requestPath = "/1/indexes/{indexName}/batch".replace("{indexName}", encodeURIComponent(indexName));
690
682
  const headers = {};
691
683
  const queryParameters = {};
@@ -711,18 +703,10 @@ function createSearchClient({
711
703
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
712
704
  */
713
705
  batchAssignUserIds({ xAlgoliaUserID, batchAssignUserIdsParams }, requestOptions) {
714
- if (!xAlgoliaUserID) {
715
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");
716
- }
717
- if (!batchAssignUserIdsParams) {
718
- throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");
719
- }
720
- if (!batchAssignUserIdsParams.cluster) {
721
- throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");
722
- }
723
- if (!batchAssignUserIdsParams.users) {
724
- throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");
725
- }
706
+ validateRequired("xAlgoliaUserID", "batchAssignUserIds", xAlgoliaUserID);
707
+ validateRequired("batchAssignUserIdsParams", "batchAssignUserIds", batchAssignUserIdsParams);
708
+ validateRequired("batchAssignUserIdsParams.cluster", "batchAssignUserIds", batchAssignUserIdsParams.cluster);
709
+ validateRequired("batchAssignUserIdsParams.users", "batchAssignUserIds", batchAssignUserIdsParams.users);
726
710
  const requestPath = "/1/clusters/mapping/batch";
727
711
  const headers = {};
728
712
  const queryParameters = {};
@@ -749,17 +733,13 @@ function createSearchClient({
749
733
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
750
734
  */
751
735
  batchDictionaryEntries({ dictionaryName, batchDictionaryEntriesParams }, requestOptions) {
752
- if (!dictionaryName) {
753
- throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");
754
- }
755
- if (!batchDictionaryEntriesParams) {
756
- throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");
757
- }
758
- if (!batchDictionaryEntriesParams.requests) {
759
- throw new Error(
760
- "Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`."
761
- );
762
- }
736
+ validateRequired("dictionaryName", "batchDictionaryEntries", dictionaryName);
737
+ validateRequired("batchDictionaryEntriesParams", "batchDictionaryEntries", batchDictionaryEntriesParams);
738
+ validateRequired(
739
+ "batchDictionaryEntriesParams.requests",
740
+ "batchDictionaryEntries",
741
+ batchDictionaryEntriesParams.requests
742
+ );
763
743
  const requestPath = "/1/dictionaries/{dictionaryName}/batch".replace(
764
744
  "{dictionaryName}",
765
745
  encodeURIComponent(dictionaryName)
@@ -786,9 +766,7 @@ function createSearchClient({
786
766
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
787
767
  */
788
768
  browse({ indexName, browseParams }, requestOptions) {
789
- if (!indexName) {
790
- throw new Error("Parameter `indexName` is required when calling `browse`.");
791
- }
769
+ validateRequired("indexName", "browse", indexName);
792
770
  const requestPath = "/1/indexes/{indexName}/browse".replace("{indexName}", encodeURIComponent(indexName));
793
771
  const headers = {};
794
772
  const queryParameters = {};
@@ -812,9 +790,7 @@ function createSearchClient({
812
790
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
813
791
  */
814
792
  clearObjects({ indexName }, requestOptions) {
815
- if (!indexName) {
816
- throw new Error("Parameter `indexName` is required when calling `clearObjects`.");
817
- }
793
+ validateRequired("indexName", "clearObjects", indexName);
818
794
  const requestPath = "/1/indexes/{indexName}/clear".replace("{indexName}", encodeURIComponent(indexName));
819
795
  const headers = {};
820
796
  const queryParameters = {};
@@ -837,9 +813,7 @@ function createSearchClient({
837
813
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
838
814
  */
839
815
  clearRules({ indexName, forwardToReplicas }, requestOptions) {
840
- if (!indexName) {
841
- throw new Error("Parameter `indexName` is required when calling `clearRules`.");
842
- }
816
+ validateRequired("indexName", "clearRules", indexName);
843
817
  const requestPath = "/1/indexes/{indexName}/rules/clear".replace("{indexName}", encodeURIComponent(indexName));
844
818
  const headers = {};
845
819
  const queryParameters = {};
@@ -865,9 +839,7 @@ function createSearchClient({
865
839
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
866
840
  */
867
841
  clearSynonyms({ indexName, forwardToReplicas }, requestOptions) {
868
- if (!indexName) {
869
- throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");
870
- }
842
+ validateRequired("indexName", "clearSynonyms", indexName);
871
843
  const requestPath = "/1/indexes/{indexName}/synonyms/clear".replace("{indexName}", encodeURIComponent(indexName));
872
844
  const headers = {};
873
845
  const queryParameters = {};
@@ -890,9 +862,7 @@ function createSearchClient({
890
862
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
891
863
  */
892
864
  customDelete({ path, parameters }, requestOptions) {
893
- if (!path) {
894
- throw new Error("Parameter `path` is required when calling `customDelete`.");
895
- }
865
+ validateRequired("path", "customDelete", path);
896
866
  const requestPath = "/{path}".replace("{path}", path);
897
867
  const headers = {};
898
868
  const queryParameters = parameters ? parameters : {};
@@ -912,9 +882,7 @@ function createSearchClient({
912
882
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
913
883
  */
914
884
  customGet({ path, parameters }, requestOptions) {
915
- if (!path) {
916
- throw new Error("Parameter `path` is required when calling `customGet`.");
917
- }
885
+ validateRequired("path", "customGet", path);
918
886
  const requestPath = "/{path}".replace("{path}", path);
919
887
  const headers = {};
920
888
  const queryParameters = parameters ? parameters : {};
@@ -935,9 +903,7 @@ function createSearchClient({
935
903
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
936
904
  */
937
905
  customPost({ path, parameters, body }, requestOptions) {
938
- if (!path) {
939
- throw new Error("Parameter `path` is required when calling `customPost`.");
940
- }
906
+ validateRequired("path", "customPost", path);
941
907
  const requestPath = "/{path}".replace("{path}", path);
942
908
  const headers = {};
943
909
  const queryParameters = parameters ? parameters : {};
@@ -959,9 +925,7 @@ function createSearchClient({
959
925
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
960
926
  */
961
927
  customPut({ path, parameters, body }, requestOptions) {
962
- if (!path) {
963
- throw new Error("Parameter `path` is required when calling `customPut`.");
964
- }
928
+ validateRequired("path", "customPut", path);
965
929
  const requestPath = "/{path}".replace("{path}", path);
966
930
  const headers = {};
967
931
  const queryParameters = parameters ? parameters : {};
@@ -984,9 +948,7 @@ function createSearchClient({
984
948
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
985
949
  */
986
950
  deleteApiKey({ key }, requestOptions) {
987
- if (!key) {
988
- throw new Error("Parameter `key` is required when calling `deleteApiKey`.");
989
- }
951
+ validateRequired("key", "deleteApiKey", key);
990
952
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
991
953
  const headers = {};
992
954
  const queryParameters = {};
@@ -1009,12 +971,8 @@ function createSearchClient({
1009
971
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1010
972
  */
1011
973
  deleteBy({ indexName, deleteByParams }, requestOptions) {
1012
- if (!indexName) {
1013
- throw new Error("Parameter `indexName` is required when calling `deleteBy`.");
1014
- }
1015
- if (!deleteByParams) {
1016
- throw new Error("Parameter `deleteByParams` is required when calling `deleteBy`.");
1017
- }
974
+ validateRequired("indexName", "deleteBy", indexName);
975
+ validateRequired("deleteByParams", "deleteBy", deleteByParams);
1018
976
  const requestPath = "/1/indexes/{indexName}/deleteByQuery".replace("{indexName}", encodeURIComponent(indexName));
1019
977
  const headers = {};
1020
978
  const queryParameters = {};
@@ -1037,9 +995,7 @@ function createSearchClient({
1037
995
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1038
996
  */
1039
997
  deleteIndex({ indexName }, requestOptions) {
1040
- if (!indexName) {
1041
- throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");
1042
- }
998
+ validateRequired("indexName", "deleteIndex", indexName);
1043
999
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1044
1000
  const headers = {};
1045
1001
  const queryParameters = {};
@@ -1062,12 +1018,8 @@ function createSearchClient({
1062
1018
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1063
1019
  */
1064
1020
  deleteObject({ indexName, objectID }, requestOptions) {
1065
- if (!indexName) {
1066
- throw new Error("Parameter `indexName` is required when calling `deleteObject`.");
1067
- }
1068
- if (!objectID) {
1069
- throw new Error("Parameter `objectID` is required when calling `deleteObject`.");
1070
- }
1021
+ validateRequired("indexName", "deleteObject", indexName);
1022
+ validateRequired("objectID", "deleteObject", objectID);
1071
1023
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1072
1024
  const headers = {};
1073
1025
  const queryParameters = {};
@@ -1091,12 +1043,8 @@ function createSearchClient({
1091
1043
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1092
1044
  */
1093
1045
  deleteRule({ indexName, objectID, forwardToReplicas }, requestOptions) {
1094
- if (!indexName) {
1095
- throw new Error("Parameter `indexName` is required when calling `deleteRule`.");
1096
- }
1097
- if (!objectID) {
1098
- throw new Error("Parameter `objectID` is required when calling `deleteRule`.");
1099
- }
1046
+ validateRequired("indexName", "deleteRule", indexName);
1047
+ validateRequired("objectID", "deleteRule", objectID);
1100
1048
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1101
1049
  const headers = {};
1102
1050
  const queryParameters = {};
@@ -1121,9 +1069,7 @@ function createSearchClient({
1121
1069
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1122
1070
  */
1123
1071
  deleteSource({ source }, requestOptions) {
1124
- if (!source) {
1125
- throw new Error("Parameter `source` is required when calling `deleteSource`.");
1126
- }
1072
+ validateRequired("source", "deleteSource", source);
1127
1073
  const requestPath = "/1/security/sources/{source}".replace("{source}", encodeURIComponent(source));
1128
1074
  const headers = {};
1129
1075
  const queryParameters = {};
@@ -1147,12 +1093,8 @@ function createSearchClient({
1147
1093
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1148
1094
  */
1149
1095
  deleteSynonym({ indexName, objectID, forwardToReplicas }, requestOptions) {
1150
- if (!indexName) {
1151
- throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");
1152
- }
1153
- if (!objectID) {
1154
- throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");
1155
- }
1096
+ validateRequired("indexName", "deleteSynonym", indexName);
1097
+ validateRequired("objectID", "deleteSynonym", objectID);
1156
1098
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1157
1099
  const headers = {};
1158
1100
  const queryParameters = {};
@@ -1177,9 +1119,7 @@ function createSearchClient({
1177
1119
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1178
1120
  */
1179
1121
  getApiKey({ key }, requestOptions) {
1180
- if (!key) {
1181
- throw new Error("Parameter `key` is required when calling `getApiKey`.");
1182
- }
1122
+ validateRequired("key", "getApiKey", key);
1183
1123
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1184
1124
  const headers = {};
1185
1125
  const queryParameters = {};
@@ -1201,9 +1141,7 @@ function createSearchClient({
1201
1141
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1202
1142
  */
1203
1143
  getAppTask({ taskID }, requestOptions) {
1204
- if (!taskID) {
1205
- throw new Error("Parameter `taskID` is required when calling `getAppTask`.");
1206
- }
1144
+ validateRequired("taskID", "getAppTask", taskID);
1207
1145
  const requestPath = "/1/task/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1208
1146
  const headers = {};
1209
1147
  const queryParameters = {};
@@ -1301,12 +1239,8 @@ function createSearchClient({
1301
1239
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1302
1240
  */
1303
1241
  getObject({ indexName, objectID, attributesToRetrieve }, requestOptions) {
1304
- if (!indexName) {
1305
- throw new Error("Parameter `indexName` is required when calling `getObject`.");
1306
- }
1307
- if (!objectID) {
1308
- throw new Error("Parameter `objectID` is required when calling `getObject`.");
1309
- }
1242
+ validateRequired("indexName", "getObject", indexName);
1243
+ validateRequired("objectID", "getObject", objectID);
1310
1244
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1311
1245
  const headers = {};
1312
1246
  const queryParameters = {};
@@ -1330,12 +1264,8 @@ function createSearchClient({
1330
1264
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1331
1265
  */
1332
1266
  getObjects(getObjectsParams, requestOptions) {
1333
- if (!getObjectsParams) {
1334
- throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");
1335
- }
1336
- if (!getObjectsParams.requests) {
1337
- throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");
1338
- }
1267
+ validateRequired("getObjectsParams", "getObjects", getObjectsParams);
1268
+ validateRequired("getObjectsParams.requests", "getObjects", getObjectsParams.requests);
1339
1269
  const requestPath = "/1/indexes/*/objects";
1340
1270
  const headers = {};
1341
1271
  const queryParameters = {};
@@ -1361,12 +1291,8 @@ function createSearchClient({
1361
1291
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1362
1292
  */
1363
1293
  getRule({ indexName, objectID }, requestOptions) {
1364
- if (!indexName) {
1365
- throw new Error("Parameter `indexName` is required when calling `getRule`.");
1366
- }
1367
- if (!objectID) {
1368
- throw new Error("Parameter `objectID` is required when calling `getRule`.");
1369
- }
1294
+ validateRequired("indexName", "getRule", indexName);
1295
+ validateRequired("objectID", "getRule", objectID);
1370
1296
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1371
1297
  const headers = {};
1372
1298
  const queryParameters = {};
@@ -1389,9 +1315,7 @@ function createSearchClient({
1389
1315
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1390
1316
  */
1391
1317
  getSettings({ indexName, getVersion }, requestOptions) {
1392
- if (!indexName) {
1393
- throw new Error("Parameter `indexName` is required when calling `getSettings`.");
1394
- }
1318
+ validateRequired("indexName", "getSettings", indexName);
1395
1319
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
1396
1320
  const headers = {};
1397
1321
  const queryParameters = {};
@@ -1436,12 +1360,8 @@ function createSearchClient({
1436
1360
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1437
1361
  */
1438
1362
  getSynonym({ indexName, objectID }, requestOptions) {
1439
- if (!indexName) {
1440
- throw new Error("Parameter `indexName` is required when calling `getSynonym`.");
1441
- }
1442
- if (!objectID) {
1443
- throw new Error("Parameter `objectID` is required when calling `getSynonym`.");
1444
- }
1363
+ validateRequired("indexName", "getSynonym", indexName);
1364
+ validateRequired("objectID", "getSynonym", objectID);
1445
1365
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1446
1366
  const headers = {};
1447
1367
  const queryParameters = {};
@@ -1464,12 +1384,8 @@ function createSearchClient({
1464
1384
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1465
1385
  */
1466
1386
  getTask({ indexName, taskID }, requestOptions) {
1467
- if (!indexName) {
1468
- throw new Error("Parameter `indexName` is required when calling `getTask`.");
1469
- }
1470
- if (!taskID) {
1471
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
1472
- }
1387
+ validateRequired("indexName", "getTask", indexName);
1388
+ validateRequired("taskID", "getTask", taskID);
1473
1389
  const requestPath = "/1/indexes/{indexName}/task/{taskID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{taskID}", encodeURIComponent(taskID));
1474
1390
  const headers = {};
1475
1391
  const queryParameters = {};
@@ -1514,9 +1430,7 @@ function createSearchClient({
1514
1430
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1515
1431
  */
1516
1432
  getUserId({ userID }, requestOptions) {
1517
- if (!userID) {
1518
- throw new Error("Parameter `userID` is required when calling `getUserId`.");
1519
- }
1433
+ validateRequired("userID", "getUserId", userID);
1520
1434
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1521
1435
  const headers = {};
1522
1436
  const queryParameters = {};
@@ -1661,12 +1575,8 @@ function createSearchClient({
1661
1575
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1662
1576
  */
1663
1577
  multipleBatch(batchParams, requestOptions) {
1664
- if (!batchParams) {
1665
- throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");
1666
- }
1667
- if (!batchParams.requests) {
1668
- throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");
1669
- }
1578
+ validateRequired("batchParams", "multipleBatch", batchParams);
1579
+ validateRequired("batchParams.requests", "multipleBatch", batchParams.requests);
1670
1580
  const requestPath = "/1/indexes/*/batch";
1671
1581
  const headers = {};
1672
1582
  const queryParameters = {};
@@ -1690,18 +1600,10 @@ function createSearchClient({
1690
1600
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1691
1601
  */
1692
1602
  operationIndex({ indexName, operationIndexParams }, requestOptions) {
1693
- if (!indexName) {
1694
- throw new Error("Parameter `indexName` is required when calling `operationIndex`.");
1695
- }
1696
- if (!operationIndexParams) {
1697
- throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");
1698
- }
1699
- if (!operationIndexParams.operation) {
1700
- throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");
1701
- }
1702
- if (!operationIndexParams.destination) {
1703
- throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");
1704
- }
1603
+ validateRequired("indexName", "operationIndex", indexName);
1604
+ validateRequired("operationIndexParams", "operationIndex", operationIndexParams);
1605
+ validateRequired("operationIndexParams.operation", "operationIndex", operationIndexParams.operation);
1606
+ validateRequired("operationIndexParams.destination", "operationIndex", operationIndexParams.destination);
1705
1607
  const requestPath = "/1/indexes/{indexName}/operation".replace("{indexName}", encodeURIComponent(indexName));
1706
1608
  const headers = {};
1707
1609
  const queryParameters = {};
@@ -1727,15 +1629,9 @@ function createSearchClient({
1727
1629
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1728
1630
  */
1729
1631
  partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists }, requestOptions) {
1730
- if (!indexName) {
1731
- throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");
1732
- }
1733
- if (!objectID) {
1734
- throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");
1735
- }
1736
- if (!attributesToUpdate) {
1737
- throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");
1738
- }
1632
+ validateRequired("indexName", "partialUpdateObject", indexName);
1633
+ validateRequired("objectID", "partialUpdateObject", objectID);
1634
+ validateRequired("attributesToUpdate", "partialUpdateObject", attributesToUpdate);
1739
1635
  const requestPath = "/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1740
1636
  const headers = {};
1741
1637
  const queryParameters = {};
@@ -1763,9 +1659,7 @@ function createSearchClient({
1763
1659
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1764
1660
  */
1765
1661
  removeUserId({ userID }, requestOptions) {
1766
- if (!userID) {
1767
- throw new Error("Parameter `userID` is required when calling `removeUserId`.");
1768
- }
1662
+ validateRequired("userID", "removeUserId", userID);
1769
1663
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1770
1664
  const headers = {};
1771
1665
  const queryParameters = {};
@@ -1787,9 +1681,7 @@ function createSearchClient({
1787
1681
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1788
1682
  */
1789
1683
  replaceSources({ source }, requestOptions) {
1790
- if (!source) {
1791
- throw new Error("Parameter `source` is required when calling `replaceSources`.");
1792
- }
1684
+ validateRequired("source", "replaceSources", source);
1793
1685
  const requestPath = "/1/security/sources";
1794
1686
  const headers = {};
1795
1687
  const queryParameters = {};
@@ -1812,9 +1704,7 @@ function createSearchClient({
1812
1704
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1813
1705
  */
1814
1706
  restoreApiKey({ key }, requestOptions) {
1815
- if (!key) {
1816
- throw new Error("Parameter `key` is required when calling `restoreApiKey`.");
1817
- }
1707
+ validateRequired("key", "restoreApiKey", key);
1818
1708
  const requestPath = "/1/keys/{key}/restore".replace("{key}", encodeURIComponent(key));
1819
1709
  const headers = {};
1820
1710
  const queryParameters = {};
@@ -1837,12 +1727,8 @@ function createSearchClient({
1837
1727
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1838
1728
  */
1839
1729
  saveObject({ indexName, body }, requestOptions) {
1840
- if (!indexName) {
1841
- throw new Error("Parameter `indexName` is required when calling `saveObject`.");
1842
- }
1843
- if (!body) {
1844
- throw new Error("Parameter `body` is required when calling `saveObject`.");
1845
- }
1730
+ validateRequired("indexName", "saveObject", indexName);
1731
+ validateRequired("body", "saveObject", body);
1846
1732
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1847
1733
  const headers = {};
1848
1734
  const queryParameters = {};
@@ -1868,21 +1754,11 @@ function createSearchClient({
1868
1754
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1869
1755
  */
1870
1756
  saveRule({ indexName, objectID, rule, forwardToReplicas }, requestOptions) {
1871
- if (!indexName) {
1872
- throw new Error("Parameter `indexName` is required when calling `saveRule`.");
1873
- }
1874
- if (!objectID) {
1875
- throw new Error("Parameter `objectID` is required when calling `saveRule`.");
1876
- }
1877
- if (!rule) {
1878
- throw new Error("Parameter `rule` is required when calling `saveRule`.");
1879
- }
1880
- if (!rule.objectID) {
1881
- throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
1882
- }
1883
- if (!rule.consequence) {
1884
- throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
1885
- }
1757
+ validateRequired("indexName", "saveRule", indexName);
1758
+ validateRequired("objectID", "saveRule", objectID);
1759
+ validateRequired("rule", "saveRule", rule);
1760
+ validateRequired("rule.objectID", "saveRule", rule.objectID);
1761
+ validateRequired("rule.consequence", "saveRule", rule.consequence);
1886
1762
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1887
1763
  const headers = {};
1888
1764
  const queryParameters = {};
@@ -1911,12 +1787,8 @@ function createSearchClient({
1911
1787
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1912
1788
  */
1913
1789
  saveRules({ indexName, rules, forwardToReplicas, clearExistingRules }, requestOptions) {
1914
- if (!indexName) {
1915
- throw new Error("Parameter `indexName` is required when calling `saveRules`.");
1916
- }
1917
- if (!rules) {
1918
- throw new Error("Parameter `rules` is required when calling `saveRules`.");
1919
- }
1790
+ validateRequired("indexName", "saveRules", indexName);
1791
+ validateRequired("rules", "saveRules", rules);
1920
1792
  const requestPath = "/1/indexes/{indexName}/rules/batch".replace("{indexName}", encodeURIComponent(indexName));
1921
1793
  const headers = {};
1922
1794
  const queryParameters = {};
@@ -1948,21 +1820,11 @@ function createSearchClient({
1948
1820
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1949
1821
  */
1950
1822
  saveSynonym({ indexName, objectID, synonymHit, forwardToReplicas }, requestOptions) {
1951
- if (!indexName) {
1952
- throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");
1953
- }
1954
- if (!objectID) {
1955
- throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");
1956
- }
1957
- if (!synonymHit) {
1958
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");
1959
- }
1960
- if (!synonymHit.objectID) {
1961
- throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");
1962
- }
1963
- if (!synonymHit.type) {
1964
- throw new Error("Parameter `synonymHit.type` is required when calling `saveSynonym`.");
1965
- }
1823
+ validateRequired("indexName", "saveSynonym", indexName);
1824
+ validateRequired("objectID", "saveSynonym", objectID);
1825
+ validateRequired("synonymHit", "saveSynonym", synonymHit);
1826
+ validateRequired("synonymHit.objectID", "saveSynonym", synonymHit.objectID);
1827
+ validateRequired("synonymHit.type", "saveSynonym", synonymHit.type);
1966
1828
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1967
1829
  const headers = {};
1968
1830
  const queryParameters = {};
@@ -1991,12 +1853,8 @@ function createSearchClient({
1991
1853
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1992
1854
  */
1993
1855
  saveSynonyms({ indexName, synonymHit, forwardToReplicas, replaceExistingSynonyms }, requestOptions) {
1994
- if (!indexName) {
1995
- throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");
1996
- }
1997
- if (!synonymHit) {
1998
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");
1999
- }
1856
+ validateRequired("indexName", "saveSynonyms", indexName);
1857
+ validateRequired("synonymHit", "saveSynonyms", synonymHit);
2000
1858
  const requestPath = "/1/indexes/{indexName}/synonyms/batch".replace("{indexName}", encodeURIComponent(indexName));
2001
1859
  const headers = {};
2002
1860
  const queryParameters = {};
@@ -2045,12 +1903,8 @@ function createSearchClient({
2045
1903
  };
2046
1904
  searchMethodParams = newSignatureRequest;
2047
1905
  }
2048
- if (!searchMethodParams) {
2049
- throw new Error("Parameter `searchMethodParams` is required when calling `search`.");
2050
- }
2051
- if (!searchMethodParams.requests) {
2052
- throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");
2053
- }
1906
+ validateRequired("searchMethodParams", "search", searchMethodParams);
1907
+ validateRequired("searchMethodParams.requests", "search", searchMethodParams.requests);
2054
1908
  const requestPath = "/1/indexes/*/queries";
2055
1909
  const headers = {};
2056
1910
  const queryParameters = {};
@@ -2076,19 +1930,13 @@ function createSearchClient({
2076
1930
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2077
1931
  */
2078
1932
  searchDictionaryEntries({ dictionaryName, searchDictionaryEntriesParams }, requestOptions) {
2079
- if (!dictionaryName) {
2080
- throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");
2081
- }
2082
- if (!searchDictionaryEntriesParams) {
2083
- throw new Error(
2084
- "Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`."
2085
- );
2086
- }
2087
- if (!searchDictionaryEntriesParams.query) {
2088
- throw new Error(
2089
- "Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`."
2090
- );
2091
- }
1933
+ validateRequired("dictionaryName", "searchDictionaryEntries", dictionaryName);
1934
+ validateRequired("searchDictionaryEntriesParams", "searchDictionaryEntries", searchDictionaryEntriesParams);
1935
+ validateRequired(
1936
+ "searchDictionaryEntriesParams.query",
1937
+ "searchDictionaryEntries",
1938
+ searchDictionaryEntriesParams.query
1939
+ );
2092
1940
  const requestPath = "/1/dictionaries/{dictionaryName}/search".replace(
2093
1941
  "{dictionaryName}",
2094
1942
  encodeURIComponent(dictionaryName)
@@ -2118,12 +1966,8 @@ function createSearchClient({
2118
1966
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2119
1967
  */
2120
1968
  searchForFacetValues({ indexName, facetName, searchForFacetValuesRequest }, requestOptions) {
2121
- if (!indexName) {
2122
- throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");
2123
- }
2124
- if (!facetName) {
2125
- throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");
2126
- }
1969
+ validateRequired("indexName", "searchForFacetValues", indexName);
1970
+ validateRequired("facetName", "searchForFacetValues", facetName);
2127
1971
  const requestPath = "/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}", encodeURIComponent(indexName)).replace("{facetName}", encodeURIComponent(facetName));
2128
1972
  const headers = {};
2129
1973
  const queryParameters = {};
@@ -2149,9 +1993,7 @@ function createSearchClient({
2149
1993
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2150
1994
  */
2151
1995
  searchRules({ indexName, searchRulesParams }, requestOptions) {
2152
- if (!indexName) {
2153
- throw new Error("Parameter `indexName` is required when calling `searchRules`.");
2154
- }
1996
+ validateRequired("indexName", "searchRules", indexName);
2155
1997
  const requestPath = "/1/indexes/{indexName}/rules/search".replace("{indexName}", encodeURIComponent(indexName));
2156
1998
  const headers = {};
2157
1999
  const queryParameters = {};
@@ -2177,9 +2019,7 @@ function createSearchClient({
2177
2019
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2178
2020
  */
2179
2021
  searchSingleIndex({ indexName, searchParams }, requestOptions) {
2180
- if (!indexName) {
2181
- throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");
2182
- }
2022
+ validateRequired("indexName", "searchSingleIndex", indexName);
2183
2023
  const requestPath = "/1/indexes/{indexName}/query".replace("{indexName}", encodeURIComponent(indexName));
2184
2024
  const headers = {};
2185
2025
  const queryParameters = {};
@@ -2205,9 +2045,7 @@ function createSearchClient({
2205
2045
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2206
2046
  */
2207
2047
  searchSynonyms({ indexName, searchSynonymsParams }, requestOptions) {
2208
- if (!indexName) {
2209
- throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");
2210
- }
2048
+ validateRequired("indexName", "searchSynonyms", indexName);
2211
2049
  const requestPath = "/1/indexes/{indexName}/synonyms/search".replace(
2212
2050
  "{indexName}",
2213
2051
  encodeURIComponent(indexName)
@@ -2236,12 +2074,8 @@ function createSearchClient({
2236
2074
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2237
2075
  */
2238
2076
  searchUserIds(searchUserIdsParams, requestOptions) {
2239
- if (!searchUserIdsParams) {
2240
- throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");
2241
- }
2242
- if (!searchUserIdsParams.query) {
2243
- throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");
2244
- }
2077
+ validateRequired("searchUserIdsParams", "searchUserIds", searchUserIdsParams);
2078
+ validateRequired("searchUserIdsParams.query", "searchUserIds", searchUserIdsParams.query);
2245
2079
  const requestPath = "/1/clusters/mapping/search";
2246
2080
  const headers = {};
2247
2081
  const queryParameters = {};
@@ -2265,14 +2099,12 @@ function createSearchClient({
2265
2099
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2266
2100
  */
2267
2101
  setDictionarySettings(dictionarySettingsParams, requestOptions) {
2268
- if (!dictionarySettingsParams) {
2269
- throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");
2270
- }
2271
- if (!dictionarySettingsParams.disableStandardEntries) {
2272
- throw new Error(
2273
- "Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`."
2274
- );
2275
- }
2102
+ validateRequired("dictionarySettingsParams", "setDictionarySettings", dictionarySettingsParams);
2103
+ validateRequired(
2104
+ "dictionarySettingsParams.disableStandardEntries",
2105
+ "setDictionarySettings",
2106
+ dictionarySettingsParams.disableStandardEntries
2107
+ );
2276
2108
  const requestPath = "/1/dictionaries/*/settings";
2277
2109
  const headers = {};
2278
2110
  const queryParameters = {};
@@ -2297,12 +2129,8 @@ function createSearchClient({
2297
2129
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2298
2130
  */
2299
2131
  setSettings({ indexName, indexSettings, forwardToReplicas }, requestOptions) {
2300
- if (!indexName) {
2301
- throw new Error("Parameter `indexName` is required when calling `setSettings`.");
2302
- }
2303
- if (!indexSettings) {
2304
- throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");
2305
- }
2132
+ validateRequired("indexName", "setSettings", indexName);
2133
+ validateRequired("indexSettings", "setSettings", indexSettings);
2306
2134
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
2307
2135
  const headers = {};
2308
2136
  const queryParameters = {};
@@ -2329,15 +2157,9 @@ function createSearchClient({
2329
2157
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2330
2158
  */
2331
2159
  updateApiKey({ key, apiKey }, requestOptions) {
2332
- if (!key) {
2333
- throw new Error("Parameter `key` is required when calling `updateApiKey`.");
2334
- }
2335
- if (!apiKey) {
2336
- throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");
2337
- }
2338
- if (!apiKey.acl) {
2339
- throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");
2340
- }
2160
+ validateRequired("key", "updateApiKey", key);
2161
+ validateRequired("apiKey", "updateApiKey", apiKey);
2162
+ validateRequired("apiKey.acl", "updateApiKey", apiKey.acl);
2341
2163
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
2342
2164
  const headers = {};
2343
2165
  const queryParameters = {};
@@ -2419,6 +2241,7 @@ function searchClient(appId, apiKey, options) {
2419
2241
  * @param accountCopyIndex.destinationApiKey - The API Key of the `destinationAppID` to write the index to, must have write ACLs.
2420
2242
  * @param accountCopyIndex.destinationIndexName - The name of the index to write the copied index to.
2421
2243
  * @param accountCopyIndex.batchSize - The size of the chunk of `objects`. Defaults to 1000.
2244
+ * @param accountCopyIndex.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
2422
2245
  * @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.
2423
2246
  */
2424
2247
  async accountCopyIndex({
@@ -2426,7 +2249,8 @@ function searchClient(appId, apiKey, options) {
2426
2249
  destinationAppID,
2427
2250
  destinationApiKey,
2428
2251
  destinationIndexName,
2429
- batchSize
2252
+ batchSize,
2253
+ maxRetries = 100
2430
2254
  }, requestOptions) {
2431
2255
  const responses = [];
2432
2256
  if (this.appId === destinationAppID) {
@@ -2498,7 +2322,7 @@ function searchClient(appId, apiKey, options) {
2498
2322
  }
2499
2323
  });
2500
2324
  for (const response of responses) {
2501
- await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID });
2325
+ await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID, maxRetries });
2502
2326
  }
2503
2327
  },
2504
2328
  /**