@algolia/client-search 5.0.0-alpha.91 → 5.0.0-alpha.97

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.
@@ -4,7 +4,7 @@ var clientCommon = require('@algolia/client-common');
4
4
  var requesterNodeHttp = require('@algolia/requester-node-http');
5
5
 
6
6
  // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
7
- const apiClientVersion = '5.0.0-alpha.91';
7
+ const apiClientVersion = '5.0.0-alpha.97';
8
8
  function getDefaultHosts(appId) {
9
9
  return [
10
10
  {
@@ -597,14 +597,14 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
597
597
  * This method allow you to send requests to the Algolia REST API.
598
598
  *
599
599
  * @summary Send requests to the Algolia REST API.
600
- * @param del - The del object.
601
- * @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
602
- * @param del.parameters - Query parameters to apply to the current query.
600
+ * @param customDelete - The customDelete object.
601
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
602
+ * @param customDelete.parameters - Query parameters to apply to the current query.
603
603
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
604
604
  */
605
- del({ path, parameters }, requestOptions) {
605
+ customDelete({ path, parameters }, requestOptions) {
606
606
  if (!path) {
607
- throw new Error('Parameter `path` is required when calling `del`.');
607
+ throw new Error('Parameter `path` is required when calling `customDelete`.');
608
608
  }
609
609
  const requestPath = '/1{path}'.replace('{path}', path);
610
610
  const headers = {};
@@ -617,6 +617,82 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
617
617
  };
618
618
  return transporter.request(request, requestOptions);
619
619
  },
620
+ /**
621
+ * This method allow you to send requests to the Algolia REST API.
622
+ *
623
+ * @summary Send requests to the Algolia REST API.
624
+ * @param customGet - The customGet object.
625
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
626
+ * @param customGet.parameters - Query parameters to apply to the current query.
627
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
628
+ */
629
+ customGet({ path, parameters }, requestOptions) {
630
+ if (!path) {
631
+ throw new Error('Parameter `path` is required when calling `customGet`.');
632
+ }
633
+ const requestPath = '/1{path}'.replace('{path}', path);
634
+ const headers = {};
635
+ const queryParameters = parameters ? parameters : {};
636
+ const request = {
637
+ method: 'GET',
638
+ path: requestPath,
639
+ queryParameters,
640
+ headers,
641
+ };
642
+ return transporter.request(request, requestOptions);
643
+ },
644
+ /**
645
+ * This method allow you to send requests to the Algolia REST API.
646
+ *
647
+ * @summary Send requests to the Algolia REST API.
648
+ * @param customPost - The customPost object.
649
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
650
+ * @param customPost.parameters - Query parameters to apply to the current query.
651
+ * @param customPost.body - Parameters to send with the custom request.
652
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
653
+ */
654
+ customPost({ path, parameters, body }, requestOptions) {
655
+ if (!path) {
656
+ throw new Error('Parameter `path` is required when calling `customPost`.');
657
+ }
658
+ const requestPath = '/1{path}'.replace('{path}', path);
659
+ const headers = {};
660
+ const queryParameters = parameters ? parameters : {};
661
+ const request = {
662
+ method: 'POST',
663
+ path: requestPath,
664
+ queryParameters,
665
+ headers,
666
+ data: body ? body : {},
667
+ };
668
+ return transporter.request(request, requestOptions);
669
+ },
670
+ /**
671
+ * This method allow you to send requests to the Algolia REST API.
672
+ *
673
+ * @summary Send requests to the Algolia REST API.
674
+ * @param customPut - The customPut object.
675
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
676
+ * @param customPut.parameters - Query parameters to apply to the current query.
677
+ * @param customPut.body - Parameters to send with the custom request.
678
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
679
+ */
680
+ customPut({ path, parameters, body }, requestOptions) {
681
+ if (!path) {
682
+ throw new Error('Parameter `path` is required when calling `customPut`.');
683
+ }
684
+ const requestPath = '/1{path}'.replace('{path}', path);
685
+ const headers = {};
686
+ const queryParameters = parameters ? parameters : {};
687
+ const request = {
688
+ method: 'PUT',
689
+ path: requestPath,
690
+ queryParameters,
691
+ headers,
692
+ data: body ? body : {},
693
+ };
694
+ return transporter.request(request, requestOptions);
695
+ },
620
696
  /**
621
697
  * Delete an existing API key. The request must be authenticated with the admin API key.
622
698
  *
@@ -809,30 +885,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
809
885
  };
810
886
  return transporter.request(request, requestOptions);
811
887
  },
812
- /**
813
- * This method allow you to send requests to the Algolia REST API.
814
- *
815
- * @summary Send requests to the Algolia REST API.
816
- * @param get - The get object.
817
- * @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
818
- * @param get.parameters - Query parameters to apply to the current query.
819
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
820
- */
821
- get({ path, parameters }, requestOptions) {
822
- if (!path) {
823
- throw new Error('Parameter `path` is required when calling `get`.');
824
- }
825
- const requestPath = '/1{path}'.replace('{path}', path);
826
- const headers = {};
827
- const queryParameters = parameters ? parameters : {};
828
- const request = {
829
- method: 'GET',
830
- path: requestPath,
831
- queryParameters,
832
- headers,
833
- };
834
- return transporter.request(request, requestOptions);
835
- },
836
888
  /**
837
889
  * Get the permissions and restrictions of a specific 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.
838
890
  *
@@ -1368,58 +1420,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1368
1420
  };
1369
1421
  return transporter.request(request, requestOptions);
1370
1422
  },
1371
- /**
1372
- * This method allow you to send requests to the Algolia REST API.
1373
- *
1374
- * @summary Send requests to the Algolia REST API.
1375
- * @param post - The post object.
1376
- * @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
1377
- * @param post.parameters - Query parameters to apply to the current query.
1378
- * @param post.body - Parameters to send with the custom request.
1379
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1380
- */
1381
- post({ path, parameters, body }, requestOptions) {
1382
- if (!path) {
1383
- throw new Error('Parameter `path` is required when calling `post`.');
1384
- }
1385
- const requestPath = '/1{path}'.replace('{path}', path);
1386
- const headers = {};
1387
- const queryParameters = parameters ? parameters : {};
1388
- const request = {
1389
- method: 'POST',
1390
- path: requestPath,
1391
- queryParameters,
1392
- headers,
1393
- data: body ? body : {},
1394
- };
1395
- return transporter.request(request, requestOptions);
1396
- },
1397
- /**
1398
- * This method allow you to send requests to the Algolia REST API.
1399
- *
1400
- * @summary Send requests to the Algolia REST API.
1401
- * @param put - The put object.
1402
- * @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
1403
- * @param put.parameters - Query parameters to apply to the current query.
1404
- * @param put.body - Parameters to send with the custom request.
1405
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1406
- */
1407
- put({ path, parameters, body }, requestOptions) {
1408
- if (!path) {
1409
- throw new Error('Parameter `path` is required when calling `put`.');
1410
- }
1411
- const requestPath = '/1{path}'.replace('{path}', path);
1412
- const headers = {};
1413
- const queryParameters = parameters ? parameters : {};
1414
- const request = {
1415
- method: 'PUT',
1416
- path: requestPath,
1417
- queryParameters,
1418
- headers,
1419
- data: body ? body : {},
1420
- };
1421
- return transporter.request(request, requestOptions);
1422
- },
1423
1423
  /**
1424
1424
  * Remove a userID and its associated data from the multi-clusters.
1425
1425
  *
@@ -66,14 +66,35 @@ function createBrowserLocalStorageCache(options) {
66
66
  function getNamespace() {
67
67
  return JSON.parse(getStorage().getItem(namespaceKey) || '{}');
68
68
  }
69
+ function setNamespace(namespace) {
70
+ getStorage().setItem(namespaceKey, JSON.stringify(namespace));
71
+ }
72
+ function removeOutdatedCacheItems() {
73
+ const timeToLive = options.timeToLive ? options.timeToLive * 1000 : null;
74
+ const namespace = getNamespace();
75
+ const filteredNamespaceWithoutOldFormattedCacheItems = Object.fromEntries(Object.entries(namespace).filter(([, cacheItem]) => {
76
+ return cacheItem.timestamp !== undefined;
77
+ }));
78
+ setNamespace(filteredNamespaceWithoutOldFormattedCacheItems);
79
+ if (!timeToLive) {
80
+ return;
81
+ }
82
+ const filteredNamespaceWithoutExpiredItems = Object.fromEntries(Object.entries(filteredNamespaceWithoutOldFormattedCacheItems).filter(([, cacheItem]) => {
83
+ const currentTimestamp = new Date().getTime();
84
+ const isExpired = cacheItem.timestamp + timeToLive < currentTimestamp;
85
+ return !isExpired;
86
+ }));
87
+ setNamespace(filteredNamespaceWithoutExpiredItems);
88
+ }
69
89
  return {
70
90
  get(key, defaultValue, events = {
71
91
  miss: () => Promise.resolve()
72
92
  }) {
73
93
  return Promise.resolve().then(() => {
74
- const keyAsString = JSON.stringify(key);
75
- const value = getNamespace()[keyAsString];
76
- return Promise.all([value || defaultValue(), value !== undefined]);
94
+ removeOutdatedCacheItems();
95
+ return getNamespace()[JSON.stringify(key)];
96
+ }).then(value => {
97
+ return Promise.all([value ? value.value : defaultValue(), value !== undefined]);
77
98
  }).then(([value, exists]) => {
78
99
  return Promise.all([value, exists || events.miss(value)]);
79
100
  }).then(([value]) => value);
@@ -81,7 +102,10 @@ function createBrowserLocalStorageCache(options) {
81
102
  set(key, value) {
82
103
  return Promise.resolve().then(() => {
83
104
  const namespace = getNamespace();
84
- namespace[JSON.stringify(key)] = value;
105
+ namespace[JSON.stringify(key)] = {
106
+ timestamp: new Date().getTime(),
107
+ value
108
+ };
85
109
  getStorage().setItem(namespaceKey, JSON.stringify(namespace));
86
110
  return value;
87
111
  });
@@ -211,6 +235,20 @@ function createStatefulHost(host, status = 'up') {
211
235
  };
212
236
  }
213
237
 
238
+ function _toPrimitive(t, r) {
239
+ if ("object" != typeof t || !t) return t;
240
+ var e = t[Symbol.toPrimitive];
241
+ if (void 0 !== e) {
242
+ var i = e.call(t, r || "default");
243
+ if ("object" != typeof i) return i;
244
+ throw new TypeError("@@toPrimitive must return a primitive value.");
245
+ }
246
+ return ("string" === r ? String : Number)(t);
247
+ }
248
+ function _toPropertyKey(t) {
249
+ var i = _toPrimitive(t, "string");
250
+ return "symbol" == typeof i ? i : String(i);
251
+ }
214
252
  function _defineProperty(obj, key, value) {
215
253
  key = _toPropertyKey(key);
216
254
  if (key in obj) {
@@ -225,20 +263,6 @@ function _defineProperty(obj, key, value) {
225
263
  }
226
264
  return obj;
227
265
  }
228
- function _toPrimitive(input, hint) {
229
- if (typeof input !== "object" || input === null) return input;
230
- var prim = input[Symbol.toPrimitive];
231
- if (prim !== undefined) {
232
- var res = prim.call(input, hint || "default");
233
- if (typeof res !== "object") return res;
234
- throw new TypeError("@@toPrimitive must return a primitive value.");
235
- }
236
- return (hint === "string" ? String : Number)(input);
237
- }
238
- function _toPropertyKey(arg) {
239
- var key = _toPrimitive(arg, "string");
240
- return typeof key === "symbol" ? key : String(key);
241
- }
242
266
 
243
267
  class AlgoliaError extends Error {
244
268
  constructor(message, name) {
@@ -259,7 +283,7 @@ class ErrorWithStackTrace extends AlgoliaError {
259
283
  }
260
284
  class RetryError extends ErrorWithStackTrace {
261
285
  constructor(stackTrace) {
262
- super('Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.', stackTrace, 'RetryError');
286
+ super('Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.', stackTrace, 'RetryError');
263
287
  }
264
288
  }
265
289
  class ApiError extends ErrorWithStackTrace {
@@ -713,7 +737,7 @@ function createXhrRequester() {
713
737
  }
714
738
 
715
739
  // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
716
- const apiClientVersion = '5.0.0-alpha.91';
740
+ const apiClientVersion = '5.0.0-alpha.97';
717
741
  function getDefaultHosts(appId) {
718
742
  return [
719
743
  {
@@ -1306,14 +1330,14 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1306
1330
  * This method allow you to send requests to the Algolia REST API.
1307
1331
  *
1308
1332
  * @summary Send requests to the Algolia REST API.
1309
- * @param del - The del object.
1310
- * @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
1311
- * @param del.parameters - Query parameters to apply to the current query.
1333
+ * @param customDelete - The customDelete object.
1334
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
1335
+ * @param customDelete.parameters - Query parameters to apply to the current query.
1312
1336
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1313
1337
  */
1314
- del({ path, parameters }, requestOptions) {
1338
+ customDelete({ path, parameters }, requestOptions) {
1315
1339
  if (!path) {
1316
- throw new Error('Parameter `path` is required when calling `del`.');
1340
+ throw new Error('Parameter `path` is required when calling `customDelete`.');
1317
1341
  }
1318
1342
  const requestPath = '/1{path}'.replace('{path}', path);
1319
1343
  const headers = {};
@@ -1326,6 +1350,82 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1326
1350
  };
1327
1351
  return transporter.request(request, requestOptions);
1328
1352
  },
1353
+ /**
1354
+ * This method allow you to send requests to the Algolia REST API.
1355
+ *
1356
+ * @summary Send requests to the Algolia REST API.
1357
+ * @param customGet - The customGet object.
1358
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
1359
+ * @param customGet.parameters - Query parameters to apply to the current query.
1360
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1361
+ */
1362
+ customGet({ path, parameters }, requestOptions) {
1363
+ if (!path) {
1364
+ throw new Error('Parameter `path` is required when calling `customGet`.');
1365
+ }
1366
+ const requestPath = '/1{path}'.replace('{path}', path);
1367
+ const headers = {};
1368
+ const queryParameters = parameters ? parameters : {};
1369
+ const request = {
1370
+ method: 'GET',
1371
+ path: requestPath,
1372
+ queryParameters,
1373
+ headers,
1374
+ };
1375
+ return transporter.request(request, requestOptions);
1376
+ },
1377
+ /**
1378
+ * This method allow you to send requests to the Algolia REST API.
1379
+ *
1380
+ * @summary Send requests to the Algolia REST API.
1381
+ * @param customPost - The customPost object.
1382
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
1383
+ * @param customPost.parameters - Query parameters to apply to the current query.
1384
+ * @param customPost.body - Parameters to send with the custom request.
1385
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1386
+ */
1387
+ customPost({ path, parameters, body }, requestOptions) {
1388
+ if (!path) {
1389
+ throw new Error('Parameter `path` is required when calling `customPost`.');
1390
+ }
1391
+ const requestPath = '/1{path}'.replace('{path}', path);
1392
+ const headers = {};
1393
+ const queryParameters = parameters ? parameters : {};
1394
+ const request = {
1395
+ method: 'POST',
1396
+ path: requestPath,
1397
+ queryParameters,
1398
+ headers,
1399
+ data: body ? body : {},
1400
+ };
1401
+ return transporter.request(request, requestOptions);
1402
+ },
1403
+ /**
1404
+ * This method allow you to send requests to the Algolia REST API.
1405
+ *
1406
+ * @summary Send requests to the Algolia REST API.
1407
+ * @param customPut - The customPut object.
1408
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
1409
+ * @param customPut.parameters - Query parameters to apply to the current query.
1410
+ * @param customPut.body - Parameters to send with the custom request.
1411
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1412
+ */
1413
+ customPut({ path, parameters, body }, requestOptions) {
1414
+ if (!path) {
1415
+ throw new Error('Parameter `path` is required when calling `customPut`.');
1416
+ }
1417
+ const requestPath = '/1{path}'.replace('{path}', path);
1418
+ const headers = {};
1419
+ const queryParameters = parameters ? parameters : {};
1420
+ const request = {
1421
+ method: 'PUT',
1422
+ path: requestPath,
1423
+ queryParameters,
1424
+ headers,
1425
+ data: body ? body : {},
1426
+ };
1427
+ return transporter.request(request, requestOptions);
1428
+ },
1329
1429
  /**
1330
1430
  * Delete an existing API key. The request must be authenticated with the admin API key.
1331
1431
  *
@@ -1518,30 +1618,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
1518
1618
  };
1519
1619
  return transporter.request(request, requestOptions);
1520
1620
  },
1521
- /**
1522
- * This method allow you to send requests to the Algolia REST API.
1523
- *
1524
- * @summary Send requests to the Algolia REST API.
1525
- * @param get - The get object.
1526
- * @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
1527
- * @param get.parameters - Query parameters to apply to the current query.
1528
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1529
- */
1530
- get({ path, parameters }, requestOptions) {
1531
- if (!path) {
1532
- throw new Error('Parameter `path` is required when calling `get`.');
1533
- }
1534
- const requestPath = '/1{path}'.replace('{path}', path);
1535
- const headers = {};
1536
- const queryParameters = parameters ? parameters : {};
1537
- const request = {
1538
- method: 'GET',
1539
- path: requestPath,
1540
- queryParameters,
1541
- headers,
1542
- };
1543
- return transporter.request(request, requestOptions);
1544
- },
1545
1621
  /**
1546
1622
  * Get the permissions and restrictions of a specific 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.
1547
1623
  *
@@ -2077,58 +2153,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
2077
2153
  };
2078
2154
  return transporter.request(request, requestOptions);
2079
2155
  },
2080
- /**
2081
- * This method allow you to send requests to the Algolia REST API.
2082
- *
2083
- * @summary Send requests to the Algolia REST API.
2084
- * @param post - The post object.
2085
- * @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
2086
- * @param post.parameters - Query parameters to apply to the current query.
2087
- * @param post.body - Parameters to send with the custom request.
2088
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2089
- */
2090
- post({ path, parameters, body }, requestOptions) {
2091
- if (!path) {
2092
- throw new Error('Parameter `path` is required when calling `post`.');
2093
- }
2094
- const requestPath = '/1{path}'.replace('{path}', path);
2095
- const headers = {};
2096
- const queryParameters = parameters ? parameters : {};
2097
- const request = {
2098
- method: 'POST',
2099
- path: requestPath,
2100
- queryParameters,
2101
- headers,
2102
- data: body ? body : {},
2103
- };
2104
- return transporter.request(request, requestOptions);
2105
- },
2106
- /**
2107
- * This method allow you to send requests to the Algolia REST API.
2108
- *
2109
- * @summary Send requests to the Algolia REST API.
2110
- * @param put - The put object.
2111
- * @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
2112
- * @param put.parameters - Query parameters to apply to the current query.
2113
- * @param put.body - Parameters to send with the custom request.
2114
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2115
- */
2116
- put({ path, parameters, body }, requestOptions) {
2117
- if (!path) {
2118
- throw new Error('Parameter `path` is required when calling `put`.');
2119
- }
2120
- const requestPath = '/1{path}'.replace('{path}', path);
2121
- const headers = {};
2122
- const queryParameters = parameters ? parameters : {};
2123
- const request = {
2124
- method: 'PUT',
2125
- path: requestPath,
2126
- queryParameters,
2127
- headers,
2128
- data: body ? body : {},
2129
- };
2130
- return transporter.request(request, requestOptions);
2131
- },
2132
2156
  /**
2133
2157
  * Remove a userID and its associated data from the multi-clusters.
2134
2158
  *