@algolia/monitoring
Advanced tools
Comparing version 1.2.5 to 1.3.0
import * as _algolia_client_common from '@algolia/client-common'; | ||
import { ClientOptions } from '@algolia/client-common'; | ||
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common'; | ||
type BadRequest = { | ||
reason?: string; | ||
}; | ||
type Metric = '*' | 'avg_build_time' | 'cpu_usage' | 'ram_indexing_usage' | 'ram_search_usage' | 'ssd_usage'; | ||
type Period = 'day' | 'hour' | 'minute' | 'month' | 'week'; | ||
/** | ||
* Error. | ||
* Properties for the `customDelete` method. | ||
*/ | ||
type ErrorBase = Record<string, any> & { | ||
message?: string; | ||
type CustomDeleteProps = { | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
*/ | ||
path: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
*/ | ||
parameters?: Record<string, any>; | ||
}; | ||
type Forbidden = { | ||
reason?: string; | ||
/** | ||
* Properties for the `customGet` method. | ||
*/ | ||
type CustomGetProps = { | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
*/ | ||
path: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
*/ | ||
parameters?: Record<string, any>; | ||
}; | ||
/** | ||
* Properties for the `customPost` method. | ||
*/ | ||
type CustomPostProps = { | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
*/ | ||
path: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
*/ | ||
parameters?: Record<string, any>; | ||
/** | ||
* Parameters to send with the custom request. | ||
*/ | ||
body?: Record<string, unknown>; | ||
}; | ||
/** | ||
* Properties for the `customPut` method. | ||
*/ | ||
type CustomPutProps = { | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
*/ | ||
path: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
*/ | ||
parameters?: Record<string, any>; | ||
/** | ||
* Parameters to send with the custom request. | ||
*/ | ||
body?: Record<string, unknown>; | ||
}; | ||
/** | ||
* Properties for the `getClusterIncidents` method. | ||
*/ | ||
type GetClusterIncidentsProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getClusterStatus` method. | ||
*/ | ||
type GetClusterStatusProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getIndexingTime` method. | ||
*/ | ||
type GetIndexingTimeProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getLatency` method. | ||
*/ | ||
type GetLatencyProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getMetrics` method. | ||
*/ | ||
type GetMetricsProps = { | ||
/** | ||
* Metric to report. For more information about the individual metrics, see the description of the API response. To include all metrics, use `*`. | ||
*/ | ||
metric: Metric; | ||
/** | ||
* 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. | ||
*/ | ||
period: Period; | ||
}; | ||
/** | ||
* Properties for the `getReachability` method. | ||
*/ | ||
type GetReachabilityProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
@@ -147,6 +255,2 @@ /** | ||
type Metric = '*' | 'avg_build_time' | 'cpu_usage' | 'ram_indexing_usage' | 'ram_search_usage' | 'ssd_usage'; | ||
type Period = 'day' | 'hour' | 'minute' | 'month' | 'week'; | ||
type StatusResponse = { | ||
@@ -156,152 +260,163 @@ status?: Record<string, Status>; | ||
type Unauthorized = { | ||
reason?: string; | ||
}; | ||
/** | ||
* Properties for the `customDelete` method. | ||
*/ | ||
type CustomDeleteProps = { | ||
declare const apiClientVersion = "1.3.0"; | ||
declare function createMonitoringClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): { | ||
transporter: _algolia_client_common.Transporter; | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
* The `appId` currently in use. | ||
*/ | ||
path: string; | ||
appId: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties. | ||
*/ | ||
parameters?: Record<string, any>; | ||
}; | ||
/** | ||
* Properties for the `customGet` method. | ||
*/ | ||
type CustomGetProps = { | ||
clearCache(): Promise<void>; | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system. | ||
*/ | ||
path: string; | ||
readonly _ua: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
* Adds a `segment` to the `x-algolia-agent` sent with every requests. | ||
* | ||
* @param segment - The algolia agent (user-agent) segment to add. | ||
* @param version - The version of the agent. | ||
*/ | ||
parameters?: Record<string, any>; | ||
}; | ||
/** | ||
* Properties for the `customPost` method. | ||
*/ | ||
type CustomPostProps = { | ||
addAlgoliaAgent(segment: string, version?: string): void; | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
* Helper method to switch the API key used to authenticate the requests. | ||
* | ||
* @param params - Method params. | ||
* @param params.apiKey - The new API Key to use. | ||
*/ | ||
path: string; | ||
setClientApiKey({ apiKey }: { | ||
apiKey: string; | ||
}): void; | ||
/** | ||
* Query parameters to apply to the current query. | ||
* This method allow you to send requests to the Algolia REST API. | ||
* | ||
* @param customDelete - The customDelete object. | ||
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified. | ||
* @param customDelete.parameters - Query parameters to apply to the current query. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
parameters?: Record<string, any>; | ||
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>; | ||
/** | ||
* Parameters to send with the custom request. | ||
* This method allow you to send requests to the Algolia REST API. | ||
* | ||
* @param customGet - The customGet object. | ||
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified. | ||
* @param customGet.parameters - Query parameters to apply to the current query. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
body?: Record<string, unknown>; | ||
}; | ||
/** | ||
* Properties for the `customPut` method. | ||
*/ | ||
type CustomPutProps = { | ||
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>; | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
* This method allow you to send requests to the Algolia REST API. | ||
* | ||
* @param customPost - The customPost object. | ||
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified. | ||
* @param customPost.parameters - Query parameters to apply to the current query. | ||
* @param customPost.body - Parameters to send with the custom request. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
path: string; | ||
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>; | ||
/** | ||
* Query parameters to apply to the current query. | ||
* This method allow you to send requests to the Algolia REST API. | ||
* | ||
* @param customPut - The customPut object. | ||
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified. | ||
* @param customPut.parameters - Query parameters to apply to the current query. | ||
* @param customPut.body - Parameters to send with the custom request. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
parameters?: Record<string, any>; | ||
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>; | ||
/** | ||
* Parameters to send with the custom request. | ||
* Retrieves known incidents for the selected clusters. | ||
* | ||
* @param getClusterIncidents - The getClusterIncidents object. | ||
* @param getClusterIncidents.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
body?: Record<string, unknown>; | ||
}; | ||
/** | ||
* Properties for the `getClusterIncidents` method. | ||
*/ | ||
type GetClusterIncidentsProps = { | ||
getClusterIncidents({ clusters }: GetClusterIncidentsProps, requestOptions?: RequestOptions): Promise<IncidentsResponse>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* Retrieves the status of selected clusters. | ||
* | ||
* @param getClusterStatus - The getClusterStatus object. | ||
* @param getClusterStatus.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getClusterStatus` method. | ||
*/ | ||
type GetClusterStatusProps = { | ||
getClusterStatus({ clusters }: GetClusterStatusProps, requestOptions?: RequestOptions): Promise<StatusResponse>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* Retrieves known incidents for all clusters. | ||
* | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getIndexingTime` method. | ||
*/ | ||
type GetIndexingTimeProps = { | ||
getIncidents(requestOptions?: RequestOptions): Promise<IncidentsResponse>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* Retrieves average times for indexing operations for selected clusters. | ||
* | ||
* @param getIndexingTime - The getIndexingTime object. | ||
* @param getIndexingTime.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getLatency` method. | ||
*/ | ||
type GetLatencyProps = { | ||
getIndexingTime({ clusters }: GetIndexingTimeProps, requestOptions?: RequestOptions): Promise<IndexingTimeResponse>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* Retrieves the average latency for search requests for selected clusters. | ||
* | ||
* @param getLatency - The getLatency object. | ||
* @param getLatency.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getMetrics` method. | ||
*/ | ||
type GetMetricsProps = { | ||
getLatency({ clusters }: GetLatencyProps, requestOptions?: RequestOptions): Promise<LatencyResponse>; | ||
/** | ||
* Metric to report. For more information about the individual metrics, see the description of the API response. To include all metrics, use `*`. | ||
* 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). | ||
* | ||
* @param getMetrics - The getMetrics object. | ||
* @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 `*`. | ||
* @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. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
metric: Metric; | ||
getMetrics({ metric, period }: GetMetricsProps, requestOptions?: RequestOptions): Promise<InfrastructureResponse>; | ||
/** | ||
* 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. | ||
* Test whether clusters are reachable or not. | ||
* | ||
* @param getReachability - The getReachability object. | ||
* @param getReachability.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
period: Period; | ||
}; | ||
/** | ||
* Properties for the `getReachability` method. | ||
*/ | ||
type GetReachabilityProps = { | ||
getReachability({ clusters }: GetReachabilityProps, requestOptions?: RequestOptions): Promise<Record<string, Record<string, boolean>>>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* 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. | ||
* | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
getServers(requestOptions?: RequestOptions): Promise<InventoryResponse>; | ||
/** | ||
* Retrieves the status of all Algolia clusters and instances. | ||
* | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
getStatus(requestOptions?: RequestOptions): Promise<StatusResponse>; | ||
}; | ||
declare const apiClientVersion = "1.2.5"; | ||
type BadRequest = { | ||
reason?: string; | ||
}; | ||
/** | ||
* The client type. | ||
* Error. | ||
*/ | ||
type MonitoringClient = ReturnType<typeof monitoringClient>; | ||
declare function monitoringClient(appId: string, apiKey: string, options?: ClientOptions): { | ||
transporter: _algolia_client_common.Transporter; | ||
appId: string; | ||
clearCache(): Promise<void>; | ||
readonly _ua: string; | ||
addAlgoliaAgent(segment: string, version?: string): void; | ||
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>; | ||
customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>; | ||
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>; | ||
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>; | ||
getClusterIncidents({ clusters }: GetClusterIncidentsProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<IncidentsResponse>; | ||
getClusterStatus({ clusters }: GetClusterStatusProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<StatusResponse>; | ||
getIncidents(requestOptions?: _algolia_client_common.RequestOptions): Promise<IncidentsResponse>; | ||
getIndexingTime({ clusters }: GetIndexingTimeProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<IndexingTimeResponse>; | ||
getLatency({ clusters }: GetLatencyProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<LatencyResponse>; | ||
getMetrics({ metric, period }: GetMetricsProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<InfrastructureResponse>; | ||
getReachability({ clusters }: GetReachabilityProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, Record<string, boolean>>>; | ||
getServers(requestOptions?: _algolia_client_common.RequestOptions): Promise<InventoryResponse>; | ||
getStatus(requestOptions?: _algolia_client_common.RequestOptions): Promise<StatusResponse>; | ||
type ErrorBase = Record<string, any> & { | ||
message?: string; | ||
}; | ||
type Forbidden = { | ||
reason?: string; | ||
}; | ||
type Unauthorized = { | ||
reason?: string; | ||
}; | ||
type MonitoringClient = ReturnType<typeof createMonitoringClient>; | ||
declare function monitoringClient(appId: string, apiKey: string, options?: ClientOptions): MonitoringClient; | ||
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 }; |
@@ -14,3 +14,3 @@ // builds/browser.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "1.2.5"; | ||
var apiClientVersion = "1.3.0"; | ||
function getDefaultHosts() { | ||
@@ -27,22 +27,21 @@ return [{ url: "status.algolia.com", accept: "readWrite", protocol: "https" }]; | ||
const auth = createAuth(appIdOption, apiKeyOption, authMode); | ||
const transporter = createTransporter({ | ||
hosts: getDefaultHosts(), | ||
...options, | ||
algoliaAgent: getAlgoliaAgent({ | ||
algoliaAgents, | ||
client: "Monitoring", | ||
version: apiClientVersion | ||
return { | ||
transporter: createTransporter({ | ||
hosts: getDefaultHosts(), | ||
...options, | ||
algoliaAgent: getAlgoliaAgent({ | ||
algoliaAgents, | ||
client: "Monitoring", | ||
version: apiClientVersion | ||
}), | ||
baseHeaders: { | ||
"content-type": "text/plain", | ||
...auth.headers(), | ||
...options.baseHeaders | ||
}, | ||
baseQueryParameters: { | ||
...auth.queryParameters(), | ||
...options.baseQueryParameters | ||
} | ||
}), | ||
baseHeaders: { | ||
"content-type": "text/plain", | ||
...auth.headers(), | ||
...options.baseHeaders | ||
}, | ||
baseQueryParameters: { | ||
...auth.queryParameters(), | ||
...options.baseQueryParameters | ||
} | ||
}); | ||
return { | ||
transporter, | ||
/** | ||
@@ -56,3 +55,5 @@ * The `appId` currently in use. | ||
clearCache() { | ||
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0); | ||
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then( | ||
() => void 0 | ||
); | ||
}, | ||
@@ -63,3 +64,3 @@ /** | ||
get _ua() { | ||
return transporter.algoliaAgent.value; | ||
return this.transporter.algoliaAgent.value; | ||
}, | ||
@@ -73,5 +74,14 @@ /** | ||
addAlgoliaAgent(segment, version) { | ||
transporter.algoliaAgent.add({ segment, version }); | ||
this.transporter.algoliaAgent.add({ segment, version }); | ||
}, | ||
/** | ||
* Helper method to switch the API key used to authenticate the requests. | ||
* | ||
* @param params - Method params. | ||
* @param params.apiKey - The new API Key to use. | ||
*/ | ||
setClientApiKey({ apiKey }) { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
}, | ||
/** | ||
* This method allow you to send requests to the Algolia REST API. | ||
@@ -97,3 +107,3 @@ * | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -121,3 +131,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -147,3 +157,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -173,3 +183,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -196,3 +206,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -219,3 +229,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -237,3 +247,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -260,3 +270,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -283,3 +293,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -310,3 +320,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -333,3 +343,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -351,3 +361,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -369,3 +379,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
} | ||
@@ -372,0 +382,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
function M(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function H(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function n(){return JSON.parse(r().getItem(s)||"{}")}function p(o){r().setItem(s,JSON.stringify(o))}function c(){let o=t.timeToLive?t.timeToLive*1e3:null,a=n(),u=Object.fromEntries(Object.entries(a).filter(([,d])=>d.timestamp!==void 0));if(p(u),!o)return;let l=Object.fromEntries(Object.entries(u).filter(([,d])=>{let i=new Date().getTime();return!(d.timestamp+o<i)}));p(l)}return{get(o,a,u={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(c(),n()[JSON.stringify(o)])).then(l=>Promise.all([l?l.value:a(),l!==void 0])).then(([l,d])=>Promise.all([l,d||u.miss(l)])).then(([l])=>l)},set(o,a){return Promise.resolve().then(()=>{let u=n();return u[JSON.stringify(o)]={timestamp:new Date().getTime(),value:a},r().setItem(s,JSON.stringify(u)),a})},delete(o){return Promise.resolve().then(()=>{let a=n();delete a[JSON.stringify(o)],r().setItem(s,JSON.stringify(a))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function K(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function T(t){let e=[...t.caches],s=e.shift();return s===void 0?K():{get(r,n,p={miss:()=>Promise.resolve()}){return s.get(r,n,p).catch(()=>T({caches:e}).get(r,n,p))},set(r,n){return s.set(r,n).catch(()=>T({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>T({caches:e}).delete(r))},clear(){return s.clear().catch(()=>T({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return{get(s,r,n={miss:()=>Promise.resolve()}){let p=JSON.stringify(s);if(p in e)return Promise.resolve(t.serializable?JSON.parse(e[p]):e[p]);let c=r();return c.then(o=>n.miss(o)).then(()=>c)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var G=2*60*1e3;function L(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>G}function n(){return e==="timed out"&&Date.now()-s<=G}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var k=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},W=class extends k{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},Y=class extends W{constructor(t){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.",t,"RetryError")}},I=class extends W{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},Z=class extends k{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},ee=class extends I{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function te(t,e,s){let r=re(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function re(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function se(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function oe(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(p=>{let c=r[p];n[p.toLowerCase()]=c}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new Z(e.message,t)}}function ne({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new ee(r.message,e,r.error,s):new I(r.message,e,s)}catch{}return new I(t,e,s)}function ie({isTimedOut:t,status:e}){return!t&&~~e===0}function ce({isTimedOut:t,status:e}){return t||ie({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ue({status:t}){return~~(t/100)===2}function le(t){return t.map(e=>J(e))}function J(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function Q({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:p,requester:c,requestsCache:o,responsesCache:a}){async function u(i){let m=await Promise.all(i.map(h=>e.get(h,()=>Promise.resolve(L(h))))),f=m.filter(h=>h.isUp()),g=m.filter(h=>h.isTimedOut()),E=[...f,...g];return{hosts:E.length>0?E:i,getTimeout(h,q){return(g.length===0&&h===0?1:g.length+3+h)*q}}}async function l(i,m,f=!0){let g=[],E=se(i,m),y=oe(s,i.headers,m.headers),h=i.method==="GET"?{...i.data,...m.data}:{},q={...r,...i.queryParameters,...h};if(n.value&&(q["x-algolia-agent"]=n.value),m&&m.queryParameters)for(let P of Object.keys(m.queryParameters))!m.queryParameters[P]||Object.prototype.toString.call(m.queryParameters[P])==="[object Object]"?q[P]=m.queryParameters[P]:q[P]=m.queryParameters[P].toString();let v=0,b=async(P,C)=>{let w=P.pop();if(w===void 0)throw new Y(le(g));let A={...p,...m.timeouts},N={data:E,headers:y,method:i.method,url:te(w,i.path,q),connectTimeout:C(v,A.connect),responseTimeout:C(v,f?A.read:A.write)},D=S=>{let _={request:N,response:S,host:w,triesLeft:P.length};return g.push(_),_},R=await c.send(N);if(ce(R)){let S=D(R);return R.isTimedOut&&v++,console.log("Retryable failure",J(S)),await e.set(w,L(w,R.isTimedOut?"timed out":"down")),b(P,C)}if(ue(R))return ae(R);throw D(R),ne(R,g)},V=t.filter(P=>P.accept==="readWrite"||(f?P.accept==="read":P.accept==="write")),U=await u(V);return b([...U.hosts].reverse(),U.getTimeout)}function d(i,m={}){let f=i.useReadTransporter||i.method==="GET";if(!f)return l(i,m,f);let g=()=>l(i,m);if((m.cacheable||i.cacheable)!==!0)return g();let y={request:i,requestOptions:m,transporter:{queryParameters:r,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,g()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,q])=>q)),{miss:h=>a.set(y,h)})}return{hostsCache:e,requester:c,timeouts:p,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:d,requestsCache:o,responsesCache:a}}function me(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function j({algoliaAgents:t,client:e,version:s}){let r=me(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var $=1e3,z=2e3,F=3e4;function B(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>r.setRequestHeader(o,e.headers[o]));let n=(o,a)=>setTimeout(()=>{r.abort(),s({status:0,content:a,isTimedOut:!0})},o),p=n(e.connectTimeout,"Connection timeout"),c;r.onreadystatechange=()=>{r.readyState>r.OPENED&&c===void 0&&(clearTimeout(p),c=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(p),clearTimeout(c),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(p),clearTimeout(c),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var x="1.2.5";function de(){return[{url:"status.algolia.com",accept:"readWrite",protocol:"https"}]}function X({appId:t,apiKey:e,authMode:s,algoliaAgents:r,...n}){let p=M(t,e,s),c=Q({hosts:de(),...n,algoliaAgent:j({algoliaAgents:r,client:"Monitoring",version:x}),baseHeaders:{"content-type":"text/plain",...p.headers(),...n.baseHeaders},baseQueryParameters:{...p.queryParameters(),...n.baseQueryParameters}});return{transporter:c,appId:t,clearCache(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then(()=>{})},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent(o,a){c.algoliaAgent.add({segment:o,version:a})},customDelete({path:o,parameters:a},u){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let m={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return c.request(m,u)},customGet({path:o,parameters:a},u){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let m={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return c.request(m,u)},customPost({path:o,parameters:a,body:u},l){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:u||{}};return c.request(f,l)},customPut({path:o,parameters:a,body:u},l){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:u||{}};return c.request(f,l)},getClusterIncidents({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getClusterIncidents`.");let i={method:"GET",path:"/1/incidents/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getClusterStatus({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getClusterStatus`.");let i={method:"GET",path:"/1/status/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getIncidents(o){let d={method:"GET",path:"/1/incidents",queryParameters:{},headers:{}};return c.request(d,o)},getIndexingTime({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getIndexingTime`.");let i={method:"GET",path:"/1/indexing/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getLatency({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getLatency`.");let i={method:"GET",path:"/1/latency/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getMetrics({metric:o,period:a},u){if(!o)throw new Error("Parameter `metric` is required when calling `getMetrics`.");if(!a)throw new Error("Parameter `period` is required when calling `getMetrics`.");let m={method:"GET",path:"/1/infrastructure/{metric}/period/{period}".replace("{metric}",encodeURIComponent(o)).replace("{period}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(m,u)},getReachability({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getReachability`.");let i={method:"GET",path:"/1/reachability/{clusters}/probes".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getServers(o){let d={method:"GET",path:"/1/inventory/servers",queryParameters:{},headers:{}};return c.request(d,o)},getStatus(o){let d={method:"GET",path:"/1/status",queryParameters:{},headers:{}};return c.request(d,o)}}}function Ze(t,e,s){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return X({appId:t,apiKey:e,timeouts:{connect:$,read:z,write:F},requester:B(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:T({caches:[H({key:`${x}-${t}`}),O()]}),...s})}export{x as apiClientVersion,Ze as monitoringClient}; | ||
function L(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function H(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function n(){return JSON.parse(r().getItem(s)||"{}")}function p(a){r().setItem(s,JSON.stringify(a))}function o(){let a=t.timeToLive?t.timeToLive*1e3:null,i=n(),l=Object.fromEntries(Object.entries(i).filter(([,h])=>h.timestamp!==void 0));if(p(l),!a)return;let c=Object.fromEntries(Object.entries(l).filter(([,h])=>{let u=new Date().getTime();return!(h.timestamp+a<u)}));p(c)}return{get(a,i,l={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(o(),n()[JSON.stringify(a)])).then(c=>Promise.all([c?c.value:i(),c!==void 0])).then(([c,h])=>Promise.all([c,h||l.miss(c)])).then(([c])=>c)},set(a,i){return Promise.resolve().then(()=>{let l=n();return l[JSON.stringify(a)]={timestamp:new Date().getTime(),value:i},r().setItem(s,JSON.stringify(l)),i})},delete(a){return Promise.resolve().then(()=>{let i=n();delete i[JSON.stringify(a)],r().setItem(s,JSON.stringify(i))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function V(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function T(t){let e=[...t.caches],s=e.shift();return s===void 0?V():{get(r,n,p={miss:()=>Promise.resolve()}){return s.get(r,n,p).catch(()=>T({caches:e}).get(r,n,p))},set(r,n){return s.set(r,n).catch(()=>T({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>T({caches:e}).delete(r))},clear(){return s.clear().catch(()=>T({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return{get(s,r,n={miss:()=>Promise.resolve()}){let p=JSON.stringify(s);if(p in e)return Promise.resolve(t.serializable?JSON.parse(e[p]):e[p]);let o=r();return o.then(a=>n.miss(a)).then(()=>o)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var G=2*60*1e3;function M(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>G}function n(){return e==="timed out"&&Date.now()-s<=G}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var k=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},W=class extends k{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},Y=class extends W{constructor(t){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.",t,"RetryError")}},I=class extends W{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},Z=class extends k{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},ee=class extends I{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function te(t,e,s){let r=re(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function re(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function se(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function oe(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(p=>{let o=r[p];n[p.toLowerCase()]=o}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new Z(e.message,t)}}function ne({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new ee(r.message,e,r.error,s):new I(r.message,e,s)}catch{}return new I(t,e,s)}function ie({isTimedOut:t,status:e}){return!t&&~~e===0}function ce({isTimedOut:t,status:e}){return t||ie({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ue({status:t}){return~~(t/100)===2}function le(t){return t.map(e=>J(e))}function J(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function Q({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:p,requester:o,requestsCache:a,responsesCache:i}){async function l(u){let m=await Promise.all(u.map(d=>e.get(d,()=>Promise.resolve(M(d))))),R=m.filter(d=>d.isUp()),f=m.filter(d=>d.isTimedOut()),E=[...R,...f];return{hosts:E.length>0?E:u,getTimeout(d,y){return(f.length===0&&d===0?1:f.length+3+d)*y}}}async function c(u,m,R=!0){let f=[],E=se(u,m),g=oe(s,u.headers,m.headers),d=u.method==="GET"?{...u.data,...m.data}:{},y={...r,...u.queryParameters,...d};if(n.value&&(y["x-algolia-agent"]=n.value),m&&m.queryParameters)for(let P of Object.keys(m.queryParameters))!m.queryParameters[P]||Object.prototype.toString.call(m.queryParameters[P])==="[object Object]"?y[P]=m.queryParameters[P]:y[P]=m.queryParameters[P].toString();let v=0,b=async(P,C)=>{let w=P.pop();if(w===void 0)throw new Y(le(f));let A={...p,...m.timeouts},N={data:E,headers:g,method:u.method,url:te(w,u.path,y),connectTimeout:C(v,A.connect),responseTimeout:C(v,R?A.read:A.write)},D=S=>{let _={request:N,response:S,host:w,triesLeft:P.length};return f.push(_),_},q=await o.send(N);if(ce(q)){let S=D(q);return q.isTimedOut&&v++,console.log("Retryable failure",J(S)),await e.set(w,M(w,q.isTimedOut?"timed out":"down")),b(P,C)}if(ue(q))return ae(q);throw D(q),ne(q,f)},K=t.filter(P=>P.accept==="readWrite"||(R?P.accept==="read":P.accept==="write")),U=await l(K);return b([...U.hosts].reverse(),U.getTimeout)}function h(u,m={}){let R=u.useReadTransporter||u.method==="GET";if(!R)return c(u,m,R);let f=()=>c(u,m);if((m.cacheable||u.cacheable)!==!0)return f();let g={request:u,requestOptions:m,transporter:{queryParameters:r,headers:s}};return i.get(g,()=>a.get(g,()=>a.set(g,f()).then(d=>Promise.all([a.delete(g),d]),d=>Promise.all([a.delete(g),Promise.reject(d)])).then(([d,y])=>y)),{miss:d=>i.set(g,d)})}return{hostsCache:e,requester:o,timeouts:p,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:h,requestsCache:a,responsesCache:i}}function me(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function j({algoliaAgents:t,client:e,version:s}){let r=me(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var $=1e3,z=2e3,F=3e4;function B(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let n=(a,i)=>setTimeout(()=>{r.abort(),s({status:0,content:i,isTimedOut:!0})},a),p=n(e.connectTimeout,"Connection timeout"),o;r.onreadystatechange=()=>{r.readyState>r.OPENED&&o===void 0&&(clearTimeout(p),o=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(p),clearTimeout(o),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(p),clearTimeout(o),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var x="1.3.0";function pe(){return[{url:"status.algolia.com",accept:"readWrite",protocol:"https"}]}function X({appId:t,apiKey:e,authMode:s,algoliaAgents:r,...n}){let p=L(t,e,s);return{transporter:Q({hosts:pe(),...n,algoliaAgent:j({algoliaAgents:r,client:"Monitoring",version:x}),baseHeaders:{"content-type":"text/plain",...p.headers(),...n.baseHeaders},baseQueryParameters:{...p.queryParameters(),...n.baseQueryParameters}}),appId:t,clearCache(){return Promise.all([this.transporter.requestsCache.clear(),this.transporter.responsesCache.clear()]).then(()=>{})},get _ua(){return this.transporter.algoliaAgent.value},addAlgoliaAgent(o,a){this.transporter.algoliaAgent.add({segment:o,version:a})},setClientApiKey({apiKey:o}){this.transporter.baseHeaders["x-algolia-api-key"]=o},customDelete({path:o,parameters:a},i){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(u,i)},customGet({path:o,parameters:a},i){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(u,i)},customPost({path:o,parameters:a,body:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let m={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:i||{}};return this.transporter.request(m,l)},customPut({path:o,parameters:a,body:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let m={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:i||{}};return this.transporter.request(m,l)},getClusterIncidents({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getClusterIncidents`.");let h={method:"GET",path:"/1/incidents/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getClusterStatus({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getClusterStatus`.");let h={method:"GET",path:"/1/status/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getIncidents(o){let c={method:"GET",path:"/1/incidents",queryParameters:{},headers:{}};return this.transporter.request(c,o)},getIndexingTime({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getIndexingTime`.");let h={method:"GET",path:"/1/indexing/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getLatency({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getLatency`.");let h={method:"GET",path:"/1/latency/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getMetrics({metric:o,period:a},i){if(!o)throw new Error("Parameter `metric` is required when calling `getMetrics`.");if(!a)throw new Error("Parameter `period` is required when calling `getMetrics`.");let u={method:"GET",path:"/1/infrastructure/{metric}/period/{period}".replace("{metric}",encodeURIComponent(o)).replace("{period}",encodeURIComponent(a)),queryParameters:{},headers:{}};return this.transporter.request(u,i)},getReachability({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getReachability`.");let h={method:"GET",path:"/1/reachability/{clusters}/probes".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getServers(o){let c={method:"GET",path:"/1/inventory/servers",queryParameters:{},headers:{}};return this.transporter.request(c,o)},getStatus(o){let c={method:"GET",path:"/1/status",queryParameters:{},headers:{}};return this.transporter.request(c,o)}}}function Ze(t,e,s){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return X({appId:t,apiKey:e,timeouts:{connect:$,read:z,write:F},requester:B(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:T({caches:[H({key:`${x}-${t}`}),O()]}),...s})}export{x as apiClientVersion,Ze as monitoringClient}; | ||
//# sourceMappingURL=browser.min.js.map |
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
function M(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return {headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function H(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function n(){return JSON.parse(r().getItem(s)||"{}")}function p(o){r().setItem(s,JSON.stringify(o));}function c(){let o=t.timeToLive?t.timeToLive*1e3:null,a=n(),u=Object.fromEntries(Object.entries(a).filter(([,d])=>d.timestamp!==void 0));if(p(u),!o)return;let l=Object.fromEntries(Object.entries(u).filter(([,d])=>{let i=new Date().getTime();return !(d.timestamp+o<i)}));p(l);}return {get(o,a,u={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(c(),n()[JSON.stringify(o)])).then(l=>Promise.all([l?l.value:a(),l!==void 0])).then(([l,d])=>Promise.all([l,d||u.miss(l)])).then(([l])=>l)},set(o,a){return Promise.resolve().then(()=>{let u=n();return u[JSON.stringify(o)]={timestamp:new Date().getTime(),value:a},r().setItem(s,JSON.stringify(u)),a})},delete(o){return Promise.resolve().then(()=>{let a=n();delete a[JSON.stringify(o)],r().setItem(s,JSON.stringify(a));})},clear(){return Promise.resolve().then(()=>{r().removeItem(s);})}}}function K(){return {get(t,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function T(t){let e=[...t.caches],s=e.shift();return s===void 0?K():{get(r,n,p={miss:()=>Promise.resolve()}){return s.get(r,n,p).catch(()=>T({caches:e}).get(r,n,p))},set(r,n){return s.set(r,n).catch(()=>T({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>T({caches:e}).delete(r))},clear(){return s.clear().catch(()=>T({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return {get(s,r,n={miss:()=>Promise.resolve()}){let p=JSON.stringify(s);if(p in e)return Promise.resolve(t.serializable?JSON.parse(e[p]):e[p]);let c=r();return c.then(o=>n.miss(o)).then(()=>c)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var G=2*60*1e3;function L(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>G}function n(){return e==="timed out"&&Date.now()-s<=G}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var k=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},W=class extends k{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},Y=class extends W{constructor(t){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.",t,"RetryError");}},I=class extends W{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},Z=class extends k{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},ee=class extends I{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function te(t,e,s){let r=re(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function re(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function se(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function oe(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(p=>{let c=r[p];n[p.toLowerCase()]=c;}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new Z(e.message,t)}}function ne({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new ee(r.message,e,r.error,s):new I(r.message,e,s)}catch{}return new I(t,e,s)}function ie({isTimedOut:t,status:e}){return !t&&~~e===0}function ce({isTimedOut:t,status:e}){return t||ie({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ue({status:t}){return ~~(t/100)===2}function le(t){return t.map(e=>J(e))}function J(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function Q({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:p,requester:c,requestsCache:o,responsesCache:a}){async function u(i){let m=await Promise.all(i.map(h=>e.get(h,()=>Promise.resolve(L(h))))),f=m.filter(h=>h.isUp()),g=m.filter(h=>h.isTimedOut()),E=[...f,...g];return {hosts:E.length>0?E:i,getTimeout(h,q){return (g.length===0&&h===0?1:g.length+3+h)*q}}}async function l(i,m,f=!0){let g=[],E=se(i,m),y=oe(s,i.headers,m.headers),h=i.method==="GET"?{...i.data,...m.data}:{},q={...r,...i.queryParameters,...h};if(n.value&&(q["x-algolia-agent"]=n.value),m&&m.queryParameters)for(let P of Object.keys(m.queryParameters))!m.queryParameters[P]||Object.prototype.toString.call(m.queryParameters[P])==="[object Object]"?q[P]=m.queryParameters[P]:q[P]=m.queryParameters[P].toString();let v=0,b=async(P,C)=>{let w=P.pop();if(w===void 0)throw new Y(le(g));let A={...p,...m.timeouts},N={data:E,headers:y,method:i.method,url:te(w,i.path,q),connectTimeout:C(v,A.connect),responseTimeout:C(v,f?A.read:A.write)},D=S=>{let _={request:N,response:S,host:w,triesLeft:P.length};return g.push(_),_},R=await c.send(N);if(ce(R)){let S=D(R);return R.isTimedOut&&v++,console.log("Retryable failure",J(S)),await e.set(w,L(w,R.isTimedOut?"timed out":"down")),b(P,C)}if(ue(R))return ae(R);throw D(R),ne(R,g)},V=t.filter(P=>P.accept==="readWrite"||(f?P.accept==="read":P.accept==="write")),U=await u(V);return b([...U.hosts].reverse(),U.getTimeout)}function d(i,m={}){let f=i.useReadTransporter||i.method==="GET";if(!f)return l(i,m,f);let g=()=>l(i,m);if((m.cacheable||i.cacheable)!==!0)return g();let y={request:i,requestOptions:m,transporter:{queryParameters:r,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,g()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,q])=>q)),{miss:h=>a.set(y,h)})}return {hostsCache:e,requester:c,timeouts:p,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:d,requestsCache:o,responsesCache:a}}function me(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function j({algoliaAgents:t,client:e,version:s}){let r=me(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var $=1e3,z=2e3,F=3e4;function B(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>r.setRequestHeader(o,e.headers[o]));let n=(o,a)=>setTimeout(()=>{r.abort(),s({status:0,content:a,isTimedOut:!0});},o),p=n(e.connectTimeout,"Connection timeout"),c;r.onreadystatechange=()=>{r.readyState>r.OPENED&&c===void 0&&(clearTimeout(p),c=n(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(p),clearTimeout(c),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(p),clearTimeout(c),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}var x="1.2.5";function de(){return [{url:"status.algolia.com",accept:"readWrite",protocol:"https"}]}function X({appId:t,apiKey:e,authMode:s,algoliaAgents:r,...n}){let p=M(t,e,s),c=Q({hosts:de(),...n,algoliaAgent:j({algoliaAgents:r,client:"Monitoring",version:x}),baseHeaders:{"content-type":"text/plain",...p.headers(),...n.baseHeaders},baseQueryParameters:{...p.queryParameters(),...n.baseQueryParameters}});return {transporter:c,appId:t,clearCache(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then(()=>{})},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent(o,a){c.algoliaAgent.add({segment:o,version:a});},customDelete({path:o,parameters:a},u){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let m={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return c.request(m,u)},customGet({path:o,parameters:a},u){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let m={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return c.request(m,u)},customPost({path:o,parameters:a,body:u},l){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:u||{}};return c.request(f,l)},customPut({path:o,parameters:a,body:u},l){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:u||{}};return c.request(f,l)},getClusterIncidents({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getClusterIncidents`.");let i={method:"GET",path:"/1/incidents/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getClusterStatus({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getClusterStatus`.");let i={method:"GET",path:"/1/status/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getIncidents(o){let d={method:"GET",path:"/1/incidents",queryParameters:{},headers:{}};return c.request(d,o)},getIndexingTime({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getIndexingTime`.");let i={method:"GET",path:"/1/indexing/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getLatency({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getLatency`.");let i={method:"GET",path:"/1/latency/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getMetrics({metric:o,period:a},u){if(!o)throw new Error("Parameter `metric` is required when calling `getMetrics`.");if(!a)throw new Error("Parameter `period` is required when calling `getMetrics`.");let m={method:"GET",path:"/1/infrastructure/{metric}/period/{period}".replace("{metric}",encodeURIComponent(o)).replace("{period}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(m,u)},getReachability({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getReachability`.");let i={method:"GET",path:"/1/reachability/{clusters}/probes".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return c.request(i,a)},getServers(o){let d={method:"GET",path:"/1/inventory/servers",queryParameters:{},headers:{}};return c.request(d,o)},getStatus(o){let d={method:"GET",path:"/1/status",queryParameters:{},headers:{}};return c.request(d,o)}}}function Ze(t,e,s){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return X({appId:t,apiKey:e,timeouts:{connect:$,read:z,write:F},requester:B(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:T({caches:[H({key:`${x}-${t}`}),O()]}),...s})} | ||
function L(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return {headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function H(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function n(){return JSON.parse(r().getItem(s)||"{}")}function p(a){r().setItem(s,JSON.stringify(a));}function o(){let a=t.timeToLive?t.timeToLive*1e3:null,i=n(),l=Object.fromEntries(Object.entries(i).filter(([,h])=>h.timestamp!==void 0));if(p(l),!a)return;let c=Object.fromEntries(Object.entries(l).filter(([,h])=>{let u=new Date().getTime();return !(h.timestamp+a<u)}));p(c);}return {get(a,i,l={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(o(),n()[JSON.stringify(a)])).then(c=>Promise.all([c?c.value:i(),c!==void 0])).then(([c,h])=>Promise.all([c,h||l.miss(c)])).then(([c])=>c)},set(a,i){return Promise.resolve().then(()=>{let l=n();return l[JSON.stringify(a)]={timestamp:new Date().getTime(),value:i},r().setItem(s,JSON.stringify(l)),i})},delete(a){return Promise.resolve().then(()=>{let i=n();delete i[JSON.stringify(a)],r().setItem(s,JSON.stringify(i));})},clear(){return Promise.resolve().then(()=>{r().removeItem(s);})}}}function V(){return {get(t,e,s={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,s.miss(n)])).then(([n])=>n)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function T(t){let e=[...t.caches],s=e.shift();return s===void 0?V():{get(r,n,p={miss:()=>Promise.resolve()}){return s.get(r,n,p).catch(()=>T({caches:e}).get(r,n,p))},set(r,n){return s.set(r,n).catch(()=>T({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>T({caches:e}).delete(r))},clear(){return s.clear().catch(()=>T({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return {get(s,r,n={miss:()=>Promise.resolve()}){let p=JSON.stringify(s);if(p in e)return Promise.resolve(t.serializable?JSON.parse(e[p]):e[p]);let o=r();return o.then(a=>n.miss(a)).then(()=>o)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var G=2*60*1e3;function M(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>G}function n(){return e==="timed out"&&Date.now()-s<=G}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var k=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},W=class extends k{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},Y=class extends W{constructor(t){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.",t,"RetryError");}},I=class extends W{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},Z=class extends k{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},ee=class extends I{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function te(t,e,s){let r=re(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function re(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replaceAll("+","%20")}`).join("&")}function se(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function oe(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(p=>{let o=r[p];n[p.toLowerCase()]=o;}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new Z(e.message,t)}}function ne({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new ee(r.message,e,r.error,s):new I(r.message,e,s)}catch{}return new I(t,e,s)}function ie({isTimedOut:t,status:e}){return !t&&~~e===0}function ce({isTimedOut:t,status:e}){return t||ie({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ue({status:t}){return ~~(t/100)===2}function le(t){return t.map(e=>J(e))}function J(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function Q({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:p,requester:o,requestsCache:a,responsesCache:i}){async function l(u){let m=await Promise.all(u.map(d=>e.get(d,()=>Promise.resolve(M(d))))),R=m.filter(d=>d.isUp()),f=m.filter(d=>d.isTimedOut()),E=[...R,...f];return {hosts:E.length>0?E:u,getTimeout(d,y){return (f.length===0&&d===0?1:f.length+3+d)*y}}}async function c(u,m,R=!0){let f=[],E=se(u,m),g=oe(s,u.headers,m.headers),d=u.method==="GET"?{...u.data,...m.data}:{},y={...r,...u.queryParameters,...d};if(n.value&&(y["x-algolia-agent"]=n.value),m&&m.queryParameters)for(let P of Object.keys(m.queryParameters))!m.queryParameters[P]||Object.prototype.toString.call(m.queryParameters[P])==="[object Object]"?y[P]=m.queryParameters[P]:y[P]=m.queryParameters[P].toString();let v=0,b=async(P,C)=>{let w=P.pop();if(w===void 0)throw new Y(le(f));let A={...p,...m.timeouts},N={data:E,headers:g,method:u.method,url:te(w,u.path,y),connectTimeout:C(v,A.connect),responseTimeout:C(v,R?A.read:A.write)},D=S=>{let _={request:N,response:S,host:w,triesLeft:P.length};return f.push(_),_},q=await o.send(N);if(ce(q)){let S=D(q);return q.isTimedOut&&v++,console.log("Retryable failure",J(S)),await e.set(w,M(w,q.isTimedOut?"timed out":"down")),b(P,C)}if(ue(q))return ae(q);throw D(q),ne(q,f)},K=t.filter(P=>P.accept==="readWrite"||(R?P.accept==="read":P.accept==="write")),U=await l(K);return b([...U.hosts].reverse(),U.getTimeout)}function h(u,m={}){let R=u.useReadTransporter||u.method==="GET";if(!R)return c(u,m,R);let f=()=>c(u,m);if((m.cacheable||u.cacheable)!==!0)return f();let g={request:u,requestOptions:m,transporter:{queryParameters:r,headers:s}};return i.get(g,()=>a.get(g,()=>a.set(g,f()).then(d=>Promise.all([a.delete(g),d]),d=>Promise.all([a.delete(g),Promise.reject(d)])).then(([d,y])=>y)),{miss:d=>i.set(g,d)})}return {hostsCache:e,requester:o,timeouts:p,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:h,requestsCache:a,responsesCache:i}}function me(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function j({algoliaAgents:t,client:e,version:s}){let r=me(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var $=1e3,z=2e3,F=3e4;function B(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let n=(a,i)=>setTimeout(()=>{r.abort(),s({status:0,content:i,isTimedOut:!0});},a),p=n(e.connectTimeout,"Connection timeout"),o;r.onreadystatechange=()=>{r.readyState>r.OPENED&&o===void 0&&(clearTimeout(p),o=n(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(p),clearTimeout(o),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(p),clearTimeout(o),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}var x="1.3.0";function pe(){return [{url:"status.algolia.com",accept:"readWrite",protocol:"https"}]}function X({appId:t,apiKey:e,authMode:s,algoliaAgents:r,...n}){let p=L(t,e,s);return {transporter:Q({hosts:pe(),...n,algoliaAgent:j({algoliaAgents:r,client:"Monitoring",version:x}),baseHeaders:{"content-type":"text/plain",...p.headers(),...n.baseHeaders},baseQueryParameters:{...p.queryParameters(),...n.baseQueryParameters}}),appId:t,clearCache(){return Promise.all([this.transporter.requestsCache.clear(),this.transporter.responsesCache.clear()]).then(()=>{})},get _ua(){return this.transporter.algoliaAgent.value},addAlgoliaAgent(o,a){this.transporter.algoliaAgent.add({segment:o,version:a});},setClientApiKey({apiKey:o}){this.transporter.baseHeaders["x-algolia-api-key"]=o;},customDelete({path:o,parameters:a},i){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(u,i)},customGet({path:o,parameters:a},i){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(u,i)},customPost({path:o,parameters:a,body:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let m={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:i||{}};return this.transporter.request(m,l)},customPut({path:o,parameters:a,body:i},l){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let m={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:i||{}};return this.transporter.request(m,l)},getClusterIncidents({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getClusterIncidents`.");let h={method:"GET",path:"/1/incidents/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getClusterStatus({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getClusterStatus`.");let h={method:"GET",path:"/1/status/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getIncidents(o){let c={method:"GET",path:"/1/incidents",queryParameters:{},headers:{}};return this.transporter.request(c,o)},getIndexingTime({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getIndexingTime`.");let h={method:"GET",path:"/1/indexing/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getLatency({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getLatency`.");let h={method:"GET",path:"/1/latency/{clusters}".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getMetrics({metric:o,period:a},i){if(!o)throw new Error("Parameter `metric` is required when calling `getMetrics`.");if(!a)throw new Error("Parameter `period` is required when calling `getMetrics`.");let u={method:"GET",path:"/1/infrastructure/{metric}/period/{period}".replace("{metric}",encodeURIComponent(o)).replace("{period}",encodeURIComponent(a)),queryParameters:{},headers:{}};return this.transporter.request(u,i)},getReachability({clusters:o},a){if(!o)throw new Error("Parameter `clusters` is required when calling `getReachability`.");let h={method:"GET",path:"/1/reachability/{clusters}/probes".replace("{clusters}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(h,a)},getServers(o){let c={method:"GET",path:"/1/inventory/servers",queryParameters:{},headers:{}};return this.transporter.request(c,o)},getStatus(o){let c={method:"GET",path:"/1/status",queryParameters:{},headers:{}};return this.transporter.request(c,o)}}}function Ze(t,e,s){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return X({appId:t,apiKey:e,timeouts:{connect:$,read:z,write:F},requester:B(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:T({caches:[H({key:`${x}-${t}`}),O()]}),...s})} | ||
@@ -10,0 +10,0 @@ exports.apiClientVersion = x; |
@@ -13,3 +13,3 @@ // builds/node.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "1.2.5"; | ||
var apiClientVersion = "1.3.0"; | ||
function getDefaultHosts() { | ||
@@ -26,22 +26,21 @@ return [{ url: "status.algolia.com", accept: "readWrite", protocol: "https" }]; | ||
const auth = createAuth(appIdOption, apiKeyOption, authMode); | ||
const transporter = createTransporter({ | ||
hosts: getDefaultHosts(), | ||
...options, | ||
algoliaAgent: getAlgoliaAgent({ | ||
algoliaAgents, | ||
client: "Monitoring", | ||
version: apiClientVersion | ||
return { | ||
transporter: createTransporter({ | ||
hosts: getDefaultHosts(), | ||
...options, | ||
algoliaAgent: getAlgoliaAgent({ | ||
algoliaAgents, | ||
client: "Monitoring", | ||
version: apiClientVersion | ||
}), | ||
baseHeaders: { | ||
"content-type": "text/plain", | ||
...auth.headers(), | ||
...options.baseHeaders | ||
}, | ||
baseQueryParameters: { | ||
...auth.queryParameters(), | ||
...options.baseQueryParameters | ||
} | ||
}), | ||
baseHeaders: { | ||
"content-type": "text/plain", | ||
...auth.headers(), | ||
...options.baseHeaders | ||
}, | ||
baseQueryParameters: { | ||
...auth.queryParameters(), | ||
...options.baseQueryParameters | ||
} | ||
}); | ||
return { | ||
transporter, | ||
/** | ||
@@ -55,3 +54,5 @@ * The `appId` currently in use. | ||
clearCache() { | ||
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0); | ||
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then( | ||
() => void 0 | ||
); | ||
}, | ||
@@ -62,3 +63,3 @@ /** | ||
get _ua() { | ||
return transporter.algoliaAgent.value; | ||
return this.transporter.algoliaAgent.value; | ||
}, | ||
@@ -72,5 +73,14 @@ /** | ||
addAlgoliaAgent(segment, version) { | ||
transporter.algoliaAgent.add({ segment, version }); | ||
this.transporter.algoliaAgent.add({ segment, version }); | ||
}, | ||
/** | ||
* Helper method to switch the API key used to authenticate the requests. | ||
* | ||
* @param params - Method params. | ||
* @param params.apiKey - The new API Key to use. | ||
*/ | ||
setClientApiKey({ apiKey }) { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
}, | ||
/** | ||
* This method allow you to send requests to the Algolia REST API. | ||
@@ -96,3 +106,3 @@ * | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -120,3 +130,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -146,3 +156,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -172,3 +182,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -195,3 +205,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -218,3 +228,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -236,3 +246,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -259,3 +269,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -282,3 +292,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -309,3 +319,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -332,3 +342,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -350,3 +360,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -368,3 +378,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
} | ||
@@ -371,0 +381,0 @@ }; |
import * as _algolia_client_common from '@algolia/client-common'; | ||
import { ClientOptions } from '@algolia/client-common'; | ||
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common'; | ||
type BadRequest = { | ||
reason?: string; | ||
}; | ||
type Metric = '*' | 'avg_build_time' | 'cpu_usage' | 'ram_indexing_usage' | 'ram_search_usage' | 'ssd_usage'; | ||
type Period = 'day' | 'hour' | 'minute' | 'month' | 'week'; | ||
/** | ||
* Error. | ||
* Properties for the `customDelete` method. | ||
*/ | ||
type ErrorBase = Record<string, any> & { | ||
message?: string; | ||
type CustomDeleteProps = { | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
*/ | ||
path: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
*/ | ||
parameters?: Record<string, any>; | ||
}; | ||
type Forbidden = { | ||
reason?: string; | ||
/** | ||
* Properties for the `customGet` method. | ||
*/ | ||
type CustomGetProps = { | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
*/ | ||
path: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
*/ | ||
parameters?: Record<string, any>; | ||
}; | ||
/** | ||
* Properties for the `customPost` method. | ||
*/ | ||
type CustomPostProps = { | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
*/ | ||
path: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
*/ | ||
parameters?: Record<string, any>; | ||
/** | ||
* Parameters to send with the custom request. | ||
*/ | ||
body?: Record<string, unknown>; | ||
}; | ||
/** | ||
* Properties for the `customPut` method. | ||
*/ | ||
type CustomPutProps = { | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
*/ | ||
path: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
*/ | ||
parameters?: Record<string, any>; | ||
/** | ||
* Parameters to send with the custom request. | ||
*/ | ||
body?: Record<string, unknown>; | ||
}; | ||
/** | ||
* Properties for the `getClusterIncidents` method. | ||
*/ | ||
type GetClusterIncidentsProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getClusterStatus` method. | ||
*/ | ||
type GetClusterStatusProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getIndexingTime` method. | ||
*/ | ||
type GetIndexingTimeProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getLatency` method. | ||
*/ | ||
type GetLatencyProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getMetrics` method. | ||
*/ | ||
type GetMetricsProps = { | ||
/** | ||
* Metric to report. For more information about the individual metrics, see the description of the API response. To include all metrics, use `*`. | ||
*/ | ||
metric: Metric; | ||
/** | ||
* 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. | ||
*/ | ||
period: Period; | ||
}; | ||
/** | ||
* Properties for the `getReachability` method. | ||
*/ | ||
type GetReachabilityProps = { | ||
/** | ||
* Subset of clusters, separated by comma. | ||
*/ | ||
clusters: string; | ||
}; | ||
@@ -147,6 +255,2 @@ /** | ||
type Metric = '*' | 'avg_build_time' | 'cpu_usage' | 'ram_indexing_usage' | 'ram_search_usage' | 'ssd_usage'; | ||
type Period = 'day' | 'hour' | 'minute' | 'month' | 'week'; | ||
type StatusResponse = { | ||
@@ -156,152 +260,163 @@ status?: Record<string, Status>; | ||
type Unauthorized = { | ||
reason?: string; | ||
}; | ||
/** | ||
* Properties for the `customDelete` method. | ||
*/ | ||
type CustomDeleteProps = { | ||
declare const apiClientVersion = "1.3.0"; | ||
declare function createMonitoringClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): { | ||
transporter: _algolia_client_common.Transporter; | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
* The `appId` currently in use. | ||
*/ | ||
path: string; | ||
appId: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties. | ||
*/ | ||
parameters?: Record<string, any>; | ||
}; | ||
/** | ||
* Properties for the `customGet` method. | ||
*/ | ||
type CustomGetProps = { | ||
clearCache(): Promise<void>; | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system. | ||
*/ | ||
path: string; | ||
readonly _ua: string; | ||
/** | ||
* Query parameters to apply to the current query. | ||
* Adds a `segment` to the `x-algolia-agent` sent with every requests. | ||
* | ||
* @param segment - The algolia agent (user-agent) segment to add. | ||
* @param version - The version of the agent. | ||
*/ | ||
parameters?: Record<string, any>; | ||
}; | ||
/** | ||
* Properties for the `customPost` method. | ||
*/ | ||
type CustomPostProps = { | ||
addAlgoliaAgent(segment: string, version?: string): void; | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
* Helper method to switch the API key used to authenticate the requests. | ||
* | ||
* @param params - Method params. | ||
* @param params.apiKey - The new API Key to use. | ||
*/ | ||
path: string; | ||
setClientApiKey({ apiKey }: { | ||
apiKey: string; | ||
}): void; | ||
/** | ||
* Query parameters to apply to the current query. | ||
* This method allow you to send requests to the Algolia REST API. | ||
* | ||
* @param customDelete - The customDelete object. | ||
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified. | ||
* @param customDelete.parameters - Query parameters to apply to the current query. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
parameters?: Record<string, any>; | ||
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>; | ||
/** | ||
* Parameters to send with the custom request. | ||
* This method allow you to send requests to the Algolia REST API. | ||
* | ||
* @param customGet - The customGet object. | ||
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified. | ||
* @param customGet.parameters - Query parameters to apply to the current query. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
body?: Record<string, unknown>; | ||
}; | ||
/** | ||
* Properties for the `customPut` method. | ||
*/ | ||
type CustomPutProps = { | ||
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>; | ||
/** | ||
* Path of the endpoint, anything after \"/1\" must be specified. | ||
* This method allow you to send requests to the Algolia REST API. | ||
* | ||
* @param customPost - The customPost object. | ||
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified. | ||
* @param customPost.parameters - Query parameters to apply to the current query. | ||
* @param customPost.body - Parameters to send with the custom request. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
path: string; | ||
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>; | ||
/** | ||
* Query parameters to apply to the current query. | ||
* This method allow you to send requests to the Algolia REST API. | ||
* | ||
* @param customPut - The customPut object. | ||
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified. | ||
* @param customPut.parameters - Query parameters to apply to the current query. | ||
* @param customPut.body - Parameters to send with the custom request. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
parameters?: Record<string, any>; | ||
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>; | ||
/** | ||
* Parameters to send with the custom request. | ||
* Retrieves known incidents for the selected clusters. | ||
* | ||
* @param getClusterIncidents - The getClusterIncidents object. | ||
* @param getClusterIncidents.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
body?: Record<string, unknown>; | ||
}; | ||
/** | ||
* Properties for the `getClusterIncidents` method. | ||
*/ | ||
type GetClusterIncidentsProps = { | ||
getClusterIncidents({ clusters }: GetClusterIncidentsProps, requestOptions?: RequestOptions): Promise<IncidentsResponse>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* Retrieves the status of selected clusters. | ||
* | ||
* @param getClusterStatus - The getClusterStatus object. | ||
* @param getClusterStatus.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getClusterStatus` method. | ||
*/ | ||
type GetClusterStatusProps = { | ||
getClusterStatus({ clusters }: GetClusterStatusProps, requestOptions?: RequestOptions): Promise<StatusResponse>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* Retrieves known incidents for all clusters. | ||
* | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getIndexingTime` method. | ||
*/ | ||
type GetIndexingTimeProps = { | ||
getIncidents(requestOptions?: RequestOptions): Promise<IncidentsResponse>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* Retrieves average times for indexing operations for selected clusters. | ||
* | ||
* @param getIndexingTime - The getIndexingTime object. | ||
* @param getIndexingTime.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getLatency` method. | ||
*/ | ||
type GetLatencyProps = { | ||
getIndexingTime({ clusters }: GetIndexingTimeProps, requestOptions?: RequestOptions): Promise<IndexingTimeResponse>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* Retrieves the average latency for search requests for selected clusters. | ||
* | ||
* @param getLatency - The getLatency object. | ||
* @param getLatency.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
}; | ||
/** | ||
* Properties for the `getMetrics` method. | ||
*/ | ||
type GetMetricsProps = { | ||
getLatency({ clusters }: GetLatencyProps, requestOptions?: RequestOptions): Promise<LatencyResponse>; | ||
/** | ||
* Metric to report. For more information about the individual metrics, see the description of the API response. To include all metrics, use `*`. | ||
* 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). | ||
* | ||
* @param getMetrics - The getMetrics object. | ||
* @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 `*`. | ||
* @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. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
metric: Metric; | ||
getMetrics({ metric, period }: GetMetricsProps, requestOptions?: RequestOptions): Promise<InfrastructureResponse>; | ||
/** | ||
* 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. | ||
* Test whether clusters are reachable or not. | ||
* | ||
* @param getReachability - The getReachability object. | ||
* @param getReachability.clusters - Subset of clusters, separated by comma. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
period: Period; | ||
}; | ||
/** | ||
* Properties for the `getReachability` method. | ||
*/ | ||
type GetReachabilityProps = { | ||
getReachability({ clusters }: GetReachabilityProps, requestOptions?: RequestOptions): Promise<Record<string, Record<string, boolean>>>; | ||
/** | ||
* Subset of clusters, separated by comma. | ||
* 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. | ||
* | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
clusters: string; | ||
getServers(requestOptions?: RequestOptions): Promise<InventoryResponse>; | ||
/** | ||
* Retrieves the status of all Algolia clusters and instances. | ||
* | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
getStatus(requestOptions?: RequestOptions): Promise<StatusResponse>; | ||
}; | ||
declare const apiClientVersion = "1.2.5"; | ||
type BadRequest = { | ||
reason?: string; | ||
}; | ||
/** | ||
* The client type. | ||
* Error. | ||
*/ | ||
type MonitoringClient = ReturnType<typeof monitoringClient>; | ||
declare function monitoringClient(appId: string, apiKey: string, options?: ClientOptions): { | ||
transporter: _algolia_client_common.Transporter; | ||
appId: string; | ||
clearCache(): Promise<void>; | ||
_ua: string; | ||
addAlgoliaAgent(segment: string, version?: string): void; | ||
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>; | ||
customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>; | ||
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>; | ||
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>; | ||
getClusterIncidents({ clusters }: GetClusterIncidentsProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<IncidentsResponse>; | ||
getClusterStatus({ clusters }: GetClusterStatusProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<StatusResponse>; | ||
getIncidents(requestOptions?: _algolia_client_common.RequestOptions): Promise<IncidentsResponse>; | ||
getIndexingTime({ clusters }: GetIndexingTimeProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<IndexingTimeResponse>; | ||
getLatency({ clusters }: GetLatencyProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<LatencyResponse>; | ||
getMetrics({ metric, period }: GetMetricsProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<InfrastructureResponse>; | ||
getReachability({ clusters }: GetReachabilityProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, Record<string, boolean>>>; | ||
getServers(requestOptions?: _algolia_client_common.RequestOptions): Promise<InventoryResponse>; | ||
getStatus(requestOptions?: _algolia_client_common.RequestOptions): Promise<StatusResponse>; | ||
type ErrorBase = Record<string, any> & { | ||
message?: string; | ||
}; | ||
type Forbidden = { | ||
reason?: string; | ||
}; | ||
type Unauthorized = { | ||
reason?: string; | ||
}; | ||
type MonitoringClient = ReturnType<typeof createMonitoringClient>; | ||
declare function monitoringClient(appId: string, apiKey: string, options?: ClientOptions): MonitoringClient; | ||
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 }; |
// src/monitoringClient.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "1.2.5"; | ||
var apiClientVersion = "1.3.0"; | ||
function getDefaultHosts() { | ||
@@ -15,22 +15,21 @@ return [{ url: "status.algolia.com", accept: "readWrite", protocol: "https" }]; | ||
const auth = createAuth(appIdOption, apiKeyOption, authMode); | ||
const transporter = createTransporter({ | ||
hosts: getDefaultHosts(), | ||
...options, | ||
algoliaAgent: getAlgoliaAgent({ | ||
algoliaAgents, | ||
client: "Monitoring", | ||
version: apiClientVersion | ||
return { | ||
transporter: createTransporter({ | ||
hosts: getDefaultHosts(), | ||
...options, | ||
algoliaAgent: getAlgoliaAgent({ | ||
algoliaAgents, | ||
client: "Monitoring", | ||
version: apiClientVersion | ||
}), | ||
baseHeaders: { | ||
"content-type": "text/plain", | ||
...auth.headers(), | ||
...options.baseHeaders | ||
}, | ||
baseQueryParameters: { | ||
...auth.queryParameters(), | ||
...options.baseQueryParameters | ||
} | ||
}), | ||
baseHeaders: { | ||
"content-type": "text/plain", | ||
...auth.headers(), | ||
...options.baseHeaders | ||
}, | ||
baseQueryParameters: { | ||
...auth.queryParameters(), | ||
...options.baseQueryParameters | ||
} | ||
}); | ||
return { | ||
transporter, | ||
/** | ||
@@ -44,3 +43,5 @@ * The `appId` currently in use. | ||
clearCache() { | ||
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0); | ||
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then( | ||
() => void 0 | ||
); | ||
}, | ||
@@ -51,3 +52,3 @@ /** | ||
get _ua() { | ||
return transporter.algoliaAgent.value; | ||
return this.transporter.algoliaAgent.value; | ||
}, | ||
@@ -61,5 +62,14 @@ /** | ||
addAlgoliaAgent(segment, version) { | ||
transporter.algoliaAgent.add({ segment, version }); | ||
this.transporter.algoliaAgent.add({ segment, version }); | ||
}, | ||
/** | ||
* Helper method to switch the API key used to authenticate the requests. | ||
* | ||
* @param params - Method params. | ||
* @param params.apiKey - The new API Key to use. | ||
*/ | ||
setClientApiKey({ apiKey }) { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
}, | ||
/** | ||
* This method allow you to send requests to the Algolia REST API. | ||
@@ -85,3 +95,3 @@ * | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -109,3 +119,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -135,3 +145,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -161,3 +171,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -184,3 +194,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -207,3 +217,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -225,3 +235,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -248,3 +258,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -271,3 +281,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -298,3 +308,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -321,3 +331,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -339,3 +349,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
}, | ||
@@ -357,3 +367,3 @@ /** | ||
}; | ||
return transporter.request(request, requestOptions); | ||
return this.transporter.request(request, requestOptions); | ||
} | ||
@@ -360,0 +370,0 @@ }; |
{ | ||
"version": "1.2.5", | ||
"version": "1.3.0", | ||
"repository": { | ||
@@ -47,5 +47,5 @@ "type": "git", | ||
"dependencies": { | ||
"@algolia/client-common": "5.2.5", | ||
"@algolia/requester-browser-xhr": "5.2.5", | ||
"@algolia/requester-node-http": "5.2.5" | ||
"@algolia/client-common": "5.3.0", | ||
"@algolia/requester-browser-xhr": "5.3.0", | ||
"@algolia/requester-node-http": "5.3.0" | ||
}, | ||
@@ -52,0 +52,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
361574
3185
0
+ Added@algolia/client-common@5.3.0(transitive)
+ Added@algolia/requester-browser-xhr@5.3.0(transitive)
+ Added@algolia/requester-node-http@5.3.0(transitive)
- Removed@algolia/client-common@5.2.5(transitive)
- Removed@algolia/requester-browser-xhr@5.2.5(transitive)
- Removed@algolia/requester-node-http@5.2.5(transitive)
Updated@algolia/client-common@5.3.0