@algolia/client-search 5.0.0-alpha.52 → 5.0.0-alpha.54

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.
Files changed (163) hide show
  1. package/dist/builds/browser.d.ts +5 -5
  2. package/dist/builds/node.d.ts +5 -5
  3. package/dist/client-search.cjs.js +1997 -1995
  4. package/dist/client-search.esm.browser.js +2130 -2128
  5. package/dist/client-search.esm.node.js +1997 -1995
  6. package/dist/client-search.umd.js +2 -2
  7. package/dist/model/acl.d.ts +4 -4
  8. package/dist/model/action.d.ts +4 -4
  9. package/dist/model/addApiKeyResponse.d.ts +10 -10
  10. package/dist/model/advancedSyntaxFeatures.d.ts +1 -1
  11. package/dist/model/alternativesAsExact.d.ts +1 -1
  12. package/dist/model/anchoring.d.ts +4 -4
  13. package/dist/model/apiKey.d.ts +38 -38
  14. package/dist/model/aroundRadius.d.ts +5 -5
  15. package/dist/model/aroundRadiusAll.d.ts +1 -1
  16. package/dist/model/assignUserIdParams.d.ts +9 -9
  17. package/dist/model/attributeToUpdate.d.ts +2 -2
  18. package/dist/model/automaticFacetFilter.d.ts +17 -17
  19. package/dist/model/automaticFacetFilters.d.ts +5 -5
  20. package/dist/model/baseGetApiKeyResponse.d.ts +10 -10
  21. package/dist/model/baseIndexSettings.d.ts +62 -62
  22. package/dist/model/baseSearchParams.d.ts +3 -3
  23. package/dist/model/baseSearchParamsWithoutQuery.d.ts +122 -122
  24. package/dist/model/baseSearchResponse.d.ts +101 -101
  25. package/dist/model/batchAssignUserIdsParams.d.ts +13 -13
  26. package/dist/model/batchDictionaryEntriesParams.d.ts +14 -14
  27. package/dist/model/batchDictionaryEntriesRequest.d.ts +6 -6
  28. package/dist/model/batchParams.d.ts +7 -7
  29. package/dist/model/batchRequest.d.ts +8 -8
  30. package/dist/model/batchResponse.d.ts +10 -10
  31. package/dist/model/batchWriteParams.d.ts +7 -7
  32. package/dist/model/browseParams.d.ts +3 -3
  33. package/dist/model/browseParamsObject.d.ts +3 -3
  34. package/dist/model/browseResponse.d.ts +4 -4
  35. package/dist/model/builtInOperation.d.ts +11 -11
  36. package/dist/model/builtInOperationType.d.ts +4 -4
  37. package/dist/model/clientMethodProps.d.ts +715 -715
  38. package/dist/model/condition.d.ts +16 -16
  39. package/dist/model/consequence.d.ts +25 -25
  40. package/dist/model/consequenceHide.d.ts +9 -9
  41. package/dist/model/consequenceParams.d.ts +4 -4
  42. package/dist/model/consequenceQuery.d.ts +5 -5
  43. package/dist/model/consequenceQueryObject.d.ts +11 -11
  44. package/dist/model/createdAtResponse.d.ts +9 -9
  45. package/dist/model/cursor.d.ts +6 -6
  46. package/dist/model/deleteApiKeyResponse.d.ts +6 -6
  47. package/dist/model/deleteByParams.d.ts +26 -26
  48. package/dist/model/deleteSourceResponse.d.ts +6 -6
  49. package/dist/model/deletedAtResponse.d.ts +13 -13
  50. package/dist/model/dictionaryAction.d.ts +4 -4
  51. package/dist/model/dictionaryEntry.d.ts +27 -27
  52. package/dist/model/dictionaryEntryState.d.ts +4 -4
  53. package/dist/model/dictionaryLanguage.d.ts +9 -9
  54. package/dist/model/dictionarySettingsParams.d.ts +7 -7
  55. package/dist/model/dictionaryType.d.ts +1 -1
  56. package/dist/model/distinct.d.ts +4 -4
  57. package/dist/model/edit.d.ts +12 -12
  58. package/dist/model/editType.d.ts +4 -4
  59. package/dist/model/errorBase.d.ts +6 -6
  60. package/dist/model/exactOnSingleWordQuery.d.ts +4 -4
  61. package/dist/model/facetFilters.d.ts +5 -5
  62. package/dist/model/facetHits.d.ts +14 -14
  63. package/dist/model/facetOrdering.d.ts +12 -12
  64. package/dist/model/facets.d.ts +9 -9
  65. package/dist/model/facetsStats.d.ts +18 -18
  66. package/dist/model/fetchedIndex.d.ts +46 -46
  67. package/dist/model/getApiKeyResponse.d.ts +3 -3
  68. package/dist/model/getDictionarySettingsResponse.d.ts +4 -4
  69. package/dist/model/getLogsResponse.d.ts +4 -4
  70. package/dist/model/getObjectsParams.d.ts +7 -7
  71. package/dist/model/getObjectsRequest.d.ts +17 -17
  72. package/dist/model/getObjectsResponse.d.ts +6 -6
  73. package/dist/model/getTaskResponse.d.ts +4 -4
  74. package/dist/model/getTopUserIdsResponse.d.ts +10 -10
  75. package/dist/model/hasPendingMappingsResponse.d.ts +10 -10
  76. package/dist/model/highlightResult.d.ts +2 -2
  77. package/dist/model/highlightResultOption.d.ts +19 -19
  78. package/dist/model/hit.d.ts +22 -22
  79. package/dist/model/ignorePlurals.d.ts +4 -4
  80. package/dist/model/index.d.ts +154 -154
  81. package/dist/model/indexSettings.d.ts +6 -6
  82. package/dist/model/indexSettingsAsSearchParams.d.ts +156 -156
  83. package/dist/model/languages.d.ts +9 -9
  84. package/dist/model/listApiKeysResponse.d.ts +7 -7
  85. package/dist/model/listClustersResponse.d.ts +9 -9
  86. package/dist/model/listIndicesResponse.d.ts +11 -11
  87. package/dist/model/listUserIdsResponse.d.ts +10 -10
  88. package/dist/model/log.d.ts +63 -63
  89. package/dist/model/logQuery.d.ts +14 -14
  90. package/dist/model/logType.d.ts +1 -1
  91. package/dist/model/matchLevel.d.ts +4 -4
  92. package/dist/model/matchedGeoLocation.d.ts +14 -14
  93. package/dist/model/mixedSearchFilters.d.ts +1 -1
  94. package/dist/model/multipleBatchRequest.d.ts +12 -12
  95. package/dist/model/multipleBatchResponse.d.ts +10 -10
  96. package/dist/model/numericFilters.d.ts +5 -5
  97. package/dist/model/operationIndexParams.d.ts +13 -13
  98. package/dist/model/operationType.d.ts +4 -4
  99. package/dist/model/optionalFilters.d.ts +5 -5
  100. package/dist/model/params.d.ts +12 -12
  101. package/dist/model/personalization.d.ts +14 -14
  102. package/dist/model/promote.d.ts +3 -3
  103. package/dist/model/promoteObjectID.d.ts +13 -13
  104. package/dist/model/promoteObjectIDs.d.ts +13 -13
  105. package/dist/model/queryType.d.ts +4 -4
  106. package/dist/model/rankingInfo.d.ts +50 -50
  107. package/dist/model/reRankingApplyFilter.d.ts +5 -5
  108. package/dist/model/removeStopWords.d.ts +4 -4
  109. package/dist/model/removeUserIdResponse.d.ts +6 -6
  110. package/dist/model/removeWordsIfNoResults.d.ts +4 -4
  111. package/dist/model/renderingContent.d.ts +7 -7
  112. package/dist/model/replaceSourceResponse.d.ts +6 -6
  113. package/dist/model/rule.d.ts +29 -29
  114. package/dist/model/saveObjectResponse.d.ts +11 -11
  115. package/dist/model/saveSynonymResponse.d.ts +14 -14
  116. package/dist/model/scopeType.d.ts +1 -1
  117. package/dist/model/searchDictionaryEntriesParams.d.ts +21 -21
  118. package/dist/model/searchForFacetValuesRequest.d.ts +14 -14
  119. package/dist/model/searchForFacetValuesResponse.d.ts +4 -4
  120. package/dist/model/searchForFacets.d.ts +3 -3
  121. package/dist/model/searchForFacetsOptions.d.ts +20 -20
  122. package/dist/model/searchForHits.d.ts +3 -3
  123. package/dist/model/searchForHitsOptions.d.ts +12 -12
  124. package/dist/model/searchHits.d.ts +4 -4
  125. package/dist/model/searchMethodParams.d.ts +6 -6
  126. package/dist/model/searchParams.d.ts +3 -3
  127. package/dist/model/searchParamsObject.d.ts +3 -3
  128. package/dist/model/searchParamsQuery.d.ts +6 -6
  129. package/dist/model/searchParamsString.d.ts +6 -6
  130. package/dist/model/searchQuery.d.ts +3 -3
  131. package/dist/model/searchResponse.d.ts +3 -3
  132. package/dist/model/searchResponses.d.ts +4 -4
  133. package/dist/model/searchRulesParams.d.ts +31 -31
  134. package/dist/model/searchRulesResponse.d.ts +19 -19
  135. package/dist/model/searchStrategy.d.ts +1 -1
  136. package/dist/model/searchSynonymsParams.d.ts +6 -6
  137. package/dist/model/searchSynonymsResponse.d.ts +11 -11
  138. package/dist/model/searchTypeDefault.d.ts +4 -4
  139. package/dist/model/searchTypeFacet.d.ts +4 -4
  140. package/dist/model/searchUserIdsParams.d.ts +21 -21
  141. package/dist/model/searchUserIdsResponse.d.ts +26 -26
  142. package/dist/model/snippetResult.d.ts +2 -2
  143. package/dist/model/snippetResultOption.d.ts +11 -11
  144. package/dist/model/sortRemainingBy.d.ts +4 -4
  145. package/dist/model/source.d.ts +13 -13
  146. package/dist/model/standardEntries.d.ts +17 -17
  147. package/dist/model/synonymHit.d.ts +35 -35
  148. package/dist/model/synonymType.d.ts +4 -4
  149. package/dist/model/tagFilters.d.ts +5 -5
  150. package/dist/model/taskStatus.d.ts +1 -1
  151. package/dist/model/timeRange.d.ts +10 -10
  152. package/dist/model/typoTolerance.d.ts +5 -5
  153. package/dist/model/typoToleranceEnum.d.ts +1 -1
  154. package/dist/model/updateApiKeyResponse.d.ts +10 -10
  155. package/dist/model/updatedAtResponse.d.ts +13 -13
  156. package/dist/model/updatedAtWithObjectIdResponse.d.ts +17 -17
  157. package/dist/model/updatedRuleResponse.d.ts +14 -14
  158. package/dist/model/userHighlightResult.d.ts +11 -11
  159. package/dist/model/userHit.d.ts +24 -24
  160. package/dist/model/userId.d.ts +21 -21
  161. package/dist/model/value.d.ts +8 -8
  162. package/dist/src/searchClient.d.ts +723 -723
  163. package/package.json +6 -6
@@ -13,15 +13,15 @@ function createAuth(appId, apiKey, authMode = 'WithinHeaders') {
13
13
  };
14
14
  }
15
15
 
16
- /**
17
- * Helper: Returns the promise of a given `func` to iterate on, based on a given `validate` condition.
18
- *
19
- * @param createIterator - The createIterator options.
20
- * @param createIterator.func - The function to run, which returns a promise.
21
- * @param createIterator.validate - The validator function. It receives the resolved return of `func`.
22
- * @param createIterator.aggregator - The function that runs right after the `func` method has been executed, allows you to do anything with the response before `validate`.
23
- * @param createIterator.error - The `validate` condition to throw an error, and its message.
24
- * @param createIterator.timeout - The function to decide how long to wait between iterations.
16
+ /**
17
+ * Helper: Returns the promise of a given `func` to iterate on, based on a given `validate` condition.
18
+ *
19
+ * @param createIterator - The createIterator options.
20
+ * @param createIterator.func - The function to run, which returns a promise.
21
+ * @param createIterator.validate - The validator function. It receives the resolved return of `func`.
22
+ * @param createIterator.aggregator - The function that runs right after the `func` method has been executed, allows you to do anything with the response before `validate`.
23
+ * @param createIterator.error - The `validate` condition to throw an error, and its message.
24
+ * @param createIterator.timeout - The function to decide how long to wait between iterations.
25
25
  */
