@algolia/monitoring 5.2.4-beta.5 → 5.10.0-beta.1

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 (49) hide show
  1. package/README.md +15 -7
  2. package/dist/browser.d.ts +194 -63
  3. package/dist/builds/browser.js +24 -22
  4. package/dist/builds/browser.js.map +1 -1
  5. package/dist/builds/browser.min.js +1 -1
  6. package/dist/builds/browser.min.js.map +1 -1
  7. package/dist/builds/browser.umd.js +4 -4
  8. package/dist/builds/fetch.js +388 -0
  9. package/dist/builds/fetch.js.map +1 -0
  10. package/dist/builds/node.cjs +21 -20
  11. package/dist/builds/node.cjs.map +1 -1
  12. package/dist/builds/node.js +22 -20
  13. package/dist/builds/node.js.map +1 -1
  14. package/dist/fetch.d.ts +437 -0
  15. package/dist/node.d.cts +196 -64
  16. package/dist/node.d.ts +196 -64
  17. package/dist/src/monitoringClient.cjs +19 -19
  18. package/dist/src/monitoringClient.cjs.map +1 -1
  19. package/dist/src/monitoringClient.js +19 -19
  20. package/dist/src/monitoringClient.js.map +1 -1
  21. package/index.d.ts +0 -1
  22. package/index.js +1 -2
  23. package/package.json +16 -11
  24. package/model/badRequest.ts +0 -5
  25. package/model/clientMethodProps.ts +0 -132
  26. package/model/errorBase.ts +0 -8
  27. package/model/forbidden.ts +0 -5
  28. package/model/incident.ts +0 -15
  29. package/model/incidentEntry.ts +0 -12
  30. package/model/incidentsResponse.ts +0 -7
  31. package/model/index.ts +0 -27
  32. package/model/indexingMetric.ts +0 -7
  33. package/model/indexingTimeResponse.ts +0 -7
  34. package/model/infrastructureResponse.ts +0 -7
  35. package/model/inventoryResponse.ts +0 -7
  36. package/model/latencyMetric.ts +0 -7
  37. package/model/latencyResponse.ts +0 -7
  38. package/model/metric.ts +0 -3
  39. package/model/metrics.ts +0 -30
  40. package/model/period.ts +0 -3
  41. package/model/probesMetric.ts +0 -13
  42. package/model/region.ts +0 -21
  43. package/model/server.ts +0 -33
  44. package/model/serverStatus.ts +0 -3
  45. package/model/status.ts +0 -6
  46. package/model/statusResponse.ts +0 -7
  47. package/model/timeEntry.ts +0 -13
  48. package/model/type.ts +0 -3
  49. package/model/unauthorized.ts +0 -5
package/README.md CHANGED
@@ -32,24 +32,32 @@
32
32
 
33
33
  ## 💡 Getting Started
34
34
 
35
- To get started, you first need to install @algolia/monitoring (or any other available API client package).
35
+ > [!TIP]
36
+ > This API client is already a dependency of [the algoliasearch client](https://www.npmjs.com/package/algoliasearch), you don't need to manually install `@algolia/monitoring` if you already have `algoliasearch` installed.
36
37
 
38
+ To get started, you first need to install @algolia/monitoring (or any other available API client package).
37
39
  All of our clients comes with type definition, and are available for both browser and node environments.
38
40
 
41
+ ### With a package manager
42
+
39
43
  ```bash
40
- yarn add @algolia/monitoring
44
+ yarn add @algolia/monitoring@1.10.0
41
45
  # or
42
- npm install @algolia/monitoring
46
+ npm install @algolia/monitoring@1.10.0
47
+ # or
48
+ pnpm add @algolia/monitoring@1.10.0
43
49
  ```
44
50
 
45
- Without a package manager
51
+ ### Without a package manager
46
52
 
47
53
  Add the following JavaScript snippet to the <head> of your website:
48
54
 
49
55
  ```html
50
- <script src="https://cdn.jsdelivr.net/npm/algoliasearch/dist/monitoring.umd.min.js"></script>
56
+ <script src="https://cdn.jsdelivr.net/npm/@algolia/monitoring@1.10.0/dist/builds/browser.umd.js"></script>
51
57
  ```
52
58
 
59
+ ### Usage
60
+
53
61
  You can now import the Algolia API client in your project and play with it.
54
62
 
55
63
  ```js
@@ -58,7 +66,7 @@ import { monitoringClient } from '@algolia/monitoring';
58
66
  const client = monitoringClient('YOUR_APP_ID', 'YOUR_API_KEY');
59
67
  ```
60
68
 
61
- For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/)**.
69
+ For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/v5/methods/monitoring/)**.
62
70
 
