@algolia/client-search 5.23.4 → 5.24.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.
- package/README.md +4 -4
- package/dist/browser.d.ts +21 -2
- package/dist/builds/browser.js +1 -1
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +2 -2
- package/dist/builds/fetch.js +96 -2
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +86 -1
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +95 -2
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +1 -1
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +21 -2
- package/dist/node.d.cts +21 -2
- package/dist/node.d.ts +21 -2
- package/dist/src/searchClient.cjs +1 -1
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +1 -1
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +21 -2
- package/package.json +8 -8
package/dist/builds/node.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
// builds/node.ts
|
|
2
2
|
import { createHmac } from "node:crypto";
|
|
3
3
|
import { createHttpRequester } from "@algolia/requester-node-http";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
IndexAlreadyExistsError,
|
|
6
|
+
IndexNotFoundError,
|
|
7
|
+
IndicesInSameAppError,
|
|
8
|
+
createMemoryCache,
|
|
9
|
+
createNullCache,
|
|
10
|
+
createNullLogger,
|
|
11
|
+
serializeQueryParameters
|
|
12
|
+
} from "@algolia/client-common";
|
|
5
13
|
|
|
6
14
|
// src/searchClient.ts
|
|
7
15
|
import {
|
|
@@ -12,7 +20,7 @@ import {
|
|
|
12
20
|
getAlgoliaAgent,
|
|
13
21
|
shuffle
|
|
14
22
|
} from "@algolia/client-common";
|
|
15
|
-
var apiClientVersion = "5.
|
|
23
|
+
var apiClientVersion = "5.24.0";
|
|
16
24
|
function getDefaultHosts(appId) {
|
|
17
25
|
return [
|
|
18
26
|
{
|
|
@@ -2385,6 +2393,91 @@ function searchClient(appId, apiKey, options) {
|
|
|
2385
2393
|
createHmac("sha256", parentApiKey).update(queryParameters).digest("hex") + queryParameters
|
|
2386
2394
|
).toString("base64");
|
|
2387
2395
|
},
|
|
2396
|
+
/**
|
|
2397
|
+
* Helper: Copies the given `sourceIndexName` records, rules and synonyms to an other Algolia application for the given `destinationIndexName`.
|
|
2398
|
+
* See https://api-clients-automation.netlify.app/docs/add-new-api-client#5-helpers for implementation details.
|
|
2399
|
+
*
|
|
2400
|
+
* @summary Helper: Copies the given `sourceIndexName` records, rules and synonyms to an other Algolia application for the given `destinationIndexName`.
|
|
2401
|
+
* @param accountCopyIndex - The `accountCopyIndex` object.
|
|
2402
|
+
* @param accountCopyIndex.sourceIndexName - The name of the index to copy.
|
|
2403
|
+
* @param accountCopyIndex.destinationAppID - The application ID to write the index to.
|
|
2404
|
+
* @param accountCopyIndex.destinationApiKey - The API Key of the `destinationAppID` to write the index to, must have write ACLs.
|
|
2405
|
+
* @param accountCopyIndex.destinationIndexName - The name of the index to write the copied index to.
|
|
2406
|
+
* @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.
|
|
2407
|
+
*/
|
|
2408
|
+
async accountCopyIndex({ sourceIndexName, destinationAppID, destinationApiKey, destinationIndexName }, requestOptions) {
|
|
2409
|
+
const responses = [];
|
|
2410
|
+
if (this.appId === destinationAppID) {
|
|
2411
|
+
throw new IndicesInSameAppError();
|
|
2412
|
+
}
|
|
2413
|
+
if (!await this.indexExists({ indexName: sourceIndexName })) {
|
|
2414
|
+
throw new IndexNotFoundError(sourceIndexName);
|
|
2415
|
+
}
|
|
2416
|
+
const destinationClient = createSearchClient({
|
|
2417
|
+
appId: destinationAppID,
|
|
2418
|
+
apiKey: destinationApiKey,
|
|
2419
|
+
timeouts: {
|
|
2420
|
+
connect: 2e3,
|
|
2421
|
+
read: 5e3,
|
|
2422
|
+
write: 3e4
|
|
2423
|
+
},
|
|
2424
|
+
logger: createNullLogger(),
|
|
2425
|
+
requester: createHttpRequester(),
|
|
2426
|
+
algoliaAgents: [{ segment: "accountCopyIndex", version: process.versions.node }],
|
|
2427
|
+
responsesCache: createNullCache(),
|
|
2428
|
+
requestsCache: createNullCache(),
|
|
2429
|
+
hostsCache: createMemoryCache(),
|
|
2430
|
+
...options
|
|
2431
|
+
});
|
|
2432
|
+
if (await destinationClient.indexExists({ indexName: destinationIndexName })) {
|
|
2433
|
+
throw new IndexAlreadyExistsError(destinationIndexName);
|
|
2434
|
+
}
|
|
2435
|
+
responses.push(
|
|
2436
|
+
await destinationClient.setSettings(
|
|
2437
|
+
{
|
|
2438
|
+
indexName: destinationIndexName,
|
|
2439
|
+
indexSettings: await this.getSettings({ indexName: sourceIndexName })
|
|
2440
|
+
},
|
|
2441
|
+
requestOptions
|
|
2442
|
+
)
|
|
2443
|
+
);
|
|
2444
|
+
await this.browseRules({
|
|
2445
|
+
indexName: sourceIndexName,
|
|
2446
|
+
async aggregator(response) {
|
|
2447
|
+
responses.push(
|
|
2448
|
+
await destinationClient.saveRules(
|
|
2449
|
+
{ indexName: destinationIndexName, rules: response.hits },
|
|
2450
|
+
requestOptions
|
|
2451
|
+
)
|
|
2452
|
+
);
|
|
2453
|
+
}
|
|
2454
|
+
});
|
|
2455
|
+
await this.browseSynonyms({
|
|
2456
|
+
indexName: sourceIndexName,
|
|
2457
|
+
async aggregator(response) {
|
|
2458
|
+
responses.push(
|
|
2459
|
+
await destinationClient.saveSynonyms(
|
|
2460
|
+
{ indexName: destinationIndexName, synonymHit: response.hits },
|
|
2461
|
+
requestOptions
|
|
2462
|
+
)
|
|
2463
|
+
);
|
|
2464
|
+
}
|
|
2465
|
+
});
|
|
2466
|
+
await this.browseObjects({
|
|
2467
|
+
indexName: sourceIndexName,
|
|
2468
|
+
async aggregator(response) {
|
|
2469
|
+
responses.push(
|
|
2470
|
+
...await destinationClient.saveObjects(
|
|
2471
|
+
{ indexName: destinationIndexName, objects: response.hits },
|
|
2472
|
+
requestOptions
|
|
2473
|
+
)
|
|
2474
|
+
);
|
|
2475
|
+
}
|
|
2476
|
+
});
|
|
2477
|
+
for (const response of responses) {
|
|
2478
|
+
await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID });
|
|
2479
|
+
}
|
|
2480
|
+
},
|
|
2388
2481
|
/**
|
|
2389
2482
|
* Helper: Retrieves the remaining validity of the previous generated `securedApiKey`, the `ValidUntil` parameter must have been provided.
|
|
2390
2483
|
*
|