|
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 | 3 | import type { ClientOptions, RequestOptions } from '@algolia/client-common'; |
4 | | -import { DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES } from '@algolia/client-common'; |
| 4 | +import { DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES, logWarning } from '@algolia/client-common'; |
5 | 5 |
|
6 | 6 | import type { AbtestingV3Client } from '@algolia/abtesting'; |
7 | 7 | import { abtestingV3Client } from '@algolia/abtesting'; |
@@ -97,6 +97,8 @@ export type Algoliasearch = SearchClient & { |
97 | 97 | /** |
98 | 98 | * Helper: Similar to the `replaceAllObjects` method but requires a Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) to be created first, in order to transform records before indexing them to Algolia. The `region` must have been passed to the client instantiation method. |
99 | 99 | * |
| 100 | + * Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records. |
| 101 | + * |
100 | 102 | * @summary Helper: Replaces all objects (records) in the given `index_name` by leveraging the Transformation pipeline setup in the Push connector (https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/connectors/push/) with the given `objects`. A temporary index is created during this process in order to backup your data. |
101 | 103 | * @param replaceAllObjects - The `replaceAllObjects` object. |
102 | 104 | * @param replaceAllObjects.indexName - The `indexName` to replace `objects` in. |
@@ -220,6 +222,13 @@ export function algoliasearch( |
220 | 222 | ); |
221 | 223 | } |
222 | 224 |
|
| 225 | + if (objects.length === 0) { |
| 226 | + logWarning( |
| 227 | + client.transporter.logger, |
| 228 | + `replaceAllObjectsWithTransformation was called with an empty list of objects, which will delete all records currently in the "${indexName}" index.`, |
| 229 | + ); |
| 230 | + } |
| 231 | + |
223 | 232 | const randomSuffix = Math.floor(Math.random() * 1000000) + 100000; |
224 | 233 | const tmpIndexName = `${indexName}_tmp_${randomSuffix}`; |
225 | 234 |
|
|
0 commit comments