63
71
  ## ❓ Troubleshooting
64
72
 
@@ -66,4 +74,4 @@ Encountering an issue? Before reaching out to support, we recommend heading to o
66
74
 
67
75
  ## 📄 License
68
76
 
69
- The Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE).
77
+ The Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE).
package/dist/browser.d.ts CHANGED
@@ -1,25 +1,10 @@
1
1
  import * as _algolia_client_common from '@algolia/client-common';
2
- import { ClientOptions } from '@algolia/client-common';
3
-
4
- type BadRequest = {
5
- reason?: string;
6
- };
7
-
8
- /**
9
- * Error.
10
- */
11
- type ErrorBase = Record<string, any> & {
12
- message?: string;
13
- };
14
-
15
- type Forbidden = {
16
- reason?: string;
17
- };
2
+ import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
18
3
 
19
4
  /**
20
5
  * Status of the cluster.
21
6
  */
22
- type Status = 'degraded_performance' | 'major_outage' | 'operational' | 'partial_outage';
7
+ type Status = 'operational' | 'degraded_performance' | 'partial_outage' | 'major_outage';
23
8
 
24
9
  /**
25
10
  * Incident details.
@@ -41,7 +26,9 @@ type IncidentEntry = {
41
26
  };
42
27
 
43
28
  type IncidentsResponse = {
44
- incidents?: Record<string, IncidentEntry[]>;
29
+ incidents?: {
30
+ [key: string]: Array<IncidentEntry>;
31
+ };
45
32
  };
46
33
 
47
34
  type TimeEntry = {
@@ -56,7 +43,9 @@ type TimeEntry = {
56
43
  };
57
44
 
58
45
  type IndexingMetric = {
59
- indexing?: Record<string, TimeEntry[]>;
46
+ indexing?: {
47
+ [key: string]: Array<TimeEntry>;
48
+ };
60
49
  };
61
50
 
62
51
  type IndexingTimeResponse = {
@@ -78,23 +67,33 @@ type Metrics = {
78
67
  /**
79
68
  * CPU idleness in %.
80
69
  */
81
- cpu_usage?: Record<string, ProbesMetric[]>;
70
+ cpu_usage?: {
71
+ [key: string]: Array<ProbesMetric>;
72
+ };
82
73
  /**
83
74
  * RAM used for indexing in MB.
84
75
  */
85
- ram_indexing_usage?: Record<string, ProbesMetric[]>;
76
+ ram_indexing_usage?: {
77
+ [key: string]: Array<ProbesMetric>;
78
+ };
86
79
  /**
87
80
  * RAM used for search in MB.
88
81
  */
89
- ram_search_usage?: Record<string, ProbesMetric[]>;
82
+ ram_search_usage?: {
83
+ [key: string]: Array<ProbesMetric>;
84
+ };
90
85
  /**
91
86
  * Solid-state disk (SSD) usage expressed as % of RAM. 0% means no SSD usage. A value of 50% indicates 32&nbsp;GB SSD usage for a machine with 64&nbsp;RAM.
92
87
  */
93
- ssd_usage?: Record<string, ProbesMetric[]>;
88
+ ssd_usage?: {
89
+ [key: string]: Array<ProbesMetric>;
90
+ };
94
91
  /**
95
92
  * Average build time of the indices in seconds.
96
93
  */
97
- avg_build_time?: Record<string, ProbesMetric[]>;
94
+ avg_build_time?: {
95
+ [key: string]: Array<ProbesMetric>;
96
+ };
98
97
  };
99
98
 
