@algolia/client-search 5.56.0 → 5.57.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 +4 -2
- package/dist/builds/browser.js +49 -21
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +5 -5
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +7 -7
- package/dist/builds/fetch.js +102 -60
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +97 -58
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +102 -60
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +49 -21
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +4 -2
- package/dist/node.d.cts +4 -2
- package/dist/node.d.ts +4 -2
- package/dist/src/searchClient.cjs +45 -20
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +53 -23
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +4 -2
- package/package.json +9 -9
package/dist/builds/worker.js
CHANGED
|
@@ -10,10 +10,12 @@ import {
|
|
|
10
10
|
createIterablePromise,
|
|
11
11
|
createTransporter,
|
|
12
12
|
getAlgoliaAgent,
|
|
13
|
+
logWarning,
|
|
13
14
|
shuffle,
|
|
14
|
-
validateRequired
|
|
15
|
+
validateRequired,
|
|
16
|
+
withRequestId
|
|
15
17
|
} from "@algolia/client-common";
|
|
16
|
-
var apiClientVersion = "5.
|
|
18
|
+
var apiClientVersion = "5.57.0";
|
|
17
19
|
function getDefaultHosts(appId) {
|
|
18
20
|
return [
|
|
19
21
|
{
|
|
@@ -133,6 +135,7 @@ function createSearchClient({
|
|
|
133
135
|
maxRetries = 100,
|
|
134
136
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
135
137
|
}, requestOptions) {
|
|
138
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
136
139
|
let retryCount = 0;
|
|
137
140
|
return createIterablePromise({
|
|
138
141
|
func: () => this.getTask({ indexName, taskID }, requestOptions),
|
|
@@ -160,6 +163,7 @@ function createSearchClient({
|
|
|
160
163
|
maxRetries = 100,
|
|
161
164
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
162
165
|
}, requestOptions) {
|
|
166
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
163
167
|
let retryCount = 0;
|
|
164
168
|
return createIterablePromise({
|
|
165
169
|
func: () => this.getAppTask({ taskID }, requestOptions),
|
|
@@ -191,6 +195,7 @@ function createSearchClient({
|
|
|
191
195
|
maxRetries = 100,
|
|
192
196
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
193
197
|
}, requestOptions) {
|
|
198
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
194
199
|
let retryCount = 0;
|
|
195
200
|
const baseIteratorOptions = {
|
|
196
201
|
aggregator: () => retryCount += 1,
|
|
@@ -246,6 +251,7 @@ function createSearchClient({
|
|
|
246
251
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
|
|
247
252
|
*/
|
|
248
253
|
browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
|
|
254
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
249
255
|
return createIterablePromise({
|
|
250
256
|
func: (previousResponse) => {
|
|
251
257
|
return this.browse(
|
|
@@ -276,6 +282,7 @@ function createSearchClient({
|
|
|
276
282
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
277
283
|
*/
|
|
278
284
|
browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
|
|
285
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
279
286
|
const params = {
|
|
280
287
|
...searchRulesParams,
|
|
281
288
|
hitsPerPage: (searchRulesParams == null ? void 0 : searchRulesParams.hitsPerPage) || 1e3
|
|
@@ -313,6 +320,7 @@ function createSearchClient({
|
|
|
313
320
|
searchSynonymsParams,
|
|
314
321
|
...browseSynonymsOptions
|
|
315
322
|
}, requestOptions) {
|
|
323
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
316
324
|
const params = {
|
|
317
325
|
...searchSynonymsParams,
|
|
318
326
|
page: (searchSynonymsParams == null ? void 0 : searchSynonymsParams.page) || 0,
|
|
@@ -358,6 +366,7 @@ function createSearchClient({
|
|
|
358
366
|
batchSize = 1e3,
|
|
359
367
|
maxRetries = 100
|
|
360
368
|
}, requestOptions) {
|
|
369
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
361
370
|
let requests = [];
|
|
362
371
|
const responses = [];
|
|
363
372
|
const objectEntries = objects.entries();
|
|
@@ -370,7 +379,7 @@ function createSearchClient({
|
|
|
370
379
|
}
|
|
371
380
|
if (waitForTasks) {
|
|
372
381
|
for (const resp of responses) {
|
|
373
|
-
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
|
|
382
|
+
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries }, requestOptions);
|
|
374
383
|
}
|
|
375
384
|
}
|
|
376
385
|
return responses;
|
|
@@ -448,6 +457,8 @@ function createSearchClient({
|
|
|
448
457
|
* Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
|
|
449
458
|
* See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
|
|
450
459
|
*
|
|
460
|
+
* Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
|
|
461
|
+
*
|
|
451
462
|
* @summary Helper: Replaces all objects (records) in the given `index_name` with the given `objects`. A temporary index is created during this process in order to backup your data.
|
|
452
463
|
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
453
464
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
@@ -464,6 +475,13 @@ function createSearchClient({
|
|
|
464
475
|
scopes,
|
|
465
476
|
maxRetries = DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES
|
|
466
477
|
}, requestOptions) {
|
|
478
|
+
requestOptions = withRequestId(transporter, requestOptions);
|
|
479
|
+
if (objects.length === 0) {
|
|
480
|
+
logWarning(
|
|
481
|
+
transporter.logger,
|
|
482
|
+
`replaceAllObjects was called with an empty list of objects, which will delete all records currently in the "${indexName}" index.`
|
|
483
|
+
);
|
|
484
|
+
}
|
|
467
485
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
468
486
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
469
487
|
if (scopes === void 0) {
|
|
@@ -485,11 +503,14 @@ function createSearchClient({
|
|
|
485
503
|
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
|
|
486
504
|
requestOptions
|
|
487
505
|
);
|
|
488
|
-
await this.waitForTask(
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
506
|
+
await this.waitForTask(
|
|
507
|
+
{
|
|
508
|
+
indexName: tmpIndexName,
|
|
509
|
+
taskID: copyOperationResponse.taskID,
|
|
510
|
+
maxRetries
|
|
511
|
+
},
|
|
512
|
+
requestOptions
|
|
513
|
+
);
|
|
493
514
|
copyOperationResponse = await this.operationIndex(
|
|
494
515
|
{
|
|
495
516
|
indexName,
|
|
@@ -501,11 +522,14 @@ function createSearchClient({
|
|
|
501
522
|
},
|
|
502
523
|
requestOptions
|
|
503
524
|
);
|
|
504
|
-
await this.waitForTask(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
525
|
+
await this.waitForTask(
|
|
526
|
+
{
|
|
527
|
+
indexName: tmpIndexName,
|
|
528
|
+
taskID: copyOperationResponse.taskID,
|
|
529
|
+
maxRetries
|
|
530
|
+
},
|
|
531
|
+
requestOptions
|
|
532
|
+
);
|
|
509
533
|
const moveOperationResponse = await this.operationIndex(
|
|
510
534
|
{
|
|
511
535
|
indexName: tmpIndexName,
|
|
@@ -513,20 +537,23 @@ function createSearchClient({
|
|
|
513
537
|
},
|
|
514
538
|
requestOptions
|
|
515
539
|
);
|
|
516
|
-
await this.waitForTask(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
540
|
+
await this.waitForTask(
|
|
541
|
+
{
|
|
542
|
+
indexName: tmpIndexName,
|
|
543
|
+
taskID: moveOperationResponse.taskID,
|
|
544
|
+
maxRetries
|
|
545
|
+
},
|
|
546
|
+
requestOptions
|
|
547
|
+
);
|
|
521
548
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
522
549
|
} catch (error) {
|
|
523
|
-
await this.deleteIndex({ indexName: tmpIndexName });
|
|
550
|
+
await this.deleteIndex({ indexName: tmpIndexName }, requestOptions);
|
|
524
551
|
throw error;
|
|
525
552
|
}
|
|
526
553
|
},
|
|
527
|
-
async indexExists({ indexName }) {
|
|
554
|
+
async indexExists({ indexName }, requestOptions) {
|
|
528
555
|
try {
|
|
529
|
-
await this.getSettings({ indexName });
|
|
556
|
+
await this.getSettings({ indexName }, requestOptions);
|
|
530
557
|
} catch (error) {
|
|
531
558
|
if (error instanceof ApiError && error.status === 404) {
|
|
532
559
|
return false;
|
|
@@ -4011,6 +4038,7 @@ function searchClient(appId, apiKey, options) {
|
|
|
4011
4038
|
logger: createNullLogger(),
|
|
4012
4039
|
requester: createFetchRequester(),
|
|
4013
4040
|
algoliaAgents: [{ segment: "Worker" }],
|
|
4041
|
+
requestIdChannel: "queryParameters",
|
|
4014
4042
|
responsesCache: createNullCache(),
|
|
4015
4043
|
requestsCache: createNullCache(),
|
|
4016
4044
|
hostsCache: createMemoryCache(),
|