@algolia/client-search 5.23.4 → 5.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,7 @@ var import_client_common2 = require("@algolia/client-common");
30
30
 
31
31
  // src/searchClient.ts
32
32
  var import_client_common = require("@algolia/client-common");
33
- var apiClientVersion = "5.23.4";
33
+ var apiClientVersion = "5.25.0";
34
34
  function getDefaultHosts(appId) {
35
35
  return [
36
36
  {
@@ -1058,7 +1058,7 @@ function createSearchClient({
1058
1058
  return transporter.request(request, requestOptions);
1059
1059
  },
1060
1060
  /**
1061
- * Deletes a record by its object ID. To delete more than one record, use the [`batch` operation](#tag/Records/operation/batch). To delete records matching a query, use the [`deleteByQuery` operation](#tag/Records/operation/deleteBy).
1061
+ * Deletes a record by its object ID. To delete more than one record, use the [`batch` operation](#tag/Records/operation/batch). To delete records matching a query, use the [`deleteBy` operation](#tag/Records/operation/deleteBy).
1062
1062
  *
1063
1063
  * Required API Key ACLs:
1064
1064
  * - deleteObject
@@ -2403,6 +2403,91 @@ function searchClient(appId, apiKey, options) {
2403
2403
  (0, import_node_crypto.createHmac)("sha256", parentApiKey).update(queryParameters).digest("hex") + queryParameters
2404
2404
  ).toString("base64");
2405
2405
  },
2406
+ /**
2407
+ * Helper: Copies the given `sourceIndexName` records, rules and synonyms to an other Algolia application for the given `destinationIndexName`.
2408
+ * See https://api-clients-automation.netlify.app/docs/add-new-api-client#5-helpers for implementation details.
2409
+ *
2410
+ * @summary Helper: Copies the given `sourceIndexName` records, rules and synonyms to an other Algolia application for the given `destinationIndexName`.
2411
+ * @param accountCopyIndex - The `accountCopyIndex` object.
2412
+ * @param accountCopyIndex.sourceIndexName - The name of the index to copy.
2413
+ * @param accountCopyIndex.destinationAppID - The application ID to write the index to.
2414
+ * @param accountCopyIndex.destinationApiKey - The API Key of the `destinationAppID` to write the index to, must have write ACLs.
2415
+ * @param accountCopyIndex.destinationIndexName - The name of the index to write the copied index to.
2416
+ * @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `setSettings`, `saveRules`, `saveSynonyms` and `saveObjects` method and merged with the transporter requestOptions.
2417
+ */
2418
+ async accountCopyIndex({ sourceIndexName, destinationAppID, destinationApiKey, destinationIndexName }, requestOptions) {
2419
+ const responses = [];
2420
+ if (this.appId === destinationAppID) {
2421
+ throw new import_client_common2.IndicesInSameAppError();
2422
+ }
2423
+ if (!await this.indexExists({ indexName: sourceIndexName })) {
2424
+ throw new import_client_common2.IndexNotFoundError(sourceIndexName);
2425
+ }
2426
+ const destinationClient = createSearchClient({
2427
+ appId: destinationAppID,
2428
+ apiKey: destinationApiKey,
2429
+ timeouts: {
2430
+ connect: 2e3,
2431
+ read: 5e3,
2432
+ write: 3e4
2433
+ },
2434
+ logger: (0, import_client_common2.createNullLogger)(),
2435
+ requester: (0, import_requester_node_http.createHttpRequester)(),
2436
+ algoliaAgents: [{ segment: "accountCopyIndex", version: process.versions.node }],
2437
+ responsesCache: (0, import_client_common2.createNullCache)(),
2438
+ requestsCache: (0, import_client_common2.createNullCache)(),
2439
+ hostsCache: (0, import_client_common2.createMemoryCache)(),
2440
+ ...options
2441
+ });
2442
+ if (await destinationClient.indexExists({ indexName: destinationIndexName })) {
2443
+ throw new import_client_common2.IndexAlreadyExistsError(destinationIndexName);
2444
+ }
2445
+ responses.push(
2446
+ await destinationClient.setSettings(
2447
+ {
2448
+ indexName: destinationIndexName,
2449
+ indexSettings: await this.getSettings({ indexName: sourceIndexName })
2450
+ },
2451
+ requestOptions
2452
+ )
2453
+ );
2454
+ await this.browseRules({
2455
+ indexName: sourceIndexName,
2456
+ async aggregator(response) {
2457
+ responses.push(
2458
+ await destinationClient.saveRules(
2459
+ { indexName: destinationIndexName, rules: response.hits },
2460
+ requestOptions
2461
+ )
2462
+ );
2463
+ }
2464
+ });
2465
+ await this.browseSynonyms({
2466
+ indexName: sourceIndexName,
2467
+ async aggregator(response) {
2468
+ responses.push(
2469
+ await destinationClient.saveSynonyms(
2470
+ { indexName: destinationIndexName, synonymHit: response.hits },
2471
+ requestOptions
2472
+ )
2473
+ );
2474
+ }
2475
+ });
2476
+ await this.browseObjects({
2477
+ indexName: sourceIndexName,
2478
+ async aggregator(response) {
2479
+ responses.push(
2480
+ ...await destinationClient.saveObjects(
2481
+ { indexName: destinationIndexName, objects: response.hits },
2482
+ requestOptions
2483
+ )
2484
+ );
2485
+ }
2486
+ });
2487
+ for (const response of responses) {
2488
+ await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID });
2489
+ }
2490
+ },
2406
2491
  /**
2407
2492
  * Helper: Retrieves the remaining validity of the previous generated `securedApiKey`, the `ValidUntil` parameter must have been provided.
2408
2493
  *