@algolia/client-search 5.53.0 → 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.
@@ -9,9 +9,10 @@ import {
9
9
  createIterablePromise,
10
10
  createTransporter,
11
11
  getAlgoliaAgent,
12
- shuffle
12
+ shuffle,
13
+ validateRequired
13
14
  } from "@algolia/client-common";
14
- var apiClientVersion = "5.53.0";
15
+ var apiClientVersion = "5.54.0";
15
16
  function getDefaultHosts(appId) {
16
17
  return [
17
18
  {
@@ -558,12 +559,8 @@ function createSearchClient({
558
559
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
559
560
  */
560
561
  addApiKey(apiKey, requestOptions) {
561
- if (!apiKey) {
562
- throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");
563
- }
564
- if (!apiKey.acl) {
565
- throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");
566
- }
562
+ validateRequired("apiKey", "addApiKey", apiKey);
563
+ validateRequired("apiKey.acl", "addApiKey", apiKey.acl);
567
564
  const requestPath = "/1/keys";
568
565
  const headers = {};
569
566
  const queryParameters = {};
@@ -588,15 +585,9 @@ function createSearchClient({
588
585
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
589
586
  */
590
587
  addOrUpdateObject({ indexName, objectID, body }, requestOptions) {
591
- if (!indexName) {
592
- throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");
593
- }
594
- if (!objectID) {
595
- throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");
596
- }
597
- if (!body) {
598
- throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");
599
- }
588
+ validateRequired("indexName", "addOrUpdateObject", indexName);
589
+ validateRequired("objectID", "addOrUpdateObject", objectID);
590
+ validateRequired("body", "addOrUpdateObject", body);
600
591
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
601
592
  const headers = {};
602
593
  const queryParameters = {};
@@ -618,12 +609,8 @@ function createSearchClient({
618
609
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
619
610
  */
620
611
  appendSource(source, requestOptions) {
621
- if (!source) {
622
- throw new Error("Parameter `source` is required when calling `appendSource`.");
623
- }
624
- if (!source.source) {
625
- throw new Error("Parameter `source.source` is required when calling `appendSource`.");
626
- }
612
+ validateRequired("source", "appendSource", source);
613
+ validateRequired("source.source", "appendSource", source.source);
627
614
  const requestPath = "/1/security/sources/append";
628
615
  const headers = {};
629
616
  const queryParameters = {};
@@ -649,15 +636,9 @@ function createSearchClient({
649
636
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
650
637
  */
651
638
  assignUserId({ xAlgoliaUserID, assignUserIdParams }, requestOptions) {
652
- if (!xAlgoliaUserID) {
653
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");
654
- }
655
- if (!assignUserIdParams) {
656
- throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");
657
- }
658
- if (!assignUserIdParams.cluster) {
659
- throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");
660
- }
639
+ validateRequired("xAlgoliaUserID", "assignUserId", xAlgoliaUserID);
640
+ validateRequired("assignUserIdParams", "assignUserId", assignUserIdParams);
641
+ validateRequired("assignUserIdParams.cluster", "assignUserId", assignUserIdParams.cluster);
661
642
  const requestPath = "/1/clusters/mapping";
662
643
  const headers = {};
663
644
  const queryParameters = {};
@@ -684,15 +665,9 @@ function createSearchClient({
684
665
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
685
666
  */
686
667
  batch({ indexName, batchWriteParams }, requestOptions) {
687
- if (!indexName) {
688
- throw new Error("Parameter `indexName` is required when calling `batch`.");
689
- }
690
- if (!batchWriteParams) {
691
- throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");
692
- }
693
- if (!batchWriteParams.requests) {
694
- throw new Error("Parameter `batchWriteParams.requests` is required when calling `batch`.");
695
- }
668
+ validateRequired("indexName", "batch", indexName);
669
+ validateRequired("batchWriteParams", "batch", batchWriteParams);
670
+ validateRequired("batchWriteParams.requests", "batch", batchWriteParams.requests);
696
671
  const requestPath = "/1/indexes/{indexName}/batch".replace("{indexName}", encodeURIComponent(indexName));
697
672
  const headers = {};
698
673
  const queryParameters = {};
@@ -718,18 +693,10 @@ function createSearchClient({
718
693
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
719
694
  */
720
695
  batchAssignUserIds({ xAlgoliaUserID, batchAssignUserIdsParams }, requestOptions) {
721
- if (!xAlgoliaUserID) {
722
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");
723
- }
724
- if (!batchAssignUserIdsParams) {
725
- throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");
726
- }
727
- if (!batchAssignUserIdsParams.cluster) {
728
- throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");
729
- }
730
- if (!batchAssignUserIdsParams.users) {
731
- throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");
732
- }
696
+ validateRequired("xAlgoliaUserID", "batchAssignUserIds", xAlgoliaUserID);
697
+ validateRequired("batchAssignUserIdsParams", "batchAssignUserIds", batchAssignUserIdsParams);
698
+ validateRequired("batchAssignUserIdsParams.cluster", "batchAssignUserIds", batchAssignUserIdsParams.cluster);
699
+ validateRequired("batchAssignUserIdsParams.users", "batchAssignUserIds", batchAssignUserIdsParams.users);
733
700
  const requestPath = "/1/clusters/mapping/batch";
734
701
  const headers = {};
735
702
  const queryParameters = {};
@@ -756,17 +723,13 @@ function createSearchClient({
756
723
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
757
724
  */
758
725
  batchDictionaryEntries({ dictionaryName, batchDictionaryEntriesParams }, requestOptions) {
759
- if (!dictionaryName) {
760
- throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");
761
- }
762
- if (!batchDictionaryEntriesParams) {
763
- throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");
764
- }
765
- if (!batchDictionaryEntriesParams.requests) {
766
- throw new Error(
767
- "Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`."
768
- );
769
- }
726
+ validateRequired("dictionaryName", "batchDictionaryEntries", dictionaryName);
727
+ validateRequired("batchDictionaryEntriesParams", "batchDictionaryEntries", batchDictionaryEntriesParams);
728
+ validateRequired(
729
+ "batchDictionaryEntriesParams.requests",
730
+ "batchDictionaryEntries",
731
+ batchDictionaryEntriesParams.requests
732
+ );
770
733
  const requestPath = "/1/dictionaries/{dictionaryName}/batch".replace(
771
734
  "{dictionaryName}",
772
735
  encodeURIComponent(dictionaryName)
@@ -793,9 +756,7 @@ function createSearchClient({
793
756
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
794
757
  */
795
758
  browse({ indexName, browseParams }, requestOptions) {
796
- if (!indexName) {
797
- throw new Error("Parameter `indexName` is required when calling `browse`.");
798
- }
759
+ validateRequired("indexName", "browse", indexName);
799
760
  const requestPath = "/1/indexes/{indexName}/browse".replace("{indexName}", encodeURIComponent(indexName));
800
761
  const headers = {};
801
762
  const queryParameters = {};
@@ -819,9 +780,7 @@ function createSearchClient({
819
780
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
820
781
  */
821
782
  clearObjects({ indexName }, requestOptions) {
822
- if (!indexName) {
823
- throw new Error("Parameter `indexName` is required when calling `clearObjects`.");
824
- }
783
+ validateRequired("indexName", "clearObjects", indexName);
825
784
  const requestPath = "/1/indexes/{indexName}/clear".replace("{indexName}", encodeURIComponent(indexName));
826
785
  const headers = {};
827
786
  const queryParameters = {};
@@ -844,9 +803,7 @@ function createSearchClient({
844
803
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
845
804
  */
846
805
  clearRules({ indexName, forwardToReplicas }, requestOptions) {
847
- if (!indexName) {
848
- throw new Error("Parameter `indexName` is required when calling `clearRules`.");
849
- }
806
+ validateRequired("indexName", "clearRules", indexName);
850
807
  const requestPath = "/1/indexes/{indexName}/rules/clear".replace("{indexName}", encodeURIComponent(indexName));
851
808
  const headers = {};
852
809
  const queryParameters = {};
@@ -872,9 +829,7 @@ function createSearchClient({
872
829
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
873
830
  */
874
831
  clearSynonyms({ indexName, forwardToReplicas }, requestOptions) {
875
- if (!indexName) {
876
- throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");
877
- }
832
+ validateRequired("indexName", "clearSynonyms", indexName);
878
833
  const requestPath = "/1/indexes/{indexName}/synonyms/clear".replace("{indexName}", encodeURIComponent(indexName));
879
834
  const headers = {};
880
835
  const queryParameters = {};
@@ -897,9 +852,7 @@ function createSearchClient({
897
852
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
898
853
  */
899
854
  customDelete({ path, parameters }, requestOptions) {
900
- if (!path) {
901
- throw new Error("Parameter `path` is required when calling `customDelete`.");
902
- }
855
+ validateRequired("path", "customDelete", path);
903
856
  const requestPath = "/{path}".replace("{path}", path);
904
857
  const headers = {};
905
858
  const queryParameters = parameters ? parameters : {};
@@ -919,9 +872,7 @@ function createSearchClient({
919
872
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
920
873
  */
921
874
  customGet({ path, parameters }, requestOptions) {
922
- if (!path) {
923
- throw new Error("Parameter `path` is required when calling `customGet`.");
924
- }
875
+ validateRequired("path", "customGet", path);
925
876
  const requestPath = "/{path}".replace("{path}", path);
926
877
  const headers = {};
927
878
  const queryParameters = parameters ? parameters : {};
@@ -942,9 +893,7 @@ function createSearchClient({
942
893
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
943
894
  */
944
895
  customPost({ path, parameters, body }, requestOptions) {
945
- if (!path) {
946
- throw new Error("Parameter `path` is required when calling `customPost`.");
947
- }
896
+ validateRequired("path", "customPost", path);
948
897
  const requestPath = "/{path}".replace("{path}", path);
949
898
  const headers = {};
950
899
  const queryParameters = parameters ? parameters : {};
@@ -966,9 +915,7 @@ function createSearchClient({
966
915
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
967
916
  */
968
917
  customPut({ path, parameters, body }, requestOptions) {
969
- if (!path) {
970
- throw new Error("Parameter `path` is required when calling `customPut`.");
971
- }
918
+ validateRequired("path", "customPut", path);
972
919
  const requestPath = "/{path}".replace("{path}", path);
973
920
  const headers = {};
974
921
  const queryParameters = parameters ? parameters : {};
@@ -991,9 +938,7 @@ function createSearchClient({
991
938
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
992
939
  */
993
940
  deleteApiKey({ key }, requestOptions) {
994
- if (!key) {
995
- throw new Error("Parameter `key` is required when calling `deleteApiKey`.");
996
- }
941
+ validateRequired("key", "deleteApiKey", key);
997
942
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
998
943
  const headers = {};
999
944
  const queryParameters = {};
@@ -1016,12 +961,8 @@ function createSearchClient({
1016
961
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1017
962
  */
1018
963
  deleteBy({ indexName, deleteByParams }, requestOptions) {
1019
- if (!indexName) {
1020
- throw new Error("Parameter `indexName` is required when calling `deleteBy`.");
1021
- }
1022
- if (!deleteByParams) {
1023
- throw new Error("Parameter `deleteByParams` is required when calling `deleteBy`.");
1024
- }
964
+ validateRequired("indexName", "deleteBy", indexName);
965
+ validateRequired("deleteByParams", "deleteBy", deleteByParams);
1025
966
  const requestPath = "/1/indexes/{indexName}/deleteByQuery".replace("{indexName}", encodeURIComponent(indexName));
1026
967
  const headers = {};
1027
968
  const queryParameters = {};
@@ -1044,9 +985,7 @@ function createSearchClient({
1044
985
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1045
986
  */
1046
987
  deleteIndex({ indexName }, requestOptions) {
1047
- if (!indexName) {
1048
- throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");
1049
- }
988
+ validateRequired("indexName", "deleteIndex", indexName);
1050
989
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1051
990
  const headers = {};
1052
991
  const queryParameters = {};
@@ -1069,12 +1008,8 @@ function createSearchClient({
1069
1008
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1070
1009
  */
1071
1010
  deleteObject({ indexName, objectID }, requestOptions) {
1072
- if (!indexName) {
1073
- throw new Error("Parameter `indexName` is required when calling `deleteObject`.");
1074
- }
1075
- if (!objectID) {
1076
- throw new Error("Parameter `objectID` is required when calling `deleteObject`.");
1077
- }
1011
+ validateRequired("indexName", "deleteObject", indexName);
1012
+ validateRequired("objectID", "deleteObject", objectID);
1078
1013
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1079
1014
  const headers = {};
1080
1015
  const queryParameters = {};
@@ -1098,12 +1033,8 @@ function createSearchClient({
1098
1033
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1099
1034
  */
1100
1035
  deleteRule({ indexName, objectID, forwardToReplicas }, requestOptions) {
1101
- if (!indexName) {
1102
- throw new Error("Parameter `indexName` is required when calling `deleteRule`.");
1103
- }
1104
- if (!objectID) {
1105
- throw new Error("Parameter `objectID` is required when calling `deleteRule`.");
1106
- }
1036
+ validateRequired("indexName", "deleteRule", indexName);
1037
+ validateRequired("objectID", "deleteRule", objectID);
1107
1038
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1108
1039
  const headers = {};
1109
1040
  const queryParameters = {};
@@ -1128,9 +1059,7 @@ function createSearchClient({
1128
1059
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1129
1060
  */
1130
1061
  deleteSource({ source }, requestOptions) {
1131
- if (!source) {
1132
- throw new Error("Parameter `source` is required when calling `deleteSource`.");
1133
- }
1062
+ validateRequired("source", "deleteSource", source);
1134
1063
  const requestPath = "/1/security/sources/{source}".replace("{source}", encodeURIComponent(source));
1135
1064
  const headers = {};
1136
1065
  const queryParameters = {};
@@ -1154,12 +1083,8 @@ function createSearchClient({
1154
1083
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1155
1084
  */
1156
1085
  deleteSynonym({ indexName, objectID, forwardToReplicas }, requestOptions) {
1157
- if (!indexName) {
1158
- throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");
1159
- }
1160
- if (!objectID) {
1161
- throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");
1162
- }
1086
+ validateRequired("indexName", "deleteSynonym", indexName);
1087
+ validateRequired("objectID", "deleteSynonym", objectID);
1163
1088
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1164
1089
  const headers = {};
1165
1090
  const queryParameters = {};
@@ -1184,9 +1109,7 @@ function createSearchClient({
1184
1109
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1185
1110
  */
1186
1111
  getApiKey({ key }, requestOptions) {
1187
- if (!key) {
1188
- throw new Error("Parameter `key` is required when calling `getApiKey`.");
1189
- }
1112
+ validateRequired("key", "getApiKey", key);
1190
1113
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1191
1114
  const headers = {};
1192
1115
  const queryParameters = {};
@@ -1208,9 +1131,7 @@ function createSearchClient({
1208
1131
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1209
1132
  */
1210
1133
  getAppTask({ taskID }, requestOptions) {
1211
- if (!taskID) {
1212
- throw new Error("Parameter `taskID` is required when calling `getAppTask`.");
1213
- }
1134
+ validateRequired("taskID", "getAppTask", taskID);
1214
1135
  const requestPath = "/1/task/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1215
1136
  const headers = {};
1216
1137
  const queryParameters = {};
@@ -1308,12 +1229,8 @@ function createSearchClient({
1308
1229
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1309
1230
  */
1310
1231
  getObject({ indexName, objectID, attributesToRetrieve }, requestOptions) {
1311
- if (!indexName) {
1312
- throw new Error("Parameter `indexName` is required when calling `getObject`.");
1313
- }
1314
- if (!objectID) {
1315
- throw new Error("Parameter `objectID` is required when calling `getObject`.");
1316
- }
1232
+ validateRequired("indexName", "getObject", indexName);
1233
+ validateRequired("objectID", "getObject", objectID);
1317
1234
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1318
1235
  const headers = {};
1319
1236
  const queryParameters = {};
@@ -1337,12 +1254,8 @@ function createSearchClient({
1337
1254
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1338
1255
  */
1339
1256
  getObjects(getObjectsParams, requestOptions) {
1340
- if (!getObjectsParams) {
1341
- throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");
1342
- }
1343
- if (!getObjectsParams.requests) {
1344
- throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");
1345
- }
1257
+ validateRequired("getObjectsParams", "getObjects", getObjectsParams);
1258
+ validateRequired("getObjectsParams.requests", "getObjects", getObjectsParams.requests);
1346
1259
  const requestPath = "/1/indexes/*/objects";
1347
1260
  const headers = {};
1348
1261
  const queryParameters = {};
@@ -1368,12 +1281,8 @@ function createSearchClient({
1368
1281
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1369
1282
  */
1370
1283
  getRule({ indexName, objectID }, requestOptions) {
1371
- if (!indexName) {
1372
- throw new Error("Parameter `indexName` is required when calling `getRule`.");
1373
- }
1374
- if (!objectID) {
1375
- throw new Error("Parameter `objectID` is required when calling `getRule`.");
1376
- }
1284
+ validateRequired("indexName", "getRule", indexName);
1285
+ validateRequired("objectID", "getRule", objectID);
1377
1286
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1378
1287
  const headers = {};
1379
1288
  const queryParameters = {};
@@ -1396,9 +1305,7 @@ function createSearchClient({
1396
1305
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1397
1306
  */
1398
1307
  getSettings({ indexName, getVersion }, requestOptions) {
1399
- if (!indexName) {
1400
- throw new Error("Parameter `indexName` is required when calling `getSettings`.");
1401
- }
1308
+ validateRequired("indexName", "getSettings", indexName);
1402
1309
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
1403
1310
  const headers = {};
1404
1311
  const queryParameters = {};
@@ -1443,12 +1350,8 @@ function createSearchClient({
1443
1350
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1444
1351
  */
1445
1352
  getSynonym({ indexName, objectID }, requestOptions) {
1446
- if (!indexName) {
1447
- throw new Error("Parameter `indexName` is required when calling `getSynonym`.");
1448
- }
1449
- if (!objectID) {
1450
- throw new Error("Parameter `objectID` is required when calling `getSynonym`.");
1451
- }
1353
+ validateRequired("indexName", "getSynonym", indexName);
1354
+ validateRequired("objectID", "getSynonym", objectID);
1452
1355
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1453
1356
  const headers = {};
1454
1357
  const queryParameters = {};
@@ -1471,12 +1374,8 @@ function createSearchClient({
1471
1374
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1472
1375
  */
1473
1376
  getTask({ indexName, taskID }, requestOptions) {
1474
- if (!indexName) {
1475
- throw new Error("Parameter `indexName` is required when calling `getTask`.");
1476
- }
1477
- if (!taskID) {
1478
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
1479
- }
1377
+ validateRequired("indexName", "getTask", indexName);
1378
+ validateRequired("taskID", "getTask", taskID);
1480
1379
  const requestPath = "/1/indexes/{indexName}/task/{taskID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{taskID}", encodeURIComponent(taskID));
1481
1380
  const headers = {};
1482
1381
  const queryParameters = {};
@@ -1521,9 +1420,7 @@ function createSearchClient({
1521
1420
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1522
1421
  */
1523
1422
  getUserId({ userID }, requestOptions) {
1524
- if (!userID) {
1525
- throw new Error("Parameter `userID` is required when calling `getUserId`.");
1526
- }
1423
+ validateRequired("userID", "getUserId", userID);
1527
1424
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1528
1425
  const headers = {};
1529
1426
  const queryParameters = {};
@@ -1668,12 +1565,8 @@ function createSearchClient({
1668
1565
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1669
1566
  */
1670
1567
  multipleBatch(batchParams, requestOptions) {
1671
- if (!batchParams) {
1672
- throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");
1673
- }
1674
- if (!batchParams.requests) {
1675
- throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");
1676
- }
1568
+ validateRequired("batchParams", "multipleBatch", batchParams);
1569
+ validateRequired("batchParams.requests", "multipleBatch", batchParams.requests);
1677
1570
  const requestPath = "/1/indexes/*/batch";
1678
1571
  const headers = {};
1679
1572
  const queryParameters = {};
@@ -1697,18 +1590,10 @@ function createSearchClient({
1697
1590
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1698
1591
  */
1699
1592
  operationIndex({ indexName, operationIndexParams }, requestOptions) {
1700
- if (!indexName) {
1701
- throw new Error("Parameter `indexName` is required when calling `operationIndex`.");
1702
- }
1703
- if (!operationIndexParams) {
1704
- throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");
1705
- }
1706
- if (!operationIndexParams.operation) {
1707
- throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");
1708
- }
1709
- if (!operationIndexParams.destination) {
1710
- throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");
1711
- }
1593
+ validateRequired("indexName", "operationIndex", indexName);
1594
+ validateRequired("operationIndexParams", "operationIndex", operationIndexParams);
1595
+ validateRequired("operationIndexParams.operation", "operationIndex", operationIndexParams.operation);
1596
+ validateRequired("operationIndexParams.destination", "operationIndex", operationIndexParams.destination);
1712
1597
  const requestPath = "/1/indexes/{indexName}/operation".replace("{indexName}", encodeURIComponent(indexName));
1713
1598
  const headers = {};
1714
1599
  const queryParameters = {};
@@ -1734,15 +1619,9 @@ function createSearchClient({
1734
1619
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1735
1620
  */
1736
1621
  partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists }, requestOptions) {
1737
- if (!indexName) {
1738
- throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");
1739
- }
1740
- if (!objectID) {
1741
- throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");
1742
- }
1743
- if (!attributesToUpdate) {
1744
- throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");
1745
- }
1622
+ validateRequired("indexName", "partialUpdateObject", indexName);
1623
+ validateRequired("objectID", "partialUpdateObject", objectID);
1624
+ validateRequired("attributesToUpdate", "partialUpdateObject", attributesToUpdate);
1746
1625
  const requestPath = "/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1747
1626
  const headers = {};
1748
1627
  const queryParameters = {};
@@ -1770,9 +1649,7 @@ function createSearchClient({
1770
1649
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1771
1650
  */
1772
1651
  removeUserId({ userID }, requestOptions) {
1773
- if (!userID) {
1774
- throw new Error("Parameter `userID` is required when calling `removeUserId`.");
1775
- }
1652
+ validateRequired("userID", "removeUserId", userID);
1776
1653
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1777
1654
  const headers = {};
1778
1655
  const queryParameters = {};
@@ -1794,9 +1671,7 @@ function createSearchClient({
1794
1671
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1795
1672
  */
1796
1673
  replaceSources({ source }, requestOptions) {
1797
- if (!source) {
1798
- throw new Error("Parameter `source` is required when calling `replaceSources`.");
1799
- }
1674
+ validateRequired("source", "replaceSources", source);
1800
1675
  const requestPath = "/1/security/sources";
1801
1676
  const headers = {};
1802
1677
  const queryParameters = {};
@@ -1819,9 +1694,7 @@ function createSearchClient({
1819
1694
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1820
1695
  */
1821
1696
  restoreApiKey({ key }, requestOptions) {
1822
- if (!key) {
1823
- throw new Error("Parameter `key` is required when calling `restoreApiKey`.");
1824
- }
1697
+ validateRequired("key", "restoreApiKey", key);
1825
1698
  const requestPath = "/1/keys/{key}/restore".replace("{key}", encodeURIComponent(key));
1826
1699
  const headers = {};
1827
1700
  const queryParameters = {};
@@ -1844,12 +1717,8 @@ function createSearchClient({
1844
1717
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1845
1718
  */
1846
1719
  saveObject({ indexName, body }, requestOptions) {
1847
- if (!indexName) {
1848
- throw new Error("Parameter `indexName` is required when calling `saveObject`.");
1849
- }
1850
- if (!body) {
1851
- throw new Error("Parameter `body` is required when calling `saveObject`.");
1852
- }
1720
+ validateRequired("indexName", "saveObject", indexName);
1721
+ validateRequired("body", "saveObject", body);
1853
1722
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1854
1723
  const headers = {};
1855
1724
  const queryParameters = {};
@@ -1875,21 +1744,11 @@ function createSearchClient({
1875
1744
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1876
1745
  */
1877
1746
  saveRule({ indexName, objectID, rule, forwardToReplicas }, requestOptions) {
1878
- if (!indexName) {
1879
- throw new Error("Parameter `indexName` is required when calling `saveRule`.");
1880
- }
1881
- if (!objectID) {
1882
- throw new Error("Parameter `objectID` is required when calling `saveRule`.");
1883
- }
1884
- if (!rule) {
1885
- throw new Error("Parameter `rule` is required when calling `saveRule`.");
1886
- }
1887
- if (!rule.objectID) {
1888
- throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
1889
- }
1890
- if (!rule.consequence) {
1891
- throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
1892
- }
1747
+ validateRequired("indexName", "saveRule", indexName);
1748
+ validateRequired("objectID", "saveRule", objectID);
1749
+ validateRequired("rule", "saveRule", rule);
1750
+ validateRequired("rule.objectID", "saveRule", rule.objectID);
1751
+ validateRequired("rule.consequence", "saveRule", rule.consequence);
1893
1752
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1894
1753
  const headers = {};
1895
1754
  const queryParameters = {};
@@ -1918,12 +1777,8 @@ function createSearchClient({
1918
1777
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1919
1778
  */
1920
1779
  saveRules({ indexName, rules, forwardToReplicas, clearExistingRules }, requestOptions) {
1921
- if (!indexName) {
1922
- throw new Error("Parameter `indexName` is required when calling `saveRules`.");
1923
- }
1924
- if (!rules) {
1925
- throw new Error("Parameter `rules` is required when calling `saveRules`.");
1926
- }
1780
+ validateRequired("indexName", "saveRules", indexName);
1781
+ validateRequired("rules", "saveRules", rules);
1927
1782
  const requestPath = "/1/indexes/{indexName}/rules/batch".replace("{indexName}", encodeURIComponent(indexName));
1928
1783
  const headers = {};
1929
1784
  const queryParameters = {};
@@ -1955,21 +1810,11 @@ function createSearchClient({
1955
1810
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1956
1811
  */
1957
1812
  saveSynonym({ indexName, objectID, synonymHit, forwardToReplicas }, requestOptions) {
1958
- if (!indexName) {
1959
- throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");
1960
- }
1961
- if (!objectID) {
1962
- throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");
1963
- }
1964
- if (!synonymHit) {
1965
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");
1966
- }
1967
- if (!synonymHit.objectID) {
1968
- throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");
1969
- }
1970
- if (!synonymHit.type) {
1971
- throw new Error("Parameter `synonymHit.type` is required when calling `saveSynonym`.");
1972
- }
1813
+ validateRequired("indexName", "saveSynonym", indexName);
1814
+ validateRequired("objectID", "saveSynonym", objectID);
1815
+ validateRequired("synonymHit", "saveSynonym", synonymHit);
1816
+ validateRequired("synonymHit.objectID", "saveSynonym", synonymHit.objectID);
1817
+ validateRequired("synonymHit.type", "saveSynonym", synonymHit.type);
1973
1818
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1974
1819
  const headers = {};
1975
1820
  const queryParameters = {};
@@ -1998,12 +1843,8 @@ function createSearchClient({
1998
1843
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1999
1844
  */
2000
1845
  saveSynonyms({ indexName, synonymHit, forwardToReplicas, replaceExistingSynonyms }, requestOptions) {
2001
- if (!indexName) {
2002
- throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");
2003
- }
2004
- if (!synonymHit) {
2005
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");
2006
- }
1846
+ validateRequired("indexName", "saveSynonyms", indexName);
1847
+ validateRequired("synonymHit", "saveSynonyms", synonymHit);
2007
1848
  const requestPath = "/1/indexes/{indexName}/synonyms/batch".replace("{indexName}", encodeURIComponent(indexName));
2008
1849
  const headers = {};
2009
1850
  const queryParameters = {};
@@ -2052,12 +1893,8 @@ function createSearchClient({
2052
1893
  };
2053
1894
  searchMethodParams = newSignatureRequest;
2054
1895
  }
2055
- if (!searchMethodParams) {
2056
- throw new Error("Parameter `searchMethodParams` is required when calling `search`.");
2057
- }
2058
- if (!searchMethodParams.requests) {
2059
- throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");
2060
- }
1896
+ validateRequired("searchMethodParams", "search", searchMethodParams);
1897
+ validateRequired("searchMethodParams.requests", "search", searchMethodParams.requests);
2061
1898
  const requestPath = "/1/indexes/*/queries";
2062
1899
  const headers = {};
2063
1900
  const queryParameters = {};
@@ -2083,19 +1920,13 @@ function createSearchClient({
2083
1920
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2084
1921
  */
2085
1922
  searchDictionaryEntries({ dictionaryName, searchDictionaryEntriesParams }, requestOptions) {
2086
- if (!dictionaryName) {
2087
- throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");
2088
- }
2089
- if (!searchDictionaryEntriesParams) {
2090
- throw new Error(
2091
- "Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`."
2092
- );
2093
- }
2094
- if (!searchDictionaryEntriesParams.query) {
2095
- throw new Error(
2096
- "Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`."
2097
- );
2098
- }
1923
+ validateRequired("dictionaryName", "searchDictionaryEntries", dictionaryName);
1924
+ validateRequired("searchDictionaryEntriesParams", "searchDictionaryEntries", searchDictionaryEntriesParams);
1925
+ validateRequired(
1926
+ "searchDictionaryEntriesParams.query",
1927
+ "searchDictionaryEntries",
1928
+ searchDictionaryEntriesParams.query
1929
+ );
2099
1930
  const requestPath = "/1/dictionaries/{dictionaryName}/search".replace(
2100
1931
  "{dictionaryName}",
2101
1932
  encodeURIComponent(dictionaryName)
@@ -2125,12 +1956,8 @@ function createSearchClient({
2125
1956
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2126
1957
  */
2127
1958
  searchForFacetValues({ indexName, facetName, searchForFacetValuesRequest }, requestOptions) {
2128
- if (!indexName) {
2129
- throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");
2130
- }
2131
- if (!facetName) {
2132
- throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");
2133
- }
1959
+ validateRequired("indexName", "searchForFacetValues", indexName);
1960
+ validateRequired("facetName", "searchForFacetValues", facetName);
2134
1961
  const requestPath = "/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}", encodeURIComponent(indexName)).replace("{facetName}", encodeURIComponent(facetName));
2135
1962
  const headers = {};
2136
1963
  const queryParameters = {};
@@ -2156,9 +1983,7 @@ function createSearchClient({
2156
1983
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2157
1984
  */
2158
1985
  searchRules({ indexName, searchRulesParams }, requestOptions) {
2159
- if (!indexName) {
2160
- throw new Error("Parameter `indexName` is required when calling `searchRules`.");
2161
- }
1986
+ validateRequired("indexName", "searchRules", indexName);
2162
1987
  const requestPath = "/1/indexes/{indexName}/rules/search".replace("{indexName}", encodeURIComponent(indexName));
2163
1988
  const headers = {};
2164
1989
  const queryParameters = {};
@@ -2184,9 +2009,7 @@ function createSearchClient({
2184
2009
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2185
2010
  */
2186
2011
  searchSingleIndex({ indexName, searchParams }, requestOptions) {
2187
- if (!indexName) {
2188
- throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");
2189
- }
2012
+ validateRequired("indexName", "searchSingleIndex", indexName);
2190
2013
  const requestPath = "/1/indexes/{indexName}/query".replace("{indexName}", encodeURIComponent(indexName));
2191
2014
  const headers = {};
2192
2015
  const queryParameters = {};
@@ -2212,9 +2035,7 @@ function createSearchClient({
2212
2035
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2213
2036
  */
2214
2037
  searchSynonyms({ indexName, searchSynonymsParams }, requestOptions) {
2215
- if (!indexName) {
2216
- throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");
2217
- }
2038
+ validateRequired("indexName", "searchSynonyms", indexName);
2218
2039
  const requestPath = "/1/indexes/{indexName}/synonyms/search".replace(
2219
2040
  "{indexName}",
2220
2041
  encodeURIComponent(indexName)
@@ -2243,12 +2064,8 @@ function createSearchClient({
2243
2064
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2244
2065
  */
2245
2066
  searchUserIds(searchUserIdsParams, requestOptions) {
2246
- if (!searchUserIdsParams) {
2247
- throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");
2248
- }
2249
- if (!searchUserIdsParams.query) {
2250
- throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");
2251
- }
2067
+ validateRequired("searchUserIdsParams", "searchUserIds", searchUserIdsParams);
2068
+ validateRequired("searchUserIdsParams.query", "searchUserIds", searchUserIdsParams.query);
2252
2069
  const requestPath = "/1/clusters/mapping/search";
2253
2070
  const headers = {};
2254
2071
  const queryParameters = {};
@@ -2272,14 +2089,12 @@ function createSearchClient({
2272
2089
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2273
2090
  */
2274
2091
  setDictionarySettings(dictionarySettingsParams, requestOptions) {
2275
- if (!dictionarySettingsParams) {
2276
- throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");
2277
- }
2278
- if (!dictionarySettingsParams.disableStandardEntries) {
2279
- throw new Error(
2280
- "Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`."
2281
- );
2282
- }
2092
+ validateRequired("dictionarySettingsParams", "setDictionarySettings", dictionarySettingsParams);
2093
+ validateRequired(
2094
+ "dictionarySettingsParams.disableStandardEntries",
2095
+ "setDictionarySettings",
2096
+ dictionarySettingsParams.disableStandardEntries
2097
+ );
2283
2098
  const requestPath = "/1/dictionaries/*/settings";
2284
2099
  const headers = {};
2285
2100
  const queryParameters = {};
@@ -2304,12 +2119,8 @@ function createSearchClient({
2304
2119
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2305
2120
  */
2306
2121
  setSettings({ indexName, indexSettings, forwardToReplicas }, requestOptions) {
2307
- if (!indexName) {
2308
- throw new Error("Parameter `indexName` is required when calling `setSettings`.");
2309
- }
2310
- if (!indexSettings) {
2311
- throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");
2312
- }
2122
+ validateRequired("indexName", "setSettings", indexName);
2123
+ validateRequired("indexSettings", "setSettings", indexSettings);
2313
2124
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
2314
2125
  const headers = {};
2315
2126
  const queryParameters = {};
@@ -2336,15 +2147,9 @@ function createSearchClient({
2336
2147
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2337
2148
  */
2338
2149
  updateApiKey({ key, apiKey }, requestOptions) {
2339
- if (!key) {
2340
- throw new Error("Parameter `key` is required when calling `updateApiKey`.");
2341
- }
2342
- if (!apiKey) {
2343
- throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");
2344
- }
2345
- if (!apiKey.acl) {
2346
- throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");
2347
- }
2150
+ validateRequired("key", "updateApiKey", key);
2151
+ validateRequired("apiKey", "updateApiKey", apiKey);
2152
+ validateRequired("apiKey.acl", "updateApiKey", apiKey.acl);
2348
2153
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
2349
2154
  const headers = {};
2350
2155
  const queryParameters = {};