@algolia/client-query-suggestions 5.0.0-alpha.99 → 5.0.0-beta.10
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 +24 -3
- package/dist/builds/browser.d.ts.map +1 -1
- package/dist/builds/node.d.ts +24 -3
- package/dist/builds/node.d.ts.map +1 -1
- package/dist/client-query-suggestions.cjs +64 -51
- package/dist/client-query-suggestions.esm.browser.js +60 -59
- package/dist/client-query-suggestions.esm.node.js +64 -51
- package/dist/client-query-suggestions.umd.js +2 -2
- package/dist/model/appID.d.ts +7 -0
- package/dist/model/appID.d.ts.map +1 -0
- package/dist/model/clientMethodProps.d.ts +2 -2
- package/dist/model/clientMethodProps.d.ts.map +1 -1
- package/dist/model/{querySuggestionsConfiguration.d.ts → configuration.d.ts} +4 -7
- package/dist/model/configuration.d.ts.map +1 -0
- package/dist/model/configurationResponse.d.ts +7 -0
- package/dist/model/configurationResponse.d.ts.map +1 -0
- package/dist/model/configurationWithIndex.d.ts +6 -0
- package/dist/model/configurationWithIndex.d.ts.map +1 -0
- package/dist/model/getConfigStatus200Response.d.ts +4 -4
- package/dist/model/getLogFile200Response.d.ts +2 -2
- package/dist/model/index.d.ts +4 -5
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/languages.d.ts +1 -1
- package/dist/model/logLevel.d.ts +1 -1
- package/dist/model/sourceIndex.d.ts +4 -13
- package/dist/model/sourceIndex.d.ts.map +1 -1
- package/dist/src/querySuggestionsClient.d.ts +37 -31
- package/dist/src/querySuggestionsClient.d.ts.map +1 -1
- package/model/{baseQuerySuggestionsConfigurationWithIndex.ts → appID.ts} +3 -3
- package/model/clientMethodProps.ts +2 -2
- package/model/{querySuggestionsConfiguration.ts → configuration.ts} +3 -6
- package/model/configurationResponse.ts +9 -0
- package/model/configurationWithIndex.ts +8 -0
- package/model/getConfigStatus200Response.ts +4 -4
- package/model/getLogFile200Response.ts +2 -2
- package/model/index.ts +4 -5
- package/model/languages.ts +1 -1
- package/model/logLevel.ts +1 -1
- package/model/sourceIndex.ts +4 -13
- package/package.json +11 -8
- package/dist/model/baseQuerySuggestionsConfigurationResponse.d.ts +0 -19
- package/dist/model/baseQuerySuggestionsConfigurationResponse.d.ts.map +0 -1
- package/dist/model/baseQuerySuggestionsConfigurationWithIndex.d.ts +0 -7
- package/dist/model/baseQuerySuggestionsConfigurationWithIndex.d.ts.map +0 -1
- package/dist/model/querySuggestionsConfiguration.d.ts.map +0 -1
- package/dist/model/querySuggestionsConfigurationResponse.d.ts +0 -4
- package/dist/model/querySuggestionsConfigurationResponse.d.ts.map +0 -1
- package/dist/model/querySuggestionsConfigurationWithIndex.d.ts +0 -7
- package/dist/model/querySuggestionsConfigurationWithIndex.d.ts.map +0 -1
- package/model/baseQuerySuggestionsConfigurationResponse.ts +0 -23
- package/model/querySuggestionsConfigurationResponse.ts +0 -8
- package/model/querySuggestionsConfigurationWithIndex.ts +0 -10
|
@@ -195,6 +195,14 @@ function createStatefulHost(host, status = 'up') {
|
|
|
195
195
|
};
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
function _defineProperty(e, r, t) {
|
|
199
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
200
|
+
value: t,
|
|
201
|
+
enumerable: !0,
|
|
202
|
+
configurable: !0,
|
|
203
|
+
writable: !0
|
|
204
|
+
}) : e[r] = t, e;
|
|
205
|
+
}
|
|
198
206
|
function _toPrimitive(t, r) {
|
|
199
207
|
if ("object" != typeof t || !t) return t;
|
|
200
208
|
var e = t[Symbol.toPrimitive];
|
|
@@ -207,21 +215,7 @@ function _toPrimitive(t, r) {
|
|
|
207
215
|
}
|
|
208
216
|
function _toPropertyKey(t) {
|
|
209
217
|
var i = _toPrimitive(t, "string");
|
|
210
|
-
return "symbol" == typeof i ? i :
|
|
211
|
-
}
|
|
212
|
-
function _defineProperty(obj, key, value) {
|
|
213
|
-
key = _toPropertyKey(key);
|
|
214
|
-
if (key in obj) {
|
|
215
|
-
Object.defineProperty(obj, key, {
|
|
216
|
-
value: value,
|
|
217
|
-
enumerable: true,
|
|
218
|
-
configurable: true,
|
|
219
|
-
writable: true
|
|
220
|
-
});
|
|
221
|
-
} else {
|
|
222
|
-
obj[key] = value;
|
|
223
|
-
}
|
|
224
|
-
return obj;
|
|
218
|
+
return "symbol" == typeof i ? i : i + "";
|
|
225
219
|
}
|
|
226
220
|
|
|
227
221
|
class AlgoliaError extends Error {
|
|
@@ -243,7 +237,7 @@ class ErrorWithStackTrace extends AlgoliaError {
|
|
|
243
237
|
}
|
|
244
238
|
class RetryError extends ErrorWithStackTrace {
|
|
245
239
|
constructor(stackTrace) {
|
|
246
|
-
super('Unreachable hosts - your application id may be incorrect. If the error persists, please
|
|
240
|
+
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');
|
|
247
241
|
}
|
|
248
242
|
}
|
|
249
243
|
class ApiError extends ErrorWithStackTrace {
|
|
@@ -270,15 +264,14 @@ class DetailedApiError extends ApiError {
|
|
|
270
264
|
}
|
|
271
265
|
function serializeUrl(host, path, queryParameters) {
|
|
272
266
|
const queryParametersAsString = serializeQueryParameters(queryParameters);
|
|
273
|
-
let url = `${host.protocol}://${host.url}/${path.charAt(0) === '/' ? path.
|
|
267
|
+
let url = `${host.protocol}://${host.url}${host.port ? `:${host.port}` : ''}/${path.charAt(0) === '/' ? path.substring(1) : path}`;
|
|
274
268
|
if (queryParametersAsString.length) {
|
|
275
269
|
url += `?${queryParametersAsString}`;
|
|
276
270
|
}
|
|
277
271
|
return url;
|
|
278
272
|
}
|
|
279
273
|
function serializeQueryParameters(parameters) {
|
|
280
|
-
|
|
281
|
-
return Object.keys(parameters).map(key => `${key}=${encodeURIComponent(isObjectOrArray(parameters[key]) ? JSON.stringify(parameters[key]) : parameters[key])}`).join('&');
|
|
274
|
+
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('&');
|
|
282
275
|
}
|
|
283
276
|
function serializeData(request, requestOptions) {
|
|
284
277
|
if (request.method === 'GET' || request.data === undefined && requestOptions.data === undefined) {
|
|
@@ -449,16 +442,13 @@ function createTransporter({
|
|
|
449
442
|
if (host === undefined) {
|
|
450
443
|
throw new RetryError(stackTraceWithoutCredentials(stackTrace));
|
|
451
444
|
}
|
|
452
|
-
let responseTimeout = requestOptions.
|
|
453
|
-
if (responseTimeout === undefined) {
|
|
454
|
-
responseTimeout = isRead ? timeouts.read : timeouts.write;
|
|
455
|
-
}
|
|
445
|
+
let responseTimeout = isRead ? requestOptions.timeouts?.read || timeouts.read : requestOptions.timeouts?.write || timeouts.write;
|
|
456
446
|
const payload = {
|
|
457
447
|
data,
|
|
458
448
|
headers,
|
|
459
449
|
method: request.method,
|
|
460
450
|
url: serializeUrl(host, request.path, queryParameters),
|
|
461
|
-
connectTimeout: getTimeout(timeoutsCount, timeouts.connect),
|
|
451
|
+
connectTimeout: getTimeout(timeoutsCount, requestOptions.timeouts?.connect || timeouts.connect),
|
|
462
452
|
responseTimeout: getTimeout(timeoutsCount, responseTimeout)
|
|
463
453
|
};
|
|
464
454
|
/**
|
|
@@ -686,7 +676,7 @@ function createXhrRequester() {
|
|
|
686
676
|
}
|
|
687
677
|
|
|
688
678
|
// 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.
|
|
689
|
-
const apiClientVersion = '5.0.0-
|
|
679
|
+
const apiClientVersion = '5.0.0-beta.10';
|
|
690
680
|
const REGIONS = ['eu', 'us'];
|
|
691
681
|
function getDefaultHosts(region) {
|
|
692
682
|
const url = 'query-suggestions.{region}.algolia.com'.replace('{region}', region);
|
|
@@ -744,15 +734,17 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
744
734
|
transporter.algoliaAgent.add({ segment, version });
|
|
745
735
|
},
|
|
746
736
|
/**
|
|
747
|
-
*
|
|
737
|
+
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
|
|
738
|
+
*
|
|
739
|
+
* Required API Key ACLs:
|
|
740
|
+
* - editSettings.
|
|
748
741
|
*
|
|
749
|
-
* @
|
|
750
|
-
* @param querySuggestionsConfigurationWithIndex - The querySuggestionsConfigurationWithIndex object.
|
|
742
|
+
* @param configurationWithIndex - The configurationWithIndex object.
|
|
751
743
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
752
744
|
*/
|
|
753
|
-
createConfig(
|
|
754
|
-
if (!
|
|
755
|
-
throw new Error('Parameter `
|
|
745
|
+
createConfig(configurationWithIndex, requestOptions) {
|
|
746
|
+
if (!configurationWithIndex) {
|
|
747
|
+
throw new Error('Parameter `configurationWithIndex` is required when calling `createConfig`.');
|
|
756
748
|
}
|
|
757
749
|
const requestPath = '/1/configs';
|
|
758
750
|
const headers = {};
|
|
@@ -762,14 +754,13 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
762
754
|
path: requestPath,
|
|
763
755
|
queryParameters,
|
|
764
756
|
headers,
|
|
765
|
-
data:
|
|
757
|
+
data: configurationWithIndex,
|
|
766
758
|
};
|
|
767
759
|
return transporter.request(request, requestOptions);
|
|
768
760
|
},
|
|
769
761
|
/**
|
|
770
762
|
* This method allow you to send requests to the Algolia REST API.
|
|
771
763
|
*
|
|
772
|
-
* @summary Send requests to the Algolia REST API.
|
|
773
764
|
* @param customDelete - The customDelete object.
|
|
774
765
|
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
775
766
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
@@ -779,7 +770,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
779
770
|
if (!path) {
|
|
780
771
|
throw new Error('Parameter `path` is required when calling `customDelete`.');
|
|
781
772
|
}
|
|
782
|
-
const requestPath = '/
|
|
773
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
783
774
|
const headers = {};
|
|
784
775
|
const queryParameters = parameters ? parameters : {};
|
|
785
776
|
const request = {
|
|
@@ -793,7 +784,6 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
793
784
|
/**
|
|
794
785
|
* This method allow you to send requests to the Algolia REST API.
|
|
795
786
|
*
|
|
796
|
-
* @summary Send requests to the Algolia REST API.
|
|
797
787
|
* @param customGet - The customGet object.
|
|
798
788
|
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
799
789
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
@@ -803,7 +793,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
803
793
|
if (!path) {
|
|
804
794
|
throw new Error('Parameter `path` is required when calling `customGet`.');
|
|
805
795
|
}
|
|
806
|
-
const requestPath = '/
|
|
796
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
807
797
|
const headers = {};
|
|
808
798
|
const queryParameters = parameters ? parameters : {};
|
|
809
799
|
const request = {
|
|
@@ -817,7 +807,6 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
817
807
|
/**
|
|
818
808
|
* This method allow you to send requests to the Algolia REST API.
|
|
819
809
|
*
|
|
820
|
-
* @summary Send requests to the Algolia REST API.
|
|
821
810
|
* @param customPost - The customPost object.
|
|
822
811
|
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
823
812
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
@@ -828,7 +817,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
828
817
|
if (!path) {
|
|
829
818
|
throw new Error('Parameter `path` is required when calling `customPost`.');
|
|
830
819
|
}
|
|
831
|
-
const requestPath = '/
|
|
820
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
832
821
|
const headers = {};
|
|
833
822
|
const queryParameters = parameters ? parameters : {};
|
|
834
823
|
const request = {
|
|
@@ -843,7 +832,6 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
843
832
|
/**
|
|
844
833
|
* This method allow you to send requests to the Algolia REST API.
|
|
845
834
|
*
|
|
846
|
-
* @summary Send requests to the Algolia REST API.
|
|
847
835
|
* @param customPut - The customPut object.
|
|
848
836
|
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
849
837
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
@@ -854,7 +842,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
854
842
|
if (!path) {
|
|
855
843
|
throw new Error('Parameter `path` is required when calling `customPut`.');
|
|
856
844
|
}
|
|
857
|
-
const requestPath = '/
|
|
845
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
858
846
|
const headers = {};
|
|
859
847
|
const queryParameters = parameters ? parameters : {};
|
|
860
848
|
const request = {
|
|
@@ -867,9 +855,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
867
855
|
return transporter.request(request, requestOptions);
|
|
868
856
|
},
|
|
869
857
|
/**
|
|
870
|
-
*
|
|
858
|
+
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the [Delete an index](/specs/search#tag/Indices/operation/deleteIndex) operation.
|
|
859
|
+
*
|
|
860
|
+
* Required API Key ACLs:
|
|
861
|
+
* - editSettings.
|
|
871
862
|
*
|
|
872
|
-
* @summary Delete a configuration.
|
|
873
863
|
* @param deleteConfig - The deleteConfig object.
|
|
874
864
|
* @param deleteConfig.indexName - Query Suggestions index name.
|
|
875
865
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -890,9 +880,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
890
880
|
return transporter.request(request, requestOptions);
|
|
891
881
|
},
|
|
892
882
|
/**
|
|
893
|
-
*
|
|
883
|
+
* Retrieves all Query Suggestions configurations of your Algolia application.
|
|
884
|
+
*
|
|
885
|
+
* Required API Key ACLs:
|
|
886
|
+
* - settings.
|
|
894
887
|
*
|
|
895
|
-
* @summary List configurations.
|
|
896
888
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
897
889
|
*/
|
|
898
890
|
getAllConfigs(requestOptions) {
|
|
@@ -908,9 +900,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
908
900
|
return transporter.request(request, requestOptions);
|
|
909
901
|
},
|
|
910
902
|
/**
|
|
911
|
-
*
|
|
903
|
+
* Retrieves a single Query Suggestions configuration by its index name.
|
|
904
|
+
*
|
|
905
|
+
* Required API Key ACLs:
|
|
906
|
+
* - settings.
|
|
912
907
|
*
|
|
913
|
-
* @summary Get a configuration.
|
|
914
908
|
* @param getConfig - The getConfig object.
|
|
915
909
|
* @param getConfig.indexName - Query Suggestions index name.
|
|
916
910
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -931,9 +925,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
931
925
|
return transporter.request(request, requestOptions);
|
|
932
926
|
},
|
|
933
927
|
/**
|
|
934
|
-
*
|
|
928
|
+
* Reports the status of a Query Suggestions index.
|
|
929
|
+
*
|
|
930
|
+
* Required API Key ACLs:
|
|
931
|
+
* - settings.
|
|
935
932
|
*
|
|
936
|
-
* @summary Get configuration status.
|
|
937
933
|
* @param getConfigStatus - The getConfigStatus object.
|
|
938
934
|
* @param getConfigStatus.indexName - Query Suggestions index name.
|
|
939
935
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -954,9 +950,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
954
950
|
return transporter.request(request, requestOptions);
|
|
955
951
|
},
|
|
956
952
|
/**
|
|
957
|
-
*
|
|
953
|
+
* Retrieves the logs for a single Query Suggestions index.
|
|
954
|
+
*
|
|
955
|
+
* Required API Key ACLs:
|
|
956
|
+
* - settings.
|
|
958
957
|
*
|
|
959
|
-
* @summary Get logs.
|
|
960
958
|
* @param getLogFile - The getLogFile object.
|
|
961
959
|
* @param getLogFile.indexName - Query Suggestions index name.
|
|
962
960
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -977,23 +975,25 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
977
975
|
return transporter.request(request, requestOptions);
|
|
978
976
|
},
|
|
979
977
|
/**
|
|
980
|
-
*
|
|
978
|
+
* Updates a QuerySuggestions configuration.
|
|
979
|
+
*
|
|
980
|
+
* Required API Key ACLs:
|
|
981
|
+
* - editSettings.
|
|
981
982
|
*
|
|
982
|
-
* @summary Update a configuration.
|
|
983
983
|
* @param updateConfig - The updateConfig object.
|
|
984
984
|
* @param updateConfig.indexName - Query Suggestions index name.
|
|
985
|
-
* @param updateConfig.
|
|
985
|
+
* @param updateConfig.configuration - The configuration object.
|
|
986
986
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
987
987
|
*/
|
|
988
|
-
updateConfig({ indexName,
|
|
988
|
+
updateConfig({ indexName, configuration }, requestOptions) {
|
|
989
989
|
if (!indexName) {
|
|
990
990
|
throw new Error('Parameter `indexName` is required when calling `updateConfig`.');
|
|
991
991
|
}
|
|
992
|
-
if (!
|
|
993
|
-
throw new Error('Parameter `
|
|
992
|
+
if (!configuration) {
|
|
993
|
+
throw new Error('Parameter `configuration` is required when calling `updateConfig`.');
|
|
994
994
|
}
|
|
995
|
-
if (!
|
|
996
|
-
throw new Error('Parameter `
|
|
995
|
+
if (!configuration.sourceIndices) {
|
|
996
|
+
throw new Error('Parameter `configuration.sourceIndices` is required when calling `updateConfig`.');
|
|
997
997
|
}
|
|
998
998
|
const requestPath = '/1/configs/{indexName}'.replace('{indexName}', encodeURIComponent(indexName));
|
|
999
999
|
const headers = {};
|
|
@@ -1003,7 +1003,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
1003
1003
|
path: requestPath,
|
|
1004
1004
|
queryParameters,
|
|
1005
1005
|
headers,
|
|
1006
|
-
data:
|
|
1006
|
+
data: configuration,
|
|
1007
1007
|
};
|
|
1008
1008
|
return transporter.request(request, requestOptions);
|
|
1009
1009
|
},
|
|
@@ -1011,6 +1011,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
1011
1011
|
}
|
|
1012
1012
|
|
|
1013
1013
|
// 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.
|
|
1014
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
1014
1015
|
function querySuggestionsClient(appId, apiKey, region, options) {
|
|
1015
1016
|
if (!appId || typeof appId !== 'string') {
|
|
1016
1017
|
throw new Error('`appId` is missing.');
|
|
@@ -2,7 +2,7 @@ import { createAuth, createTransporter, getAlgoliaAgent, DEFAULT_CONNECT_TIMEOUT
|
|
|
2
2
|
import { createHttpRequester } from '@algolia/requester-node-http';
|
|
3
3
|
|
|
4
4
|
// 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.
|
|
5
|
-
const apiClientVersion = '5.0.0-
|
|
5
|
+
const apiClientVersion = '5.0.0-beta.10';
|
|
6
6
|
const REGIONS = ['eu', 'us'];
|
|
7
7
|
function getDefaultHosts(region) {
|
|
8
8
|
const url = 'query-suggestions.{region}.algolia.com'.replace('{region}', region);
|
|
@@ -60,15 +60,17 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
60
60
|
transporter.algoliaAgent.add({ segment, version });
|
|
61
61
|
},
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
|
|
64
64
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
65
|
+
* Required API Key ACLs:
|
|
66
|
+
* - editSettings.
|
|
67
|
+
*
|
|
68
|
+
* @param configurationWithIndex - The configurationWithIndex object.
|
|
67
69
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
68
70
|
*/
|
|
69
|
-
createConfig(
|
|
70
|
-
if (!
|
|
71
|
-
throw new Error('Parameter `
|
|
71
|
+
createConfig(configurationWithIndex, requestOptions) {
|
|
72
|
+
if (!configurationWithIndex) {
|
|
73
|
+
throw new Error('Parameter `configurationWithIndex` is required when calling `createConfig`.');
|
|
72
74
|
}
|
|
73
75
|
const requestPath = '/1/configs';
|
|
74
76
|
const headers = {};
|
|
@@ -78,14 +80,13 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
78
80
|
path: requestPath,
|
|
79
81
|
queryParameters,
|
|
80
82
|
headers,
|
|
81
|
-
data:
|
|
83
|
+
data: configurationWithIndex,
|
|
82
84
|
};
|
|
83
85
|
return transporter.request(request, requestOptions);
|
|
84
86
|
},
|
|
85
87
|
/**
|
|
86
88
|
* This method allow you to send requests to the Algolia REST API.
|
|
87
89
|
*
|
|
88
|
-
* @summary Send requests to the Algolia REST API.
|
|
89
90
|
* @param customDelete - The customDelete object.
|
|
90
91
|
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
91
92
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
@@ -95,7 +96,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
95
96
|
if (!path) {
|
|
96
97
|
throw new Error('Parameter `path` is required when calling `customDelete`.');
|
|
97
98
|
}
|
|
98
|
-
const requestPath = '/
|
|
99
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
99
100
|
const headers = {};
|
|
100
101
|
const queryParameters = parameters ? parameters : {};
|
|
101
102
|
const request = {
|
|
@@ -109,7 +110,6 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
109
110
|
/**
|
|
110
111
|
* This method allow you to send requests to the Algolia REST API.
|
|
111
112
|
*
|
|
112
|
-
* @summary Send requests to the Algolia REST API.
|
|
113
113
|
* @param customGet - The customGet object.
|
|
114
114
|
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
115
115
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
@@ -119,7 +119,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
119
119
|
if (!path) {
|
|
120
120
|
throw new Error('Parameter `path` is required when calling `customGet`.');
|
|
121
121
|
}
|
|
122
|
-
const requestPath = '/
|
|
122
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
123
123
|
const headers = {};
|
|
124
124
|
const queryParameters = parameters ? parameters : {};
|
|
125
125
|
const request = {
|
|
@@ -133,7 +133,6 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
133
133
|
/**
|
|
134
134
|
* This method allow you to send requests to the Algolia REST API.
|
|
135
135
|
*
|
|
136
|
-
* @summary Send requests to the Algolia REST API.
|
|
137
136
|
* @param customPost - The customPost object.
|
|
138
137
|
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
139
138
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
@@ -144,7 +143,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
144
143
|
if (!path) {
|
|
145
144
|
throw new Error('Parameter `path` is required when calling `customPost`.');
|
|
146
145
|
}
|
|
147
|
-
const requestPath = '/
|
|
146
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
148
147
|
const headers = {};
|
|
149
148
|
const queryParameters = parameters ? parameters : {};
|
|
150
149
|
const request = {
|
|
@@ -159,7 +158,6 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
159
158
|
/**
|
|
160
159
|
* This method allow you to send requests to the Algolia REST API.
|
|
161
160
|
*
|
|
162
|
-
* @summary Send requests to the Algolia REST API.
|
|
163
161
|
* @param customPut - The customPut object.
|
|
164
162
|
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
165
163
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
@@ -170,7 +168,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
170
168
|
if (!path) {
|
|
171
169
|
throw new Error('Parameter `path` is required when calling `customPut`.');
|
|
172
170
|
}
|
|
173
|
-
const requestPath = '/
|
|
171
|
+
const requestPath = '/{path}'.replace('{path}', path);
|
|
174
172
|
const headers = {};
|
|
175
173
|
const queryParameters = parameters ? parameters : {};
|
|
176
174
|
const request = {
|
|
@@ -183,9 +181,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
183
181
|
return transporter.request(request, requestOptions);
|
|
184
182
|
},
|
|
185
183
|
/**
|
|
186
|
-
*
|
|
184
|
+
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the [Delete an index](/specs/search#tag/Indices/operation/deleteIndex) operation.
|
|
185
|
+
*
|
|
186
|
+
* Required API Key ACLs:
|
|
187
|
+
* - editSettings.
|
|
187
188
|
*
|
|
188
|
-
* @summary Delete a configuration.
|
|
189
189
|
* @param deleteConfig - The deleteConfig object.
|
|
190
190
|
* @param deleteConfig.indexName - Query Suggestions index name.
|
|
191
191
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -206,9 +206,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
206
206
|
return transporter.request(request, requestOptions);
|
|
207
207
|
},
|
|
208
208
|
/**
|
|
209
|
-
*
|
|
209
|
+
* Retrieves all Query Suggestions configurations of your Algolia application.
|
|
210
|
+
*
|
|
211
|
+
* Required API Key ACLs:
|
|
212
|
+
* - settings.
|
|
210
213
|
*
|
|
211
|
-
* @summary List configurations.
|
|
212
214
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
213
215
|
*/
|
|
214
216
|
getAllConfigs(requestOptions) {
|
|
@@ -224,9 +226,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
224
226
|
return transporter.request(request, requestOptions);
|
|
225
227
|
},
|
|
226
228
|
/**
|
|
227
|
-
*
|
|
229
|
+
* Retrieves a single Query Suggestions configuration by its index name.
|
|
230
|
+
*
|
|
231
|
+
* Required API Key ACLs:
|
|
232
|
+
* - settings.
|
|
228
233
|
*
|
|
229
|
-
* @summary Get a configuration.
|
|
230
234
|
* @param getConfig - The getConfig object.
|
|
231
235
|
* @param getConfig.indexName - Query Suggestions index name.
|
|
232
236
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -247,9 +251,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
247
251
|
return transporter.request(request, requestOptions);
|
|
248
252
|
},
|
|
249
253
|
/**
|
|
250
|
-
*
|
|
254
|
+
* Reports the status of a Query Suggestions index.
|
|
255
|
+
*
|
|
256
|
+
* Required API Key ACLs:
|
|
257
|
+
* - settings.
|
|
251
258
|
*
|
|
252
|
-
* @summary Get configuration status.
|
|
253
259
|
* @param getConfigStatus - The getConfigStatus object.
|
|
254
260
|
* @param getConfigStatus.indexName - Query Suggestions index name.
|
|
255
261
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -270,9 +276,11 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
270
276
|
return transporter.request(request, requestOptions);
|
|
271
277
|
},
|
|
272
278
|
/**
|
|
273
|
-
*
|
|
279
|
+
* Retrieves the logs for a single Query Suggestions index.
|
|
280
|
+
*
|
|
281
|
+
* Required API Key ACLs:
|
|
282
|
+
* - settings.
|
|
274
283
|
*
|
|
275
|
-
* @summary Get logs.
|
|
276
284
|
* @param getLogFile - The getLogFile object.
|
|
277
285
|
* @param getLogFile.indexName - Query Suggestions index name.
|
|
278
286
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -293,23 +301,25 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
293
301
|
return transporter.request(request, requestOptions);
|
|
294
302
|
},
|
|
295
303
|
/**
|
|
296
|
-
*
|
|
304
|
+
* Updates a QuerySuggestions configuration.
|
|
305
|
+
*
|
|
306
|
+
* Required API Key ACLs:
|
|
307
|
+
* - editSettings.
|
|
297
308
|
*
|
|
298
|
-
* @summary Update a configuration.
|
|
299
309
|
* @param updateConfig - The updateConfig object.
|
|
300
310
|
* @param updateConfig.indexName - Query Suggestions index name.
|
|
301
|
-
* @param updateConfig.
|
|
311
|
+
* @param updateConfig.configuration - The configuration object.
|
|
302
312
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
303
313
|
*/
|
|
304
|
-
updateConfig({ indexName,
|
|
314
|
+
updateConfig({ indexName, configuration }, requestOptions) {
|
|
305
315
|
if (!indexName) {
|
|
306
316
|
throw new Error('Parameter `indexName` is required when calling `updateConfig`.');
|
|
307
317
|
}
|
|
308
|
-
if (!
|
|
309
|
-
throw new Error('Parameter `
|
|
318
|
+
if (!configuration) {
|
|
319
|
+
throw new Error('Parameter `configuration` is required when calling `updateConfig`.');
|
|
310
320
|
}
|
|
311
|
-
if (!
|
|
312
|
-
throw new Error('Parameter `
|
|
321
|
+
if (!configuration.sourceIndices) {
|
|
322
|
+
throw new Error('Parameter `configuration.sourceIndices` is required when calling `updateConfig`.');
|
|
313
323
|
}
|
|
314
324
|
const requestPath = '/1/configs/{indexName}'.replace('{indexName}', encodeURIComponent(indexName));
|
|
315
325
|
const headers = {};
|
|
@@ -319,7 +329,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
319
329
|
path: requestPath,
|
|
320
330
|
queryParameters,
|
|
321
331
|
headers,
|
|
322
|
-
data:
|
|
332
|
+
data: configuration,
|
|
323
333
|
};
|
|
324
334
|
return transporter.request(request, requestOptions);
|
|
325
335
|
},
|
|
@@ -327,6 +337,7 @@ function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption
|
|
|
327
337
|
}
|
|
328
338
|
|
|
329
339
|
// 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.
|
|
340
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
330
341
|
function querySuggestionsClient(appId, apiKey, region, options) {
|
|
331
342
|
if (!appId || typeof appId !== 'string') {
|
|
332
343
|
throw new Error('`appId` is missing.');
|
|
@@ -338,22 +349,24 @@ function querySuggestionsClient(appId, apiKey, region, options) {
|
|
|
338
349
|
(region && (typeof region !== 'string' || !REGIONS.includes(region)))) {
|
|
339
350
|
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(', ')}`);
|
|
340
351
|
}
|
|
341
|
-
return
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
352
|
+
return {
|
|
353
|
+
...createQuerySuggestionsClient({
|
|
354
|
+
appId,
|
|
355
|
+
apiKey,
|
|
356
|
+
region,
|
|
357
|
+
timeouts: {
|
|
358
|
+
connect: DEFAULT_CONNECT_TIMEOUT_NODE,
|
|
359
|
+
read: DEFAULT_READ_TIMEOUT_NODE,
|
|
360
|
+
write: DEFAULT_WRITE_TIMEOUT_NODE,
|
|
361
|
+
},
|
|
362
|
+
requester: createHttpRequester(),
|
|
363
|
+
algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
|
|
364
|
+
responsesCache: createNullCache(),
|
|
365
|
+
requestsCache: createNullCache(),
|
|
366
|
+
hostsCache: createMemoryCache(),
|
|
367
|
+
...options,
|
|
368
|
+
}),
|
|
369
|
+
};
|
|
357
370
|
}
|
|
358
371
|
|
|
359
372
|
export { apiClientVersion, querySuggestionsClient };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! client-query-suggestions.umd.js | 5.0.0-
|
|
2
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-query-suggestions"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function s(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function a(){return JSON.parse(s().getItem(r)||"{}")}function n(e){s().setItem(r,JSON.stringify(e))}return{get:(t,r,s={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=a(),s=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(n(s),!t)return;n(Object.fromEntries(Object.entries(s).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),a()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||s.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const n=a();return n[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},s().setItem(r,JSON.stringify(n)),t})),delete:e=>Promise.resolve().then((()=>{const t=a();delete t[JSON.stringify(e)],s().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{s().removeItem(r)}))}}function r(e){const t=[...e.caches],s=t.shift();return void 0===s?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,n={miss:()=>Promise.resolve()})=>s.get(e,a,n).catch((()=>r({caches:t}).get(e,a,n))),set:(e,a)=>s.set(e,a).catch((()=>r({caches:t}).set(e,a))),delete:e=>s.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>s.clear().catch((()=>r({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,s,a={miss:()=>Promise.resolve()}){const n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);const o=s();return o.then((e=>a.miss(e))).then((()=>o))},set:(r,s)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(s):s,Promise.resolve(s)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const a=12e4;function n(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>a},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=a}}}function o(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function i(e,t,r){return(t=o(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class u extends Error{constructor(e,t){super(e),i(this,"name","AlgoliaError"),t&&(this.name=t)}}class c extends u{constructor(e,t,r){super(e,r),i(this,"stackTrace",void 0),this.stackTrace=t}}class l extends c{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please create a ticket at https://support.algolia.com/ sharing steps we can use to reproduce the issue.",e,"RetryError")}}class d extends c{constructor(e,t,r,s="ApiError"){super(e,r,s),i(this,"status",void 0),this.status=t}}class m extends u{constructor(e,t){super(e,"DeserializationError"),i(this,"response",void 0),this.response=t}}class h extends d{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),i(this,"error",void 0),this.error=r}}function g(e,t,r){const s=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${encodeURIComponent(t(e[r])?JSON.stringify(e[r]):e[r])}`)).join("&")}(r);let a=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return s.length&&(a+=`?${s}`),a}function p(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function f({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:s,algoliaAgent:a,timeouts:o,requester:i,requestsCache:u,responsesCache:c}){async function f(u,c,f=!0){const y=[],P=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(u,c),w=function(e,t,r){const s={Accept:"application/json",...e,...t,...r},a={};return Object.keys(s).forEach((e=>{const t=s[e];a[e.toLowerCase()]=t})),a}(r,u.headers,c.headers),q="GET"===u.method?{...u.data,...c.data}:{},v={...s,...u.queryParameters,...q};if(a.value&&(v["x-algolia-agent"]=a.value),c&&c.queryParameters)for(const e of Object.keys(c.queryParameters))c.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(c.queryParameters[e])?v[e]=c.queryParameters[e].toString():v[e]=c.queryParameters[e];let b=0;const T=async(e,r)=>{const s=e.pop();if(void 0===s)throw new l(function(e){return e.map((e=>p(e)))}(y));let a=c.timeout;void 0===a&&(a=f?o.read:o.write);const q={data:P,headers:w,method:u.method,url:g(s,u.path,v),connectTimeout:r(b,o.connect),responseTimeout:r(b,a)},O=t=>{const r={request:q,response:t,host:s,triesLeft:e.length};return y.push(r),r},E=await i.send(q);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const a=O(E);return E.isTimedOut&&b++,console.log("Retryable failure",p(a)),await t.set(s,n(s,E.isTimedOut?"timed out":"down")),T(e,r)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e)}}(E);throw O(E),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new h(s.message,t,s.error,r):new d(s.message,t,r)}catch(e){}return new d(e,t,r)}(E,y)},O=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),E=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(n(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),o=[...s,...a];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(O);return T([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:t,requester:i,timeouts:o,algoliaAgent:a,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){const a=e.useReadTransporter||"GET"===e.method;if(!a)return f(e,t,a);const n=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return n();const o={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return c.get(o,(()=>u.get(o,(()=>u.set(o,n()).then((e=>Promise.all([u.delete(o),e])),(e=>Promise.all([u.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>c.set(o,e)})},requestsCache:u,responsesCache:c}}function y({algoliaAgents:e,client:t,version:r}){const s=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>s.add(e))),s}const P="5.0.0-alpha.99",w=["eu","us"];e.apiClientVersion=P,e.querySuggestionsClient=function(e,a,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(!n||n&&("string"!=typeof n||!w.includes(n)))throw new Error(`\`region\` is required and must be one of the following: ${w.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...n}){const o=function(e,t,r="WithinHeaders"){const s={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?s:{},queryParameters:()=>"WithinQueryParameters"===r?s:{}}}(e,t,r),i=f({hosts:(u=a,[{url:"query-suggestions.{region}.algolia.com".replace("{region}",u),accept:"readWrite",protocol:"https"}]),...n,algoliaAgent:y({algoliaAgents:s,client:"QuerySuggestions",version:P}),baseHeaders:{"content-type":"text/plain",...o.headers(),...n.baseHeaders},baseQueryParameters:{...o.queryParameters(),...n.baseQueryParameters}});var u;return{transporter:i,appId:e,clearCache:()=>Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then((()=>{})),get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(e,t){i.algoliaAgent.add({segment:e,version:t})},createConfig(e,t){if(!e)throw new Error("Parameter `querySuggestionsConfigurationWithIndex` is required when calling `createConfig`.");const r={method:"POST",path:"/1/configs",queryParameters:{},headers:{},data:e};return i.request(r,t)},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const s={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const s={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customPost({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const a={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},customPut({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const a={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},deleteConfig({indexName:e},t){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");const r={method:"DELETE",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},getAllConfigs(e){const t={method:"GET",path:"/1/configs",queryParameters:{},headers:{}};return i.request(t,e)},getConfig({indexName:e},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getConfig`.");const r={method:"GET",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},getConfigStatus({indexName:e},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");const r={method:"GET",path:"/1/configs/{indexName}/status".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},getLogFile({indexName:e},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getLogFile`.");const r={method:"GET",path:"/1/logs/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},updateConfig({indexName:e,querySuggestionsConfiguration:t},r){if(!e)throw new Error("Parameter `indexName` is required when calling `updateConfig`.");if(!t)throw new Error("Parameter `querySuggestionsConfiguration` is required when calling `updateConfig`.");if(!t.sourceIndices)throw new Error("Parameter `querySuggestionsConfiguration.sourceIndices` is required when calling `updateConfig`.");const s={method:"PUT",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return i.request(s,r)}}}({appId:e,apiKey:a,region:n,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const s=(e,s)=>setTimeout((()=>{r.abort(),t({status:0,content:s,isTimedOut:!0})}),e),a=s(e.connectTimeout,"Connection timeout");let n;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:r({caches:[t({key:`${P}-${e}`}),s()]}),...o})}}));
|
|
1
|
+
/*! client-query-suggestions.umd.js | 5.0.0-beta.10 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
|
|
2
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-query-suggestions"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function s(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function a(){return JSON.parse(s().getItem(r)||"{}")}function n(e){s().setItem(r,JSON.stringify(e))}return{get:(t,r,s={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=a(),s=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(n(s),!t)return;n(Object.fromEntries(Object.entries(s).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),a()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||s.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const n=a();return n[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},s().setItem(r,JSON.stringify(n)),t})),delete:e=>Promise.resolve().then((()=>{const t=a();delete t[JSON.stringify(e)],s().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{s().removeItem(r)}))}}function r(e){const t=[...e.caches],s=t.shift();return void 0===s?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,n={miss:()=>Promise.resolve()})=>s.get(e,a,n).catch((()=>r({caches:t}).get(e,a,n))),set:(e,a)=>s.set(e,a).catch((()=>r({caches:t}).set(e,a))),delete:e=>s.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>s.clear().catch((()=>r({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,s,a={miss:()=>Promise.resolve()}){const n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);const o=s();return o.then((e=>a.miss(e))).then((()=>o))},set:(r,s)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(s):s,Promise.resolve(s)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const a=12e4;function n(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>a},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=a}}}function o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class i extends Error{constructor(e,t){super(e),o(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends i{constructor(e,t,r){super(e,r),o(this,"stackTrace",void 0),this.stackTrace=t}}class c extends u{constructor(e){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.",e,"RetryError")}}class l extends u{constructor(e,t,r,s="ApiError"){super(e,r,s),o(this,"status",void 0),this.status=t}}class m extends i{constructor(e,t){super(e,"DeserializationError"),o(this,"response",void 0),this.response=t}}class d extends l{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),o(this,"error",void 0),this.error=r}}function h(e,t,r){const s=(a=r,Object.keys(a).filter((e=>void 0!==a[e])).sort().map((e=>`${e}=${encodeURIComponent("[object Array]"===Object.prototype.toString.call(a[e])?a[e].join(","):a[e]).replaceAll("+","%20")}`)).join("&"));var a;let n=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${"/"===t.charAt(0)?t.substring(1):t}`;return s.length&&(n+=`?${s}`),n}function p(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function g({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:s,algoliaAgent:a,timeouts:o,requester:i,requestsCache:u,responsesCache:g}){async function f(u,g,f=!0){const y=[],P=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(u,g),w=function(e,t,r){const s={Accept:"application/json",...e,...t,...r},a={};return Object.keys(s).forEach((e=>{const t=s[e];a[e.toLowerCase()]=t})),a}(r,u.headers,g.headers),q="GET"===u.method?{...u.data,...g.data}:{},v={...s,...u.queryParameters,...q};if(a.value&&(v["x-algolia-agent"]=a.value),g&&g.queryParameters)for(const e of Object.keys(g.queryParameters))g.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(g.queryParameters[e])?v[e]=g.queryParameters[e].toString():v[e]=g.queryParameters[e];let b=0;const T=async(e,r)=>{const s=e.pop();if(void 0===s)throw new c(function(e){return e.map((e=>p(e)))}(y));let a=f?g.timeouts?.read||o.read:g.timeouts?.write||o.write;const q={data:P,headers:w,method:u.method,url:h(s,u.path,v),connectTimeout:r(b,g.timeouts?.connect||o.connect),responseTimeout:r(b,a)},E=t=>{const r={request:q,response:t,host:s,triesLeft:e.length};return y.push(r),r},O=await i.send(q);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&!~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(O)){const a=E(O);return O.isTimedOut&&b++,console.log("Retryable failure",p(a)),await t.set(s,n(s,O.isTimedOut?"timed out":"down")),T(e,r)}if(function({status:e}){return 2==~~(e/100)}(O))return function(e){try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e)}}(O);throw E(O),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new d(s.message,t,s.error,r):new l(s.message,t,r)}catch(e){}return new l(e,t,r)}(O,y)},E=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),O=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(n(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),o=[...s,...a];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(E);return T([...O.hosts].reverse(),O.getTimeout)}return{hostsCache:t,requester:i,timeouts:o,algoliaAgent:a,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){const a=e.useReadTransporter||"GET"===e.method;if(!a)return f(e,t,a);const n=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return n();const o={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return g.get(o,(()=>u.get(o,(()=>u.set(o,n()).then((e=>Promise.all([u.delete(o),e])),(e=>Promise.all([u.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>g.set(o,e)})},requestsCache:u,responsesCache:g}}function f({algoliaAgents:e,client:t,version:r}){const s=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>s.add(e))),s}const y="5.0.0-beta.10",P=["eu","us"];e.apiClientVersion=y,e.querySuggestionsClient=function(e,a,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(!n||n&&("string"!=typeof n||!P.includes(n)))throw new Error(`\`region\` is required and must be one of the following: ${P.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...n}){const o=function(e,t,r="WithinHeaders"){const s={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?s:{},queryParameters:()=>"WithinQueryParameters"===r?s:{}}}(e,t,r),i=g({hosts:(u=a,[{url:"query-suggestions.{region}.algolia.com".replace("{region}",u),accept:"readWrite",protocol:"https"}]),...n,algoliaAgent:f({algoliaAgents:s,client:"QuerySuggestions",version:y}),baseHeaders:{"content-type":"text/plain",...o.headers(),...n.baseHeaders},baseQueryParameters:{...o.queryParameters(),...n.baseQueryParameters}});var u;return{transporter:i,appId:e,clearCache:()=>Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then((()=>{})),get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(e,t){i.algoliaAgent.add({segment:e,version:t})},createConfig(e,t){if(!e)throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");const r={method:"POST",path:"/1/configs",queryParameters:{},headers:{},data:e};return i.request(r,t)},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const s={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const s={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customPost({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const a={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},customPut({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const a={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},deleteConfig({indexName:e},t){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");const r={method:"DELETE",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},getAllConfigs(e){const t={method:"GET",path:"/1/configs",queryParameters:{},headers:{}};return i.request(t,e)},getConfig({indexName:e},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getConfig`.");const r={method:"GET",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},getConfigStatus({indexName:e},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");const r={method:"GET",path:"/1/configs/{indexName}/status".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},getLogFile({indexName:e},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getLogFile`.");const r={method:"GET",path:"/1/logs/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},updateConfig({indexName:e,configuration:t},r){if(!e)throw new Error("Parameter `indexName` is required when calling `updateConfig`.");if(!t)throw new Error("Parameter `configuration` is required when calling `updateConfig`.");if(!t.sourceIndices)throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");const s={method:"PUT",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return i.request(s,r)}}}({appId:e,apiKey:a,region:n,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const s=(e,s)=>setTimeout((()=>{r.abort(),t({status:0,content:s,isTimedOut:!0})}),e),a=s(e.connectTimeout,"Connection timeout");let n;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(n),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:r({caches:[t({key:`${y}-${e}`}),s()]}),...o})}}));
|