@algolia/client-search 5.0.0-beta.1 → 5.0.0-beta.11
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/LICENSE +21 -0
- package/dist/builds/browser.d.ts +73 -68
- package/dist/builds/browser.d.ts.map +1 -1
- package/dist/builds/node.d.ts +73 -68
- package/dist/builds/node.d.ts.map +1 -1
- package/dist/client-search.cjs +144 -14
- package/dist/client-search.esm.browser.js +137 -30
- package/dist/client-search.esm.node.js +144 -14
- package/dist/client-search.umd.js +2 -2
- package/dist/model/baseIndexSettings.d.ts +2 -2
- package/dist/model/baseIndexSettings.d.ts.map +1 -1
- package/dist/model/baseSearchResponse.d.ts +2 -18
- package/dist/model/baseSearchResponse.d.ts.map +1 -1
- package/dist/model/browsePagination.d.ts +19 -0
- package/dist/model/browsePagination.d.ts.map +1 -0
- package/dist/model/browseResponse.d.ts +2 -1
- package/dist/model/browseResponse.d.ts.map +1 -1
- package/dist/model/clientMethodProps.d.ts +31 -23
- package/dist/model/clientMethodProps.d.ts.map +1 -1
- package/dist/model/facetFilters.d.ts +1 -2
- package/dist/model/facetFilters.d.ts.map +1 -1
- package/dist/model/fetchedIndex.d.ts +4 -0
- package/dist/model/fetchedIndex.d.ts.map +1 -1
- package/dist/model/index.d.ts +5 -2
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/numericFilters.d.ts +1 -2
- package/dist/model/numericFilters.d.ts.map +1 -1
- package/dist/model/optionalFilters.d.ts +1 -2
- package/dist/model/optionalFilters.d.ts.map +1 -1
- package/dist/model/rankingInfo.d.ts +3 -3
- package/dist/model/rankingInfo.d.ts.map +1 -1
- package/dist/model/reRankingApplyFilter.d.ts +1 -2
- package/dist/model/reRankingApplyFilter.d.ts.map +1 -1
- package/dist/model/redirect.d.ts +1 -1
- package/dist/model/redirectURL.d.ts +7 -0
- package/dist/model/redirectURL.d.ts.map +1 -0
- package/dist/model/renderingContent.d.ts +2 -0
- package/dist/model/renderingContent.d.ts.map +1 -1
- package/dist/model/replaceAllObjectsResponse.d.ts +11 -0
- package/dist/model/replaceAllObjectsResponse.d.ts.map +1 -0
- package/dist/model/searchForFacetValuesResponse.d.ts +1 -1
- package/dist/model/searchPagination.d.ts +19 -0
- package/dist/model/searchPagination.d.ts.map +1 -0
- package/dist/model/searchResponse.d.ts +2 -1
- package/dist/model/searchResponse.d.ts.map +1 -1
- package/dist/model/{securedAPIKeyRestrictions.d.ts → securedApiKeyRestrictions.d.ts} +2 -2
- package/dist/model/{securedAPIKeyRestrictions.d.ts.map → securedApiKeyRestrictions.d.ts.map} +1 -1
- package/dist/model/tagFilters.d.ts +1 -2
- package/dist/model/tagFilters.d.ts.map +1 -1
- package/dist/model/value.d.ts +4 -0
- package/dist/model/value.d.ts.map +1 -1
- package/dist/src/searchClient.d.ts +69 -14
- package/dist/src/searchClient.d.ts.map +1 -1
- package/model/baseIndexSettings.ts +2 -2
- package/model/baseSearchResponse.ts +2 -22
- package/model/browsePagination.ts +23 -0
- package/model/browseResponse.ts +2 -0
- package/model/clientMethodProps.ts +42 -26
- package/model/facetFilters.ts +1 -3
- package/model/fetchedIndex.ts +5 -0
- package/model/index.ts +5 -2
- package/model/numericFilters.ts +1 -3
- package/model/optionalFilters.ts +1 -3
- package/model/rankingInfo.ts +3 -3
- package/model/reRankingApplyFilter.ts +1 -3
- package/model/redirect.ts +1 -1
- package/model/{mixedSearchFilters.ts → redirectURL.ts} +6 -1
- package/model/renderingContent.ts +3 -0
- package/model/replaceAllObjectsResponse.ts +15 -0
- package/model/searchForFacetValuesResponse.ts +1 -1
- package/model/searchPagination.ts +23 -0
- package/model/searchResponse.ts +3 -1
- package/model/{securedAPIKeyRestrictions.ts → securedApiKeyRestrictions.ts} +1 -1
- package/model/tagFilters.ts +1 -3
- package/model/value.ts +5 -0
- package/package.json +11 -8
- package/dist/model/mixedSearchFilters.d.ts +0 -2
- package/dist/model/mixedSearchFilters.d.ts.map +0 -1
package/dist/client-search.cjs
CHANGED
|
@@ -5,7 +5,7 @@ var clientCommon = require('@algolia/client-common');
|
|
|
5
5
|
var requesterNodeHttp = require('@algolia/requester-node-http');
|
|
6
6
|
|
|
7
7
|
// 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.
|
|
8
|
-
const apiClientVersion = '5.0.0-beta.
|
|
8
|
+
const apiClientVersion = '5.0.0-beta.11';
|
|
9
9
|
function getDefaultHosts(appId) {
|
|
10
10
|
return [
|
|
11
11
|
{
|
|
@@ -111,6 +111,29 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
111
111
|
timeout: () => timeout(retryCount),
|
|
112
112
|
});
|
|
113
113
|
},
|
|
114
|
+
/**
|
|
115
|
+
* Helper: Wait for an application-level task to complete for a given `taskID`.
|
|
116
|
+
*
|
|
117
|
+
* @summary Helper method that waits for a task to be published (completed).
|
|
118
|
+
* @param waitForAppTaskOptions - The `waitForTaskOptions` object.
|
|
119
|
+
* @param waitForAppTaskOptions.taskID - The `taskID` returned in the method response.
|
|
120
|
+
* @param waitForAppTaskOptions.maxRetries - The maximum number of retries. 50 by default.
|
|
121
|
+
* @param waitForAppTaskOptions.timeout - The function to decide how long to wait between retries.
|
|
122
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
123
|
+
*/
|
|
124
|
+
waitForAppTask({ taskID, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
|
|
125
|
+
let retryCount = 0;
|
|
126
|
+
return clientCommon.createIterablePromise({
|
|
127
|
+
func: () => this.getAppTask({ taskID }, requestOptions),
|
|
128
|
+
validate: (response) => response.status === 'published',
|
|
129
|
+
aggregator: () => (retryCount += 1),
|
|
130
|
+
error: {
|
|
131
|
+
validate: () => retryCount >= maxRetries,
|
|
132
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
|
|
133
|
+
},
|
|
134
|
+
timeout: () => timeout(retryCount),
|
|
135
|
+
});
|
|
136
|
+
},
|
|
114
137
|
/**
|
|
115
138
|
* Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
|
|
116
139
|
*
|
|
@@ -160,8 +183,13 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
160
183
|
}
|
|
161
184
|
return clientCommon.createIterablePromise({
|
|
162
185
|
...baseIteratorOptions,
|
|
163
|
-
func: () => this.getApiKey({ key }, requestOptions).catch((error) =>
|
|
164
|
-
|
|
186
|
+
func: () => this.getApiKey({ key }, requestOptions).catch((error) => {
|
|
187
|
+
if (error.status === 404) {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
throw error;
|
|
191
|
+
}),
|
|
192
|
+
validate: (response) => operation === 'add' ? response !== undefined : response === undefined,
|
|
165
193
|
});
|
|
166
194
|
},
|
|
167
195
|
/**
|
|
@@ -292,9 +320,10 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
292
320
|
async chunkedBatch({ indexName, objects, action = 'addObject', waitForTasks, batchSize = 1000, }, requestOptions) {
|
|
293
321
|
let requests = [];
|
|
294
322
|
const responses = [];
|
|
295
|
-
|
|
323
|
+
const objectEntries = objects.entries();
|
|
324
|
+
for (const [i, obj] of objectEntries) {
|
|
296
325
|
requests.push({ action, body: obj });
|
|
297
|
-
if (
|
|
326
|
+
if (requests.length === batchSize || i === objects.length - 1) {
|
|
298
327
|
responses.push(await this.batch({ indexName, batchWriteParams: { requests } }, requestOptions));
|
|
299
328
|
requests = [];
|
|
300
329
|
}
|
|
@@ -306,20 +335,68 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
306
335
|
}
|
|
307
336
|
return responses;
|
|
308
337
|
},
|
|
338
|
+
/**
|
|
339
|
+
* Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
|
|
340
|
+
*
|
|
341
|
+
* @summary Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
|
|
342
|
+
* @param saveObjects - The `saveObjects` object.
|
|
343
|
+
* @param saveObjects.indexName - The `indexName` to save `objects` in.
|
|
344
|
+
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
345
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
346
|
+
*/
|
|
347
|
+
async saveObjects({ indexName, objects }, requestOptions) {
|
|
348
|
+
return await this.chunkedBatch({ indexName, objects, action: 'addObject' }, requestOptions);
|
|
349
|
+
},
|
|
350
|
+
/**
|
|
351
|
+
* Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
|
|
352
|
+
*
|
|
353
|
+
* @summary Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
|
|
354
|
+
* @param deleteObjects - The `deleteObjects` object.
|
|
355
|
+
* @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
|
|
356
|
+
* @param deleteObjects.objectIDs - The objectIDs to delete.
|
|
357
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
358
|
+
*/
|
|
359
|
+
async deleteObjects({ indexName, objectIDs }, requestOptions) {
|
|
360
|
+
return await this.chunkedBatch({
|
|
361
|
+
indexName,
|
|
362
|
+
objects: objectIDs.map((objectID) => ({ objectID })),
|
|
363
|
+
action: 'deleteObject',
|
|
364
|
+
}, requestOptions);
|
|
365
|
+
},
|
|
366
|
+
/**
|
|
367
|
+
* Helper: Replaces object content of all the given objects according to their respective `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
|
|
368
|
+
*
|
|
369
|
+
* @summary Helper: Replaces object content of all the given objects according to their respective `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
|
|
370
|
+
* @param partialUpdateObjects - The `partialUpdateObjects` object.
|
|
371
|
+
* @param partialUpdateObjects.indexName - The `indexName` to update `objects` in.
|
|
372
|
+
* @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`.
|
|
373
|
+
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail..
|
|
374
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
375
|
+
*/
|
|
376
|
+
async partialUpdateObjects({ indexName, objects, createIfNotExists }, requestOptions) {
|
|
377
|
+
return await this.chunkedBatch({
|
|
378
|
+
indexName,
|
|
379
|
+
objects,
|
|
380
|
+
action: createIfNotExists
|
|
381
|
+
? 'partialUpdateObject'
|
|
382
|
+
: 'partialUpdateObjectNoCreate',
|
|
383
|
+
}, requestOptions);
|
|
384
|
+
},
|
|
309
385
|
/**
|
|
310
386
|
* 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.
|
|
387
|
+
* See https://api-clients-automation.netlify.app/docs/contributing/add-new-api-client#5-helpers for implementation details.
|
|
311
388
|
*
|
|
312
389
|
* @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.
|
|
313
390
|
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
314
391
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
315
392
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
316
|
-
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length
|
|
317
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
393
|
+
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `objects.length / batchSize`. Defaults to 1000.
|
|
394
|
+
* @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.
|
|
318
395
|
*/
|
|
319
396
|
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
320
|
-
const randomSuffix = Math.
|
|
397
|
+
const randomSuffix = Math.floor(Math.random() * 1000000) + 100000;
|
|
321
398
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
322
|
-
|
|
399
|
+
let copyOperationResponse = await this.operationIndex({
|
|
323
400
|
indexName,
|
|
324
401
|
operationIndexParams: {
|
|
325
402
|
operation: 'copy',
|
|
@@ -327,17 +404,29 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
327
404
|
scope: ['settings', 'rules', 'synonyms'],
|
|
328
405
|
},
|
|
329
406
|
}, requestOptions);
|
|
407
|
+
const batchResponses = await this.chunkedBatch({ indexName: tmpIndexName, objects, waitForTasks: true, batchSize }, requestOptions);
|
|
330
408
|
await this.waitForTask({
|
|
409
|
+
indexName: tmpIndexName,
|
|
410
|
+
taskID: copyOperationResponse.taskID,
|
|
411
|
+
});
|
|
412
|
+
copyOperationResponse = await this.operationIndex({
|
|
331
413
|
indexName,
|
|
414
|
+
operationIndexParams: {
|
|
415
|
+
operation: 'copy',
|
|
416
|
+
destination: tmpIndexName,
|
|
417
|
+
scope: ['settings', 'rules', 'synonyms'],
|
|
418
|
+
},
|
|
419
|
+
}, requestOptions);
|
|
420
|
+
await this.waitForTask({
|
|
421
|
+
indexName: tmpIndexName,
|
|
332
422
|
taskID: copyOperationResponse.taskID,
|
|
333
423
|
});
|
|
334
|
-
const batchResponses = await this.chunkedBatch({ indexName: tmpIndexName, objects, waitForTasks: true, batchSize }, requestOptions);
|
|
335
424
|
const moveOperationResponse = await this.operationIndex({
|
|
336
425
|
indexName: tmpIndexName,
|
|
337
426
|
operationIndexParams: { operation: 'move', destination: indexName },
|
|
338
427
|
}, requestOptions);
|
|
339
428
|
await this.waitForTask({
|
|
340
|
-
indexName,
|
|
429
|
+
indexName: tmpIndexName,
|
|
341
430
|
taskID: moveOperationResponse.taskID,
|
|
342
431
|
});
|
|
343
432
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
@@ -573,7 +662,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
573
662
|
return transporter.request(request, requestOptions);
|
|
574
663
|
},
|
|
575
664
|
/**
|
|
576
|
-
* Retrieves records from an index, up to 1,000 per request. While searching retrieves _hits_ (records augmented with attributes for highlighting and ranking details), browsing _just_ returns matching records. This can be useful if you want to export your indices. - The Analytics API doesn\'t collect data when using `browse`. - Records are ranked by attributes and custom ranking. -
|
|
665
|
+
* Retrieves records from an index, up to 1,000 per request. While searching retrieves _hits_ (records augmented with attributes for highlighting and ranking details), browsing _just_ returns matching records. This can be useful if you want to export your indices. - The Analytics API doesn\'t collect data when using `browse`. - Records are ranked by attributes and custom ranking. - There\'s no ranking for: typo-tolerance, number of matched words, proximity, geo distance. Browse requests automatically apply these settings: - `advancedSyntax`: `false` - `attributesToHighlight`: `[]` - `attributesToSnippet`: `[]` - `distinct`: `false` - `enablePersonalization`: `false` - `enableRules`: `false` - `facets`: `[]` - `getRankingInfo`: `false` - `ignorePlurals`: `false` - `optionalFilters`: `[]` - `typoTolerance`: `true` or `false` (`min` and `strict` is evaluated to `true`) If you send these parameters with your browse requests, they\'ll be ignored.
|
|
577
666
|
*
|
|
578
667
|
* Required API Key ACLs:
|
|
579
668
|
* - browse.
|
|
@@ -1006,6 +1095,31 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1006
1095
|
};
|
|
1007
1096
|
return transporter.request(request, requestOptions);
|
|
1008
1097
|
},
|
|
1098
|
+
/**
|
|
1099
|
+
* Checks the status of a given application task.
|
|
1100
|
+
*
|
|
1101
|
+
* Required API Key ACLs:
|
|
1102
|
+
* - editSettings.
|
|
1103
|
+
*
|
|
1104
|
+
* @param getAppTask - The getAppTask object.
|
|
1105
|
+
* @param getAppTask.taskID - Unique task identifier.
|
|
1106
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1107
|
+
*/
|
|
1108
|
+
getAppTask({ taskID }, requestOptions) {
|
|
1109
|
+
if (!taskID) {
|
|
1110
|
+
throw new Error('Parameter `taskID` is required when calling `getAppTask`.');
|
|
1111
|
+
}
|
|
1112
|
+
const requestPath = '/1/task/{taskID}'.replace('{taskID}', encodeURIComponent(taskID));
|
|
1113
|
+
const headers = {};
|
|
1114
|
+
const queryParameters = {};
|
|
1115
|
+
const request = {
|
|
1116
|
+
method: 'GET',
|
|
1117
|
+
path: requestPath,
|
|
1118
|
+
queryParameters,
|
|
1119
|
+
headers,
|
|
1120
|
+
};
|
|
1121
|
+
return transporter.request(request, requestOptions);
|
|
1122
|
+
},
|
|
1009
1123
|
/**
|
|
1010
1124
|
* Lists supported languages with their supported dictionary types and number of custom entries.
|
|
1011
1125
|
*
|
|
@@ -1480,7 +1594,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1480
1594
|
return transporter.request(request, requestOptions);
|
|
1481
1595
|
},
|
|
1482
1596
|
/**
|
|
1483
|
-
* Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for
|
|
1597
|
+
* Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn\'t exist yet, it\'ll be created. **Copy** - Copying a source index that doesn\'t exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can\'t copy the `enableReRanking`, `mode`, and `replicas` settings. - You can\'t copy to a destination index that already has replicas. - Be aware of the [size limits](https://www.algolia.com/doc/guides/scaling/algolia-service-limits/#application-record-and-index-limits). - Related guide: [Copy indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/copy-indices/) **Move** - Moving a source index that doesn\'t exist is ignored without returning an error. - When moving an index, the analytics data keep their original name and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: [Move indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/move-indices/).
|
|
1484
1598
|
*
|
|
1485
1599
|
* Required API Key ACLs:
|
|
1486
1600
|
* - addObject.
|
|
@@ -2198,7 +2312,23 @@ function searchClient(appId, apiKey, options) {
|
|
|
2198
2312
|
* @param generateSecuredApiKey.restrictions - A set of properties defining the restrictions of the secured API key.
|
|
2199
2313
|
*/
|
|
2200
2314
|
generateSecuredApiKey({ parentApiKey, restrictions = {}, }) {
|
|
2201
|
-
|
|
2315
|
+
let mergedRestrictions = restrictions;
|
|
2316
|
+
if (restrictions.searchParams) {
|
|
2317
|
+
// merge searchParams with the root restrictions
|
|
2318
|
+
mergedRestrictions = {
|
|
2319
|
+
...restrictions,
|
|
2320
|
+
...restrictions.searchParams,
|
|
2321
|
+
};
|
|
2322
|
+
delete mergedRestrictions.searchParams;
|
|
2323
|
+
}
|
|
2324
|
+
mergedRestrictions = Object.keys(mergedRestrictions)
|
|
2325
|
+
.sort()
|
|
2326
|
+
.reduce((acc, key) => {
|
|
2327
|
+
// eslint-disable-next-line no-param-reassign
|
|
2328
|
+
acc[key] = mergedRestrictions[key];
|
|
2329
|
+
return acc;
|
|
2330
|
+
}, {});
|
|
2331
|
+
const queryParameters = clientCommon.serializeQueryParameters(mergedRestrictions);
|
|
2202
2332
|
return Buffer.from(crypto.createHmac('sha256', parentApiKey)
|
|
2203
2333
|
.update(queryParameters)
|
|
2204
2334
|
.digest('hex') + queryParameters).toString('base64');
|
|
@@ -235,6 +235,14 @@ function createStatefulHost(host, status = 'up') {
|
|
|
235
235
|
};
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
+
function _defineProperty(e, r, t) {
|
|
239
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
240
|
+
value: t,
|
|
241
|
+
enumerable: !0,
|
|
242
|
+
configurable: !0,
|
|
243
|
+
writable: !0
|
|
244
|
+
}) : e[r] = t, e;
|
|
245
|
+
}
|
|
238
246
|
function _toPrimitive(t, r) {
|
|
239
247
|
if ("object" != typeof t || !t) return t;
|
|
240
248
|
var e = t[Symbol.toPrimitive];
|
|
@@ -249,20 +257,6 @@ function _toPropertyKey(t) {
|
|
|
249
257
|
var i = _toPrimitive(t, "string");
|
|
250
258
|
return "symbol" == typeof i ? i : i + "";
|
|
251
259
|
}
|
|
252
|
-
function _defineProperty(obj, key, value) {
|
|
253
|
-
key = _toPropertyKey(key);
|
|
254
|
-
if (key in obj) {
|
|
255
|
-
Object.defineProperty(obj, key, {
|
|
256
|
-
value: value,
|
|
257
|
-
enumerable: true,
|
|
258
|
-
configurable: true,
|
|
259
|
-
writable: true
|
|
260
|
-
});
|
|
261
|
-
} else {
|
|
262
|
-
obj[key] = value;
|
|
263
|
-
}
|
|
264
|
-
return obj;
|
|
265
|
-
}
|
|
266
260
|
|
|
267
261
|
class AlgoliaError extends Error {
|
|
268
262
|
constructor(message, name) {
|
|
@@ -283,7 +277,7 @@ class ErrorWithStackTrace extends AlgoliaError {
|
|
|
283
277
|
}
|
|
284
278
|
class RetryError extends ErrorWithStackTrace {
|
|
285
279
|
constructor(stackTrace) {
|
|
286
|
-
super('Unreachable hosts - your application id may be incorrect. If the error persists, please
|
|
280
|
+
super('Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.', stackTrace, 'RetryError');
|
|
287
281
|
}
|
|
288
282
|
}
|
|
289
283
|
class ApiError extends ErrorWithStackTrace {
|
|
@@ -328,8 +322,7 @@ function serializeUrl(host, path, queryParameters) {
|
|
|
328
322
|
return url;
|
|
329
323
|
}
|
|
330
324
|
function serializeQueryParameters(parameters) {
|
|
331
|
-
|
|
332
|
-
return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key]).replaceAll('+', '%20')}`).join('&');
|
|
325
|
+
return Object.keys(parameters).filter(key => parameters[key] !== undefined).sort().map(key => `${key}=${encodeURIComponent(Object.prototype.toString.call(parameters[key]) === '[object Array]' ? parameters[key].join(',') : parameters[key]).replaceAll('+', '%20')}`).join('&');
|
|
333
326
|
}
|
|
334
327
|
function serializeData(request, requestOptions) {
|
|
335
328
|
if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
|
|
@@ -734,7 +727,7 @@ function createXhrRequester() {
|
|
|
734
727
|
}
|
|
735
728
|
|
|
736
729
|
// 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.
|
|
737
|
-
const apiClientVersion = '5.0.0-beta.
|
|
730
|
+
const apiClientVersion = '5.0.0-beta.11';
|
|
738
731
|
function getDefaultHosts(appId) {
|
|
739
732
|
return [
|
|
740
733
|
{
|
|
@@ -840,6 +833,29 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
840
833
|
timeout: () => timeout(retryCount),
|
|
841
834
|
});
|
|
842
835
|
},
|
|
836
|
+
/**
|
|
837
|
+
* Helper: Wait for an application-level task to complete for a given `taskID`.
|
|
838
|
+
*
|
|
839
|
+
* @summary Helper method that waits for a task to be published (completed).
|
|
840
|
+
* @param waitForAppTaskOptions - The `waitForTaskOptions` object.
|
|
841
|
+
* @param waitForAppTaskOptions.taskID - The `taskID` returned in the method response.
|
|
842
|
+
* @param waitForAppTaskOptions.maxRetries - The maximum number of retries. 50 by default.
|
|
843
|
+
* @param waitForAppTaskOptions.timeout - The function to decide how long to wait between retries.
|
|
844
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
845
|
+
*/
|
|
846
|
+
waitForAppTask({ taskID, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
|
|
847
|
+
let retryCount = 0;
|
|
848
|
+
return createIterablePromise({
|
|
849
|
+
func: () => this.getAppTask({ taskID }, requestOptions),
|
|
850
|
+
validate: (response) => response.status === 'published',
|
|
851
|
+
aggregator: () => (retryCount += 1),
|
|
852
|
+
error: {
|
|
853
|
+
validate: () => retryCount >= maxRetries,
|
|
854
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
|
|
855
|
+
},
|
|
856
|
+
timeout: () => timeout(retryCount),
|
|
857
|
+
});
|
|
858
|
+
},
|
|
843
859
|
/**
|
|
844
860
|
* Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
|
|
845
861
|
*
|
|
@@ -889,8 +905,13 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
889
905
|
}
|
|
890
906
|
return createIterablePromise({
|
|
891
907
|
...baseIteratorOptions,
|
|
892
|
-
func: () => this.getApiKey({ key }, requestOptions).catch((error) =>
|
|
893
|
-
|
|
908
|
+
func: () => this.getApiKey({ key }, requestOptions).catch((error) => {
|
|
909
|
+
if (error.status === 404) {
|
|
910
|
+
return undefined;
|
|
911
|
+
}
|
|
912
|
+
throw error;
|
|
913
|
+
}),
|
|
914
|
+
validate: (response) => operation === 'add' ? response !== undefined : response === undefined,
|
|
894
915
|
});
|
|
895
916
|
},
|
|
896
917
|
/**
|
|
@@ -1021,9 +1042,10 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1021
1042
|
async chunkedBatch({ indexName, objects, action = 'addObject', waitForTasks, batchSize = 1000, }, requestOptions) {
|
|
1022
1043
|
let requests = [];
|
|
1023
1044
|
const responses = [];
|
|
1024
|
-
|
|
1045
|
+
const objectEntries = objects.entries();
|
|
1046
|
+
for (const [i, obj] of objectEntries) {
|
|
1025
1047
|
requests.push({ action, body: obj });
|
|
1026
|
-
if (
|
|
1048
|
+
if (requests.length === batchSize || i === objects.length - 1) {
|
|
1027
1049
|
responses.push(await this.batch({ indexName, batchWriteParams: { requests } }, requestOptions));
|
|
1028
1050
|
requests = [];
|
|
1029
1051
|
}
|
|
@@ -1035,20 +1057,68 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1035
1057
|
}
|
|
1036
1058
|
return responses;
|
|
1037
1059
|
},
|
|
1060
|
+
/**
|
|
1061
|
+
* Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
|
|
1062
|
+
*
|
|
1063
|
+
* @summary Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
|
|
1064
|
+
* @param saveObjects - The `saveObjects` object.
|
|
1065
|
+
* @param saveObjects.indexName - The `indexName` to save `objects` in.
|
|
1066
|
+
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
1067
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
1068
|
+
*/
|
|
1069
|
+
async saveObjects({ indexName, objects }, requestOptions) {
|
|
1070
|
+
return await this.chunkedBatch({ indexName, objects, action: 'addObject' }, requestOptions);
|
|
1071
|
+
},
|
|
1072
|
+
/**
|
|
1073
|
+
* Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
|
|
1074
|
+
*
|
|
1075
|
+
* @summary Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
|
|
1076
|
+
* @param deleteObjects - The `deleteObjects` object.
|
|
1077
|
+
* @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
|
|
1078
|
+
* @param deleteObjects.objectIDs - The objectIDs to delete.
|
|
1079
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
1080
|
+
*/
|
|
1081
|
+
async deleteObjects({ indexName, objectIDs }, requestOptions) {
|
|
1082
|
+
return await this.chunkedBatch({
|
|
1083
|
+
indexName,
|
|
1084
|
+
objects: objectIDs.map((objectID) => ({ objectID })),
|
|
1085
|
+
action: 'deleteObject',
|
|
1086
|
+
}, requestOptions);
|
|
1087
|
+
},
|
|
1088
|
+
/**
|
|
1089
|
+
* Helper: Replaces object content of all the given objects according to their respective `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
|
|
1090
|
+
*
|
|
1091
|
+
* @summary Helper: Replaces object content of all the given objects according to their respective `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objects in it.
|
|
1092
|
+
* @param partialUpdateObjects - The `partialUpdateObjects` object.
|
|
1093
|
+
* @param partialUpdateObjects.indexName - The `indexName` to update `objects` in.
|
|
1094
|
+
* @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`.
|
|
1095
|
+
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail..
|
|
1096
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
1097
|
+
*/
|
|
1098
|
+
async partialUpdateObjects({ indexName, objects, createIfNotExists }, requestOptions) {
|
|
1099
|
+
return await this.chunkedBatch({
|
|
1100
|
+
indexName,
|
|
1101
|
+
objects,
|
|
1102
|
+
action: createIfNotExists
|
|
1103
|
+
? 'partialUpdateObject'
|
|
1104
|
+
: 'partialUpdateObjectNoCreate',
|
|
1105
|
+
}, requestOptions);
|
|
1106
|
+
},
|
|
1038
1107
|
/**
|
|
1039
1108
|
* 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.
|
|
1109
|
+
* See https://api-clients-automation.netlify.app/docs/contributing/add-new-api-client#5-helpers for implementation details.
|
|
1040
1110
|
*
|
|
1041
1111
|
* @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.
|
|
1042
1112
|
* @param replaceAllObjects - The `replaceAllObjects` object.
|
|
1043
1113
|
* @param replaceAllObjects.indexName - The `indexName` to replace `objects` in.
|
|
1044
1114
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
1045
|
-
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length
|
|
1046
|
-
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
1115
|
+
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `objects.length / batchSize`. Defaults to 1000.
|
|
1116
|
+
* @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.
|
|
1047
1117
|
*/
|
|
1048
1118
|
async replaceAllObjects({ indexName, objects, batchSize }, requestOptions) {
|
|
1049
|
-
const randomSuffix = Math.
|
|
1119
|
+
const randomSuffix = Math.floor(Math.random() * 1000000) + 100000;
|
|
1050
1120
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
1051
|
-
|
|
1121
|
+
let copyOperationResponse = await this.operationIndex({
|
|
1052
1122
|
indexName,
|
|
1053
1123
|
operationIndexParams: {
|
|
1054
1124
|
operation: 'copy',
|
|
@@ -1056,17 +1126,29 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1056
1126
|
scope: ['settings', 'rules', 'synonyms'],
|
|
1057
1127
|
},
|
|
1058
1128
|
}, requestOptions);
|
|
1129
|
+
const batchResponses = await this.chunkedBatch({ indexName: tmpIndexName, objects, waitForTasks: true, batchSize }, requestOptions);
|
|
1059
1130
|
await this.waitForTask({
|
|
1131
|
+
indexName: tmpIndexName,
|
|
1132
|
+
taskID: copyOperationResponse.taskID,
|
|
1133
|
+
});
|
|
1134
|
+
copyOperationResponse = await this.operationIndex({
|
|
1060
1135
|
indexName,
|
|
1136
|
+
operationIndexParams: {
|
|
1137
|
+
operation: 'copy',
|
|
1138
|
+
destination: tmpIndexName,
|
|
1139
|
+
scope: ['settings', 'rules', 'synonyms'],
|
|
1140
|
+
},
|
|
1141
|
+
}, requestOptions);
|
|
1142
|
+
await this.waitForTask({
|
|
1143
|
+
indexName: tmpIndexName,
|
|
1061
1144
|
taskID: copyOperationResponse.taskID,
|
|
1062
1145
|
});
|
|
1063
|
-
const batchResponses = await this.chunkedBatch({ indexName: tmpIndexName, objects, waitForTasks: true, batchSize }, requestOptions);
|
|
1064
1146
|
const moveOperationResponse = await this.operationIndex({
|
|
1065
1147
|
indexName: tmpIndexName,
|
|
1066
1148
|
operationIndexParams: { operation: 'move', destination: indexName },
|
|
1067
1149
|
}, requestOptions);
|
|
1068
1150
|
await this.waitForTask({
|
|
1069
|
-
indexName,
|
|
1151
|
+
indexName: tmpIndexName,
|
|
1070
1152
|
taskID: moveOperationResponse.taskID,
|
|
1071
1153
|
});
|
|
1072
1154
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
@@ -1302,7 +1384,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1302
1384
|
return transporter.request(request, requestOptions);
|
|
1303
1385
|
},
|
|
1304
1386
|
/**
|
|
1305
|
-
* Retrieves records from an index, up to 1,000 per request. While searching retrieves _hits_ (records augmented with attributes for highlighting and ranking details), browsing _just_ returns matching records. This can be useful if you want to export your indices. - The Analytics API doesn\'t collect data when using `browse`. - Records are ranked by attributes and custom ranking. -
|
|
1387
|
+
* Retrieves records from an index, up to 1,000 per request. While searching retrieves _hits_ (records augmented with attributes for highlighting and ranking details), browsing _just_ returns matching records. This can be useful if you want to export your indices. - The Analytics API doesn\'t collect data when using `browse`. - Records are ranked by attributes and custom ranking. - There\'s no ranking for: typo-tolerance, number of matched words, proximity, geo distance. Browse requests automatically apply these settings: - `advancedSyntax`: `false` - `attributesToHighlight`: `[]` - `attributesToSnippet`: `[]` - `distinct`: `false` - `enablePersonalization`: `false` - `enableRules`: `false` - `facets`: `[]` - `getRankingInfo`: `false` - `ignorePlurals`: `false` - `optionalFilters`: `[]` - `typoTolerance`: `true` or `false` (`min` and `strict` is evaluated to `true`) If you send these parameters with your browse requests, they\'ll be ignored.
|
|
1306
1388
|
*
|
|
1307
1389
|
* Required API Key ACLs:
|
|
1308
1390
|
* - browse.
|
|
@@ -1735,6 +1817,31 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1735
1817
|
};
|
|
1736
1818
|
return transporter.request(request, requestOptions);
|
|
1737
1819
|
},
|
|
1820
|
+
/**
|
|
1821
|
+
* Checks the status of a given application task.
|
|
1822
|
+
*
|
|
1823
|
+
* Required API Key ACLs:
|
|
1824
|
+
* - editSettings.
|
|
1825
|
+
*
|
|
1826
|
+
* @param getAppTask - The getAppTask object.
|
|
1827
|
+
* @param getAppTask.taskID - Unique task identifier.
|
|
1828
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1829
|
+
*/
|
|
1830
|
+
getAppTask({ taskID }, requestOptions) {
|
|
1831
|
+
if (!taskID) {
|
|
1832
|
+
throw new Error('Parameter `taskID` is required when calling `getAppTask`.');
|
|
1833
|
+
}
|
|
1834
|
+
const requestPath = '/1/task/{taskID}'.replace('{taskID}', encodeURIComponent(taskID));
|
|
1835
|
+
const headers = {};
|
|
1836
|
+
const queryParameters = {};
|
|
1837
|
+
const request = {
|
|
1838
|
+
method: 'GET',
|
|
1839
|
+
path: requestPath,
|
|
1840
|
+
queryParameters,
|
|
1841
|
+
headers,
|
|
1842
|
+
};
|
|
1843
|
+
return transporter.request(request, requestOptions);
|
|
1844
|
+
},
|
|
1738
1845
|
/**
|
|
1739
1846
|
* Lists supported languages with their supported dictionary types and number of custom entries.
|
|
1740
1847
|
*
|
|
@@ -2209,7 +2316,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
2209
2316
|
return transporter.request(request, requestOptions);
|
|
2210
2317
|
},
|
|
2211
2318
|
/**
|
|
2212
|
-
* Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for
|
|
2319
|
+
* Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn\'t exist yet, it\'ll be created. **Copy** - Copying a source index that doesn\'t exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can\'t copy the `enableReRanking`, `mode`, and `replicas` settings. - You can\'t copy to a destination index that already has replicas. - Be aware of the [size limits](https://www.algolia.com/doc/guides/scaling/algolia-service-limits/#application-record-and-index-limits). - Related guide: [Copy indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/copy-indices/) **Move** - Moving a source index that doesn\'t exist is ignored without returning an error. - When moving an index, the analytics data keep their original name and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: [Move indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/move-indices/).
|
|
2213
2320
|
*
|
|
2214
2321
|
* Required API Key ACLs:
|
|
2215
2322
|
* - addObject.
|