@algolia/client-search 5.2.5 → 5.3.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.
@@ -11,8 +11,15 @@ import {
11
11
  import { createHttpRequester } from "@algolia/requester-node-http";
12
12
 
13
13
  // src/searchClient.ts
14
- import { createAuth, createTransporter, getAlgoliaAgent, shuffle, createIterablePromise } from "@algolia/client-common";
15
- var apiClientVersion = "5.2.5";
14
+ import {
15
+ createAuth,
16
+ createTransporter,
17
+ getAlgoliaAgent,
18
+ shuffle,
19
+ ApiError,
20
+ createIterablePromise
21
+ } from "@algolia/client-common";
22
+ var apiClientVersion = "5.3.1";
16
23
  function getDefaultHosts(appId) {
17
24
  return [
18
25
  {
@@ -53,26 +60,25 @@ function createSearchClient({
53
60
  ...options
54
61
  }) {
55
62
  const auth = createAuth(appIdOption, apiKeyOption, authMode);
56
- const transporter = createTransporter({
57
- hosts: getDefaultHosts(appIdOption),
58
- ...options,
59
- algoliaAgent: getAlgoliaAgent({
60
- algoliaAgents,
61
- client: "Search",
62
- version: apiClientVersion
63
- }),
64
- baseHeaders: {
65
- "content-type": "text/plain",
66
- ...auth.headers(),
67
- ...options.baseHeaders
68
- },
69
- baseQueryParameters: {
70
- ...auth.queryParameters(),
71
- ...options.baseQueryParameters
72
- }
73
- });
74
63
  return {
75
- transporter,
64
+ transporter: createTransporter({
65
+ hosts: getDefaultHosts(appIdOption),
66
+ ...options,
67
+ algoliaAgent: getAlgoliaAgent({
68
+ algoliaAgents,
69
+ client: "Search",
70
+ version: apiClientVersion
71
+ }),
72
+ baseHeaders: {
73
+ "content-type": "text/plain",
74
+ ...auth.headers(),
75
+ ...options.baseHeaders
76
+ },
77
+ baseQueryParameters: {
78
+ ...auth.queryParameters(),
79
+ ...options.baseQueryParameters
80
+ }
81
+ }),
76
82
  /**
77
83
  * The `appId` currently in use.
78
84
  */
@@ -81,13 +87,15 @@ function createSearchClient({
81
87
  * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
82
88
  */
83
89
  clearCache() {
84
- return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
90
+ return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
91
+ () => void 0
92
+ );
85
93
  },
86
94
  /**
87
95
  * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
88
96
  */
89
97
  get _ua() {
90
- return transporter.algoliaAgent.value;
98
+ return this.transporter.algoliaAgent.value;
91
99
  },
92
100
  /**
93
101
  * Adds a `segment` to the `x-algolia-agent` sent with every requests.
@@ -96,7 +104,20 @@ function createSearchClient({
96
104
  * @param version - The version of the agent.
97
105
  */
98
106
  addAlgoliaAgent(segment, version) {
99
- transporter.algoliaAgent.add({ segment, version });
107
+ this.transporter.algoliaAgent.add({ segment, version });
108
+ },
109
+ /**
110
+ * Helper method to switch the API key used to authenticate the requests.
111
+ *
112
+ * @param params - Method params.
113
+ * @param params.apiKey - The new API Key to use.
114
+ */
115
+ setClientApiKey({ apiKey }) {
116
+ if (!authMode || authMode === "WithinHeaders") {
117
+ this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
118
+ } else {
119
+ this.transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
120
+ }
100
121
  },
101
122
  /**
102
123
  * Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
@@ -460,6 +481,17 @@ function createSearchClient({
460
481
  });
461
482
  return { copyOperationResponse, batchResponses, moveOperationResponse };
462
483
  },
484
+ async indexExists({ indexName }) {
485
+ try {
486
+ await this.getSettings({ indexName });
487
+ } catch (error) {
488
+ if (error instanceof ApiError && error.status === 404) {
489
+ return false;
490
+ }
491
+ throw error;
492
+ }
493
+ return true;
494
+ },
463
495
  /**
464
496
  * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
465
497
  * Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes.
@@ -508,7 +540,7 @@ function createSearchClient({
508
540
  headers,
509
541
  data: apiKey
510
542
  };
511
- return transporter.request(request, requestOptions);
543
+ return this.transporter.request(request, requestOptions);
512
544
  },
513
545
  /**
514
546
  * If a record with the specified object ID exists, the existing record is replaced. Otherwise, a new record is added to the index. To update _some_ attributes of an existing record, use the [`partial` operation](#tag/Records/operation/partialUpdateObject) instead. To add, update, or replace multiple records, use the [`batch` operation](#tag/Records/operation/batch).
@@ -542,7 +574,7 @@ function createSearchClient({
542
574
  headers,
543
575
  data: body
544
576
  };
545
- return transporter.request(request, requestOptions);
577
+ return this.transporter.request(request, requestOptions);
546
578
  },
547
579
  /**
548
580
  * Adds a source to the list of allowed sources.
@@ -570,7 +602,7 @@ function createSearchClient({
570
602
  headers,
571
603
  data: source
572
604
  };
573
- return transporter.request(request, requestOptions);
605
+ return this.transporter.request(request, requestOptions);
574
606
  },
575
607
  /**
576
608
  * Assigns or moves a user ID to a cluster. The time it takes to move a user is proportional to the amount of data linked to the user ID.
@@ -606,7 +638,7 @@ function createSearchClient({
606
638
  headers,
607
639
  data: assignUserIdParams
608
640
  };
609
- return transporter.request(request, requestOptions);
641
+ return this.transporter.request(request, requestOptions);
610
642
  },
611
643
  /**
612
644
  * Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they\'re specified. - Actions are equivalent to the individual API requests of the same name.
@@ -636,7 +668,7 @@ function createSearchClient({
636
668
  headers,
637
669
  data: batchWriteParams
638
670
  };
639
- return transporter.request(request, requestOptions);
671
+ return this.transporter.request(request, requestOptions);
640
672
  },
641
673
  /**
642
674
  * Assigns multiple user IDs to a cluster. **You can\'t move users with this operation**.
@@ -675,7 +707,7 @@ function createSearchClient({
675
707
  headers,
676
708
  data: batchAssignUserIdsParams
677
709
  };
678
- return transporter.request(request, requestOptions);
710
+ return this.transporter.request(request, requestOptions);
679
711
  },
680
712
  /**
681
713
  * Adds or deletes multiple entries from your plurals, segmentation, or stop word dictionaries.
@@ -713,7 +745,7 @@ function createSearchClient({
713
745
  headers,
714
746
  data: batchDictionaryEntriesParams
715
747
  };
716
- return transporter.request(request, requestOptions);
748
+ return this.transporter.request(request, requestOptions);
717
749
  },
718
750
  /**
719
751
  * Retrieves records from an index, up to 1,000 per request. While searching retrieves _hits_ (records augmented with attributes for highlighting and ranking details), browsing _just_ returns matching records. This can be useful if you want to export your indices. - The Analytics API doesn\'t collect data when using `browse`. - Records are ranked by attributes and custom ranking. - There\'s no ranking for: typo-tolerance, number of matched words, proximity, geo distance. Browse requests automatically apply these settings: - `advancedSyntax`: `false` - `attributesToHighlight`: `[]` - `attributesToSnippet`: `[]` - `distinct`: `false` - `enablePersonalization`: `false` - `enableRules`: `false` - `facets`: `[]` - `getRankingInfo`: `false` - `ignorePlurals`: `false` - `optionalFilters`: `[]` - `typoTolerance`: `true` or `false` (`min` and `strict` is evaluated to `true`) If you send these parameters with your browse requests, they\'ll be ignored.
@@ -740,7 +772,7 @@ function createSearchClient({
740
772
  headers,
741
773
  data: browseParams ? browseParams : {}
742
774
  };
743
- return transporter.request(request, requestOptions);
775
+ return this.transporter.request(request, requestOptions);
744
776
  },
745
777
  /**
746
778
  * Deletes only the records from an index while keeping settings, synonyms, and rules.
@@ -765,7 +797,7 @@ function createSearchClient({
765
797
  queryParameters,
766
798
  headers
767
799
  };
768
- return transporter.request(request, requestOptions);
800
+ return this.transporter.request(request, requestOptions);
769
801
  },
770
802
  /**
771
803
  * Deletes all rules from the index.
@@ -794,7 +826,7 @@ function createSearchClient({
794
826
  queryParameters,
795
827
  headers
796
828
  };
797
- return transporter.request(request, requestOptions);
829
+ return this.transporter.request(request, requestOptions);
798
830
  },
799
831
  /**
800
832
  * Deletes all synonyms from the index.
@@ -823,7 +855,7 @@ function createSearchClient({
823
855
  queryParameters,
824
856
  headers
825
857
  };
826
- return transporter.request(request, requestOptions);
858
+ return this.transporter.request(request, requestOptions);
827
859
  },
828
860
  /**
829
861
  * This method allow you to send requests to the Algolia REST API.
@@ -846,7 +878,7 @@ function createSearchClient({
846
878
  queryParameters,
847
879
  headers
848
880
  };
849
- return transporter.request(request, requestOptions);
881
+ return this.transporter.request(request, requestOptions);
850
882
  },
851
883
  /**
852
884
  * This method allow you to send requests to the Algolia REST API.
@@ -869,7 +901,7 @@ function createSearchClient({
869
901
  queryParameters,
870
902
  headers
871
903
  };
872
- return transporter.request(request, requestOptions);
904
+ return this.transporter.request(request, requestOptions);
873
905
  },
874
906
  /**
875
907
  * This method allow you to send requests to the Algolia REST API.
@@ -894,7 +926,7 @@ function createSearchClient({
894
926
  headers,
895
927
  data: body ? body : {}
896
928
  };
897
- return transporter.request(request, requestOptions);
929
+ return this.transporter.request(request, requestOptions);
898
930
  },
899
931
  /**
900
932
  * This method allow you to send requests to the Algolia REST API.
@@ -919,7 +951,7 @@ function createSearchClient({
919
951
  headers,
920
952
  data: body ? body : {}
921
953
  };
922
- return transporter.request(request, requestOptions);
954
+ return this.transporter.request(request, requestOptions);
923
955
  },
924
956
  /**
925
957
  * Deletes the API key.
@@ -944,7 +976,7 @@ function createSearchClient({
944
976
  queryParameters,
945
977
  headers
946
978
  };
947
- return transporter.request(request, requestOptions);
979
+ return this.transporter.request(request, requestOptions);
948
980
  },
949
981
  /**
950
982
  * This operation doesn\'t accept empty queries or filters. It\'s more efficient to get a list of object IDs with the [`browse` operation](#tag/Search/operation/browse), and then delete the records using the [`batch` operation](#tag/Records/operation/batch).
@@ -974,7 +1006,7 @@ function createSearchClient({
974
1006
  headers,
975
1007
  data: deleteByParams
976
1008
  };
977
- return transporter.request(request, requestOptions);
1009
+ return this.transporter.request(request, requestOptions);
978
1010
  },
979
1011
  /**
980
1012
  * Deletes an index and all its settings. - Deleting an index doesn\'t delete its analytics data. - If you try to delete a non-existing index, the operation is ignored without warning. - If the index you want to delete has replica indices, the replicas become independent indices. - If the index you want to delete is a replica index, you must first unlink it from its primary index before you can delete it. For more information, see [Delete replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/how-to/deleting-replicas/).
@@ -999,7 +1031,7 @@ function createSearchClient({
999
1031
  queryParameters,
1000
1032
  headers
1001
1033
  };
1002
- return transporter.request(request, requestOptions);
1034
+ return this.transporter.request(request, requestOptions);
1003
1035
  },
1004
1036
  /**
1005
1037
  * Deletes a record by its object ID. To delete more than one record, use the [`batch` operation](#tag/Records/operation/batch). To delete records matching a query, use the [`deleteByQuery` operation](#tag/Records/operation/deleteBy).
@@ -1028,7 +1060,7 @@ function createSearchClient({
1028
1060
  queryParameters,
1029
1061
  headers
1030
1062
  };
1031
- return transporter.request(request, requestOptions);
1063
+ return this.transporter.request(request, requestOptions);
1032
1064
  },
1033
1065
  /**
1034
1066
  * Deletes a rule by its ID. To find the object ID for rules, use the [`search` operation](#tag/Rules/operation/searchRules).
@@ -1061,7 +1093,7 @@ function createSearchClient({
1061
1093
  queryParameters,
1062
1094
  headers
1063
1095
  };
1064
- return transporter.request(request, requestOptions);
1096
+ return this.transporter.request(request, requestOptions);
1065
1097
  },
1066
1098
  /**
1067
1099
  * Deletes a source from the list of allowed sources.
@@ -1086,7 +1118,7 @@ function createSearchClient({
1086
1118
  queryParameters,
1087
1119
  headers
1088
1120
  };
1089
- return transporter.request(request, requestOptions);
1121
+ return this.transporter.request(request, requestOptions);
1090
1122
  },
1091
1123
  /**
1092
1124
  * Deletes a synonym by its ID. To find the object IDs of your synonyms, use the [`search` operation](#tag/Synonyms/operation/searchSynonyms).
@@ -1119,7 +1151,7 @@ function createSearchClient({
1119
1151
  queryParameters,
1120
1152
  headers
1121
1153
  };
1122
- return transporter.request(request, requestOptions);
1154
+ return this.transporter.request(request, requestOptions);
1123
1155
  },
1124
1156
  /**
1125
1157
  * Gets the permissions and restrictions of an API key. When authenticating with the admin API key, you can request information for any of your application\'s keys. When authenticating with other API keys, you can only retrieve information for that key.
@@ -1141,7 +1173,7 @@ function createSearchClient({
1141
1173
  queryParameters,
1142
1174
  headers
1143
1175
  };
1144
- return transporter.request(request, requestOptions);
1176
+ return this.transporter.request(request, requestOptions);
1145
1177
  },
1146
1178
  /**
1147
1179
  * Checks the status of a given application task.
@@ -1166,7 +1198,7 @@ function createSearchClient({
1166
1198
  queryParameters,
1167
1199
  headers
1168
1200
  };
1169
- return transporter.request(request, requestOptions);
1201
+ return this.transporter.request(request, requestOptions);
1170
1202
  },
1171
1203
  /**
1172
1204
  * Lists supported languages with their supported dictionary types and number of custom entries.
@@ -1186,7 +1218,7 @@ function createSearchClient({
1186
1218
  queryParameters,
1187
1219
  headers
1188
1220
  };
1189
- return transporter.request(request, requestOptions);
1221
+ return this.transporter.request(request, requestOptions);
1190
1222
  },
1191
1223
  /**
1192
1224
  * Retrieves the languages for which standard dictionary entries are turned off.
@@ -1206,7 +1238,7 @@ function createSearchClient({
1206
1238
  queryParameters,
1207
1239
  headers
1208
1240
  };
1209
- return transporter.request(request, requestOptions);
1241
+ return this.transporter.request(request, requestOptions);
1210
1242
  },
1211
1243
  /**
1212
1244
  * The request must be authenticated by an API key with the [`logs` ACL](https://www.algolia.com/doc/guides/security/api-keys/#access-control-list-acl). - Logs are held for the last seven days. - Up to 1,000 API requests per server are logged. - This request counts towards your [operations quota](https://support.algolia.com/hc/en-us/articles/4406981829777-How-does-Algolia-count-records-and-operations-) but doesn\'t appear in the logs itself.
@@ -1243,7 +1275,7 @@ function createSearchClient({
1243
1275
  queryParameters,
1244
1276
  headers
1245
1277
  };
1246
- return transporter.request(request, requestOptions);
1278
+ return this.transporter.request(request, requestOptions);
1247
1279
  },
1248
1280
  /**
1249
1281
  * Retrieves one record by its object ID. To retrieve more than one record, use the [`objects` operation](#tag/Records/operation/getObjects).
@@ -1276,7 +1308,7 @@ function createSearchClient({
1276
1308
  queryParameters,
1277
1309
  headers
1278
1310
  };
1279
- return transporter.request(request, requestOptions);
1311
+ return this.transporter.request(request, requestOptions);
1280
1312
  },
1281
1313
  /**
1282
1314
  * Retrieves one or more records, potentially from different indices. Records are returned in the same order as the requests.
@@ -1306,7 +1338,7 @@ function createSearchClient({
1306
1338
  useReadTransporter: true,
1307
1339
  cacheable: true
1308
1340
  };
1309
- return transporter.request(request, requestOptions);
1341
+ return this.transporter.request(request, requestOptions);
1310
1342
  },
1311
1343
  /**
1312
1344
  * Retrieves a rule by its ID. To find the object ID of rules, use the [`search` operation](#tag/Rules/operation/searchRules).
@@ -1335,7 +1367,7 @@ function createSearchClient({
1335
1367
  queryParameters,
1336
1368
  headers
1337
1369
  };
1338
- return transporter.request(request, requestOptions);
1370
+ return this.transporter.request(request, requestOptions);
1339
1371
  },
1340
1372
  /**
1341
1373
  * Retrieves an object with non-null index settings.
@@ -1360,7 +1392,7 @@ function createSearchClient({
1360
1392
  queryParameters,
1361
1393
  headers
1362
1394
  };
1363
- return transporter.request(request, requestOptions);
1395
+ return this.transporter.request(request, requestOptions);
1364
1396
  },
1365
1397
  /**
1366
1398
  * Retrieves all allowed IP addresses with access to your application.
@@ -1380,7 +1412,7 @@ function createSearchClient({
1380
1412
  queryParameters,
1381
1413
  headers
1382
1414
  };
1383
- return transporter.request(request, requestOptions);
1415
+ return this.transporter.request(request, requestOptions);
1384
1416
  },
1385
1417
  /**
1386
1418
  * Retrieves a syonym by its ID. To find the object IDs for your synonyms, use the [`search` operation](#tag/Synonyms/operation/searchSynonyms).
@@ -1409,7 +1441,7 @@ function createSearchClient({
1409
1441
  queryParameters,
1410
1442
  headers
1411
1443
  };
1412
- return transporter.request(request, requestOptions);
1444
+ return this.transporter.request(request, requestOptions);
1413
1445
  },
1414
1446
  /**
1415
1447
  * Checks the status of a given task. Indexing tasks are asynchronous. When you add, update, or delete records or indices, a task is created on a queue and completed depending on the load on the server. The indexing tasks\' responses include a task ID that you can use to check the status.
@@ -1438,7 +1470,7 @@ function createSearchClient({
1438
1470
  queryParameters,
1439
1471
  headers
1440
1472
  };
1441
- return transporter.request(request, requestOptions);
1473
+ return this.transporter.request(request, requestOptions);
1442
1474
  },
1443
1475
  /**
1444
1476
  * Get the IDs of the 10 users with the highest number of records per cluster. Since it can take a few seconds to get the data from the different clusters, the response isn\'t real-time.
@@ -1458,7 +1490,7 @@ function createSearchClient({
1458
1490
  queryParameters,
1459
1491
  headers
1460
1492
  };
1461
- return transporter.request(request, requestOptions);
1493
+ return this.transporter.request(request, requestOptions);
1462
1494
  },
1463
1495
  /**
1464
1496
  * Returns the user ID data stored in the mapping. Since it can take a few seconds to get the data from the different clusters, the response isn\'t real-time.
@@ -1483,7 +1515,7 @@ function createSearchClient({
1483
1515
  queryParameters,
1484
1516
  headers
1485
1517
  };
1486
- return transporter.request(request, requestOptions);
1518
+ return this.transporter.request(request, requestOptions);
1487
1519
  },
1488
1520
  /**
1489
1521
  * To determine when the time-consuming process of creating a large batch of users or migrating users from one cluster to another is complete, this operation retrieves the status of the process.
@@ -1508,7 +1540,7 @@ function createSearchClient({
1508
1540
  queryParameters,
1509
1541
  headers
1510
1542
  };
1511
- return transporter.request(request, requestOptions);
1543
+ return this.transporter.request(request, requestOptions);
1512
1544
  },
1513
1545
  /**
1514
1546
  * Lists all API keys associated with your Algolia application, including their permissions and restrictions.
@@ -1528,7 +1560,7 @@ function createSearchClient({
1528
1560
  queryParameters,
1529
1561
  headers
1530
1562
  };
1531
- return transporter.request(request, requestOptions);
1563
+ return this.transporter.request(request, requestOptions);
1532
1564
  },
1533
1565
  /**
1534
1566
  * Lists the available clusters in a multi-cluster setup.
@@ -1548,7 +1580,7 @@ function createSearchClient({
1548
1580
  queryParameters,
1549
1581
  headers
1550
1582
  };
1551
- return transporter.request(request, requestOptions);
1583
+ return this.transporter.request(request, requestOptions);
1552
1584
  },
1553
1585
  /**
1554
1586
  * Lists all indices in the current Algolia application. The request follows any index restrictions of the API key you use to make the request.
@@ -1577,7 +1609,7 @@ function createSearchClient({
1577
1609
  queryParameters,
1578
1610
  headers
1579
1611
  };
1580
- return transporter.request(request, requestOptions);
1612
+ return this.transporter.request(request, requestOptions);
1581
1613
  },
1582
1614
  /**
1583
1615
  * Lists the userIDs assigned to a multi-cluster application. Since it can take a few seconds to get the data from the different clusters, the response isn\'t real-time.
@@ -1606,7 +1638,7 @@ function createSearchClient({
1606
1638
  queryParameters,
1607
1639
  headers
1608
1640
  };
1609
- return transporter.request(request, requestOptions);
1641
+ return this.transporter.request(request, requestOptions);
1610
1642
  },
1611
1643
  /**
1612
1644
  * Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name.
@@ -1631,7 +1663,7 @@ function createSearchClient({
1631
1663
  headers,
1632
1664
  data: batchParams
1633
1665
  };
1634
- return transporter.request(request, requestOptions);
1666
+ return this.transporter.request(request, requestOptions);
1635
1667
  },
1636
1668
  /**
1637
1669
  * Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn\'t exist yet, it\'ll be created. **Copy** - Copying a source index that doesn\'t exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can\'t copy the `enableReRanking`, `mode`, and `replicas` settings. - You can\'t copy to a destination index that already has replicas. - Be aware of the [size limits](https://www.algolia.com/doc/guides/scaling/algolia-service-limits/#application-record-and-index-limits). - Related guide: [Copy indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/copy-indices/) **Move** - Moving a source index that doesn\'t exist is ignored without returning an error. - When moving an index, the analytics data keep their original name and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: [Move indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/move-indices/).
@@ -1667,7 +1699,7 @@ function createSearchClient({
1667
1699
  headers,
1668
1700
  data: operationIndexParams
1669
1701
  };
1670
- return transporter.request(request, requestOptions);
1702
+ return this.transporter.request(request, requestOptions);
1671
1703
  },
1672
1704
  /**
1673
1705
  * Adds new attributes to a record, or update existing ones. - If a record with the specified object ID doesn\'t exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn\'t exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, the engine treats it as a replacement for its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don\'t have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it\'s not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn\'t exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn\'t exist yet, the engine only creates it if you pass an IncrementSet value that\'s greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove.
@@ -1705,7 +1737,7 @@ function createSearchClient({
1705
1737
  headers,
1706
1738
  data: attributesToUpdate
1707
1739
  };
1708
- return transporter.request(request, requestOptions);
1740
+ return this.transporter.request(request, requestOptions);
1709
1741
  },
1710
1742
  /**
1711
1743
  * Deletes a user ID and its associated data from the clusters.
@@ -1730,7 +1762,7 @@ function createSearchClient({
1730
1762
  queryParameters,
1731
1763
  headers
1732
1764
  };
1733
- return transporter.request(request, requestOptions);
1765
+ return this.transporter.request(request, requestOptions);
1734
1766
  },
1735
1767
  /**
1736
1768
  * Replaces the list of allowed sources.
@@ -1756,7 +1788,7 @@ function createSearchClient({
1756
1788
  headers,
1757
1789
  data: source
1758
1790
  };
1759
- return transporter.request(request, requestOptions);
1791
+ return this.transporter.request(request, requestOptions);
1760
1792
  },
1761
1793
  /**
1762
1794
  * Restores a deleted API key. Restoring resets the `validity` attribute to `0`. Algolia stores up to 1,000 API keys per application. If you create more, the oldest API keys are deleted and can\'t be restored.
@@ -1781,7 +1813,7 @@ function createSearchClient({
1781
1813
  queryParameters,
1782
1814
  headers
1783
1815
  };
1784
- return transporter.request(request, requestOptions);
1816
+ return this.transporter.request(request, requestOptions);
1785
1817
  },
1786
1818
  /**
1787
1819
  * Adds a record to an index or replace it. - If the record doesn\'t have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn\'t exist, a new record is added to your index. - If you add a record to an index that doesn\'t exist yet, a new index is created. To update _some_ attributes of a record, use the [`partial` operation](#tag/Records/operation/partialUpdateObject). To add, update, or replace multiple records, use the [`batch` operation](#tag/Records/operation/batch).
@@ -1811,7 +1843,7 @@ function createSearchClient({
1811
1843
  headers,
1812
1844
  data: body
1813
1845
  };
1814
- return transporter.request(request, requestOptions);
1846
+ return this.transporter.request(request, requestOptions);
1815
1847
  },
1816
1848
  /**
1817
1849
  * If a rule with the specified object ID doesn\'t exist, it\'s created. Otherwise, the existing rule is replaced. To create or update more than one rule, use the [`batch` operation](#tag/Rules/operation/saveRules).
@@ -1852,7 +1884,7 @@ function createSearchClient({
1852
1884
  headers,
1853
1885
  data: rule
1854
1886
  };
1855
- return transporter.request(request, requestOptions);
1887
+ return this.transporter.request(request, requestOptions);
1856
1888
  },
1857
1889
  /**
1858
1890
  * Create or update multiple rules. If a rule with the specified object ID doesn\'t exist, Algolia creates a new one. Otherwise, existing rules are replaced.
@@ -1890,7 +1922,7 @@ function createSearchClient({
1890
1922
  headers,
1891
1923
  data: rules
1892
1924
  };
1893
- return transporter.request(request, requestOptions);
1925
+ return this.transporter.request(request, requestOptions);
1894
1926
  },
1895
1927
  /**
1896
1928
  * If a synonym with the specified object ID doesn\'t exist, Algolia adds a new one. Otherwise, the existing synonym is replaced. To add multiple synonyms in a single API request, use the [`batch` operation](#tag/Synonyms/operation/saveSynonyms).
@@ -1934,7 +1966,7 @@ function createSearchClient({
1934
1966
  headers,
1935
1967
  data: synonymHit
1936
1968
  };
1937
- return transporter.request(request, requestOptions);
1969
+ return this.transporter.request(request, requestOptions);
1938
1970
  },
1939
1971
  /**
1940
1972
  * If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced.
@@ -1972,7 +2004,7 @@ function createSearchClient({
1972
2004
  headers,
1973
2005
  data: synonymHit
1974
2006
  };
1975
- return transporter.request(request, requestOptions);
2007
+ return this.transporter.request(request, requestOptions);
1976
2008
  },
1977
2009
  /**
1978
2010
  * Sends multiple search request to one or more indices. This can be useful in these cases: - Different indices for different purposes, such as, one index for products, another one for marketing content. - Multiple searches to the same index—for example, with different filters.
@@ -2023,7 +2055,7 @@ function createSearchClient({
2023
2055
  useReadTransporter: true,
2024
2056
  cacheable: true
2025
2057
  };
2026
- return transporter.request(request, requestOptions);
2058
+ return this.transporter.request(request, requestOptions);
2027
2059
  },
2028
2060
  /**
2029
2061
  * Searches for standard and custom dictionary entries.
@@ -2065,7 +2097,7 @@ function createSearchClient({
2065
2097
  useReadTransporter: true,
2066
2098
  cacheable: true
2067
2099
  };
2068
- return transporter.request(request, requestOptions);
2100
+ return this.transporter.request(request, requestOptions);
2069
2101
  },
2070
2102
  /**
2071
2103
  * Searches for values of a specified facet attribute. - By default, facet values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching for facet values doesn\'t work if you have **more than 65 searchable facets and searchable attributes combined**.
@@ -2098,7 +2130,7 @@ function createSearchClient({
2098
2130
  useReadTransporter: true,
2099
2131
  cacheable: true
2100
2132
  };
2101
- return transporter.request(request, requestOptions);
2133
+ return this.transporter.request(request, requestOptions);
2102
2134
  },
2103
2135
  /**
2104
2136
  * Searches for rules in your index.
@@ -2127,7 +2159,7 @@ function createSearchClient({
2127
2159
  useReadTransporter: true,
2128
2160
  cacheable: true
2129
2161
  };
2130
- return transporter.request(request, requestOptions);
2162
+ return this.transporter.request(request, requestOptions);
2131
2163
  },
2132
2164
  /**
2133
2165
  * Searches a single index and return matching search results (_hits_). This method lets you retrieve up to 1,000 hits. If you need more, use the [`browse` operation](#tag/Search/operation/browse) or increase the `paginatedLimitedTo` index setting.
@@ -2156,7 +2188,7 @@ function createSearchClient({
2156
2188
  useReadTransporter: true,
2157
2189
  cacheable: true
2158
2190
  };
2159
- return transporter.request(request, requestOptions);
2191
+ return this.transporter.request(request, requestOptions);
2160
2192
  },
2161
2193
  /**
2162
2194
  * Searches for synonyms in your index.
@@ -2188,7 +2220,7 @@ function createSearchClient({
2188
2220
  useReadTransporter: true,
2189
2221
  cacheable: true
2190
2222
  };
2191
- return transporter.request(request, requestOptions);
2223
+ return this.transporter.request(request, requestOptions);
2192
2224
  },
2193
2225
  /**
2194
2226
  * Since it can take a few seconds to get the data from the different clusters, the response isn\'t real-time. To ensure rapid updates, the user IDs index isn\'t built at the same time as the mapping. Instead, it\'s built every 12 hours, at the same time as the update of user ID usage. For example, if you add or move a user ID, the search will show an old value until the next time the mapping is rebuilt (every 12 hours).
@@ -2218,7 +2250,7 @@ function createSearchClient({
2218
2250
  useReadTransporter: true,
2219
2251
  cacheable: true
2220
2252
  };
2221
- return transporter.request(request, requestOptions);
2253
+ return this.transporter.request(request, requestOptions);
2222
2254
  },
2223
2255
  /**
2224
2256
  * Turns standard stop word dictionary entries on or off for a given language.
@@ -2248,7 +2280,7 @@ function createSearchClient({
2248
2280
  headers,
2249
2281
  data: dictionarySettingsParams
2250
2282
  };
2251
- return transporter.request(request, requestOptions);
2283
+ return this.transporter.request(request, requestOptions);
2252
2284
  },
2253
2285
  /**
2254
2286
  * Update the specified index settings. Index settings that you don\'t specify are left unchanged. Specify `null` to reset a setting to its default value. For best performance, update the index settings before you add new records to your index.
@@ -2282,7 +2314,7 @@ function createSearchClient({
2282
2314
  headers,
2283
2315
  data: indexSettings
2284
2316
  };
2285
- return transporter.request(request, requestOptions);
2317
+ return this.transporter.request(request, requestOptions);
2286
2318
  },
2287
2319
  /**
2288
2320
  * Replaces the permissions of an existing API key. Any unspecified attribute resets that attribute to its default value.
@@ -2315,7 +2347,7 @@ function createSearchClient({
2315
2347
  headers,
2316
2348
  data: apiKey
2317
2349
  };
2318
- return transporter.request(request, requestOptions);
2350
+ return this.transporter.request(request, requestOptions);
2319
2351
  }
2320
2352
  };
2321
2353
  }
@@ -2352,7 +2384,7 @@ function searchClient(appId, apiKey, options) {
2352
2384
  * @param generateSecuredApiKey.parentApiKey - The base API key from which to generate the new secured one.
2353
2385
  * @param generateSecuredApiKey.restrictions - A set of properties defining the restrictions of the secured API key.
2354
2386
  */
2355
- generateSecuredApiKey({ parentApiKey, restrictions = {} }) {
2387
+ generateSecuredApiKey: ({ parentApiKey, restrictions = {} }) => {
2356
2388
  let mergedRestrictions = restrictions;
2357
2389
  if (restrictions.searchParams) {
2358
2390
  mergedRestrictions = {
@@ -2380,7 +2412,7 @@ function searchClient(appId, apiKey, options) {
2380
2412
  * @param getSecuredApiKeyRemainingValidity - The `getSecuredApiKeyRemainingValidity` object.
2381
2413
  * @param getSecuredApiKeyRemainingValidity.securedApiKey - The secured API key generated with the `generateSecuredApiKey` method.
2382
2414
  */
2383
- getSecuredApiKeyRemainingValidity({ securedApiKey }) {
2415
+ getSecuredApiKeyRemainingValidity: ({ securedApiKey }) => {
2384
2416
  const decodedString = Buffer.from(securedApiKey, "base64").toString("ascii");
2385
2417
  const regex = /validUntil=(\d+)/;
2386
2418
  const match = decodedString.match(regex);