@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.
@@ -14,9 +14,10 @@ import {
14
14
  createIterablePromise,
15
15
  createTransporter,
16
16
  getAlgoliaAgent,
17
- shuffle
17
+ shuffle,
18
+ validateRequired
18
19
  } from "@algolia/client-common";
19
- var apiClientVersion = "5.53.0";
20
+ var apiClientVersion = "5.54.1";
20
21
  function getDefaultHosts(appId) {
21
22
  return [
22
23
  {
@@ -563,12 +564,8 @@ function createSearchClient({
563
564
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
564
565
  */
565
566
  addApiKey(apiKey, requestOptions) {
566
- if (!apiKey) {
567
- throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");
568
- }
569
- if (!apiKey.acl) {
570
- throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");
571
- }
567
+ validateRequired("apiKey", "addApiKey", apiKey);
568
+ validateRequired("apiKey.acl", "addApiKey", apiKey.acl);
572
569
  const requestPath = "/1/keys";
573
570
  const headers = {};
574
571
  const queryParameters = {};
@@ -593,15 +590,9 @@ function createSearchClient({
593
590
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
594
591
  */
595
592
  addOrUpdateObject({ indexName, objectID, body }, requestOptions) {
596
- if (!indexName) {
597
- throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");
598
- }
599
- if (!objectID) {
600
- throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");
601
- }
602
- if (!body) {
603
- throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");
604
- }
593
+ validateRequired("indexName", "addOrUpdateObject", indexName);
594
+ validateRequired("objectID", "addOrUpdateObject", objectID);
595
+ validateRequired("body", "addOrUpdateObject", body);
605
596
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
606
597
  const headers = {};
607
598
  const queryParameters = {};
@@ -623,12 +614,8 @@ function createSearchClient({
623
614
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
624
615
  */
625
616
  appendSource(source, requestOptions) {
626
- if (!source) {
627
- throw new Error("Parameter `source` is required when calling `appendSource`.");
628
- }
629
- if (!source.source) {
630
- throw new Error("Parameter `source.source` is required when calling `appendSource`.");
631
- }
617
+ validateRequired("source", "appendSource", source);
618
+ validateRequired("source.source", "appendSource", source.source);
632
619
  const requestPath = "/1/security/sources/append";
633
620
  const headers = {};
634
621
  const queryParameters = {};
@@ -654,15 +641,9 @@ function createSearchClient({
654
641
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
655
642
  */
656
643
  assignUserId({ xAlgoliaUserID, assignUserIdParams }, requestOptions) {
657
- if (!xAlgoliaUserID) {
658
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");
659
- }
660
- if (!assignUserIdParams) {
661
- throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");
662
- }
663
- if (!assignUserIdParams.cluster) {
664
- throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");
665
- }
644
+ validateRequired("xAlgoliaUserID", "assignUserId", xAlgoliaUserID);
645
+ validateRequired("assignUserIdParams", "assignUserId", assignUserIdParams);
646
+ validateRequired("assignUserIdParams.cluster", "assignUserId", assignUserIdParams.cluster);
666
647
  const requestPath = "/1/clusters/mapping";
667
648
  const headers = {};
668
649
  const queryParameters = {};
@@ -689,15 +670,9 @@ function createSearchClient({
689
670
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
690
671
  */
691
672
  batch({ indexName, batchWriteParams }, requestOptions) {
692
- if (!indexName) {
693
- throw new Error("Parameter `indexName` is required when calling `batch`.");
694
- }
695
- if (!batchWriteParams) {
696
- throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");
697
- }
698
- if (!batchWriteParams.requests) {
699
- throw new Error("Parameter `batchWriteParams.requests` is required when calling `batch`.");
700
- }
673
+ validateRequired("indexName", "batch", indexName);
674
+ validateRequired("batchWriteParams", "batch", batchWriteParams);
675
+ validateRequired("batchWriteParams.requests", "batch", batchWriteParams.requests);
701
676
  const requestPath = "/1/indexes/{indexName}/batch".replace("{indexName}", encodeURIComponent(indexName));
702
677
  const headers = {};
703
678
  const queryParameters = {};
@@ -723,18 +698,10 @@ function createSearchClient({
723
698
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
724
699
  */
725
700
  batchAssignUserIds({ xAlgoliaUserID, batchAssignUserIdsParams }, requestOptions) {
726
- if (!xAlgoliaUserID) {
727
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");
728
- }
729
- if (!batchAssignUserIdsParams) {
730
- throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");
731
- }
732
- if (!batchAssignUserIdsParams.cluster) {
733
- throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");
734
- }
735
- if (!batchAssignUserIdsParams.users) {
736
- throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");
737
- }
701
+ validateRequired("xAlgoliaUserID", "batchAssignUserIds", xAlgoliaUserID);
702
+ validateRequired("batchAssignUserIdsParams", "batchAssignUserIds", batchAssignUserIdsParams);
703
+ validateRequired("batchAssignUserIdsParams.cluster", "batchAssignUserIds", batchAssignUserIdsParams.cluster);
704
+ validateRequired("batchAssignUserIdsParams.users", "batchAssignUserIds", batchAssignUserIdsParams.users);
738
705
  const requestPath = "/1/clusters/mapping/batch";
739
706
  const headers = {};
740
707
  const queryParameters = {};
@@ -761,17 +728,13 @@ function createSearchClient({
761
728
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
762
729
  */
763
730
  batchDictionaryEntries({ dictionaryName, batchDictionaryEntriesParams }, requestOptions) {
764
- if (!dictionaryName) {
765
- throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");
766
- }
767
- if (!batchDictionaryEntriesParams) {
768
- throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");
769
- }
770
- if (!batchDictionaryEntriesParams.requests) {
771
- throw new Error(
772
- "Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`."
773
- );
774
- }
731
+ validateRequired("dictionaryName", "batchDictionaryEntries", dictionaryName);
732
+ validateRequired("batchDictionaryEntriesParams", "batchDictionaryEntries", batchDictionaryEntriesParams);
733
+ validateRequired(
734
+ "batchDictionaryEntriesParams.requests",
735
+ "batchDictionaryEntries",
736
+ batchDictionaryEntriesParams.requests
737
+ );
775
738
  const requestPath = "/1/dictionaries/{dictionaryName}/batch".replace(
776
739
  "{dictionaryName}",
777
740
  encodeURIComponent(dictionaryName)
@@ -798,9 +761,7 @@ function createSearchClient({
798
761
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
799
762
  */
800
763
  browse({ indexName, browseParams }, requestOptions) {
801
- if (!indexName) {
802
- throw new Error("Parameter `indexName` is required when calling `browse`.");
803
- }
764
+ validateRequired("indexName", "browse", indexName);
804
765
  const requestPath = "/1/indexes/{indexName}/browse".replace("{indexName}", encodeURIComponent(indexName));
805
766
  const headers = {};
806
767
  const queryParameters = {};
@@ -824,9 +785,7 @@ function createSearchClient({
824
785
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
825
786
  */
826
787
  clearObjects({ indexName }, requestOptions) {
827
- if (!indexName) {
828
- throw new Error("Parameter `indexName` is required when calling `clearObjects`.");
829
- }
788
+ validateRequired("indexName", "clearObjects", indexName);
830
789
  const requestPath = "/1/indexes/{indexName}/clear".replace("{indexName}", encodeURIComponent(indexName));
831
790
  const headers = {};
832
791
  const queryParameters = {};
@@ -849,9 +808,7 @@ function createSearchClient({
849
808
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
850
809
  */
851
810
  clearRules({ indexName, forwardToReplicas }, requestOptions) {
852
- if (!indexName) {
853
- throw new Error("Parameter `indexName` is required when calling `clearRules`.");
854
- }
811
+ validateRequired("indexName", "clearRules", indexName);
855
812
  const requestPath = "/1/indexes/{indexName}/rules/clear".replace("{indexName}", encodeURIComponent(indexName));
856
813
  const headers = {};
857
814
  const queryParameters = {};
@@ -877,9 +834,7 @@ function createSearchClient({
877
834
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
878
835
  */
879
836
  clearSynonyms({ indexName, forwardToReplicas }, requestOptions) {
880
- if (!indexName) {
881
- throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");
882
- }
837
+ validateRequired("indexName", "clearSynonyms", indexName);
883
838
  const requestPath = "/1/indexes/{indexName}/synonyms/clear".replace("{indexName}", encodeURIComponent(indexName));
884
839
  const headers = {};
885
840
  const queryParameters = {};
@@ -902,9 +857,7 @@ function createSearchClient({
902
857
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
903
858
  */
904
859
  customDelete({ path, parameters }, requestOptions) {
905
- if (!path) {
906
- throw new Error("Parameter `path` is required when calling `customDelete`.");
907
- }
860
+ validateRequired("path", "customDelete", path);
908
861
  const requestPath = "/{path}".replace("{path}", path);
909
862
  const headers = {};
910
863
  const queryParameters = parameters ? parameters : {};
@@ -924,9 +877,7 @@ function createSearchClient({
924
877
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
925
878
  */
926
879
  customGet({ path, parameters }, requestOptions) {
927
- if (!path) {
928
- throw new Error("Parameter `path` is required when calling `customGet`.");
929
- }
880
+ validateRequired("path", "customGet", path);
930
881
  const requestPath = "/{path}".replace("{path}", path);
931
882
  const headers = {};
932
883
  const queryParameters = parameters ? parameters : {};
@@ -947,9 +898,7 @@ function createSearchClient({
947
898
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
948
899
  */
949
900
  customPost({ path, parameters, body }, requestOptions) {
950
- if (!path) {
951
- throw new Error("Parameter `path` is required when calling `customPost`.");
952
- }
901
+ validateRequired("path", "customPost", path);
953
902
  const requestPath = "/{path}".replace("{path}", path);
954
903
  const headers = {};
955
904
  const queryParameters = parameters ? parameters : {};
@@ -971,9 +920,7 @@ function createSearchClient({
971
920
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
972
921
  */
973
922
  customPut({ path, parameters, body }, requestOptions) {
974
- if (!path) {
975
- throw new Error("Parameter `path` is required when calling `customPut`.");
976
- }
923
+ validateRequired("path", "customPut", path);
977
924
  const requestPath = "/{path}".replace("{path}", path);
978
925
  const headers = {};
979
926
  const queryParameters = parameters ? parameters : {};
@@ -996,9 +943,7 @@ function createSearchClient({
996
943
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
997
944
  */
998
945
  deleteApiKey({ key }, requestOptions) {
999
- if (!key) {
1000
- throw new Error("Parameter `key` is required when calling `deleteApiKey`.");
1001
- }
946
+ validateRequired("key", "deleteApiKey", key);
1002
947
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1003
948
  const headers = {};
1004
949
  const queryParameters = {};
@@ -1021,12 +966,8 @@ function createSearchClient({
1021
966
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1022
967
  */
1023
968
  deleteBy({ indexName, deleteByParams }, requestOptions) {
1024
- if (!indexName) {
1025
- throw new Error("Parameter `indexName` is required when calling `deleteBy`.");
1026
- }
1027
- if (!deleteByParams) {
1028
- throw new Error("Parameter `deleteByParams` is required when calling `deleteBy`.");
1029
- }
969
+ validateRequired("indexName", "deleteBy", indexName);
970
+ validateRequired("deleteByParams", "deleteBy", deleteByParams);
1030
971
  const requestPath = "/1/indexes/{indexName}/deleteByQuery".replace("{indexName}", encodeURIComponent(indexName));
1031
972
  const headers = {};
1032
973
  const queryParameters = {};
@@ -1049,9 +990,7 @@ function createSearchClient({
1049
990
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1050
991
  */
1051
992
  deleteIndex({ indexName }, requestOptions) {
1052
- if (!indexName) {
1053
- throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");
1054
- }
993
+ validateRequired("indexName", "deleteIndex", indexName);
1055
994
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1056
995
  const headers = {};
1057
996
  const queryParameters = {};
@@ -1074,12 +1013,8 @@ function createSearchClient({
1074
1013
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1075
1014
  */
1076
1015
  deleteObject({ indexName, objectID }, requestOptions) {
1077
- if (!indexName) {
1078
- throw new Error("Parameter `indexName` is required when calling `deleteObject`.");
1079
- }
1080
- if (!objectID) {
1081
- throw new Error("Parameter `objectID` is required when calling `deleteObject`.");
1082
- }
1016
+ validateRequired("indexName", "deleteObject", indexName);
1017
+ validateRequired("objectID", "deleteObject", objectID);
1083
1018
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1084
1019
  const headers = {};
1085
1020
  const queryParameters = {};
@@ -1103,12 +1038,8 @@ function createSearchClient({
1103
1038
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1104
1039
  */
1105
1040
  deleteRule({ indexName, objectID, forwardToReplicas }, requestOptions) {
1106
- if (!indexName) {
1107
- throw new Error("Parameter `indexName` is required when calling `deleteRule`.");
1108
- }
1109
- if (!objectID) {
1110
- throw new Error("Parameter `objectID` is required when calling `deleteRule`.");
1111
- }
1041
+ validateRequired("indexName", "deleteRule", indexName);
1042
+ validateRequired("objectID", "deleteRule", objectID);
1112
1043
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1113
1044
  const headers = {};
1114
1045
  const queryParameters = {};
@@ -1133,9 +1064,7 @@ function createSearchClient({
1133
1064
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1134
1065
  */
1135
1066
  deleteSource({ source }, requestOptions) {
1136
- if (!source) {
1137
- throw new Error("Parameter `source` is required when calling `deleteSource`.");
1138
- }
1067
+ validateRequired("source", "deleteSource", source);
1139
1068
  const requestPath = "/1/security/sources/{source}".replace("{source}", encodeURIComponent(source));
1140
1069
  const headers = {};
1141
1070
  const queryParameters = {};
@@ -1159,12 +1088,8 @@ function createSearchClient({
1159
1088
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1160
1089
  */
1161
1090
  deleteSynonym({ indexName, objectID, forwardToReplicas }, requestOptions) {
1162
- if (!indexName) {
1163
- throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");
1164
- }
1165
- if (!objectID) {
1166
- throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");
1167
- }
1091
+ validateRequired("indexName", "deleteSynonym", indexName);
1092
+ validateRequired("objectID", "deleteSynonym", objectID);
1168
1093
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1169
1094
  const headers = {};
1170
1095
  const queryParameters = {};
@@ -1189,9 +1114,7 @@ function createSearchClient({
1189
1114
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1190
1115
  */
1191
1116
  getApiKey({ key }, requestOptions) {
1192
- if (!key) {
1193
- throw new Error("Parameter `key` is required when calling `getApiKey`.");
1194
- }
1117
+ validateRequired("key", "getApiKey", key);
1195
1118
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1196
1119
  const headers = {};
1197
1120
  const queryParameters = {};
@@ -1213,9 +1136,7 @@ function createSearchClient({
1213
1136
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1214
1137
  */
1215
1138
  getAppTask({ taskID }, requestOptions) {
1216
- if (!taskID) {
1217
- throw new Error("Parameter `taskID` is required when calling `getAppTask`.");
1218
- }
1139
+ validateRequired("taskID", "getAppTask", taskID);
1219
1140
  const requestPath = "/1/task/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1220
1141
  const headers = {};
1221
1142
  const queryParameters = {};
@@ -1313,12 +1234,8 @@ function createSearchClient({
1313
1234
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1314
1235
  */
1315
1236
  getObject({ indexName, objectID, attributesToRetrieve }, requestOptions) {
1316
- if (!indexName) {
1317
- throw new Error("Parameter `indexName` is required when calling `getObject`.");
1318
- }
1319
- if (!objectID) {
1320
- throw new Error("Parameter `objectID` is required when calling `getObject`.");
1321
- }
1237
+ validateRequired("indexName", "getObject", indexName);
1238
+ validateRequired("objectID", "getObject", objectID);
1322
1239
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1323
1240
  const headers = {};
1324
1241
  const queryParameters = {};
@@ -1342,12 +1259,8 @@ function createSearchClient({
1342
1259
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1343
1260
  */
1344
1261
  getObjects(getObjectsParams, requestOptions) {
1345
- if (!getObjectsParams) {
1346
- throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");
1347
- }
1348
- if (!getObjectsParams.requests) {
1349
- throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");
1350
- }
1262
+ validateRequired("getObjectsParams", "getObjects", getObjectsParams);
1263
+ validateRequired("getObjectsParams.requests", "getObjects", getObjectsParams.requests);
1351
1264
  const requestPath = "/1/indexes/*/objects";
1352
1265
  const headers = {};
1353
1266
  const queryParameters = {};
@@ -1373,12 +1286,8 @@ function createSearchClient({
1373
1286
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1374
1287
  */
1375
1288
  getRule({ indexName, objectID }, requestOptions) {
1376
- if (!indexName) {
1377
- throw new Error("Parameter `indexName` is required when calling `getRule`.");
1378
- }
1379
- if (!objectID) {
1380
- throw new Error("Parameter `objectID` is required when calling `getRule`.");
1381
- }
1289
+ validateRequired("indexName", "getRule", indexName);
1290
+ validateRequired("objectID", "getRule", objectID);
1382
1291
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1383
1292
  const headers = {};
1384
1293
  const queryParameters = {};
@@ -1401,9 +1310,7 @@ function createSearchClient({
1401
1310
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1402
1311
  */
1403
1312
  getSettings({ indexName, getVersion }, requestOptions) {
1404
- if (!indexName) {
1405
- throw new Error("Parameter `indexName` is required when calling `getSettings`.");
1406
- }
1313
+ validateRequired("indexName", "getSettings", indexName);
1407
1314
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
1408
1315
  const headers = {};
1409
1316
  const queryParameters = {};
@@ -1448,12 +1355,8 @@ function createSearchClient({
1448
1355
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1449
1356
  */
1450
1357
  getSynonym({ indexName, objectID }, requestOptions) {
1451
- if (!indexName) {
1452
- throw new Error("Parameter `indexName` is required when calling `getSynonym`.");
1453
- }
1454
- if (!objectID) {
1455
- throw new Error("Parameter `objectID` is required when calling `getSynonym`.");
1456
- }
1358
+ validateRequired("indexName", "getSynonym", indexName);
1359
+ validateRequired("objectID", "getSynonym", objectID);
1457
1360
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1458
1361
  const headers = {};
1459
1362
  const queryParameters = {};
@@ -1476,12 +1379,8 @@ function createSearchClient({
1476
1379
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1477
1380
  */
1478
1381
  getTask({ indexName, taskID }, requestOptions) {
1479
- if (!indexName) {
1480
- throw new Error("Parameter `indexName` is required when calling `getTask`.");
1481
- }
1482
- if (!taskID) {
1483
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
1484
- }
1382
+ validateRequired("indexName", "getTask", indexName);
1383
+ validateRequired("taskID", "getTask", taskID);
1485
1384
  const requestPath = "/1/indexes/{indexName}/task/{taskID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{taskID}", encodeURIComponent(taskID));
1486
1385
  const headers = {};
1487
1386
  const queryParameters = {};
@@ -1526,9 +1425,7 @@ function createSearchClient({
1526
1425
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1527
1426
  */
1528
1427
  getUserId({ userID }, requestOptions) {
1529
- if (!userID) {
1530
- throw new Error("Parameter `userID` is required when calling `getUserId`.");
1531
- }
1428
+ validateRequired("userID", "getUserId", userID);
1532
1429
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1533
1430
  const headers = {};
1534
1431
  const queryParameters = {};
@@ -1673,12 +1570,8 @@ function createSearchClient({
1673
1570
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1674
1571
  */
1675
1572
  multipleBatch(batchParams, requestOptions) {
1676
- if (!batchParams) {
1677
- throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");
1678
- }
1679
- if (!batchParams.requests) {
1680
- throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");
1681
- }
1573
+ validateRequired("batchParams", "multipleBatch", batchParams);
1574
+ validateRequired("batchParams.requests", "multipleBatch", batchParams.requests);
1682
1575
  const requestPath = "/1/indexes/*/batch";
1683
1576
  const headers = {};
1684
1577
  const queryParameters = {};
@@ -1702,18 +1595,10 @@ function createSearchClient({
1702
1595
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1703
1596
  */
1704
1597
  operationIndex({ indexName, operationIndexParams }, requestOptions) {
1705
- if (!indexName) {
1706
- throw new Error("Parameter `indexName` is required when calling `operationIndex`.");
1707
- }
1708
- if (!operationIndexParams) {
1709
- throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");
1710
- }
1711
- if (!operationIndexParams.operation) {
1712
- throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");
1713
- }
1714
- if (!operationIndexParams.destination) {
1715
- throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");
1716
- }
1598
+ validateRequired("indexName", "operationIndex", indexName);
1599
+ validateRequired("operationIndexParams", "operationIndex", operationIndexParams);
1600
+ validateRequired("operationIndexParams.operation", "operationIndex", operationIndexParams.operation);
1601
+ validateRequired("operationIndexParams.destination", "operationIndex", operationIndexParams.destination);
1717
1602
  const requestPath = "/1/indexes/{indexName}/operation".replace("{indexName}", encodeURIComponent(indexName));
1718
1603
  const headers = {};
1719
1604
  const queryParameters = {};
@@ -1739,15 +1624,9 @@ function createSearchClient({
1739
1624
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1740
1625
  */
1741
1626
  partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists }, requestOptions) {
1742
- if (!indexName) {
1743
- throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");
1744
- }
1745
- if (!objectID) {
1746
- throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");
1747
- }
1748
- if (!attributesToUpdate) {
1749
- throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");
1750
- }
1627
+ validateRequired("indexName", "partialUpdateObject", indexName);
1628
+ validateRequired("objectID", "partialUpdateObject", objectID);
1629
+ validateRequired("attributesToUpdate", "partialUpdateObject", attributesToUpdate);
1751
1630
  const requestPath = "/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1752
1631
  const headers = {};
1753
1632
  const queryParameters = {};
@@ -1775,9 +1654,7 @@ function createSearchClient({
1775
1654
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1776
1655
  */
1777
1656
  removeUserId({ userID }, requestOptions) {
1778
- if (!userID) {
1779
- throw new Error("Parameter `userID` is required when calling `removeUserId`.");
1780
- }
1657
+ validateRequired("userID", "removeUserId", userID);
1781
1658
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1782
1659
  const headers = {};
1783
1660
  const queryParameters = {};
@@ -1799,9 +1676,7 @@ function createSearchClient({
1799
1676
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1800
1677
  */
1801
1678
  replaceSources({ source }, requestOptions) {
1802
- if (!source) {
1803
- throw new Error("Parameter `source` is required when calling `replaceSources`.");
1804
- }
1679
+ validateRequired("source", "replaceSources", source);
1805
1680
  const requestPath = "/1/security/sources";
1806
1681
  const headers = {};
1807
1682
  const queryParameters = {};
@@ -1824,9 +1699,7 @@ function createSearchClient({
1824
1699
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1825
1700
  */
1826
1701
  restoreApiKey({ key }, requestOptions) {
1827
- if (!key) {
1828
- throw new Error("Parameter `key` is required when calling `restoreApiKey`.");
1829
- }
1702
+ validateRequired("key", "restoreApiKey", key);
1830
1703
  const requestPath = "/1/keys/{key}/restore".replace("{key}", encodeURIComponent(key));
1831
1704
  const headers = {};
1832
1705
  const queryParameters = {};
@@ -1849,12 +1722,8 @@ function createSearchClient({
1849
1722
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1850
1723
  */
1851
1724
  saveObject({ indexName, body }, requestOptions) {
1852
- if (!indexName) {
1853
- throw new Error("Parameter `indexName` is required when calling `saveObject`.");
1854
- }
1855
- if (!body) {
1856
- throw new Error("Parameter `body` is required when calling `saveObject`.");
1857
- }
1725
+ validateRequired("indexName", "saveObject", indexName);
1726
+ validateRequired("body", "saveObject", body);
1858
1727
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1859
1728
  const headers = {};
1860
1729
  const queryParameters = {};
@@ -1880,21 +1749,11 @@ function createSearchClient({
1880
1749
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1881
1750
  */
1882
1751
  saveRule({ indexName, objectID, rule, forwardToReplicas }, requestOptions) {
1883
- if (!indexName) {
1884
- throw new Error("Parameter `indexName` is required when calling `saveRule`.");
1885
- }
1886
- if (!objectID) {
1887
- throw new Error("Parameter `objectID` is required when calling `saveRule`.");
1888
- }
1889
- if (!rule) {
1890
- throw new Error("Parameter `rule` is required when calling `saveRule`.");
1891
- }
1892
- if (!rule.objectID) {
1893
- throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
1894
- }
1895
- if (!rule.consequence) {
1896
- throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
1897
- }
1752
+ validateRequired("indexName", "saveRule", indexName);
1753
+ validateRequired("objectID", "saveRule", objectID);
1754
+ validateRequired("rule", "saveRule", rule);
1755
+ validateRequired("rule.objectID", "saveRule", rule.objectID);
1756
+ validateRequired("rule.consequence", "saveRule", rule.consequence);
1898
1757
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1899
1758
  const headers = {};
1900
1759
  const queryParameters = {};
@@ -1923,12 +1782,8 @@ function createSearchClient({
1923
1782
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1924
1783
  */
1925
1784
  saveRules({ indexName, rules, forwardToReplicas, clearExistingRules }, requestOptions) {
1926
- if (!indexName) {
1927
- throw new Error("Parameter `indexName` is required when calling `saveRules`.");
1928
- }
1929
- if (!rules) {
1930
- throw new Error("Parameter `rules` is required when calling `saveRules`.");
1931
- }
1785
+ validateRequired("indexName", "saveRules", indexName);
1786
+ validateRequired("rules", "saveRules", rules);
1932
1787
  const requestPath = "/1/indexes/{indexName}/rules/batch".replace("{indexName}", encodeURIComponent(indexName));
1933
1788
  const headers = {};
1934
1789
  const queryParameters = {};
@@ -1960,21 +1815,11 @@ function createSearchClient({
1960
1815
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1961
1816
  */
1962
1817
  saveSynonym({ indexName, objectID, synonymHit, forwardToReplicas }, requestOptions) {
1963
- if (!indexName) {
1964
- throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");
1965
- }
1966
- if (!objectID) {
1967
- throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");
1968
- }
1969
- if (!synonymHit) {
1970
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");
1971
- }
1972
- if (!synonymHit.objectID) {
1973
- throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");
1974
- }
1975
- if (!synonymHit.type) {
1976
- throw new Error("Parameter `synonymHit.type` is required when calling `saveSynonym`.");
1977
- }
1818
+ validateRequired("indexName", "saveSynonym", indexName);
1819
+ validateRequired("objectID", "saveSynonym", objectID);
1820
+ validateRequired("synonymHit", "saveSynonym", synonymHit);
1821
+ validateRequired("synonymHit.objectID", "saveSynonym", synonymHit.objectID);
1822
+ validateRequired("synonymHit.type", "saveSynonym", synonymHit.type);
1978
1823
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1979
1824
  const headers = {};
1980
1825
  const queryParameters = {};
@@ -2003,12 +1848,8 @@ function createSearchClient({
2003
1848
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2004
1849
  */
2005
1850
  saveSynonyms({ indexName, synonymHit, forwardToReplicas, replaceExistingSynonyms }, requestOptions) {
2006
- if (!indexName) {
2007
- throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");
2008
- }
2009
- if (!synonymHit) {
2010
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");
2011
- }
1851
+ validateRequired("indexName", "saveSynonyms", indexName);
1852
+ validateRequired("synonymHit", "saveSynonyms", synonymHit);
2012
1853
  const requestPath = "/1/indexes/{indexName}/synonyms/batch".replace("{indexName}", encodeURIComponent(indexName));
2013
1854
  const headers = {};
2014
1855
  const queryParameters = {};
@@ -2057,12 +1898,8 @@ function createSearchClient({
2057
1898
  };
2058
1899
  searchMethodParams = newSignatureRequest;
2059
1900
  }
2060
- if (!searchMethodParams) {
2061
- throw new Error("Parameter `searchMethodParams` is required when calling `search`.");
2062
- }
2063
- if (!searchMethodParams.requests) {
2064
- throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");
2065
- }
1901
+ validateRequired("searchMethodParams", "search", searchMethodParams);
1902
+ validateRequired("searchMethodParams.requests", "search", searchMethodParams.requests);
2066
1903
  const requestPath = "/1/indexes/*/queries";
2067
1904
  const headers = {};
2068
1905
  const queryParameters = {};
@@ -2088,19 +1925,13 @@ function createSearchClient({
2088
1925
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2089
1926
  */
2090
1927
  searchDictionaryEntries({ dictionaryName, searchDictionaryEntriesParams }, requestOptions) {
2091
- if (!dictionaryName) {
2092
- throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");
2093
- }
2094
- if (!searchDictionaryEntriesParams) {
2095
- throw new Error(
2096
- "Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`."
2097
- );
2098
- }
2099
- if (!searchDictionaryEntriesParams.query) {
2100
- throw new Error(
2101
- "Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`."
2102
- );
2103
- }
1928
+ validateRequired("dictionaryName", "searchDictionaryEntries", dictionaryName);
1929
+ validateRequired("searchDictionaryEntriesParams", "searchDictionaryEntries", searchDictionaryEntriesParams);
1930
+ validateRequired(
1931
+ "searchDictionaryEntriesParams.query",
1932
+ "searchDictionaryEntries",
1933
+ searchDictionaryEntriesParams.query
1934
+ );
2104
1935
  const requestPath = "/1/dictionaries/{dictionaryName}/search".replace(
2105
1936
  "{dictionaryName}",
2106
1937
  encodeURIComponent(dictionaryName)
@@ -2130,12 +1961,8 @@ function createSearchClient({
2130
1961
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2131
1962
  */
2132
1963
  searchForFacetValues({ indexName, facetName, searchForFacetValuesRequest }, requestOptions) {
2133
- if (!indexName) {
2134
- throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");
2135
- }
2136
- if (!facetName) {
2137
- throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");
2138
- }
1964
+ validateRequired("indexName", "searchForFacetValues", indexName);
1965
+ validateRequired("facetName", "searchForFacetValues", facetName);
2139
1966
  const requestPath = "/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}", encodeURIComponent(indexName)).replace("{facetName}", encodeURIComponent(facetName));
2140
1967
  const headers = {};
2141
1968
  const queryParameters = {};
@@ -2161,9 +1988,7 @@ function createSearchClient({
2161
1988
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2162
1989
  */
2163
1990
  searchRules({ indexName, searchRulesParams }, requestOptions) {
2164
- if (!indexName) {
2165
- throw new Error("Parameter `indexName` is required when calling `searchRules`.");
2166
- }
1991
+ validateRequired("indexName", "searchRules", indexName);
2167
1992
  const requestPath = "/1/indexes/{indexName}/rules/search".replace("{indexName}", encodeURIComponent(indexName));
2168
1993
  const headers = {};
2169
1994
  const queryParameters = {};
@@ -2189,9 +2014,7 @@ function createSearchClient({
2189
2014
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2190
2015
  */
2191
2016
  searchSingleIndex({ indexName, searchParams }, requestOptions) {
2192
- if (!indexName) {
2193
- throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");
2194
- }
2017
+ validateRequired("indexName", "searchSingleIndex", indexName);
2195
2018
  const requestPath = "/1/indexes/{indexName}/query".replace("{indexName}", encodeURIComponent(indexName));
2196
2019
  const headers = {};
2197
2020
  const queryParameters = {};
@@ -2217,9 +2040,7 @@ function createSearchClient({
2217
2040
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2218
2041
  */
2219
2042
  searchSynonyms({ indexName, searchSynonymsParams }, requestOptions) {
2220
- if (!indexName) {
2221
- throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");
2222
- }
2043
+ validateRequired("indexName", "searchSynonyms", indexName);
2223
2044
  const requestPath = "/1/indexes/{indexName}/synonyms/search".replace(
2224
2045
  "{indexName}",
2225
2046
  encodeURIComponent(indexName)
@@ -2248,12 +2069,8 @@ function createSearchClient({
2248
2069
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2249
2070
  */
2250
2071
  searchUserIds(searchUserIdsParams, requestOptions) {
2251
- if (!searchUserIdsParams) {
2252
- throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");
2253
- }
2254
- if (!searchUserIdsParams.query) {
2255
- throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");
2256
- }
2072
+ validateRequired("searchUserIdsParams", "searchUserIds", searchUserIdsParams);
2073
+ validateRequired("searchUserIdsParams.query", "searchUserIds", searchUserIdsParams.query);
2257
2074
  const requestPath = "/1/clusters/mapping/search";
2258
2075
  const headers = {};
2259
2076
  const queryParameters = {};
@@ -2277,14 +2094,12 @@ function createSearchClient({
2277
2094
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2278
2095
  */
2279
2096
  setDictionarySettings(dictionarySettingsParams, requestOptions) {
2280
- if (!dictionarySettingsParams) {
2281
- throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");
2282
- }
2283
- if (!dictionarySettingsParams.disableStandardEntries) {
2284
- throw new Error(
2285
- "Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`."
2286
- );
2287
- }
2097
+ validateRequired("dictionarySettingsParams", "setDictionarySettings", dictionarySettingsParams);
2098
+ validateRequired(
2099
+ "dictionarySettingsParams.disableStandardEntries",
2100
+ "setDictionarySettings",
2101
+ dictionarySettingsParams.disableStandardEntries
2102
+ );
2288
2103
  const requestPath = "/1/dictionaries/*/settings";
2289
2104
  const headers = {};
2290
2105
  const queryParameters = {};
@@ -2309,12 +2124,8 @@ function createSearchClient({
2309
2124
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2310
2125
  */
2311
2126
  setSettings({ indexName, indexSettings, forwardToReplicas }, requestOptions) {
2312
- if (!indexName) {
2313
- throw new Error("Parameter `indexName` is required when calling `setSettings`.");
2314
- }
2315
- if (!indexSettings) {
2316
- throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");
2317
- }
2127
+ validateRequired("indexName", "setSettings", indexName);
2128
+ validateRequired("indexSettings", "setSettings", indexSettings);
2318
2129
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
2319
2130
  const headers = {};
2320
2131
  const queryParameters = {};
@@ -2341,15 +2152,9 @@ function createSearchClient({
2341
2152
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2342
2153
  */
2343
2154
  updateApiKey({ key, apiKey }, requestOptions) {
2344
- if (!key) {
2345
- throw new Error("Parameter `key` is required when calling `updateApiKey`.");
2346
- }
2347
- if (!apiKey) {
2348
- throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");
2349
- }
2350
- if (!apiKey.acl) {
2351
- throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");
2352
- }
2155
+ validateRequired("key", "updateApiKey", key);
2156
+ validateRequired("apiKey", "updateApiKey", apiKey);
2157
+ validateRequired("apiKey.acl", "updateApiKey", apiKey.acl);
2353
2158
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
2354
2159
  const headers = {};
2355
2160
  const queryParameters = {};