26
26
  function createIterablePromise({
27
27
  func,
@@ -419,16 +419,16 @@ function createTransporter({
419
419
  return {
420
420
  hosts: compatibleHostsAvailable,
421
421
  getTimeout(timeoutsCount, baseTimeout) {
422
- /**
423
- * Imagine that you have 4 hosts, if timeouts will increase
424
- * on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
425
- *
426
- * Note that, the very next request, we start from the previous timeout.
427
- *
428
- * 5 (timed out) > 6 (timed out) > 7 ...
429
- *
430
- * This strategy may need to be reviewed, but is the strategy on the our
431
- * current v3 version.
422
+ /**
423
+ * Imagine that you have 4 hosts, if timeouts will increase
424
+ * on the following way: 1 (timed out) > 4 (timed out) > 5 (200).
425
+ *
426
+ * Note that, the very next request, we start from the previous timeout.
427
+ *
428
+ * 5 (timed out) > 6 (timed out) > 7 ...
429
+ *
430
+ * This strategy may need to be reviewed, but is the strategy on the our
431
+ * current v3 version.
432
432
  */
433
433
  const timeoutMultiplier = hostsTimedOut.length === 0 && timeoutsCount === 0 ? 1 : hostsTimedOut.length + 3 + timeoutsCount;
434
434
  return timeoutMultiplier * baseTimeout;
@@ -437,8 +437,8 @@ function createTransporter({
437
437
  }
438
438
  async function retryableRequest(request, requestOptions, isRead = true) {
439
439
  const stackTrace = [];
440
- /**
441
- * First we prepare the payload that do not depend from hosts.
440
+ /**
441
+ * First we prepare the payload that do not depend from hosts.
442
442
  */
443
443
  const data = serializeData(request, requestOptions);
444
444
  const headers = serializeHeaders(baseHeaders, request.headers, requestOptions.headers);
@@ -469,8 +469,8 @@ function createTransporter({
469
469
  }
470
470
  let timeoutsCount = 0;
471
471
  const retry = async (retryableHosts, getTimeout) => {
472
- /**
473
- * We iterate on each host, until there is no host left.
472
+ /**
473
+ * We iterate on each host, until there is no host left.
474
474
  */
475
475
  const host = retryableHosts.pop();
476
476
  if (host === undefined) {
@@ -488,10 +488,10 @@ function createTransporter({
488
488
  connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
489
489
  responseTimeout: getTimeout(timeoutsCount, responseTimeout)
490
490
  };
491
- /**
492
- * The stackFrame is pushed to the stackTrace so we
493
- * can have information about onRetry and onFailure
494
- * decisions.
491
+ /**
492
+ * The stackFrame is pushed to the stackTrace so we
493
+ * can have information about onRetry and onFailure
494
+ * decisions.
495
495
  */
496
496
  const pushToStackTrace = response => {
497
497
  const stackFrame = {
@@ -510,17 +510,17 @@ function createTransporter({
510
510
  if (response.isTimedOut) {
511
511
  timeoutsCount++;
512
512
  }
513
- /**
514
- * Failures are individually sent to the logger, allowing
515
- * the end user to debug / store stack frames even
516
- * when a retry error does not happen.
513
+ /**
514
+ * Failures are individually sent to the logger, allowing
515
+ * the end user to debug / store stack frames even
516
+ * when a retry error does not happen.
517
517
  */
518
518
  // eslint-disable-next-line no-console -- this will be fixed by exposing a `logger` to the transporter
519
519
  console.log('Retryable failure', stackFrameWithoutCredentials(stackFrame));
520
- /**
521
- * We also store the state of the host in failure cases. If the host, is
522
- * down it will remain down for the next 2 minutes. In a timeout situation,
523
- * this host will be added end of the list of hosts on the next request.
520
+ /**
521
+ * We also store the state of the host in failure cases. If the host, is
522
+ * down it will remain down for the next 2 minutes. In a timeout situation,
523
+ * this host will be added end of the list of hosts on the next request.
524
524
  */
525
525
  await hostsCache.set(host, createStatefulHost(host, response.isTimedOut ? 'timed out' : 'down'));
526
526
  return retry(retryableHosts, getTimeout);
@@ -531,56 +531,56 @@ function createTransporter({
531
531
  pushToStackTrace(response);
532
532
  throw deserializeFailure(response, stackTrace);
533
533
  };
534
- /**
535
- * Finally, for each retryable host perform request until we got a non
536
- * retryable response. Some notes here:
537
- *
538
- * 1. The reverse here is applied so we can apply a `pop` later on => more performant.
539
- * 2. We also get from the retryable options a timeout multiplier that is tailored
540
- * for the current context.
534
+ /**
535
+ * Finally, for each retryable host perform request until we got a non
536
+ * retryable response. Some notes here:
537
+ *
538
+ * 1. The reverse here is applied so we can apply a `pop` later on => more performant.
539
+ * 2. We also get from the retryable options a timeout multiplier that is tailored
540
+ * for the current context.
541
541
  */
542
542
  const compatibleHosts = hosts.filter(host => host.accept === 'readWrite' || (isRead ? host.accept === 'read' : host.accept === 'write'));
543
543
  const options = await createRetryableOptions(compatibleHosts);
544
544
  return retry([...options.hosts].reverse(), options.getTimeout);
545
545
  }
546
546
  function createRequest(request, requestOptions = {}) {
547
- /**
548
- * A read request is either a `GET` request, or a request that we make
549
- * via the `read` transporter (e.g. `search`).
547
+ /**
548
+ * A read request is either a `GET` request, or a request that we make
549
+ * via the `read` transporter (e.g. `search`).
550
550
  */
551
551
  const isRead = request.useReadTransporter || request.method === 'GET';
552
552
  if (!isRead) {
553
- /**
554
- * On write requests, no cache mechanisms are applied, and we
555
- * proxy the request immediately to the requester.
553
+ /**
554
+ * On write requests, no cache mechanisms are applied, and we
555
+ * proxy the request immediately to the requester.
556
556
  */
557
557
  return retryableRequest(request, requestOptions, isRead);
558
558
  }
559
559
  const createRetryableRequest = () => {
560
- /**
561
- * Then, we prepare a function factory that contains the construction of
562
- * the retryable request. At this point, we may *not* perform the actual
563
- * request. But we want to have the function factory ready.
560
+ /**
561
+ * Then, we prepare a function factory that contains the construction of
562
+ * the retryable request. At this point, we may *not* perform the actual
563
+ * request. But we want to have the function factory ready.
564
564
  */
565
565
  return retryableRequest(request, requestOptions);
566
566
  };
567
- /**
568
- * Once we have the function factory ready, we need to determine of the
569
- * request is "cacheable" - should be cached. Note that, once again,
570
- * the user can force this option.
567
+ /**
568
+ * Once we have the function factory ready, we need to determine of the
569
+ * request is "cacheable" - should be cached. Note that, once again,
570
+ * the user can force this option.
571
571
  */
572
572
  const cacheable = requestOptions.cacheable || request.cacheable;
573
- /**
574
- * If is not "cacheable", we immediately trigger the retryable request, no
575
- * need to check cache implementations.
573
+ /**
574
+ * If is not "cacheable", we immediately trigger the retryable request, no
575
+ * need to check cache implementations.
576
576
  */
577
577
  if (cacheable !== true) {
578
578
  return createRetryableRequest();
579
579
  }
580
- /**
581
- * If the request is "cacheable", we need to first compute the key to ask
582
- * the cache implementations if this request is on progress or if the
583
- * response already exists on the cache.
580
+ /**
581
+ * If the request is "cacheable", we need to first compute the key to ask
582
+ * the cache implementations if this request is on progress or if the
583
+ * response already exists on the cache.
584
584
  */
585
585
  const key = {
586
586
  request,
@@ -590,27 +590,27 @@ function createTransporter({
590
590
  headers: baseHeaders
591
591
  }
592
592
  };
593
- /**
594
- * With the computed key, we first ask the responses cache
595
- * implementation if this request was been resolved before.
593
+ /**
594
+ * With the computed key, we first ask the responses cache
595
+ * implementation if this request was been resolved before.
596
596
  */
597
597
  return responsesCache.get(key, () => {
598
- /**
599
- * If the request has never resolved before, we actually ask if there
600
- * is a current request with the same key on progress.
598
+ /**
599
+ * If the request has never resolved before, we actually ask if there
600
+ * is a current request with the same key on progress.
601
601
  */
602
602
  return requestsCache.get(key, () =>
603
- /**
604
- * Finally, if there is no request in progress with the same key,
605
- * this `createRetryableRequest()` will actually trigger the
606
- * retryable request.
603
+ /**
604
+ * Finally, if there is no request in progress with the same key,
605
+ * this `createRetryableRequest()` will actually trigger the
606
+ * retryable request.
607
607
  */
608
608
  requestsCache.set(key, createRetryableRequest()).then(response => Promise.all([requestsCache.delete(key), response]), err => Promise.all([requestsCache.delete(key), Promise.reject(err)])).then(([_, response]) => response));
609
609
  }, {
610
- /**
611
- * Of course, once we get this response back from the server, we
612
- * tell response cache to actually store the received response
613
- * to be used later.
610
+ /**
611
+ * Of course, once we get this response back from the server, we
612
+ * tell response cache to actually store the received response
613
+ * to be used later.
614
614
  */
615
615
  miss: response => responsesCache.set(key, response)
616
616
  });
@@ -660,2061 +660,2063 @@ const DEFAULT_CONNECT_TIMEOUT_BROWSER = 1000;
660
660
  const DEFAULT_READ_TIMEOUT_BROWSER = 2000;
661
661
  const DEFAULT_WRITE_TIMEOUT_BROWSER = 30000;
662
662
 
663
- function createXhrRequester() {
664
- function send(request) {
665
- return new Promise((resolve) => {
666
- const baseRequester = new XMLHttpRequest();
667
- baseRequester.open(request.method, request.url, true);
668
- Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
669
- const createTimeout = (timeout, content) => {
670
- return setTimeout(() => {
671
- baseRequester.abort();
672
- resolve({
673
- status: 0,
674
- content,
675
- isTimedOut: true,
676
- });
677
- }, timeout);
678
- };
679
- const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
680
- let responseTimeout;
681
- baseRequester.onreadystatechange = () => {
682
- if (baseRequester.readyState > baseRequester.OPENED &&
683
- responseTimeout === undefined) {
684
- clearTimeout(connectTimeout);
685
- responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
686
- }
687
- };
688
- baseRequester.onerror = () => {
689
- // istanbul ignore next
690
- if (baseRequester.status === 0) {
691
- clearTimeout(connectTimeout);
692
- clearTimeout(responseTimeout);
693
- resolve({
694
- content: baseRequester.responseText || 'Network request failed',
695
- status: baseRequester.status,
696
- isTimedOut: false,
697
- });
698
- }
699
- };
700
- baseRequester.onload = () => {
701
- clearTimeout(connectTimeout);
702
- clearTimeout(responseTimeout);
703
- resolve({
704
- content: baseRequester.responseText,
705
- status: baseRequester.status,
706
- isTimedOut: false,
707
- });
708
- };
709
- baseRequester.send(request.data);
710
- });
711
- }
712
- return { send };
663
+ function createXhrRequester() {
664
+ function send(request) {
665
+ return new Promise((resolve) => {
666
+ const baseRequester = new XMLHttpRequest();
667
+ baseRequester.open(request.method, request.url, true);
668
+ Object.keys(request.headers).forEach((key) => baseRequester.setRequestHeader(key, request.headers[key]));
669
+ const createTimeout = (timeout, content) => {
670
+ return setTimeout(() => {
671
+ baseRequester.abort();
672
+ resolve({
673
+ status: 0,
674
+ content,
675
+ isTimedOut: true,
676
+ });
677
+ }, timeout);
678
+ };
679
+ const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
680
+ let responseTimeout;
681
+ baseRequester.onreadystatechange = () => {
682
+ if (baseRequester.readyState > baseRequester.OPENED &&
683
+ responseTimeout === undefined) {
684
+ clearTimeout(connectTimeout);
685
+ responseTimeout = createTimeout(request.responseTimeout, 'Socket timeout');
686
+ }
687
+ };
688
+ baseRequester.onerror = () => {
689
+ // istanbul ignore next
690
+ if (baseRequester.status === 0) {
691
+ clearTimeout(connectTimeout);
692
+ clearTimeout(responseTimeout);
693
+ resolve({
694
+ content: baseRequester.responseText || 'Network request failed',
695
+ status: baseRequester.status,
696
+ isTimedOut: false,
697
+ });
698
+ }
699
+ };
700
+ baseRequester.onload = () => {
701
+ clearTimeout(connectTimeout);
702
+ clearTimeout(responseTimeout);
703
+ resolve({
704
+ content: baseRequester.responseText,
705
+ status: baseRequester.status,
706
+ isTimedOut: false,
707
+ });
708
+ };
709
+ baseRequester.send(request.data);
710
+ });
711
+ }
712
+ return { send };
713
713
  }
714
714
 
715
- // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
716
- const apiClientVersion = '5.0.0-alpha.52';
717
- function getDefaultHosts(appId) {
718
- return [
719
- {
720
- url: `${appId}-dsn.algolia.net`,
721
- accept: 'read',
722
- protocol: 'https',
723
- },
724
- {
725
- url: `${appId}.algolia.net`,
726
- accept: 'write',
727
- protocol: 'https',
728
- },
729
- ].concat(shuffle([
730
- {
731
- url: `${appId}-1.algolianet.com`,
732
- accept: 'readWrite',
733
- protocol: 'https',
734
- },
735
- {
736
- url: `${appId}-2.algolianet.com`,
737
- accept: 'readWrite',
738
- protocol: 'https',
739
- },
740
- {
741
- url: `${appId}-3.algolianet.com`,
742
- accept: 'readWrite',
743
- protocol: 'https',
744
- },
745
- ]));
746
- }
747
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
748
- function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }) {
749
- const auth = createAuth(appIdOption, apiKeyOption, authMode);
750
- const transporter = createTransporter({
751
- hosts: getDefaultHosts(appIdOption),
752
- ...options,
753
- algoliaAgent: getAlgoliaAgent({
754
- algoliaAgents,
755
- client: 'Search',
756
- version: apiClientVersion,
757
- }),
758
- baseHeaders: {
759
- 'content-type': 'text/plain',
760
- ...auth.headers(),
761
- ...options.baseHeaders,
762
- },
763
- baseQueryParameters: {
764
- ...auth.queryParameters(),
765
- ...options.baseQueryParameters,
766
- },
767
- });
768
- return {
769
- transporter,
770
- /**
771
- * The `appId` currently in use.
772
- */
773
- appId: appIdOption,
774
- /**
775
- * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
776
- */
777
- clearCache() {
778
- return Promise.all([
779
- transporter.requestsCache.clear(),
780
- transporter.responsesCache.clear(),
781
- ]).then(() => undefined);
782
- },
783
- /**
784
- * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
785
- */
786
- get _ua() {
787
- return transporter.algoliaAgent.value;
788
- },
789
- /**
790
- * Adds a `segment` to the `x-algolia-agent` sent with every requests.
791
- *
792
- * @param segment - The algolia agent (user-agent) segment to add.
793
- * @param version - The version of the agent.
794
- */
795
- addAlgoliaAgent(segment, version) {
796
- transporter.algoliaAgent.add({ segment, version });
797
- },
798
- /**
799
- * Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
800
- *
801
- * @summary Helper method that waits for a task to be published (completed).
802
- * @param waitForTaskOptions - The waitForTaskOptions object.
803
- * @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
804
- * @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
805
- * @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
806
- * @param waitForTaskOptions.timeout - The function to decide how long to wait between retries.
807
- * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
808
- */
809
- waitForTask({ indexName, taskID, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
810
- let retryCount = 0;
811
- return createIterablePromise({
812
- func: () => this.getTask({ indexName, taskID }, requestOptions),
813
- validate: (response) => response.status === 'published',
814
- aggregator: () => (retryCount += 1),
815
- error: {
816
- validate: () => retryCount >= maxRetries,
817
- message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
818
- },
819
- timeout: () => timeout(retryCount),
820
- });
821
- },
822
- /**
823
- * Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
824
- *
825
- * @summary Helper method that waits for an API key task to be processed.
826
- * @param waitForApiKeyOptions - The waitForApiKeyOptions object.
827
- * @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
828
- * @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
829
- * @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
830
- * @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 50 by default.
831
- * @param waitForApiKeyOptions.timeout - The function to decide how long to wait between retries.
832
- * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
833
- */
834
- waitForApiKey({ operation, key, apiKey, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
835
- let retryCount = 0;
836
- const baseIteratorOptions = {
837
- aggregator: () => (retryCount += 1),
838
- error: {
839
- validate: () => retryCount >= maxRetries,
840
- message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
841
- },
842
- timeout: () => timeout(retryCount),
843
- };
844
- if (operation === 'update') {
845
- if (!apiKey) {
846
- throw new Error('`apiKey` is required when waiting for an `update` operation.');
847
- }
848
- return createIterablePromise({
849
- ...baseIteratorOptions,
850
- func: () => this.getApiKey({ key }, requestOptions),
851
- validate: (response) => {
852
- for (const field of Object.keys(apiKey)) {
853
- if (Array.isArray(apiKey[field])) {
854
- if (apiKey[field].length !== response[field].length ||
855
- apiKey[field].some((value, index) => value !== response[field][index])) {
856
- return false;
857
- }
858
- }
859
- else if (response[field] !== apiKey[field]) {
860
- return false;
861
- }
862
- }
863
- return true;
864
- },
865
- });
866
- }
867
- return createIterablePromise({
868
- ...baseIteratorOptions,
869
- func: () => this.getApiKey({ key }, requestOptions).catch((error) => error),
870
- validate: (error) => operation === 'add' ? error.status !== 404 : error.status === 404,
871
- });
872
- },
873
- /**
874
- * Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
875
- *
876
- * @summary Helper method that iterates on the `browse` method.
877
- * @param browseObjects - The browseObjects object.
878
- * @param browseObjects.indexName - The index in which to perform the request.
879
- * @param browseObjects.browseParams - The `browse` parameters.
880
- * @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is no `cursor` in the response.
881
- * @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
882
- * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
883
- */
884
- browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
885
- return createIterablePromise({
886
- func: (previousResponse) => {
887
- return this.browse({
888
- indexName,
889
- browseParams: {
890
- cursor: previousResponse ? previousResponse.cursor : undefined,
891
- ...browseParams,
892
- },
893
- }, requestOptions);
894
- },
895
- validate: (response) => response.cursor === undefined,
896
- ...browseObjectsOptions,
897
- });
898
- },
899
- /**
900
- * Helper: Iterate on the `searchRules` method of the client to allow aggregating rules of an index.
901
- *
902
- * @summary Helper method that iterates on the `searchRules` method.
903
- * @param browseObjects - The browseObjects object.
904
- * @param browseObjects.indexName - The index in which to perform the request.
905
- * @param browseObjects.searchRulesParams - The `searchRules` method parameters.
906
- * @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
907
- * @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
908
- * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
909
- */
910
- browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
911
- const params = {
912
- hitsPerPage: 1000,
913
- ...searchRulesParams,
914
- };
915
- return createIterablePromise({
916
- func: (previousResponse) => {
917
- return this.searchRules({
918
- indexName,
919
- searchRulesParams: {
920
- ...params,
921
- page: previousResponse
922
- ? previousResponse.page + 1
923
- : params.page || 0,
924
- },
925
- }, requestOptions);
926
- },
927
- validate: (response) => response.nbHits < params.hitsPerPage,
928
- ...browseRulesOptions,
929
- });
930
- },
931
- /**
932
- * Helper: Iterate on the `searchSynonyms` method of the client to allow aggregating rules of an index.
933
- *
934
- * @summary Helper method that iterates on the `searchSynonyms` method.
935
- * @param browseObjects - The browseObjects object.
936
- * @param browseObjects.indexName - The index in which to perform the request.
937
- * @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
938
- * @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
939
- * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
940
- */
941
- browseSynonyms({ indexName, validate, aggregator, ...browseSynonymsOptions }, requestOptions) {
942
- const params = {
943
- hitsPerPage: 1000,
944
- ...browseSynonymsOptions,
945
- };
946
- return createIterablePromise({
947
- func: (previousResponse) => {
948
- return this.searchSynonyms({
949
- ...params,
950
- indexName,
951
- page: previousResponse
952
- ? previousResponse.page + 1
953
- : browseSynonymsOptions.page || 0,
954
- }, requestOptions);
955
- },
956
- validate: (response) => response.nbHits < params.hitsPerPage,
957
- ...browseSynonymsOptions,
958
- });
959
- },
960
- /**
961
- * Add a new API Key with specific permissions/restrictions.
962
- *
963
- * @summary Create an API key.
964
- * @param apiKey - The apiKey object.
965
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
966
- */
967
- addApiKey(apiKey, requestOptions) {
968
- if (!apiKey) {
969
- throw new Error('Parameter `apiKey` is required when calling `addApiKey`.');
970
- }
971
- if (!apiKey.acl) {
972
- throw new Error('Parameter `apiKey.acl` is required when calling `addApiKey`.');
973
- }
974
- const requestPath = '/1/keys';
975
- const headers = {};
976
- const queryParameters = {};
977
- const request = {
978
- method: 'POST',
979
- path: requestPath,
980
- queryParameters,
981
- headers,
982
- data: apiKey,
983
- };
984
- return transporter.request(request, requestOptions);
985
- },
986
- /**
987
- * Add or replace an object with a given object ID. If the object does not exist, it will be created. If it already exists, it will be replaced.
988
- *
989
- * @summary Add or replace an object.
990
- * @param addOrUpdateObject - The addOrUpdateObject object.
991
- * @param addOrUpdateObject.indexName - The index in which to perform the request.
992
- * @param addOrUpdateObject.objectID - Unique identifier of an object.
993
- * @param addOrUpdateObject.body - The Algolia object.
994
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
995
- */
996
- addOrUpdateObject({ indexName, objectID, body }, requestOptions) {
997
- if (!indexName) {
998
- throw new Error('Parameter `indexName` is required when calling `addOrUpdateObject`.');
999
- }
1000
- if (!objectID) {
1001
- throw new Error('Parameter `objectID` is required when calling `addOrUpdateObject`.');
1002
- }
1003
- if (!body) {
1004
- throw new Error('Parameter `body` is required when calling `addOrUpdateObject`.');
1005
- }
1006
- const requestPath = '/1/indexes/{indexName}/{objectID}'
1007
- .replace('{indexName}', encodeURIComponent(indexName))
1008
- .replace('{objectID}', encodeURIComponent(objectID));
1009
- const headers = {};
1010
- const queryParameters = {};
1011
- const request = {
1012
- method: 'PUT',
1013
- path: requestPath,
1014
- queryParameters,
1015
- headers,
1016
- data: body,
1017
- };
1018
- return transporter.request(request, requestOptions);
1019
- },
1020
- /**
1021
- * Add a single source to the list of allowed sources.
1022
- *
1023
- * @summary Add a single source.
1024
- * @param source - The source to add.
1025
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1026
- */
1027
- appendSource(source, requestOptions) {
1028
- if (!source) {
1029
- throw new Error('Parameter `source` is required when calling `appendSource`.');
1030
- }
1031
- if (!source.source) {
1032
- throw new Error('Parameter `source.source` is required when calling `appendSource`.');
1033
- }
1034
- const requestPath = '/1/security/sources/append';
1035
- const headers = {};
1036
- const queryParameters = {};
1037
- const request = {
1038
- method: 'POST',
1039
- path: requestPath,
1040
- queryParameters,
1041
- headers,
1042
- data: source,
1043
- };
1044
- return transporter.request(request, requestOptions);
1045
- },
1046
- /**
1047
- * Assign or Move a userID to a cluster. The time it takes to migrate (move) a user is proportional to the amount of data linked to the userID. Upon success, the response is 200 OK. A successful response indicates that the operation has been taken into account, and the userID is directly usable.
1048
- *
1049
- * @summary Assign or Move userID.
1050
- * @param assignUserId - The assignUserId object.
1051
- * @param assignUserId.xAlgoliaUserID - UserID to assign.
1052
- * @param assignUserId.assignUserIdParams - The assignUserIdParams object.
1053
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1054
- */
1055
- assignUserId({ xAlgoliaUserID, assignUserIdParams }, requestOptions) {
1056
- if (!xAlgoliaUserID) {
1057
- throw new Error('Parameter `xAlgoliaUserID` is required when calling `assignUserId`.');
1058
- }
1059
- if (!assignUserIdParams) {
1060
- throw new Error('Parameter `assignUserIdParams` is required when calling `assignUserId`.');
1061
- }
1062
- if (!assignUserIdParams.cluster) {
1063
- throw new Error('Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.');
1064
- }
1065
- const requestPath = '/1/clusters/mapping';
1066
- const headers = {};
1067
- const queryParameters = {};
1068
- if (xAlgoliaUserID !== undefined) {
1069
- headers['X-Algolia-User-ID'] = xAlgoliaUserID.toString();
1070
- }
1071
- const request = {
1072
- method: 'POST',
1073
- path: requestPath,
1074
- queryParameters,
1075
- headers,
1076
- data: assignUserIdParams,
1077
- };
1078
- return transporter.request(request, requestOptions);
1079
- },
1080
- /**
1081
- * Perform multiple write operations targeting one index, in a single API call.
1082
- *
1083
- * @summary Batch operations to one index.
1084
- * @param batch - The batch object.
1085
- * @param batch.indexName - The index in which to perform the request.
1086
- * @param batch.batchWriteParams - The batchWriteParams object.
1087
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1088
- */
1089
- batch({ indexName, batchWriteParams }, requestOptions) {
1090
- if (!indexName) {
1091
- throw new Error('Parameter `indexName` is required when calling `batch`.');
1092
- }
1093
- if (!batchWriteParams) {
1094
- throw new Error('Parameter `batchWriteParams` is required when calling `batch`.');
1095
- }
1096
- if (!batchWriteParams.requests) {
1097
- throw new Error('Parameter `batchWriteParams.requests` is required when calling `batch`.');
1098
- }
1099
- const requestPath = '/1/indexes/{indexName}/batch'.replace('{indexName}', encodeURIComponent(indexName));
1100
- const headers = {};
1101
- const queryParameters = {};
1102
- const request = {
1103
- method: 'POST',
1104
- path: requestPath,
1105
- queryParameters,
1106
- headers,
1107
- data: batchWriteParams,
1108
- };
1109
- return transporter.request(request, requestOptions);
1110
- },
1111
- /**
1112
- * Assign multiple userIDs to a cluster. Upon success, the response is 200 OK. A successful response indicates that the operation has been taken into account, and the userIDs are directly usable.
1113
- *
1114
- * @summary Batch assign userIDs.
1115
- * @param batchAssignUserIds - The batchAssignUserIds object.
1116
- * @param batchAssignUserIds.xAlgoliaUserID - UserID to assign.
1117
- * @param batchAssignUserIds.batchAssignUserIdsParams - The batchAssignUserIdsParams object.
1118
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1119
- */
1120
- batchAssignUserIds({ xAlgoliaUserID, batchAssignUserIdsParams }, requestOptions) {
1121
- if (!xAlgoliaUserID) {
1122
- throw new Error('Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.');
1123
- }
1124
- if (!batchAssignUserIdsParams) {
1125
- throw new Error('Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.');
1126
- }
1127
- if (!batchAssignUserIdsParams.cluster) {
1128
- throw new Error('Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.');
1129
- }
1130
- if (!batchAssignUserIdsParams.users) {
1131
- throw new Error('Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.');
1132
- }
1133
- const requestPath = '/1/clusters/mapping/batch';
1134
- const headers = {};
1135
- const queryParameters = {};
1136
- if (xAlgoliaUserID !== undefined) {
1137
- headers['X-Algolia-User-ID'] = xAlgoliaUserID.toString();
1138
- }
1139
- const request = {
1140
- method: 'POST',
1141
- path: requestPath,
1142
- queryParameters,
1143
- headers,
1144
- data: batchAssignUserIdsParams,
1145
- };
1146
- return transporter.request(request, requestOptions);
1147
- },
1148
- /**
1149
- * Send a batch of dictionary entries.
1150
- *
1151
- * @summary Batch dictionary entries.
1152
- * @param batchDictionaryEntries - The batchDictionaryEntries object.
1153
- * @param batchDictionaryEntries.dictionaryName - The dictionary to search in.
1154
- * @param batchDictionaryEntries.batchDictionaryEntriesParams - The batchDictionaryEntriesParams object.
1155
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1156
- */
1157
- batchDictionaryEntries({ dictionaryName, batchDictionaryEntriesParams, }, requestOptions) {
1158
- if (!dictionaryName) {
1159
- throw new Error('Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.');
1160
- }
1161
- if (!batchDictionaryEntriesParams) {
1162
- throw new Error('Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.');
1163
- }
1164
- if (!batchDictionaryEntriesParams.requests) {
1165
- throw new Error('Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`.');
1166
- }
1167
- const requestPath = '/1/dictionaries/{dictionaryName}/batch'.replace('{dictionaryName}', encodeURIComponent(dictionaryName));
1168
- const headers = {};
1169
- const queryParameters = {};
1170
- const request = {
1171
- method: 'POST',
1172
- path: requestPath,
1173
- queryParameters,
1174
- headers,
1175
- data: batchDictionaryEntriesParams,
1176
- };
1177
- return transporter.request(request, requestOptions);
1178
- },
1179
- /**
1180
- * This method allows you to retrieve all index content. It can retrieve up to 1,000 records per call and supports full text search and filters. For performance reasons, some features are not supported, including `distinct`, sorting by `typos`, `words` or `geo distance`. When there is more content to be browsed, the response contains a cursor field. This cursor has to be passed to the subsequent call to browse in order to get the next page of results. When the end of the index has been reached, the cursor field is absent from the response.
1181
- *
1182
- * @summary Retrieve all index content.
1183
- * @param browse - The browse object.
1184
- * @param browse.indexName - The index in which to perform the request.
1185
- * @param browse.browseParams - The browseParams object.
1186
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1187
- */
1188
- browse({ indexName, browseParams }, requestOptions) {
1189
- if (!indexName) {
1190
- throw new Error('Parameter `indexName` is required when calling `browse`.');
1191
- }
1192
- const requestPath = '/1/indexes/{indexName}/browse'.replace('{indexName}', encodeURIComponent(indexName));
1193
- const headers = {};
1194
- const queryParameters = {};
1195
- const request = {
1196
- method: 'POST',
1197
- path: requestPath,
1198
- queryParameters,
1199
- headers,
1200
- data: browseParams ? browseParams : {},
1201
- };
1202
- return transporter.request(request, requestOptions);
1203
- },
1204
- /**
1205
- * Remove all synonyms from an index.
1206
- *
1207
- * @summary Clear all synonyms.
1208
- * @param clearAllSynonyms - The clearAllSynonyms object.
1209
- * @param clearAllSynonyms.indexName - The index in which to perform the request.
1210
- * @param clearAllSynonyms.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1211
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1212
- */
1213
- clearAllSynonyms({ indexName, forwardToReplicas }, requestOptions) {
1214
- if (!indexName) {
1215
- throw new Error('Parameter `indexName` is required when calling `clearAllSynonyms`.');
1216
- }
1217
- const requestPath = '/1/indexes/{indexName}/synonyms/clear'.replace('{indexName}', encodeURIComponent(indexName));
1218
- const headers = {};
1219
- const queryParameters = {};
1220
- if (forwardToReplicas !== undefined) {
1221
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
1222
- }
1223
- const request = {
1224
- method: 'POST',
1225
- path: requestPath,
1226
- queryParameters,
1227
- headers,
1228
- };
1229
- return transporter.request(request, requestOptions);
1230
- },
1231
- /**
1232
- * Delete an index\'s content, but leave settings and index-specific API keys untouched.
1233
- *
1234
- * @summary Clear all objects from an index.
1235
- * @param clearObjects - The clearObjects object.
1236
- * @param clearObjects.indexName - The index in which to perform the request.
1237
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1238
- */
1239
- clearObjects({ indexName }, requestOptions) {
1240
- if (!indexName) {
1241
- throw new Error('Parameter `indexName` is required when calling `clearObjects`.');
1242
- }
1243
- const requestPath = '/1/indexes/{indexName}/clear'.replace('{indexName}', encodeURIComponent(indexName));
1244
- const headers = {};
1245
- const queryParameters = {};
1246
- const request = {
1247
- method: 'POST',
1248
- path: requestPath,
1249
- queryParameters,
1250
- headers,
1251
- };
1252
- return transporter.request(request, requestOptions);
1253
- },
1254
- /**
1255
- * Delete all Rules in the index.
1256
- *
1257
- * @summary Clear Rules.
1258
- * @param clearRules - The clearRules object.
1259
- * @param clearRules.indexName - The index in which to perform the request.
1260
- * @param clearRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1261
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1262
- */
1263
- clearRules({ indexName, forwardToReplicas }, requestOptions) {
1264
- if (!indexName) {
1265
- throw new Error('Parameter `indexName` is required when calling `clearRules`.');
1266
- }
1267
- const requestPath = '/1/indexes/{indexName}/rules/clear'.replace('{indexName}', encodeURIComponent(indexName));
1268
- const headers = {};
1269
- const queryParameters = {};
1270
- if (forwardToReplicas !== undefined) {
1271
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
1272
- }
1273
- const request = {
1274
- method: 'POST',
1275
- path: requestPath,
1276
- queryParameters,
1277
- headers,
1278
- };
1279
- return transporter.request(request, requestOptions);
1280
- },
1281
- /**
1282
- * This method allow you to send requests to the Algolia REST API.
1283
- *
1284
- * @summary Send requests to the Algolia REST API.
1285
- * @param del - The del object.
1286
- * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1287
- * @param del.parameters - Query parameters to be applied to the current query.
1288
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1289
- */
1290
- del({ path, parameters }, requestOptions) {
1291
- if (!path) {
1292
- throw new Error('Parameter `path` is required when calling `del`.');
1293
- }
1294
- const requestPath = '/1{path}'.replace('{path}', path);
1295
- const headers = {};
1296
- const queryParameters = parameters ? parameters : {};
1297
- const request = {
1298
- method: 'DELETE',
1299
- path: requestPath,
1300
- queryParameters,
1301
- headers,
1302
- };
1303
- return transporter.request(request, requestOptions);
1304
- },
1305
- /**
1306
- * Delete an existing API Key.
1307
- *
1308
- * @summary Delete an API key.
1309
- * @param deleteApiKey - The deleteApiKey object.
1310
- * @param deleteApiKey.key - API Key string.
1311
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1312
- */
1313
- deleteApiKey({ key }, requestOptions) {
1314
- if (!key) {
1315
- throw new Error('Parameter `key` is required when calling `deleteApiKey`.');
1316
- }
1317
- const requestPath = '/1/keys/{key}'.replace('{key}', encodeURIComponent(key));
1318
- const headers = {};
1319
- const queryParameters = {};
1320
- const request = {
1321
- method: 'DELETE',
1322
- path: requestPath,
1323
- queryParameters,
1324
- headers,
1325
- };
1326
- return transporter.request(request, requestOptions);
1327
- },
1328
- /**
1329
- * Remove all objects matching a filter (including geo filters). This method enables you to delete one or more objects based on filters (numeric, facet, tag or geo queries). It doesn\'t accept empty filters or a query.
1330
- *
1331
- * @summary Delete all records matching the query.
1332
- * @param deleteBy - The deleteBy object.
1333
- * @param deleteBy.indexName - The index in which to perform the request.
1334
- * @param deleteBy.deleteByParams - The deleteByParams object.
1335
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1336
- */
1337
- deleteBy({ indexName, deleteByParams }, requestOptions) {
1338
- if (!indexName) {
1339
- throw new Error('Parameter `indexName` is required when calling `deleteBy`.');
1340
- }
1341
- if (!deleteByParams) {
1342
- throw new Error('Parameter `deleteByParams` is required when calling `deleteBy`.');
1343
- }
1344
- const requestPath = '/1/indexes/{indexName}/deleteByQuery'.replace('{indexName}', encodeURIComponent(indexName));
1345
- const headers = {};
1346
- const queryParameters = {};
1347
- const request = {
1348
- method: 'POST',
1349
- path: requestPath,
1350
- queryParameters,
1351
- headers,
1352
- data: deleteByParams,
1353
- };
1354
- return transporter.request(request, requestOptions);
1355
- },
1356
- /**
1357
- * Delete an existing index.
1358
- *
1359
- * @summary Delete index.
1360
- * @param deleteIndex - The deleteIndex object.
1361
- * @param deleteIndex.indexName - The index in which to perform the request.
1362
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1363
- */
1364
- deleteIndex({ indexName }, requestOptions) {
1365
- if (!indexName) {
1366
- throw new Error('Parameter `indexName` is required when calling `deleteIndex`.');
1367
- }
1368
- const requestPath = '/1/indexes/{indexName}'.replace('{indexName}', encodeURIComponent(indexName));
1369
- const headers = {};
1370
- const queryParameters = {};
1371
- const request = {
1372
- method: 'DELETE',
1373
- path: requestPath,
1374
- queryParameters,
1375
- headers,
1376
- };
1377
- return transporter.request(request, requestOptions);
1378
- },
1379
- /**
1380
- * Delete an existing object.
1381
- *
1382
- * @summary Delete an object.
1383
- * @param deleteObject - The deleteObject object.
1384
- * @param deleteObject.indexName - The index in which to perform the request.
1385
- * @param deleteObject.objectID - Unique identifier of an object.
1386
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1387
- */
1388
- deleteObject({ indexName, objectID }, requestOptions) {
1389
- if (!indexName) {
1390
- throw new Error('Parameter `indexName` is required when calling `deleteObject`.');
1391
- }
1392
- if (!objectID) {
1393
- throw new Error('Parameter `objectID` is required when calling `deleteObject`.');
1394
- }
1395
- const requestPath = '/1/indexes/{indexName}/{objectID}'
1396
- .replace('{indexName}', encodeURIComponent(indexName))
1397
- .replace('{objectID}', encodeURIComponent(objectID));
1398
- const headers = {};
1399
- const queryParameters = {};
1400
- const request = {
1401
- method: 'DELETE',
1402
- path: requestPath,
1403
- queryParameters,
1404
- headers,
1405
- };
1406
- return transporter.request(request, requestOptions);
1407
- },
1408
- /**
1409
- * Delete the Rule with the specified objectID.
1410
- *
1411
- * @summary Delete a rule.
1412
- * @param deleteRule - The deleteRule object.
1413
- * @param deleteRule.indexName - The index in which to perform the request.
1414
- * @param deleteRule.objectID - Unique identifier of an object.
1415
- * @param deleteRule.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1416
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1417
- */
1418
- deleteRule({ indexName, objectID, forwardToReplicas }, requestOptions) {
1419
- if (!indexName) {
1420
- throw new Error('Parameter `indexName` is required when calling `deleteRule`.');
1421
- }
1422
- if (!objectID) {
1423
- throw new Error('Parameter `objectID` is required when calling `deleteRule`.');
1424
- }
1425
- const requestPath = '/1/indexes/{indexName}/rules/{objectID}'
1426
- .replace('{indexName}', encodeURIComponent(indexName))
1427
- .replace('{objectID}', encodeURIComponent(objectID));
1428
- const headers = {};
1429
- const queryParameters = {};
1430
- if (forwardToReplicas !== undefined) {
1431
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
1432
- }
1433
- const request = {
1434
- method: 'DELETE',
1435
- path: requestPath,
1436
- queryParameters,
1437
- headers,
1438
- };
1439
- return transporter.request(request, requestOptions);
1440
- },
1441
- /**
1442
- * Remove a single source from the list of allowed sources.
1443
- *
1444
- * @summary Remove a single source.
1445
- * @param deleteSource - The deleteSource object.
1446
- * @param deleteSource.source - The IP range of the source.
1447
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1448
- */
1449
- deleteSource({ source }, requestOptions) {
1450
- if (!source) {
1451
- throw new Error('Parameter `source` is required when calling `deleteSource`.');
1452
- }
1453
- const requestPath = '/1/security/sources/{source}'.replace('{source}', encodeURIComponent(source));
1454
- const headers = {};
1455
- const queryParameters = {};
1456
- const request = {
1457
- method: 'DELETE',
1458
- path: requestPath,
1459
- queryParameters,
1460
- headers,
1461
- };
1462
- return transporter.request(request, requestOptions);
1463
- },
1464
- /**
1465
- * Delete a single synonyms set, identified by the given objectID.
1466
- *
1467
- * @summary Delete synonym.
1468
- * @param deleteSynonym - The deleteSynonym object.
1469
- * @param deleteSynonym.indexName - The index in which to perform the request.
1470
- * @param deleteSynonym.objectID - Unique identifier of an object.
1471
- * @param deleteSynonym.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1472
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1473
- */
1474
- deleteSynonym({ indexName, objectID, forwardToReplicas }, requestOptions) {
1475
- if (!indexName) {
1476
- throw new Error('Parameter `indexName` is required when calling `deleteSynonym`.');
1477
- }
1478
- if (!objectID) {
1479
- throw new Error('Parameter `objectID` is required when calling `deleteSynonym`.');
1480
- }
1481
- const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}'
1482
- .replace('{indexName}', encodeURIComponent(indexName))
1483
- .replace('{objectID}', encodeURIComponent(objectID));
1484
- const headers = {};
1485
- const queryParameters = {};
1486
- if (forwardToReplicas !== undefined) {
1487
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
1488
- }
1489
- const request = {
1490
- method: 'DELETE',
1491
- path: requestPath,
1492
- queryParameters,
1493
- headers,
1494
- };
1495
- return transporter.request(request, requestOptions);
1496
- },
1497
- /**
1498
- * This method allow you to send requests to the Algolia REST API.
1499
- *
1500
- * @summary Send requests to the Algolia REST API.
1501
- * @param get - The get object.
1502
- * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1503
- * @param get.parameters - Query parameters to be applied to the current query.
1504
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1505
- */
1506
- get({ path, parameters }, requestOptions) {
1507
- if (!path) {
1508
- throw new Error('Parameter `path` is required when calling `get`.');
1509
- }
1510
- const requestPath = '/1{path}'.replace('{path}', path);
1511
- const headers = {};
1512
- const queryParameters = parameters ? parameters : {};
1513
- const request = {
1514
- method: 'GET',
1515
- path: requestPath,
1516
- queryParameters,
1517
- headers,
1518
- };
1519
- return transporter.request(request, requestOptions);
1520
- },
1521
- /**
1522
- * Get the permissions of an API key.
1523
- *
1524
- * @summary Get an API key.
1525
- * @param getApiKey - The getApiKey object.
1526
- * @param getApiKey.key - API Key string.
1527
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1528
- */
1529
- getApiKey({ key }, requestOptions) {
1530
- if (!key) {
1531
- throw new Error('Parameter `key` is required when calling `getApiKey`.');
1532
- }
1533
- const requestPath = '/1/keys/{key}'.replace('{key}', encodeURIComponent(key));
1534
- const headers = {};
1535
- const queryParameters = {};
1536
- const request = {
1537
- method: 'GET',
1538
- path: requestPath,
1539
- queryParameters,
1540
- headers,
1541
- };
1542
- return transporter.request(request, requestOptions);
1543
- },
1544
- /**
1545
- * List dictionaries supported per language.
1546
- *
1547
- * @summary List available languages.
1548
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1549
- */
1550
- getDictionaryLanguages(requestOptions) {
1551
- const requestPath = '/1/dictionaries/*/languages';
1552
- const headers = {};
1553
- const queryParameters = {};
1554
- const request = {
1555
- method: 'GET',
1556
- path: requestPath,
1557
- queryParameters,
1558
- headers,
1559
- };
1560
- return transporter.request(request, requestOptions);
1561
- },
1562
- /**
1563
- * Retrieve dictionaries settings. The API stores languages whose standard entries are disabled. Fetch settings does not return false values.
1564
- *
1565
- * @summary Retrieve dictionaries settings.
1566
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1567
- */
1568
- getDictionarySettings(requestOptions) {
1569
- const requestPath = '/1/dictionaries/*/settings';
1570
- const headers = {};
1571
- const queryParameters = {};
1572
- const request = {
1573
- method: 'GET',
1574
- path: requestPath,
1575
- queryParameters,
1576
- headers,
1577
- };
1578
- return transporter.request(request, requestOptions);
1579
- },
1580
- /**
1581
- * Return the latest log entries.
1582
- *
1583
- * @summary Return the latest log entries.
1584
- * @param getLogs - The getLogs object.
1585
- * @param getLogs.offset - First entry to retrieve (zero-based). Log entries are sorted by decreasing date, therefore 0 designates the most recent log entry.
1586
- * @param getLogs.length - Maximum number of entries to retrieve. The maximum allowed value is 1000.
1587
- * @param getLogs.indexName - Index for which log entries should be retrieved. When omitted, log entries are retrieved across all indices.
1588
- * @param getLogs.type - Type of log entries to retrieve. When omitted, all log entries are retrieved.
1589
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1590
- */
1591
- getLogs({ offset, length, indexName, type } = {}, requestOptions = undefined) {
1592
- const requestPath = '/1/logs';
1593
- const headers = {};
1594
- const queryParameters = {};
1595
- if (offset !== undefined) {
1596
- queryParameters.offset = offset.toString();
1597
- }
1598
- if (length !== undefined) {
1599
- queryParameters.length = length.toString();
1600
- }
1601
- if (indexName !== undefined) {
1602
- queryParameters.indexName = indexName.toString();
1603
- }
1604
- if (type !== undefined) {
1605
- queryParameters.type = type.toString();
1606
- }
1607
- const request = {
1608
- method: 'GET',
1609
- path: requestPath,
1610
- queryParameters,
1611
- headers,
1612
- };
1613
- return transporter.request(request, requestOptions);
1614
- },
1615
- /**
1616
- * Retrieve one object from the index.
1617
- *
1618
- * @summary Retrieve an object.
1619
- * @param getObject - The getObject object.
1620
- * @param getObject.indexName - The index in which to perform the request.
1621
- * @param getObject.objectID - Unique identifier of an object.
1622
- * @param getObject.attributesToRetrieve - List of attributes to retrieve. If not specified, all retrievable attributes are returned.
1623
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1624
- */
1625
- getObject({ indexName, objectID, attributesToRetrieve }, requestOptions) {
1626
- if (!indexName) {
1627
- throw new Error('Parameter `indexName` is required when calling `getObject`.');
1628
- }
1629
- if (!objectID) {
1630
- throw new Error('Parameter `objectID` is required when calling `getObject`.');
1631
- }
1632
- const requestPath = '/1/indexes/{indexName}/{objectID}'
1633
- .replace('{indexName}', encodeURIComponent(indexName))
1634
- .replace('{objectID}', encodeURIComponent(objectID));
1635
- const headers = {};
1636
- const queryParameters = {};
1637
- if (attributesToRetrieve !== undefined) {
1638
- queryParameters.attributesToRetrieve = attributesToRetrieve.toString();
1639
- }
1640
- const request = {
1641
- method: 'GET',
1642
- path: requestPath,
1643
- queryParameters,
1644
- headers,
1645
- };
1646
- return transporter.request(request, requestOptions);
1647
- },
1648
- /**
1649
- * Retrieve one or more objects, potentially from different indices, in a single API call.
1650
- *
1651
- * @summary Retrieve one or more objects.
1652
- * @param getObjectsParams - The Algolia object.
1653
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1654
- */
1655
- getObjects(getObjectsParams, requestOptions) {
1656
- if (!getObjectsParams) {
1657
- throw new Error('Parameter `getObjectsParams` is required when calling `getObjects`.');
1658
- }
1659
- if (!getObjectsParams.requests) {
1660
- throw new Error('Parameter `getObjectsParams.requests` is required when calling `getObjects`.');
1661
- }
1662
- const requestPath = '/1/indexes/*/objects';
1663
- const headers = {};
1664
- const queryParameters = {};
1665
- const request = {
1666
- method: 'POST',
1667
- path: requestPath,
1668
- queryParameters,
1669
- headers,
1670
- data: getObjectsParams,
1671
- useReadTransporter: true,
1672
- cacheable: true,
1673
- };
1674
- return transporter.request(request, requestOptions);
1675
- },
1676
- /**
1677
- * Retrieve the Rule with the specified objectID.
1678
- *
1679
- * @summary Get a rule.
1680
- * @param getRule - The getRule object.
1681
- * @param getRule.indexName - The index in which to perform the request.
1682
- * @param getRule.objectID - Unique identifier of an object.
1683
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1684
- */
1685
- getRule({ indexName, objectID }, requestOptions) {
1686
- if (!indexName) {
1687
- throw new Error('Parameter `indexName` is required when calling `getRule`.');
1688
- }
1689
- if (!objectID) {
1690
- throw new Error('Parameter `objectID` is required when calling `getRule`.');
1691
- }
1692
- const requestPath = '/1/indexes/{indexName}/rules/{objectID}'
1693
- .replace('{indexName}', encodeURIComponent(indexName))
1694
- .replace('{objectID}', encodeURIComponent(objectID));
1695
- const headers = {};
1696
- const queryParameters = {};
1697
- const request = {
1698
- method: 'GET',
1699
- path: requestPath,
1700
- queryParameters,
1701
- headers,
1702
- };
1703
- return transporter.request(request, requestOptions);
1704
- },
1705
- /**
1706
- * Retrieve settings of an index.
1707
- *
1708
- * @summary Retrieve settings of an index.
1709
- * @param getSettings - The getSettings object.
1710
- * @param getSettings.indexName - The index in which to perform the request.
1711
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1712
- */
1713
- getSettings({ indexName }, requestOptions) {
1714
- if (!indexName) {
1715
- throw new Error('Parameter `indexName` is required when calling `getSettings`.');
1716
- }
1717
- const requestPath = '/1/indexes/{indexName}/settings'.replace('{indexName}', encodeURIComponent(indexName));
1718
- const headers = {};
1719
- const queryParameters = {};
1720
- const request = {
1721
- method: 'GET',
1722
- path: requestPath,
1723
- queryParameters,
1724
- headers,
1725
- };
1726
- return transporter.request(request, requestOptions);
1727
- },
1728
- /**
1729
- * List all allowed sources.
1730
- *
1731
- * @summary List all allowed sources.
1732
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1733
- */
1734
- getSources(requestOptions) {
1735
- const requestPath = '/1/security/sources';
1736
- const headers = {};
1737
- const queryParameters = {};
1738
- const request = {
1739
- method: 'GET',
1740
- path: requestPath,
1741
- queryParameters,
1742
- headers,
1743
- };
1744
- return transporter.request(request, requestOptions);
1745
- },
1746
- /**
1747
- * Fetch a synonym object identified by its objectID.
1748
- *
1749
- * @summary Get synonym.
1750
- * @param getSynonym - The getSynonym object.
1751
- * @param getSynonym.indexName - The index in which to perform the request.
1752
- * @param getSynonym.objectID - Unique identifier of an object.
1753
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1754
- */
1755
- getSynonym({ indexName, objectID }, requestOptions) {
1756
- if (!indexName) {
1757
- throw new Error('Parameter `indexName` is required when calling `getSynonym`.');
1758
- }
1759
- if (!objectID) {
1760
- throw new Error('Parameter `objectID` is required when calling `getSynonym`.');
1761
- }
1762
- const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}'
1763
- .replace('{indexName}', encodeURIComponent(indexName))
1764
- .replace('{objectID}', encodeURIComponent(objectID));
1765
- const headers = {};
1766
- const queryParameters = {};
1767
- const request = {
1768
- method: 'GET',
1769
- path: requestPath,
1770
- queryParameters,
1771
- headers,
1772
- };
1773
- return transporter.request(request, requestOptions);
1774
- },
1775
- /**
1776
- * Check the current status of a given task.
1777
- *
1778
- * @summary Check the status of a task.
1779
- * @param getTask - The getTask object.
1780
- * @param getTask.indexName - The index in which to perform the request.
1781
- * @param getTask.taskID - Unique identifier of an task. Numeric value (up to 64bits).
1782
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1783
- */
1784
- getTask({ indexName, taskID }, requestOptions) {
1785
- if (!indexName) {
1786
- throw new Error('Parameter `indexName` is required when calling `getTask`.');
1787
- }
1788
- if (!taskID) {
1789
- throw new Error('Parameter `taskID` is required when calling `getTask`.');
1790
- }
1791
- const requestPath = '/1/indexes/{indexName}/task/{taskID}'
1792
- .replace('{indexName}', encodeURIComponent(indexName))
1793
- .replace('{taskID}', encodeURIComponent(taskID));
1794
- const headers = {};
1795
- const queryParameters = {};
1796
- const request = {
1797
- method: 'GET',
1798
- path: requestPath,
1799
- queryParameters,
1800
- headers,
1801
- };
1802
- return transporter.request(request, requestOptions);
1803
- },
1804
- /**
1805
- * Get the top 10 userIDs with the highest number of records per cluster. The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds to propagate to the different clusters. Upon success, the response is 200 OK and contains the following array of userIDs and clusters.
1806
- *
1807
- * @summary Get top userID.
1808
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1809
- */
1810
- getTopUserIds(requestOptions) {
1811
- const requestPath = '/1/clusters/mapping/top';
1812
- const headers = {};
1813
- const queryParameters = {};
1814
- const request = {
1815
- method: 'GET',
1816
- path: requestPath,
1817
- queryParameters,
1818
- headers,
1819
- };
1820
- return transporter.request(request, requestOptions);
1821
- },
1822
- /**
1823
- * Returns the userID data stored in the mapping. The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds to propagate to the different clusters. Upon success, the response is 200 OK and contains the following userID data.
1824
- *
1825
- * @summary Get userID.
1826
- * @param getUserId - The getUserId object.
1827
- * @param getUserId.userID - UserID to assign.
1828
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1829
- */
1830
- getUserId({ userID }, requestOptions) {
1831
- if (!userID) {
1832
- throw new Error('Parameter `userID` is required when calling `getUserId`.');
1833
- }
1834
- const requestPath = '/1/clusters/mapping/{userID}'.replace('{userID}', encodeURIComponent(userID));
1835
- const headers = {};
1836
- const queryParameters = {};
1837
- const request = {
1838
- method: 'GET',
1839
- path: requestPath,
1840
- queryParameters,
1841
- headers,
1842
- };
1843
- return transporter.request(request, requestOptions);
1844
- },
1845
- /**
1846
- * Get the status of your clusters\' migrations or user creations. Creating a large batch of users or migrating your multi-cluster may take quite some time. This method lets you retrieve the status of the migration, so you can know when it\'s done. Upon success, the response is 200 OK. A successful response indicates that the operation has been taken into account, and the userIDs are directly usable.
1847
- *
1848
- * @summary Get migration status.
1849
- * @param hasPendingMappings - The hasPendingMappings object.
1850
- * @param hasPendingMappings.getClusters - If the clusters pending mapping state should be on the response.
1851
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1852
- */
1853
- hasPendingMappings({ getClusters } = {}, requestOptions = undefined) {
1854
- const requestPath = '/1/clusters/mapping/pending';
1855
- const headers = {};
1856
- const queryParameters = {};
1857
- if (getClusters !== undefined) {
1858
- queryParameters.getClusters = getClusters.toString();
1859
- }
1860
- const request = {
1861
- method: 'GET',
1862
- path: requestPath,
1863
- queryParameters,
1864
- headers,
1865
- };
1866
- return transporter.request(request, requestOptions);
1867
- },
1868
- /**
1869
- * List API keys, along with their associated rights.
1870
- *
1871
- * @summary List API Keys.
1872
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1873
- */
1874
- listApiKeys(requestOptions) {
1875
- const requestPath = '/1/keys';
1876
- const headers = {};
1877
- const queryParameters = {};
1878
- const request = {
1879
- method: 'GET',
1880
- path: requestPath,
1881
- queryParameters,
1882
- headers,
1883
- };
1884
- return transporter.request(request, requestOptions);
1885
- },
1886
- /**
1887
- * List the clusters available in a multi-clusters setup for a single appID. Upon success, the response is 200 OK and contains the following clusters.
1888
- *
1889
- * @summary List clusters.
1890
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1891
- */
1892
- listClusters(requestOptions) {
1893
- const requestPath = '/1/clusters';
1894
- const headers = {};
1895
- const queryParameters = {};
1896
- const request = {
1897
- method: 'GET',
1898
- path: requestPath,
1899
- queryParameters,
1900
- headers,
1901
- };
1902
- return transporter.request(request, requestOptions);
1903
- },
1904
- /**
1905
- * List existing indexes from an application.
1906
- *
1907
- * @summary List existing indexes.
1908
- * @param listIndices - The listIndices object.
1909
- * @param listIndices.page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination).
1910
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1911
- */
1912
- listIndices({ page } = {}, requestOptions = undefined) {
1913
- const requestPath = '/1/indexes';
1914
- const headers = {};
1915
- const queryParameters = {};
1916
- if (page !== undefined) {
1917
- queryParameters.page = page.toString();
1918
- }
1919
- const request = {
1920
- method: 'GET',
1921
- path: requestPath,
1922
- queryParameters,
1923
- headers,
1924
- };
1925
- return transporter.request(request, requestOptions);
1926
- },
1927
- /**
1928
- * List the userIDs assigned to a multi-clusters appID. The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds to propagate to the different clusters. Upon success, the response is 200 OK and contains the following userIDs data.
1929
- *
1930
- * @summary List userIDs.
1931
- * @param listUserIds - The listUserIds object.
1932
- * @param listUserIds.page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination).
1933
- * @param listUserIds.hitsPerPage - Maximum number of objects to retrieve.
1934
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1935
- */
1936
- listUserIds({ page, hitsPerPage } = {}, requestOptions = undefined) {
1937
- const requestPath = '/1/clusters/mapping';
1938
- const headers = {};
1939
- const queryParameters = {};
1940
- if (page !== undefined) {
1941
- queryParameters.page = page.toString();
1942
- }
1943
- if (hitsPerPage !== undefined) {
1944
- queryParameters.hitsPerPage = hitsPerPage.toString();
1945
- }
1946
- const request = {
1947
- method: 'GET',
1948
- path: requestPath,
1949
- queryParameters,
1950
- headers,
1951
- };
1952
- return transporter.request(request, requestOptions);
1953
- },
1954
- /**
1955
- * Perform multiple write operations, potentially targeting multiple indices, in a single API call.
1956
- *
1957
- * @summary Batch operations to many indices.
1958
- * @param batchParams - The batchParams object.
1959
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1960
- */
1961
- multipleBatch(batchParams, requestOptions) {
1962
- if (!batchParams) {
1963
- throw new Error('Parameter `batchParams` is required when calling `multipleBatch`.');
1964
- }
1965
- if (!batchParams.requests) {
1966
- throw new Error('Parameter `batchParams.requests` is required when calling `multipleBatch`.');
1967
- }
1968
- const requestPath = '/1/indexes/*/batch';
1969
- const headers = {};
1970
- const queryParameters = {};
1971
- const request = {
1972
- method: 'POST',
1973
- path: requestPath,
1974
- queryParameters,
1975
- headers,
1976
- data: batchParams,
1977
- };
1978
- return transporter.request(request, requestOptions);
1979
- },
1980
- /**
1981
- * Performs a copy or a move operation on a index.
1982
- *
1983
- * @summary Copy/move index.
1984
- * @param operationIndex - The operationIndex object.
1985
- * @param operationIndex.indexName - The index in which to perform the request.
1986
- * @param operationIndex.operationIndexParams - The operationIndexParams object.
1987
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1988
- */
1989
- operationIndex({ indexName, operationIndexParams }, requestOptions) {
1990
- if (!indexName) {
1991
- throw new Error('Parameter `indexName` is required when calling `operationIndex`.');
1992
- }
1993
- if (!operationIndexParams) {
1994
- throw new Error('Parameter `operationIndexParams` is required when calling `operationIndex`.');
1995
- }
1996
- if (!operationIndexParams.operation) {
1997
- throw new Error('Parameter `operationIndexParams.operation` is required when calling `operationIndex`.');
1998
- }
1999
- if (!operationIndexParams.destination) {
2000
- throw new Error('Parameter `operationIndexParams.destination` is required when calling `operationIndex`.');
2001
- }
2002
- const requestPath = '/1/indexes/{indexName}/operation'.replace('{indexName}', encodeURIComponent(indexName));
2003
- const headers = {};
2004
- const queryParameters = {};
2005
- const request = {
2006
- method: 'POST',
2007
- path: requestPath,
2008
- queryParameters,
2009
- headers,
2010
- data: operationIndexParams,
2011
- };
2012
- return transporter.request(request, requestOptions);
2013
- },
2014
- /**
2015
- * Update one or more attributes of an existing object. This method lets you update only a part of an existing object, either by adding new attributes or updating existing ones. You can partially update several objects in a single method call. If the index targeted by this operation doesn\'t exist yet, it\'s automatically created.
2016
- *
2017
- * @summary Partially update an object.
2018
- * @param partialUpdateObject - The partialUpdateObject object.
2019
- * @param partialUpdateObject.indexName - The index in which to perform the request.
2020
- * @param partialUpdateObject.objectID - Unique identifier of an object.
2021
- * @param partialUpdateObject.attributesToUpdate - Map of attribute(s) to update.
2022
- * @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
2023
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2024
- */
2025
- partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists, }, requestOptions) {
2026
- if (!indexName) {
2027
- throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
2028
- }
2029
- if (!objectID) {
2030
- throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
2031
- }
2032
- if (!attributesToUpdate) {
2033
- throw new Error('Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.');
2034
- }
2035
- const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
2036
- .replace('{indexName}', encodeURIComponent(indexName))
2037
- .replace('{objectID}', encodeURIComponent(objectID));
2038
- const headers = {};
2039
- const queryParameters = {};
2040
- if (createIfNotExists !== undefined) {
2041
- queryParameters.createIfNotExists = createIfNotExists.toString();
2042
- }
2043
- const request = {
2044
- method: 'POST',
2045
- path: requestPath,
2046
- queryParameters,
2047
- headers,
2048
- data: attributesToUpdate,
2049
- };
2050
- return transporter.request(request, requestOptions);
2051
- },
2052
- /**
2053
- * This method allow you to send requests to the Algolia REST API.
2054
- *
2055
- * @summary Send requests to the Algolia REST API.
2056
- * @param post - The post object.
2057
- * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
2058
- * @param post.parameters - Query parameters to be applied to the current query.
2059
- * @param post.body - The parameters to send with the custom request.
2060
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2061
- */
2062
- post({ path, parameters, body }, requestOptions) {
2063
- if (!path) {
2064
- throw new Error('Parameter `path` is required when calling `post`.');
2065
- }
2066
- const requestPath = '/1{path}'.replace('{path}', path);
2067
- const headers = {};
2068
- const queryParameters = parameters ? parameters : {};
2069
- const request = {
2070
- method: 'POST',
2071
- path: requestPath,
2072
- queryParameters,
2073
- headers,
2074
- data: body ? body : {},
2075
- };
2076
- return transporter.request(request, requestOptions);
2077
- },
2078
- /**
2079
- * This method allow you to send requests to the Algolia REST API.
2080
- *
2081
- * @summary Send requests to the Algolia REST API.
2082
- * @param put - The put object.
2083
- * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
2084
- * @param put.parameters - Query parameters to be applied to the current query.
2085
- * @param put.body - The parameters to send with the custom request.
2086
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2087
- */
2088
- put({ path, parameters, body }, requestOptions) {
2089
- if (!path) {
2090
- throw new Error('Parameter `path` is required when calling `put`.');
2091
- }
2092
- const requestPath = '/1{path}'.replace('{path}', path);
2093
- const headers = {};
2094
- const queryParameters = parameters ? parameters : {};
2095
- const request = {
2096
- method: 'PUT',
2097
- path: requestPath,
2098
- queryParameters,
2099
- headers,
2100
- data: body ? body : {},
2101
- };
2102
- return transporter.request(request, requestOptions);
2103
- },
2104
- /**
2105
- * Remove a userID and its associated data from the multi-clusters. Upon success, the response is 200 OK and a task is created to remove the userID data and mapping.
2106
- *
2107
- * @summary Remove userID.
2108
- * @param removeUserId - The removeUserId object.
2109
- * @param removeUserId.userID - UserID to assign.
2110
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2111
- */
2112
- removeUserId({ userID }, requestOptions) {
2113
- if (!userID) {
2114
- throw new Error('Parameter `userID` is required when calling `removeUserId`.');
2115
- }
2116
- const requestPath = '/1/clusters/mapping/{userID}'.replace('{userID}', encodeURIComponent(userID));
2117
- const headers = {};
2118
- const queryParameters = {};
2119
- const request = {
2120
- method: 'DELETE',
2121
- path: requestPath,
2122
- queryParameters,
2123
- headers,
2124
- };
2125
- return transporter.request(request, requestOptions);
2126
- },
2127
- /**
2128
- * Replace all allowed sources.
2129
- *
2130
- * @summary Replace all allowed sources.
2131
- * @param replaceSources - The replaceSources object.
2132
- * @param replaceSources.source - The sources to allow.
2133
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2134
- */
2135
- replaceSources({ source }, requestOptions) {
2136
- if (!source) {
2137
- throw new Error('Parameter `source` is required when calling `replaceSources`.');
2138
- }
2139
- const requestPath = '/1/security/sources';
2140
- const headers = {};
2141
- const queryParameters = {};
2142
- const request = {
2143
- method: 'PUT',
2144
- path: requestPath,
2145
- queryParameters,
2146
- headers,
2147
- data: source,
2148
- };
2149
- return transporter.request(request, requestOptions);
2150
- },
2151
- /**
2152
- * Restore a deleted API key, along with its associated rights.
2153
- *
2154
- * @summary Restore an API key.
2155
- * @param restoreApiKey - The restoreApiKey object.
2156
- * @param restoreApiKey.key - API Key string.
2157
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2158
- */
2159
- restoreApiKey({ key }, requestOptions) {
2160
- if (!key) {
2161
- throw new Error('Parameter `key` is required when calling `restoreApiKey`.');
2162
- }
2163
- const requestPath = '/1/keys/{key}/restore'.replace('{key}', encodeURIComponent(key));
2164
- const headers = {};
2165
- const queryParameters = {};
2166
- const request = {
2167
- method: 'POST',
2168
- path: requestPath,
2169
- queryParameters,
2170
- headers,
2171
- };
2172
- return transporter.request(request, requestOptions);
2173
- },
2174
- /**
2175
- * Add an object to the index, automatically assigning it an object ID.
2176
- *
2177
- * @summary Add an object to the index.
2178
- * @param saveObject - The saveObject object.
2179
- * @param saveObject.indexName - The index in which to perform the request.
2180
- * @param saveObject.body - The Algolia record.
2181
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2182
- */
2183
- saveObject({ indexName, body }, requestOptions) {
2184
- if (!indexName) {
2185
- throw new Error('Parameter `indexName` is required when calling `saveObject`.');
2186
- }
2187
- if (!body) {
2188
- throw new Error('Parameter `body` is required when calling `saveObject`.');
2189
- }
2190
- const requestPath = '/1/indexes/{indexName}'.replace('{indexName}', encodeURIComponent(indexName));
2191
- const headers = {};
2192
- const queryParameters = {};
2193
- const request = {
2194
- method: 'POST',
2195
- path: requestPath,
2196
- queryParameters,
2197
- headers,
2198
- data: body,
2199
- };
2200
- return transporter.request(request, requestOptions);
2201
- },
2202
- /**
2203
- * Create or update the Rule with the specified objectID.
2204
- *
2205
- * @summary Save/Update a rule.
2206
- * @param saveRule - The saveRule object.
2207
- * @param saveRule.indexName - The index in which to perform the request.
2208
- * @param saveRule.objectID - Unique identifier of an object.
2209
- * @param saveRule.rule - The rule object.
2210
- * @param saveRule.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2211
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2212
- */
2213
- saveRule({ indexName, objectID, rule, forwardToReplicas }, requestOptions) {
2214
- if (!indexName) {
2215
- throw new Error('Parameter `indexName` is required when calling `saveRule`.');
2216
- }
2217
- if (!objectID) {
2218
- throw new Error('Parameter `objectID` is required when calling `saveRule`.');
2219
- }
2220
- if (!rule) {
2221
- throw new Error('Parameter `rule` is required when calling `saveRule`.');
2222
- }
2223
- if (!rule.objectID) {
2224
- throw new Error('Parameter `rule.objectID` is required when calling `saveRule`.');
2225
- }
2226
- const requestPath = '/1/indexes/{indexName}/rules/{objectID}'
2227
- .replace('{indexName}', encodeURIComponent(indexName))
2228
- .replace('{objectID}', encodeURIComponent(objectID));
2229
- const headers = {};
2230
- const queryParameters = {};
2231
- if (forwardToReplicas !== undefined) {
2232
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
2233
- }
2234
- const request = {
2235
- method: 'PUT',
2236
- path: requestPath,
2237
- queryParameters,
2238
- headers,
2239
- data: rule,
2240
- };
2241
- return transporter.request(request, requestOptions);
2242
- },
2243
- /**
2244
- * Create/update multiple rules objects at once.
2245
- *
2246
- * @summary Save a batch of rules.
2247
- * @param saveRules - The saveRules object.
2248
- * @param saveRules.indexName - The index in which to perform the request.
2249
- * @param saveRules.rules - The rules object.
2250
- * @param saveRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2251
- * @param saveRules.clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept.
2252
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2253
- */
2254
- saveRules({ indexName, rules, forwardToReplicas, clearExistingRules, }, requestOptions) {
2255
- if (!indexName) {
2256
- throw new Error('Parameter `indexName` is required when calling `saveRules`.');
2257
- }
2258
- if (!rules) {
2259
- throw new Error('Parameter `rules` is required when calling `saveRules`.');
2260
- }
2261
- const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
2262
- const headers = {};
2263
- const queryParameters = {};
2264
- if (forwardToReplicas !== undefined) {
2265
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
2266
- }
2267
- if (clearExistingRules !== undefined) {
2268
- queryParameters.clearExistingRules = clearExistingRules.toString();
2269
- }
2270
- const request = {
2271
- method: 'POST',
2272
- path: requestPath,
2273
- queryParameters,
2274
- headers,
2275
- data: rules,
2276
- };
2277
- return transporter.request(request, requestOptions);
2278
- },
2279
- /**
2280
- * Create a new synonym object or update the existing synonym object with the given object ID.
2281
- *
2282
- * @summary Save synonym.
2283
- * @param saveSynonym - The saveSynonym object.
2284
- * @param saveSynonym.indexName - The index in which to perform the request.
2285
- * @param saveSynonym.objectID - Unique identifier of an object.
2286
- * @param saveSynonym.synonymHit - The synonymHit object.
2287
- * @param saveSynonym.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2288
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2289
- */
2290
- saveSynonym({ indexName, objectID, synonymHit, forwardToReplicas }, requestOptions) {
2291
- if (!indexName) {
2292
- throw new Error('Parameter `indexName` is required when calling `saveSynonym`.');
2293
- }
2294
- if (!objectID) {
2295
- throw new Error('Parameter `objectID` is required when calling `saveSynonym`.');
2296
- }
2297
- if (!synonymHit) {
2298
- throw new Error('Parameter `synonymHit` is required when calling `saveSynonym`.');
2299
- }
2300
- if (!synonymHit.objectID) {
2301
- throw new Error('Parameter `synonymHit.objectID` is required when calling `saveSynonym`.');
2302
- }
2303
- if (!synonymHit.type) {
2304
- throw new Error('Parameter `synonymHit.type` is required when calling `saveSynonym`.');
2305
- }
2306
- const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}'
2307
- .replace('{indexName}', encodeURIComponent(indexName))
2308
- .replace('{objectID}', encodeURIComponent(objectID));
2309
- const headers = {};
2310
- const queryParameters = {};
2311
- if (forwardToReplicas !== undefined) {
2312
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
2313
- }
2314
- const request = {
2315
- method: 'PUT',
2316
- path: requestPath,
2317
- queryParameters,
2318
- headers,
2319
- data: synonymHit,
2320
- };
2321
- return transporter.request(request, requestOptions);
2322
- },
2323
- /**
2324
- * Create/update multiple synonym objects at once, potentially replacing the entire list of synonyms if replaceExistingSynonyms is true.
2325
- *
2326
- * @summary Save a batch of synonyms.
2327
- * @param saveSynonyms - The saveSynonyms object.
2328
- * @param saveSynonyms.indexName - The index in which to perform the request.
2329
- * @param saveSynonyms.synonymHit - The synonymHit object.
2330
- * @param saveSynonyms.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2331
- * @param saveSynonyms.replaceExistingSynonyms - Replace all synonyms of the index with the ones sent with this request.
2332
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2333
- */
2334
- saveSynonyms({ indexName, synonymHit, forwardToReplicas, replaceExistingSynonyms, }, requestOptions) {
2335
- if (!indexName) {
2336
- throw new Error('Parameter `indexName` is required when calling `saveSynonyms`.');
2337
- }
2338
- if (!synonymHit) {
2339
- throw new Error('Parameter `synonymHit` is required when calling `saveSynonyms`.');
2340
- }
2341
- const requestPath = '/1/indexes/{indexName}/synonyms/batch'.replace('{indexName}', encodeURIComponent(indexName));
2342
- const headers = {};
2343
- const queryParameters = {};
2344
- if (forwardToReplicas !== undefined) {
2345
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
2346
- }
2347
- if (replaceExistingSynonyms !== undefined) {
2348
- queryParameters.replaceExistingSynonyms =
2349
- replaceExistingSynonyms.toString();
2350
- }
2351
- const request = {
2352
- method: 'POST',
2353
- path: requestPath,
2354
- queryParameters,
2355
- headers,
2356
- data: synonymHit,
2357
- };
2358
- return transporter.request(request, requestOptions);
2359
- },
2360
- /**
2361
- * Perform a search operation targeting one or many indices.
2362
- *
2363
- * @summary Search multiple indices.
2364
- * @param searchMethodParams - The `search` requests and strategy.
2365
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2366
- */
2367
- search(searchMethodParams, requestOptions) {
2368
- if (searchMethodParams && Array.isArray(searchMethodParams)) {
2369
- const newSignatureRequest = {
2370
- requests: searchMethodParams.map(({ params, ...legacyRequest }) => {
2371
- if (legacyRequest.type === 'facet') {
2372
- return {
2373
- ...legacyRequest,
2374
- ...params,
2375
- type: 'facet',
2376
- };
2377
- }
2378
- return {
2379
- ...legacyRequest,
2380
- ...params,
2381
- facet: undefined,
2382
- maxFacetHits: undefined,
2383
- facetQuery: undefined,
2384
- };
2385
- }),
2386
- };
2387
- // eslint-disable-next-line no-param-reassign
2388
- searchMethodParams = newSignatureRequest;
2389
- }
2390
- if (!searchMethodParams) {
2391
- throw new Error('Parameter `searchMethodParams` is required when calling `search`.');
2392
- }
2393
- if (!searchMethodParams.requests) {
2394
- throw new Error('Parameter `searchMethodParams.requests` is required when calling `search`.');
2395
- }
2396
- const requestPath = '/1/indexes/*/queries';
2397
- const headers = {};
2398
- const queryParameters = {};
2399
- const request = {
2400
- method: 'POST',
2401
- path: requestPath,
2402
- queryParameters,
2403
- headers,
2404
- data: searchMethodParams,
2405
- useReadTransporter: true,
2406
- cacheable: true,
2407
- };
2408
- return transporter.request(request, requestOptions);
2409
- },
2410
- /**
2411
- * Search the dictionary entries.
2412
- *
2413
- * @summary Search a dictionary entries.
2414
- * @param searchDictionaryEntries - The searchDictionaryEntries object.
2415
- * @param searchDictionaryEntries.dictionaryName - The dictionary to search in.
2416
- * @param searchDictionaryEntries.searchDictionaryEntriesParams - The searchDictionaryEntriesParams object.
2417
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2418
- */
2419
- searchDictionaryEntries({ dictionaryName, searchDictionaryEntriesParams, }, requestOptions) {
2420
- if (!dictionaryName) {
2421
- throw new Error('Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.');
2422
- }
2423
- if (!searchDictionaryEntriesParams) {
2424
- throw new Error('Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`.');
2425
- }
2426
- if (!searchDictionaryEntriesParams.query) {
2427
- throw new Error('Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`.');
2428
- }
2429
- const requestPath = '/1/dictionaries/{dictionaryName}/search'.replace('{dictionaryName}', encodeURIComponent(dictionaryName));
2430
- const headers = {};
2431
- const queryParameters = {};
2432
- const request = {
2433
- method: 'POST',
2434
- path: requestPath,
2435
- queryParameters,
2436
- headers,
2437
- data: searchDictionaryEntriesParams,
2438
- useReadTransporter: true,
2439
- cacheable: true,
2440
- };
2441
- return transporter.request(request, requestOptions);
2442
- },
2443
- /**
2444
- * Search for values of a given facet, optionally restricting the returned values to those contained in objects matching other search criteria.
2445
- *
2446
- * @summary Search for values of a given facet.
2447
- * @param searchForFacetValues - The searchForFacetValues object.
2448
- * @param searchForFacetValues.indexName - The index in which to perform the request.
2449
- * @param searchForFacetValues.facetName - The facet name.
2450
- * @param searchForFacetValues.searchForFacetValuesRequest - The searchForFacetValuesRequest object.
2451
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2452
- */
2453
- searchForFacetValues({ indexName, facetName, searchForFacetValuesRequest, }, requestOptions) {
2454
- if (!indexName) {
2455
- throw new Error('Parameter `indexName` is required when calling `searchForFacetValues`.');
2456
- }
2457
- if (!facetName) {
2458
- throw new Error('Parameter `facetName` is required when calling `searchForFacetValues`.');
2459
- }
2460
- const requestPath = '/1/indexes/{indexName}/facets/{facetName}/query'
2461
- .replace('{indexName}', encodeURIComponent(indexName))
2462
- .replace('{facetName}', encodeURIComponent(facetName));
2463
- const headers = {};
2464
- const queryParameters = {};
2465
- const request = {
2466
- method: 'POST',
2467
- path: requestPath,
2468
- queryParameters,
2469
- headers,
2470
- data: searchForFacetValuesRequest ? searchForFacetValuesRequest : {},
2471
- useReadTransporter: true,
2472
- cacheable: true,
2473
- };
2474
- return transporter.request(request, requestOptions);
2475
- },
2476
- /**
2477
- * Search for rules matching various criteria.
2478
- *
2479
- * @summary Search for rules.
2480
- * @param searchRules - The searchRules object.
2481
- * @param searchRules.indexName - The index in which to perform the request.
2482
- * @param searchRules.searchRulesParams - The searchRulesParams object.
2483
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2484
- */
2485
- searchRules({ indexName, searchRulesParams }, requestOptions) {
2486
- if (!indexName) {
2487
- throw new Error('Parameter `indexName` is required when calling `searchRules`.');
2488
- }
2489
- const requestPath = '/1/indexes/{indexName}/rules/search'.replace('{indexName}', encodeURIComponent(indexName));
2490
- const headers = {};
2491
- const queryParameters = {};
2492
- const request = {
2493
- method: 'POST',
2494
- path: requestPath,
2495
- queryParameters,
2496
- headers,
2497
- data: searchRulesParams ? searchRulesParams : {},
2498
- useReadTransporter: true,
2499
- cacheable: true,
2500
- };
2501
- return transporter.request(request, requestOptions);
2502
- },
2503
- /**
2504
- * Perform a search operation targeting one specific index.
2505
- *
2506
- * @summary Search in a single index.
2507
- * @param searchSingleIndex - The searchSingleIndex object.
2508
- * @param searchSingleIndex.indexName - The index in which to perform the request.
2509
- * @param searchSingleIndex.searchParams - The searchParams object.
2510
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2511
- */
2512
- searchSingleIndex({ indexName, searchParams }, requestOptions) {
2513
- if (!indexName) {
2514
- throw new Error('Parameter `indexName` is required when calling `searchSingleIndex`.');
2515
- }
2516
- const requestPath = '/1/indexes/{indexName}/query'.replace('{indexName}', encodeURIComponent(indexName));
2517
- const headers = {};
2518
- const queryParameters = {};
2519
- const request = {
2520
- method: 'POST',
2521
- path: requestPath,
2522
- queryParameters,
2523
- headers,
2524
- data: searchParams ? searchParams : {},
2525
- useReadTransporter: true,
2526
- cacheable: true,
2527
- };
2528
- return transporter.request(request, requestOptions);
2529
- },
2530
- /**
2531
- * Search or browse all synonyms, optionally filtering them by type.
2532
- *
2533
- * @summary Search synonyms.
2534
- * @param searchSynonyms - The searchSynonyms object.
2535
- * @param searchSynonyms.indexName - The index in which to perform the request.
2536
- * @param searchSynonyms.type - Only search for specific types of synonyms.
2537
- * @param searchSynonyms.page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination).
2538
- * @param searchSynonyms.hitsPerPage - Maximum number of objects to retrieve.
2539
- * @param searchSynonyms.searchSynonymsParams - The body of the the `searchSynonyms` method.
2540
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2541
- */
2542
- searchSynonyms({ indexName, type, page, hitsPerPage, searchSynonymsParams, }, requestOptions) {
2543
- if (!indexName) {
2544
- throw new Error('Parameter `indexName` is required when calling `searchSynonyms`.');
2545
- }
2546
- const requestPath = '/1/indexes/{indexName}/synonyms/search'.replace('{indexName}', encodeURIComponent(indexName));
2547
- const headers = {};
2548
- const queryParameters = {};
2549
- if (type !== undefined) {
2550
- queryParameters.type = type.toString();
2551
- }
2552
- if (page !== undefined) {
2553
- queryParameters.page = page.toString();
2554
- }
2555
- if (hitsPerPage !== undefined) {
2556
- queryParameters.hitsPerPage = hitsPerPage.toString();
2557
- }
2558
- const request = {
2559
- method: 'POST',
2560
- path: requestPath,
2561
- queryParameters,
2562
- headers,
2563
- data: searchSynonymsParams ? searchSynonymsParams : {},
2564
- useReadTransporter: true,
2565
- cacheable: true,
2566
- };
2567
- return transporter.request(request, requestOptions);
2568
- },
2569
- /**
2570
- * Search for userIDs. The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds propagate to the different clusters. To keep updates moving quickly, the index of userIDs isn\'t built synchronously with the mapping. Instead, the index is built once every 12h, at the same time as the update of userID usage. For example, when you perform a modification like adding or moving a userID, the search will report an outdated value until the next rebuild of the mapping, which takes place every 12h. Upon success, the response is 200 OK and contains the following userIDs data.
2571
- *
2572
- * @summary Search userID.
2573
- * @param searchUserIdsParams - The searchUserIdsParams object.
2574
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2575
- */
2576
- searchUserIds(searchUserIdsParams, requestOptions) {
2577
- if (!searchUserIdsParams) {
2578
- throw new Error('Parameter `searchUserIdsParams` is required when calling `searchUserIds`.');
2579
- }
2580
- if (!searchUserIdsParams.query) {
2581
- throw new Error('Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.');
2582
- }
2583
- const requestPath = '/1/clusters/mapping/search';
2584
- const headers = {};
2585
- const queryParameters = {};
2586
- const request = {
2587
- method: 'POST',
2588
- path: requestPath,
2589
- queryParameters,
2590
- headers,
2591
- data: searchUserIdsParams,
2592
- useReadTransporter: true,
2593
- cacheable: true,
2594
- };
2595
- return transporter.request(request, requestOptions);
2596
- },
2597
- /**
2598
- * Set dictionaries settings.
2599
- *
2600
- * @summary Set dictionaries settings.
2601
- * @param dictionarySettingsParams - The dictionarySettingsParams object.
2602
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2603
- */
2604
- setDictionarySettings(dictionarySettingsParams, requestOptions) {
2605
- if (!dictionarySettingsParams) {
2606
- throw new Error('Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.');
2607
- }
2608
- if (!dictionarySettingsParams.disableStandardEntries) {
2609
- throw new Error('Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`.');
2610
- }
2611
- const requestPath = '/1/dictionaries/*/settings';
2612
- const headers = {};
2613
- const queryParameters = {};
2614
- const request = {
2615
- method: 'PUT',
2616
- path: requestPath,
2617
- queryParameters,
2618
- headers,
2619
- data: dictionarySettingsParams,
2620
- };
2621
- return transporter.request(request, requestOptions);
2622
- },
2623
- /**
2624
- * Update settings of an index. Only specified settings are overridden; unspecified settings are left unchanged. Specifying null for a setting resets it to its default value.
2625
- *
2626
- * @summary Update settings of an index.
2627
- * @param setSettings - The setSettings object.
2628
- * @param setSettings.indexName - The index in which to perform the request.
2629
- * @param setSettings.indexSettings - The indexSettings object.
2630
- * @param setSettings.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2631
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2632
- */
2633
- setSettings({ indexName, indexSettings, forwardToReplicas }, requestOptions) {
2634
- if (!indexName) {
2635
- throw new Error('Parameter `indexName` is required when calling `setSettings`.');
2636
- }
2637
- if (!indexSettings) {
2638
- throw new Error('Parameter `indexSettings` is required when calling `setSettings`.');
2639
- }
2640
- const requestPath = '/1/indexes/{indexName}/settings'.replace('{indexName}', encodeURIComponent(indexName));
2641
- const headers = {};
2642
- const queryParameters = {};
2643
- if (forwardToReplicas !== undefined) {
2644
- queryParameters.forwardToReplicas = forwardToReplicas.toString();
2645
- }
2646
- const request = {
2647
- method: 'PUT',
2648
- path: requestPath,
2649
- queryParameters,
2650
- headers,
2651
- data: indexSettings,
2652
- };
2653
- return transporter.request(request, requestOptions);
2654
- },
2655
- /**
2656
- * Replace every permission of an existing API key.
2657
- *
2658
- * @summary Update an API key.
2659
- * @param updateApiKey - The updateApiKey object.
2660
- * @param updateApiKey.key - API Key string.
2661
- * @param updateApiKey.apiKey - The apiKey object.
2662
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2663
- */
2664
- updateApiKey({ key, apiKey }, requestOptions) {
2665
- if (!key) {
2666
- throw new Error('Parameter `key` is required when calling `updateApiKey`.');
2667
- }
2668
- if (!apiKey) {
2669
- throw new Error('Parameter `apiKey` is required when calling `updateApiKey`.');
2670
- }
2671
- if (!apiKey.acl) {
2672
- throw new Error('Parameter `apiKey.acl` is required when calling `updateApiKey`.');
2673
- }
2674
- const requestPath = '/1/keys/{key}'.replace('{key}', encodeURIComponent(key));
2675
- const headers = {};
2676
- const queryParameters = {};
2677
- const request = {
2678
- method: 'PUT',
2679
- path: requestPath,
2680
- queryParameters,
2681
- headers,
2682
- data: apiKey,
2683
- };
2684
- return transporter.request(request, requestOptions);
2685
- },
2686
- };
715
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
716
+ const apiClientVersion = '5.0.0-alpha.54';
717
+ function getDefaultHosts(appId) {
718
+ return [
719
+ {
720
+ url: `${appId}-dsn.algolia.net`,
721
+ accept: 'read',
722
+ protocol: 'https',
723
+ },
724
+ {
725
+ url: `${appId}.algolia.net`,
726
+ accept: 'write',
727
+ protocol: 'https',
728
+ },
729
+ ].concat(shuffle([
730
+ {
731
+ url: `${appId}-1.algolianet.com`,
732
+ accept: 'readWrite',
733
+ protocol: 'https',
734
+ },
735
+ {
736
+ url: `${appId}-2.algolianet.com`,
737
+ accept: 'readWrite',
738
+ protocol: 'https',
739
+ },
740
+ {
741
+ url: `${appId}-3.algolianet.com`,
742
+ accept: 'readWrite',
743
+ protocol: 'https',
744
+ },
745
+ ]));
746
+ }
747
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
748
+ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }) {
749
+ const auth = createAuth(appIdOption, apiKeyOption, authMode);
750
+ const transporter = createTransporter({
751
+ hosts: getDefaultHosts(appIdOption),
752
+ ...options,
753
+ algoliaAgent: getAlgoliaAgent({
754
+ algoliaAgents,
755
+ client: 'Search',
756
+ version: apiClientVersion,
757
+ }),
758
+ baseHeaders: {
759
+ 'content-type': 'text/plain',
760
+ ...auth.headers(),
761
+ ...options.baseHeaders,
762
+ },
763
+ baseQueryParameters: {
764
+ ...auth.queryParameters(),
765
+ ...options.baseQueryParameters,
766
+ },
767
+ });
768
+ return {
769
+ transporter,
770
+ /**
771
+ * The `appId` currently in use.
772
+ */
773
+ appId: appIdOption,
774
+ /**
775
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
776
+ */
777
+ clearCache() {
778
+ return Promise.all([
779
+ transporter.requestsCache.clear(),
780
+ transporter.responsesCache.clear(),
781
+ ]).then(() => undefined);
782
+ },
783
+ /**
784
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
785
+ */
786
+ get _ua() {
787
+ return transporter.algoliaAgent.value;
788
+ },
789
+ /**
790
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
791
+ *
792
+ * @param segment - The algolia agent (user-agent) segment to add.
793
+ * @param version - The version of the agent.
794
+ */
795
+ addAlgoliaAgent(segment, version) {
796
+ transporter.algoliaAgent.add({ segment, version });
797
+ },
798
+ /**
799
+ * Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
800
+ *
801
+ * @summary Helper method that waits for a task to be published (completed).
802
+ * @param waitForTaskOptions - The waitForTaskOptions object.
803
+ * @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
804
+ * @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
805
+ * @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
806
+ * @param waitForTaskOptions.timeout - The function to decide how long to wait between retries.
807
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
808
+ */
809
+ waitForTask({ indexName, taskID, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
810
+ let retryCount = 0;
811
+ return createIterablePromise({
812
+ func: () => this.getTask({ indexName, taskID }, requestOptions),
813
+ validate: (response) => response.status === 'published',
814
+ aggregator: () => (retryCount += 1),
815
+ error: {
816
+ validate: () => retryCount >= maxRetries,
817
+ message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
818
+ },
819
+ timeout: () => timeout(retryCount),
820
+ });
821
+ },
822
+ /**
823
+ * Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
824
+ *
825
+ * @summary Helper method that waits for an API key task to be processed.
826
+ * @param waitForApiKeyOptions - The waitForApiKeyOptions object.
827
+ * @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
828
+ * @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
829
+ * @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
830
+ * @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 50 by default.
831
+ * @param waitForApiKeyOptions.timeout - The function to decide how long to wait between retries.
832
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
833
+ */
834
+ waitForApiKey({ operation, key, apiKey, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
835
+ let retryCount = 0;
836
+ const baseIteratorOptions = {
837
+ aggregator: () => (retryCount += 1),
838
+ error: {
839
+ validate: () => retryCount >= maxRetries,
840
+ message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
841
+ },
842
+ timeout: () => timeout(retryCount),
843
+ };
844
+ if (operation === 'update') {
845
+ if (!apiKey) {
846
+ throw new Error('`apiKey` is required when waiting for an `update` operation.');
847
+ }
848
+ return createIterablePromise({
849
+ ...baseIteratorOptions,
850
+ func: () => this.getApiKey({ key }, requestOptions),
851
+ validate: (response) => {
852
+ for (const field of Object.keys(apiKey)) {
853
+ const value = apiKey[field];
854
+ const resValue = response[field];
855
+ if (Array.isArray(value) && Array.isArray(resValue)) {
856
+ if (value.length !== resValue.length ||
857
+ value.some((v, index) => v !== resValue[index])) {
858
+ return false;
859
+ }
860
+ }
861
+ else if (value !== resValue) {
862
+ return false;
863
+ }
864
+ }
865
+ return true;
866
+ },
867
+ });
868
+ }
869
+ return createIterablePromise({
870
+ ...baseIteratorOptions,
871
+ func: () => this.getApiKey({ key }, requestOptions).catch((error) => error),
872
+ validate: (error) => operation === 'add' ? error.status !== 404 : error.status === 404,
873
+ });
874
+ },
875
+ /**
876
+ * Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
877
+ *
878
+ * @summary Helper method that iterates on the `browse` method.
879
+ * @param browseObjects - The browseObjects object.
880
+ * @param browseObjects.indexName - The index in which to perform the request.
881
+ * @param browseObjects.browseParams - The `browse` parameters.
882
+ * @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is no `cursor` in the response.
883
+ * @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
884
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
885
+ */
886
+ browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
887
+ return createIterablePromise({
888
+ func: (previousResponse) => {
889
+ return this.browse({
890
+ indexName,
891
+ browseParams: {
892
+ cursor: previousResponse ? previousResponse.cursor : undefined,
893
+ ...browseParams,
894
+ },
895
+ }, requestOptions);
896
+ },
897
+ validate: (response) => response.cursor === undefined,
898
+ ...browseObjectsOptions,
899
+ });
900
+ },
901
+ /**
902
+ * Helper: Iterate on the `searchRules` method of the client to allow aggregating rules of an index.
903
+ *
904
+ * @summary Helper method that iterates on the `searchRules` method.
905
+ * @param browseObjects - The browseObjects object.
906
+ * @param browseObjects.indexName - The index in which to perform the request.
907
+ * @param browseObjects.searchRulesParams - The `searchRules` method parameters.
908
+ * @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
909
+ * @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
910
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
911
+ */
912
+ browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
913
+ const params = {
914
+ hitsPerPage: 1000,
915
+ ...searchRulesParams,
916
+ };
917
+ return createIterablePromise({
918
+ func: (previousResponse) => {
919
+ return this.searchRules({
920
+ indexName,
921
+ searchRulesParams: {
922
+ ...params,
923
+ page: previousResponse
924
+ ? previousResponse.page + 1
925
+ : params.page || 0,
926
+ },
927
+ }, requestOptions);
928
+ },
929
+ validate: (response) => response.nbHits < params.hitsPerPage,
930
+ ...browseRulesOptions,
931
+ });
932
+ },
933
+ /**
934
+ * Helper: Iterate on the `searchSynonyms` method of the client to allow aggregating rules of an index.
935
+ *
936
+ * @summary Helper method that iterates on the `searchSynonyms` method.
937
+ * @param browseObjects - The browseObjects object.
938
+ * @param browseObjects.indexName - The index in which to perform the request.
939
+ * @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
940
+ * @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
941
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
942
+ */
943
+ browseSynonyms({ indexName, validate, aggregator, ...browseSynonymsOptions }, requestOptions) {
944
+ const params = {
945
+ hitsPerPage: 1000,
946
+ ...browseSynonymsOptions,
947
+ };
948
+ return createIterablePromise({
949
+ func: (previousResponse) => {
950
+ return this.searchSynonyms({
951
+ ...params,
952
+ indexName,
953
+ page: previousResponse
954
+ ? previousResponse.page + 1
955
+ : browseSynonymsOptions.page || 0,
956
+ }, requestOptions);
957
+ },
958
+ validate: (response) => response.nbHits < params.hitsPerPage,
959
+ ...browseSynonymsOptions,
960
+ });
961
+ },
962
+ /**
963
+ * Add a new API Key with specific permissions/restrictions.
964
+ *
965
+ * @summary Create an API key.
966
+ * @param apiKey - The apiKey object.
967
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
968
+ */
969
+ addApiKey(apiKey, requestOptions) {
970
+ if (!apiKey) {
971
+ throw new Error('Parameter `apiKey` is required when calling `addApiKey`.');
972
+ }
973
+ if (!apiKey.acl) {
974
+ throw new Error('Parameter `apiKey.acl` is required when calling `addApiKey`.');
975
+ }
976
+ const requestPath = '/1/keys';
977
+ const headers = {};
978
+ const queryParameters = {};
979
+ const request = {
980
+ method: 'POST',
981
+ path: requestPath,
982
+ queryParameters,
983
+ headers,
984
+ data: apiKey,
985
+ };
986
+ return transporter.request(request, requestOptions);
987
+ },
988
+ /**
989
+ * Add or replace an object with a given object ID. If the object does not exist, it will be created. If it already exists, it will be replaced.
990
+ *
991
+ * @summary Add or replace an object.
992
+ * @param addOrUpdateObject - The addOrUpdateObject object.
993
+ * @param addOrUpdateObject.indexName - The index in which to perform the request.
994
+ * @param addOrUpdateObject.objectID - Unique identifier of an object.
995
+ * @param addOrUpdateObject.body - The Algolia object.
996
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
997
+ */
998
+ addOrUpdateObject({ indexName, objectID, body }, requestOptions) {
999
+ if (!indexName) {
1000
+ throw new Error('Parameter `indexName` is required when calling `addOrUpdateObject`.');
1001
+ }
1002
+ if (!objectID) {
1003
+ throw new Error('Parameter `objectID` is required when calling `addOrUpdateObject`.');
1004
+ }
1005
+ if (!body) {
1006
+ throw new Error('Parameter `body` is required when calling `addOrUpdateObject`.');
1007
+ }
1008
+ const requestPath = '/1/indexes/{indexName}/{objectID}'
1009
+ .replace('{indexName}', encodeURIComponent(indexName))
1010
+ .replace('{objectID}', encodeURIComponent(objectID));
1011
+ const headers = {};
1012
+ const queryParameters = {};
1013
+ const request = {
1014
+ method: 'PUT',
1015
+ path: requestPath,
1016
+ queryParameters,
1017
+ headers,
1018
+ data: body,
1019
+ };
1020
+ return transporter.request(request, requestOptions);
1021
+ },
1022
+ /**
1023
+ * Add a single source to the list of allowed sources.
1024
+ *
1025
+ * @summary Add a single source.
1026
+ * @param source - The source to add.
1027
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1028
+ */
1029
+ appendSource(source, requestOptions) {
1030
+ if (!source) {
1031
+ throw new Error('Parameter `source` is required when calling `appendSource`.');
1032
+ }
1033
+ if (!source.source) {
1034
+ throw new Error('Parameter `source.source` is required when calling `appendSource`.');
1035
+ }
1036
+ const requestPath = '/1/security/sources/append';
1037
+ const headers = {};
1038
+ const queryParameters = {};
1039
+ const request = {
1040
+ method: 'POST',
1041
+ path: requestPath,
1042
+ queryParameters,
1043
+ headers,
1044
+ data: source,
1045
+ };
1046
+ return transporter.request(request, requestOptions);
1047
+ },
1048
+ /**
1049
+ * Assign or Move a userID to a cluster. The time it takes to migrate (move) a user is proportional to the amount of data linked to the userID. Upon success, the response is 200 OK. A successful response indicates that the operation has been taken into account, and the userID is directly usable.
1050
+ *
1051
+ * @summary Assign or Move userID.
1052
+ * @param assignUserId - The assignUserId object.
1053
+ * @param assignUserId.xAlgoliaUserID - UserID to assign.
1054
+ * @param assignUserId.assignUserIdParams - The assignUserIdParams object.
1055
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1056
+ */
1057
+ assignUserId({ xAlgoliaUserID, assignUserIdParams }, requestOptions) {
1058
+ if (!xAlgoliaUserID) {
1059
+ throw new Error('Parameter `xAlgoliaUserID` is required when calling `assignUserId`.');
1060
+ }
1061
+ if (!assignUserIdParams) {
1062
+ throw new Error('Parameter `assignUserIdParams` is required when calling `assignUserId`.');
1063
+ }
1064
+ if (!assignUserIdParams.cluster) {
1065
+ throw new Error('Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.');
1066
+ }
1067
+ const requestPath = '/1/clusters/mapping';
1068
+ const headers = {};
1069
+ const queryParameters = {};
1070
+ if (xAlgoliaUserID !== undefined) {
1071
+ headers['X-Algolia-User-ID'] = xAlgoliaUserID.toString();
1072
+ }
1073
+ const request = {
1074
+ method: 'POST',
1075
+ path: requestPath,
1076
+ queryParameters,
1077
+ headers,
1078
+ data: assignUserIdParams,
1079
+ };
1080
+ return transporter.request(request, requestOptions);
1081
+ },
1082
+ /**
1083
+ * Perform multiple write operations targeting one index, in a single API call.
1084
+ *
1085
+ * @summary Batch operations to one index.
1086
+ * @param batch - The batch object.
1087
+ * @param batch.indexName - The index in which to perform the request.
1088
+ * @param batch.batchWriteParams - The batchWriteParams object.
1089
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1090
+ */
1091
+ batch({ indexName, batchWriteParams }, requestOptions) {
1092
+ if (!indexName) {
1093
+ throw new Error('Parameter `indexName` is required when calling `batch`.');
1094
+ }
1095
+ if (!batchWriteParams) {
1096
+ throw new Error('Parameter `batchWriteParams` is required when calling `batch`.');
1097
+ }
1098
+ if (!batchWriteParams.requests) {
1099
+ throw new Error('Parameter `batchWriteParams.requests` is required when calling `batch`.');
1100
+ }
1101
+ const requestPath = '/1/indexes/{indexName}/batch'.replace('{indexName}', encodeURIComponent(indexName));
1102
+ const headers = {};
1103
+ const queryParameters = {};
1104
+ const request = {
1105
+ method: 'POST',
1106
+ path: requestPath,
1107
+ queryParameters,
1108
+ headers,
1109
+ data: batchWriteParams,
1110
+ };
1111
+ return transporter.request(request, requestOptions);
1112
+ },
1113
+ /**
1114
+ * Assign multiple userIDs to a cluster. Upon success, the response is 200 OK. A successful response indicates that the operation has been taken into account, and the userIDs are directly usable.
1115
+ *
1116
+ * @summary Batch assign userIDs.
1117
+ * @param batchAssignUserIds - The batchAssignUserIds object.
1118
+ * @param batchAssignUserIds.xAlgoliaUserID - UserID to assign.
1119
+ * @param batchAssignUserIds.batchAssignUserIdsParams - The batchAssignUserIdsParams object.
1120
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1121
+ */
1122
+ batchAssignUserIds({ xAlgoliaUserID, batchAssignUserIdsParams }, requestOptions) {
1123
+ if (!xAlgoliaUserID) {
1124
+ throw new Error('Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.');
1125
+ }
1126
+ if (!batchAssignUserIdsParams) {
1127
+ throw new Error('Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.');
1128
+ }
1129
+ if (!batchAssignUserIdsParams.cluster) {
1130
+ throw new Error('Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.');
1131
+ }
1132
+ if (!batchAssignUserIdsParams.users) {
1133
+ throw new Error('Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.');
1134
+ }
1135
+ const requestPath = '/1/clusters/mapping/batch';
1136
+ const headers = {};
1137
+ const queryParameters = {};
1138
+ if (xAlgoliaUserID !== undefined) {
1139
+ headers['X-Algolia-User-ID'] = xAlgoliaUserID.toString();
1140
+ }
1141
+ const request = {
1142
+ method: 'POST',
1143
+ path: requestPath,
1144
+ queryParameters,
1145
+ headers,
1146
+ data: batchAssignUserIdsParams,
1147
+ };
1148
+ return transporter.request(request, requestOptions);
1149
+ },
1150
+ /**
1151
+ * Send a batch of dictionary entries.
1152
+ *
1153
+ * @summary Batch dictionary entries.
1154
+ * @param batchDictionaryEntries - The batchDictionaryEntries object.
1155
+ * @param batchDictionaryEntries.dictionaryName - The dictionary to search in.
1156
+ * @param batchDictionaryEntries.batchDictionaryEntriesParams - The batchDictionaryEntriesParams object.
1157
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1158
+ */
1159
+ batchDictionaryEntries({ dictionaryName, batchDictionaryEntriesParams, }, requestOptions) {
1160
+ if (!dictionaryName) {
1161
+ throw new Error('Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.');
1162
+ }
1163
+ if (!batchDictionaryEntriesParams) {
1164
+ throw new Error('Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.');
1165
+ }
1166
+ if (!batchDictionaryEntriesParams.requests) {
1167
+ throw new Error('Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`.');
1168
+ }
1169
+ const requestPath = '/1/dictionaries/{dictionaryName}/batch'.replace('{dictionaryName}', encodeURIComponent(dictionaryName));
1170
+ const headers = {};
1171
+ const queryParameters = {};
1172
+ const request = {
1173
+ method: 'POST',
1174
+ path: requestPath,
1175
+ queryParameters,
1176
+ headers,
1177
+ data: batchDictionaryEntriesParams,
1178
+ };
1179
+ return transporter.request(request, requestOptions);
1180
+ },
1181
+ /**
1182
+ * This method allows you to retrieve all index content. It can retrieve up to 1,000 records per call and supports full text search and filters. For performance reasons, some features are not supported, including `distinct`, sorting by `typos`, `words` or `geo distance`. When there is more content to be browsed, the response contains a cursor field. This cursor has to be passed to the subsequent call to browse in order to get the next page of results. When the end of the index has been reached, the cursor field is absent from the response.
1183
+ *
1184
+ * @summary Retrieve all index content.
1185
+ * @param browse - The browse object.
1186
+ * @param browse.indexName - The index in which to perform the request.
1187
+ * @param browse.browseParams - The browseParams object.
1188
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1189
+ */
1190
+ browse({ indexName, browseParams }, requestOptions) {
1191
+ if (!indexName) {
1192
+ throw new Error('Parameter `indexName` is required when calling `browse`.');
1193
+ }
1194
+ const requestPath = '/1/indexes/{indexName}/browse'.replace('{indexName}', encodeURIComponent(indexName));
1195
+ const headers = {};
1196
+ const queryParameters = {};
1197
+ const request = {
1198
+ method: 'POST',
1199
+ path: requestPath,
1200
+ queryParameters,
1201
+ headers,
1202
+ data: browseParams ? browseParams : {},
1203
+ };
1204
+ return transporter.request(request, requestOptions);
1205
+ },
1206
+ /**
1207
+ * Remove all synonyms from an index.
1208
+ *
1209
+ * @summary Clear all synonyms.
1210
+ * @param clearAllSynonyms - The clearAllSynonyms object.
1211
+ * @param clearAllSynonyms.indexName - The index in which to perform the request.
1212
+ * @param clearAllSynonyms.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1213
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1214
+ */
1215
+ clearAllSynonyms({ indexName, forwardToReplicas }, requestOptions) {
1216
+ if (!indexName) {
1217
+ throw new Error('Parameter `indexName` is required when calling `clearAllSynonyms`.');
1218
+ }
1219
+ const requestPath = '/1/indexes/{indexName}/synonyms/clear'.replace('{indexName}', encodeURIComponent(indexName));
1220
+ const headers = {};
1221
+ const queryParameters = {};
1222
+ if (forwardToReplicas !== undefined) {
1223
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
1224
+ }
1225
+ const request = {
1226
+ method: 'POST',
1227
+ path: requestPath,
1228
+ queryParameters,
1229
+ headers,
1230
+ };
1231
+ return transporter.request(request, requestOptions);
1232
+ },
1233
+ /**
1234
+ * Delete an index\'s content, but leave settings and index-specific API keys untouched.
1235
+ *
1236
+ * @summary Clear all objects from an index.
1237
+ * @param clearObjects - The clearObjects object.
1238
+ * @param clearObjects.indexName - The index in which to perform the request.
1239
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1240
+ */
1241
+ clearObjects({ indexName }, requestOptions) {
1242
+ if (!indexName) {
1243
+ throw new Error('Parameter `indexName` is required when calling `clearObjects`.');
1244
+ }
1245
+ const requestPath = '/1/indexes/{indexName}/clear'.replace('{indexName}', encodeURIComponent(indexName));
1246
+ const headers = {};
1247
+ const queryParameters = {};
1248
+ const request = {
1249
+ method: 'POST',
1250
+ path: requestPath,
1251
+ queryParameters,
1252
+ headers,
1253
+ };
1254
+ return transporter.request(request, requestOptions);
1255
+ },
1256
+ /**
1257
+ * Delete all Rules in the index.
1258
+ *
1259
+ * @summary Clear Rules.
1260
+ * @param clearRules - The clearRules object.
1261
+ * @param clearRules.indexName - The index in which to perform the request.
1262
+ * @param clearRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1263
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1264
+ */
1265
+ clearRules({ indexName, forwardToReplicas }, requestOptions) {
1266
+ if (!indexName) {
1267
+ throw new Error('Parameter `indexName` is required when calling `clearRules`.');
1268
+ }
1269
+ const requestPath = '/1/indexes/{indexName}/rules/clear'.replace('{indexName}', encodeURIComponent(indexName));
1270
+ const headers = {};
1271
+ const queryParameters = {};
1272
+ if (forwardToReplicas !== undefined) {
1273
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
1274
+ }
1275
+ const request = {
1276
+ method: 'POST',
1277
+ path: requestPath,
1278
+ queryParameters,
1279
+ headers,
1280
+ };
1281
+ return transporter.request(request, requestOptions);
1282
+ },
1283
+ /**
1284
+ * This method allow you to send requests to the Algolia REST API.
1285
+ *
1286
+ * @summary Send requests to the Algolia REST API.
1287
+ * @param del - The del object.
1288
+ * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1289
+ * @param del.parameters - Query parameters to be applied to the current query.
1290
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1291
+ */
1292
+ del({ path, parameters }, requestOptions) {
1293
+ if (!path) {
1294
+ throw new Error('Parameter `path` is required when calling `del`.');
1295
+ }
1296
+ const requestPath = '/1{path}'.replace('{path}', path);
1297
+ const headers = {};
1298
+ const queryParameters = parameters ? parameters : {};
1299
+ const request = {
1300
+ method: 'DELETE',
1301
+ path: requestPath,
1302
+ queryParameters,
1303
+ headers,
1304
+ };
1305
+ return transporter.request(request, requestOptions);
1306
+ },
1307
+ /**
1308
+ * Delete an existing API Key.
1309
+ *
1310
+ * @summary Delete an API key.
1311
+ * @param deleteApiKey - The deleteApiKey object.
1312
+ * @param deleteApiKey.key - API Key string.
1313
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1314
+ */
1315
+ deleteApiKey({ key }, requestOptions) {
1316
+ if (!key) {
1317
+ throw new Error('Parameter `key` is required when calling `deleteApiKey`.');
1318
+ }
1319
+ const requestPath = '/1/keys/{key}'.replace('{key}', encodeURIComponent(key));
1320
+ const headers = {};
1321
+ const queryParameters = {};
1322
+ const request = {
1323
+ method: 'DELETE',
1324
+ path: requestPath,
1325
+ queryParameters,
1326
+ headers,
1327
+ };
1328
+ return transporter.request(request, requestOptions);
1329
+ },
1330
+ /**
1331
+ * Remove all objects matching a filter (including geo filters). This method enables you to delete one or more objects based on filters (numeric, facet, tag or geo queries). It doesn\'t accept empty filters or a query.
1332
+ *
1333
+ * @summary Delete all records matching the query.
1334
+ * @param deleteBy - The deleteBy object.
1335
+ * @param deleteBy.indexName - The index in which to perform the request.
1336
+ * @param deleteBy.deleteByParams - The deleteByParams object.
1337
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1338
+ */
1339
+ deleteBy({ indexName, deleteByParams }, requestOptions) {
1340
+ if (!indexName) {
1341
+ throw new Error('Parameter `indexName` is required when calling `deleteBy`.');
1342
+ }
1343
+ if (!deleteByParams) {
1344
+ throw new Error('Parameter `deleteByParams` is required when calling `deleteBy`.');
1345
+ }
1346
+ const requestPath = '/1/indexes/{indexName}/deleteByQuery'.replace('{indexName}', encodeURIComponent(indexName));
1347
+ const headers = {};
1348
+ const queryParameters = {};
1349
+ const request = {
1350
+ method: 'POST',
1351
+ path: requestPath,
1352
+ queryParameters,
1353
+ headers,
1354
+ data: deleteByParams,
1355
+ };
1356
+ return transporter.request(request, requestOptions);
1357
+ },
1358
+ /**
1359
+ * Delete an existing index.
1360
+ *
1361
+ * @summary Delete index.
1362
+ * @param deleteIndex - The deleteIndex object.
1363
+ * @param deleteIndex.indexName - The index in which to perform the request.
1364
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1365
+ */
1366
+ deleteIndex({ indexName }, requestOptions) {
1367
+ if (!indexName) {
1368
+ throw new Error('Parameter `indexName` is required when calling `deleteIndex`.');
1369
+ }
1370
+ const requestPath = '/1/indexes/{indexName}'.replace('{indexName}', encodeURIComponent(indexName));
1371
+ const headers = {};
1372
+ const queryParameters = {};
1373
+ const request = {
1374
+ method: 'DELETE',
1375
+ path: requestPath,
1376
+ queryParameters,
1377
+ headers,
1378
+ };
1379
+ return transporter.request(request, requestOptions);
1380
+ },
1381
+ /**
1382
+ * Delete an existing object.
1383
+ *
1384
+ * @summary Delete an object.
1385
+ * @param deleteObject - The deleteObject object.
1386
+ * @param deleteObject.indexName - The index in which to perform the request.
1387
+ * @param deleteObject.objectID - Unique identifier of an object.
1388
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1389
+ */
1390
+ deleteObject({ indexName, objectID }, requestOptions) {
1391
+ if (!indexName) {
1392
+ throw new Error('Parameter `indexName` is required when calling `deleteObject`.');
1393
+ }
1394
+ if (!objectID) {
1395
+ throw new Error('Parameter `objectID` is required when calling `deleteObject`.');
1396
+ }
1397
+ const requestPath = '/1/indexes/{indexName}/{objectID}'
1398
+ .replace('{indexName}', encodeURIComponent(indexName))
1399
+ .replace('{objectID}', encodeURIComponent(objectID));
1400
+ const headers = {};
1401
+ const queryParameters = {};
1402
+ const request = {
1403
+ method: 'DELETE',
1404
+ path: requestPath,
1405
+ queryParameters,
1406
+ headers,
1407
+ };
1408
+ return transporter.request(request, requestOptions);
1409
+ },
1410
+ /**
1411
+ * Delete the Rule with the specified objectID.
1412
+ *
1413
+ * @summary Delete a rule.
1414
+ * @param deleteRule - The deleteRule object.
1415
+ * @param deleteRule.indexName - The index in which to perform the request.
1416
+ * @param deleteRule.objectID - Unique identifier of an object.
1417
+ * @param deleteRule.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1418
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1419
+ */
1420
+ deleteRule({ indexName, objectID, forwardToReplicas }, requestOptions) {
1421
+ if (!indexName) {
1422
+ throw new Error('Parameter `indexName` is required when calling `deleteRule`.');
1423
+ }
1424
+ if (!objectID) {
1425
+ throw new Error('Parameter `objectID` is required when calling `deleteRule`.');
1426
+ }
1427
+ const requestPath = '/1/indexes/{indexName}/rules/{objectID}'
1428
+ .replace('{indexName}', encodeURIComponent(indexName))
1429
+ .replace('{objectID}', encodeURIComponent(objectID));
1430
+ const headers = {};
1431
+ const queryParameters = {};
1432
+ if (forwardToReplicas !== undefined) {
1433
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
1434
+ }
1435
+ const request = {
1436
+ method: 'DELETE',
1437
+ path: requestPath,
1438
+ queryParameters,
1439
+ headers,
1440
+ };
1441
+ return transporter.request(request, requestOptions);
1442
+ },
1443
+ /**
1444
+ * Remove a single source from the list of allowed sources.
1445
+ *
1446
+ * @summary Remove a single source.
1447
+ * @param deleteSource - The deleteSource object.
1448
+ * @param deleteSource.source - The IP range of the source.
1449
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1450
+ */
1451
+ deleteSource({ source }, requestOptions) {
1452
+ if (!source) {
1453
+ throw new Error('Parameter `source` is required when calling `deleteSource`.');
1454
+ }
1455
+ const requestPath = '/1/security/sources/{source}'.replace('{source}', encodeURIComponent(source));
1456
+ const headers = {};
1457
+ const queryParameters = {};
1458
+ const request = {
1459
+ method: 'DELETE',
1460
+ path: requestPath,
1461
+ queryParameters,
1462
+ headers,
1463
+ };
1464
+ return transporter.request(request, requestOptions);
1465
+ },
1466
+ /**
1467
+ * Delete a single synonyms set, identified by the given objectID.
1468
+ *
1469
+ * @summary Delete synonym.
1470
+ * @param deleteSynonym - The deleteSynonym object.
1471
+ * @param deleteSynonym.indexName - The index in which to perform the request.
1472
+ * @param deleteSynonym.objectID - Unique identifier of an object.
1473
+ * @param deleteSynonym.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
1474
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1475
+ */
1476
+ deleteSynonym({ indexName, objectID, forwardToReplicas }, requestOptions) {
1477
+ if (!indexName) {
1478
+ throw new Error('Parameter `indexName` is required when calling `deleteSynonym`.');
1479
+ }
1480
+ if (!objectID) {
1481
+ throw new Error('Parameter `objectID` is required when calling `deleteSynonym`.');
1482
+ }
1483
+ const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}'
1484
+ .replace('{indexName}', encodeURIComponent(indexName))
1485
+ .replace('{objectID}', encodeURIComponent(objectID));
1486
+ const headers = {};
1487
+ const queryParameters = {};
1488
+ if (forwardToReplicas !== undefined) {
1489
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
1490
+ }
1491
+ const request = {
1492
+ method: 'DELETE',
1493
+ path: requestPath,
1494
+ queryParameters,
1495
+ headers,
1496
+ };
1497
+ return transporter.request(request, requestOptions);
1498
+ },
1499
+ /**
1500
+ * This method allow you to send requests to the Algolia REST API.
1501
+ *
1502
+ * @summary Send requests to the Algolia REST API.
1503
+ * @param get - The get object.
1504
+ * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
1505
+ * @param get.parameters - Query parameters to be applied to the current query.
1506
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1507
+ */
1508
+ get({ path, parameters }, requestOptions) {
1509
+ if (!path) {
1510
+ throw new Error('Parameter `path` is required when calling `get`.');
1511
+ }
1512
+ const requestPath = '/1{path}'.replace('{path}', path);
1513
+ const headers = {};
1514
+ const queryParameters = parameters ? parameters : {};
1515
+ const request = {
1516
+ method: 'GET',
1517
+ path: requestPath,
1518
+ queryParameters,
1519
+ headers,
1520
+ };
1521
+ return transporter.request(request, requestOptions);
1522
+ },
1523
+ /**
1524
+ * Get the permissions of an API key.
1525
+ *
1526
+ * @summary Get an API key.
1527
+ * @param getApiKey - The getApiKey object.
1528
+ * @param getApiKey.key - API Key string.
1529
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1530
+ */
1531
+ getApiKey({ key }, requestOptions) {
1532
+ if (!key) {
1533
+ throw new Error('Parameter `key` is required when calling `getApiKey`.');
1534
+ }
1535
+ const requestPath = '/1/keys/{key}'.replace('{key}', encodeURIComponent(key));
1536
+ const headers = {};
1537
+ const queryParameters = {};
1538
+ const request = {
1539
+ method: 'GET',
1540
+ path: requestPath,
1541
+ queryParameters,
1542
+ headers,
1543
+ };
1544
+ return transporter.request(request, requestOptions);
1545
+ },
1546
+ /**
1547
+ * List dictionaries supported per language.
1548
+ *
1549
+ * @summary List available languages.
1550
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1551
+ */
1552
+ getDictionaryLanguages(requestOptions) {
1553
+ const requestPath = '/1/dictionaries/*/languages';
1554
+ const headers = {};
1555
+ const queryParameters = {};
1556
+ const request = {
1557
+ method: 'GET',
1558
+ path: requestPath,
1559
+ queryParameters,
1560
+ headers,
1561
+ };
1562
+ return transporter.request(request, requestOptions);
1563
+ },
1564
+ /**
1565
+ * Retrieve dictionaries settings. The API stores languages whose standard entries are disabled. Fetch settings does not return false values.
1566
+ *
1567
+ * @summary Retrieve dictionaries settings.
1568
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1569
+ */
1570
+ getDictionarySettings(requestOptions) {
1571
+ const requestPath = '/1/dictionaries/*/settings';
1572
+ const headers = {};
1573
+ const queryParameters = {};
1574
+ const request = {
1575
+ method: 'GET',
1576
+ path: requestPath,
1577
+ queryParameters,
1578
+ headers,
1579
+ };
1580
+ return transporter.request(request, requestOptions);
1581
+ },
1582
+ /**
1583
+ * Return the latest log entries.
1584
+ *
1585
+ * @summary Return the latest log entries.
1586
+ * @param getLogs - The getLogs object.
1587
+ * @param getLogs.offset - First entry to retrieve (zero-based). Log entries are sorted by decreasing date, therefore 0 designates the most recent log entry.
1588
+ * @param getLogs.length - Maximum number of entries to retrieve. The maximum allowed value is 1000.
1589
+ * @param getLogs.indexName - Index for which log entries should be retrieved. When omitted, log entries are retrieved across all indices.
1590
+ * @param getLogs.type - Type of log entries to retrieve. When omitted, all log entries are retrieved.
1591
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1592
+ */
1593
+ getLogs({ offset, length, indexName, type } = {}, requestOptions = undefined) {
1594
+ const requestPath = '/1/logs';
1595
+ const headers = {};
1596
+ const queryParameters = {};
1597
+ if (offset !== undefined) {
1598
+ queryParameters.offset = offset.toString();
1599
+ }
1600
+ if (length !== undefined) {
1601
+ queryParameters.length = length.toString();
1602
+ }
1603
+ if (indexName !== undefined) {
1604
+ queryParameters.indexName = indexName.toString();
1605
+ }
1606
+ if (type !== undefined) {
1607
+ queryParameters.type = type.toString();
1608
+ }
1609
+ const request = {
1610
+ method: 'GET',
1611
+ path: requestPath,
1612
+ queryParameters,
1613
+ headers,
1614
+ };
1615
+ return transporter.request(request, requestOptions);
1616
+ },
1617
+ /**
1618
+ * Retrieve one object from the index.
1619
+ *
1620
+ * @summary Retrieve an object.
1621
+ * @param getObject - The getObject object.
1622
+ * @param getObject.indexName - The index in which to perform the request.
1623
+ * @param getObject.objectID - Unique identifier of an object.
1624
+ * @param getObject.attributesToRetrieve - List of attributes to retrieve. If not specified, all retrievable attributes are returned.
1625
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1626
+ */
1627
+ getObject({ indexName, objectID, attributesToRetrieve }, requestOptions) {
1628
+ if (!indexName) {
1629
+ throw new Error('Parameter `indexName` is required when calling `getObject`.');
1630
+ }
1631
+ if (!objectID) {
1632
+ throw new Error('Parameter `objectID` is required when calling `getObject`.');
1633
+ }
1634
+ const requestPath = '/1/indexes/{indexName}/{objectID}'
1635
+ .replace('{indexName}', encodeURIComponent(indexName))
1636
+ .replace('{objectID}', encodeURIComponent(objectID));
1637
+ const headers = {};
1638
+ const queryParameters = {};
1639
+ if (attributesToRetrieve !== undefined) {
1640
+ queryParameters.attributesToRetrieve = attributesToRetrieve.toString();
1641
+ }
1642
+ const request = {
1643
+ method: 'GET',
1644
+ path: requestPath,
1645
+ queryParameters,
1646
+ headers,
1647
+ };
1648
+ return transporter.request(request, requestOptions);
1649
+ },
1650
+ /**
1651
+ * Retrieve one or more objects, potentially from different indices, in a single API call.
1652
+ *
1653
+ * @summary Retrieve one or more objects.
1654
+ * @param getObjectsParams - The Algolia object.
1655
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1656
+ */
1657
+ getObjects(getObjectsParams, requestOptions) {
1658
+ if (!getObjectsParams) {
1659
+ throw new Error('Parameter `getObjectsParams` is required when calling `getObjects`.');
1660
+ }
1661
+ if (!getObjectsParams.requests) {
1662
+ throw new Error('Parameter `getObjectsParams.requests` is required when calling `getObjects`.');
1663
+ }
1664
+ const requestPath = '/1/indexes/*/objects';
1665
+ const headers = {};
1666
+ const queryParameters = {};
1667
+ const request = {
1668
+ method: 'POST',
1669
+ path: requestPath,
1670
+ queryParameters,
1671
+ headers,
1672
+ data: getObjectsParams,
1673
+ useReadTransporter: true,
1674
+ cacheable: true,
1675
+ };
1676
+ return transporter.request(request, requestOptions);
1677
+ },
1678
+ /**
1679
+ * Retrieve the Rule with the specified objectID.
1680
+ *
1681
+ * @summary Get a rule.
1682
+ * @param getRule - The getRule object.
1683
+ * @param getRule.indexName - The index in which to perform the request.
1684
+ * @param getRule.objectID - Unique identifier of an object.
1685
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1686
+ */
1687
+ getRule({ indexName, objectID }, requestOptions) {
1688
+ if (!indexName) {
1689
+ throw new Error('Parameter `indexName` is required when calling `getRule`.');
1690
+ }
1691
+ if (!objectID) {
1692
+ throw new Error('Parameter `objectID` is required when calling `getRule`.');
1693
+ }
1694
+ const requestPath = '/1/indexes/{indexName}/rules/{objectID}'
1695
+ .replace('{indexName}', encodeURIComponent(indexName))
1696
+ .replace('{objectID}', encodeURIComponent(objectID));
1697
+ const headers = {};
1698
+ const queryParameters = {};
1699
+ const request = {
1700
+ method: 'GET',
1701
+ path: requestPath,
1702
+ queryParameters,
1703
+ headers,
1704
+ };
1705
+ return transporter.request(request, requestOptions);
1706
+ },
1707
+ /**
1708
+ * Retrieve settings of an index.
1709
+ *
1710
+ * @summary Retrieve settings of an index.
1711
+ * @param getSettings - The getSettings object.
1712
+ * @param getSettings.indexName - The index in which to perform the request.
1713
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1714
+ */
1715
+ getSettings({ indexName }, requestOptions) {
1716
+ if (!indexName) {
1717
+ throw new Error('Parameter `indexName` is required when calling `getSettings`.');
1718
+ }
1719
+ const requestPath = '/1/indexes/{indexName}/settings'.replace('{indexName}', encodeURIComponent(indexName));
1720
+ const headers = {};
1721
+ const queryParameters = {};
1722
+ const request = {
1723
+ method: 'GET',
1724
+ path: requestPath,
1725
+ queryParameters,
1726
+ headers,
1727
+ };
1728
+ return transporter.request(request, requestOptions);
1729
+ },
1730
+ /**
1731
+ * List all allowed sources.
1732
+ *
1733
+ * @summary List all allowed sources.
1734
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1735
+ */
1736
+ getSources(requestOptions) {
1737
+ const requestPath = '/1/security/sources';
1738
+ const headers = {};
1739
+ const queryParameters = {};
1740
+ const request = {
1741
+ method: 'GET',
1742
+ path: requestPath,
1743
+ queryParameters,
1744
+ headers,
1745
+ };
1746
+ return transporter.request(request, requestOptions);
1747
+ },
1748
+ /**
1749
+ * Fetch a synonym object identified by its objectID.
1750
+ *
1751
+ * @summary Get synonym.
1752
+ * @param getSynonym - The getSynonym object.
1753
+ * @param getSynonym.indexName - The index in which to perform the request.
1754
+ * @param getSynonym.objectID - Unique identifier of an object.
1755
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1756
+ */
1757
+ getSynonym({ indexName, objectID }, requestOptions) {
1758
+ if (!indexName) {
1759
+ throw new Error('Parameter `indexName` is required when calling `getSynonym`.');
1760
+ }
1761
+ if (!objectID) {
1762
+ throw new Error('Parameter `objectID` is required when calling `getSynonym`.');
1763
+ }
1764
+ const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}'
1765
+ .replace('{indexName}', encodeURIComponent(indexName))
1766
+ .replace('{objectID}', encodeURIComponent(objectID));
1767
+ const headers = {};
1768
+ const queryParameters = {};
1769
+ const request = {
1770
+ method: 'GET',
1771
+ path: requestPath,
1772
+ queryParameters,
1773
+ headers,
1774
+ };
1775
+ return transporter.request(request, requestOptions);
1776
+ },
1777
+ /**
1778
+ * Check the current status of a given task.
1779
+ *
1780
+ * @summary Check the status of a task.
1781
+ * @param getTask - The getTask object.
1782
+ * @param getTask.indexName - The index in which to perform the request.
1783
+ * @param getTask.taskID - Unique identifier of an task. Numeric value (up to 64bits).
1784
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1785
+ */
1786
+ getTask({ indexName, taskID }, requestOptions) {
1787
+ if (!indexName) {
1788
+ throw new Error('Parameter `indexName` is required when calling `getTask`.');
1789
+ }
1790
+ if (!taskID) {
1791
+ throw new Error('Parameter `taskID` is required when calling `getTask`.');
1792
+ }
1793
+ const requestPath = '/1/indexes/{indexName}/task/{taskID}'
1794
+ .replace('{indexName}', encodeURIComponent(indexName))
1795
+ .replace('{taskID}', encodeURIComponent(taskID));
1796
+ const headers = {};
1797
+ const queryParameters = {};
1798
+ const request = {
1799
+ method: 'GET',
1800
+ path: requestPath,
1801
+ queryParameters,
1802
+ headers,
1803
+ };
1804
+ return transporter.request(request, requestOptions);
1805
+ },
1806
+ /**
1807
+ * Get the top 10 userIDs with the highest number of records per cluster. The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds to propagate to the different clusters. Upon success, the response is 200 OK and contains the following array of userIDs and clusters.
1808
+ *
1809
+ * @summary Get top userID.
1810
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1811
+ */
1812
+ getTopUserIds(requestOptions) {
1813
+ const requestPath = '/1/clusters/mapping/top';
1814
+ const headers = {};
1815
+ const queryParameters = {};
1816
+ const request = {
1817
+ method: 'GET',
1818
+ path: requestPath,
1819
+ queryParameters,
1820
+ headers,
1821
+ };
1822
+ return transporter.request(request, requestOptions);
1823
+ },
1824
+ /**
1825
+ * Returns the userID data stored in the mapping. The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds to propagate to the different clusters. Upon success, the response is 200 OK and contains the following userID data.
1826
+ *
1827
+ * @summary Get userID.
1828
+ * @param getUserId - The getUserId object.
1829
+ * @param getUserId.userID - UserID to assign.
1830
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1831
+ */
1832
+ getUserId({ userID }, requestOptions) {
1833
+ if (!userID) {
1834
+ throw new Error('Parameter `userID` is required when calling `getUserId`.');
1835
+ }
1836
+ const requestPath = '/1/clusters/mapping/{userID}'.replace('{userID}', encodeURIComponent(userID));
1837
+ const headers = {};
1838
+ const queryParameters = {};
1839
+ const request = {
1840
+ method: 'GET',
1841
+ path: requestPath,
1842
+ queryParameters,
1843
+ headers,
1844
+ };
1845
+ return transporter.request(request, requestOptions);
1846
+ },
1847
+ /**
1848
+ * Get the status of your clusters\' migrations or user creations. Creating a large batch of users or migrating your multi-cluster may take quite some time. This method lets you retrieve the status of the migration, so you can know when it\'s done. Upon success, the response is 200 OK. A successful response indicates that the operation has been taken into account, and the userIDs are directly usable.
1849
+ *
1850
+ * @summary Get migration status.
1851
+ * @param hasPendingMappings - The hasPendingMappings object.
1852
+ * @param hasPendingMappings.getClusters - If the clusters pending mapping state should be on the response.
1853
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1854
+ */
1855
+ hasPendingMappings({ getClusters } = {}, requestOptions = undefined) {
1856
+ const requestPath = '/1/clusters/mapping/pending';
1857
+ const headers = {};
1858
+ const queryParameters = {};
1859
+ if (getClusters !== undefined) {
1860
+ queryParameters.getClusters = getClusters.toString();
1861
+ }
1862
+ const request = {
1863
+ method: 'GET',
1864
+ path: requestPath,
1865
+ queryParameters,
1866
+ headers,
1867
+ };
1868
+ return transporter.request(request, requestOptions);
1869
+ },
1870
+ /**
1871
+ * List API keys, along with their associated rights.
1872
+ *
1873
+ * @summary List API Keys.
1874
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1875
+ */
1876
+ listApiKeys(requestOptions) {
1877
+ const requestPath = '/1/keys';
1878
+ const headers = {};
1879
+ const queryParameters = {};
1880
+ const request = {
1881
+ method: 'GET',
1882
+ path: requestPath,
1883
+ queryParameters,
1884
+ headers,
1885
+ };
1886
+ return transporter.request(request, requestOptions);
1887
+ },
1888
+ /**
1889
+ * List the clusters available in a multi-clusters setup for a single appID. Upon success, the response is 200 OK and contains the following clusters.
1890
+ *
1891
+ * @summary List clusters.
1892
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1893
+ */
1894
+ listClusters(requestOptions) {
1895
+ const requestPath = '/1/clusters';
1896
+ const headers = {};
1897
+ const queryParameters = {};
1898
+ const request = {
1899
+ method: 'GET',
1900
+ path: requestPath,
1901
+ queryParameters,
1902
+ headers,
1903
+ };
1904
+ return transporter.request(request, requestOptions);
1905
+ },
1906
+ /**
1907
+ * List existing indexes from an application.
1908
+ *
1909
+ * @summary List existing indexes.
1910
+ * @param listIndices - The listIndices object.
1911
+ * @param listIndices.page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination).
1912
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1913
+ */
1914
+ listIndices({ page } = {}, requestOptions = undefined) {
1915
+ const requestPath = '/1/indexes';
1916
+ const headers = {};
1917
+ const queryParameters = {};
1918
+ if (page !== undefined) {
1919
+ queryParameters.page = page.toString();
1920
+ }
1921
+ const request = {
1922
+ method: 'GET',
1923
+ path: requestPath,
1924
+ queryParameters,
1925
+ headers,
1926
+ };
1927
+ return transporter.request(request, requestOptions);
1928
+ },
1929
+ /**
1930
+ * List the userIDs assigned to a multi-clusters appID. The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds to propagate to the different clusters. Upon success, the response is 200 OK and contains the following userIDs data.
1931
+ *
1932
+ * @summary List userIDs.
1933
+ * @param listUserIds - The listUserIds object.
1934
+ * @param listUserIds.page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination).
1935
+ * @param listUserIds.hitsPerPage - Maximum number of objects to retrieve.
1936
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1937
+ */
1938
+ listUserIds({ page, hitsPerPage } = {}, requestOptions = undefined) {
1939
+ const requestPath = '/1/clusters/mapping';
1940
+ const headers = {};
1941
+ const queryParameters = {};
1942
+ if (page !== undefined) {
1943
+ queryParameters.page = page.toString();
1944
+ }
1945
+ if (hitsPerPage !== undefined) {
1946
+ queryParameters.hitsPerPage = hitsPerPage.toString();
1947
+ }
1948
+ const request = {
1949
+ method: 'GET',
1950
+ path: requestPath,
1951
+ queryParameters,
1952
+ headers,
1953
+ };
1954
+ return transporter.request(request, requestOptions);
1955
+ },
1956
+ /**
1957
+ * Perform multiple write operations, potentially targeting multiple indices, in a single API call.
1958
+ *
1959
+ * @summary Batch operations to many indices.
1960
+ * @param batchParams - The batchParams object.
1961
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1962
+ */
1963
+ multipleBatch(batchParams, requestOptions) {
1964
+ if (!batchParams) {
1965
+ throw new Error('Parameter `batchParams` is required when calling `multipleBatch`.');
1966
+ }
1967
+ if (!batchParams.requests) {
1968
+ throw new Error('Parameter `batchParams.requests` is required when calling `multipleBatch`.');
1969
+ }
1970
+ const requestPath = '/1/indexes/*/batch';
1971
+ const headers = {};
1972
+ const queryParameters = {};
1973
+ const request = {
1974
+ method: 'POST',
1975
+ path: requestPath,
1976
+ queryParameters,
1977
+ headers,
1978
+ data: batchParams,
1979
+ };
1980
+ return transporter.request(request, requestOptions);
1981
+ },
1982
+ /**
1983
+ * Performs a copy or a move operation on a index.
1984
+ *
1985
+ * @summary Copy/move index.
1986
+ * @param operationIndex - The operationIndex object.
1987
+ * @param operationIndex.indexName - The index in which to perform the request.
1988
+ * @param operationIndex.operationIndexParams - The operationIndexParams object.
1989
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
1990
+ */
1991
+ operationIndex({ indexName, operationIndexParams }, requestOptions) {
1992
+ if (!indexName) {
1993
+ throw new Error('Parameter `indexName` is required when calling `operationIndex`.');
1994
+ }
1995
+ if (!operationIndexParams) {
1996
+ throw new Error('Parameter `operationIndexParams` is required when calling `operationIndex`.');
1997
+ }
1998
+ if (!operationIndexParams.operation) {
1999
+ throw new Error('Parameter `operationIndexParams.operation` is required when calling `operationIndex`.');
2000
+ }
2001
+ if (!operationIndexParams.destination) {
2002
+ throw new Error('Parameter `operationIndexParams.destination` is required when calling `operationIndex`.');
2003
+ }
2004
+ const requestPath = '/1/indexes/{indexName}/operation'.replace('{indexName}', encodeURIComponent(indexName));
2005
+ const headers = {};
2006
+ const queryParameters = {};
2007
+ const request = {
2008
+ method: 'POST',
2009
+ path: requestPath,
2010
+ queryParameters,
2011
+ headers,
2012
+ data: operationIndexParams,
2013
+ };
2014
+ return transporter.request(request, requestOptions);
2015
+ },
2016
+ /**
2017
+ * Update one or more attributes of an existing object. This method lets you update only a part of an existing object, either by adding new attributes or updating existing ones. You can partially update several objects in a single method call. If the index targeted by this operation doesn\'t exist yet, it\'s automatically created.
2018
+ *
2019
+ * @summary Partially update an object.
2020
+ * @param partialUpdateObject - The partialUpdateObject object.
2021
+ * @param partialUpdateObject.indexName - The index in which to perform the request.
2022
+ * @param partialUpdateObject.objectID - Unique identifier of an object.
2023
+ * @param partialUpdateObject.attributesToUpdate - Map of attribute(s) to update.
2024
+ * @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
2025
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2026
+ */
2027
+ partialUpdateObject({ indexName, objectID, attributesToUpdate, createIfNotExists, }, requestOptions) {
2028
+ if (!indexName) {
2029
+ throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
2030
+ }
2031
+ if (!objectID) {
2032
+ throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
2033
+ }
2034
+ if (!attributesToUpdate) {
2035
+ throw new Error('Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.');
2036
+ }
2037
+ const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
2038
+ .replace('{indexName}', encodeURIComponent(indexName))
2039
+ .replace('{objectID}', encodeURIComponent(objectID));
2040
+ const headers = {};
2041
+ const queryParameters = {};
2042
+ if (createIfNotExists !== undefined) {
2043
+ queryParameters.createIfNotExists = createIfNotExists.toString();
2044
+ }
2045
+ const request = {
2046
+ method: 'POST',
2047
+ path: requestPath,
2048
+ queryParameters,
2049
+ headers,
2050
+ data: attributesToUpdate,
2051
+ };
2052
+ return transporter.request(request, requestOptions);
2053
+ },
2054
+ /**
2055
+ * This method allow you to send requests to the Algolia REST API.
2056
+ *
2057
+ * @summary Send requests to the Algolia REST API.
2058
+ * @param post - The post object.
2059
+ * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
2060
+ * @param post.parameters - Query parameters to be applied to the current query.
2061
+ * @param post.body - The parameters to send with the custom request.
2062
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2063
+ */
2064
+ post({ path, parameters, body }, requestOptions) {
2065
+ if (!path) {
2066
+ throw new Error('Parameter `path` is required when calling `post`.');
2067
+ }
2068
+ const requestPath = '/1{path}'.replace('{path}', path);
2069
+ const headers = {};
2070
+ const queryParameters = parameters ? parameters : {};
2071
+ const request = {
2072
+ method: 'POST',
2073
+ path: requestPath,
2074
+ queryParameters,
2075
+ headers,
2076
+ data: body ? body : {},
2077
+ };
2078
+ return transporter.request(request, requestOptions);
2079
+ },
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 put - The put object.
2085
+ * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
2086
+ * @param put.parameters - Query parameters to be applied to the current query.
2087
+ * @param put.body - The 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
+ put({ path, parameters, body }, requestOptions) {
2091
+ if (!path) {
2092
+ throw new Error('Parameter `path` is required when calling `put`.');
2093
+ }
2094
+ const requestPath = '/1{path}'.replace('{path}', path);
2095
+ const headers = {};
2096
+ const queryParameters = parameters ? parameters : {};
2097
+ const request = {
2098
+ method: 'PUT',
2099
+ path: requestPath,
2100
+ queryParameters,
2101
+ headers,
2102
+ data: body ? body : {},
2103
+ };
2104
+ return transporter.request(request, requestOptions);
2105
+ },
2106
+ /**
2107
+ * Remove a userID and its associated data from the multi-clusters. Upon success, the response is 200 OK and a task is created to remove the userID data and mapping.
2108
+ *
2109
+ * @summary Remove userID.
2110
+ * @param removeUserId - The removeUserId object.
2111
+ * @param removeUserId.userID - UserID to assign.
2112
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2113
+ */
2114
+ removeUserId({ userID }, requestOptions) {
2115
+ if (!userID) {
2116
+ throw new Error('Parameter `userID` is required when calling `removeUserId`.');
2117
+ }
2118
+ const requestPath = '/1/clusters/mapping/{userID}'.replace('{userID}', encodeURIComponent(userID));
2119
+ const headers = {};
2120
+ const queryParameters = {};
2121
+ const request = {
2122
+ method: 'DELETE',
2123
+ path: requestPath,
2124
+ queryParameters,
2125
+ headers,
2126
+ };
2127
+ return transporter.request(request, requestOptions);
2128
+ },
2129
+ /**
2130
+ * Replace all allowed sources.
2131
+ *
2132
+ * @summary Replace all allowed sources.
2133
+ * @param replaceSources - The replaceSources object.
2134
+ * @param replaceSources.source - The sources to allow.
2135
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2136
+ */
2137
+ replaceSources({ source }, requestOptions) {
2138
+ if (!source) {
2139
+ throw new Error('Parameter `source` is required when calling `replaceSources`.');
2140
+ }
2141
+ const requestPath = '/1/security/sources';
2142
+ const headers = {};
2143
+ const queryParameters = {};
2144
+ const request = {
2145
+ method: 'PUT',
2146
+ path: requestPath,
2147
+ queryParameters,
2148
+ headers,
2149
+ data: source,
2150
+ };
2151
+ return transporter.request(request, requestOptions);
2152
+ },
2153
+ /**
2154
+ * Restore a deleted API key, along with its associated rights.
2155
+ *
2156
+ * @summary Restore an API key.
2157
+ * @param restoreApiKey - The restoreApiKey object.
2158
+ * @param restoreApiKey.key - API Key string.
2159
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2160
+ */
2161
+ restoreApiKey({ key }, requestOptions) {
2162
+ if (!key) {
2163
+ throw new Error('Parameter `key` is required when calling `restoreApiKey`.');
2164
+ }
2165
+ const requestPath = '/1/keys/{key}/restore'.replace('{key}', encodeURIComponent(key));
2166
+ const headers = {};
2167
+ const queryParameters = {};
2168
+ const request = {
2169
+ method: 'POST',
2170
+ path: requestPath,
2171
+ queryParameters,
2172
+ headers,
2173
+ };
2174
+ return transporter.request(request, requestOptions);
2175
+ },
2176
+ /**
2177
+ * Add an object to the index, automatically assigning it an object ID.
2178
+ *
2179
+ * @summary Add an object to the index.
2180
+ * @param saveObject - The saveObject object.
2181
+ * @param saveObject.indexName - The index in which to perform the request.
2182
+ * @param saveObject.body - The Algolia record.
2183
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2184
+ */
2185
+ saveObject({ indexName, body }, requestOptions) {
2186
+ if (!indexName) {
2187
+ throw new Error('Parameter `indexName` is required when calling `saveObject`.');
2188
+ }
2189
+ if (!body) {
2190
+ throw new Error('Parameter `body` is required when calling `saveObject`.');
2191
+ }
2192
+ const requestPath = '/1/indexes/{indexName}'.replace('{indexName}', encodeURIComponent(indexName));
2193
+ const headers = {};
2194
+ const queryParameters = {};
2195
+ const request = {
2196
+ method: 'POST',
2197
+ path: requestPath,
2198
+ queryParameters,
2199
+ headers,
2200
+ data: body,
2201
+ };
2202
+ return transporter.request(request, requestOptions);
2203
+ },
2204
+ /**
2205
+ * Create or update the Rule with the specified objectID.
2206
+ *
2207
+ * @summary Save/Update a rule.
2208
+ * @param saveRule - The saveRule object.
2209
+ * @param saveRule.indexName - The index in which to perform the request.
2210
+ * @param saveRule.objectID - Unique identifier of an object.
2211
+ * @param saveRule.rule - The rule object.
2212
+ * @param saveRule.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2213
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2214
+ */
2215
+ saveRule({ indexName, objectID, rule, forwardToReplicas }, requestOptions) {
2216
+ if (!indexName) {
2217
+ throw new Error('Parameter `indexName` is required when calling `saveRule`.');
2218
+ }
2219
+ if (!objectID) {
2220
+ throw new Error('Parameter `objectID` is required when calling `saveRule`.');
2221
+ }
2222
+ if (!rule) {
2223
+ throw new Error('Parameter `rule` is required when calling `saveRule`.');
2224
+ }
2225
+ if (!rule.objectID) {
2226
+ throw new Error('Parameter `rule.objectID` is required when calling `saveRule`.');
2227
+ }
2228
+ const requestPath = '/1/indexes/{indexName}/rules/{objectID}'
2229
+ .replace('{indexName}', encodeURIComponent(indexName))
2230
+ .replace('{objectID}', encodeURIComponent(objectID));
2231
+ const headers = {};
2232
+ const queryParameters = {};
2233
+ if (forwardToReplicas !== undefined) {
2234
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
2235
+ }
2236
+ const request = {
2237
+ method: 'PUT',
2238
+ path: requestPath,
2239
+ queryParameters,
2240
+ headers,
2241
+ data: rule,
2242
+ };
2243
+ return transporter.request(request, requestOptions);
2244
+ },
2245
+ /**
2246
+ * Create/update multiple rules objects at once.
2247
+ *
2248
+ * @summary Save a batch of rules.
2249
+ * @param saveRules - The saveRules object.
2250
+ * @param saveRules.indexName - The index in which to perform the request.
2251
+ * @param saveRules.rules - The rules object.
2252
+ * @param saveRules.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2253
+ * @param saveRules.clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept.
2254
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2255
+ */
2256
+ saveRules({ indexName, rules, forwardToReplicas, clearExistingRules, }, requestOptions) {
2257
+ if (!indexName) {
2258
+ throw new Error('Parameter `indexName` is required when calling `saveRules`.');
2259
+ }
2260
+ if (!rules) {
2261
+ throw new Error('Parameter `rules` is required when calling `saveRules`.');
2262
+ }
2263
+ const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
2264
+ const headers = {};
2265
+ const queryParameters = {};
2266
+ if (forwardToReplicas !== undefined) {
2267
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
2268
+ }
2269
+ if (clearExistingRules !== undefined) {
2270
+ queryParameters.clearExistingRules = clearExistingRules.toString();
2271
+ }
2272
+ const request = {
2273
+ method: 'POST',
2274
+ path: requestPath,
2275
+ queryParameters,
2276
+ headers,
2277
+ data: rules,
2278
+ };
2279
+ return transporter.request(request, requestOptions);
2280
+ },
2281
+ /**
2282
+ * Create a new synonym object or update the existing synonym object with the given object ID.
2283
+ *
2284
+ * @summary Save synonym.
2285
+ * @param saveSynonym - The saveSynonym object.
2286
+ * @param saveSynonym.indexName - The index in which to perform the request.
2287
+ * @param saveSynonym.objectID - Unique identifier of an object.
2288
+ * @param saveSynonym.synonymHit - The synonymHit object.
2289
+ * @param saveSynonym.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2290
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2291
+ */
2292
+ saveSynonym({ indexName, objectID, synonymHit, forwardToReplicas }, requestOptions) {
2293
+ if (!indexName) {
2294
+ throw new Error('Parameter `indexName` is required when calling `saveSynonym`.');
2295
+ }
2296
+ if (!objectID) {
2297
+ throw new Error('Parameter `objectID` is required when calling `saveSynonym`.');
2298
+ }
2299
+ if (!synonymHit) {
2300
+ throw new Error('Parameter `synonymHit` is required when calling `saveSynonym`.');
2301
+ }
2302
+ if (!synonymHit.objectID) {
2303
+ throw new Error('Parameter `synonymHit.objectID` is required when calling `saveSynonym`.');
2304
+ }
2305
+ if (!synonymHit.type) {
2306
+ throw new Error('Parameter `synonymHit.type` is required when calling `saveSynonym`.');
2307
+ }
2308
+ const requestPath = '/1/indexes/{indexName}/synonyms/{objectID}'
2309
+ .replace('{indexName}', encodeURIComponent(indexName))
2310
+ .replace('{objectID}', encodeURIComponent(objectID));
2311
+ const headers = {};
2312
+ const queryParameters = {};
2313
+ if (forwardToReplicas !== undefined) {
2314
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
2315
+ }
2316
+ const request = {
2317
+ method: 'PUT',
2318
+ path: requestPath,
2319
+ queryParameters,
2320
+ headers,
2321
+ data: synonymHit,
2322
+ };
2323
+ return transporter.request(request, requestOptions);
2324
+ },
2325
+ /**
2326
+ * Create/update multiple synonym objects at once, potentially replacing the entire list of synonyms if replaceExistingSynonyms is true.
2327
+ *
2328
+ * @summary Save a batch of synonyms.
2329
+ * @param saveSynonyms - The saveSynonyms object.
2330
+ * @param saveSynonyms.indexName - The index in which to perform the request.
2331
+ * @param saveSynonyms.synonymHit - The synonymHit object.
2332
+ * @param saveSynonyms.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2333
+ * @param saveSynonyms.replaceExistingSynonyms - Replace all synonyms of the index with the ones sent with this request.
2334
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2335
+ */
2336
+ saveSynonyms({ indexName, synonymHit, forwardToReplicas, replaceExistingSynonyms, }, requestOptions) {
2337
+ if (!indexName) {
2338
+ throw new Error('Parameter `indexName` is required when calling `saveSynonyms`.');
2339
+ }
2340
+ if (!synonymHit) {
2341
+ throw new Error('Parameter `synonymHit` is required when calling `saveSynonyms`.');
2342
+ }
2343
+ const requestPath = '/1/indexes/{indexName}/synonyms/batch'.replace('{indexName}', encodeURIComponent(indexName));
2344
+ const headers = {};
2345
+ const queryParameters = {};
2346
+ if (forwardToReplicas !== undefined) {
2347
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
2348
+ }
2349
+ if (replaceExistingSynonyms !== undefined) {
2350
+ queryParameters.replaceExistingSynonyms =
2351
+ replaceExistingSynonyms.toString();
2352
+ }
2353
+ const request = {
2354
+ method: 'POST',
2355
+ path: requestPath,
2356
+ queryParameters,
2357
+ headers,
2358
+ data: synonymHit,
2359
+ };
2360
+ return transporter.request(request, requestOptions);
2361
+ },
2362
+ /**
2363
+ * Perform a search operation targeting one or many indices.
2364
+ *
2365
+ * @summary Search multiple indices.
2366
+ * @param searchMethodParams - The `search` requests and strategy.
2367
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2368
+ */
2369
+ search(searchMethodParams, requestOptions) {
2370
+ if (searchMethodParams && Array.isArray(searchMethodParams)) {
2371
+ const newSignatureRequest = {
2372
+ requests: searchMethodParams.map(({ params, ...legacyRequest }) => {
2373
+ if (legacyRequest.type === 'facet') {
2374
+ return {
2375
+ ...legacyRequest,
2376
+ ...params,
2377
+ type: 'facet',
2378
+ };
2379
+ }
2380
+ return {
2381
+ ...legacyRequest,
2382
+ ...params,
2383
+ facet: undefined,
2384
+ maxFacetHits: undefined,
2385
+ facetQuery: undefined,
2386
+ };
2387
+ }),
2388
+ };
2389
+ // eslint-disable-next-line no-param-reassign
2390
+ searchMethodParams = newSignatureRequest;
2391
+ }
2392
+ if (!searchMethodParams) {
2393
+ throw new Error('Parameter `searchMethodParams` is required when calling `search`.');
2394
+ }
2395
+ if (!searchMethodParams.requests) {
2396
+ throw new Error('Parameter `searchMethodParams.requests` is required when calling `search`.');
2397
+ }
2398
+ const requestPath = '/1/indexes/*/queries';
2399
+ const headers = {};
2400
+ const queryParameters = {};
2401
+ const request = {
2402
+ method: 'POST',
2403
+ path: requestPath,
2404
+ queryParameters,
2405
+ headers,
2406
+ data: searchMethodParams,
2407
+ useReadTransporter: true,
2408
+ cacheable: true,
2409
+ };
2410
+ return transporter.request(request, requestOptions);
2411
+ },
2412
+ /**
2413
+ * Search the dictionary entries.
2414
+ *
2415
+ * @summary Search a dictionary entries.
2416
+ * @param searchDictionaryEntries - The searchDictionaryEntries object.
2417
+ * @param searchDictionaryEntries.dictionaryName - The dictionary to search in.
2418
+ * @param searchDictionaryEntries.searchDictionaryEntriesParams - The searchDictionaryEntriesParams object.
2419
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2420
+ */
2421
+ searchDictionaryEntries({ dictionaryName, searchDictionaryEntriesParams, }, requestOptions) {
2422
+ if (!dictionaryName) {
2423
+ throw new Error('Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.');
2424
+ }
2425
+ if (!searchDictionaryEntriesParams) {
2426
+ throw new Error('Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`.');
2427
+ }
2428
+ if (!searchDictionaryEntriesParams.query) {
2429
+ throw new Error('Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`.');
2430
+ }
2431
+ const requestPath = '/1/dictionaries/{dictionaryName}/search'.replace('{dictionaryName}', encodeURIComponent(dictionaryName));
2432
+ const headers = {};
2433
+ const queryParameters = {};
2434
+ const request = {
2435
+ method: 'POST',
2436
+ path: requestPath,
2437
+ queryParameters,
2438
+ headers,
2439
+ data: searchDictionaryEntriesParams,
2440
+ useReadTransporter: true,
2441
+ cacheable: true,
2442
+ };
2443
+ return transporter.request(request, requestOptions);
2444
+ },
2445
+ /**
2446
+ * Search for values of a given facet, optionally restricting the returned values to those contained in objects matching other search criteria.
2447
+ *
2448
+ * @summary Search for values of a given facet.
2449
+ * @param searchForFacetValues - The searchForFacetValues object.
2450
+ * @param searchForFacetValues.indexName - The index in which to perform the request.
2451
+ * @param searchForFacetValues.facetName - The facet name.
2452
+ * @param searchForFacetValues.searchForFacetValuesRequest - The searchForFacetValuesRequest object.
2453
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2454
+ */
2455
+ searchForFacetValues({ indexName, facetName, searchForFacetValuesRequest, }, requestOptions) {
2456
+ if (!indexName) {
2457
+ throw new Error('Parameter `indexName` is required when calling `searchForFacetValues`.');
2458
+ }
2459
+ if (!facetName) {
2460
+ throw new Error('Parameter `facetName` is required when calling `searchForFacetValues`.');
2461
+ }
2462
+ const requestPath = '/1/indexes/{indexName}/facets/{facetName}/query'
2463
+ .replace('{indexName}', encodeURIComponent(indexName))
2464
+ .replace('{facetName}', encodeURIComponent(facetName));
2465
+ const headers = {};
2466
+ const queryParameters = {};
2467
+ const request = {
2468
+ method: 'POST',
2469
+ path: requestPath,
2470
+ queryParameters,
2471
+ headers,
2472
+ data: searchForFacetValuesRequest ? searchForFacetValuesRequest : {},
2473
+ useReadTransporter: true,
2474
+ cacheable: true,
2475
+ };
2476
+ return transporter.request(request, requestOptions);
2477
+ },
2478
+ /**
2479
+ * Search for rules matching various criteria.
2480
+ *
2481
+ * @summary Search for rules.
2482
+ * @param searchRules - The searchRules object.
2483
+ * @param searchRules.indexName - The index in which to perform the request.
2484
+ * @param searchRules.searchRulesParams - The searchRulesParams object.
2485
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2486
+ */
2487
+ searchRules({ indexName, searchRulesParams }, requestOptions) {
2488
+ if (!indexName) {
2489
+ throw new Error('Parameter `indexName` is required when calling `searchRules`.');
2490
+ }
2491
+ const requestPath = '/1/indexes/{indexName}/rules/search'.replace('{indexName}', encodeURIComponent(indexName));
2492
+ const headers = {};
2493
+ const queryParameters = {};
2494
+ const request = {
2495
+ method: 'POST',
2496
+ path: requestPath,
2497
+ queryParameters,
2498
+ headers,
2499
+ data: searchRulesParams ? searchRulesParams : {},
2500
+ useReadTransporter: true,
2501
+ cacheable: true,
2502
+ };
2503
+ return transporter.request(request, requestOptions);
2504
+ },
2505
+ /**
2506
+ * Perform a search operation targeting one specific index.
2507
+ *
2508
+ * @summary Search in a single index.
2509
+ * @param searchSingleIndex - The searchSingleIndex object.
2510
+ * @param searchSingleIndex.indexName - The index in which to perform the request.
2511
+ * @param searchSingleIndex.searchParams - The searchParams object.
2512
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2513
+ */
2514
+ searchSingleIndex({ indexName, searchParams }, requestOptions) {
2515
+ if (!indexName) {
2516
+ throw new Error('Parameter `indexName` is required when calling `searchSingleIndex`.');
2517
+ }
2518
+ const requestPath = '/1/indexes/{indexName}/query'.replace('{indexName}', encodeURIComponent(indexName));
2519
+ const headers = {};
2520
+ const queryParameters = {};
2521
+ const request = {
2522
+ method: 'POST',
2523
+ path: requestPath,
2524
+ queryParameters,
2525
+ headers,
2526
+ data: searchParams ? searchParams : {},
2527
+ useReadTransporter: true,
2528
+ cacheable: true,
2529
+ };
2530
+ return transporter.request(request, requestOptions);
2531
+ },
2532
+ /**
2533
+ * Search or browse all synonyms, optionally filtering them by type.
2534
+ *
2535
+ * @summary Search synonyms.
2536
+ * @param searchSynonyms - The searchSynonyms object.
2537
+ * @param searchSynonyms.indexName - The index in which to perform the request.
2538
+ * @param searchSynonyms.type - Only search for specific types of synonyms.
2539
+ * @param searchSynonyms.page - Requested page (zero-based). When specified, will retrieve a specific page; the page size is implicitly set to 100. When null, will retrieve all indices (no pagination).
2540
+ * @param searchSynonyms.hitsPerPage - Maximum number of objects to retrieve.
2541
+ * @param searchSynonyms.searchSynonymsParams - The body of the the `searchSynonyms` method.
2542
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2543
+ */
2544
+ searchSynonyms({ indexName, type, page, hitsPerPage, searchSynonymsParams, }, requestOptions) {
2545
+ if (!indexName) {
2546
+ throw new Error('Parameter `indexName` is required when calling `searchSynonyms`.');
2547
+ }
2548
+ const requestPath = '/1/indexes/{indexName}/synonyms/search'.replace('{indexName}', encodeURIComponent(indexName));
2549
+ const headers = {};
2550
+ const queryParameters = {};
2551
+ if (type !== undefined) {
2552
+ queryParameters.type = type.toString();
2553
+ }
2554
+ if (page !== undefined) {
2555
+ queryParameters.page = page.toString();
2556
+ }
2557
+ if (hitsPerPage !== undefined) {
2558
+ queryParameters.hitsPerPage = hitsPerPage.toString();
2559
+ }
2560
+ const request = {
2561
+ method: 'POST',
2562
+ path: requestPath,
2563
+ queryParameters,
2564
+ headers,
2565
+ data: searchSynonymsParams ? searchSynonymsParams : {},
2566
+ useReadTransporter: true,
2567
+ cacheable: true,
2568
+ };
2569
+ return transporter.request(request, requestOptions);
2570
+ },
2571
+ /**
2572
+ * Search for userIDs. The data returned will usually be a few seconds behind real time, because userID usage may take up to a few seconds propagate to the different clusters. To keep updates moving quickly, the index of userIDs isn\'t built synchronously with the mapping. Instead, the index is built once every 12h, at the same time as the update of userID usage. For example, when you perform a modification like adding or moving a userID, the search will report an outdated value until the next rebuild of the mapping, which takes place every 12h. Upon success, the response is 200 OK and contains the following userIDs data.
2573
+ *
2574
+ * @summary Search userID.
2575
+ * @param searchUserIdsParams - The searchUserIdsParams object.
2576
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2577
+ */
2578
+ searchUserIds(searchUserIdsParams, requestOptions) {
2579
+ if (!searchUserIdsParams) {
2580
+ throw new Error('Parameter `searchUserIdsParams` is required when calling `searchUserIds`.');
2581
+ }
2582
+ if (!searchUserIdsParams.query) {
2583
+ throw new Error('Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.');
2584
+ }
2585
+ const requestPath = '/1/clusters/mapping/search';
2586
+ const headers = {};
2587
+ const queryParameters = {};
2588
+ const request = {
2589
+ method: 'POST',
2590
+ path: requestPath,
2591
+ queryParameters,
2592
+ headers,
2593
+ data: searchUserIdsParams,
2594
+ useReadTransporter: true,
2595
+ cacheable: true,
2596
+ };
2597
+ return transporter.request(request, requestOptions);
2598
+ },
2599
+ /**
2600
+ * Set dictionaries settings.
2601
+ *
2602
+ * @summary Set dictionaries settings.
2603
+ * @param dictionarySettingsParams - The dictionarySettingsParams object.
2604
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2605
+ */
2606
+ setDictionarySettings(dictionarySettingsParams, requestOptions) {
2607
+ if (!dictionarySettingsParams) {
2608
+ throw new Error('Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.');
2609
+ }
2610
+ if (!dictionarySettingsParams.disableStandardEntries) {
2611
+ throw new Error('Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`.');
2612
+ }
2613
+ const requestPath = '/1/dictionaries/*/settings';
2614
+ const headers = {};
2615
+ const queryParameters = {};
2616
+ const request = {
2617
+ method: 'PUT',
2618
+ path: requestPath,
2619
+ queryParameters,
2620
+ headers,
2621
+ data: dictionarySettingsParams,
2622
+ };
2623
+ return transporter.request(request, requestOptions);
2624
+ },
2625
+ /**
2626
+ * Update settings of an index. Only specified settings are overridden; unspecified settings are left unchanged. Specifying null for a setting resets it to its default value.
2627
+ *
2628
+ * @summary Update settings of an index.
2629
+ * @param setSettings - The setSettings object.
2630
+ * @param setSettings.indexName - The index in which to perform the request.
2631
+ * @param setSettings.indexSettings - The indexSettings object.
2632
+ * @param setSettings.forwardToReplicas - When true, changes are also propagated to replicas of the given indexName.
2633
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2634
+ */
2635
+ setSettings({ indexName, indexSettings, forwardToReplicas }, requestOptions) {
2636
+ if (!indexName) {
2637
+ throw new Error('Parameter `indexName` is required when calling `setSettings`.');
2638
+ }
2639
+ if (!indexSettings) {
2640
+ throw new Error('Parameter `indexSettings` is required when calling `setSettings`.');
2641
+ }
2642
+ const requestPath = '/1/indexes/{indexName}/settings'.replace('{indexName}', encodeURIComponent(indexName));
2643
+ const headers = {};
2644
+ const queryParameters = {};
2645
+ if (forwardToReplicas !== undefined) {
2646
+ queryParameters.forwardToReplicas = forwardToReplicas.toString();
2647
+ }
2648
+ const request = {
2649
+ method: 'PUT',
2650
+ path: requestPath,
2651
+ queryParameters,
2652
+ headers,
2653
+ data: indexSettings,
2654
+ };
2655
+ return transporter.request(request, requestOptions);
2656
+ },
2657
+ /**
2658
+ * Replace every permission of an existing API key.
2659
+ *
2660
+ * @summary Update an API key.
2661
+ * @param updateApiKey - The updateApiKey object.
2662
+ * @param updateApiKey.key - API Key string.
2663
+ * @param updateApiKey.apiKey - The apiKey object.
2664
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
2665
+ */
2666
+ updateApiKey({ key, apiKey }, requestOptions) {
2667
+ if (!key) {
2668
+ throw new Error('Parameter `key` is required when calling `updateApiKey`.');
2669
+ }
2670
+ if (!apiKey) {
2671
+ throw new Error('Parameter `apiKey` is required when calling `updateApiKey`.');
2672
+ }
2673
+ if (!apiKey.acl) {
2674
+ throw new Error('Parameter `apiKey.acl` is required when calling `updateApiKey`.');
2675
+ }
2676
+ const requestPath = '/1/keys/{key}'.replace('{key}', encodeURIComponent(key));
2677
+ const headers = {};
2678
+ const queryParameters = {};
2679
+ const request = {
2680
+ method: 'PUT',
2681
+ path: requestPath,
2682
+ queryParameters,
2683
+ headers,
2684
+ data: apiKey,
2685
+ };
2686
+ return transporter.request(request, requestOptions);
2687
+ },
2688
+ };
2687
2689
  }
2688
2690
 
2689
- // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2690
- function searchClient(appId, apiKey, options) {
2691
- if (!appId || typeof appId !== 'string') {
2692
- throw new Error('`appId` is missing.');
2693
- }
2694
- if (!apiKey || typeof apiKey !== 'string') {
2695
- throw new Error('`apiKey` is missing.');
2696
- }
2697
- return createSearchClient({
2698
- appId,
2699
- apiKey,
2700
- timeouts: {
2701
- connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
2702
- read: DEFAULT_READ_TIMEOUT_BROWSER,
2703
- write: DEFAULT_WRITE_TIMEOUT_BROWSER,
2704
- },
2705
- requester: createXhrRequester(),
2706
- algoliaAgents: [{ segment: 'Browser' }],
2707
- authMode: 'WithinQueryParameters',
2708
- responsesCache: createMemoryCache(),
2709
- requestsCache: createMemoryCache({ serializable: false }),
2710
- hostsCache: createFallbackableCache({
2711
- caches: [
2712
- createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
2713
- createMemoryCache(),
2714
- ],
2715
- }),
2716
- ...options,
2717
- });
2691
+ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
2692
+ function searchClient(appId, apiKey, options) {
2693
+ if (!appId || typeof appId !== 'string') {
2694
+ throw new Error('`appId` is missing.');
2695
+ }
2696
+ if (!apiKey || typeof apiKey !== 'string') {
2697
+ throw new Error('`apiKey` is missing.');
2698
+ }
2699
+ return createSearchClient({
2700
+ appId,
2701
+ apiKey,
2702
+ timeouts: {
2703
+ connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
2704
+ read: DEFAULT_READ_TIMEOUT_BROWSER,
2705
+ write: DEFAULT_WRITE_TIMEOUT_BROWSER,
2706
+ },
2707
+ requester: createXhrRequester(),
2708
+ algoliaAgents: [{ segment: 'Browser' }],
2709
+ authMode: 'WithinQueryParameters',
2710
+ responsesCache: createMemoryCache(),
2711
+ requestsCache: createMemoryCache({ serializable: false }),
2712
+ hostsCache: createFallbackableCache({
2713
+ caches: [
2714
+ createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }),
2715
+ createMemoryCache(),
2716
+ ],
2717
+ }),
2718
+ ...options,
2719
+ });
2718
2720
  }
2719
2721
 
2720
2722
  export { apiClientVersion, searchClient };