@algolia/client-search 5.2.5 → 5.3.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.
@@ -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.0";
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,16 @@ 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
+ this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
100
117
  },
101
118
  /**
102
119
  * Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
@@ -460,6 +477,17 @@ function createSearchClient({
460
477
  });
461
478
  return { copyOperationResponse, batchResponses, moveOperationResponse };
462
479
  },
480
+ async indexExists({ indexName }) {
481
+ try {
482
+ await this.getSettings({ indexName });
483
+ } catch (error) {
484
+ if (error instanceof ApiError && error.status === 404) {
485
+ return false;
486
+ }
487
+ throw error;
488
+ }
489
+ return true;
490
+ },
463
491
  /**
464
492
  * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
465
493
  * 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 +536,7 @@ function createSearchClient({
508
536
  headers,
509
537
  data: apiKey
510
538
  };
511
- return transporter.request(request, requestOptions);
539
+ return this.transporter.request(request, requestOptions);
512
540
  },
513
541
  /**
514
542
  * 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 +570,7 @@ function createSearchClient({
542
570
  headers,
543
571
  data: body
544
572
  };
545
- return transporter.request(request, requestOptions);
573
+ return this.transporter.request(request, requestOptions);
546
574
  },
547
575
  /**
548
576
  * Adds a source to the list of allowed sources.
@@ -570,7 +598,7 @@ function createSearchClient({
570
598
  headers,
571
599
  data: source
572
600
  };
573
- return transporter.request(request, requestOptions);
601
+ return this.transporter.request(request, requestOptions);
574
602
  },
575
603
  /**
576
604
  * 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 +634,7 @@ function createSearchClient({
606
634
  headers,
607
635
  data: assignUserIdParams
608
636
  };
609
- return transporter.request(request, requestOptions);
637
+ return this.transporter.request(request, requestOptions);
610
638
  },
611
639
  /**
612
640
  * 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 +664,7 @@ function createSearchClient({
636
664
  headers,
637
665
  data: batchWriteParams
638
666
  };
639
- return transporter.request(request, requestOptions);
667
+ return this.transporter.request(request, requestOptions);
640
668
  },
641
669
  /**
642
670
  * Assigns multiple user IDs to a cluster. **You can\'t move users with this operation**.
@@ -675,7 +703,7 @@ function createSearchClient({
675
703
  headers,
676
704
  data: batchAssignUserIdsParams
677
705
  };
678
- return transporter.request(request, requestOptions);
706
+ return this.transporter.request(request, requestOptions);
679
707
  },
680
708
  /**
681
709
  * Adds or deletes multiple entries from your plurals, segmentation, or stop word dictionaries.
@@ -713,7 +741,7 @@ function createSearchClient({
713
741
  headers,
714
742
  data: batchDictionaryEntriesParams
715
743
  };
716
- return transporter.request(request, requestOptions);
744
+ return this.transporter.request(request, requestOptions);
717
745
  },
718
746
  /**
719
747
  * 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 +768,7 @@ function createSearchClient({
740
768
  headers,
741
769
  data: browseParams ? browseParams : {}
742
770
  };
743
- return transporter.request(request, requestOptions);
771
+ return this.transporter.request(request, requestOptions);
744
772
  },
745
773
  /**
746
774
  * Deletes only the records from an index while keeping settings, synonyms, and rules.
@@ -765,7 +793,7 @@ function createSearchClient({
765
793
  queryParameters,
766
794
  headers
767
795
  };
768
- return transporter.request(request, requestOptions);
796
+ return this.transporter.request(request, requestOptions);
769
797
  },
770
798
  /**
771
799
  * Deletes all rules from the index.
@@ -794,7 +822,7 @@ function createSearchClient({
794
822
  queryParameters,
795
823
  headers
796
824
  };
797
- return transporter.request(request, requestOptions);
825
+ return this.transporter.request(request, requestOptions);
798
826
  },
799
827
  /**
800
828
  * Deletes all synonyms from the index.
@@ -823,7 +851,7 @@ function createSearchClient({
823
851
  queryParameters,
824
852
  headers
825
853
  };
826
- return transporter.request(request, requestOptions);
854
+ return this.transporter.request(request, requestOptions);
827
855
  },
828
856
  /**
829
857
  * This method allow you to send requests to the Algolia REST API.
@@ -846,7 +874,7 @@ function createSearchClient({
846
874
  queryParameters,
847
875
  headers
848
876
  };
849
- return transporter.request(request, requestOptions);
877
+ return this.transporter.request(request, requestOptions);
850
878
  },
851
879
  /**
852
880
  * This method allow you to send requests to the Algolia REST API.
@@ -869,7 +897,7 @@ function createSearchClient({
869
897
  queryParameters,
870
898
  headers
871
899
  };
872
- return transporter.request(request, requestOptions);
900
+ return this.transporter.request(request, requestOptions);
873
901
  },
874
902
  /**
875
903
  * This method allow you to send requests to the Algolia REST API.
@@ -894,7 +922,7 @@ function createSearchClient({
894
922
  headers,
895
923
  data: body ? body : {}
896
924
  };
897
- return transporter.request(request, requestOptions);
925
+ return this.transporter.request(request, requestOptions);
898
926
  },
899
927
  /**
900
928
  * This method allow you to send requests to the Algolia REST API.
@@ -919,7 +947,7 @@ function createSearchClient({
919
947
  headers,
920
948
  data: body ? body : {}
921
949
  };
922
- return transporter.request(request, requestOptions);
950
+ return this.transporter.request(request, requestOptions);
923
951
  },
924
952
  /**
925
953
  * Deletes the API key.
@@ -944,7 +972,7 @@ function createSearchClient({
944
972
  queryParameters,
945
973
  headers
946
974
  };
947
- return transporter.request(request, requestOptions);
975
+ return this.transporter.request(request, requestOptions);
948
976
  },
949
977
  /**
950
978
  * 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 +1002,7 @@ function createSearchClient({
974
1002
  headers,
975
1003
  data: deleteByParams
976
1004
  };
977
- return transporter.request(request, requestOptions);
1005
+ return this.transporter.request(request, requestOptions);
978
1006
  },
979
1007
  /**
980
1008
  * 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 +1027,7 @@ function createSearchClient({
999
1027
  queryParameters,
1000
1028
  headers
1001
1029
  };
1002
- return transporter.request(request, requestOptions);
1030
+ return this.transporter.request(request, requestOptions);
1003
1031
  },
1004
1032
  /**
1005
1033
  * 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 +1056,7 @@ function createSearchClient({
1028
1056
  queryParameters,
1029
1057
  headers
1030
1058
  };
1031
- return transporter.request(request, requestOptions);
1059
+ return this.transporter.request(request, requestOptions);
1032
1060
  },
1033
1061
  /**
1034
1062
  * Deletes a rule by its ID. To find the object ID for rules, use the [`search` operation](#tag/Rules/operation/searchRules).
@@ -1061,7 +1089,7 @@ function createSearchClient({
1061
1089
  queryParameters,
1062
1090
  headers
1063
1091
  };
1064
- return transporter.request(request, requestOptions);
1092
+ return this.transporter.request(request, requestOptions);
1065
1093
  },
1066
1094
  /**
1067
1095
  * Deletes a source from the list of allowed sources.
@@ -1086,7 +1114,7 @@ function createSearchClient({
1086
1114
  queryParameters,
1087
1115
  headers
1088
1116
  };
1089
- return transporter.request(request, requestOptions);
1117
+ return this.transporter.request(request, requestOptions);
1090
1118
  },
1091
1119
  /**
1092
1120
  * Deletes a synonym by its ID. To find the object IDs of your synonyms, use the [`search` operation](#tag/Synonyms/operation/searchSynonyms).
@@ -1119,7 +1147,7 @@ function createSearchClient({
1119
1147
  queryParameters,
1120
1148
  headers
1121
1149
  };
1122
- return transporter.request(request, requestOptions);
1150
+ return this.transporter.request(request, requestOptions);
1123
1151
  },
1124
1152
  /**
1125
1153
  * 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 +1169,7 @@ function createSearchClient({
1141
1169
  queryParameters,
1142
1170
  headers
1143
1171
  };
1144
- return transporter.request(request, requestOptions);
1172
+ return this.transporter.request(request, requestOptions);
1145
1173
  },
1146
1174
  /**
1147
1175
  * Checks the status of a given application task.
@@ -1166,7 +1194,7 @@ function createSearchClient({
1166
1194
  queryParameters,
1167
1195
  headers
1168
1196
  };
1169
- return transporter.request(request, requestOptions);
1197
+ return this.transporter.request(request, requestOptions);
1170
1198
  },
1171
1199
  /**
1172
1200
  * Lists supported languages with their supported dictionary types and number of custom entries.
@@ -1186,7 +1214,7 @@ function createSearchClient({
1186
1214
  queryParameters,
1187
1215
  headers
1188
1216
  };
1189
- return transporter.request(request, requestOptions);
1217
+ return this.transporter.request(request, requestOptions);
1190
1218
  },
1191
1219
  /**
1192
1220
  * Retrieves the languages for which standard dictionary entries are turned off.
@@ -1206,7 +1234,7 @@ function createSearchClient({
1206
1234
  queryParameters,
1207
1235
  headers
1208
1236
  };
1209
- return transporter.request(request, requestOptions);
1237
+ return this.transporter.request(request, requestOptions);
1210
1238
  },
1211
1239
  /**
1212
1240
  * 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 +1271,7 @@ function createSearchClient({
1243
1271
  queryParameters,
1244
1272
  headers
1245
1273
  };
1246
- return transporter.request(request, requestOptions);
1274
+ return this.transporter.request(request, requestOptions);
1247
1275
  },
1248
1276
  /**
1249
1277
  * Retrieves one record by its object ID. To retrieve more than one record, use the [`objects` operation](#tag/Records/operation/getObjects).
@@ -1276,7 +1304,7 @@ function createSearchClient({
1276
1304
  queryParameters,
1277
1305
  headers
1278
1306
  };
1279
- return transporter.request(request, requestOptions);
1307
+ return this.transporter.request(request, requestOptions);
1280
1308
  },
1281
1309
  /**
1282
1310
  * Retrieves one or more records, potentially from different indices. Records are returned in the same order as the requests.
@@ -1306,7 +1334,7 @@ function createSearchClient({
1306
1334
  useReadTransporter: true,
1307
1335
  cacheable: true
1308
1336
  };
1309
- return transporter.request(request, requestOptions);
1337
+ return this.transporter.request(request, requestOptions);
1310
1338
  },
1311
1339
  /**
1312
1340
  * Retrieves a rule by its ID. To find the object ID of rules, use the [`search` operation](#tag/Rules/operation/searchRules).
@@ -1335,7 +1363,7 @@ function createSearchClient({
1335
1363
  queryParameters,
1336
1364
  headers
1337
1365
  };
1338
- return transporter.request(request, requestOptions);
1366
+ return this.transporter.request(request, requestOptions);
1339
1367
  },
1340
1368
  /**
1341
1369
  * Retrieves an object with non-null index settings.
@@ -1360,7 +1388,7 @@ function createSearchClient({
1360
1388
  queryParameters,
1361
1389
  headers
1362
1390
  };
1363
- return transporter.request(request, requestOptions);
1391
+ return this.transporter.request(request, requestOptions);
1364
1392
  },
1365
1393
  /**
1366
1394
  * Retrieves all allowed IP addresses with access to your application.
@@ -1380,7 +1408,7 @@ function createSearchClient({
1380
1408
  queryParameters,
1381
1409
  headers
1382
1410
  };
1383
- return transporter.request(request, requestOptions);
1411
+ return this.transporter.request(request, requestOptions);
1384
1412
  },
1385
1413
  /**
1386
1414
  * Retrieves a syonym by its ID. To find the object IDs for your synonyms, use the [`search` operation](#tag/Synonyms/operation/searchSynonyms).
@@ -1409,7 +1437,7 @@ function createSearchClient({
1409
1437
  queryParameters,
1410
1438
  headers
1411
1439
  };
1412
- return transporter.request(request, requestOptions);
1440
+ return this.transporter.request(request, requestOptions);
1413
1441
  },
1414
1442
  /**
1415
1443
  * 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 +1466,7 @@ function createSearchClient({
1438
1466
  queryParameters,
1439
1467
  headers
1440
1468
  };
1441
- return transporter.request(request, requestOptions);
1469
+ return this.transporter.request(request, requestOptions);
1442
1470
  },
1443
1471
  /**
1444
1472
  * 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 +1486,7 @@ function createSearchClient({
1458
1486
  queryParameters,
1459
1487
  headers
1460
1488
  };
1461
- return transporter.request(request, requestOptions);
1489
+ return this.transporter.request(request, requestOptions);
1462
1490
  },
1463
1491
  /**
1464
1492
  * 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 +1511,7 @@ function createSearchClient({
1483
1511
  queryParameters,
1484
1512
  headers
1485
1513
  };
1486
- return transporter.request(request, requestOptions);
1514
+ return this.transporter.request(request, requestOptions);
1487
1515
  },
1488
1516
  /**
1489
1517
  * 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 +1536,7 @@ function createSearchClient({
1508
1536
  queryParameters,
1509
1537
  headers
1510
1538
  };
1511
- return transporter.request(request, requestOptions);
1539
+ return this.transporter.request(request, requestOptions);
1512
1540
  },
1513
1541
  /**
1514
1542
  * Lists all API keys associated with your Algolia application, including their permissions and restrictions.
@@ -1528,7 +1556,7 @@ function createSearchClient({
1528
1556
  queryParameters,
1529
1557
  headers
1530
1558
  };
1531
- return transporter.request(request, requestOptions);
1559
+ return this.transporter.request(request, requestOptions);
1532
1560
  },
1533
1561
  /**
1534
1562
  * Lists the available clusters in a multi-cluster setup.
@@ -1548,7 +1576,7 @@ function createSearchClient({
1548
1576
  queryParameters,
1549
1577
  headers
1550
1578
  };
1551
- return transporter.request(request, requestOptions);
1579
+ return this.transporter.request(request, requestOptions);
1552
1580
  },
1553
1581
  /**
1554
1582
  * 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 +1605,7 @@ function createSearchClient({
1577
1605
  queryParameters,
1578
1606
  headers
1579
1607
  };
1580
- return transporter.request(request, requestOptions);
1608
+ return this.transporter.request(request, requestOptions);
1581
1609
  },
1582
1610
  /**
1583
1611
  * 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 +1634,7 @@ function createSearchClient({
1606
1634
  queryParameters,
1607
1635
  headers
1608
1636
  };
1609
- return transporter.request(request, requestOptions);
1637
+ return this.transporter.request(request, requestOptions);
1610
1638
  },
1611
1639
  /**
1612
1640
  * 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 +1659,7 @@ function createSearchClient({
1631
1659
  headers,
1632
1660
  data: batchParams
1633
1661
  };
1634
- return transporter.request(request, requestOptions);
1662
+ return this.transporter.request(request, requestOptions);
1635
1663
  },
1636
1664
  /**
1637
1665
  * 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 +1695,7 @@ function createSearchClient({
1667
1695
  headers,
1668
1696
  data: operationIndexParams
1669
1697
  };
1670
- return transporter.request(request, requestOptions);
1698
+ return this.transporter.request(request, requestOptions);
1671
1699
  },
1672
1700
  /**
1673
1701
  * 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 +1733,7 @@ function createSearchClient({
1705
1733
  headers,
1706
1734
  data: attributesToUpdate
1707
1735
  };
1708
- return transporter.request(request, requestOptions);
1736
+ return this.transporter.request(request, requestOptions);
1709
1737
  },
1710
1738
  /**
1711
1739
  * Deletes a user ID and its associated data from the clusters.
@@ -1730,7 +1758,7 @@ function createSearchClient({
1730
1758
  queryParameters,
1731
1759
  headers
1732
1760
  };
1733
- return transporter.request(request, requestOptions);
1761
+ return this.transporter.request(request, requestOptions);
1734
1762
  },
1735
1763
  /**
1736
1764
  * Replaces the list of allowed sources.
@@ -1756,7 +1784,7 @@ function createSearchClient({
1756
1784
  headers,
1757
1785
  data: source
1758
1786
  };
1759
- return transporter.request(request, requestOptions);
1787
+ return this.transporter.request(request, requestOptions);
1760
1788
  },
1761
1789
  /**
1762
1790
  * 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 +1809,7 @@ function createSearchClient({
1781
1809
  queryParameters,
1782
1810
  headers
1783
1811
  };
1784
- return transporter.request(request, requestOptions);
1812
+ return this.transporter.request(request, requestOptions);
1785
1813
  },
1786
1814
  /**
1787
1815
  * 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 +1839,7 @@ function createSearchClient({
1811
1839
  headers,
1812
1840
  data: body
1813
1841
  };
1814
- return transporter.request(request, requestOptions);
1842
+ return this.transporter.request(request, requestOptions);
1815
1843
  },
1816
1844
  /**
1817
1845
  * 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 +1880,7 @@ function createSearchClient({
1852
1880
  headers,
1853
1881
  data: rule
1854
1882
  };
1855
- return transporter.request(request, requestOptions);
1883
+ return this.transporter.request(request, requestOptions);
1856
1884
  },
1857
1885
  /**
1858
1886
  * 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 +1918,7 @@ function createSearchClient({
1890
1918
  headers,
1891
1919
  data: rules
1892
1920
  };
1893
- return transporter.request(request, requestOptions);
1921
+ return this.transporter.request(request, requestOptions);
1894
1922
  },
1895
1923
  /**
1896
1924
  * 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 +1962,7 @@ function createSearchClient({
1934
1962
  headers,
1935
1963
  data: synonymHit
1936
1964
  };
1937
- return transporter.request(request, requestOptions);
1965
+ return this.transporter.request(request, requestOptions);
1938
1966
  },
1939
1967
  /**
1940
1968
  * If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced.
@@ -1972,7 +2000,7 @@ function createSearchClient({
1972
2000
  headers,
1973
2001
  data: synonymHit
1974
2002
  };
1975
- return transporter.request(request, requestOptions);
2003
+ return this.transporter.request(request, requestOptions);
1976
2004
  },
1977
2005
  /**
1978
2006
  * 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 +2051,7 @@ function createSearchClient({
2023
2051
  useReadTransporter: true,
2024
2052
  cacheable: true
2025
2053
  };
2026
- return transporter.request(request, requestOptions);
2054
+ return this.transporter.request(request, requestOptions);
2027
2055
  },
2028
2056
  /**
2029
2057
  * Searches for standard and custom dictionary entries.
@@ -2065,7 +2093,7 @@ function createSearchClient({
2065
2093
  useReadTransporter: true,
2066
2094
  cacheable: true
2067
2095
  };
2068
- return transporter.request(request, requestOptions);
2096
+ return this.transporter.request(request, requestOptions);
2069
2097
  },
2070
2098
  /**
2071
2099
  * 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 +2126,7 @@ function createSearchClient({
2098
2126
  useReadTransporter: true,
2099
2127
  cacheable: true
2100
2128
  };
2101
- return transporter.request(request, requestOptions);
2129
+ return this.transporter.request(request, requestOptions);
2102
2130
  },
2103
2131
  /**
2104
2132
  * Searches for rules in your index.
@@ -2127,7 +2155,7 @@ function createSearchClient({
2127
2155
  useReadTransporter: true,
2128
2156
  cacheable: true
2129
2157
  };
2130
- return transporter.request(request, requestOptions);
2158
+ return this.transporter.request(request, requestOptions);
2131
2159
  },
2132
2160
  /**
2133
2161
  * 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 +2184,7 @@ function createSearchClient({
2156
2184
  useReadTransporter: true,
2157
2185
  cacheable: true
2158
2186
  };
2159
- return transporter.request(request, requestOptions);
2187
+ return this.transporter.request(request, requestOptions);
2160
2188
  },
2161
2189
  /**
2162
2190
  * Searches for synonyms in your index.
@@ -2188,7 +2216,7 @@ function createSearchClient({
2188
2216
  useReadTransporter: true,
2189
2217
  cacheable: true
2190
2218
  };
2191
- return transporter.request(request, requestOptions);
2219
+ return this.transporter.request(request, requestOptions);
2192
2220
  },
2193
2221
  /**
2194
2222
  * 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 +2246,7 @@ function createSearchClient({
2218
2246
  useReadTransporter: true,
2219
2247
  cacheable: true
2220
2248
  };
2221
- return transporter.request(request, requestOptions);
2249
+ return this.transporter.request(request, requestOptions);
2222
2250
  },
2223
2251
  /**
2224
2252
  * Turns standard stop word dictionary entries on or off for a given language.
@@ -2248,7 +2276,7 @@ function createSearchClient({
2248
2276
  headers,
2249
2277
  data: dictionarySettingsParams
2250
2278
  };
2251
- return transporter.request(request, requestOptions);
2279
+ return this.transporter.request(request, requestOptions);
2252
2280
  },
2253
2281
  /**
2254
2282
  * 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 +2310,7 @@ function createSearchClient({
2282
2310
  headers,
2283
2311
  data: indexSettings
2284
2312
  };
2285
- return transporter.request(request, requestOptions);
2313
+ return this.transporter.request(request, requestOptions);
2286
2314
  },
2287
2315
  /**
2288
2316
  * Replaces the permissions of an existing API key. Any unspecified attribute resets that attribute to its default value.
@@ -2315,7 +2343,7 @@ function createSearchClient({
2315
2343
  headers,
2316
2344
  data: apiKey
2317
2345
  };
2318
- return transporter.request(request, requestOptions);
2346
+ return this.transporter.request(request, requestOptions);
2319
2347
  }
2320
2348
  };
2321
2349
  }
@@ -2352,7 +2380,7 @@ function searchClient(appId, apiKey, options) {
2352
2380
  * @param generateSecuredApiKey.parentApiKey - The base API key from which to generate the new secured one.
2353
2381
  * @param generateSecuredApiKey.restrictions - A set of properties defining the restrictions of the secured API key.
2354
2382
  */
2355
- generateSecuredApiKey({ parentApiKey, restrictions = {} }) {
2383
+ generateSecuredApiKey: ({ parentApiKey, restrictions = {} }) => {
2356
2384
  let mergedRestrictions = restrictions;
2357
2385
  if (restrictions.searchParams) {
2358
2386
  mergedRestrictions = {
@@ -2380,7 +2408,7 @@ function searchClient(appId, apiKey, options) {
2380
2408
  * @param getSecuredApiKeyRemainingValidity - The `getSecuredApiKeyRemainingValidity` object.
2381
2409
  * @param getSecuredApiKeyRemainingValidity.securedApiKey - The secured API key generated with the `generateSecuredApiKey` method.
2382
2410
  */
2383
- getSecuredApiKeyRemainingValidity({ securedApiKey }) {
2411
+ getSecuredApiKeyRemainingValidity: ({ securedApiKey }) => {
2384
2412
  const decodedString = Buffer.from(securedApiKey, "base64").toString("ascii");
2385
2413
  const regex = /validUntil=(\d+)/;
2386
2414
  const match = decodedString.match(regex);