@algolia/client-query-suggestions 5.2.3 → 5.2.4-beta.2

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.
Files changed (57) hide show
  1. package/dist/browser.d.ts +282 -0
  2. package/dist/builds/browser.js +386 -0
  3. package/dist/builds/browser.js.map +1 -0
  4. package/dist/builds/browser.min.js +2 -0
  5. package/dist/builds/browser.min.js.map +1 -0
  6. package/dist/builds/browser.umd.js +12 -0
  7. package/dist/builds/node.cjs +404 -0
  8. package/dist/builds/node.cjs.map +1 -0
  9. package/dist/builds/node.js +384 -0
  10. package/dist/builds/node.js.map +1 -0
  11. package/dist/node.d.cts +282 -0
  12. package/dist/node.d.ts +282 -0
  13. package/dist/src/querySuggestionsClient.cjs +371 -0
  14. package/dist/src/querySuggestionsClient.cjs.map +1 -0
  15. package/dist/src/querySuggestionsClient.js +344 -0
  16. package/dist/src/querySuggestionsClient.js.map +1 -0
  17. package/index.d.ts +1 -1
  18. package/index.js +1 -1
  19. package/package.json +27 -27
  20. package/dist/builds/browser.d.ts +0 -27
  21. package/dist/builds/browser.d.ts.map +0 -1
  22. package/dist/builds/node.d.ts +0 -27
  23. package/dist/builds/node.d.ts.map +0 -1
  24. package/dist/client-query-suggestions.cjs +0 -371
  25. package/dist/client-query-suggestions.esm.browser.js +0 -1045
  26. package/dist/client-query-suggestions.esm.node.js +0 -368
  27. package/dist/client-query-suggestions.umd.js +0 -2
  28. package/dist/model/appID.d.ts +0 -7
  29. package/dist/model/appID.d.ts.map +0 -1
  30. package/dist/model/baseResponse.d.ts +0 -11
  31. package/dist/model/baseResponse.d.ts.map +0 -1
  32. package/dist/model/clientMethodProps.d.ts +0 -108
  33. package/dist/model/clientMethodProps.d.ts.map +0 -1
  34. package/dist/model/configStatus.d.ts +0 -23
  35. package/dist/model/configStatus.d.ts.map +0 -1
  36. package/dist/model/configuration.d.ts +0 -22
  37. package/dist/model/configuration.d.ts.map +0 -1
  38. package/dist/model/configurationResponse.d.ts +0 -7
  39. package/dist/model/configurationResponse.d.ts.map +0 -1
  40. package/dist/model/configurationWithIndex.d.ts +0 -6
  41. package/dist/model/configurationWithIndex.d.ts.map +0 -1
  42. package/dist/model/errorBase.d.ts +0 -7
  43. package/dist/model/errorBase.d.ts.map +0 -1
  44. package/dist/model/facet.d.ts +0 -14
  45. package/dist/model/facet.d.ts.map +0 -1
  46. package/dist/model/index.d.ts +0 -14
  47. package/dist/model/index.d.ts.map +0 -1
  48. package/dist/model/languages.d.ts +0 -5
  49. package/dist/model/languages.d.ts.map +0 -1
  50. package/dist/model/logFile.d.ts +0 -17
  51. package/dist/model/logFile.d.ts.map +0 -1
  52. package/dist/model/logLevel.d.ts +0 -5
  53. package/dist/model/logLevel.d.ts.map +0 -1
  54. package/dist/model/sourceIndex.d.ts +0 -27
  55. package/dist/model/sourceIndex.d.ts.map +0 -1
  56. package/dist/src/querySuggestionsClient.d.ts +0 -148
  57. package/dist/src/querySuggestionsClient.d.ts.map +0 -1
