@algolia/client-search 5.0.0-alpha.1 → 5.0.0-alpha.4
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/dist/builds/browser.d.ts +2 -2
- package/dist/builds/browser.d.ts.map +1 -1
- package/dist/builds/node.d.ts +2 -2
- package/dist/builds/node.d.ts.map +1 -1
- package/dist/client-search.cjs.js +144 -25
- package/dist/client-search.esm.browser.js +172 -53
- package/dist/client-search.esm.node.js +145 -26
- package/dist/client-search.umd.js +2 -2
- package/dist/model/acl.d.ts +3 -0
- package/dist/model/acl.d.ts.map +1 -1
- package/dist/model/addApiKeyResponse.d.ts +1 -1
- package/dist/model/addApiKeyResponse.d.ts.map +1 -1
- package/dist/model/apiKey.d.ts.map +1 -1
- package/dist/model/attributeToUpdate.d.ts +3 -0
- package/dist/model/attributeToUpdate.d.ts.map +1 -0
- package/dist/model/automaticFacetFilter.d.ts.map +1 -1
- package/dist/model/baseGetApiKeyResponse.d.ts +11 -0
- package/dist/model/baseGetApiKeyResponse.d.ts.map +1 -0
- package/dist/model/baseIndexSettings.d.ts.map +1 -1
- package/dist/model/baseSearchParamsWithoutQuery.d.ts.map +1 -1
- package/dist/model/baseSearchResponse.d.ts +2 -2
- package/dist/model/baseSearchResponse.d.ts.map +1 -1
- package/dist/model/batchAssignUserIdsParams.d.ts.map +1 -1
- package/dist/model/batchDictionaryEntriesParams.d.ts.map +1 -1
- package/dist/model/batchDictionaryEntriesRequest.d.ts.map +1 -1
- package/dist/model/batchParams.d.ts +2 -2
- package/dist/model/batchParams.d.ts.map +1 -1
- package/dist/model/{batchOperation.d.ts → batchRequest.d.ts} +2 -2
- package/dist/model/batchRequest.d.ts.map +1 -0
- package/dist/model/batchResponse.d.ts.map +1 -1
- package/dist/model/batchWriteParams.d.ts +2 -2
- package/dist/model/batchWriteParams.d.ts.map +1 -1
- package/dist/model/browseRequest.d.ts.map +1 -1
- package/dist/model/browseResponse.d.ts +1 -1
- package/dist/model/browseResponse.d.ts.map +1 -1
- package/dist/model/builtInOperation.d.ts.map +1 -1
- package/dist/model/clientMethodProps.d.ts +21 -8
- package/dist/model/clientMethodProps.d.ts.map +1 -1
- package/dist/model/condition.d.ts.map +1 -1
- package/dist/model/consequence.d.ts.map +1 -1
- package/dist/model/consequenceQueryObject.d.ts.map +1 -1
- package/dist/model/deletedAtResponse.d.ts.map +1 -1
- package/dist/model/dictionaryEntry.d.ts.map +1 -1
- package/dist/model/distinct.d.ts +5 -0
- package/dist/model/distinct.d.ts.map +1 -0
- package/dist/model/edit.d.ts.map +1 -1
- package/dist/model/facetHits.d.ts.map +1 -1
- package/dist/model/facetOrdering.d.ts.map +1 -1
- package/dist/model/facetsStats.d.ts.map +1 -1
- package/dist/model/fetchedIndex.d.ts.map +1 -1
- package/dist/model/getApiKeyResponse.d.ts +4 -0
- package/dist/model/getApiKeyResponse.d.ts.map +1 -0
- package/dist/model/getObjectsParams.d.ts +2 -2
- package/dist/model/getObjectsParams.d.ts.map +1 -1
- package/dist/model/{multipleGetObjectsParams.d.ts → getObjectsRequest.d.ts} +2 -2
- package/dist/model/getObjectsRequest.d.ts.map +1 -0
- package/dist/model/getObjectsResponse.d.ts +2 -2
- package/dist/model/getObjectsResponse.d.ts.map +1 -1
- package/dist/model/hasPendingMappingsResponse.d.ts.map +1 -1
- package/dist/model/highlightResultOption.d.ts.map +1 -1
- package/dist/model/hit.d.ts +1 -1
- package/dist/model/hit.d.ts.map +1 -1
- package/dist/model/index.d.ts +7 -6
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/indexSettingsAsSearchParams.d.ts +2 -4
- package/dist/model/indexSettingsAsSearchParams.d.ts.map +1 -1
- package/dist/model/languages.d.ts.map +1 -1
- package/dist/model/listApiKeysResponse.d.ts +2 -2
- package/dist/model/listApiKeysResponse.d.ts.map +1 -1
- package/dist/model/listIndicesResponse.d.ts +1 -1
- package/dist/model/listIndicesResponse.d.ts.map +1 -1
- package/dist/model/log.d.ts.map +1 -1
- package/dist/model/logQuery.d.ts.map +1 -1
- package/dist/model/matchedGeoLocation.d.ts.map +1 -1
- package/dist/model/{multipleBatchOperation.d.ts → multipleBatchRequest.d.ts} +5 -5
- package/dist/model/multipleBatchRequest.d.ts.map +1 -0
- package/dist/model/multipleBatchResponse.d.ts +2 -2
- package/dist/model/multipleBatchResponse.d.ts.map +1 -1
- package/dist/model/operationIndexParams.d.ts.map +1 -1
- package/dist/model/params.d.ts.map +1 -1
- package/dist/model/personalization.d.ts.map +1 -1
- package/dist/model/promoteObjectID.d.ts.map +1 -1
- package/dist/model/promoteObjectIDs.d.ts.map +1 -1
- package/dist/model/rankingInfo.d.ts.map +1 -1
- package/dist/model/rule.d.ts.map +1 -1
- package/dist/model/saveObjectResponse.d.ts +2 -2
- package/dist/model/saveObjectResponse.d.ts.map +1 -1
- package/dist/model/saveSynonymResponse.d.ts.map +1 -1
- package/dist/model/searchDictionaryEntriesParams.d.ts.map +1 -1
- package/dist/model/searchForFacetValuesRequest.d.ts.map +1 -1
- package/dist/model/searchForFacetsOptions.d.ts.map +1 -1
- package/dist/model/searchForHitsOptions.d.ts.map +1 -1
- package/dist/model/searchHits.d.ts +2 -2
- package/dist/model/searchHits.d.ts.map +1 -1
- package/dist/model/searchMethodParams.d.ts.map +1 -1
- package/dist/model/searchResponse.d.ts +1 -1
- package/dist/model/searchResponse.d.ts.map +1 -1
- package/dist/model/searchResponses.d.ts +1 -1
- package/dist/model/searchResponses.d.ts.map +1 -1
- package/dist/model/searchRulesParams.d.ts.map +1 -1
- package/dist/model/searchRulesResponse.d.ts.map +1 -1
- package/dist/model/searchSynonymsResponse.d.ts.map +1 -1
- package/dist/model/searchUserIdsParams.d.ts.map +1 -1
- package/dist/model/searchUserIdsResponse.d.ts.map +1 -1
- package/dist/model/snippetResultOption.d.ts.map +1 -1
- package/dist/model/source.d.ts.map +1 -1
- package/dist/model/standardEntries.d.ts.map +1 -1
- package/dist/model/synonymHit.d.ts.map +1 -1
- package/dist/model/synonymHitHighlightResult.d.ts.map +1 -1
- package/dist/model/timeRange.d.ts.map +1 -1
- package/dist/model/updateApiKeyResponse.d.ts +1 -1
- package/dist/model/updateApiKeyResponse.d.ts.map +1 -1
- package/dist/model/updatedAtResponse.d.ts.map +1 -1
- package/dist/model/updatedAtWithObjectIdResponse.d.ts.map +1 -1
- package/dist/model/updatedRuleResponse.d.ts.map +1 -1
- package/dist/model/userHighlightResult.d.ts.map +1 -1
- package/dist/model/userHit.d.ts.map +1 -1
- package/dist/model/userId.d.ts.map +1 -1
- package/dist/model/value.d.ts.map +1 -1
- package/dist/src/searchClient.d.ts +65 -15
- package/dist/src/searchClient.d.ts.map +1 -1
- package/model/acl.ts +3 -0
- package/model/addApiKeyResponse.ts +2 -1
- package/model/apiKey.ts +7 -0
- package/model/{attributeOrBuiltInOperation.ts → attributeToUpdate.ts} +1 -1
- package/model/automaticFacetFilter.ts +2 -0
- package/model/baseGetApiKeyResponse.ts +13 -0
- package/model/baseIndexSettings.ts +13 -0
- package/model/baseSearchParamsWithoutQuery.ts +32 -0
- package/model/baseSearchResponse.ts +26 -2
- package/model/batchAssignUserIdsParams.ts +1 -0
- package/model/batchDictionaryEntriesParams.ts +1 -0
- package/model/batchDictionaryEntriesRequest.ts +1 -0
- package/model/batchParams.ts +2 -2
- package/model/{batchOperation.ts → batchRequest.ts} +2 -1
- package/model/batchResponse.ts +1 -0
- package/model/batchWriteParams.ts +2 -2
- package/model/browseRequest.ts +1 -0
- package/model/browseResponse.ts +1 -1
- package/model/builtInOperation.ts +1 -0
- package/model/clientMethodProps.ts +28 -12
- package/model/condition.ts +3 -0
- package/model/consequence.ts +4 -0
- package/model/consequenceQueryObject.ts +1 -0
- package/model/deletedAtResponse.ts +1 -0
- package/model/dictionaryEntry.ts +5 -0
- package/model/{createdAtObject.ts → distinct.ts} +4 -6
- package/model/edit.ts +2 -0
- package/model/facetHits.ts +2 -0
- package/model/facetOrdering.ts +1 -0
- package/model/facetsStats.ts +3 -0
- package/model/fetchedIndex.ts +10 -0
- package/model/{key.ts → getApiKeyResponse.ts} +2 -2
- package/model/getObjectsParams.ts +2 -2
- package/model/{multipleGetObjectsParams.ts → getObjectsRequest.ts} +3 -1
- package/model/getObjectsResponse.ts +2 -2
- package/model/hasPendingMappingsResponse.ts +1 -0
- package/model/highlightResultOption.ts +3 -0
- package/model/hit.ts +5 -1
- package/model/index.ts +7 -6
- package/model/indexSettingsAsSearchParams.ts +43 -4
- package/model/languages.ts +2 -0
- package/model/listApiKeysResponse.ts +2 -2
- package/model/listIndicesResponse.ts +2 -1
- package/model/log.ts +14 -0
- package/model/logQuery.ts +2 -0
- package/model/matchedGeoLocation.ts +2 -0
- package/model/{multipleBatchOperation.ts → multipleBatchRequest.ts} +6 -4
- package/model/multipleBatchResponse.ts +3 -2
- package/model/operationIndexParams.ts +2 -0
- package/model/params.ts +3 -0
- package/model/personalization.ts +2 -0
- package/model/promoteObjectID.ts +1 -0
- package/model/promoteObjectIDs.ts +1 -0
- package/model/rankingInfo.ts +12 -0
- package/model/rule.ts +5 -0
- package/model/saveObjectResponse.ts +4 -2
- package/model/saveSynonymResponse.ts +2 -0
- package/model/searchDictionaryEntriesParams.ts +3 -0
- package/model/searchForFacetValuesRequest.ts +2 -0
- package/model/searchForFacetsOptions.ts +4 -0
- package/model/searchForHitsOptions.ts +1 -0
- package/model/searchHits.ts +2 -2
- package/model/searchMethodParams.ts +1 -0
- package/model/searchResponse.ts +2 -1
- package/model/searchResponses.ts +1 -1
- package/model/searchRulesParams.ts +6 -0
- package/model/searchRulesResponse.ts +3 -0
- package/model/searchSynonymsResponse.ts +1 -0
- package/model/searchUserIdsParams.ts +3 -0
- package/model/searchUserIdsResponse.ts +4 -0
- package/model/snippetResultOption.ts +1 -0
- package/model/source.ts +1 -0
- package/model/standardEntries.ts +2 -0
- package/model/synonymHit.ts +8 -0
- package/model/synonymHitHighlightResult.ts +1 -0
- package/model/timeRange.ts +1 -0
- package/model/updateApiKeyResponse.ts +2 -1
- package/model/updatedAtResponse.ts +1 -0
- package/model/updatedAtWithObjectIdResponse.ts +2 -0
- package/model/updatedRuleResponse.ts +2 -0
- package/model/userHighlightResult.ts +1 -0
- package/model/userHit.ts +5 -0
- package/model/userId.ts +3 -0
- package/model/value.ts +1 -0
- package/package.json +5 -5
- package/dist/model/attributeOrBuiltInOperation.d.ts +0 -3
- package/dist/model/attributeOrBuiltInOperation.d.ts.map +0 -1
- package/dist/model/batchOperation.d.ts.map +0 -1
- package/dist/model/createdAtObject.d.ts +0 -7
- package/dist/model/createdAtObject.d.ts.map +0 -1
- package/dist/model/key.d.ts +0 -4
- package/dist/model/key.d.ts.map +0 -1
- package/dist/model/multipleBatchOperation.d.ts.map +0 -1
- package/dist/model/multipleGetObjectsParams.d.ts.map +0 -1
package/dist/builds/browser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ClientOptions } from '@algolia/client-common';
|
|
2
2
|
import type { SearchClient } from '../src/searchClient';
|
|
3
3
|
export { apiClientVersion, SearchClient } from '../src/searchClient';
|
|
4
4
|
export * from '../model';
|
|
5
|
-
export declare function searchClient(appId: string, apiKey: string, options?:
|
|
5
|
+
export declare function searchClient(appId: string, apiKey: string, options?: ClientOptions): SearchClient;
|
|
6
6
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../packages/client-search/builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../packages/client-search/builds/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAY5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,cAAc,UAAU,CAAC;AAEzB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CA8Bd"}
|
package/dist/builds/node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ClientOptions } from '@algolia/client-common';
|
|
2
2
|
import type { SearchClient } from '../src/searchClient';
|
|
3
3
|
export { apiClientVersion, SearchClient } from '../src/searchClient';
|
|
4
4
|
export * from '../model';
|
|
5
|
-
export declare function searchClient(appId: string, apiKey: string, options?:
|
|
5
|
+
export declare function searchClient(appId: string, apiKey: string, options?: ClientOptions): SearchClient;
|
|
6
6
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../packages/client-search/builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../packages/client-search/builds/node.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAW5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,cAAc,UAAU,CAAC;AAEzB,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,aAAa,GACtB,YAAY,CAwBd"}
|
|
@@ -6,7 +6,7 @@ var clientCommon = require('@algolia/client-common');
|
|
|
6
6
|
var requesterNodeHttp = require('@algolia/requester-node-http');
|
|
7
7
|
|
|
8
8
|
// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
|
|
9
|
-
const apiClientVersion = '5.0.0-alpha.
|
|
9
|
+
const apiClientVersion = '5.0.0-alpha.4';
|
|
10
10
|
function getDefaultHosts(appId) {
|
|
11
11
|
return [
|
|
12
12
|
{
|
|
@@ -60,6 +60,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
60
60
|
});
|
|
61
61
|
return {
|
|
62
62
|
transporter,
|
|
63
|
+
/**
|
|
64
|
+
* The `appId` currently in use.
|
|
65
|
+
*/
|
|
66
|
+
appId: appIdOption,
|
|
67
|
+
/**
|
|
68
|
+
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
69
|
+
*/
|
|
70
|
+
clearCache() {
|
|
71
|
+
return Promise.all([
|
|
72
|
+
transporter.requestsCache.clear(),
|
|
73
|
+
transporter.responsesCache.clear(),
|
|
74
|
+
]).then(() => undefined);
|
|
75
|
+
},
|
|
63
76
|
/**
|
|
64
77
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
65
78
|
*/
|
|
@@ -76,38 +89,57 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
76
89
|
transporter.algoliaAgent.add({ segment, version });
|
|
77
90
|
},
|
|
78
91
|
/**
|
|
79
|
-
* Helper: Wait for a task to
|
|
92
|
+
* Helper: Wait for a task to be published (completed) for a given `indexName` and `taskID`.
|
|
80
93
|
*
|
|
81
|
-
* @summary
|
|
94
|
+
* @summary Helper method that waits for a task to be published (completed).
|
|
82
95
|
* @param waitForTaskOptions - The waitForTaskOptions object.
|
|
83
96
|
* @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
|
|
84
97
|
* @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
|
|
98
|
+
* @param waitForTaskOptions.maxRetries - The maximum number of retries. 50 by default.
|
|
99
|
+
* @param waitForTaskOptions.timeout - The function to decide how long to wait between retries.
|
|
85
100
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
86
101
|
*/
|
|
87
|
-
waitForTask({ indexName, taskID,
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
waitForTask({ indexName, taskID, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
|
|
103
|
+
let retryCount = 0;
|
|
104
|
+
return clientCommon.createIterablePromise({
|
|
90
105
|
func: () => this.getTask({ indexName, taskID }, requestOptions),
|
|
91
106
|
validate: (response) => response.status === 'published',
|
|
107
|
+
aggregator: () => (retryCount += 1),
|
|
108
|
+
error: {
|
|
109
|
+
validate: () => retryCount >= maxRetries,
|
|
110
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
|
|
111
|
+
},
|
|
112
|
+
timeout: () => timeout(retryCount),
|
|
92
113
|
});
|
|
93
114
|
},
|
|
94
115
|
/**
|
|
95
116
|
* Helper: Wait for an API key to be added, updated or deleted based on a given `operation`.
|
|
96
117
|
*
|
|
97
|
-
* @summary
|
|
118
|
+
* @summary Helper method that waits for an API key task to be processed.
|
|
98
119
|
* @param waitForApiKeyOptions - The waitForApiKeyOptions object.
|
|
99
120
|
* @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
|
|
100
121
|
* @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
|
|
101
122
|
* @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
|
|
123
|
+
* @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 50 by default.
|
|
124
|
+
* @param waitForApiKeyOptions.timeout - The function to decide how long to wait between retries.
|
|
102
125
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
|
|
103
126
|
*/
|
|
104
|
-
waitForApiKey({ operation, key, apiKey,
|
|
127
|
+
waitForApiKey({ operation, key, apiKey, maxRetries = 50, timeout = (retryCount) => Math.min(retryCount * 200, 5000), }, requestOptions) {
|
|
128
|
+
let retryCount = 0;
|
|
129
|
+
const baseIteratorOptions = {
|
|
130
|
+
aggregator: () => (retryCount += 1),
|
|
131
|
+
error: {
|
|
132
|
+
validate: () => retryCount >= maxRetries,
|
|
133
|
+
message: () => `The maximum number of retries exceeded. (${retryCount}/${maxRetries})`,
|
|
134
|
+
},
|
|
135
|
+
timeout: () => timeout(retryCount),
|
|
136
|
+
};
|
|
105
137
|
if (operation === 'update') {
|
|
106
138
|
if (!apiKey) {
|
|
107
139
|
throw new Error('`apiKey` is required when waiting for an `update` operation.');
|
|
108
140
|
}
|
|
109
|
-
return clientCommon.
|
|
110
|
-
...
|
|
141
|
+
return clientCommon.createIterablePromise({
|
|
142
|
+
...baseIteratorOptions,
|
|
111
143
|
func: () => this.getApiKey({ key }, requestOptions),
|
|
112
144
|
validate: (response) => {
|
|
113
145
|
for (const field of Object.keys(apiKey)) {
|
|
@@ -125,12 +157,99 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
125
157
|
},
|
|
126
158
|
});
|
|
127
159
|
}
|
|
128
|
-
return clientCommon.
|
|
129
|
-
...
|
|
160
|
+
return clientCommon.createIterablePromise({
|
|
161
|
+
...baseIteratorOptions,
|
|
130
162
|
func: () => this.getApiKey({ key }, requestOptions).catch((error) => error),
|
|
131
163
|
validate: (error) => operation === 'add' ? error.status !== 404 : error.status === 404,
|
|
132
164
|
});
|
|
133
165
|
},
|
|
166
|
+
/**
|
|
167
|
+
* Helper: Iterate on the `browse` method of the client to allow aggregating objects of an index.
|
|
168
|
+
*
|
|
169
|
+
* @summary Helper method that iterates on the `browse` method.
|
|
170
|
+
* @param browseObjects - The browseObjects object.
|
|
171
|
+
* @param browseObjects.indexName - The index in which to perform the request.
|
|
172
|
+
* @param browseObjects.browseRequest - The `browse` method parameters.
|
|
173
|
+
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
174
|
+
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
175
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
|
|
176
|
+
*/
|
|
177
|
+
browseObjects({ indexName, browseRequest, ...browseObjectsOptions }, requestOptions) {
|
|
178
|
+
return clientCommon.createIterablePromise({
|
|
179
|
+
func: (previousResponse) => {
|
|
180
|
+
return this.browse({
|
|
181
|
+
indexName,
|
|
182
|
+
browseRequest: {
|
|
183
|
+
cursor: previousResponse ? previousResponse.cursor : undefined,
|
|
184
|
+
...browseRequest,
|
|
185
|
+
},
|
|
186
|
+
}, requestOptions);
|
|
187
|
+
},
|
|
188
|
+
validate: (response) => response.cursor === undefined,
|
|
189
|
+
...browseObjectsOptions,
|
|
190
|
+
});
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Helper: Iterate on the `searchRules` method of the client to allow aggregating rules of an index.
|
|
194
|
+
*
|
|
195
|
+
* @summary Helper method that iterates on the `searchRules` method.
|
|
196
|
+
* @param browseObjects - The browseObjects object.
|
|
197
|
+
* @param browseObjects.indexName - The index in which to perform the request.
|
|
198
|
+
* @param browseObjects.searchRulesParams - The `searchRules` method parameters.
|
|
199
|
+
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
200
|
+
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
201
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
|
|
202
|
+
*/
|
|
203
|
+
browseRules({ indexName, searchRulesParams, ...browseRulesOptions }, requestOptions) {
|
|
204
|
+
const params = {
|
|
205
|
+
hitsPerPage: 1000,
|
|
206
|
+
...searchRulesParams,
|
|
207
|
+
};
|
|
208
|
+
return clientCommon.createIterablePromise({
|
|
209
|
+
func: (previousResponse) => {
|
|
210
|
+
return this.searchRules({
|
|
211
|
+
indexName,
|
|
212
|
+
searchRulesParams: {
|
|
213
|
+
...params,
|
|
214
|
+
page: previousResponse
|
|
215
|
+
? previousResponse.page + 1
|
|
216
|
+
: params.page || 0,
|
|
217
|
+
},
|
|
218
|
+
}, requestOptions);
|
|
219
|
+
},
|
|
220
|
+
validate: (response) => response.nbHits < params.hitsPerPage,
|
|
221
|
+
...browseRulesOptions,
|
|
222
|
+
});
|
|
223
|
+
},
|
|
224
|
+
/**
|
|
225
|
+
* Helper: Iterate on the `searchSynonyms` method of the client to allow aggregating rules of an index.
|
|
226
|
+
*
|
|
227
|
+
* @summary Helper method that iterates on the `searchSynonyms` method.
|
|
228
|
+
* @param browseObjects - The browseObjects object.
|
|
229
|
+
* @param browseObjects.indexName - The index in which to perform the request.
|
|
230
|
+
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
|
|
231
|
+
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
|
|
232
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
|
|
233
|
+
*/
|
|
234
|
+
browseSynonyms({ indexName, validate, aggregator, ...browseSynonymsOptions }, requestOptions) {
|
|
235
|
+
const params = {
|
|
236
|
+
hitsPerPage: 1000,
|
|
237
|
+
...browseSynonymsOptions,
|
|
238
|
+
};
|
|
239
|
+
return clientCommon.createIterablePromise({
|
|
240
|
+
func: (previousResponse) => {
|
|
241
|
+
return this.searchSynonyms({
|
|
242
|
+
...params,
|
|
243
|
+
indexName,
|
|
244
|
+
page: previousResponse
|
|
245
|
+
? previousResponse.page + 1
|
|
246
|
+
: browseSynonymsOptions.page || 0,
|
|
247
|
+
}, requestOptions);
|
|
248
|
+
},
|
|
249
|
+
validate: (response) => response.nbHits < params.hitsPerPage,
|
|
250
|
+
...browseSynonymsOptions,
|
|
251
|
+
});
|
|
252
|
+
},
|
|
134
253
|
/**
|
|
135
254
|
* Add a new API Key with specific permissions/restrictions.
|
|
136
255
|
*
|
|
@@ -824,6 +943,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
824
943
|
if (!getObjectsParams) {
|
|
825
944
|
throw new Error('Parameter `getObjectsParams` is required when calling `getObjects`.');
|
|
826
945
|
}
|
|
946
|
+
if (!getObjectsParams.requests) {
|
|
947
|
+
throw new Error('Parameter `getObjectsParams.requests` is required when calling `getObjects`.');
|
|
948
|
+
}
|
|
827
949
|
const requestPath = '/1/indexes/*/objects';
|
|
828
950
|
const headers = {};
|
|
829
951
|
const queryParameters = {};
|
|
@@ -1127,6 +1249,9 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1127
1249
|
if (!batchParams) {
|
|
1128
1250
|
throw new Error('Parameter `batchParams` is required when calling `multipleBatch`.');
|
|
1129
1251
|
}
|
|
1252
|
+
if (!batchParams.requests) {
|
|
1253
|
+
throw new Error('Parameter `batchParams.requests` is required when calling `multipleBatch`.');
|
|
1254
|
+
}
|
|
1130
1255
|
const requestPath = '/1/indexes/*/batch';
|
|
1131
1256
|
const headers = {};
|
|
1132
1257
|
const queryParameters = {};
|
|
@@ -1180,19 +1305,19 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1180
1305
|
* @param partialUpdateObject - The partialUpdateObject object.
|
|
1181
1306
|
* @param partialUpdateObject.indexName - The index in which to perform the request.
|
|
1182
1307
|
* @param partialUpdateObject.objectID - Unique identifier of an object.
|
|
1183
|
-
* @param partialUpdateObject.
|
|
1308
|
+
* @param partialUpdateObject.attributeToUpdate - List of attributes to update.
|
|
1184
1309
|
* @param partialUpdateObject.createIfNotExists - Creates the record if it does not exist yet.
|
|
1185
1310
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1186
1311
|
*/
|
|
1187
|
-
partialUpdateObject({ indexName, objectID,
|
|
1312
|
+
partialUpdateObject({ indexName, objectID, attributeToUpdate, createIfNotExists, }, requestOptions) {
|
|
1188
1313
|
if (!indexName) {
|
|
1189
1314
|
throw new Error('Parameter `indexName` is required when calling `partialUpdateObject`.');
|
|
1190
1315
|
}
|
|
1191
1316
|
if (!objectID) {
|
|
1192
1317
|
throw new Error('Parameter `objectID` is required when calling `partialUpdateObject`.');
|
|
1193
1318
|
}
|
|
1194
|
-
if (!
|
|
1195
|
-
throw new Error('Parameter `
|
|
1319
|
+
if (!attributeToUpdate) {
|
|
1320
|
+
throw new Error('Parameter `attributeToUpdate` is required when calling `partialUpdateObject`.');
|
|
1196
1321
|
}
|
|
1197
1322
|
const requestPath = '/1/indexes/{indexName}/{objectID}/partial'
|
|
1198
1323
|
.replace('{indexName}', encodeURIComponent(indexName))
|
|
@@ -1207,7 +1332,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1207
1332
|
path: requestPath,
|
|
1208
1333
|
queryParameters,
|
|
1209
1334
|
headers,
|
|
1210
|
-
data:
|
|
1335
|
+
data: attributeToUpdate,
|
|
1211
1336
|
};
|
|
1212
1337
|
return transporter.request(request, requestOptions);
|
|
1213
1338
|
},
|
|
@@ -1645,9 +1770,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1645
1770
|
if (!indexName) {
|
|
1646
1771
|
throw new Error('Parameter `indexName` is required when calling `searchRules`.');
|
|
1647
1772
|
}
|
|
1648
|
-
if (!searchRulesParams) {
|
|
1649
|
-
throw new Error('Parameter `searchRulesParams` is required when calling `searchRules`.');
|
|
1650
|
-
}
|
|
1651
1773
|
const requestPath = '/1/indexes/{indexName}/rules/search'.replace('{indexName}', encodeURIComponent(indexName));
|
|
1652
1774
|
const headers = {};
|
|
1653
1775
|
const queryParameters = {};
|
|
@@ -1656,7 +1778,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1656
1778
|
path: requestPath,
|
|
1657
1779
|
queryParameters,
|
|
1658
1780
|
headers,
|
|
1659
|
-
data: searchRulesParams,
|
|
1781
|
+
data: searchRulesParams ? searchRulesParams : {},
|
|
1660
1782
|
useReadTransporter: true,
|
|
1661
1783
|
cacheable: true,
|
|
1662
1784
|
};
|
|
@@ -1675,9 +1797,6 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1675
1797
|
if (!indexName) {
|
|
1676
1798
|
throw new Error('Parameter `indexName` is required when calling `searchSingleIndex`.');
|
|
1677
1799
|
}
|
|
1678
|
-
if (!searchParams) {
|
|
1679
|
-
throw new Error('Parameter `searchParams` is required when calling `searchSingleIndex`.');
|
|
1680
|
-
}
|
|
1681
1800
|
const requestPath = '/1/indexes/{indexName}/query'.replace('{indexName}', encodeURIComponent(indexName));
|
|
1682
1801
|
const headers = {};
|
|
1683
1802
|
const queryParameters = {};
|
|
@@ -1686,7 +1805,7 @@ function createSearchClient({ appId: appIdOption, apiKey: apiKeyOption, authMode
|
|
|
1686
1805
|
path: requestPath,
|
|
1687
1806
|
queryParameters,
|
|
1688
1807
|
headers,
|
|
1689
|
-
data: searchParams,
|
|
1808
|
+
data: searchParams ? searchParams : {},
|
|
1690
1809
|
useReadTransporter: true,
|
|
1691
1810
|
cacheable: true,
|
|
1692
1811
|
};
|