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