@algolia/client-search 5.53.0 → 5.54.1

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.53.0";
25
+ var apiClientVersion = "5.54.1";
25
26
  function getDefaultHosts(appId) {
26
27
  return [
27
28
  {
@@ -568,12 +569,8 @@ function createSearchClient({
568
569
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
569
570
  */
570
571
  addApiKey(apiKey, requestOptions) {
571
- if (!apiKey) {
572
- throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");
573
- }
574
- if (!apiKey.acl) {
575
- throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");
576
- }
572
+ validateRequired("apiKey", "addApiKey", apiKey);
573
+ validateRequired("apiKey.acl", "addApiKey", apiKey.acl);
577
574
  const requestPath = "/1/keys";
578
575
  const headers = {};
579
576
  const queryParameters = {};
@@ -598,15 +595,9 @@ function createSearchClient({
598
595
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
599
596
  */
600
597
  addOrUpdateObject({ indexName, objectID, body }, requestOptions) {
601
- if (!indexName) {
602
- throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");
603
- }
604
- if (!objectID) {
605
- throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");
606
- }
607
- if (!body) {
608
- throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");
609
- }
598
+ validateRequired("indexName", "addOrUpdateObject", indexName);
599
+ validateRequired("objectID", "addOrUpdateObject", objectID);
600
+ validateRequired("body", "addOrUpdateObject", body);
610
601
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
611
602
  const headers = {};
612
603
  const queryParameters = {};
@@ -628,12 +619,8 @@ function createSearchClient({
628
619
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
629
620
  */
630
621
  appendSource(source, requestOptions) {
631
- if (!source) {
632
- throw new Error("Parameter `source` is required when calling `appendSource`.");
633
- }
634
- if (!source.source) {
635
- throw new Error("Parameter `source.source` is required when calling `appendSource`.");
636
- }
622
+ validateRequired("source", "appendSource", source);
623
+ validateRequired("source.source", "appendSource", source.source);
637
624
  const requestPath = "/1/security/sources/append";
638
625
  const headers = {};
639
626
  const queryParameters = {};
@@ -659,15 +646,9 @@ function createSearchClient({
659
646
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
660
647
  */
661
648
  assignUserId({ xAlgoliaUserID, assignUserIdParams }, requestOptions) {
662
- if (!xAlgoliaUserID) {
663
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");
664
- }
665
- if (!assignUserIdParams) {
666
- throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");
667
- }
668
- if (!assignUserIdParams.cluster) {
669
- throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");
670
- }
649
+ validateRequired("xAlgoliaUserID", "assignUserId", xAlgoliaUserID);
650
+ validateRequired("assignUserIdParams", "assignUserId", assignUserIdParams);
651
+ validateRequired("assignUserIdParams.cluster", "assignUserId", assignUserIdParams.cluster);
671
652
  const requestPath = "/1/clusters/mapping";
672
653
  const headers = {};
673
654
  const queryParameters = {};
@@ -694,15 +675,9 @@ function createSearchClient({
694
675
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
695
676
  */
696
677
  batch({ indexName, batchWriteParams }, requestOptions) {
697
- if (!indexName) {
698
- throw new Error("Parameter `indexName` is required when calling `batch`.");
699
- }
700
- if (!batchWriteParams) {
701
- throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");
702
- }
703
- if (!batchWriteParams.requests) {
704
- throw new Error("Parameter `batchWriteParams.requests` is required when calling `batch`.");
705
- }
678
+ validateRequired("indexName", "batch", indexName);
679
+ validateRequired("batchWriteParams", "batch", batchWriteParams);
680
+ validateRequired("batchWriteParams.requests", "batch", batchWriteParams.requests);
706
681
  const requestPath = "/1/indexes/{indexName}/batch".replace("{indexName}", encodeURIComponent(indexName));
707
682
  const headers = {};
708
683
  const queryParameters = {};
@@ -728,18 +703,10 @@ function createSearchClient({
728
703
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
729
704
  */
730
705
  batchAssignUserIds({ xAlgoliaUserID, batchAssignUserIdsParams }, requestOptions) {
731
- if (!xAlgoliaUserID) {
732
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");
733
- }
734
- if (!batchAssignUserIdsParams) {
735
- throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");
736
- }
737
- if (!batchAssignUserIdsParams.cluster) {
738
- throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");
739
- }
740
- if (!batchAssignUserIdsParams.users) {
741
- throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");
742
- }
706
+ validateRequired("xAlgoliaUserID", "batchAssignUserIds", xAlgoliaUserID);
707
+ validateRequired("batchAssignUserIdsParams", "batchAssignUserIds", batchAssignUserIdsParams);
708
+ validateRequired("batchAssignUserIdsParams.cluster", "batchAssignUserIds", batchAssignUserIdsParams.cluster);
709
+ validateRequired("batchAssignUserIdsParams.users", "batchAssignUserIds", batchAssignUserIdsParams.users);
743
710
  const requestPath = "/1/clusters/mapping/batch";
744
711
  const headers = {};
745
712
  const queryParameters = {};
@@ -766,17 +733,13 @@ function createSearchClient({
766
733
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
767
734
  */
768
735
  batchDictionaryEntries({ dictionaryName, batchDictionaryEntriesParams }, requestOptions) {
769
- if (!dictionaryName) {
770
- throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");
771
- }
772
- if (!batchDictionaryEntriesParams) {
773
- throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");
774
- }
775
- if (!batchDictionaryEntriesParams.requests) {
776
- throw new Error(
777
- "Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`."
778
- );
779
- }
736
+ validateRequired("dictionaryName", "batchDictionaryEntries", dictionaryName);
737
+ validateRequired("batchDictionaryEntriesParams", "batchDictionaryEntries", batchDictionaryEntriesParams);
738
+ validateRequired(
739
+ "batchDictionaryEntriesParams.requests",
740
+ "batchDictionaryEntries",
741
+ batchDictionaryEntriesParams.requests
742
+ );
780
743
  const requestPath = "/1/dictionaries/{dictionaryName}/batch".replace(
781
744
  "{dictionaryName}",
782
745
  encodeURIComponent(dictionaryName)
@@ -803,9 +766,7 @@ function createSearchClient({
803
766
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
804
767
  */
805
768
  browse({ indexName, browseParams }, requestOptions) {
806
- if (!indexName) {
807
- throw new Error("Parameter `indexName` is required when calling `browse`.");
808
- }
769
+ validateRequired("indexName", "browse", indexName);
809
770
  const requestPath = "/1/indexes/{indexName}/browse".replace("{indexName}", encodeURIComponent(indexName));
810
771
  const headers = {};
811
772
  const queryParameters = {};
@@ -829,9 +790,7 @@ function createSearchClient({
829
790
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
830
791
  */
831
792
  clearObjects({ indexName }, requestOptions) {
832
- if (!indexName) {
833
- throw new Error("Parameter `indexName` is required when calling `clearObjects`.");
834
- }
793
+ validateRequired("indexName", "clearObjects", indexName);
835
794
  const requestPath = "/1/indexes/{indexName}/clear".replace("{indexName}", encodeURIComponent(indexName));
836
795
  const headers = {};
837
796
  const queryParameters = {};
@@ -854,9 +813,7 @@ function createSearchClient({
854
813
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
855
814
  */
856
815
  clearRules({ indexName, forwardToReplicas }, requestOptions) {
857
- if (!indexName) {
858
- throw new Error("Parameter `indexName` is required when calling `clearRules`.");
859
- }
816
+ validateRequired("indexName", "clearRules", indexName);
860
817
  const requestPath = "/1/indexes/{indexName}/rules/clear".replace("{indexName}", encodeURIComponent(indexName));
861
818
  const headers = {};
862
819
  const queryParameters = {};
@@ -882,9 +839,7 @@ function createSearchClient({
882
839
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
883
840
  */
884
841
  clearSynonyms({ indexName, forwardToReplicas }, requestOptions) {
885
- if (!indexName) {
886
- throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");
887
- }
842
+ validateRequired("indexName", "clearSynonyms", indexName);
888
843
  const requestPath = "/1/indexes/{indexName}/synonyms/clear".replace("{indexName}", encodeURIComponent(indexName));
889
844
  const headers = {};
890
845
  const queryParameters = {};
@@ -907,9 +862,7 @@ function createSearchClient({
907
862
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
908
863
  */
909
864
  customDelete({ path, parameters }, requestOptions) {
910
- if (!path) {
911
- throw new Error("Parameter `path` is required when calling `customDelete`.");
912
- }
865
+ validateRequired("path", "customDelete", path);
913
866
  const requestPath = "/{path}".replace("{path}", path);
914
867
  const headers = {};
915
868
  const queryParameters = parameters ? parameters : {};
@@ -929,9 +882,7 @@ function createSearchClient({
929
882
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
930
883
  */
931
884
  customGet({ path, parameters }, requestOptions) {
932
- if (!path) {
933
- throw new Error("Parameter `path` is required when calling `customGet`.");
934
- }
885
+ validateRequired("path", "customGet", path);
935
886
  const requestPath = "/{path}".replace("{path}", path);
936
887
  const headers = {};
937
888
  const queryParameters = parameters ? parameters : {};
@@ -952,9 +903,7 @@ function createSearchClient({
952
903
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
953
904
  */
954
905
  customPost({ path, parameters, body }, requestOptions) {
955
- if (!path) {
956
- throw new Error("Parameter `path` is required when calling `customPost`.");
957
- }
906
+ validateRequired("path", "customPost", path);
958
907
  const requestPath = "/{path}".replace("{path}", path);
959
908
  const headers = {};
960
909
  const queryParameters = parameters ? parameters : {};
@@ -976,9 +925,7 @@ function createSearchClient({
976
925
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
977
926
  */
978
927
  customPut({ path, parameters, body }, requestOptions) {
979
- if (!path) {
980
- throw new Error("Parameter `path` is required when calling `customPut`.");
981
- }
928
+ validateRequired("path", "customPut", path);
982
929
  const requestPath = "/{path}".replace("{path}", path);
983
930
  const headers = {};
984
931
  const queryParameters = parameters ? parameters : {};
@@ -1001,9 +948,7 @@ function createSearchClient({
1001
948
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1002
949
  */
1003
950
  deleteApiKey({ key }, requestOptions) {
1004
- if (!key) {
1005
- throw new Error("Parameter `key` is required when calling `deleteApiKey`.");
1006
- }
951
+ validateRequired("key", "deleteApiKey", key);
1007
952
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1008
953
  const headers = {};
1009
954
  const queryParameters = {};
@@ -1026,12 +971,8 @@ function createSearchClient({
1026
971
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1027
972
  */
1028
973
  deleteBy({ indexName, deleteByParams }, requestOptions) {
1029
- if (!indexName) {
1030
- throw new Error("Parameter `indexName` is required when calling `deleteBy`.");
1031
- }
1032
- if (!deleteByParams) {
1033
- throw new Error("Parameter `deleteByParams` is required when calling `deleteBy`.");
1034
- }
974
+ validateRequired("indexName", "deleteBy", indexName);
975
+ validateRequired("deleteByParams", "deleteBy", deleteByParams);
1035
976
  const requestPath = "/1/indexes/{indexName}/deleteByQuery".replace("{indexName}", encodeURIComponent(indexName));
1036
977
  const headers = {};
1037
978
  const queryParameters = {};
@@ -1054,9 +995,7 @@ function createSearchClient({
1054
995
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1055
996
  */
1056
997
  deleteIndex({ indexName }, requestOptions) {
1057
- if (!indexName) {
1058
- throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");
1059
- }
998
+ validateRequired("indexName", "deleteIndex", indexName);
1060
999
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1061
1000
  const headers = {};
1062
1001
  const queryParameters = {};
@@ -1079,12 +1018,8 @@ function createSearchClient({
1079
1018
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1080
1019
  */
1081
1020
  deleteObject({ indexName, objectID }, requestOptions) {
1082
- if (!indexName) {
1083
- throw new Error("Parameter `indexName` is required when calling `deleteObject`.");
1084
- }
1085
- if (!objectID) {
1086
- throw new Error("Parameter `objectID` is required when calling `deleteObject`.");
1087
- }
1021
+ validateRequired("indexName", "deleteObject", indexName);
1022
+ validateRequired("objectID", "deleteObject", objectID);
1088
1023
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1089
1024
  const headers = {};
1090
1025
  const queryParameters = {};
@@ -1108,12 +1043,8 @@ function createSearchClient({
1108
1043
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1109
1044
  */
1110
1045
  deleteRule({ indexName, objectID, forwardToReplicas }, requestOptions) {
1111
- if (!indexName) {
1112
- throw new Error("Parameter `indexName` is required when calling `deleteRule`.");
1113
- }
1114
- if (!objectID) {
1115
- throw new Error("Parameter `objectID` is required when calling `deleteRule`.");
1116
- }
1046
+ validateRequired("indexName", "deleteRule", indexName);
1047
+ validateRequired("objectID", "deleteRule", objectID);
1117
1048
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1118
1049
  const headers = {};
1119
1050
  const queryParameters = {};
@@ -1138,9 +1069,7 @@ function createSearchClient({
1138
1069
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1139
1070
  */
1140
1071
  deleteSource({ source }, requestOptions) {
1141
- if (!source) {
1142
- throw new Error("Parameter `source` is required when calling `deleteSource`.");
1143
- }
1072
+ validateRequired("source", "deleteSource", source);
1144
1073
  const requestPath = "/1/security/sources/{source}".replace("{source}", encodeURIComponent(source));
1145
1074
  const headers = {};
1146
1075
  const queryParameters = {};
@@ -1164,12 +1093,8 @@ function createSearchClient({
1164
1093
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1165
1094
  */
1166
1095
  deleteSynonym({ indexName, objectID, forwardToReplicas }, requestOptions) {
1167
- if (!indexName) {
1168
- throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");
1169
- }
1170
- if (!objectID) {
1171
- throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");
1172
- }
1096
+ validateRequired("indexName", "deleteSynonym", indexName);
1097
+ validateRequired("objectID", "deleteSynonym", objectID);
1173
1098
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1174
1099
  const headers = {};
1175
1100
  const queryParameters = {};
@@ -1194,9 +1119,7 @@ function createSearchClient({
1194
1119
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1195
1120
  */
1196
1121
  getApiKey({ key }, requestOptions) {
1197
- if (!key) {
1198
- throw new Error("Parameter `key` is required when calling `getApiKey`.");
1199
- }
1122
+ validateRequired("key", "getApiKey", key);
1200
1123
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1201
1124
  const headers = {};
1202
1125
  const queryParameters = {};
@@ -1218,9 +1141,7 @@ function createSearchClient({
1218
1141
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1219
1142
  */
1220
1143
  getAppTask({ taskID }, requestOptions) {
1221
- if (!taskID) {
1222
- throw new Error("Parameter `taskID` is required when calling `getAppTask`.");
1223
- }
1144
+ validateRequired("taskID", "getAppTask", taskID);
1224
1145
  const requestPath = "/1/task/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1225
1146
  const headers = {};
1226
1147
  const queryParameters = {};
@@ -1318,12 +1239,8 @@ function createSearchClient({
1318
1239
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1319
1240
  */
1320
1241
  getObject({ indexName, objectID, attributesToRetrieve }, requestOptions) {
1321
- if (!indexName) {
1322
- throw new Error("Parameter `indexName` is required when calling `getObject`.");
1323
- }
1324
- if (!objectID) {
1325
- throw new Error("Parameter `objectID` is required when calling `getObject`.");
1326
- }
1242
+ validateRequired("indexName", "getObject", indexName);
1243
+ validateRequired("objectID", "getObject", objectID);
1327
1244
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1328
1245
  const headers = {};
1329
1246
  const queryParameters = {};
@@ -1347,12 +1264,8 @@ function createSearchClient({
1347
1264
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1348
1265
  */
1349
1266
  getObjects(getObjectsParams, requestOptions) {
1350
- if (!getObjectsParams) {
1351
- throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");
1352
- }
1353
- if (!getObjectsParams.requests) {
1354
- throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");
1355
- }
1267
+ validateRequired("getObjectsParams", "getObjects", getObjectsParams);
1268
+ validateRequired("getObjectsParams.requests", "getObjects", getObjectsParams.requests);
1356
1269
  const requestPath = "/1/indexes/*/objects";
1357
1270
  const headers = {};
1358
1271
  const queryParameters = {};
@@ -1378,12 +1291,8 @@ function createSearchClient({
1378
1291
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1379
1292
  */
1380
1293
  getRule({ indexName, objectID }, requestOptions) {
1381
- if (!indexName) {
1382
- throw new Error("Parameter `indexName` is required when calling `getRule`.");
1383
- }
1384
- if (!objectID) {
1385
- throw new Error("Parameter `objectID` is required when calling `getRule`.");
1386
- }
1294
+ validateRequired("indexName", "getRule", indexName);
1295
+ validateRequired("objectID", "getRule", objectID);
1387
1296
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1388
1297
  const headers = {};
1389
1298
  const queryParameters = {};
@@ -1406,9 +1315,7 @@ function createSearchClient({
1406
1315
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1407
1316
  */
1408
1317
  getSettings({ indexName, getVersion }, requestOptions) {
1409
- if (!indexName) {
1410
- throw new Error("Parameter `indexName` is required when calling `getSettings`.");
1411
- }
1318
+ validateRequired("indexName", "getSettings", indexName);
1412
1319
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
1413
1320
  const headers = {};
1414
1321
  const queryParameters = {};
@@ -1453,12 +1360,8 @@ function createSearchClient({
1453
1360
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1454
1361
  */
1455
1362
  getSynonym({ indexName, objectID }, requestOptions) {
1456
- if (!indexName) {
1457
- throw new Error("Parameter `indexName` is required when calling `getSynonym`.");
1458
- }
1459
- if (!objectID) {
1460
- throw new Error("Parameter `objectID` is required when calling `getSynonym`.");
1461
- }
1363
+ validateRequired("indexName", "getSynonym", indexName);
1364
+ validateRequired("objectID", "getSynonym", objectID);
1462
1365
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1463
1366
  const headers = {};
1464
1367
  const queryParameters = {};
@@ -1481,12 +1384,8 @@ function createSearchClient({
1481
1384
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1482
1385
  */
1483
1386
  getTask({ indexName, taskID }, requestOptions) {
1484
- if (!indexName) {
1485
- throw new Error("Parameter `indexName` is required when calling `getTask`.");
1486
- }
1487
- if (!taskID) {
1488
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
1489
- }
1387
+ validateRequired("indexName", "getTask", indexName);
1388
+ validateRequired("taskID", "getTask", taskID);
1490
1389
  const requestPath = "/1/indexes/{indexName}/task/{taskID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{taskID}", encodeURIComponent(taskID));
1491
1390
  const headers = {};
1492
1391
  const queryParameters = {};
@@ -1531,9 +1430,7 @@ function createSearchClient({
1531
1430
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1532
1431
  */
1533
1432
  getUserId({ userID }, requestOptions) {
1534
- if (!userID) {
1535
- throw new Error("Parameter `userID` is required when calling `getUserId`.");
1536
- }
1433
+ validateRequired("userID", "getUserId", userID);
1537
1434
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1538
1435
  const headers = {};
1539
1436
  const queryParameters = {};
@@ -1678,12 +1575,8 @@ function createSearchClient({
1678
1575
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1679
1576
  */
1680
1577
  multipleBatch(batchParams, requestOptions) {
1681
- if (!batchParams) {
1682
- throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");
1683
- }
1684
- if (!batchParams.requests) {
1685
- throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");
1686
- }
1578
+ validateRequired("batchParams", "multipleBatch", batchParams);
1579
+ validateRequired("batchParams.requests", "multipleBatch", batchParams.requests);
1687
1580
  const requestPath = "/1/indexes/*/batch";
1688
1581
  const headers = {};
1689
1582
  const queryParameters = {};
@@ -1707,18 +1600,10 @@ function createSearchClient({
1707
1600
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1708
1601
  */
1709
1602
  operationIndex({ indexName, operationIndexParams }, requestOptions) {
1710
- if (!indexName) {
1711
- throw new Error("Parameter `indexName` is required when calling `operationIndex`.");
1712
- }
1713
- if (!operationIndexParams) {
1714
- throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");
1715
- }
1716
- if (!operationIndexParams.operation) {
1717
- throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");
1718
- }
1719
- if (!operationIndexParams.destination) {
1720
- throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");
1721
- }
1603
+ validateRequired("indexName", "operationIndex", indexName);
1604
+ validateRequired("operationIndexParams", "operationIndex", operationIndexParams);
1605
+ validateRequired("operationIndexParams.operation", "operationIndex", operationIndexParams.operation);
1606
+ validateRequired("operationIndexParams.destination", "operationIndex", operationIndexParams.destination);
1722
1607
  const requestPath = "/1/indexes/{indexName}/operation".replace("{indexName}", encodeURIComponent(indexName));
1723
1608
  const headers = {};
1724
1609
  const queryParameters = {};
@@ -1744,15 +1629,9 @@ function createSearchClient({
1744
1629
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1745
1630
  */
1746
1631
  partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists }, requestOptions) {
1747
- if (!indexName) {
1748
- throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");
1749
- }
1750
- if (!objectID) {
1751
- throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");
1752
- }
1753
- if (!attributesToUpdate) {
1754
- throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");
1755
- }
1632
+ validateRequired("indexName", "partialUpdateObject", indexName);
1633
+ validateRequired("objectID", "partialUpdateObject", objectID);
1634
+ validateRequired("attributesToUpdate", "partialUpdateObject", attributesToUpdate);
1756
1635
  const requestPath = "/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1757
1636
  const headers = {};
1758
1637
  const queryParameters = {};
@@ -1780,9 +1659,7 @@ function createSearchClient({
1780
1659
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1781
1660
  */
1782
1661
  removeUserId({ userID }, requestOptions) {
1783
- if (!userID) {
1784
- throw new Error("Parameter `userID` is required when calling `removeUserId`.");
1785
- }
1662
+ validateRequired("userID", "removeUserId", userID);
1786
1663
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1787
1664
  const headers = {};
1788
1665
  const queryParameters = {};
@@ -1804,9 +1681,7 @@ function createSearchClient({
1804
1681
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1805
1682
  */
1806
1683
  replaceSources({ source }, requestOptions) {
1807
- if (!source) {
1808
- throw new Error("Parameter `source` is required when calling `replaceSources`.");
1809
- }
1684
+ validateRequired("source", "replaceSources", source);
1810
1685
  const requestPath = "/1/security/sources";
1811
1686
  const headers = {};
1812
1687
  const queryParameters = {};
@@ -1829,9 +1704,7 @@ function createSearchClient({
1829
1704
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1830
1705
  */
1831
1706
  restoreApiKey({ key }, requestOptions) {
1832
- if (!key) {
1833
- throw new Error("Parameter `key` is required when calling `restoreApiKey`.");
1834
- }
1707
+ validateRequired("key", "restoreApiKey", key);
1835
1708
  const requestPath = "/1/keys/{key}/restore".replace("{key}", encodeURIComponent(key));
1836
1709
  const headers = {};
1837
1710
  const queryParameters = {};
@@ -1854,12 +1727,8 @@ function createSearchClient({
1854
1727
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1855
1728
  */
1856
1729
  saveObject({ indexName, body }, requestOptions) {
1857
- if (!indexName) {
1858
- throw new Error("Parameter `indexName` is required when calling `saveObject`.");
1859
- }
1860
- if (!body) {
1861
- throw new Error("Parameter `body` is required when calling `saveObject`.");
1862
- }
1730
+ validateRequired("indexName", "saveObject", indexName);
1731
+ validateRequired("body", "saveObject", body);
1863
1732
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1864
1733
  const headers = {};
1865
1734
  const queryParameters = {};
@@ -1885,21 +1754,11 @@ function createSearchClient({
1885
1754
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1886
1755
  */
1887
1756
  saveRule({ indexName, objectID, rule, forwardToReplicas }, requestOptions) {
1888
- if (!indexName) {
1889
- throw new Error("Parameter `indexName` is required when calling `saveRule`.");
1890
- }
1891
- if (!objectID) {
1892
- throw new Error("Parameter `objectID` is required when calling `saveRule`.");
1893
- }
1894
- if (!rule) {
1895
- throw new Error("Parameter `rule` is required when calling `saveRule`.");
1896
- }
1897
- if (!rule.objectID) {
1898
- throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
1899
- }
1900
- if (!rule.consequence) {
1901
- throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
1902
- }
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);
1903
1762
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1904
1763
  const headers = {};
1905
1764
  const queryParameters = {};
@@ -1928,12 +1787,8 @@ function createSearchClient({
1928
1787
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1929
1788
  */
1930
1789
  saveRules({ indexName, rules, forwardToReplicas, clearExistingRules }, requestOptions) {
1931
- if (!indexName) {
1932
- throw new Error("Parameter `indexName` is required when calling `saveRules`.");
1933
- }
1934
- if (!rules) {
1935
- throw new Error("Parameter `rules` is required when calling `saveRules`.");
1936
- }
1790
+ validateRequired("indexName", "saveRules", indexName);
1791
+ validateRequired("rules", "saveRules", rules);
1937
1792
  const requestPath = "/1/indexes/{indexName}/rules/batch".replace("{indexName}", encodeURIComponent(indexName));
1938
1793
  const headers = {};
1939
1794
  const queryParameters = {};
@@ -1965,21 +1820,11 @@ function createSearchClient({
1965
1820
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1966
1821
  */
1967
1822
  saveSynonym({ indexName, objectID, synonymHit, forwardToReplicas }, requestOptions) {
1968
- if (!indexName) {
1969
- throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");
1970
- }
1971
- if (!objectID) {
1972
- throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");
1973
- }
1974
- if (!synonymHit) {
1975
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");
1976
- }
1977
- if (!synonymHit.objectID) {
1978
- throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");
1979
- }
1980
- if (!synonymHit.type) {
1981
- throw new Error("Parameter `synonymHit.type` is required when calling `saveSynonym`.");
1982
- }
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);
1983
1828
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1984
1829
  const headers = {};
1985
1830
  const queryParameters = {};
@@ -2008,12 +1853,8 @@ function createSearchClient({
2008
1853
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2009
1854
  */
2010
1855
  saveSynonyms({ indexName, synonymHit, forwardToReplicas, replaceExistingSynonyms }, requestOptions) {
2011
- if (!indexName) {
2012
- throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");
2013
- }
2014
- if (!synonymHit) {
2015
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");
2016
- }
1856
+ validateRequired("indexName", "saveSynonyms", indexName);
1857
+ validateRequired("synonymHit", "saveSynonyms", synonymHit);
2017
1858
  const requestPath = "/1/indexes/{indexName}/synonyms/batch".replace("{indexName}", encodeURIComponent(indexName));
2018
1859
  const headers = {};
2019
1860
  const queryParameters = {};
@@ -2062,12 +1903,8 @@ function createSearchClient({
2062
1903
  };
2063
1904
  searchMethodParams = newSignatureRequest;
2064
1905
  }
2065
- if (!searchMethodParams) {
2066
- throw new Error("Parameter `searchMethodParams` is required when calling `search`.");
2067
- }
2068
- if (!searchMethodParams.requests) {
2069
- throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");
2070
- }
1906
+ validateRequired("searchMethodParams", "search", searchMethodParams);
1907
+ validateRequired("searchMethodParams.requests", "search", searchMethodParams.requests);
2071
1908
  const requestPath = "/1/indexes/*/queries";
2072
1909
  const headers = {};
2073
1910
  const queryParameters = {};
@@ -2093,19 +1930,13 @@ function createSearchClient({
2093
1930
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2094
1931
  */
2095
1932
  searchDictionaryEntries({ dictionaryName, searchDictionaryEntriesParams }, requestOptions) {
2096
- if (!dictionaryName) {
2097
- throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");
2098
- }
2099
- if (!searchDictionaryEntriesParams) {
2100
- throw new Error(
2101
- "Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`."
2102
- );
2103
- }
2104
- if (!searchDictionaryEntriesParams.query) {
2105
- throw new Error(
2106
- "Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`."
2107
- );
2108
- }
1933
+ validateRequired("dictionaryName", "searchDictionaryEntries", dictionaryName);
1934
+ validateRequired("searchDictionaryEntriesParams", "searchDictionaryEntries", searchDictionaryEntriesParams);
1935
+ validateRequired(
1936
+ "searchDictionaryEntriesParams.query",
1937
+ "searchDictionaryEntries",
1938
+ searchDictionaryEntriesParams.query
1939
+ );
2109
1940
  const requestPath = "/1/dictionaries/{dictionaryName}/search".replace(
2110
1941
  "{dictionaryName}",
2111
1942
  encodeURIComponent(dictionaryName)
@@ -2135,12 +1966,8 @@ function createSearchClient({
2135
1966
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2136
1967
  */
2137
1968
  searchForFacetValues({ indexName, facetName, searchForFacetValuesRequest }, requestOptions) {
2138
- if (!indexName) {
2139
- throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");
2140
- }
2141
- if (!facetName) {
2142
- throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");
2143
- }
1969
+ validateRequired("indexName", "searchForFacetValues", indexName);
1970
+ validateRequired("facetName", "searchForFacetValues", facetName);
2144
1971
  const requestPath = "/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}", encodeURIComponent(indexName)).replace("{facetName}", encodeURIComponent(facetName));
2145
1972
  const headers = {};
2146
1973
  const queryParameters = {};
@@ -2166,9 +1993,7 @@ function createSearchClient({
2166
1993
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2167
1994
  */
2168
1995
  searchRules({ indexName, searchRulesParams }, requestOptions) {
2169
- if (!indexName) {
2170
- throw new Error("Parameter `indexName` is required when calling `searchRules`.");
2171
- }
1996
+ validateRequired("indexName", "searchRules", indexName);
2172
1997
  const requestPath = "/1/indexes/{indexName}/rules/search".replace("{indexName}", encodeURIComponent(indexName));
2173
1998
  const headers = {};
2174
1999
  const queryParameters = {};
@@ -2194,9 +2019,7 @@ function createSearchClient({
2194
2019
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2195
2020
  */
2196
2021
  searchSingleIndex({ indexName, searchParams }, requestOptions) {
2197
- if (!indexName) {
2198
- throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");
2199
- }
2022
+ validateRequired("indexName", "searchSingleIndex", indexName);
2200
2023
  const requestPath = "/1/indexes/{indexName}/query".replace("{indexName}", encodeURIComponent(indexName));
2201
2024
  const headers = {};
2202
2025
  const queryParameters = {};
@@ -2222,9 +2045,7 @@ function createSearchClient({
2222
2045
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2223
2046
  */
2224
2047
  searchSynonyms({ indexName, searchSynonymsParams }, requestOptions) {
2225
- if (!indexName) {
2226
- throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");
2227
- }
2048
+ validateRequired("indexName", "searchSynonyms", indexName);
2228
2049
  const requestPath = "/1/indexes/{indexName}/synonyms/search".replace(
2229
2050
  "{indexName}",
2230
2051
  encodeURIComponent(indexName)
@@ -2253,12 +2074,8 @@ function createSearchClient({
2253
2074
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2254
2075
  */
2255
2076
  searchUserIds(searchUserIdsParams, requestOptions) {
2256
- if (!searchUserIdsParams) {
2257
- throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");
2258
- }
2259
- if (!searchUserIdsParams.query) {
2260
- throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");
2261
- }
2077
+ validateRequired("searchUserIdsParams", "searchUserIds", searchUserIdsParams);
2078
+ validateRequired("searchUserIdsParams.query", "searchUserIds", searchUserIdsParams.query);
2262
2079
  const requestPath = "/1/clusters/mapping/search";
2263
2080
  const headers = {};
2264
2081
  const queryParameters = {};
@@ -2282,14 +2099,12 @@ function createSearchClient({
2282
2099
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2283
2100
  */
2284
2101
  setDictionarySettings(dictionarySettingsParams, requestOptions) {
2285
- if (!dictionarySettingsParams) {
2286
- throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");
2287
- }
2288
- if (!dictionarySettingsParams.disableStandardEntries) {
2289
- throw new Error(
2290
- "Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`."
2291
- );
2292
- }
2102
+ validateRequired("dictionarySettingsParams", "setDictionarySettings", dictionarySettingsParams);
2103
+ validateRequired(
2104
+ "dictionarySettingsParams.disableStandardEntries",
2105
+ "setDictionarySettings",
2106
+ dictionarySettingsParams.disableStandardEntries
2107
+ );
2293
2108
  const requestPath = "/1/dictionaries/*/settings";
2294
2109
  const headers = {};
2295
2110
  const queryParameters = {};
@@ -2314,12 +2129,8 @@ function createSearchClient({
2314
2129
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2315
2130
  */
2316
2131
  setSettings({ indexName, indexSettings, forwardToReplicas }, requestOptions) {
2317
- if (!indexName) {
2318
- throw new Error("Parameter `indexName` is required when calling `setSettings`.");
2319
- }
2320
- if (!indexSettings) {
2321
- throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");
2322
- }
2132
+ validateRequired("indexName", "setSettings", indexName);
2133
+ validateRequired("indexSettings", "setSettings", indexSettings);
2323
2134
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
2324
2135
  const headers = {};
2325
2136
  const queryParameters = {};
@@ -2346,15 +2157,9 @@ function createSearchClient({
2346
2157
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2347
2158
  */
2348
2159
  updateApiKey({ key, apiKey }, requestOptions) {
2349
- if (!key) {
2350
- throw new Error("Parameter `key` is required when calling `updateApiKey`.");
2351
- }
2352
- if (!apiKey) {
2353
- throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");
2354
- }
2355
- if (!apiKey.acl) {
2356
- throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");
2357
- }
2160
+ validateRequired("key", "updateApiKey", key);
2161
+ validateRequired("apiKey", "updateApiKey", apiKey);
2162
+ validateRequired("apiKey.acl", "updateApiKey", apiKey.acl);
2358
2163
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
2359
2164
  const headers = {};
2360
2165
  const queryParameters = {};