100
99
  type InfrastructureResponse = {
@@ -133,28 +132,28 @@ type Server = {
133
132
  };
134
133
 
135
134
  type InventoryResponse = {
136
- inventory?: Server[];
135
+ inventory?: Array<Server>;
137
136
  };
138
137
 
139
138
  type LatencyMetric = {
140
- latency?: Record<string, TimeEntry[]>;
139
+ latency?: {
140
+ [key: string]: Array<TimeEntry>;
141
+ };
141
142
  };
142
143
 
143
144
  type LatencyResponse = {
144
145
  metrics?: LatencyMetric;
145
146
  };
146
147
 
147
- type Metric = '*' | 'avg_build_time' | 'cpu_usage' | 'ram_indexing_usage' | 'ram_search_usage' | 'ssd_usage';
148
-
149
- type Period = 'day' | 'hour' | 'minute' | 'month' | 'week';
150
-
151
148
  type StatusResponse = {
152
- status?: Record<string, Status>;
149
+ status?: {
150
+ [key: string]: Status;
151
+ };
153
152
  };
154
153
 
155
- type Unauthorized = {
156
- reason?: string;
157
- };
154
+ type Metric = 'avg_build_time' | 'ssd_usage' | 'ram_search_usage' | 'ram_indexing_usage' | 'cpu_usage' | '*';
155
+
156
+ type Period = 'minute' | 'hour' | 'day' | 'week' | 'month';
158
157
 
159
158
  /**
160
159
  * Properties for the `customDelete` method.
@@ -167,7 +166,9 @@ type CustomDeleteProps = {
167
166
  /**
168
167
  * Query parameters to apply to the current query.
169
168
  */
170
- parameters?: Record<string, any>;
169
+ parameters?: {
170
+ [key: string]: any;
171
+ };
171
172
  };
172
173
  /**
173
174
  * Properties for the `customGet` method.
@@ -180,7 +181,9 @@ type CustomGetProps = {
180
181
  /**
181
182
  * Query parameters to apply to the current query.
182
183
  */
183
- parameters?: Record<string, any>;
184
+ parameters?: {
185
+ [key: string]: any;
186
+ };
184
187
  };
185
188
  /**
186
189
  * Properties for the `customPost` method.
@@ -193,7 +196,9 @@ type CustomPostProps = {
193
196
  /**
194
197
  * Query parameters to apply to the current query.
195
198
  */
196
- parameters?: Record<string, any>;
199
+ parameters?: {
200
+ [key: string]: any;
201
+ };
197
202
  /**
198
203
  * Parameters to send with the custom request.
199
204
  */
