|
1 | 1 | // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
2 | 2 |
|
3 |
| -import { createAuth, createTransporter, getAlgoliaAgent, shuffle, createIterablePromise } from '@algolia/client-common'; |
| 3 | +import { |
| 4 | + createAuth, |
| 5 | + createTransporter, |
| 6 | + getAlgoliaAgent, |
| 7 | + shuffle, |
| 8 | + ApiError, |
| 9 | + createIterablePromise, |
| 10 | +} from '@algolia/client-common'; |
4 | 11 | import type {
|
5 | 12 | CreateClientOptions,
|
6 | 13 | Headers,
|
7 | 14 | Host,
|
8 | 15 | QueryParameters,
|
9 | 16 | Request,
|
10 | 17 | RequestOptions,
|
11 |
| - ApiError, |
12 | 18 | IterableOptions,
|
13 | 19 | } from '@algolia/client-common';
|
14 | 20 |
|
@@ -643,6 +649,19 @@ export function createSearchClient({
|
643 | 649 | return { copyOperationResponse, batchResponses, moveOperationResponse };
|
644 | 650 | },
|
645 | 651 |
|
| 652 | + async indexExists({ indexName }: GetSettingsProps): Promise<boolean> { |
| 653 | + try { |
| 654 | + await this.getSettings({ indexName }); |
| 655 | + } catch (error) { |
| 656 | + if (error instanceof ApiError && error.status === 404) { |
| 657 | + return false; |
| 658 | + } |
| 659 | + throw error; |
| 660 | + } |
| 661 | + |
| 662 | + return true; |
| 663 | + }, |
| 664 | + |
646 | 665 | /**
|
647 | 666 | * Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
|
648 | 667 | * Disclaimer: We don't assert that the parameters you pass to this method only contains `hits` requests to prevent impacting search performances, this helper is purely for typing purposes.
|
@@ -1045,7 +1064,6 @@ export function createSearchClient({
|
1045 | 1064 | const requestPath = '/1/indexes/{indexName}/rules/clear'.replace('{indexName}', encodeURIComponent(indexName));
|
1046 | 1065 | const headers: Headers = {};
|
1047 | 1066 | const queryParameters: QueryParameters = {};
|
1048 |
| - |
1049 | 1067 | if (forwardToReplicas !== undefined) {
|
1050 | 1068 | queryParameters.forwardToReplicas = forwardToReplicas.toString();
|
1051 | 1069 | }
|
@@ -1082,7 +1100,6 @@ export function createSearchClient({
|
1082 | 1100 | const requestPath = '/1/indexes/{indexName}/synonyms/clear'.replace('{indexName}', encodeURIComponent(indexName));
|
1083 | 1101 | const headers: Headers = {};
|
1084 | 1102 | const queryParameters: QueryParameters = {};
|
1085 |
| - |
1086 | 1103 | if (forwardToReplicas !== undefined) {
|
1087 | 1104 | queryParameters.forwardToReplicas = forwardToReplicas.toString();
|
1088 | 1105 | }
|
@@ -1454,6 +1471,7 @@ export function createSearchClient({
|
1454 | 1471 | .replace('{objectID}', encodeURIComponent(objectID));
|
1455 | 1472 | const headers: Headers = {};
|
1456 | 1473 | const queryParameters: QueryParameters = {};
|
| 1474 | + |
1457 | 1475 | if (forwardToReplicas !== undefined) {
|
1458 | 1476 | queryParameters.forwardToReplicas = forwardToReplicas.toString();
|
1459 | 1477 | }
|
@@ -1595,7 +1613,6 @@ export function createSearchClient({
|
1595 | 1613 | if (length !== undefined) {
|
1596 | 1614 | queryParameters.length = length.toString();
|
1597 | 1615 | }
|
1598 |
| - |
1599 | 1616 | if (indexName !== undefined) {
|
1600 | 1617 | queryParameters.indexName = indexName.toString();
|
1601 | 1618 | }
|
@@ -1642,6 +1659,7 @@ export function createSearchClient({
|
1642 | 1659 | .replace('{objectID}', encodeURIComponent(objectID));
|
1643 | 1660 | const headers: Headers = {};
|
1644 | 1661 | const queryParameters: QueryParameters = {};
|
| 1662 | + |
1645 | 1663 | if (attributesToRetrieve !== undefined) {
|
1646 | 1664 | queryParameters.attributesToRetrieve = attributesToRetrieve.toString();
|
1647 | 1665 | }
|
@@ -2381,10 +2399,10 @@ export function createSearchClient({
|
2381 | 2399 | const requestPath = '/1/indexes/{indexName}/rules/batch'.replace('{indexName}', encodeURIComponent(indexName));
|
2382 | 2400 | const headers: Headers = {};
|
2383 | 2401 | const queryParameters: QueryParameters = {};
|
| 2402 | + |
2384 | 2403 | if (forwardToReplicas !== undefined) {
|
2385 | 2404 | queryParameters.forwardToReplicas = forwardToReplicas.toString();
|
2386 | 2405 | }
|
2387 |
| - |
2388 | 2406 | if (clearExistingRules !== undefined) {
|
2389 | 2407 | queryParameters.clearExistingRules = clearExistingRules.toString();
|
2390 | 2408 | }
|
@@ -2487,7 +2505,6 @@ export function createSearchClient({
|
2487 | 2505 | if (forwardToReplicas !== undefined) {
|
2488 | 2506 | queryParameters.forwardToReplicas = forwardToReplicas.toString();
|
2489 | 2507 | }
|
2490 |
| - |
2491 | 2508 | if (replaceExistingSynonyms !== undefined) {
|
2492 | 2509 | queryParameters.replaceExistingSynonyms = replaceExistingSynonyms.toString();
|
2493 | 2510 | }
|
|
0 commit comments