@algolia/client-search 5.53.0 → 5.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,9 +5,10 @@ import {
5
5
  createIterablePromise,
6
6
  createTransporter,
7
7
  getAlgoliaAgent,
8
- shuffle
8
+ shuffle,
9
+ validateRequired
9
10
  } from "@algolia/client-common";
10
- var apiClientVersion = "5.53.0";
11
+ var apiClientVersion = "5.54.0";
11
12
  function getDefaultHosts(appId) {
12
13
  return [
13
14
  {
@@ -554,12 +555,8 @@ function createSearchClient({
554
555
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
555
556
  */
556
557
  addApiKey(apiKey, requestOptions) {
557
- if (!apiKey) {
558
- throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");
559
- }
560
- if (!apiKey.acl) {
561
- throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");
562
- }
558
+ validateRequired("apiKey", "addApiKey", apiKey);
559
+ validateRequired("apiKey.acl", "addApiKey", apiKey.acl);
563
560
  const requestPath = "/1/keys";
564
561
  const headers = {};
565
562
  const queryParameters = {};
@@ -584,15 +581,9 @@ function createSearchClient({
584
581
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
585
582
  */
586
583
  addOrUpdateObject({ indexName, objectID, body }, requestOptions) {
587
- if (!indexName) {
588
- throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");
589
- }
590
- if (!objectID) {
591
- throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");
592
- }
593
- if (!body) {
594
- throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");
595
- }
584
+ validateRequired("indexName", "addOrUpdateObject", indexName);
585
+ validateRequired("objectID", "addOrUpdateObject", objectID);
586
+ validateRequired("body", "addOrUpdateObject", body);
596
587
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
597
588
  const headers = {};
598
589
  const queryParameters = {};
@@ -614,12 +605,8 @@ function createSearchClient({
614
605
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
615
606
  */
616
607
  appendSource(source, requestOptions) {
617
- if (!source) {
618
- throw new Error("Parameter `source` is required when calling `appendSource`.");
619
- }
620
- if (!source.source) {
621
- throw new Error("Parameter `source.source` is required when calling `appendSource`.");
622
- }
608
+ validateRequired("source", "appendSource", source);
609
+ validateRequired("source.source", "appendSource", source.source);
623
610
  const requestPath = "/1/security/sources/append";
624
611
  const headers = {};
625
612
  const queryParameters = {};
@@ -645,15 +632,9 @@ function createSearchClient({
645
632
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
646
633
  */
647
634
  assignUserId({ xAlgoliaUserID, assignUserIdParams }, requestOptions) {
648
- if (!xAlgoliaUserID) {
649
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");
650
- }
651
- if (!assignUserIdParams) {
652
- throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");
653
- }
654
- if (!assignUserIdParams.cluster) {
655
- throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");
656
- }
635
+ validateRequired("xAlgoliaUserID", "assignUserId", xAlgoliaUserID);
636
+ validateRequired("assignUserIdParams", "assignUserId", assignUserIdParams);
637
+ validateRequired("assignUserIdParams.cluster", "assignUserId", assignUserIdParams.cluster);
657
638
  const requestPath = "/1/clusters/mapping";
658
639
  const headers = {};
659
640
  const queryParameters = {};
@@ -680,15 +661,9 @@ function createSearchClient({
680
661
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
681
662
  */
682
663
  batch({ indexName, batchWriteParams }, requestOptions) {
683
- if (!indexName) {
684
- throw new Error("Parameter `indexName` is required when calling `batch`.");
685
- }
686
- if (!batchWriteParams) {
687
- throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");
688
- }
689
- if (!batchWriteParams.requests) {
690
- throw new Error("Parameter `batchWriteParams.requests` is required when calling `batch`.");
691
- }
664
+ validateRequired("indexName", "batch", indexName);
665
+ validateRequired("batchWriteParams", "batch", batchWriteParams);
666
+ validateRequired("batchWriteParams.requests", "batch", batchWriteParams.requests);
692
667
  const requestPath = "/1/indexes/{indexName}/batch".replace("{indexName}", encodeURIComponent(indexName));
693
668
  const headers = {};
694
669
  const queryParameters = {};
@@ -714,18 +689,10 @@ function createSearchClient({
714
689
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
715
690
  */
716
691
  batchAssignUserIds({ xAlgoliaUserID, batchAssignUserIdsParams }, requestOptions) {
717
- if (!xAlgoliaUserID) {
718
- throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");
719
- }
720
- if (!batchAssignUserIdsParams) {
721
- throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");
722
- }
723
- if (!batchAssignUserIdsParams.cluster) {
724
- throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");
725
- }
726
- if (!batchAssignUserIdsParams.users) {
727
- throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");
728
- }
692
+ validateRequired("xAlgoliaUserID", "batchAssignUserIds", xAlgoliaUserID);
693
+ validateRequired("batchAssignUserIdsParams", "batchAssignUserIds", batchAssignUserIdsParams);
694
+ validateRequired("batchAssignUserIdsParams.cluster", "batchAssignUserIds", batchAssignUserIdsParams.cluster);
695
+ validateRequired("batchAssignUserIdsParams.users", "batchAssignUserIds", batchAssignUserIdsParams.users);
729
696
  const requestPath = "/1/clusters/mapping/batch";
730
697
  const headers = {};
731
698
  const queryParameters = {};
@@ -752,17 +719,13 @@ function createSearchClient({
752
719
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
753
720
  */
754
721
  batchDictionaryEntries({ dictionaryName, batchDictionaryEntriesParams }, requestOptions) {
755
- if (!dictionaryName) {
756
- throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");
757
- }
758
- if (!batchDictionaryEntriesParams) {
759
- throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");
760
- }
761
- if (!batchDictionaryEntriesParams.requests) {
762
- throw new Error(
763
- "Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`."
764
- );
765
- }
722
+ validateRequired("dictionaryName", "batchDictionaryEntries", dictionaryName);
723
+ validateRequired("batchDictionaryEntriesParams", "batchDictionaryEntries", batchDictionaryEntriesParams);
724
+ validateRequired(
725
+ "batchDictionaryEntriesParams.requests",
726
+ "batchDictionaryEntries",
727
+ batchDictionaryEntriesParams.requests
728
+ );
766
729
  const requestPath = "/1/dictionaries/{dictionaryName}/batch".replace(
767
730
  "{dictionaryName}",
768
731
  encodeURIComponent(dictionaryName)
@@ -789,9 +752,7 @@ function createSearchClient({
789
752
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
790
753
  */
791
754
  browse({ indexName, browseParams }, requestOptions) {
792
- if (!indexName) {
793
- throw new Error("Parameter `indexName` is required when calling `browse`.");
794
- }
755
+ validateRequired("indexName", "browse", indexName);
795
756
  const requestPath = "/1/indexes/{indexName}/browse".replace("{indexName}", encodeURIComponent(indexName));
796
757
  const headers = {};
797
758
  const queryParameters = {};
@@ -815,9 +776,7 @@ function createSearchClient({
815
776
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
816
777
  */
817
778
  clearObjects({ indexName }, requestOptions) {
818
- if (!indexName) {
819
- throw new Error("Parameter `indexName` is required when calling `clearObjects`.");
820
- }
779
+ validateRequired("indexName", "clearObjects", indexName);
821
780
  const requestPath = "/1/indexes/{indexName}/clear".replace("{indexName}", encodeURIComponent(indexName));
822
781
  const headers = {};
823
782
  const queryParameters = {};
@@ -840,9 +799,7 @@ function createSearchClient({
840
799
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
841
800
  */
842
801
  clearRules({ indexName, forwardToReplicas }, requestOptions) {
843
- if (!indexName) {
844
- throw new Error("Parameter `indexName` is required when calling `clearRules`.");
845
- }
802
+ validateRequired("indexName", "clearRules", indexName);
846
803
  const requestPath = "/1/indexes/{indexName}/rules/clear".replace("{indexName}", encodeURIComponent(indexName));
847
804
  const headers = {};
848
805
  const queryParameters = {};
@@ -868,9 +825,7 @@ function createSearchClient({
868
825
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
869
826
  */
870
827
  clearSynonyms({ indexName, forwardToReplicas }, requestOptions) {
871
- if (!indexName) {
872
- throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");
873
- }
828
+ validateRequired("indexName", "clearSynonyms", indexName);
874
829
  const requestPath = "/1/indexes/{indexName}/synonyms/clear".replace("{indexName}", encodeURIComponent(indexName));
875
830
  const headers = {};
876
831
  const queryParameters = {};
@@ -893,9 +848,7 @@ function createSearchClient({
893
848
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
894
849
  */
895
850
  customDelete({ path, parameters }, requestOptions) {
896
- if (!path) {
897
- throw new Error("Parameter `path` is required when calling `customDelete`.");
898
- }
851
+ validateRequired("path", "customDelete", path);
899
852
  const requestPath = "/{path}".replace("{path}", path);
900
853
  const headers = {};
901
854
  const queryParameters = parameters ? parameters : {};
@@ -915,9 +868,7 @@ function createSearchClient({
915
868
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
916
869
  */
917
870
  customGet({ path, parameters }, requestOptions) {
918
- if (!path) {
919
- throw new Error("Parameter `path` is required when calling `customGet`.");
920
- }
871
+ validateRequired("path", "customGet", path);
921
872
  const requestPath = "/{path}".replace("{path}", path);
922
873
  const headers = {};
923
874
  const queryParameters = parameters ? parameters : {};
@@ -938,9 +889,7 @@ function createSearchClient({
938
889
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
939
890
  */
940
891
  customPost({ path, parameters, body }, requestOptions) {
941
- if (!path) {
942
- throw new Error("Parameter `path` is required when calling `customPost`.");
943
- }
892
+ validateRequired("path", "customPost", path);
944
893
  const requestPath = "/{path}".replace("{path}", path);
945
894
  const headers = {};
946
895
  const queryParameters = parameters ? parameters : {};
@@ -962,9 +911,7 @@ function createSearchClient({
962
911
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
963
912
  */
964
913
  customPut({ path, parameters, body }, requestOptions) {
965
- if (!path) {
966
- throw new Error("Parameter `path` is required when calling `customPut`.");
967
- }
914
+ validateRequired("path", "customPut", path);
968
915
  const requestPath = "/{path}".replace("{path}", path);
969
916
  const headers = {};
970
917
  const queryParameters = parameters ? parameters : {};
@@ -987,9 +934,7 @@ function createSearchClient({
987
934
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
988
935
  */
989
936
  deleteApiKey({ key }, requestOptions) {
990
- if (!key) {
991
- throw new Error("Parameter `key` is required when calling `deleteApiKey`.");
992
- }
937
+ validateRequired("key", "deleteApiKey", key);
993
938
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
994
939
  const headers = {};
995
940
  const queryParameters = {};
@@ -1012,12 +957,8 @@ function createSearchClient({
1012
957
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1013
958
  */
1014
959
  deleteBy({ indexName, deleteByParams }, requestOptions) {
1015
- if (!indexName) {
1016
- throw new Error("Parameter `indexName` is required when calling `deleteBy`.");
1017
- }
1018
- if (!deleteByParams) {
1019
- throw new Error("Parameter `deleteByParams` is required when calling `deleteBy`.");
1020
- }
960
+ validateRequired("indexName", "deleteBy", indexName);
961
+ validateRequired("deleteByParams", "deleteBy", deleteByParams);
1021
962
  const requestPath = "/1/indexes/{indexName}/deleteByQuery".replace("{indexName}", encodeURIComponent(indexName));
1022
963
  const headers = {};
1023
964
  const queryParameters = {};
@@ -1040,9 +981,7 @@ function createSearchClient({
1040
981
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1041
982
  */
1042
983
  deleteIndex({ indexName }, requestOptions) {
1043
- if (!indexName) {
1044
- throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");
1045
- }
984
+ validateRequired("indexName", "deleteIndex", indexName);
1046
985
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1047
986
  const headers = {};
1048
987
  const queryParameters = {};
@@ -1065,12 +1004,8 @@ function createSearchClient({
1065
1004
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1066
1005
  */
1067
1006
  deleteObject({ indexName, objectID }, requestOptions) {
1068
- if (!indexName) {
1069
- throw new Error("Parameter `indexName` is required when calling `deleteObject`.");
1070
- }
1071
- if (!objectID) {
1072
- throw new Error("Parameter `objectID` is required when calling `deleteObject`.");
1073
- }
1007
+ validateRequired("indexName", "deleteObject", indexName);
1008
+ validateRequired("objectID", "deleteObject", objectID);
1074
1009
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1075
1010
  const headers = {};
1076
1011
  const queryParameters = {};
@@ -1094,12 +1029,8 @@ function createSearchClient({
1094
1029
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1095
1030
  */
1096
1031
  deleteRule({ indexName, objectID, forwardToReplicas }, requestOptions) {
1097
- if (!indexName) {
1098
- throw new Error("Parameter `indexName` is required when calling `deleteRule`.");
1099
- }
1100
- if (!objectID) {
1101
- throw new Error("Parameter `objectID` is required when calling `deleteRule`.");
1102
- }
1032
+ validateRequired("indexName", "deleteRule", indexName);
1033
+ validateRequired("objectID", "deleteRule", objectID);
1103
1034
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1104
1035
  const headers = {};
1105
1036
  const queryParameters = {};
@@ -1124,9 +1055,7 @@ function createSearchClient({
1124
1055
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1125
1056
  */
1126
1057
  deleteSource({ source }, requestOptions) {
1127
- if (!source) {
1128
- throw new Error("Parameter `source` is required when calling `deleteSource`.");
1129
- }
1058
+ validateRequired("source", "deleteSource", source);
1130
1059
  const requestPath = "/1/security/sources/{source}".replace("{source}", encodeURIComponent(source));
1131
1060
  const headers = {};
1132
1061
  const queryParameters = {};
@@ -1150,12 +1079,8 @@ function createSearchClient({
1150
1079
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1151
1080
  */
1152
1081
  deleteSynonym({ indexName, objectID, forwardToReplicas }, requestOptions) {
1153
- if (!indexName) {
1154
- throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");
1155
- }
1156
- if (!objectID) {
1157
- throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");
1158
- }
1082
+ validateRequired("indexName", "deleteSynonym", indexName);
1083
+ validateRequired("objectID", "deleteSynonym", objectID);
1159
1084
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1160
1085
  const headers = {};
1161
1086
  const queryParameters = {};
@@ -1180,9 +1105,7 @@ function createSearchClient({
1180
1105
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1181
1106
  */
1182
1107
  getApiKey({ key }, requestOptions) {
1183
- if (!key) {
1184
- throw new Error("Parameter `key` is required when calling `getApiKey`.");
1185
- }
1108
+ validateRequired("key", "getApiKey", key);
1186
1109
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
1187
1110
  const headers = {};
1188
1111
  const queryParameters = {};
@@ -1204,9 +1127,7 @@ function createSearchClient({
1204
1127
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1205
1128
  */
1206
1129
  getAppTask({ taskID }, requestOptions) {
1207
- if (!taskID) {
1208
- throw new Error("Parameter `taskID` is required when calling `getAppTask`.");
1209
- }
1130
+ validateRequired("taskID", "getAppTask", taskID);
1210
1131
  const requestPath = "/1/task/{taskID}".replace("{taskID}", encodeURIComponent(taskID));
1211
1132
  const headers = {};
1212
1133
  const queryParameters = {};
@@ -1304,12 +1225,8 @@ function createSearchClient({
1304
1225
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1305
1226
  */
1306
1227
  getObject({ indexName, objectID, attributesToRetrieve }, requestOptions) {
1307
- if (!indexName) {
1308
- throw new Error("Parameter `indexName` is required when calling `getObject`.");
1309
- }
1310
- if (!objectID) {
1311
- throw new Error("Parameter `objectID` is required when calling `getObject`.");
1312
- }
1228
+ validateRequired("indexName", "getObject", indexName);
1229
+ validateRequired("objectID", "getObject", objectID);
1313
1230
  const requestPath = "/1/indexes/{indexName}/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1314
1231
  const headers = {};
1315
1232
  const queryParameters = {};
@@ -1333,12 +1250,8 @@ function createSearchClient({
1333
1250
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1334
1251
  */
1335
1252
  getObjects(getObjectsParams, requestOptions) {
1336
- if (!getObjectsParams) {
1337
- throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");
1338
- }
1339
- if (!getObjectsParams.requests) {
1340
- throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");
1341
- }
1253
+ validateRequired("getObjectsParams", "getObjects", getObjectsParams);
1254
+ validateRequired("getObjectsParams.requests", "getObjects", getObjectsParams.requests);
1342
1255
  const requestPath = "/1/indexes/*/objects";
1343
1256
  const headers = {};
1344
1257
  const queryParameters = {};
@@ -1364,12 +1277,8 @@ function createSearchClient({
1364
1277
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1365
1278
  */
1366
1279
  getRule({ indexName, objectID }, requestOptions) {
1367
- if (!indexName) {
1368
- throw new Error("Parameter `indexName` is required when calling `getRule`.");
1369
- }
1370
- if (!objectID) {
1371
- throw new Error("Parameter `objectID` is required when calling `getRule`.");
1372
- }
1280
+ validateRequired("indexName", "getRule", indexName);
1281
+ validateRequired("objectID", "getRule", objectID);
1373
1282
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1374
1283
  const headers = {};
1375
1284
  const queryParameters = {};
@@ -1392,9 +1301,7 @@ function createSearchClient({
1392
1301
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1393
1302
  */
1394
1303
  getSettings({ indexName, getVersion }, requestOptions) {
1395
- if (!indexName) {
1396
- throw new Error("Parameter `indexName` is required when calling `getSettings`.");
1397
- }
1304
+ validateRequired("indexName", "getSettings", indexName);
1398
1305
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
1399
1306
  const headers = {};
1400
1307
  const queryParameters = {};
@@ -1439,12 +1346,8 @@ function createSearchClient({
1439
1346
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1440
1347
  */
1441
1348
  getSynonym({ indexName, objectID }, requestOptions) {
1442
- if (!indexName) {
1443
- throw new Error("Parameter `indexName` is required when calling `getSynonym`.");
1444
- }
1445
- if (!objectID) {
1446
- throw new Error("Parameter `objectID` is required when calling `getSynonym`.");
1447
- }
1349
+ validateRequired("indexName", "getSynonym", indexName);
1350
+ validateRequired("objectID", "getSynonym", objectID);
1448
1351
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1449
1352
  const headers = {};
1450
1353
  const queryParameters = {};
@@ -1467,12 +1370,8 @@ function createSearchClient({
1467
1370
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1468
1371
  */
1469
1372
  getTask({ indexName, taskID }, requestOptions) {
1470
- if (!indexName) {
1471
- throw new Error("Parameter `indexName` is required when calling `getTask`.");
1472
- }
1473
- if (!taskID) {
1474
- throw new Error("Parameter `taskID` is required when calling `getTask`.");
1475
- }
1373
+ validateRequired("indexName", "getTask", indexName);
1374
+ validateRequired("taskID", "getTask", taskID);
1476
1375
  const requestPath = "/1/indexes/{indexName}/task/{taskID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{taskID}", encodeURIComponent(taskID));
1477
1376
  const headers = {};
1478
1377
  const queryParameters = {};
@@ -1517,9 +1416,7 @@ function createSearchClient({
1517
1416
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1518
1417
  */
1519
1418
  getUserId({ userID }, requestOptions) {
1520
- if (!userID) {
1521
- throw new Error("Parameter `userID` is required when calling `getUserId`.");
1522
- }
1419
+ validateRequired("userID", "getUserId", userID);
1523
1420
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1524
1421
  const headers = {};
1525
1422
  const queryParameters = {};
@@ -1664,12 +1561,8 @@ function createSearchClient({
1664
1561
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1665
1562
  */
1666
1563
  multipleBatch(batchParams, requestOptions) {
1667
- if (!batchParams) {
1668
- throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");
1669
- }
1670
- if (!batchParams.requests) {
1671
- throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");
1672
- }
1564
+ validateRequired("batchParams", "multipleBatch", batchParams);
1565
+ validateRequired("batchParams.requests", "multipleBatch", batchParams.requests);
1673
1566
  const requestPath = "/1/indexes/*/batch";
1674
1567
  const headers = {};
1675
1568
  const queryParameters = {};
@@ -1693,18 +1586,10 @@ function createSearchClient({
1693
1586
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1694
1587
  */
1695
1588
  operationIndex({ indexName, operationIndexParams }, requestOptions) {
1696
- if (!indexName) {
1697
- throw new Error("Parameter `indexName` is required when calling `operationIndex`.");
1698
- }
1699
- if (!operationIndexParams) {
1700
- throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");
1701
- }
1702
- if (!operationIndexParams.operation) {
1703
- throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");
1704
- }
1705
- if (!operationIndexParams.destination) {
1706
- throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");
1707
- }
1589
+ validateRequired("indexName", "operationIndex", indexName);
1590
+ validateRequired("operationIndexParams", "operationIndex", operationIndexParams);
1591
+ validateRequired("operationIndexParams.operation", "operationIndex", operationIndexParams.operation);
1592
+ validateRequired("operationIndexParams.destination", "operationIndex", operationIndexParams.destination);
1708
1593
  const requestPath = "/1/indexes/{indexName}/operation".replace("{indexName}", encodeURIComponent(indexName));
1709
1594
  const headers = {};
1710
1595
  const queryParameters = {};
@@ -1730,15 +1615,9 @@ function createSearchClient({
1730
1615
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1731
1616
  */
1732
1617
  partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists }, requestOptions) {
1733
- if (!indexName) {
1734
- throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");
1735
- }
1736
- if (!objectID) {
1737
- throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");
1738
- }
1739
- if (!attributesToUpdate) {
1740
- throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");
1741
- }
1618
+ validateRequired("indexName", "partialUpdateObject", indexName);
1619
+ validateRequired("objectID", "partialUpdateObject", objectID);
1620
+ validateRequired("attributesToUpdate", "partialUpdateObject", attributesToUpdate);
1742
1621
  const requestPath = "/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1743
1622
  const headers = {};
1744
1623
  const queryParameters = {};
@@ -1766,9 +1645,7 @@ function createSearchClient({
1766
1645
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1767
1646
  */
1768
1647
  removeUserId({ userID }, requestOptions) {
1769
- if (!userID) {
1770
- throw new Error("Parameter `userID` is required when calling `removeUserId`.");
1771
- }
1648
+ validateRequired("userID", "removeUserId", userID);
1772
1649
  const requestPath = "/1/clusters/mapping/{userID}".replace("{userID}", encodeURIComponent(userID));
1773
1650
  const headers = {};
1774
1651
  const queryParameters = {};
@@ -1790,9 +1667,7 @@ function createSearchClient({
1790
1667
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1791
1668
  */
1792
1669
  replaceSources({ source }, requestOptions) {
1793
- if (!source) {
1794
- throw new Error("Parameter `source` is required when calling `replaceSources`.");
1795
- }
1670
+ validateRequired("source", "replaceSources", source);
1796
1671
  const requestPath = "/1/security/sources";
1797
1672
  const headers = {};
1798
1673
  const queryParameters = {};
@@ -1815,9 +1690,7 @@ function createSearchClient({
1815
1690
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1816
1691
  */
1817
1692
  restoreApiKey({ key }, requestOptions) {
1818
- if (!key) {
1819
- throw new Error("Parameter `key` is required when calling `restoreApiKey`.");
1820
- }
1693
+ validateRequired("key", "restoreApiKey", key);
1821
1694
  const requestPath = "/1/keys/{key}/restore".replace("{key}", encodeURIComponent(key));
1822
1695
  const headers = {};
1823
1696
  const queryParameters = {};
@@ -1840,12 +1713,8 @@ function createSearchClient({
1840
1713
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1841
1714
  */
1842
1715
  saveObject({ indexName, body }, requestOptions) {
1843
- if (!indexName) {
1844
- throw new Error("Parameter `indexName` is required when calling `saveObject`.");
1845
- }
1846
- if (!body) {
1847
- throw new Error("Parameter `body` is required when calling `saveObject`.");
1848
- }
1716
+ validateRequired("indexName", "saveObject", indexName);
1717
+ validateRequired("body", "saveObject", body);
1849
1718
  const requestPath = "/1/indexes/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
1850
1719
  const headers = {};
1851
1720
  const queryParameters = {};
@@ -1871,21 +1740,11 @@ function createSearchClient({
1871
1740
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1872
1741
  */
1873
1742
  saveRule({ indexName, objectID, rule, forwardToReplicas }, requestOptions) {
1874
- if (!indexName) {
1875
- throw new Error("Parameter `indexName` is required when calling `saveRule`.");
1876
- }
1877
- if (!objectID) {
1878
- throw new Error("Parameter `objectID` is required when calling `saveRule`.");
1879
- }
1880
- if (!rule) {
1881
- throw new Error("Parameter `rule` is required when calling `saveRule`.");
1882
- }
1883
- if (!rule.objectID) {
1884
- throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
1885
- }
1886
- if (!rule.consequence) {
1887
- throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
1888
- }
1743
+ validateRequired("indexName", "saveRule", indexName);
1744
+ validateRequired("objectID", "saveRule", objectID);
1745
+ validateRequired("rule", "saveRule", rule);
1746
+ validateRequired("rule.objectID", "saveRule", rule.objectID);
1747
+ validateRequired("rule.consequence", "saveRule", rule.consequence);
1889
1748
  const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1890
1749
  const headers = {};
1891
1750
  const queryParameters = {};
@@ -1914,12 +1773,8 @@ function createSearchClient({
1914
1773
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1915
1774
  */
1916
1775
  saveRules({ indexName, rules, forwardToReplicas, clearExistingRules }, requestOptions) {
1917
- if (!indexName) {
1918
- throw new Error("Parameter `indexName` is required when calling `saveRules`.");
1919
- }
1920
- if (!rules) {
1921
- throw new Error("Parameter `rules` is required when calling `saveRules`.");
1922
- }
1776
+ validateRequired("indexName", "saveRules", indexName);
1777
+ validateRequired("rules", "saveRules", rules);
1923
1778
  const requestPath = "/1/indexes/{indexName}/rules/batch".replace("{indexName}", encodeURIComponent(indexName));
1924
1779
  const headers = {};
1925
1780
  const queryParameters = {};
@@ -1951,21 +1806,11 @@ function createSearchClient({
1951
1806
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1952
1807
  */
1953
1808
  saveSynonym({ indexName, objectID, synonymHit, forwardToReplicas }, requestOptions) {
1954
- if (!indexName) {
1955
- throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");
1956
- }
1957
- if (!objectID) {
1958
- throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");
1959
- }
1960
- if (!synonymHit) {
1961
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");
1962
- }
1963
- if (!synonymHit.objectID) {
1964
- throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");
1965
- }
1966
- if (!synonymHit.type) {
1967
- throw new Error("Parameter `synonymHit.type` is required when calling `saveSynonym`.");
1968
- }
1809
+ validateRequired("indexName", "saveSynonym", indexName);
1810
+ validateRequired("objectID", "saveSynonym", objectID);
1811
+ validateRequired("synonymHit", "saveSynonym", synonymHit);
1812
+ validateRequired("synonymHit.objectID", "saveSynonym", synonymHit.objectID);
1813
+ validateRequired("synonymHit.type", "saveSynonym", synonymHit.type);
1969
1814
  const requestPath = "/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
1970
1815
  const headers = {};
1971
1816
  const queryParameters = {};
@@ -1994,12 +1839,8 @@ function createSearchClient({
1994
1839
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1995
1840
  */
1996
1841
  saveSynonyms({ indexName, synonymHit, forwardToReplicas, replaceExistingSynonyms }, requestOptions) {
1997
- if (!indexName) {
1998
- throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");
1999
- }
2000
- if (!synonymHit) {
2001
- throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");
2002
- }
1842
+ validateRequired("indexName", "saveSynonyms", indexName);
1843
+ validateRequired("synonymHit", "saveSynonyms", synonymHit);
2003
1844
  const requestPath = "/1/indexes/{indexName}/synonyms/batch".replace("{indexName}", encodeURIComponent(indexName));
2004
1845
  const headers = {};
2005
1846
  const queryParameters = {};
@@ -2048,12 +1889,8 @@ function createSearchClient({
2048
1889
  };
2049
1890
  searchMethodParams = newSignatureRequest;
2050
1891
  }
2051
- if (!searchMethodParams) {
2052
- throw new Error("Parameter `searchMethodParams` is required when calling `search`.");
2053
- }
2054
- if (!searchMethodParams.requests) {
2055
- throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");
2056
- }
1892
+ validateRequired("searchMethodParams", "search", searchMethodParams);
1893
+ validateRequired("searchMethodParams.requests", "search", searchMethodParams.requests);
2057
1894
  const requestPath = "/1/indexes/*/queries";
2058
1895
  const headers = {};
2059
1896
  const queryParameters = {};
@@ -2079,19 +1916,13 @@ function createSearchClient({
2079
1916
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2080
1917
  */
2081
1918
  searchDictionaryEntries({ dictionaryName, searchDictionaryEntriesParams }, requestOptions) {
2082
- if (!dictionaryName) {
2083
- throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");
2084
- }
2085
- if (!searchDictionaryEntriesParams) {
2086
- throw new Error(
2087
- "Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`."
2088
- );
2089
- }
2090
- if (!searchDictionaryEntriesParams.query) {
2091
- throw new Error(
2092
- "Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`."
2093
- );
2094
- }
1919
+ validateRequired("dictionaryName", "searchDictionaryEntries", dictionaryName);
1920
+ validateRequired("searchDictionaryEntriesParams", "searchDictionaryEntries", searchDictionaryEntriesParams);
1921
+ validateRequired(
1922
+ "searchDictionaryEntriesParams.query",
1923
+ "searchDictionaryEntries",
1924
+ searchDictionaryEntriesParams.query
1925
+ );
2095
1926
  const requestPath = "/1/dictionaries/{dictionaryName}/search".replace(
2096
1927
  "{dictionaryName}",
2097
1928
  encodeURIComponent(dictionaryName)
@@ -2121,12 +1952,8 @@ function createSearchClient({
2121
1952
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2122
1953
  */
2123
1954
  searchForFacetValues({ indexName, facetName, searchForFacetValuesRequest }, requestOptions) {
2124
- if (!indexName) {
2125
- throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");
2126
- }
2127
- if (!facetName) {
2128
- throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");
2129
- }
1955
+ validateRequired("indexName", "searchForFacetValues", indexName);
1956
+ validateRequired("facetName", "searchForFacetValues", facetName);
2130
1957
  const requestPath = "/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}", encodeURIComponent(indexName)).replace("{facetName}", encodeURIComponent(facetName));
2131
1958
  const headers = {};
2132
1959
  const queryParameters = {};
@@ -2152,9 +1979,7 @@ function createSearchClient({
2152
1979
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2153
1980
  */
2154
1981
  searchRules({ indexName, searchRulesParams }, requestOptions) {
2155
- if (!indexName) {
2156
- throw new Error("Parameter `indexName` is required when calling `searchRules`.");
2157
- }
1982
+ validateRequired("indexName", "searchRules", indexName);
2158
1983
  const requestPath = "/1/indexes/{indexName}/rules/search".replace("{indexName}", encodeURIComponent(indexName));
2159
1984
  const headers = {};
2160
1985
  const queryParameters = {};
@@ -2180,9 +2005,7 @@ function createSearchClient({
2180
2005
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2181
2006
  */
2182
2007
  searchSingleIndex({ indexName, searchParams }, requestOptions) {
2183
- if (!indexName) {
2184
- throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");
2185
- }
2008
+ validateRequired("indexName", "searchSingleIndex", indexName);
2186
2009
  const requestPath = "/1/indexes/{indexName}/query".replace("{indexName}", encodeURIComponent(indexName));
2187
2010
  const headers = {};
2188
2011
  const queryParameters = {};
@@ -2208,9 +2031,7 @@ function createSearchClient({
2208
2031
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2209
2032
  */
2210
2033
  searchSynonyms({ indexName, searchSynonymsParams }, requestOptions) {
2211
- if (!indexName) {
2212
- throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");
2213
- }
2034
+ validateRequired("indexName", "searchSynonyms", indexName);
2214
2035
  const requestPath = "/1/indexes/{indexName}/synonyms/search".replace(
2215
2036
  "{indexName}",
2216
2037
  encodeURIComponent(indexName)
@@ -2239,12 +2060,8 @@ function createSearchClient({
2239
2060
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2240
2061
  */
2241
2062
  searchUserIds(searchUserIdsParams, requestOptions) {
2242
- if (!searchUserIdsParams) {
2243
- throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");
2244
- }
2245
- if (!searchUserIdsParams.query) {
2246
- throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");
2247
- }
2063
+ validateRequired("searchUserIdsParams", "searchUserIds", searchUserIdsParams);
2064
+ validateRequired("searchUserIdsParams.query", "searchUserIds", searchUserIdsParams.query);
2248
2065
  const requestPath = "/1/clusters/mapping/search";
2249
2066
  const headers = {};
2250
2067
  const queryParameters = {};
@@ -2268,14 +2085,12 @@ function createSearchClient({
2268
2085
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2269
2086
  */
2270
2087
  setDictionarySettings(dictionarySettingsParams, requestOptions) {
2271
- if (!dictionarySettingsParams) {
2272
- throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");
2273
- }
2274
- if (!dictionarySettingsParams.disableStandardEntries) {
2275
- throw new Error(
2276
- "Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`."
2277
- );
2278
- }
2088
+ validateRequired("dictionarySettingsParams", "setDictionarySettings", dictionarySettingsParams);
2089
+ validateRequired(
2090
+ "dictionarySettingsParams.disableStandardEntries",
2091
+ "setDictionarySettings",
2092
+ dictionarySettingsParams.disableStandardEntries
2093
+ );
2279
2094
  const requestPath = "/1/dictionaries/*/settings";
2280
2095
  const headers = {};
2281
2096
  const queryParameters = {};
@@ -2300,12 +2115,8 @@ function createSearchClient({
2300
2115
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2301
2116
  */
2302
2117
  setSettings({ indexName, indexSettings, forwardToReplicas }, requestOptions) {
2303
- if (!indexName) {
2304
- throw new Error("Parameter `indexName` is required when calling `setSettings`.");
2305
- }
2306
- if (!indexSettings) {
2307
- throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");
2308
- }
2118
+ validateRequired("indexName", "setSettings", indexName);
2119
+ validateRequired("indexSettings", "setSettings", indexSettings);
2309
2120
  const requestPath = "/1/indexes/{indexName}/settings".replace("{indexName}", encodeURIComponent(indexName));
2310
2121
  const headers = {};
2311
2122
  const queryParameters = {};
@@ -2332,15 +2143,9 @@ function createSearchClient({
2332
2143
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2333
2144
  */
2334
2145
  updateApiKey({ key, apiKey }, requestOptions) {
2335
- if (!key) {
2336
- throw new Error("Parameter `key` is required when calling `updateApiKey`.");
2337
- }
2338
- if (!apiKey) {
2339
- throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");
2340
- }
2341
- if (!apiKey.acl) {
2342
- throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");
2343
- }
2146
+ validateRequired("key", "updateApiKey", key);
2147
+ validateRequired("apiKey", "updateApiKey", apiKey);
2148
+ validateRequired("apiKey.acl", "updateApiKey", apiKey.acl);
2344
2149
  const requestPath = "/1/keys/{key}".replace("{key}", encodeURIComponent(key));
2345
2150
  const headers = {};
2346
2151
  const queryParameters = {};