@@ -0,0 +1,282 @@
1
+ import * as _algolia_client_common from '@algolia/client-common';
2
+ import { ClientOptions } from '@algolia/client-common';
3
+
4
+ type AppID = {
5
+ /**
6
+ * Algolia application ID to which this Query Suggestions configuration belongs.
7
+ */
8
+ appID?: string;
9
+ };
10
+
11
+ type BaseResponse = {
12
+ /**
13
+ * HTTP status code.
14
+ */
15
+ status?: number;
16
+ /**
17
+ * Details about the response, such as error messages.
18
+ */
19
+ message?: string;
20
+ };
21
+
22
+ type ConfigStatus = {
23
+ /**
24
+ * Name of the Query Suggestions index (case-sensitive).
25
+ */
26
+ indexName?: string;
27
+ /**
28
+ * Whether the creation or update of the Query Suggestions index is in progress.
29
+ */
30
+ isRunning?: boolean;
31
+ /**
32
+ * Date and time when the Query Suggestions index was last built, in RFC 3339 format.
33
+ */
34
+ lastBuiltAt?: string;
35
+ /**
36
+ * Date and time when the Query Suggestions index was last updated successfully.
37
+ */
38
+ lastSuccessfulBuiltAt?: string;
39
+ /**
40
+ * Duration of the last successful build in seconds.
41
+ */
42
+ lastSuccessfulBuildDuration?: string;
43
+ };
44
+
45
+ /**
46
+ * Languages for deduplicating singular and plural suggestions. If specified, only the more popular form is included.
47
+ */
48
+ type Languages = string[] | boolean;
49
+
50
+ /**
51
+ * Facet to use as category.
52
+ */
53
+ type Facet = {
54
+ /**
55
+ * Facet name.
56
+ */
57
+ attribute?: string;
58
+ /**
59
+ * Number of suggestions.
60
+ */
61
+ amount?: number;
62
+ };
63
+
64
+ /**
65
+ * Configuration of an Algolia index for Query Suggestions.
66
+ */
67
+ type SourceIndex = {
68
+ /**
69
+ * Name of the Algolia index (case-sensitive) to use as source for query suggestions.
70
+ */
71
+ indexName: string;
72
+ /**
73
+ * If true, Query Suggestions uses all replica indices to find popular searches. If false, only the primary index is used.
74
+ */
75
+ replicas?: boolean;
76
+ analyticsTags?: string[] | null;
77
+ facets?: Facet[] | null;
78
+ /**
79
+ * Minimum number of hits required to be included as a suggestion. A search query must at least generate `minHits` search results to be included in the Query Suggestions index.
80
+ */
81
+ minHits?: number;
82
+ /**
83
+ * Minimum letters required to be included as a suggestion. A search query must be at least `minLetters` long to be included in the Query Suggestions index.
84
+ */
85
+ minLetters?: number;
86
+ generate?: string[][] | null;
87
+ external?: string[] | null;
88
+ };
89
+
90
+ /**
91
+ * Query Suggestions configuration.
92
+ */
93
+ type Configuration = {
94
+ /**
95
+ * Algolia indices from which to get the popular searches for query suggestions.
96
+ */
97
+ sourceIndices: SourceIndex[];
98
+ languages?: Languages;
99
+ exclude?: string[] | null;
100
+ /**
101
+ * Whether to turn on personalized query suggestions.
102
+ */
103
+ enablePersonalization?: boolean;
104
+ /**
105
+ * Whether to include suggestions with special characters.
106
+ */
107
+ allowSpecialCharacters?: boolean;
108
+ };
109
+
110
+ /**
111
+ * Query Suggestions configuration.
112
+ */
113
+ type ConfigurationWithIndex = Configuration & Record<string, unknown>;
114
+
115
+ /**
116
+ * API response for retrieving Query Suggestions configurations.
117
+ */
118
+ type ConfigurationResponse = AppID & ConfigurationWithIndex;
119
+
120
+ /**
121
+ * Error.
122
+ */
123
+ type ErrorBase = Record<string, any> & {
124
+ message?: string;
125
+ };
126
+
127
+ /**
128
+ * Type of log entry. - `SKIP`. A query is skipped because it doesn\'t match the conditions for successful inclusion. For example, when a query doesn\'t generate enough search results. - `INFO`. An informative log entry. - `ERROR`. The Query Suggestions process encountered an error.
129
+ */
130
+ type LogLevel = 'ERROR' | 'INFO' | 'SKIP';
131
+
132
+ type LogFile = {
133
+ /**
134
+ * Date and time of the log entry, in RFC 3339 format.
135
+ */
136
+ timestamp?: string;
137
+ level?: LogLevel;
138
+ /**
139
+ * Details about this log entry.
140
+ */
141
+ message?: string;
142
+ /**
143
+ * Level indicating the position of a suggestion in a hierarchy of records. For example, a `contextLevel` of 1 indicates that this suggestion belongs to a previous suggestion with `contextLevel` 0.
144
+ */
145
+ contextLevel?: number;
146
+ };
147
+
148
+ /**
149
+ * Properties for the `customDelete` method.
150
+ */
151
+ type CustomDeleteProps = {
152
+ /**
153
+ * Path of the endpoint, anything after \"/1\" must be specified.
154
+ */
155
+ path: string;
156
+ /**
157
+ * Query parameters to apply to the current query.
158
+ */
159
+ parameters?: Record<string, any>;
160
+ };
161
+ /**
162
+ * Properties for the `customGet` method.
163
+ */
164
+ type CustomGetProps = {
165
+ /**
166
+ * Path of the endpoint, anything after \"/1\" must be specified.
167
+ */
168
+ path: string;
169
+ /**
170
+ * Query parameters to apply to the current query.
171
+ */
172
+ parameters?: Record<string, any>;
173
+ };
174
+ /**
175
+ * Properties for the `customPost` method.
176
+ */
177
+ type CustomPostProps = {
178
+ /**
179
+ * Path of the endpoint, anything after \"/1\" must be specified.
180
+ */
181
+ path: string;
182
+ /**
183
+ * Query parameters to apply to the current query.
184
+ */
185
+ parameters?: Record<string, any>;
186
+ /**
187
+ * Parameters to send with the custom request.
188
+ */
189
+ body?: Record<string, unknown>;
190
+ };
191
+ /**
192
+ * Properties for the `customPut` method.
193
+ */
194
+ type CustomPutProps = {
195
+ /**
196
+ * Path of the endpoint, anything after \"/1\" must be specified.
197
+ */
198
+ path: string;
199
+ /**
200
+ * Query parameters to apply to the current query.
201
+ */
202
+ parameters?: Record<string, any>;
203
+ /**
204
+ * Parameters to send with the custom request.
205
+ */
206
+ body?: Record<string, unknown>;
207
+ };
208
+ /**
209
+ * Properties for the `deleteConfig` method.
210
+ */
211
+ type DeleteConfigProps = {
212
+ /**
213
+ * Query Suggestions index name.
214
+ */
215
+ indexName: string;
216
+ };
217
+ /**
218
+ * Properties for the `getConfig` method.
219
+ */
220
+ type GetConfigProps = {
221
+ /**
222
+ * Query Suggestions index name.
223
+ */
224
+ indexName: string;
225
+ };
226
+ /**
227
+ * Properties for the `getConfigStatus` method.
228
+ */
229
+ type GetConfigStatusProps = {
230
+ /**
231
+ * Query Suggestions index name.
232
+ */
233
+ indexName: string;
234
+ };
235
+ /**
236
+ * Properties for the `getLogFile` method.
237
+ */
238
+ type GetLogFileProps = {
239
+ /**
240
+ * Query Suggestions index name.
241
+ */
242
+ indexName: string;
243
+ };
244
+ /**
245
+ * Properties for the `updateConfig` method.
246
+ */
247
+ type UpdateConfigProps = {
248
+ /**
249
+ * Query Suggestions index name.
250
+ */
251
+ indexName: string;
252
+ configuration: Configuration;
253
+ };
254
+
255
+ declare const apiClientVersion = "5.2.4";
256
+ declare const REGIONS: readonly ["eu", "us"];
257
+ type Region = (typeof REGIONS)[number];
258
+
259
+ /**
260
+ * The client type.
261
+ */
262
+ type QuerySuggestionsClient = ReturnType<typeof querySuggestionsClient>;
263
+ declare function querySuggestionsClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): {
264
+ transporter: _algolia_client_common.Transporter;
265
+ appId: string;
266
+ clearCache(): Promise<void>;
267
+ readonly _ua: string;
268
+ addAlgoliaAgent(segment: string, version?: string): void;
269
+ createConfig(configurationWithIndex: ConfigurationWithIndex, requestOptions?: _algolia_client_common.RequestOptions): Promise<BaseResponse>;
270
+ customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
271
+ customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
272
+ customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
273
+ customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
274
+ deleteConfig({ indexName }: DeleteConfigProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<BaseResponse>;
275
+ getAllConfigs(requestOptions?: _algolia_client_common.RequestOptions): Promise<ConfigurationResponse[]>;
276
+ getConfig({ indexName }: GetConfigProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<ConfigurationResponse>;
277
+ getConfigStatus({ indexName }: GetConfigStatusProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<ConfigStatus>;
278
+ getLogFile({ indexName }: GetLogFileProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<LogFile>;
279
+ updateConfig({ indexName, configuration }: UpdateConfigProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<BaseResponse>;
280
+ };
281
+
282
+ export { type AppID, type BaseResponse, type ConfigStatus, type Configuration, type ConfigurationResponse, type ConfigurationWithIndex, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteConfigProps, type ErrorBase, type Facet, type GetConfigProps, type GetConfigStatusProps, type GetLogFileProps, type Languages, type LogFile, type LogLevel, type QuerySuggestionsClient, type Region, type SourceIndex, type UpdateConfigProps, apiClientVersion, querySuggestionsClient };
@@ -0,0 +1,386 @@
1
+ // builds/browser.ts
2
+ import {
3
+ createMemoryCache,
4
+ createFallbackableCache,
5
+ createBrowserLocalStorageCache,
6
+ DEFAULT_CONNECT_TIMEOUT_BROWSER,
7
+ DEFAULT_READ_TIMEOUT_BROWSER,
8
+ DEFAULT_WRITE_TIMEOUT_BROWSER
9
+ } from "@algolia/client-common";
10
+ import { createXhrRequester } from "@algolia/requester-browser-xhr";
11
+
12
+ // src/querySuggestionsClient.ts
13
+ import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
14
+ var apiClientVersion = "5.2.4";
15
+ var REGIONS = ["eu", "us"];
16
+ function getDefaultHosts(region) {
17
+ const url = "query-suggestions.{region}.algolia.com".replace("{region}", region);
18
+ return [{ url, accept: "readWrite", protocol: "https" }];
19
+ }
20
+ function createQuerySuggestionsClient({
21
+ appId: appIdOption,
22
+ apiKey: apiKeyOption,
23
+ authMode,
24
+ algoliaAgents,
25
+ region: regionOption,
26
+ ...options
27
+ }) {
28
+ const auth = createAuth(appIdOption, apiKeyOption, authMode);
29
+ const transporter = createTransporter({
30
+ hosts: getDefaultHosts(regionOption),
31
+ ...options,
32
+ algoliaAgent: getAlgoliaAgent({
33
+ algoliaAgents,
34
+ client: "QuerySuggestions",
35
+ version: apiClientVersion
36
+ }),
37
+ baseHeaders: {
38
+ "content-type": "text/plain",
39
+ ...auth.headers(),
40
+ ...options.baseHeaders
41
+ },
42
+ baseQueryParameters: {
43
+ ...auth.queryParameters(),
44
+ ...options.baseQueryParameters
45
+ }
46
+ });
47
+ return {
48
+ transporter,
49
+ /**
50
+ * The `appId` currently in use.
51
+ */
52
+ appId: appIdOption,
53
+ /**
54
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
55
+ */
56
+ clearCache() {
57
+ return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
58
+ },
59
+ /**
60
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
61
+ */
62
+ get _ua() {
63
+ return transporter.algoliaAgent.value;
64
+ },
65
+ /**
66
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
67
+ *
68
+ * @param segment - The algolia agent (user-agent) segment to add.
69
+ * @param version - The version of the agent.
70
+ */
71
+ addAlgoliaAgent(segment, version) {
72
+ transporter.algoliaAgent.add({ segment, version });
73
+ },
74
+ /**
75
+ * Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
76
+ *
77
+ * Required API Key ACLs:
78
+ * - editSettings.
79
+ *
80
+ * @param configurationWithIndex - The configurationWithIndex object.
81
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
82
+ */
83
+ createConfig(configurationWithIndex, requestOptions) {
84
+ if (!configurationWithIndex) {
85
+ throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");
86
+ }
87
+ const requestPath = "/1/configs";
88
+ const headers = {};
89
+ const queryParameters = {};
90
+ const request = {
91
+ method: "POST",
92
+ path: requestPath,
93
+ queryParameters,
94
+ headers,
95
+ data: configurationWithIndex
96
+ };
97
+ return transporter.request(request, requestOptions);
98
+ },
99
+ /**
100
+ * This method allow you to send requests to the Algolia REST API.
101
+ *
102
+ * @param customDelete - The customDelete object.
103
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
104
+ * @param customDelete.parameters - Query parameters to apply to the current query.
105
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
106
+ */
107
+ customDelete({ path, parameters }, requestOptions) {
108
+ if (!path) {
109
+ throw new Error("Parameter `path` is required when calling `customDelete`.");
110
+ }
111
+ const requestPath = "/{path}".replace("{path}", path);
112
+ const headers = {};
113
+ const queryParameters = parameters ? parameters : {};
114
+ const request = {
115
+ method: "DELETE",
116
+ path: requestPath,
117
+ queryParameters,
118
+ headers
119
+ };
120
+ return transporter.request(request, requestOptions);
121
+ },
122
+ /**
123
+ * This method allow you to send requests to the Algolia REST API.
124
+ *
125
+ * @param customGet - The customGet object.
126
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
127
+ * @param customGet.parameters - Query parameters to apply to the current query.
128
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
129
+ */
130
+ customGet({ path, parameters }, requestOptions) {
131
+ if (!path) {
132
+ throw new Error("Parameter `path` is required when calling `customGet`.");
133
+ }
134
+ const requestPath = "/{path}".replace("{path}", path);
135
+ const headers = {};
136
+ const queryParameters = parameters ? parameters : {};
137
+ const request = {
138
+ method: "GET",
139
+ path: requestPath,
140
+ queryParameters,
141
+ headers
142
+ };
143
+ return transporter.request(request, requestOptions);
144
+ },
145
+ /**
146
+ * This method allow you to send requests to the Algolia REST API.
147
+ *
148
+ * @param customPost - The customPost object.
149
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
150
+ * @param customPost.parameters - Query parameters to apply to the current query.
151
+ * @param customPost.body - Parameters to send with the custom request.
152
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
153
+ */
154
+ customPost({ path, parameters, body }, requestOptions) {
155
+ if (!path) {
156
+ throw new Error("Parameter `path` is required when calling `customPost`.");
157
+ }
158
+ const requestPath = "/{path}".replace("{path}", path);
159
+ const headers = {};
160
+ const queryParameters = parameters ? parameters : {};
161
+ const request = {
162
+ method: "POST",
163
+ path: requestPath,
164
+ queryParameters,
165
+ headers,
166
+ data: body ? body : {}
167
+ };
168
+ return transporter.request(request, requestOptions);
169
+ },
170
+ /**
171
+ * This method allow you to send requests to the Algolia REST API.
172
+ *
173
+ * @param customPut - The customPut object.
174
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
175
+ * @param customPut.parameters - Query parameters to apply to the current query.
176
+ * @param customPut.body - Parameters to send with the custom request.
177
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
178
+ */
179
+ customPut({ path, parameters, body }, requestOptions) {
180
+ if (!path) {
181
+ throw new Error("Parameter `path` is required when calling `customPut`.");
182
+ }
183
+ const requestPath = "/{path}".replace("{path}", path);
184
+ const headers = {};
185
+ const queryParameters = parameters ? parameters : {};
186
+ const request = {
187
+ method: "PUT",
188
+ path: requestPath,
189
+ queryParameters,
190
+ headers,
191
+ data: body ? body : {}
192
+ };
193
+ return transporter.request(request, requestOptions);
194
+ },
195
+ /**
196
+ * 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` operation.
197
+ *
198
+ * Required API Key ACLs:
199
+ * - editSettings.
200
+ *
201
+ * @param deleteConfig - The deleteConfig object.
202
+ * @param deleteConfig.indexName - Query Suggestions index name.
203
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
204
+ */
205
+ deleteConfig({ indexName }, requestOptions) {
206
+ if (!indexName) {
207
+ throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");
208
+ }
209
+ const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
210
+ const headers = {};
211
+ const queryParameters = {};
212
+ const request = {
213
+ method: "DELETE",
214
+ path: requestPath,
215
+ queryParameters,
216
+ headers
217
+ };
218
+ return transporter.request(request, requestOptions);
219
+ },
220
+ /**
221
+ * Retrieves all Query Suggestions configurations of your Algolia application.
222
+ *
223
+ * Required API Key ACLs:
224
+ * - settings.
225
+ *
226
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
227
+ */
228
+ getAllConfigs(requestOptions) {
229
+ const requestPath = "/1/configs";
230
+ const headers = {};
231
+ const queryParameters = {};
232
+ const request = {
233
+ method: "GET",
234
+ path: requestPath,
235
+ queryParameters,
236
+ headers
237
+ };
238
+ return transporter.request(request, requestOptions);
239
+ },
240
+ /**
241
+ * Retrieves a single Query Suggestions configuration by its index name.
242
+ *
243
+ * Required API Key ACLs:
244
+ * - settings.
245
+ *
246
+ * @param getConfig - The getConfig object.
247
+ * @param getConfig.indexName - Query Suggestions index name.
248
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
249
+ */
250
+ getConfig({ indexName }, requestOptions) {
251
+ if (!indexName) {
252
+ throw new Error("Parameter `indexName` is required when calling `getConfig`.");
253
+ }
254
+ const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
255
+ const headers = {};
256
+ const queryParameters = {};
257
+ const request = {
258
+ method: "GET",
259
+ path: requestPath,
260
+ queryParameters,
261
+ headers
262
+ };
263
+ return transporter.request(request, requestOptions);
264
+ },
265
+ /**
266
+ * Reports the status of a Query Suggestions index.
267
+ *
268
+ * Required API Key ACLs:
269
+ * - settings.
270
+ *
271
+ * @param getConfigStatus - The getConfigStatus object.
272
+ * @param getConfigStatus.indexName - Query Suggestions index name.
273
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
274
+ */
275
+ getConfigStatus({ indexName }, requestOptions) {
276
+ if (!indexName) {
277
+ throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");
278
+ }
279
+ const requestPath = "/1/configs/{indexName}/status".replace("{indexName}", encodeURIComponent(indexName));
280
+ const headers = {};
281
+ const queryParameters = {};
282
+ const request = {
283
+ method: "GET",
284
+ path: requestPath,
285
+ queryParameters,
286
+ headers
287
+ };
288
+ return transporter.request(request, requestOptions);
289
+ },
290
+ /**
291
+ * Retrieves the logs for a single Query Suggestions index.
292
+ *
293
+ * Required API Key ACLs:
294
+ * - settings.
295
+ *
296
+ * @param getLogFile - The getLogFile object.
297
+ * @param getLogFile.indexName - Query Suggestions index name.
298
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
299
+ */
300
+ getLogFile({ indexName }, requestOptions) {
301
+ if (!indexName) {
302
+ throw new Error("Parameter `indexName` is required when calling `getLogFile`.");
303
+ }
304
+ const requestPath = "/1/logs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
305
+ const headers = {};
306
+ const queryParameters = {};
307
+ const request = {
308
+ method: "GET",
309
+ path: requestPath,
310
+ queryParameters,
311
+ headers
312
+ };
313
+ return transporter.request(request, requestOptions);
314
+ },
315
+ /**
316
+ * Updates a QuerySuggestions configuration.
317
+ *
318
+ * Required API Key ACLs:
319
+ * - editSettings.
320
+ *
321
+ * @param updateConfig - The updateConfig object.
322
+ * @param updateConfig.indexName - Query Suggestions index name.
323
+ * @param updateConfig.configuration - The configuration object.
324
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
325
+ */
326
+ updateConfig({ indexName, configuration }, requestOptions) {
327
+ if (!indexName) {
328
+ throw new Error("Parameter `indexName` is required when calling `updateConfig`.");
329
+ }
330
+ if (!configuration) {
331
+ throw new Error("Parameter `configuration` is required when calling `updateConfig`.");
332
+ }
333
+ if (!configuration.sourceIndices) {
334
+ throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");
335
+ }
336
+ const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
337
+ const headers = {};
338
+ const queryParameters = {};
339
+ const request = {
340
+ method: "PUT",
341
+ path: requestPath,
342
+ queryParameters,
343
+ headers,
344
+ data: configuration
345
+ };
346
+ return transporter.request(request, requestOptions);
347
+ }
348
+ };
349
+ }
350
+
351
+ // builds/browser.ts
352
+ function querySuggestionsClient(appId, apiKey, region, options) {
353
+ if (!appId || typeof appId !== "string") {
354
+ throw new Error("`appId` is missing.");
355
+ }
356
+ if (!apiKey || typeof apiKey !== "string") {
357
+ throw new Error("`apiKey` is missing.");
358
+ }
359
+ if (!region || region && (typeof region !== "string" || !REGIONS.includes(region))) {
360
+ throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(", ")}`);
361
+ }
362
+ return createQuerySuggestionsClient({
363
+ appId,
364
+ apiKey,
365
+ region,
366
+ timeouts: {
367
+ connect: DEFAULT_CONNECT_TIMEOUT_BROWSER,
368
+ read: DEFAULT_READ_TIMEOUT_BROWSER,
369
+ write: DEFAULT_WRITE_TIMEOUT_BROWSER
370
+ },
371
+ requester: createXhrRequester(),
372
+ algoliaAgents: [{ segment: "Browser" }],
373
+ authMode: "WithinQueryParameters",
374
+ responsesCache: createMemoryCache(),
375
+ requestsCache: createMemoryCache({ serializable: false }),
376
+ hostsCache: createFallbackableCache({
377
+ caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()]
378
+ }),
379
+ ...options
380
+ });
381
+ }
382
+ export {
383
+ apiClientVersion,
384
+ querySuggestionsClient
385
+ };
386
+ //# sourceMappingURL=browser.js.map