@algolia/monitoring
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -259,3 +259,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "1.6.0"; | ||
declare const apiClientVersion = "1.6.1"; | ||
declare function createMonitoringClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): { | ||
@@ -262,0 +262,0 @@ transporter: _algolia_client_common.Transporter; |
@@ -15,3 +15,3 @@ // builds/browser.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "1.6.0"; | ||
var apiClientVersion = "1.6.1"; | ||
function getDefaultHosts() { | ||
@@ -18,0 +18,0 @@ return [{ url: "status.algolia.com", accept: "readWrite", protocol: "https" }]; |
@@ -1,2 +0,2 @@ | ||
function M(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(s)||"{}")}function d(o){t().setItem(s,JSON.stringify(o))}function i(){let o=r.timeToLive?r.timeToLive*1e3:null,n=a(),c=Object.fromEntries(Object.entries(n).filter(([,m])=>m.timestamp!==void 0));if(d(c),!o)return;let u=Object.fromEntries(Object.entries(c).filter(([,m])=>{let h=new Date().getTime();return!(m.timestamp+o<h)}));d(u)}return{get(o,n,c={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(i(),a()[JSON.stringify(o)])).then(u=>Promise.all([u?u.value:n(),u!==void 0])).then(([u,m])=>Promise.all([u,m||c.miss(u)])).then(([u])=>u)},set(o,n){return Promise.resolve().then(()=>{let c=a();return c[JSON.stringify(o)]={timestamp:new Date().getTime(),value:n},t().setItem(s,JSON.stringify(c)),n})},delete(o){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(o)],t().setItem(s,JSON.stringify(n))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function Z(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,s.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(r){let e=[...r.caches],s=e.shift();return s===void 0?Z():{get(t,a,d={miss:()=>Promise.resolve()}){return s.get(t,a,d).catch(()=>E({caches:e}).get(t,a,d))},set(t,a){return s.set(t,a).catch(()=>E({caches:e}).set(t,a))},delete(t){return s.delete(t).catch(()=>E({caches:e}).delete(t))},clear(){return s.clear().catch(()=>E({caches:e}).clear())}}}function x(r={serializable:!0}){let e={};return{get(s,t,a={miss:()=>Promise.resolve()}){let d=JSON.stringify(s);if(d in e)return Promise.resolve(r.serializable?JSON.parse(e[d]):e[d]);let i=t();return i.then(o=>a.miss(o)).then(()=>i)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var k=1e3,W=2e3,Q=3e4;function ee(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function $(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function j({algoliaAgents:r,client:e,version:s}){let t=ee(s).add({segment:e,version:s});return r.forEach(a=>t.add(a)),t}function J(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>L}function a(){return e==="timed out"&&Date.now()-s<=L}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:a}}var z=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},F=class extends z{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},re=class extends F{constructor(r){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.",r,"RetryError")}},b=class extends F{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},te=class extends z{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends b{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function oe(r,e,s){let t=ne(s),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replaceAll("+","%20")}`).join("&")}function ae(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ie(r,e,s){let t={Accept:"application/json",...r,...e,...s},a={};return Object.keys(t).forEach(d=>{let i=t[d];a[d.toLowerCase()]=i}),a}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new te(e.message,r)}}function ue({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}function le({isTimedOut:r,status:e}){return!r&&~~e===0}function me({isTimedOut:r,status:e}){return r||le({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function de({status:r}){return~~(r/100)===2}function pe(r){return r.map(e=>B(e))}function B(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function X({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:a,algoliaAgent:d,timeouts:i,requester:o,requestsCache:n,responsesCache:c}){async function u(l){let p=await Promise.all(l.map(P=>e.get(P,()=>Promise.resolve(H(P))))),T=p.filter(P=>P.isUp()),g=p.filter(P=>P.isTimedOut()),w=[...T,...g];return{hosts:w.length>0?w:l,getTimeout(P,q){return(g.length===0&&P===0?1:g.length+3+P)*q}}}async function m(l,p,T=!0){let g=[],w=ae(l,p),y=ie(s,l.headers,p.headers),P=l.method==="GET"?{...l.data,...p.data}:{},q={...a,...l.queryParameters,...P};if(d.value&&(q["x-algolia-agent"]=d.value),p&&p.queryParameters)for(let f of Object.keys(p.queryParameters))!p.queryParameters[f]||Object.prototype.toString.call(p.queryParameters[f])==="[object Object]"?q[f]=p.queryParameters[f]:q[f]=p.queryParameters[f].toString();let O=0,_=async(f,A)=>{let v=f.pop();if(v===void 0)throw new re(pe(g));let I={...i,...p.timeouts},D={data:w,headers:y,method:l.method,url:oe(v,l.path,q),connectTimeout:A(O,I.connect),responseTimeout:A(O,T?I.read:I.write)},U=S=>{let G={request:D,response:S,host:v,triesLeft:f.length};return g.push(G),G},R=await o.send(D);if(me(R)){let S=U(R);return R.isTimedOut&&O++,t.info("Retryable failure",B(S)),await e.set(v,H(v,R.isTimedOut?"timed out":"down")),_(f,A)}if(de(R))return ce(R);throw U(R),ue(R,g)},Y=r.filter(f=>f.accept==="readWrite"||(T?f.accept==="read":f.accept==="write")),N=await u(Y);return _([...N.hosts].reverse(),N.getTimeout)}function h(l,p={}){let T=l.useReadTransporter||l.method==="GET";if(!T)return m(l,p,T);let g=()=>m(l,p);if((p.cacheable||l.cacheable)!==!0)return g();let y={request:l,requestOptions:p,transporter:{queryParameters:a,headers:s}};return c.get(y,()=>n.get(y,()=>n.set(y,g()).then(P=>Promise.all([n.delete(y),P]),P=>Promise.all([n.delete(y),Promise.reject(P)])).then(([P,q])=>q)),{miss:P=>c.set(y,P)})}return{hostsCache:e,requester:o,timeouts:i,logger:t,algoliaAgent:d,baseHeaders:s,baseQueryParameters:a,hosts:r,request:h,requestsCache:n,responsesCache:c}}function K(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>t.setRequestHeader(o,e.headers[o]));let a=(o,n)=>setTimeout(()=>{t.abort(),s({status:0,content:n,isTimedOut:!0})},o),d=a(e.connectTimeout,"Connection timeout"),i;t.onreadystatechange=()=>{t.readyState>t.OPENED&&i===void 0&&(clearTimeout(d),i=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(d),clearTimeout(i),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(d),clearTimeout(i),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var C="1.6.0";function he(){return[{url:"status.algolia.com",accept:"readWrite",protocol:"https"}]}function V({appId:r,apiKey:e,authMode:s,algoliaAgents:t,...a}){let d=$(r,e,s),i=X({hosts:he(),...a,algoliaAgent:j({algoliaAgents:t,client:"Monitoring",version:C}),baseHeaders:{"content-type":"text/plain",...d.headers(),...a.baseHeaders},baseQueryParameters:{...d.queryParameters(),...a.baseQueryParameters}});return{transporter:i,appId:r,clearCache(){return Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then(()=>{})},get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(o,n){i.algoliaAgent.add({segment:o,version:n})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?i.baseHeaders["x-algolia-api-key"]=o:i.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:n},c){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return i.request(l,c)},customGet({path:o,parameters:n},c){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return i.request(l,c)},customPost({path:o,parameters:n,body:c},u){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let p={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:c||{}};return i.request(p,u)},customPut({path:o,parameters:n,body:c},u){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let p={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:c||{}};return i.request(p,u)},getClusterIncidents({clusters:o},n){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 i.request(h,n)},getClusterStatus({clusters:o},n){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 i.request(h,n)},getIncidents(o){let m={method:"GET",path:"/1/incidents",queryParameters:{},headers:{}};return i.request(m,o)},getIndexingTime({clusters:o},n){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 i.request(h,n)},getLatency({clusters:o},n){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 i.request(h,n)},getMetrics({metric:o,period:n},c){if(!o)throw new Error("Parameter `metric` is required when calling `getMetrics`.");if(!n)throw new Error("Parameter `period` is required when calling `getMetrics`.");let l={method:"GET",path:"/1/infrastructure/{metric}/period/{period}".replace("{metric}",encodeURIComponent(o)).replace("{period}",encodeURIComponent(n)),queryParameters:{},headers:{}};return i.request(l,c)},getReachability({clusters:o},n){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 i.request(h,n)},getServers(o){let m={method:"GET",path:"/1/inventory/servers",queryParameters:{},headers:{}};return i.request(m,o)},getStatus(o){let m={method:"GET",path:"/1/status",queryParameters:{},headers:{}};return i.request(m,o)}}}function Ze(r,e,s){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return V({appId:r,apiKey:e,timeouts:{connect:k,read:W,write:Q},logger:J(),requester:K(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:E({caches:[M({key:`${C}-${r}`}),x()]}),...s})}export{C as apiClientVersion,Ze as monitoringClient}; | ||
function M(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(s)||"{}")}function d(o){t().setItem(s,JSON.stringify(o))}function i(){let o=r.timeToLive?r.timeToLive*1e3:null,n=a(),c=Object.fromEntries(Object.entries(n).filter(([,m])=>m.timestamp!==void 0));if(d(c),!o)return;let u=Object.fromEntries(Object.entries(c).filter(([,m])=>{let h=new Date().getTime();return!(m.timestamp+o<h)}));d(u)}return{get(o,n,c={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(i(),a()[JSON.stringify(o)])).then(u=>Promise.all([u?u.value:n(),u!==void 0])).then(([u,m])=>Promise.all([u,m||c.miss(u)])).then(([u])=>u)},set(o,n){return Promise.resolve().then(()=>{let c=a();return c[JSON.stringify(o)]={timestamp:new Date().getTime(),value:n},t().setItem(s,JSON.stringify(c)),n})},delete(o){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(o)],t().setItem(s,JSON.stringify(n))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function Z(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,s.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(r){let e=[...r.caches],s=e.shift();return s===void 0?Z():{get(t,a,d={miss:()=>Promise.resolve()}){return s.get(t,a,d).catch(()=>E({caches:e}).get(t,a,d))},set(t,a){return s.set(t,a).catch(()=>E({caches:e}).set(t,a))},delete(t){return s.delete(t).catch(()=>E({caches:e}).delete(t))},clear(){return s.clear().catch(()=>E({caches:e}).clear())}}}function x(r={serializable:!0}){let e={};return{get(s,t,a={miss:()=>Promise.resolve()}){let d=JSON.stringify(s);if(d in e)return Promise.resolve(r.serializable?JSON.parse(e[d]):e[d]);let i=t();return i.then(o=>a.miss(o)).then(()=>i)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var k=1e3,W=2e3,Q=3e4;function ee(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function $(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function j({algoliaAgents:r,client:e,version:s}){let t=ee(s).add({segment:e,version:s});return r.forEach(a=>t.add(a)),t}function J(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>L}function a(){return e==="timed out"&&Date.now()-s<=L}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:a}}var z=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},F=class extends z{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e}},re=class extends F{constructor(r){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.",r,"RetryError")}},b=class extends F{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e}},te=class extends z{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends b{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function oe(r,e,s){let t=ne(s),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replaceAll("+","%20")}`).join("&")}function ae(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ie(r,e,s){let t={Accept:"application/json",...r,...e,...s},a={};return Object.keys(t).forEach(d=>{let i=t[d];a[d.toLowerCase()]=i}),a}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new te(e.message,r)}}function ue({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}function le({isTimedOut:r,status:e}){return!r&&~~e===0}function me({isTimedOut:r,status:e}){return r||le({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function de({status:r}){return~~(r/100)===2}function pe(r){return r.map(e=>B(e))}function B(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function X({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:a,algoliaAgent:d,timeouts:i,requester:o,requestsCache:n,responsesCache:c}){async function u(l){let p=await Promise.all(l.map(P=>e.get(P,()=>Promise.resolve(H(P))))),T=p.filter(P=>P.isUp()),g=p.filter(P=>P.isTimedOut()),w=[...T,...g];return{hosts:w.length>0?w:l,getTimeout(P,q){return(g.length===0&&P===0?1:g.length+3+P)*q}}}async function m(l,p,T=!0){let g=[],w=ae(l,p),y=ie(s,l.headers,p.headers),P=l.method==="GET"?{...l.data,...p.data}:{},q={...a,...l.queryParameters,...P};if(d.value&&(q["x-algolia-agent"]=d.value),p&&p.queryParameters)for(let f of Object.keys(p.queryParameters))!p.queryParameters[f]||Object.prototype.toString.call(p.queryParameters[f])==="[object Object]"?q[f]=p.queryParameters[f]:q[f]=p.queryParameters[f].toString();let O=0,_=async(f,A)=>{let v=f.pop();if(v===void 0)throw new re(pe(g));let I={...i,...p.timeouts},D={data:w,headers:y,method:l.method,url:oe(v,l.path,q),connectTimeout:A(O,I.connect),responseTimeout:A(O,T?I.read:I.write)},U=S=>{let G={request:D,response:S,host:v,triesLeft:f.length};return g.push(G),G},R=await o.send(D);if(me(R)){let S=U(R);return R.isTimedOut&&O++,t.info("Retryable failure",B(S)),await e.set(v,H(v,R.isTimedOut?"timed out":"down")),_(f,A)}if(de(R))return ce(R);throw U(R),ue(R,g)},Y=r.filter(f=>f.accept==="readWrite"||(T?f.accept==="read":f.accept==="write")),N=await u(Y);return _([...N.hosts].reverse(),N.getTimeout)}function h(l,p={}){let T=l.useReadTransporter||l.method==="GET";if(!T)return m(l,p,T);let g=()=>m(l,p);if((p.cacheable||l.cacheable)!==!0)return g();let y={request:l,requestOptions:p,transporter:{queryParameters:a,headers:s}};return c.get(y,()=>n.get(y,()=>n.set(y,g()).then(P=>Promise.all([n.delete(y),P]),P=>Promise.all([n.delete(y),Promise.reject(P)])).then(([P,q])=>q)),{miss:P=>c.set(y,P)})}return{hostsCache:e,requester:o,timeouts:i,logger:t,algoliaAgent:d,baseHeaders:s,baseQueryParameters:a,hosts:r,request:h,requestsCache:n,responsesCache:c}}function K(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>t.setRequestHeader(o,e.headers[o]));let a=(o,n)=>setTimeout(()=>{t.abort(),s({status:0,content:n,isTimedOut:!0})},o),d=a(e.connectTimeout,"Connection timeout"),i;t.onreadystatechange=()=>{t.readyState>t.OPENED&&i===void 0&&(clearTimeout(d),i=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(d),clearTimeout(i),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(d),clearTimeout(i),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var C="1.6.1";function he(){return[{url:"status.algolia.com",accept:"readWrite",protocol:"https"}]}function V({appId:r,apiKey:e,authMode:s,algoliaAgents:t,...a}){let d=$(r,e,s),i=X({hosts:he(),...a,algoliaAgent:j({algoliaAgents:t,client:"Monitoring",version:C}),baseHeaders:{"content-type":"text/plain",...d.headers(),...a.baseHeaders},baseQueryParameters:{...d.queryParameters(),...a.baseQueryParameters}});return{transporter:i,appId:r,clearCache(){return Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then(()=>{})},get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(o,n){i.algoliaAgent.add({segment:o,version:n})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?i.baseHeaders["x-algolia-api-key"]=o:i.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:n},c){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return i.request(l,c)},customGet({path:o,parameters:n},c){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return i.request(l,c)},customPost({path:o,parameters:n,body:c},u){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let p={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:c||{}};return i.request(p,u)},customPut({path:o,parameters:n,body:c},u){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let p={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:c||{}};return i.request(p,u)},getClusterIncidents({clusters:o},n){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 i.request(h,n)},getClusterStatus({clusters:o},n){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 i.request(h,n)},getIncidents(o){let m={method:"GET",path:"/1/incidents",queryParameters:{},headers:{}};return i.request(m,o)},getIndexingTime({clusters:o},n){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 i.request(h,n)},getLatency({clusters:o},n){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 i.request(h,n)},getMetrics({metric:o,period:n},c){if(!o)throw new Error("Parameter `metric` is required when calling `getMetrics`.");if(!n)throw new Error("Parameter `period` is required when calling `getMetrics`.");let l={method:"GET",path:"/1/infrastructure/{metric}/period/{period}".replace("{metric}",encodeURIComponent(o)).replace("{period}",encodeURIComponent(n)),queryParameters:{},headers:{}};return i.request(l,c)},getReachability({clusters:o},n){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 i.request(h,n)},getServers(o){let m={method:"GET",path:"/1/inventory/servers",queryParameters:{},headers:{}};return i.request(m,o)},getStatus(o){let m={method:"GET",path:"/1/status",queryParameters:{},headers:{}};return i.request(m,o)}}}function Ze(r,e,s){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return V({appId:r,apiKey:e,timeouts:{connect:k,read:W,write:Q},logger:J(),requester:K(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:E({caches:[M({key:`${C}-${r}`}),x()]}),...s})}export{C as apiClientVersion,Ze as monitoringClient}; | ||
//# sourceMappingURL=browser.min.js.map |
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
function M(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(s)||"{}")}function d(o){t().setItem(s,JSON.stringify(o));}function i(){let o=r.timeToLive?r.timeToLive*1e3:null,n=a(),c=Object.fromEntries(Object.entries(n).filter(([,m])=>m.timestamp!==void 0));if(d(c),!o)return;let u=Object.fromEntries(Object.entries(c).filter(([,m])=>{let h=new Date().getTime();return !(m.timestamp+o<h)}));d(u);}return {get(o,n,c={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(i(),a()[JSON.stringify(o)])).then(u=>Promise.all([u?u.value:n(),u!==void 0])).then(([u,m])=>Promise.all([u,m||c.miss(u)])).then(([u])=>u)},set(o,n){return Promise.resolve().then(()=>{let c=a();return c[JSON.stringify(o)]={timestamp:new Date().getTime(),value:n},t().setItem(s,JSON.stringify(c)),n})},delete(o){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(o)],t().setItem(s,JSON.stringify(n));})},clear(){return Promise.resolve().then(()=>{t().removeItem(s);})}}}function Z(){return {get(r,e,s={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,s.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(r){let e=[...r.caches],s=e.shift();return s===void 0?Z():{get(t,a,d={miss:()=>Promise.resolve()}){return s.get(t,a,d).catch(()=>E({caches:e}).get(t,a,d))},set(t,a){return s.set(t,a).catch(()=>E({caches:e}).set(t,a))},delete(t){return s.delete(t).catch(()=>E({caches:e}).delete(t))},clear(){return s.clear().catch(()=>E({caches:e}).clear())}}}function x(r={serializable:!0}){let e={};return {get(s,t,a={miss:()=>Promise.resolve()}){let d=JSON.stringify(s);if(d in e)return Promise.resolve(r.serializable?JSON.parse(e[d]):e[d]);let i=t();return i.then(o=>a.miss(o)).then(()=>i)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var k=1e3,W=2e3,Q=3e4;function ee(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function $(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function j({algoliaAgents:r,client:e,version:s}){let t=ee(s).add({segment:e,version:s});return r.forEach(a=>t.add(a)),t}function J(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>L}function a(){return e==="timed out"&&Date.now()-s<=L}return {...r,status:e,lastUpdate:s,isUp:t,isTimedOut:a}}var z=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},F=class extends z{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e;}},re=class extends F{constructor(r){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.",r,"RetryError");}},b=class extends F{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e;}},te=class extends z{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends b{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s;}};function oe(r,e,s){let t=ne(s),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replaceAll("+","%20")}`).join("&")}function ae(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ie(r,e,s){let t={Accept:"application/json",...r,...e,...s},a={};return Object.keys(t).forEach(d=>{let i=t[d];a[d.toLowerCase()]=i;}),a}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new te(e.message,r)}}function ue({content:r,status:e},s){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}function le({isTimedOut:r,status:e}){return !r&&~~e===0}function me({isTimedOut:r,status:e}){return r||le({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function de({status:r}){return ~~(r/100)===2}function pe(r){return r.map(e=>B(e))}function B(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function X({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:a,algoliaAgent:d,timeouts:i,requester:o,requestsCache:n,responsesCache:c}){async function u(l){let p=await Promise.all(l.map(P=>e.get(P,()=>Promise.resolve(H(P))))),T=p.filter(P=>P.isUp()),g=p.filter(P=>P.isTimedOut()),w=[...T,...g];return {hosts:w.length>0?w:l,getTimeout(P,q){return (g.length===0&&P===0?1:g.length+3+P)*q}}}async function m(l,p,T=!0){let g=[],w=ae(l,p),y=ie(s,l.headers,p.headers),P=l.method==="GET"?{...l.data,...p.data}:{},q={...a,...l.queryParameters,...P};if(d.value&&(q["x-algolia-agent"]=d.value),p&&p.queryParameters)for(let f of Object.keys(p.queryParameters))!p.queryParameters[f]||Object.prototype.toString.call(p.queryParameters[f])==="[object Object]"?q[f]=p.queryParameters[f]:q[f]=p.queryParameters[f].toString();let O=0,_=async(f,A)=>{let v=f.pop();if(v===void 0)throw new re(pe(g));let I={...i,...p.timeouts},D={data:w,headers:y,method:l.method,url:oe(v,l.path,q),connectTimeout:A(O,I.connect),responseTimeout:A(O,T?I.read:I.write)},U=S=>{let G={request:D,response:S,host:v,triesLeft:f.length};return g.push(G),G},R=await o.send(D);if(me(R)){let S=U(R);return R.isTimedOut&&O++,t.info("Retryable failure",B(S)),await e.set(v,H(v,R.isTimedOut?"timed out":"down")),_(f,A)}if(de(R))return ce(R);throw U(R),ue(R,g)},Y=r.filter(f=>f.accept==="readWrite"||(T?f.accept==="read":f.accept==="write")),N=await u(Y);return _([...N.hosts].reverse(),N.getTimeout)}function h(l,p={}){let T=l.useReadTransporter||l.method==="GET";if(!T)return m(l,p,T);let g=()=>m(l,p);if((p.cacheable||l.cacheable)!==!0)return g();let y={request:l,requestOptions:p,transporter:{queryParameters:a,headers:s}};return c.get(y,()=>n.get(y,()=>n.set(y,g()).then(P=>Promise.all([n.delete(y),P]),P=>Promise.all([n.delete(y),Promise.reject(P)])).then(([P,q])=>q)),{miss:P=>c.set(y,P)})}return {hostsCache:e,requester:o,timeouts:i,logger:t,algoliaAgent:d,baseHeaders:s,baseQueryParameters:a,hosts:r,request:h,requestsCache:n,responsesCache:c}}function K(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>t.setRequestHeader(o,e.headers[o]));let a=(o,n)=>setTimeout(()=>{t.abort(),s({status:0,content:n,isTimedOut:!0});},o),d=a(e.connectTimeout,"Connection timeout"),i;t.onreadystatechange=()=>{t.readyState>t.OPENED&&i===void 0&&(clearTimeout(d),i=a(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(d),clearTimeout(i),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(d),clearTimeout(i),s({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}var C="1.6.0";function he(){return [{url:"status.algolia.com",accept:"readWrite",protocol:"https"}]}function V({appId:r,apiKey:e,authMode:s,algoliaAgents:t,...a}){let d=$(r,e,s),i=X({hosts:he(),...a,algoliaAgent:j({algoliaAgents:t,client:"Monitoring",version:C}),baseHeaders:{"content-type":"text/plain",...d.headers(),...a.baseHeaders},baseQueryParameters:{...d.queryParameters(),...a.baseQueryParameters}});return {transporter:i,appId:r,clearCache(){return Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then(()=>{})},get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(o,n){i.algoliaAgent.add({segment:o,version:n});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?i.baseHeaders["x-algolia-api-key"]=o:i.baseQueryParameters["x-algolia-api-key"]=o;},customDelete({path:o,parameters:n},c){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return i.request(l,c)},customGet({path:o,parameters:n},c){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return i.request(l,c)},customPost({path:o,parameters:n,body:c},u){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let p={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:c||{}};return i.request(p,u)},customPut({path:o,parameters:n,body:c},u){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let p={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:c||{}};return i.request(p,u)},getClusterIncidents({clusters:o},n){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 i.request(h,n)},getClusterStatus({clusters:o},n){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 i.request(h,n)},getIncidents(o){let m={method:"GET",path:"/1/incidents",queryParameters:{},headers:{}};return i.request(m,o)},getIndexingTime({clusters:o},n){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 i.request(h,n)},getLatency({clusters:o},n){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 i.request(h,n)},getMetrics({metric:o,period:n},c){if(!o)throw new Error("Parameter `metric` is required when calling `getMetrics`.");if(!n)throw new Error("Parameter `period` is required when calling `getMetrics`.");let l={method:"GET",path:"/1/infrastructure/{metric}/period/{period}".replace("{metric}",encodeURIComponent(o)).replace("{period}",encodeURIComponent(n)),queryParameters:{},headers:{}};return i.request(l,c)},getReachability({clusters:o},n){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 i.request(h,n)},getServers(o){let m={method:"GET",path:"/1/inventory/servers",queryParameters:{},headers:{}};return i.request(m,o)},getStatus(o){let m={method:"GET",path:"/1/status",queryParameters:{},headers:{}};return i.request(m,o)}}}function Ze(r,e,s){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return V({appId:r,apiKey:e,timeouts:{connect:k,read:W,write:Q},logger:J(),requester:K(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:E({caches:[M({key:`${C}-${r}`}),x()]}),...s})} | ||
function M(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(s)||"{}")}function d(o){t().setItem(s,JSON.stringify(o));}function i(){let o=r.timeToLive?r.timeToLive*1e3:null,n=a(),c=Object.fromEntries(Object.entries(n).filter(([,m])=>m.timestamp!==void 0));if(d(c),!o)return;let u=Object.fromEntries(Object.entries(c).filter(([,m])=>{let h=new Date().getTime();return !(m.timestamp+o<h)}));d(u);}return {get(o,n,c={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(i(),a()[JSON.stringify(o)])).then(u=>Promise.all([u?u.value:n(),u!==void 0])).then(([u,m])=>Promise.all([u,m||c.miss(u)])).then(([u])=>u)},set(o,n){return Promise.resolve().then(()=>{let c=a();return c[JSON.stringify(o)]={timestamp:new Date().getTime(),value:n},t().setItem(s,JSON.stringify(c)),n})},delete(o){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(o)],t().setItem(s,JSON.stringify(n));})},clear(){return Promise.resolve().then(()=>{t().removeItem(s);})}}}function Z(){return {get(r,e,s={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,s.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(r){let e=[...r.caches],s=e.shift();return s===void 0?Z():{get(t,a,d={miss:()=>Promise.resolve()}){return s.get(t,a,d).catch(()=>E({caches:e}).get(t,a,d))},set(t,a){return s.set(t,a).catch(()=>E({caches:e}).set(t,a))},delete(t){return s.delete(t).catch(()=>E({caches:e}).delete(t))},clear(){return s.clear().catch(()=>E({caches:e}).clear())}}}function x(r={serializable:!0}){let e={};return {get(s,t,a={miss:()=>Promise.resolve()}){let d=JSON.stringify(s);if(d in e)return Promise.resolve(r.serializable?JSON.parse(e[d]):e[d]);let i=t();return i.then(o=>a.miss(o)).then(()=>i)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var k=1e3,W=2e3,Q=3e4;function ee(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function $(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function j({algoliaAgents:r,client:e,version:s}){let t=ee(s).add({segment:e,version:s});return r.forEach(a=>t.add(a)),t}function J(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>L}function a(){return e==="timed out"&&Date.now()-s<=L}return {...r,status:e,lastUpdate:s,isUp:t,isTimedOut:a}}var z=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},F=class extends z{stackTrace;constructor(r,e,s){super(r,s),this.stackTrace=e;}},re=class extends F{constructor(r){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.",r,"RetryError");}},b=class extends F{status;constructor(r,e,s,t="ApiError"){super(r,s,t),this.status=e;}},te=class extends z{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends b{error;constructor(r,e,s,t){super(r,e,t,"DetailedApiError"),this.error=s;}};function oe(r,e,s){let t=ne(s),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replaceAll("+","%20")}`).join("&")}function ae(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ie(r,e,s){let t={Accept:"application/json",...r,...e,...s},a={};return Object.keys(t).forEach(d=>{let i=t[d];a[d.toLowerCase()]=i;}),a}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new te(e.message,r)}}function ue({content:r,status:e},s){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}function le({isTimedOut:r,status:e}){return !r&&~~e===0}function me({isTimedOut:r,status:e}){return r||le({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function de({status:r}){return ~~(r/100)===2}function pe(r){return r.map(e=>B(e))}function B(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function X({hosts:r,hostsCache:e,baseHeaders:s,logger:t,baseQueryParameters:a,algoliaAgent:d,timeouts:i,requester:o,requestsCache:n,responsesCache:c}){async function u(l){let p=await Promise.all(l.map(P=>e.get(P,()=>Promise.resolve(H(P))))),T=p.filter(P=>P.isUp()),g=p.filter(P=>P.isTimedOut()),w=[...T,...g];return {hosts:w.length>0?w:l,getTimeout(P,q){return (g.length===0&&P===0?1:g.length+3+P)*q}}}async function m(l,p,T=!0){let g=[],w=ae(l,p),y=ie(s,l.headers,p.headers),P=l.method==="GET"?{...l.data,...p.data}:{},q={...a,...l.queryParameters,...P};if(d.value&&(q["x-algolia-agent"]=d.value),p&&p.queryParameters)for(let f of Object.keys(p.queryParameters))!p.queryParameters[f]||Object.prototype.toString.call(p.queryParameters[f])==="[object Object]"?q[f]=p.queryParameters[f]:q[f]=p.queryParameters[f].toString();let O=0,_=async(f,A)=>{let v=f.pop();if(v===void 0)throw new re(pe(g));let I={...i,...p.timeouts},D={data:w,headers:y,method:l.method,url:oe(v,l.path,q),connectTimeout:A(O,I.connect),responseTimeout:A(O,T?I.read:I.write)},U=S=>{let G={request:D,response:S,host:v,triesLeft:f.length};return g.push(G),G},R=await o.send(D);if(me(R)){let S=U(R);return R.isTimedOut&&O++,t.info("Retryable failure",B(S)),await e.set(v,H(v,R.isTimedOut?"timed out":"down")),_(f,A)}if(de(R))return ce(R);throw U(R),ue(R,g)},Y=r.filter(f=>f.accept==="readWrite"||(T?f.accept==="read":f.accept==="write")),N=await u(Y);return _([...N.hosts].reverse(),N.getTimeout)}function h(l,p={}){let T=l.useReadTransporter||l.method==="GET";if(!T)return m(l,p,T);let g=()=>m(l,p);if((p.cacheable||l.cacheable)!==!0)return g();let y={request:l,requestOptions:p,transporter:{queryParameters:a,headers:s}};return c.get(y,()=>n.get(y,()=>n.set(y,g()).then(P=>Promise.all([n.delete(y),P]),P=>Promise.all([n.delete(y),Promise.reject(P)])).then(([P,q])=>q)),{miss:P=>c.set(y,P)})}return {hostsCache:e,requester:o,timeouts:i,logger:t,algoliaAgent:d,baseHeaders:s,baseQueryParameters:a,hosts:r,request:h,requestsCache:n,responsesCache:c}}function K(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>t.setRequestHeader(o,e.headers[o]));let a=(o,n)=>setTimeout(()=>{t.abort(),s({status:0,content:n,isTimedOut:!0});},o),d=a(e.connectTimeout,"Connection timeout"),i;t.onreadystatechange=()=>{t.readyState>t.OPENED&&i===void 0&&(clearTimeout(d),i=a(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(d),clearTimeout(i),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(d),clearTimeout(i),s({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}var C="1.6.1";function he(){return [{url:"status.algolia.com",accept:"readWrite",protocol:"https"}]}function V({appId:r,apiKey:e,authMode:s,algoliaAgents:t,...a}){let d=$(r,e,s),i=X({hosts:he(),...a,algoliaAgent:j({algoliaAgents:t,client:"Monitoring",version:C}),baseHeaders:{"content-type":"text/plain",...d.headers(),...a.baseHeaders},baseQueryParameters:{...d.queryParameters(),...a.baseQueryParameters}});return {transporter:i,appId:r,clearCache(){return Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then(()=>{})},get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(o,n){i.algoliaAgent.add({segment:o,version:n});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?i.baseHeaders["x-algolia-api-key"]=o:i.baseQueryParameters["x-algolia-api-key"]=o;},customDelete({path:o,parameters:n},c){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return i.request(l,c)},customGet({path:o,parameters:n},c){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return i.request(l,c)},customPost({path:o,parameters:n,body:c},u){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let p={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:c||{}};return i.request(p,u)},customPut({path:o,parameters:n,body:c},u){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let p={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:c||{}};return i.request(p,u)},getClusterIncidents({clusters:o},n){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 i.request(h,n)},getClusterStatus({clusters:o},n){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 i.request(h,n)},getIncidents(o){let m={method:"GET",path:"/1/incidents",queryParameters:{},headers:{}};return i.request(m,o)},getIndexingTime({clusters:o},n){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 i.request(h,n)},getLatency({clusters:o},n){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 i.request(h,n)},getMetrics({metric:o,period:n},c){if(!o)throw new Error("Parameter `metric` is required when calling `getMetrics`.");if(!n)throw new Error("Parameter `period` is required when calling `getMetrics`.");let l={method:"GET",path:"/1/infrastructure/{metric}/period/{period}".replace("{metric}",encodeURIComponent(o)).replace("{period}",encodeURIComponent(n)),queryParameters:{},headers:{}};return i.request(l,c)},getReachability({clusters:o},n){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 i.request(h,n)},getServers(o){let m={method:"GET",path:"/1/inventory/servers",queryParameters:{},headers:{}};return i.request(m,o)},getStatus(o){let m={method:"GET",path:"/1/status",queryParameters:{},headers:{}};return i.request(m,o)}}}function Ze(r,e,s){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return V({appId:r,apiKey:e,timeouts:{connect:k,read:W,write:Q},logger:J(),requester:K(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:E({caches:[M({key:`${C}-${r}`}),x()]}),...s})} | ||
@@ -10,0 +10,0 @@ exports.apiClientVersion = C; |
@@ -14,3 +14,3 @@ // builds/fetch.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "1.6.0"; | ||
var apiClientVersion = "1.6.1"; | ||
function getDefaultHosts() { | ||
@@ -17,0 +17,0 @@ return [{ url: "status.algolia.com", accept: "readWrite", protocol: "https" }]; |
@@ -14,3 +14,3 @@ // builds/node.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "1.6.0"; | ||
var apiClientVersion = "1.6.1"; | ||
function getDefaultHosts() { | ||
@@ -17,0 +17,0 @@ return [{ url: "status.algolia.com", accept: "readWrite", protocol: "https" }]; |
@@ -259,3 +259,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "1.6.0"; | ||
declare const apiClientVersion = "1.6.1"; | ||
declare function createMonitoringClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): { | ||
@@ -262,0 +262,0 @@ transporter: _algolia_client_common.Transporter; |
@@ -259,3 +259,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "1.6.0"; | ||
declare const apiClientVersion = "1.6.1"; | ||
declare function createMonitoringClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, ...options }: CreateClientOptions): { | ||
@@ -262,0 +262,0 @@ transporter: _algolia_client_common.Transporter; |
// src/monitoringClient.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "1.6.0"; | ||
var apiClientVersion = "1.6.1"; | ||
function getDefaultHosts() { | ||
@@ -5,0 +5,0 @@ return [{ url: "status.algolia.com", accept: "readWrite", protocol: "https" }]; |
{ | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"repository": { | ||
@@ -52,6 +52,6 @@ "type": "git", | ||
"dependencies": { | ||
"@algolia/client-common": "5.6.0", | ||
"@algolia/requester-browser-xhr": "5.6.0", | ||
"@algolia/requester-fetch": "5.6.0", | ||
"@algolia/requester-node-http": "5.6.0" | ||
"@algolia/client-common": "5.6.1", | ||
"@algolia/requester-browser-xhr": "5.6.1", | ||
"@algolia/requester-fetch": "5.6.1", | ||
"@algolia/requester-node-http": "5.6.1" | ||
}, | ||
@@ -58,0 +58,0 @@ "devDependencies": { |
@@ -35,13 +35,18 @@ <p align="center"> | ||
To get started, you first need to install @algolia/monitoring (or any other available API client package). | ||
All of our clients comes with type definition, and are available for both browser and node environments. | ||
### With a package manager | ||
```bash | ||
yarn add @algolia/monitoring | ||
yarn add @algolia/monitoring@1.6.1 | ||
# or | ||
npm install @algolia/monitoring | ||
npm install @algolia/monitoring@1.6.1 | ||
# or | ||
pnpm add @algolia/monitoring@1.6.1 | ||
``` | ||
Without a package manager | ||
### Without a package manager | ||
@@ -51,5 +56,7 @@ Add the following JavaScript snippet to the <head> of your website: | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/algoliasearch/dist/monitoring.umd.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@algolia/monitoring@1.6.1/dist/builds/browser.umd.js"></script> | ||
``` | ||
### Usage | ||
You can now import the Algolia API client in your project and play with it. | ||
@@ -63,3 +70,3 @@ | ||
For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/)**. | ||
For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/v5/methods/monitoring/)**. | ||
@@ -66,0 +73,0 @@ ## ❓ Troubleshooting |
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
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
418451
76
+ Added@algolia/client-common@5.6.1(transitive)
+ Added@algolia/requester-browser-xhr@5.6.1(transitive)
+ Added@algolia/requester-fetch@5.6.1(transitive)
+ Added@algolia/requester-node-http@5.6.1(transitive)
- Removed@algolia/client-common@5.6.0(transitive)
- Removed@algolia/requester-browser-xhr@5.6.0(transitive)
- Removed@algolia/requester-fetch@5.6.0(transitive)
- Removed@algolia/requester-node-http@5.6.0(transitive)
Updated@algolia/client-common@5.6.1