@algolia/client-abtesting
Advanced tools
Comparing version 5.9.0 to 5.9.1
@@ -441,3 +441,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "5.9.0"; | ||
declare const apiClientVersion = "5.9.1"; | ||
declare const REGIONS: readonly ["de", "us"]; | ||
@@ -444,0 +444,0 @@ type Region = (typeof REGIONS)[number]; |
@@ -15,3 +15,3 @@ // builds/browser.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.9.0"; | ||
var apiClientVersion = "5.9.1"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -18,0 +18,0 @@ function getDefaultHosts(region) { |
@@ -1,2 +0,2 @@ | ||
function k(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let i=(a,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0})},a),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}function $(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(a){r().setItem(s,JSON.stringify(a))}function p(){let a=t.timeToLive?t.timeToLive*1e3:null,o=i(),n=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let u=Object.fromEntries(Object.entries(n).filter(([,d])=>{let g=new Date().getTime();return!(d.timestamp+a<g)}));m(u)}return{get(a,o,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:o(),u!==void 0])).then(([u,d])=>Promise.all([u,d||n.miss(u)])).then(([u])=>u)},set(a,o){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(n)),o})},delete(a){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(a)],r().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function ee(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function q(t){let e=[...t.caches],s=e.shift();return s===void 0?ee():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>q({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>q({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>q({caches:e}).delete(r))},clear(){return s.clear().catch(()=>q({caches:e}).clear())}}}function v(t={serializable:!0}){let e={};return{get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(a=>i.miss(a)).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 j=1e3,J=2e3,Q=3e4;function te(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 G(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 M({algoliaAgents:t,client:e,version:s}){let r=te(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function z(){return{debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var H=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>H}function i(){return e==="timed out"&&Date.now()-s<=H}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var F=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},X=class extends F{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},re=class extends X{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")}},C=class extends X{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},se=class extends F{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},oe=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function ae(t,e,s){let r=ne(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function ne(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]).replace(/\+/g,"%20")}`).join("&")}function ie(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 ce(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p}),i}function ue(t){try{return JSON.parse(t.content)}catch(e){throw new se(e.message,t)}}function le({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new oe(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function me({isTimedOut:t,status:e}){return!t&&~~e===0}function de({isTimedOut:t,status:e}){return t||me({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:t}){return~~(t/100)===2}function pe(t){return t.map(e=>K(e))}function K(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 V({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:o,responsesCache:n}){async function u(c){let l=await Promise.all(c.map(h=>e.get(h,()=>Promise.resolve(W(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),R=[...f,...T];return{hosts:R.length>0?R:c,getTimeout(h,A){return(T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(c,l,f=!0){let T=[],R=ie(c,l),y=ce(s,c.headers,l.headers),h=c.method==="GET"?{...c.data,...l.data}:{},A={...i,...c.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let P of Object.keys(l.queryParameters))!l.queryParameters[P]||Object.prototype.toString.call(l.queryParameters[P])==="[object Object]"?A[P]=l.queryParameters[P]:A[P]=l.queryParameters[P].toString();let O=0,N=async(P,b)=>{let w=P.pop();if(w===void 0)throw new re(pe(T));let B={...p,...l.timeouts},I={data:R,headers:y,method:c.method,url:ae(w,c.path,A),connectTimeout:b(O,B.connect),responseTimeout:b(O,f?B.read:B.write)},U=x=>{let L={request:I,response:x,host:w,triesLeft:P.length};return T.push(L),L},E=await a.send(I);if(de(E)){let x=U(E);return E.isTimedOut&&O++,r.info("Retryable failure",K(x)),await e.set(w,W(w,E.isTimedOut?"timed out":"down")),N(P,b)}if(he(E))return ue(E);throw U(E),le(E,T)},Z=t.filter(P=>P.accept==="readWrite"||(f?P.accept==="read":P.accept==="write")),D=await u(Z);return N([...D.hosts].reverse(),D.getTimeout)}function g(c,l={}){let f=c.useReadTransporter||c.method==="GET";if(!f)return d(c,l,f);let T=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return T();let y={request:c,requestOptions:l,transporter:{queryParameters:i,headers:s}};return n.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>n.set(y,h)})}return{hostsCache:e,requester:a,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:g,requestsCache:o,responsesCache:n}}var S="5.9.0",_=["de","us"];function fe(t){return[{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function Y({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=G(t,e,s),a=V({hosts:fe(i),...m,algoliaAgent:M({algoliaAgents:r,client:"Abtesting",version:S}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,n){a.algoliaAgent.add({segment:o,version:n})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},addABTests(o,n){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let c={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return a.request(c,n)},customDelete({path:o,parameters:n},u){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 a.request(l,u)},customGet({path:o,parameters:n},u){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 a.request(l,u)},customPost({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},customPut({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},deleteABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let c={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},getABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let c={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},listABTests({offset:o,limit:n,indexPrefix:u,indexSuffix:d}={},g=void 0){let c="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),n!==void 0&&(f.limit=n.toString()),u!==void 0&&(f.indexPrefix=u.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:c,queryParameters:f,headers:l};return a.request(T,g)},scheduleABTest(o,n){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let c={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return a.request(c,n)},stopABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let c={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)}}}function tt(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"||!_.includes(s)))throw new Error(`\`region\` must be one of the following: ${_.join(", ")}`);return Y({appId:t,apiKey:e,region:s,timeouts:{connect:j,read:J,write:Q},logger:z(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:v(),requestsCache:v({serializable:!1}),hostsCache:q({caches:[$({key:`${S}-${t}`}),v()]}),...r})}export{tt as abtestingClient,S as apiClientVersion}; | ||
function k(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let i=(a,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0})},a),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}function $(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(a){r().setItem(s,JSON.stringify(a))}function p(){let a=t.timeToLive?t.timeToLive*1e3:null,o=i(),n=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let u=Object.fromEntries(Object.entries(n).filter(([,d])=>{let g=new Date().getTime();return!(d.timestamp+a<g)}));m(u)}return{get(a,o,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:o(),u!==void 0])).then(([u,d])=>Promise.all([u,d||n.miss(u)])).then(([u])=>u)},set(a,o){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(n)),o})},delete(a){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(a)],r().setItem(s,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function ee(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function q(t){let e=[...t.caches],s=e.shift();return s===void 0?ee():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>q({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>q({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>q({caches:e}).delete(r))},clear(){return s.clear().catch(()=>q({caches:e}).clear())}}}function v(t={serializable:!0}){let e={};return{get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(a=>i.miss(a)).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 j=1e3,J=2e3,Q=3e4;function te(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 G(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 M({algoliaAgents:t,client:e,version:s}){let r=te(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function z(){return{debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var H=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>H}function i(){return e==="timed out"&&Date.now()-s<=H}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var F=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},X=class extends F{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},re=class extends X{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")}},C=class extends X{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},se=class extends F{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},oe=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function ae(t,e,s){let r=ne(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function ne(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]).replace(/\+/g,"%20")}`).join("&")}function ie(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 ce(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p}),i}function ue(t){try{return JSON.parse(t.content)}catch(e){throw new se(e.message,t)}}function le({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new oe(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function me({isTimedOut:t,status:e}){return!t&&~~e===0}function de({isTimedOut:t,status:e}){return t||me({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:t}){return~~(t/100)===2}function pe(t){return t.map(e=>K(e))}function K(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 V({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:o,responsesCache:n}){async function u(c){let l=await Promise.all(c.map(h=>e.get(h,()=>Promise.resolve(W(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),R=[...f,...T];return{hosts:R.length>0?R:c,getTimeout(h,A){return(T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(c,l,f=!0){let T=[],R=ie(c,l),y=ce(s,c.headers,l.headers),h=c.method==="GET"?{...c.data,...l.data}:{},A={...i,...c.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let P of Object.keys(l.queryParameters))!l.queryParameters[P]||Object.prototype.toString.call(l.queryParameters[P])==="[object Object]"?A[P]=l.queryParameters[P]:A[P]=l.queryParameters[P].toString();let O=0,N=async(P,b)=>{let w=P.pop();if(w===void 0)throw new re(pe(T));let B={...p,...l.timeouts},I={data:R,headers:y,method:c.method,url:ae(w,c.path,A),connectTimeout:b(O,B.connect),responseTimeout:b(O,f?B.read:B.write)},U=x=>{let L={request:I,response:x,host:w,triesLeft:P.length};return T.push(L),L},E=await a.send(I);if(de(E)){let x=U(E);return E.isTimedOut&&O++,r.info("Retryable failure",K(x)),await e.set(w,W(w,E.isTimedOut?"timed out":"down")),N(P,b)}if(he(E))return ue(E);throw U(E),le(E,T)},Z=t.filter(P=>P.accept==="readWrite"||(f?P.accept==="read":P.accept==="write")),D=await u(Z);return N([...D.hosts].reverse(),D.getTimeout)}function g(c,l={}){let f=c.useReadTransporter||c.method==="GET";if(!f)return d(c,l,f);let T=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return T();let y={request:c,requestOptions:l,transporter:{queryParameters:i,headers:s}};return n.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>n.set(y,h)})}return{hostsCache:e,requester:a,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:g,requestsCache:o,responsesCache:n}}var S="5.9.1",_=["de","us"];function fe(t){return[{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function Y({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=G(t,e,s),a=V({hosts:fe(i),...m,algoliaAgent:M({algoliaAgents:r,client:"Abtesting",version:S}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,n){a.algoliaAgent.add({segment:o,version:n})},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o},addABTests(o,n){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let c={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return a.request(c,n)},customDelete({path:o,parameters:n},u){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 a.request(l,u)},customGet({path:o,parameters:n},u){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 a.request(l,u)},customPost({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},customPut({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},deleteABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let c={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},getABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let c={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},listABTests({offset:o,limit:n,indexPrefix:u,indexSuffix:d}={},g=void 0){let c="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),n!==void 0&&(f.limit=n.toString()),u!==void 0&&(f.indexPrefix=u.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:c,queryParameters:f,headers:l};return a.request(T,g)},scheduleABTest(o,n){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let c={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return a.request(c,n)},stopABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let c={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)}}}function tt(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"||!_.includes(s)))throw new Error(`\`region\` must be one of the following: ${_.join(", ")}`);return Y({appId:t,apiKey:e,region:s,timeouts:{connect:j,read:J,write:Q},logger:z(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:v(),requestsCache:v({serializable:!1}),hostsCache:q({caches:[$({key:`${S}-${t}`}),v()]}),...r})}export{tt as abtestingClient,S as apiClientVersion}; | ||
//# sourceMappingURL=browser.min.js.map |
@@ -7,3 +7,3 @@ (function (global, factory) { | ||
function k(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let i=(a,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0});},a),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}function $(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(a){r().setItem(s,JSON.stringify(a));}function p(){let a=t.timeToLive?t.timeToLive*1e3:null,o=i(),n=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let u=Object.fromEntries(Object.entries(n).filter(([,d])=>{let g=new Date().getTime();return !(d.timestamp+a<g)}));m(u);}return {get(a,o,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:o(),u!==void 0])).then(([u,d])=>Promise.all([u,d||n.miss(u)])).then(([u])=>u)},set(a,o){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(n)),o})},delete(a){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(a)],r().setItem(s,JSON.stringify(o));})},clear(){return Promise.resolve().then(()=>{r().removeItem(s);})}}}function ee(){return {get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function q(t){let e=[...t.caches],s=e.shift();return s===void 0?ee():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>q({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>q({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>q({caches:e}).delete(r))},clear(){return s.clear().catch(()=>q({caches:e}).clear())}}}function v(t={serializable:!0}){let e={};return {get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(a=>i.miss(a)).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 j=1e3,J=2e3,Q=3e4;function te(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 G(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 M({algoliaAgents:t,client:e,version:s}){let r=te(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function z(){return {debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var H=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>H}function i(){return e==="timed out"&&Date.now()-s<=H}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var F=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},X=class extends F{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},re=class extends X{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");}},C=class extends X{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},se=class extends F{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},oe=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function ae(t,e,s){let r=ne(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function ne(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]).replace(/\+/g,"%20")}`).join("&")}function ie(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 ce(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p;}),i}function ue(t){try{return JSON.parse(t.content)}catch(e){throw new se(e.message,t)}}function le({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new oe(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function me({isTimedOut:t,status:e}){return !t&&~~e===0}function de({isTimedOut:t,status:e}){return t||me({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:t}){return ~~(t/100)===2}function pe(t){return t.map(e=>K(e))}function K(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 V({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:o,responsesCache:n}){async function u(c){let l=await Promise.all(c.map(h=>e.get(h,()=>Promise.resolve(W(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),R=[...f,...T];return {hosts:R.length>0?R:c,getTimeout(h,A){return (T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(c,l,f=!0){let T=[],R=ie(c,l),y=ce(s,c.headers,l.headers),h=c.method==="GET"?{...c.data,...l.data}:{},A={...i,...c.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let P of Object.keys(l.queryParameters))!l.queryParameters[P]||Object.prototype.toString.call(l.queryParameters[P])==="[object Object]"?A[P]=l.queryParameters[P]:A[P]=l.queryParameters[P].toString();let O=0,N=async(P,b)=>{let w=P.pop();if(w===void 0)throw new re(pe(T));let B={...p,...l.timeouts},I={data:R,headers:y,method:c.method,url:ae(w,c.path,A),connectTimeout:b(O,B.connect),responseTimeout:b(O,f?B.read:B.write)},U=x=>{let L={request:I,response:x,host:w,triesLeft:P.length};return T.push(L),L},E=await a.send(I);if(de(E)){let x=U(E);return E.isTimedOut&&O++,r.info("Retryable failure",K(x)),await e.set(w,W(w,E.isTimedOut?"timed out":"down")),N(P,b)}if(he(E))return ue(E);throw U(E),le(E,T)},Z=t.filter(P=>P.accept==="readWrite"||(f?P.accept==="read":P.accept==="write")),D=await u(Z);return N([...D.hosts].reverse(),D.getTimeout)}function g(c,l={}){let f=c.useReadTransporter||c.method==="GET";if(!f)return d(c,l,f);let T=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return T();let y={request:c,requestOptions:l,transporter:{queryParameters:i,headers:s}};return n.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>n.set(y,h)})}return {hostsCache:e,requester:a,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:g,requestsCache:o,responsesCache:n}}var S="5.9.0",_=["de","us"];function fe(t){return [{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function Y({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=G(t,e,s),a=V({hosts:fe(i),...m,algoliaAgent:M({algoliaAgents:r,client:"Abtesting",version:S}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return {transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,n){a.algoliaAgent.add({segment:o,version:n});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o;},addABTests(o,n){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let c={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return a.request(c,n)},customDelete({path:o,parameters:n},u){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 a.request(l,u)},customGet({path:o,parameters:n},u){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 a.request(l,u)},customPost({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},customPut({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},deleteABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let c={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},getABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let c={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},listABTests({offset:o,limit:n,indexPrefix:u,indexSuffix:d}={},g=void 0){let c="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),n!==void 0&&(f.limit=n.toString()),u!==void 0&&(f.indexPrefix=u.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:c,queryParameters:f,headers:l};return a.request(T,g)},scheduleABTest(o,n){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let c={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return a.request(c,n)},stopABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let c={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)}}}function tt(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"||!_.includes(s)))throw new Error(`\`region\` must be one of the following: ${_.join(", ")}`);return Y({appId:t,apiKey:e,region:s,timeouts:{connect:j,read:J,write:Q},logger:z(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:v(),requestsCache:v({serializable:!1}),hostsCache:q({caches:[$({key:`${S}-${t}`}),v()]}),...r})} | ||
function k(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>r.setRequestHeader(a,e.headers[a]));let i=(a,o)=>setTimeout(()=>{r.abort(),s({status:0,content:o,isTimedOut:!0});},a),m=i(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(m),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}));},r.onload=()=>{clearTimeout(m),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1});},r.send(e.data);})}return {send:t}}function $(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function i(){return JSON.parse(r().getItem(s)||"{}")}function m(a){r().setItem(s,JSON.stringify(a));}function p(){let a=t.timeToLive?t.timeToLive*1e3:null,o=i(),n=Object.fromEntries(Object.entries(o).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let u=Object.fromEntries(Object.entries(n).filter(([,d])=>{let g=new Date().getTime();return !(d.timestamp+a<g)}));m(u);}return {get(a,o,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:o(),u!==void 0])).then(([u,d])=>Promise.all([u,d||n.miss(u)])).then(([u])=>u)},set(a,o){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:o},r().setItem(s,JSON.stringify(n)),o})},delete(a){return Promise.resolve().then(()=>{let o=i();delete o[JSON.stringify(a)],r().setItem(s,JSON.stringify(o));})},clear(){return Promise.resolve().then(()=>{r().removeItem(s);})}}}function ee(){return {get(t,e,s={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,s.miss(i)])).then(([i])=>i)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function q(t){let e=[...t.caches],s=e.shift();return s===void 0?ee():{get(r,i,m={miss:()=>Promise.resolve()}){return s.get(r,i,m).catch(()=>q({caches:e}).get(r,i,m))},set(r,i){return s.set(r,i).catch(()=>q({caches:e}).set(r,i))},delete(r){return s.delete(r).catch(()=>q({caches:e}).delete(r))},clear(){return s.clear().catch(()=>q({caches:e}).clear())}}}function v(t={serializable:!0}){let e={};return {get(s,r,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(s);if(m in e)return Promise.resolve(t.serializable?JSON.parse(e[m]):e[m]);let p=r();return p.then(a=>i.miss(a)).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 j=1e3,J=2e3,Q=3e4;function te(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 G(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 M({algoliaAgents:t,client:e,version:s}){let r=te(s).add({segment:e,version:s});return t.forEach(i=>r.add(i)),r}function z(){return {debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var H=2*60*1e3;function W(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>H}function i(){return e==="timed out"&&Date.now()-s<=H}return {...t,status:e,lastUpdate:s,isUp:r,isTimedOut:i}}var F=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e);}},X=class extends F{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e;}},re=class extends X{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");}},C=class extends X{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e;}},se=class extends F{response;constructor(t,e){super(t,"DeserializationError"),this.response=e;}},oe=class extends C{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s;}};function ae(t,e,s){let r=ne(s),i=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(i+=`?${r}`),i}function ne(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]).replace(/\+/g,"%20")}`).join("&")}function ie(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 ce(t,e,s){let r={Accept:"application/json",...t,...e,...s},i={};return Object.keys(r).forEach(m=>{let p=r[m];i[m.toLowerCase()]=p;}),i}function ue(t){try{return JSON.parse(t.content)}catch(e){throw new se(e.message,t)}}function le({content:t,status:e},s){try{let r=JSON.parse(t);return "error"in r?new oe(r.message,e,r.error,s):new C(r.message,e,s)}catch{}return new C(t,e,s)}function me({isTimedOut:t,status:e}){return !t&&~~e===0}function de({isTimedOut:t,status:e}){return t||me({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:t}){return ~~(t/100)===2}function pe(t){return t.map(e=>K(e))}function K(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 V({hosts:t,hostsCache:e,baseHeaders:s,logger:r,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:o,responsesCache:n}){async function u(c){let l=await Promise.all(c.map(h=>e.get(h,()=>Promise.resolve(W(h))))),f=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),R=[...f,...T];return {hosts:R.length>0?R:c,getTimeout(h,A){return (T.length===0&&h===0?1:T.length+3+h)*A}}}async function d(c,l,f=!0){let T=[],R=ie(c,l),y=ce(s,c.headers,l.headers),h=c.method==="GET"?{...c.data,...l.data}:{},A={...i,...c.queryParameters,...h};if(m.value&&(A["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let P of Object.keys(l.queryParameters))!l.queryParameters[P]||Object.prototype.toString.call(l.queryParameters[P])==="[object Object]"?A[P]=l.queryParameters[P]:A[P]=l.queryParameters[P].toString();let O=0,N=async(P,b)=>{let w=P.pop();if(w===void 0)throw new re(pe(T));let B={...p,...l.timeouts},I={data:R,headers:y,method:c.method,url:ae(w,c.path,A),connectTimeout:b(O,B.connect),responseTimeout:b(O,f?B.read:B.write)},U=x=>{let L={request:I,response:x,host:w,triesLeft:P.length};return T.push(L),L},E=await a.send(I);if(de(E)){let x=U(E);return E.isTimedOut&&O++,r.info("Retryable failure",K(x)),await e.set(w,W(w,E.isTimedOut?"timed out":"down")),N(P,b)}if(he(E))return ue(E);throw U(E),le(E,T)},Z=t.filter(P=>P.accept==="readWrite"||(f?P.accept==="read":P.accept==="write")),D=await u(Z);return N([...D.hosts].reverse(),D.getTimeout)}function g(c,l={}){let f=c.useReadTransporter||c.method==="GET";if(!f)return d(c,l,f);let T=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return T();let y={request:c,requestOptions:l,transporter:{queryParameters:i,headers:s}};return n.get(y,()=>o.get(y,()=>o.set(y,T()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,A])=>A)),{miss:h=>n.set(y,h)})}return {hostsCache:e,requester:a,timeouts:p,logger:r,algoliaAgent:m,baseHeaders:s,baseQueryParameters:i,hosts:t,request:g,requestsCache:o,responsesCache:n}}var S="5.9.1",_=["de","us"];function fe(t){return [{url:t?"analytics.{region}.algolia.com".replace("{region}",t):"analytics.algolia.com",accept:"readWrite",protocol:"https"}]}function Y({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:i,...m}){let p=G(t,e,s),a=V({hosts:fe(i),...m,algoliaAgent:M({algoliaAgents:r,client:"Abtesting",version:S}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return {transporter:a,appId:t,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(o,n){a.algoliaAgent.add({segment:o,version:n});},setClientApiKey({apiKey:o}){!s||s==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=o:a.baseQueryParameters["x-algolia-api-key"]=o;},addABTests(o,n){if(!o)throw new Error("Parameter `addABTestsRequest` is required when calling `addABTests`.");if(!o.name)throw new Error("Parameter `addABTestsRequest.name` is required when calling `addABTests`.");if(!o.variants)throw new Error("Parameter `addABTestsRequest.variants` is required when calling `addABTests`.");if(!o.endAt)throw new Error("Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.");let c={method:"POST",path:"/2/abtests",queryParameters:{},headers:{},data:o};return a.request(c,n)},customDelete({path:o,parameters:n},u){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 a.request(l,u)},customGet({path:o,parameters:n},u){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 a.request(l,u)},customPost({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},customPut({path:o,parameters:n,body:u},d){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return a.request(f,d)},deleteABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `deleteABTest`.");let c={method:"DELETE",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},getABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `getABTest`.");let c={method:"GET",path:"/2/abtests/{id}".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)},listABTests({offset:o,limit:n,indexPrefix:u,indexSuffix:d}={},g=void 0){let c="/2/abtests",l={},f={};o!==void 0&&(f.offset=o.toString()),n!==void 0&&(f.limit=n.toString()),u!==void 0&&(f.indexPrefix=u.toString()),d!==void 0&&(f.indexSuffix=d.toString());let T={method:"GET",path:c,queryParameters:f,headers:l};return a.request(T,g)},scheduleABTest(o,n){if(!o)throw new Error("Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.");if(!o.name)throw new Error("Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.");if(!o.variants)throw new Error("Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.");if(!o.scheduledAt)throw new Error("Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.");if(!o.endAt)throw new Error("Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.");let c={method:"POST",path:"/2/abtests/schedule",queryParameters:{},headers:{},data:o};return a.request(c,n)},stopABTest({id:o},n){if(!o)throw new Error("Parameter `id` is required when calling `stopABTest`.");let c={method:"POST",path:"/2/abtests/{id}/stop".replace("{id}",encodeURIComponent(o)),queryParameters:{},headers:{}};return a.request(c,n)}}}function tt(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"||!_.includes(s)))throw new Error(`\`region\` must be one of the following: ${_.join(", ")}`);return Y({appId:t,apiKey:e,region:s,timeouts:{connect:j,read:J,write:Q},logger:z(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:v(),requestsCache:v({serializable:!1}),hostsCache:q({caches:[$({key:`${S}-${t}`}),v()]}),...r})} | ||
@@ -10,0 +10,0 @@ exports.abtestingClient = tt; |
@@ -14,3 +14,3 @@ // builds/fetch.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.9.0"; | ||
var apiClientVersion = "5.9.1"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -17,0 +17,0 @@ function getDefaultHosts(region) { |
@@ -14,3 +14,3 @@ // builds/node.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.9.0"; | ||
var apiClientVersion = "5.9.1"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -17,0 +17,0 @@ function getDefaultHosts(region) { |
@@ -441,3 +441,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "5.9.0"; | ||
declare const apiClientVersion = "5.9.1"; | ||
declare const REGIONS: readonly ["de", "us"]; | ||
@@ -444,0 +444,0 @@ type Region = (typeof REGIONS)[number]; |
@@ -441,3 +441,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "5.9.0"; | ||
declare const apiClientVersion = "5.9.1"; | ||
declare const REGIONS: readonly ["de", "us"]; | ||
@@ -444,0 +444,0 @@ type Region = (typeof REGIONS)[number]; |
// src/abtestingClient.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.9.0"; | ||
var apiClientVersion = "5.9.1"; | ||
var REGIONS = ["de", "us"]; | ||
@@ -5,0 +5,0 @@ function getDefaultHosts(region) { |
{ | ||
"version": "5.9.0", | ||
"version": "5.9.1", | ||
"repository": { | ||
@@ -52,6 +52,6 @@ "type": "git", | ||
"dependencies": { | ||
"@algolia/client-common": "5.9.0", | ||
"@algolia/requester-browser-xhr": "5.9.0", | ||
"@algolia/requester-fetch": "5.9.0", | ||
"@algolia/requester-node-http": "5.9.0" | ||
"@algolia/client-common": "5.9.1", | ||
"@algolia/requester-browser-xhr": "5.9.1", | ||
"@algolia/requester-fetch": "5.9.1", | ||
"@algolia/requester-node-http": "5.9.1" | ||
}, | ||
@@ -58,0 +58,0 @@ "devDependencies": { |
@@ -44,7 +44,7 @@ <p align="center"> | ||
```bash | ||
yarn add @algolia/client-abtesting@5.9.0 | ||
yarn add @algolia/client-abtesting@5.9.1 | ||
# or | ||
npm install @algolia/client-abtesting@5.9.0 | ||
npm install @algolia/client-abtesting@5.9.1 | ||
# or | ||
pnpm add @algolia/client-abtesting@5.9.0 | ||
pnpm add @algolia/client-abtesting@5.9.1 | ||
``` | ||
@@ -57,3 +57,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-abtesting@5.9.0/dist/builds/browser.umd.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-abtesting@5.9.1/dist/builds/browser.umd.js"></script> | ||
``` | ||
@@ -60,0 +60,0 @@ |
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
+ Added@algolia/client-common@5.9.1(transitive)
+ Added@algolia/requester-browser-xhr@5.9.1(transitive)
+ Added@algolia/requester-fetch@5.9.1(transitive)
+ Added@algolia/requester-node-http@5.9.1(transitive)
- Removed@algolia/client-common@5.9.0(transitive)
- Removed@algolia/requester-browser-xhr@5.9.0(transitive)
- Removed@algolia/requester-fetch@5.9.0(transitive)
- Removed@algolia/requester-node-http@5.9.0(transitive)
Updated@algolia/client-common@5.9.1