@@ -210,7 +215,9 @@ type CustomPutProps = {
210
215
  /**
211
216
  * Query parameters to apply to the current query.
212
217
  */
213
- parameters?: Record<string, any>;
218
+ parameters?: {
219
+ [key: string]: any;
220
+ };
214
221
  /**
215
222
  * Parameters to send with the custom request.
216
223
  */
@@ -221,7 +228,7 @@ type CustomPutProps = {
221
228
  */
222
229
  type GetClusterIncidentsProps = {
223
230
  /**
224
- * Subset of clusters, separated by comma.
231
+ * Subset of clusters, separated by commas.
225
232
  */
226
233
  clusters: string;
227
234
  };
@@ -230,7 +237,7 @@ type GetClusterIncidentsProps = {
230
237
  */
231
238
  type GetClusterStatusProps = {
232
239
  /**
233
- * Subset of clusters, separated by comma.
240
+ * Subset of clusters, separated by commas.
234
241
  */
235
242
  clusters: string;
236
243
  };
@@ -239,7 +246,7 @@ type GetClusterStatusProps = {
239
246
  */
240
247
  type GetIndexingTimeProps = {
241
248
  /**
242
- * Subset of clusters, separated by comma.
249
+ * Subset of clusters, separated by commas.
243
250
  */
244
251
  clusters: string;
245
252
  };
@@ -248,7 +255,7 @@ type GetIndexingTimeProps = {
248
255
  */
249
256
  type GetLatencyProps = {
250
257
  /**
251
- * Subset of clusters, separated by comma.
258
+ * Subset of clusters, separated by commas.
252
259
  */
253
260
  clusters: string;
254
261
  };
@@ -270,36 +277,160 @@ type GetMetricsProps = {
270
277
  */
271
278
  type GetReachabilityProps = {
272
279
  /**
273
- * Subset of clusters, separated by comma.
280
+ * Subset of clusters, separated by commas.
274
281
  */
275
282
  clusters: string;
276
283
  };
277
284
 
278
- declare const apiClientVersion = "1.2.4";
279
-
280
- /**
281
- * The client type.
282
- */
283
- type MonitoringClient = ReturnType<typeof monitoringClient>;
284
- declare function monitoringClient(appId: string, apiKey: string, options?: ClientOptions): {
285
+ declare const apiClientVersion = "1.10.0";
286
+ declare function createMonitoringClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): {
285
287
  transporter: _algolia_client_common.Transporter;
288
+ /**
289
+ * The `appId` currently in use.
290
+ */
286
291
  appId: string;
292
+ /**
293
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
294
+ */
287
295
  clearCache(): Promise<void>;
296
+ /**
297
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
298
+ */
288
299
  readonly _ua: string;
300
+ /**
301
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
302
+ *
303
+ * @param segment - The algolia agent (user-agent) segment to add.
304
+ * @param version - The version of the agent.
305
+ */
289
306
  addAlgoliaAgent(segment: string, version?: string): void;
290
- customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
291
- customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
292
- customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
293
- customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
294
- getClusterIncidents({ clusters }: GetClusterIncidentsProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<IncidentsResponse>;
295
- getClusterStatus({ clusters }: GetClusterStatusProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<StatusResponse>;
296
- getIncidents(requestOptions?: _algolia_client_common.RequestOptions): Promise<IncidentsResponse>;
297
- getIndexingTime({ clusters }: GetIndexingTimeProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<IndexingTimeResponse>;
298
- getLatency({ clusters }: GetLatencyProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<LatencyResponse>;
299
- getMetrics({ metric, period }: GetMetricsProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<InfrastructureResponse>;
300
- getReachability({ clusters }: GetReachabilityProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, Record<string, boolean>>>;
301
- getServers(requestOptions?: _algolia_client_common.RequestOptions): Promise<InventoryResponse>;
302
- getStatus(requestOptions?: _algolia_client_common.RequestOptions): Promise<StatusResponse>;
307
+ /**
308
+ * Helper method to switch the API key used to authenticate the requests.
309
+ *
310
+ * @param params - Method params.
311
+ * @param params.apiKey - The new API Key to use.
312
+ */
313
+ setClientApiKey({ apiKey }: {
314
+ apiKey: string;
315
+ }): void;
316
+ /**
317
+ * This method allow you to send requests to the Algolia REST API.
318
+ * @param customDelete - The customDelete object.
319
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
320
+ * @param customDelete.parameters - Query parameters to apply to the current query.
321
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
322
+ */
323
+ customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
324
+ /**
325
+ * This method allow you to send requests to the Algolia REST API.
326
+ * @param customGet - The customGet object.
327
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
328
+ * @param customGet.parameters - Query parameters to apply to the current query.
329
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
330
+ */
331
+ customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
332
+ /**
333
+ * This method allow you to send requests to the Algolia REST API.
334
+ * @param customPost - The customPost object.
335
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
336
+ * @param customPost.parameters - Query parameters to apply to the current query.
337
+ * @param customPost.body - Parameters to send with the custom request.
338
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
339
+ */
340
+ customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
341
+ /**
342
+ * This method allow you to send requests to the Algolia REST API.
343
+ * @param customPut - The customPut object.
344
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
345
+ * @param customPut.parameters - Query parameters to apply to the current query.
346
+ * @param customPut.body - Parameters to send with the custom request.
347
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
348
+ */
349
+ customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
350
+ /**
351
+ * Retrieves known incidents for the selected clusters.
352
+ * @param getClusterIncidents - The getClusterIncidents object.
353
+ * @param getClusterIncidents.clusters - Subset of clusters, separated by commas.
354
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
355
+ */
356
+ getClusterIncidents({ clusters }: GetClusterIncidentsProps, requestOptions?: RequestOptions): Promise<IncidentsResponse>;
357
+ /**
358
+ * Retrieves the status of selected clusters.
359
+ * @param getClusterStatus - The getClusterStatus object.
360
+ * @param getClusterStatus.clusters - Subset of clusters, separated by commas.
361
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
362
+ */
363
+ getClusterStatus({ clusters }: GetClusterStatusProps, requestOptions?: RequestOptions): Promise<StatusResponse>;
364
+ /**
365
+ * Retrieves known incidents for all clusters.
366
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
367
+ */
368
+ getIncidents(requestOptions?: RequestOptions): Promise<IncidentsResponse>;
369
+ /**
370
+ * Retrieves average times for indexing operations for selected clusters.
371
+ * @param getIndexingTime - The getIndexingTime object.
372
+ * @param getIndexingTime.clusters - Subset of clusters, separated by commas.
373
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
374
+ */
375
+ getIndexingTime({ clusters }: GetIndexingTimeProps, requestOptions?: RequestOptions): Promise<IndexingTimeResponse>;
376
+ /**
377
+ * Retrieves the average latency for search requests for selected clusters.
378
+ * @param getLatency - The getLatency object.
379
+ * @param getLatency.clusters - Subset of clusters, separated by commas.
380
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
381
+ */
382
+ getLatency({ clusters }: GetLatencyProps, requestOptions?: RequestOptions): Promise<LatencyResponse>;
383
+ /**
384
+ * Retrieves metrics related to your Algolia infrastructure, aggregated over a selected time window. Access to this API is available as part of the [Premium or Elevate plans](https://www.algolia.com/pricing). You must authenticate requests with the `x-algolia-application-id` and `x-algolia-api-key` headers (using the Monitoring API key).
385
+ * @param getMetrics - The getMetrics object.
386
+ * @param getMetrics.metric - Metric to report. For more information about the individual metrics, see the description of the API response. To include all metrics, use `*`.
387
+ * @param getMetrics.period - Period over which to aggregate the metrics: - `minute`. Aggregate the last minute. 1 data point per 10 seconds. - `hour`. Aggregate the last hour. 1 data point per minute. - `day`. Aggregate the last day. 1 data point per 10 minutes. - `week`. Aggregate the last week. 1 data point per hour. - `month`. Aggregate the last month. 1 data point per day.
388
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
389
+ */
390
+ getMetrics({ metric, period }: GetMetricsProps, requestOptions?: RequestOptions): Promise<InfrastructureResponse>;
391
+ /**
392
+ * Test whether clusters are reachable or not.
393
+ * @param getReachability - The getReachability object.
394
+ * @param getReachability.clusters - Subset of clusters, separated by commas.
395
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
396
+ */
397
+ getReachability({ clusters }: GetReachabilityProps, requestOptions?: RequestOptions): Promise<{
398
+ [key: string]: {
399
+ [key: string]: boolean;
400
+ };
401
+ }>;
402
+ /**
403
+ * Retrieves the servers that belong to clusters. The response depends on whether you authenticate your API request: - With authentication, the response lists the servers assigned to your Algolia application\'s cluster. - Without authentication, the response lists the servers for all Algolia clusters.
404
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
405
+ */
406
+ getServers(requestOptions?: RequestOptions): Promise<InventoryResponse>;
407
+ /**
408
+ * Retrieves the status of all Algolia clusters and instances.
409
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
410
+ */
411
+ getStatus(requestOptions?: RequestOptions): Promise<StatusResponse>;
303
412
  };
304
413
 
414
+ type BadRequest = {
415
+ reason?: string;
416
+ };
417
+
418
+ /**
419
+ * Error.
420
+ */
421
+ type ErrorBase = Record<string, any> & {
422
+ message?: string;
423
+ };
424
+
425
+ type Forbidden = {
426
+ reason?: string;
427
+ };
428
+
429
+ type Unauthorized = {
430
+ reason?: string;
431
+ };
432
+
433
+ declare function monitoringClient(appId: string, apiKey: string, options?: ClientOptions): MonitoringClient;
434
+ type MonitoringClient = ReturnType<typeof createMonitoringClient>;
435
+
305
436
  export { type BadRequest, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type ErrorBase, type Forbidden, type GetClusterIncidentsProps, type GetClusterStatusProps, type GetIndexingTimeProps, type GetLatencyProps, type GetMetricsProps, type GetReachabilityProps, type Incident, type IncidentEntry, type IncidentsResponse, type IndexingMetric, type IndexingTimeResponse, type InfrastructureResponse, type InventoryResponse, type LatencyMetric, type LatencyResponse, type Metric, type Metrics, type MonitoringClient, type Period, type ProbesMetric, type Region, type Server, type ServerStatus, type Status, type StatusResponse, type TimeEntry, type Type, type Unauthorized, apiClientVersion, monitoringClient };
@@ -1,17 +1,18 @@
1
1
  // builds/browser.ts
2
+ import { createXhrRequester } from "@algolia/requester-browser-xhr";
2
3
  import {
3
- createMemoryCache,
4
- createFallbackableCache,
5
4
  createBrowserLocalStorageCache,
5
+ createFallbackableCache,
6
+ createMemoryCache,
7
+ createNullLogger,
6
8
  DEFAULT_CONNECT_TIMEOUT_BROWSER,
7
9
  DEFAULT_READ_TIMEOUT_BROWSER,
8
10
  DEFAULT_WRITE_TIMEOUT_BROWSER
9
11
  } from "@algolia/client-common";
10
- import { createXhrRequester } from "@algolia/requester-browser-xhr";
11
12
 
12
13
  // src/monitoringClient.ts
13
14
  import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
14
- var apiClientVersion = "1.2.4";
15
+ var apiClientVersion = "1.10.0";
15
16
  function getDefaultHosts() {
16
17
  return [{ url: "status.algolia.com", accept: "readWrite", protocol: "https" }];
17
18
  }
@@ -69,8 +70,20 @@ function createMonitoringClient({
69
70
  transporter.algoliaAgent.add({ segment, version });
70
71
  },
71
72
  /**
72
- * This method allow you to send requests to the Algolia REST API.
73
+ * Helper method to switch the API key used to authenticate the requests.
73
74
  *
75
+ * @param params - Method params.
76
+ * @param params.apiKey - The new API Key to use.
77
+ */
78
+ setClientApiKey({ apiKey }) {
79
+ if (!authMode || authMode === "WithinHeaders") {
80
+ transporter.baseHeaders["x-algolia-api-key"] = apiKey;
81
+ } else {
82
+ transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
83
+ }
84
+ },
85
+ /**
86
+ * This method allow you to send requests to the Algolia REST API.
74
87
  * @param customDelete - The customDelete object.
75
88
  * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
76
89
  * @param customDelete.parameters - Query parameters to apply to the current query.
@@ -93,7 +106,6 @@ function createMonitoringClient({
93
106
  },
94
107
  /**
95
108
  * This method allow you to send requests to the Algolia REST API.
96
- *
97
109
  * @param customGet - The customGet object.
98
110
  * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
99
111
  * @param customGet.parameters - Query parameters to apply to the current query.
@@ -116,7 +128,6 @@ function createMonitoringClient({
116
128
  },
117
129
  /**
118
130
  * This method allow you to send requests to the Algolia REST API.
119
- *
120
131
  * @param customPost - The customPost object.
121
132
  * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
122
133
  * @param customPost.parameters - Query parameters to apply to the current query.
@@ -141,7 +152,6 @@ function createMonitoringClient({
141
152
  },
142
153
  /**
143
154
  * This method allow you to send requests to the Algolia REST API.
144
- *
145
155
  * @param customPut - The customPut object.
146
156
  * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
147
157
  * @param customPut.parameters - Query parameters to apply to the current query.
@@ -166,9 +176,8 @@ function createMonitoringClient({
166
176
  },
167
177
  /**
168
178
  * Retrieves known incidents for the selected clusters.
169
- *
170
179
  * @param getClusterIncidents - The getClusterIncidents object.
171
- * @param getClusterIncidents.clusters - Subset of clusters, separated by comma.
180
+ * @param getClusterIncidents.clusters - Subset of clusters, separated by commas.
172
181
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
173
182
  */
174
183
  getClusterIncidents({ clusters }, requestOptions) {
@@ -188,9 +197,8 @@ function createMonitoringClient({
188
197
  },
189
198
  /**
190
199
  * Retrieves the status of selected clusters.
191
- *
192
200
  * @param getClusterStatus - The getClusterStatus object.
193
- * @param getClusterStatus.clusters - Subset of clusters, separated by comma.
201
+ * @param getClusterStatus.clusters - Subset of clusters, separated by commas.
194
202
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
195
203
  */
196
204
  getClusterStatus({ clusters }, requestOptions) {
@@ -210,7 +218,6 @@ function createMonitoringClient({
210
218
  },
211
219
  /**
212
220
  * Retrieves known incidents for all clusters.
213
- *
214
221
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
215
222
  */
216
223
  getIncidents(requestOptions) {
@@ -227,9 +234,8 @@ function createMonitoringClient({
227
234
  },
228
235
  /**
229
236
  * Retrieves average times for indexing operations for selected clusters.
230
- *
231
237
  * @param getIndexingTime - The getIndexingTime object.
232
- * @param getIndexingTime.clusters - Subset of clusters, separated by comma.
238
+ * @param getIndexingTime.clusters - Subset of clusters, separated by commas.
233
239
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
234
240
  */
235
241
  getIndexingTime({ clusters }, requestOptions) {
@@ -249,9 +255,8 @@ function createMonitoringClient({
249
255
  },
250
256
  /**
251
257
  * Retrieves the average latency for search requests for selected clusters.
252
- *
253
258
  * @param getLatency - The getLatency object.
254
- * @param getLatency.clusters - Subset of clusters, separated by comma.
259
+ * @param getLatency.clusters - Subset of clusters, separated by commas.
255
260
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
256
261
  */
257
262
  getLatency({ clusters }, requestOptions) {
@@ -271,7 +276,6 @@ function createMonitoringClient({
271
276
  },
272
277
  /**
273
278
  * Retrieves metrics related to your Algolia infrastructure, aggregated over a selected time window. Access to this API is available as part of the [Premium or Elevate plans](https://www.algolia.com/pricing). You must authenticate requests with the `x-algolia-application-id` and `x-algolia-api-key` headers (using the Monitoring API key).
274
- *
275
279
  * @param getMetrics - The getMetrics object.
276
280
  * @param getMetrics.metric - Metric to report. For more information about the individual metrics, see the description of the API response. To include all metrics, use `*`.
277
281
  * @param getMetrics.period - Period over which to aggregate the metrics: - `minute`. Aggregate the last minute. 1 data point per 10 seconds. - `hour`. Aggregate the last hour. 1 data point per minute. - `day`. Aggregate the last day. 1 data point per 10 minutes. - `week`. Aggregate the last week. 1 data point per hour. - `month`. Aggregate the last month. 1 data point per day.
@@ -297,9 +301,8 @@ function createMonitoringClient({
297
301
  },
298
302
  /**
299
303
  * Test whether clusters are reachable or not.
300
- *
301
304
  * @param getReachability - The getReachability object.
302
- * @param getReachability.clusters - Subset of clusters, separated by comma.
305
+ * @param getReachability.clusters - Subset of clusters, separated by commas.
303
306
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
304
307
  */
305
308
  getReachability({ clusters }, requestOptions) {
@@ -319,7 +322,6 @@ function createMonitoringClient({
319
322
  },
320
323
  /**
321
324
  * Retrieves the servers that belong to clusters. The response depends on whether you authenticate your API request: - With authentication, the response lists the servers assigned to your Algolia application\'s cluster. - Without authentication, the response lists the servers for all Algolia clusters.
322
- *
323
325
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
324
326
  */
325
327
  getServers(requestOptions) {
@@ -336,7 +338,6 @@ function createMonitoringClient({
336
338
  },
337
339
  /**
338
340
  * Retrieves the status of all Algolia clusters and instances.
339
- *
340
341
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
341
342
  */
342
343
  getStatus(requestOptions) {
@@ -370,6 +371,7 @@ function monitoringClient(appId, apiKey, options) {
370
371
  read: DEFAULT_READ_TIMEOUT_BROWSER,
371
372
  write: DEFAULT_WRITE_TIMEOUT_BROWSER
372
373
  },
374
+ logger: createNullLogger(),
373
375
  requester: createXhrRequester(),
374
376
  algoliaAgents: [{ segment: "Browser" }],
375
377
  authMode: "WithinQueryParameters",