@algolia/client-search 5.56.0 → 5.59.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 +8 -2
- package/dist/builds/browser.js +50 -22
- 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 +103 -61
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +98 -59
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +103 -61
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +50 -22
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +8 -2
- package/dist/node.d.cts +8 -2
- package/dist/node.d.ts +8 -2
- package/dist/src/searchClient.cjs +46 -21
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +49 -22
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +8 -2
- package/package.json +9 -9
package/dist/fetch.d.ts
CHANGED
|
@@ -748,6 +748,10 @@ type LogQuery = {
|
|
|
748
748
|
};
|
|
749
749
|
|
|
750
750
|
type Log = {
|
|
751
|
+
/**
|
|
752
|
+
* Correlation ID of the logged API request, also returned in that request\'s `Correlation-ID` response header.
|
|
753
|
+
*/
|
|
754
|
+
cid?: string | undefined;
|
|
751
755
|
/**
|
|
752
756
|
* Date and time of the API request, in RFC 3339 format.
|
|
753
757
|
*/
|
|
@@ -3242,7 +3246,7 @@ type AccountCopyIndexOptions = ChunkedHelperOptions & {
|
|
|
3242
3246
|
batchSize?: number | undefined;
|
|
3243
3247
|
};
|
|
3244
3248
|
|
|
3245
|
-
declare const apiClientVersion = "5.
|
|
3249
|
+
declare const apiClientVersion = "5.59.0";
|
|
3246
3250
|
declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
|
|
3247
3251
|
transporter: _algolia_client_common.TransporterWithHttpInfo;
|
|
3248
3252
|
/**
|
|
@@ -3407,6 +3411,8 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
3407
3411
|
* 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.
|
|
3408
3412
|
* See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
|
|
3409
3413
|
*
|
|
3414
|
+
* Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
|
|
3415
|
+
*
|
|
3410
3416
|
* @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.
|
|
3411
3417
|
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
3412
3418
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
@@ -3417,7 +3423,7 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
3417
3423
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
|
|
3418
3424
|
*/
|
|
3419
3425
|
replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries, }: ReplaceAllObjectsOptions, requestOptions?: RequestOptions | undefined): Promise<ReplaceAllObjectsResponse>;
|
|
3420
|
-
indexExists({ indexName }: GetSettingsProps): Promise<boolean>;
|
|
3426
|
+
indexExists({ indexName }: GetSettingsProps, requestOptions?: RequestOptions | undefined): Promise<boolean>;
|
|
3421
3427
|
/**
|
|
3422
3428
|
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
|
|
3423
3429
|
* 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.
|
package/dist/node.d.cts
CHANGED
|
@@ -748,6 +748,10 @@ type LogQuery = {
|
|
|
748
748
|
};
|
|
749
749
|
|
|
750
750
|
type Log = {
|
|
751
|
+
/**
|
|
752
|
+
* Correlation ID of the logged API request, also returned in that request\'s `Correlation-ID` response header.
|
|
753
|
+
*/
|
|
754
|
+
cid?: string | undefined;
|
|
751
755
|
/**
|
|
752
756
|
* Date and time of the API request, in RFC 3339 format.
|
|
753
757
|
*/
|
|
@@ -3242,7 +3246,7 @@ type AccountCopyIndexOptions = ChunkedHelperOptions & {
|
|
|
3242
3246
|
batchSize?: number | undefined;
|
|
3243
3247
|
};
|
|
3244
3248
|
|
|
3245
|
-
declare const apiClientVersion = "5.
|
|
3249
|
+
declare const apiClientVersion = "5.59.0";
|
|
3246
3250
|
declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
|
|
3247
3251
|
transporter: _algolia_client_common.TransporterWithHttpInfo;
|
|
3248
3252
|
/**
|
|
@@ -3407,6 +3411,8 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
3407
3411
|
* 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.
|
|
3408
3412
|
* See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
|
|
3409
3413
|
*
|
|
3414
|
+
* Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
|
|
3415
|
+
*
|
|
3410
3416
|
* @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.
|
|
3411
3417
|
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
3412
3418
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
@@ -3417,7 +3423,7 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
3417
3423
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
|
|
3418
3424
|
*/
|
|
3419
3425
|
replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries, }: ReplaceAllObjectsOptions, requestOptions?: RequestOptions | undefined): Promise<ReplaceAllObjectsResponse>;
|
|
3420
|
-
indexExists({ indexName }: GetSettingsProps): Promise<boolean>;
|
|
3426
|
+
indexExists({ indexName }: GetSettingsProps, requestOptions?: RequestOptions | undefined): Promise<boolean>;
|
|
3421
3427
|
/**
|
|
3422
3428
|
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
|
|
3423
3429
|
* 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.
|
package/dist/node.d.ts
CHANGED
|
@@ -748,6 +748,10 @@ type LogQuery = {
|
|
|
748
748
|
};
|
|
749
749
|
|
|
750
750
|
type Log = {
|
|
751
|
+
/**
|
|
752
|
+
* Correlation ID of the logged API request, also returned in that request\'s `Correlation-ID` response header.
|
|
753
|
+
*/
|
|
754
|
+
cid?: string | undefined;
|
|
751
755
|
/**
|
|
752
756
|
* Date and time of the API request, in RFC 3339 format.
|
|
753
757
|
*/
|
|
@@ -3242,7 +3246,7 @@ type AccountCopyIndexOptions = ChunkedHelperOptions & {
|
|
|
3242
3246
|
batchSize?: number | undefined;
|
|
3243
3247
|
};
|
|
3244
3248
|
|
|
3245
|
-
declare const apiClientVersion = "5.
|
|
3249
|
+
declare const apiClientVersion = "5.59.0";
|
|
3246
3250
|
declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
|
|
3247
3251
|
transporter: _algolia_client_common.TransporterWithHttpInfo;
|
|
3248
3252
|
/**
|
|
@@ -3407,6 +3411,8 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
3407
3411
|
* 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.
|
|
3408
3412
|
* See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
|
|
3409
3413
|
*
|
|
3414
|
+
* Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
|
|
3415
|
+
*
|
|
3410
3416
|
* @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.
|
|
3411
3417
|
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
3412
3418
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
@@ -3417,7 +3423,7 @@ declare function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption,
|
|
|
3417
3423
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
|
|
3418
3424
|
*/
|
|
3419
3425
|
replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries, }: ReplaceAllObjectsOptions, requestOptions?: RequestOptions | undefined): Promise<ReplaceAllObjectsResponse>;
|
|
3420
|
-
indexExists({ indexName }: GetSettingsProps): Promise<boolean>;
|
|
3426
|
+
indexExists({ indexName }: GetSettingsProps, requestOptions?: RequestOptions | undefined): Promise<boolean>;
|
|
3421
3427
|
/**
|
|
3422
3428
|
* Helper: calls the `search` method but with certainty that we will only request Algolia records (hits) and not facets.
|
|
3423
3429
|
* 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.
|
|
@@ -25,7 +25,7 @@ __export(searchClient_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(searchClient_exports);
|
|
27
27
|
var import_client_common = require("@algolia/client-common");
|
|
28
|
-
var apiClientVersion = "5.
|
|
28
|
+
var apiClientVersion = "5.59.0";
|
|
29
29
|
function getDefaultHosts(appId) {
|
|
30
30
|
return [
|
|
31
31
|
{
|
|
@@ -145,6 +145,7 @@ function createSearchClient({
|
|
|
145
145
|
maxRetries = 100,
|
|
146
146
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
147
147
|
}, requestOptions) {
|
|
148
|
+
requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
|
|
148
149
|
let retryCount = 0;
|
|
149
150
|
return (0, import_client_common.createIterablePromise)({
|
|
150
151
|
func: () => this.getTask({ indexName, taskID }, requestOptions),
|
|
@@ -172,6 +173,7 @@ function createSearchClient({
|
|
|
172
173
|
maxRetries = 100,
|
|
173
174
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
174
175
|
}, requestOptions) {
|
|
176
|
+
requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
|
|
175
177
|
let retryCount = 0;
|
|
176
178
|
return (0, import_client_common.createIterablePromise)({
|
|
177
179
|
func: () => this.getAppTask({ taskID }, requestOptions),
|
|
@@ -203,6 +205,7 @@ function createSearchClient({
|
|
|
203
205
|
maxRetries = 100,
|
|
204
206
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
205
207
|
}, requestOptions) {
|
|
208
|
+
requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
|
|
206
209
|
let retryCount = 0;
|
|
207
210
|
const baseIteratorOptions = {
|
|
208
211
|
aggregator: () => retryCount += 1,
|
|
@@ -258,6 +261,7 @@ function createSearchClient({
|
|
|
258
261
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
|
|
259
262
|
*/
|
|
260
263
|
browseObjects({ indexName, browseParams, ...browseObjectsOptions }, requestOptions) {
|
|
264
|
+
requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
|
|
261
265
|
return (0, import_client_common.createIterablePromise)({
|
|
262
266
|
func: (previousResponse) => {
|
|
263
267
|
return this.browse(
|
|
@@ -288,6 +292,7 @@ function createSearchClient({
|
|
|
288
292
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
289
293
|
*/
|
|
290
294
|
browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
|
|
295
|
+
requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
|
|
291
296
|
const params = {
|
|
292
297
|
...searchRulesParams,
|
|
293
298
|
hitsPerPage: (searchRulesParams == null ? void 0 : searchRulesParams.hitsPerPage) || 1e3
|
|
@@ -325,13 +330,14 @@ function createSearchClient({
|
|
|
325
330
|
searchSynonymsParams,
|
|
326
331
|
...browseSynonymsOptions
|
|
327
332
|
}, requestOptions) {
|
|
333
|
+
requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
|
|
328
334
|
const params = {
|
|
329
335
|
...searchSynonymsParams,
|
|
330
336
|
page: (searchSynonymsParams == null ? void 0 : searchSynonymsParams.page) || 0,
|
|
331
337
|
hitsPerPage: 1e3
|
|
332
338
|
};
|
|
333
339
|
return (0, import_client_common.createIterablePromise)({
|
|
334
|
-
func: (
|
|
340
|
+
func: (__) => {
|
|
335
341
|
const resp = this.searchSynonyms(
|
|
336
342
|
{
|
|
337
343
|
indexName,
|
|
@@ -370,6 +376,7 @@ function createSearchClient({
|
|
|
370
376
|
batchSize = 1e3,
|
|
371
377
|
maxRetries = 100
|
|
372
378
|
}, requestOptions) {
|
|
379
|
+
requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
|
|
373
380
|
let requests = [];
|
|
374
381
|
const responses = [];
|
|
375
382
|
const objectEntries = objects.entries();
|
|
@@ -382,7 +389,7 @@ function createSearchClient({
|
|
|
382
389
|
}
|
|
383
390
|
if (waitForTasks) {
|
|
384
391
|
for (const resp of responses) {
|
|
385
|
-
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
|
|
392
|
+
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries }, requestOptions);
|
|
386
393
|
}
|
|
387
394
|
}
|
|
388
395
|
return responses;
|
|
@@ -460,6 +467,8 @@ function createSearchClient({
|
|
|
460
467
|
* 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.
|
|
461
468
|
* See https://api-clients-automation.netlify.app/docs/custom-helpers/#replaceallobjects for implementation details.
|
|
462
469
|
*
|
|
470
|
+
* Warning: calling this method with an empty `objects` list replaces the index with an empty one, deleting all existing records.
|
|
471
|
+
*
|
|
463
472
|
* @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.
|
|
464
473
|
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
465
474
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
@@ -476,6 +485,13 @@ function createSearchClient({
|
|
|
476
485
|
scopes,
|
|
477
486
|
maxRetries = import_client_common.DEFAULT_REPLACE_ALL_OBJECTS_MAX_RETRIES
|
|
478
487
|
}, requestOptions) {
|
|
488
|
+
requestOptions = (0, import_client_common.withRequestId)(transporter, requestOptions);
|
|
489
|
+
if (objects.length === 0) {
|
|
490
|
+
(0, import_client_common.logWarning)(
|
|
491
|
+
transporter.logger,
|
|
492
|
+
`replaceAllObjects was called with an empty list of objects, which will delete all records currently in the "${indexName}" index.`
|
|
493
|
+
);
|
|
494
|
+
}
|
|
479
495
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
480
496
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
481
497
|
if (scopes === void 0) {
|
|
@@ -497,11 +513,14 @@ function createSearchClient({
|
|
|
497
513
|
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
|
|
498
514
|
requestOptions
|
|
499
515
|
);
|
|
500
|
-
await this.waitForTask(
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
516
|
+
await this.waitForTask(
|
|
517
|
+
{
|
|
518
|
+
indexName: tmpIndexName,
|
|
519
|
+
taskID: copyOperationResponse.taskID,
|
|
520
|
+
maxRetries
|
|
521
|
+
},
|
|
522
|
+
requestOptions
|
|
523
|
+
);
|
|
505
524
|
copyOperationResponse = await this.operationIndex(
|
|
506
525
|
{
|
|
507
526
|
indexName,
|
|
@@ -513,11 +532,14 @@ function createSearchClient({
|
|
|
513
532
|
},
|
|
514
533
|
requestOptions
|
|
515
534
|
);
|
|
516
|
-
await this.waitForTask(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
535
|
+
await this.waitForTask(
|
|
536
|
+
{
|
|
537
|
+
indexName: tmpIndexName,
|
|
538
|
+
taskID: copyOperationResponse.taskID,
|
|
539
|
+
maxRetries
|
|
540
|
+
},
|
|
541
|
+
requestOptions
|
|
542
|
+
);
|
|
521
543
|
const moveOperationResponse = await this.operationIndex(
|
|
522
544
|
{
|
|
523
545
|
indexName: tmpIndexName,
|
|
@@ -525,20 +547,23 @@ function createSearchClient({
|
|
|
525
547
|
},
|
|
526
548
|
requestOptions
|
|
527
549
|
);
|
|
528
|
-
await this.waitForTask(
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
550
|
+
await this.waitForTask(
|
|
551
|
+
{
|
|
552
|
+
indexName: tmpIndexName,
|
|
553
|
+
taskID: moveOperationResponse.taskID,
|
|
554
|
+
maxRetries
|
|
555
|
+
},
|
|
556
|
+
requestOptions
|
|
557
|
+
);
|
|
533
558
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
534
559
|
} catch (error) {
|
|
535
|
-
await this.deleteIndex({ indexName: tmpIndexName });
|
|
560
|
+
await this.deleteIndex({ indexName: tmpIndexName }, requestOptions);
|
|
536
561
|
throw error;
|
|
537
562
|
}
|
|
538
563
|
},
|
|
539
|
-
async indexExists({ indexName }) {
|
|
564
|
+
async indexExists({ indexName }, requestOptions) {
|
|
540
565
|
try {
|
|
541
|
-
await this.getSettings({ indexName });
|
|
566
|
+
await this.getSettings({ indexName }, requestOptions);
|
|
542
567
|
} catch (error) {
|
|
543
568
|
if (error instanceof import_client_common.ApiError && error.status === 404) {
|
|
544
569
|
return false;
|