@algolia/client-insights
Advanced tools
Comparing version 5.3.0 to 5.3.1
@@ -569,3 +569,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "5.3.0"; | ||
declare const apiClientVersion = "5.3.1"; | ||
declare const REGIONS: readonly ["de", "us"]; | ||
@@ -572,0 +572,0 @@ type Region = (typeof REGIONS)[number]; |
@@ -14,3 +14,3 @@ // builds/browser.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.3.0"; | ||
var apiClientVersion = "5.3.1"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -83,3 +83,7 @@ function getDefaultHosts(region) { | ||
setClientApiKey({ apiKey }) { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
if (!authMode || authMode === "WithinHeaders") { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
} else { | ||
this.transporter.baseQueryParameters["x-algolia-api-key"] = apiKey; | ||
} | ||
}, | ||
@@ -86,0 +90,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
function H(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 j(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 u(o){r().setItem(s,JSON.stringify(o))}function p(){let o=t.timeToLive?t.timeToLive*1e3:null,a=n(),l=Object.fromEntries(Object.entries(a).filter(([,f])=>f.timestamp!==void 0));if(u(l),!o)return;let m=Object.fromEntries(Object.entries(l).filter(([,f])=>{let i=new Date().getTime();return!(f.timestamp+o<i)}));u(m)}return{get(o,a,l={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(o)])).then(m=>Promise.all([m?m.value:a(),m!==void 0])).then(([m,f])=>Promise.all([m,f||l.miss(m)])).then(([m])=>m)},set(o,a){return Promise.resolve().then(()=>{let l=n();return l[JSON.stringify(o)]={timestamp:new Date().getTime(),value:a},r().setItem(s,JSON.stringify(l)),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 Y(){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 v(t){let e=[...t.caches],s=e.shift();return s===void 0?Y():{get(r,n,u={miss:()=>Promise.resolve()}){return s.get(r,n,u).catch(()=>v({caches:e}).get(r,n,u))},set(r,n){return s.set(r,n).catch(()=>v({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>v({caches:e}).delete(r))},clear(){return s.clear().catch(()=>v({caches:e}).clear())}}}function x(t={serializable:!0}){let e={};return{get(s,r,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(t.serializable?JSON.parse(e[u]):e[u]);let p=r();return p.then(o=>n.miss(o)).then(()=>p)},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 L=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>L}function n(){return e==="timed out"&&Date.now()-s<=L}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var J=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},$=class extends J{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},Z=class extends ${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")}},b=class extends ${status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},ee=class extends J{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},te=class extends b{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function re(t,e,s){let r=se(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function se(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 oe(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 ne(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(u=>{let p=r[u];n[u.toLowerCase()]=p}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new te(r.message,e,r.error,s):new b(r.message,e,s)}catch{}return new b(t,e,s)}function ce({isTimedOut:t,status:e}){return!t&&~~e===0}function ue({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return~~(t/100)===2}function me(t){return t.map(e=>M(e))}function M(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 z({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:u,requester:p,requestsCache:o,responsesCache:a}){async function l(i){let c=await Promise.all(i.map(h=>e.get(h,()=>Promise.resolve(W(h))))),g=c.filter(h=>h.isUp()),P=c.filter(h=>h.isTimedOut()),R=[...g,...P];return{hosts:R.length>0?R:i,getTimeout(h,E){return(P.length===0&&h===0?1:P.length+3+h)*E}}}async function m(i,c,g=!0){let P=[],R=oe(i,c),y=ne(s,i.headers,c.headers),h=i.method==="GET"?{...i.data,...c.data}:{},E={...r,...i.queryParameters,...h};if(n.value&&(E["x-algolia-agent"]=n.value),c&&c.queryParameters)for(let d of Object.keys(c.queryParameters))!c.queryParameters[d]||Object.prototype.toString.call(c.queryParameters[d])==="[object Object]"?E[d]=c.queryParameters[d]:E[d]=c.queryParameters[d].toString();let O=0,D=async(d,q)=>{let w=d.pop();if(w===void 0)throw new Z(me(P));let S={...u,...c.timeouts},U={data:R,headers:y,method:i.method,url:re(w,i.path,E),connectTimeout:q(O,S.connect),responseTimeout:q(O,g?S.read:S.write)},_=C=>{let k={request:U,response:C,host:w,triesLeft:d.length};return P.push(k),k},T=await p.send(U);if(ue(T)){let C=_(T);return T.isTimedOut&&O++,console.log("Retryable failure",M(C)),await e.set(w,W(w,T.isTimedOut?"timed out":"down")),D(d,q)}if(le(T))return ae(T);throw _(T),ie(T,P)},V=t.filter(d=>d.accept==="readWrite"||(g?d.accept==="read":d.accept==="write")),I=await l(V);return D([...I.hosts].reverse(),I.getTimeout)}function f(i,c={}){let g=i.useReadTransporter||i.method==="GET";if(!g)return m(i,c,g);let P=()=>m(i,c);if((c.cacheable||i.cacheable)!==!0)return P();let y={request:i,requestOptions:c,transporter:{queryParameters:r,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,P()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,E])=>E)),{miss:h=>a.set(y,h)})}return{hostsCache:e,requester:p,timeouts:u,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:f,requestsCache:o,responsesCache:a}}function he(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 F({algoliaAgents:t,client:e,version:s}){let r=he(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var G=1e3,Q=2e3,B=3e4;function X(){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),u=n(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(u),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var A="5.3.0",N=["de","us"];function pe(t){return[{url:t?"insights.{region}.algolia.io".replace("{region}",t):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function K({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:n,...u}){let p=H(t,e,s);return{transporter:z({hosts:pe(n),...u,algoliaAgent:F({algoliaAgents:r,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.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},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let c={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customGet({path:o,parameters:a},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let c={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customPost({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},customPut({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},deleteUserToken({userToken:o},a){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let i={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(i,a)},pushEvents(o,a){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let i={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return this.transporter.request(i,a)}}}function rt(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return K({appId:t,apiKey:e,region:s,timeouts:{connect:G,read:Q,write:B},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:v({caches:[j({key:`${A}-${t}`}),x()]}),...r})}export{A as apiClientVersion,rt as insightsClient}; | ||
function H(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 j(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 u(o){r().setItem(s,JSON.stringify(o))}function p(){let o=t.timeToLive?t.timeToLive*1e3:null,a=n(),l=Object.fromEntries(Object.entries(a).filter(([,f])=>f.timestamp!==void 0));if(u(l),!o)return;let m=Object.fromEntries(Object.entries(l).filter(([,f])=>{let i=new Date().getTime();return!(f.timestamp+o<i)}));u(m)}return{get(o,a,l={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(o)])).then(m=>Promise.all([m?m.value:a(),m!==void 0])).then(([m,f])=>Promise.all([m,f||l.miss(m)])).then(([m])=>m)},set(o,a){return Promise.resolve().then(()=>{let l=n();return l[JSON.stringify(o)]={timestamp:new Date().getTime(),value:a},r().setItem(s,JSON.stringify(l)),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 Y(){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 v(t){let e=[...t.caches],s=e.shift();return s===void 0?Y():{get(r,n,u={miss:()=>Promise.resolve()}){return s.get(r,n,u).catch(()=>v({caches:e}).get(r,n,u))},set(r,n){return s.set(r,n).catch(()=>v({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>v({caches:e}).delete(r))},clear(){return s.clear().catch(()=>v({caches:e}).clear())}}}function x(t={serializable:!0}){let e={};return{get(s,r,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(t.serializable?JSON.parse(e[u]):e[u]);let p=r();return p.then(o=>n.miss(o)).then(()=>p)},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 L=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>L}function n(){return e==="timed out"&&Date.now()-s<=L}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var J=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},$=class extends J{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},Z=class extends ${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")}},b=class extends ${status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},ee=class extends J{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},te=class extends b{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function re(t,e,s){let r=se(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function se(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 oe(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 ne(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(u=>{let p=r[u];n[u.toLowerCase()]=p}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new te(r.message,e,r.error,s):new b(r.message,e,s)}catch{}return new b(t,e,s)}function ce({isTimedOut:t,status:e}){return!t&&~~e===0}function ue({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return~~(t/100)===2}function me(t){return t.map(e=>M(e))}function M(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 z({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:u,requester:p,requestsCache:o,responsesCache:a}){async function l(i){let c=await Promise.all(i.map(h=>e.get(h,()=>Promise.resolve(W(h))))),g=c.filter(h=>h.isUp()),P=c.filter(h=>h.isTimedOut()),R=[...g,...P];return{hosts:R.length>0?R:i,getTimeout(h,E){return(P.length===0&&h===0?1:P.length+3+h)*E}}}async function m(i,c,g=!0){let P=[],R=oe(i,c),y=ne(s,i.headers,c.headers),h=i.method==="GET"?{...i.data,...c.data}:{},E={...r,...i.queryParameters,...h};if(n.value&&(E["x-algolia-agent"]=n.value),c&&c.queryParameters)for(let d of Object.keys(c.queryParameters))!c.queryParameters[d]||Object.prototype.toString.call(c.queryParameters[d])==="[object Object]"?E[d]=c.queryParameters[d]:E[d]=c.queryParameters[d].toString();let O=0,D=async(d,q)=>{let w=d.pop();if(w===void 0)throw new Z(me(P));let S={...u,...c.timeouts},U={data:R,headers:y,method:i.method,url:re(w,i.path,E),connectTimeout:q(O,S.connect),responseTimeout:q(O,g?S.read:S.write)},k=C=>{let _={request:U,response:C,host:w,triesLeft:d.length};return P.push(_),_},T=await p.send(U);if(ue(T)){let C=k(T);return T.isTimedOut&&O++,console.log("Retryable failure",M(C)),await e.set(w,W(w,T.isTimedOut?"timed out":"down")),D(d,q)}if(le(T))return ae(T);throw k(T),ie(T,P)},V=t.filter(d=>d.accept==="readWrite"||(g?d.accept==="read":d.accept==="write")),I=await l(V);return D([...I.hosts].reverse(),I.getTimeout)}function f(i,c={}){let g=i.useReadTransporter||i.method==="GET";if(!g)return m(i,c,g);let P=()=>m(i,c);if((c.cacheable||i.cacheable)!==!0)return P();let y={request:i,requestOptions:c,transporter:{queryParameters:r,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,P()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,E])=>E)),{miss:h=>a.set(y,h)})}return{hostsCache:e,requester:p,timeouts:u,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:f,requestsCache:o,responsesCache:a}}function he(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 Q({algoliaAgents:t,client:e,version:s}){let r=he(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var F=1e3,G=2e3,B=3e4;function X(){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),u=n(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(u),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var A="5.3.1",N=["de","us"];function pe(t){return[{url:t?"insights.{region}.algolia.io".replace("{region}",t):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function K({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:n,...u}){let p=H(t,e,s);return{transporter:z({hosts:pe(n),...u,algoliaAgent:Q({algoliaAgents:r,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.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}){!s||s==="WithinHeaders"?this.transporter.baseHeaders["x-algolia-api-key"]=o:this.transporter.baseQueryParameters["x-algolia-api-key"]=o},customDelete({path:o,parameters:a},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let c={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customGet({path:o,parameters:a},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let c={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customPost({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},customPut({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},deleteUserToken({userToken:o},a){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let i={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(i,a)},pushEvents(o,a){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let i={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return this.transporter.request(i,a)}}}function rt(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return K({appId:t,apiKey:e,region:s,timeouts:{connect:F,read:G,write:B},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:v({caches:[j({key:`${A}-${t}`}),x()]}),...r})}export{A as apiClientVersion,rt as insightsClient}; | ||
//# sourceMappingURL=browser.min.js.map |
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
function H(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 j(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 u(o){r().setItem(s,JSON.stringify(o));}function p(){let o=t.timeToLive?t.timeToLive*1e3:null,a=n(),l=Object.fromEntries(Object.entries(a).filter(([,f])=>f.timestamp!==void 0));if(u(l),!o)return;let m=Object.fromEntries(Object.entries(l).filter(([,f])=>{let i=new Date().getTime();return !(f.timestamp+o<i)}));u(m);}return {get(o,a,l={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(o)])).then(m=>Promise.all([m?m.value:a(),m!==void 0])).then(([m,f])=>Promise.all([m,f||l.miss(m)])).then(([m])=>m)},set(o,a){return Promise.resolve().then(()=>{let l=n();return l[JSON.stringify(o)]={timestamp:new Date().getTime(),value:a},r().setItem(s,JSON.stringify(l)),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 Y(){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 v(t){let e=[...t.caches],s=e.shift();return s===void 0?Y():{get(r,n,u={miss:()=>Promise.resolve()}){return s.get(r,n,u).catch(()=>v({caches:e}).get(r,n,u))},set(r,n){return s.set(r,n).catch(()=>v({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>v({caches:e}).delete(r))},clear(){return s.clear().catch(()=>v({caches:e}).clear())}}}function x(t={serializable:!0}){let e={};return {get(s,r,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(t.serializable?JSON.parse(e[u]):e[u]);let p=r();return p.then(o=>n.miss(o)).then(()=>p)},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 L=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>L}function n(){return e==="timed out"&&Date.now()-s<=L}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var J=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},$=class extends J{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},Z=class extends ${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");}},b=class extends ${status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},ee=class extends J{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},te=class extends b{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function re(t,e,s){let r=se(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function se(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 oe(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 ne(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(u=>{let p=r[u];n[u.toLowerCase()]=p;}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new te(r.message,e,r.error,s):new b(r.message,e,s)}catch{}return new b(t,e,s)}function ce({isTimedOut:t,status:e}){return !t&&~~e===0}function ue({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return ~~(t/100)===2}function me(t){return t.map(e=>M(e))}function M(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 z({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:u,requester:p,requestsCache:o,responsesCache:a}){async function l(i){let c=await Promise.all(i.map(h=>e.get(h,()=>Promise.resolve(W(h))))),g=c.filter(h=>h.isUp()),P=c.filter(h=>h.isTimedOut()),R=[...g,...P];return {hosts:R.length>0?R:i,getTimeout(h,E){return (P.length===0&&h===0?1:P.length+3+h)*E}}}async function m(i,c,g=!0){let P=[],R=oe(i,c),y=ne(s,i.headers,c.headers),h=i.method==="GET"?{...i.data,...c.data}:{},E={...r,...i.queryParameters,...h};if(n.value&&(E["x-algolia-agent"]=n.value),c&&c.queryParameters)for(let d of Object.keys(c.queryParameters))!c.queryParameters[d]||Object.prototype.toString.call(c.queryParameters[d])==="[object Object]"?E[d]=c.queryParameters[d]:E[d]=c.queryParameters[d].toString();let O=0,D=async(d,q)=>{let w=d.pop();if(w===void 0)throw new Z(me(P));let S={...u,...c.timeouts},U={data:R,headers:y,method:i.method,url:re(w,i.path,E),connectTimeout:q(O,S.connect),responseTimeout:q(O,g?S.read:S.write)},_=C=>{let k={request:U,response:C,host:w,triesLeft:d.length};return P.push(k),k},T=await p.send(U);if(ue(T)){let C=_(T);return T.isTimedOut&&O++,console.log("Retryable failure",M(C)),await e.set(w,W(w,T.isTimedOut?"timed out":"down")),D(d,q)}if(le(T))return ae(T);throw _(T),ie(T,P)},V=t.filter(d=>d.accept==="readWrite"||(g?d.accept==="read":d.accept==="write")),I=await l(V);return D([...I.hosts].reverse(),I.getTimeout)}function f(i,c={}){let g=i.useReadTransporter||i.method==="GET";if(!g)return m(i,c,g);let P=()=>m(i,c);if((c.cacheable||i.cacheable)!==!0)return P();let y={request:i,requestOptions:c,transporter:{queryParameters:r,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,P()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,E])=>E)),{miss:h=>a.set(y,h)})}return {hostsCache:e,requester:p,timeouts:u,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:f,requestsCache:o,responsesCache:a}}function he(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 F({algoliaAgents:t,client:e,version:s}){let r=he(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var G=1e3,Q=2e3,B=3e4;function X(){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),u=n(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(u),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}var A="5.3.0",N=["de","us"];function pe(t){return [{url:t?"insights.{region}.algolia.io".replace("{region}",t):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function K({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:n,...u}){let p=H(t,e,s);return {transporter:z({hosts:pe(n),...u,algoliaAgent:F({algoliaAgents:r,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.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},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let c={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customGet({path:o,parameters:a},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let c={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customPost({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},customPut({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},deleteUserToken({userToken:o},a){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let i={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(i,a)},pushEvents(o,a){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let i={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return this.transporter.request(i,a)}}}function rt(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return K({appId:t,apiKey:e,region:s,timeouts:{connect:G,read:Q,write:B},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:v({caches:[j({key:`${A}-${t}`}),x()]}),...r})} | ||
function H(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 j(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 u(o){r().setItem(s,JSON.stringify(o));}function p(){let o=t.timeToLive?t.timeToLive*1e3:null,a=n(),l=Object.fromEntries(Object.entries(a).filter(([,f])=>f.timestamp!==void 0));if(u(l),!o)return;let m=Object.fromEntries(Object.entries(l).filter(([,f])=>{let i=new Date().getTime();return !(f.timestamp+o<i)}));u(m);}return {get(o,a,l={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(o)])).then(m=>Promise.all([m?m.value:a(),m!==void 0])).then(([m,f])=>Promise.all([m,f||l.miss(m)])).then(([m])=>m)},set(o,a){return Promise.resolve().then(()=>{let l=n();return l[JSON.stringify(o)]={timestamp:new Date().getTime(),value:a},r().setItem(s,JSON.stringify(l)),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 Y(){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 v(t){let e=[...t.caches],s=e.shift();return s===void 0?Y():{get(r,n,u={miss:()=>Promise.resolve()}){return s.get(r,n,u).catch(()=>v({caches:e}).get(r,n,u))},set(r,n){return s.set(r,n).catch(()=>v({caches:e}).set(r,n))},delete(r){return s.delete(r).catch(()=>v({caches:e}).delete(r))},clear(){return s.clear().catch(()=>v({caches:e}).clear())}}}function x(t={serializable:!0}){let e={};return {get(s,r,n={miss:()=>Promise.resolve()}){let u=JSON.stringify(s);if(u in e)return Promise.resolve(t.serializable?JSON.parse(e[u]):e[u]);let p=r();return p.then(o=>n.miss(o)).then(()=>p)},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 L=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>L}function n(){return e==="timed out"&&Date.now()-s<=L}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:n}}var J=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},$=class extends J{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},Z=class extends ${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");}},b=class extends ${status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},ee=class extends J{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},te=class extends b{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function re(t,e,s){let r=se(s),n=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(n+=`?${r}`),n}function se(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 oe(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 ne(t,e,s){let r={Accept:"application/json",...t,...e,...s},n={};return Object.keys(r).forEach(u=>{let p=r[u];n[u.toLowerCase()]=p;}),n}function ae(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new te(r.message,e,r.error,s):new b(r.message,e,s)}catch{}return new b(t,e,s)}function ce({isTimedOut:t,status:e}){return !t&&~~e===0}function ue({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:t}){return ~~(t/100)===2}function me(t){return t.map(e=>M(e))}function M(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 z({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:n,timeouts:u,requester:p,requestsCache:o,responsesCache:a}){async function l(i){let c=await Promise.all(i.map(h=>e.get(h,()=>Promise.resolve(W(h))))),g=c.filter(h=>h.isUp()),P=c.filter(h=>h.isTimedOut()),R=[...g,...P];return {hosts:R.length>0?R:i,getTimeout(h,E){return (P.length===0&&h===0?1:P.length+3+h)*E}}}async function m(i,c,g=!0){let P=[],R=oe(i,c),y=ne(s,i.headers,c.headers),h=i.method==="GET"?{...i.data,...c.data}:{},E={...r,...i.queryParameters,...h};if(n.value&&(E["x-algolia-agent"]=n.value),c&&c.queryParameters)for(let d of Object.keys(c.queryParameters))!c.queryParameters[d]||Object.prototype.toString.call(c.queryParameters[d])==="[object Object]"?E[d]=c.queryParameters[d]:E[d]=c.queryParameters[d].toString();let O=0,D=async(d,q)=>{let w=d.pop();if(w===void 0)throw new Z(me(P));let S={...u,...c.timeouts},U={data:R,headers:y,method:i.method,url:re(w,i.path,E),connectTimeout:q(O,S.connect),responseTimeout:q(O,g?S.read:S.write)},k=C=>{let _={request:U,response:C,host:w,triesLeft:d.length};return P.push(_),_},T=await p.send(U);if(ue(T)){let C=k(T);return T.isTimedOut&&O++,console.log("Retryable failure",M(C)),await e.set(w,W(w,T.isTimedOut?"timed out":"down")),D(d,q)}if(le(T))return ae(T);throw k(T),ie(T,P)},V=t.filter(d=>d.accept==="readWrite"||(g?d.accept==="read":d.accept==="write")),I=await l(V);return D([...I.hosts].reverse(),I.getTimeout)}function f(i,c={}){let g=i.useReadTransporter||i.method==="GET";if(!g)return m(i,c,g);let P=()=>m(i,c);if((c.cacheable||i.cacheable)!==!0)return P();let y={request:i,requestOptions:c,transporter:{queryParameters:r,headers:s}};return a.get(y,()=>o.get(y,()=>o.set(y,P()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,E])=>E)),{miss:h=>a.set(y,h)})}return {hostsCache:e,requester:p,timeouts:u,algoliaAgent:n,baseHeaders:s,baseQueryParameters:r,hosts:t,request:f,requestsCache:o,responsesCache:a}}function he(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 Q({algoliaAgents:t,client:e,version:s}){let r=he(s).add({segment:e,version:s});return t.forEach(n=>r.add(n)),r}var F=1e3,G=2e3,B=3e4;function X(){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),u=n(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(u),p=n(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(u),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(u),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}var A="5.3.1",N=["de","us"];function pe(t){return [{url:t?"insights.{region}.algolia.io".replace("{region}",t):"insights.algolia.io",accept:"readWrite",protocol:"https"}]}function K({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:n,...u}){let p=H(t,e,s);return {transporter:z({hosts:pe(n),...u,algoliaAgent:Q({algoliaAgents:r,client:"Insights",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...u.baseHeaders},baseQueryParameters:{...p.queryParameters(),...u.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}){!s||s==="WithinHeaders"?this.transporter.baseHeaders["x-algolia-api-key"]=o:this.transporter.baseQueryParameters["x-algolia-api-key"]=o;},customDelete({path:o,parameters:a},l){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let c={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customGet({path:o,parameters:a},l){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let c={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{}};return this.transporter.request(c,l)},customPost({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},customPut({path:o,parameters:a,body:l},m){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:a||{},headers:{},data:l||{}};return this.transporter.request(g,m)},deleteUserToken({userToken:o},a){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserToken`.");let i={method:"DELETE",path:"/1/usertokens/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(i,a)},pushEvents(o,a){if(!o)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!o.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");let i={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:o};return this.transporter.request(i,a)}}}function rt(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(s&&(typeof s!="string"||!N.includes(s)))throw new Error(`\`region\` must be one of the following: ${N.join(", ")}`);return K({appId:t,apiKey:e,region:s,timeouts:{connect:F,read:G,write:B},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:x(),requestsCache:x({serializable:!1}),hostsCache:v({caches:[j({key:`${A}-${t}`}),x()]}),...r})} | ||
@@ -10,0 +10,0 @@ exports.apiClientVersion = A; |
@@ -13,3 +13,3 @@ // builds/node.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.3.0"; | ||
var apiClientVersion = "5.3.1"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -82,3 +82,7 @@ function getDefaultHosts(region) { | ||
setClientApiKey({ apiKey }) { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
if (!authMode || authMode === "WithinHeaders") { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
} else { | ||
this.transporter.baseQueryParameters["x-algolia-api-key"] = apiKey; | ||
} | ||
}, | ||
@@ -85,0 +89,0 @@ /** |
@@ -569,3 +569,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "5.3.0"; | ||
declare const apiClientVersion = "5.3.1"; | ||
declare const REGIONS: readonly ["de", "us"]; | ||
@@ -572,0 +572,0 @@ type Region = (typeof REGIONS)[number]; |
// src/insightsClient.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.3.0"; | ||
var apiClientVersion = "5.3.1"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -71,3 +71,7 @@ function getDefaultHosts(region) { | ||
setClientApiKey({ apiKey }) { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
if (!authMode || authMode === "WithinHeaders") { | ||
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey; | ||
} else { | ||
this.transporter.baseQueryParameters["x-algolia-api-key"] = apiKey; | ||
} | ||
}, | ||
@@ -74,0 +78,0 @@ /** |
{ | ||
"version": "5.3.0", | ||
"version": "5.3.1", | ||
"repository": { | ||
@@ -47,5 +47,5 @@ "type": "git", | ||
"dependencies": { | ||
"@algolia/client-common": "5.3.0", | ||
"@algolia/requester-browser-xhr": "5.3.0", | ||
"@algolia/requester-node-http": "5.3.0" | ||
"@algolia/client-common": "5.3.1", | ||
"@algolia/requester-browser-xhr": "5.3.1", | ||
"@algolia/requester-node-http": "5.3.1" | ||
}, | ||
@@ -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
355441
3360
+ Added@algolia/client-common@5.3.1(transitive)
+ Added@algolia/requester-browser-xhr@5.3.1(transitive)
+ Added@algolia/requester-node-http@5.3.1(transitive)
- Removed@algolia/client-common@5.3.0(transitive)
- Removed@algolia/requester-browser-xhr@5.3.0(transitive)
- Removed@algolia/requester-node-http@5.3.0(transitive)
Updated@algolia/client-common@5.3.1