Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@algolia/client-personalization

Package Overview
Dependencies
Maintainers
87
Versions
198
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/client-personalization - npm Package Compare versions

Comparing version 5.14.2 to 5.15.0

2

dist/browser.d.ts

@@ -167,3 +167,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.14.2";
declare const apiClientVersion = "5.15.0";
declare const REGIONS: readonly ["eu", "us"];

@@ -170,0 +170,0 @@ type Region = (typeof REGIONS)[number];

@@ -15,3 +15,3 @@ // builds/browser.ts

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.14.2";
var apiClientVersion = "5.15.0";
var REGIONS = ["eu", "us"];

@@ -18,0 +18,0 @@ function getDefaultHosts(region) {

@@ -1,2 +0,2 @@

function L(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>t.setRequestHeader(n,e.headers[n]));let a=(n,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},n),m=a(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(m),h=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(m),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function $(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function m(n){t().setItem(o,JSON.stringify(n))}function h(){let n=r.timeToLive?r.timeToLive*1e3:null,s=a(),i=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(i),!n)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let P=new Date().getTime();return!(d.timestamp+n<P)}));m(u)}return{get(n,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),a()[JSON.stringify(n)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(n,s){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(n)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(n){return Promise.resolve().then(()=>{let s=a();delete s[JSON.stringify(n)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,m={miss:()=>Promise.resolve()}){return o.get(t,a,m).catch(()=>w({caches:e}).get(t,a,m))},set(t,a){return o.set(t,a).catch(()=>w({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>w({caches:e}).delete(t))},clear(){return o.clear().catch(()=>w({caches:e}).clear())}}}function S(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let h=t();return h.then(n=>a.miss(n)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var j=1e3,G=2e3,J=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function M(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function Q({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function F(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function W(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function a(){return e==="timed out"&&Date.now()-o<=H}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},x=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends x{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function ae(r,e,o){let t=ne(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(m=>{let h=t[m];a[m.toLowerCase()]=h}),a}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new x(t.message,e,o)}catch{}return new x(r,e,o)}function me({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return~~(r/100)===2}function he(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:m,timeouts:h,requester:n,requestsCache:s,responsesCache:i}){async function u(c){let l=await Promise.all(c.map(p=>e.get(p,()=>Promise.resolve(W(p))))),g=l.filter(p=>p.isUp()),y=l.filter(p=>p.isTimedOut()),q=[...g,...y];return{hosts:q.length>0?q:c,getTimeout(p,E){return(y.length===0&&p===0?1:y.length+3+p)*E}}}async function d(c,l,g=!0){let y=[],q=ie(c,l),T=ce(o,c.headers,l.headers),p=c.method==="GET"?{...c.data,...l.data}:{},E={...a,...c.queryParameters,...p};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?E[f]=l.queryParameters[f]:E[f]=l.queryParameters[f].toString();let v=0,D=async(f,C)=>{let O=f.pop();if(O===void 0)throw new te(he(y));let b={...h,...l.timeouts},N={data:q,headers:T,method:c.method,url:ae(O,c.path,E),connectTimeout:C(v,b.connect),responseTimeout:C(v,g?b.read:b.write)},k=U=>{let I={request:N,response:U,host:O,triesLeft:f.length};return y.push(I),I},R=await n.send(N);if(de(R)){let U=k(R);return R.isTimedOut&&v++,t.info("Retryable failure",K(U)),await e.set(O,W(O,R.isTimedOut?"timed out":"down")),D(f,C)}if(pe(R))return ue(R);throw k(R),le(R,y)},Z=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),_=await u(Z);return D([..._.hosts].reverse(),_.getTimeout)}function P(c,l={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return d(c,l,g);let y=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return y();let T={request:c,requestOptions:l,transporter:{queryParameters:a,headers:o}};return i.get(T,()=>s.get(T,()=>s.set(T,y()).then(p=>Promise.all([s.delete(T),p]),p=>Promise.all([s.delete(T),Promise.reject(p)])).then(([p,E])=>E)),{miss:p=>i.set(T,p)})}return{hostsCache:e,requester:n,timeouts:h,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:a,hosts:r,request:P,requestsCache:s,responsesCache:i}}var A="5.14.2",z=["eu","us"];function fe(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...m}){let h=M(r,e,o),n=V({hosts:fe(a),...m,algoliaAgent:Q({algoliaAgents:t,client:"Personalization",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...m.baseHeaders},baseQueryParameters:{...h.queryParameters(),...m.baseQueryParameters}});return{transporter:n,appId:r,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(s,i){n.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=s:n.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customPost({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},customPut({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},getPersonalizationStrategy(s){let P={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return n.request(P,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!s.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!s.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let c={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:s};return n.request(c,i)}}}function He(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!z.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${z.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:j,read:G,write:J},logger:F(),requester:L(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:S(),requestsCache:S({serializable:!1}),hostsCache:w({caches:[$({key:`${A}-${r}`}),S()]}),...t})}export{A as apiClientVersion,He as personalizationClient};
function L(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>t.setRequestHeader(n,e.headers[n]));let a=(n,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},n),m=a(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(m),h=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(m),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function $(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function m(n){t().setItem(o,JSON.stringify(n))}function h(){let n=r.timeToLive?r.timeToLive*1e3:null,s=a(),i=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(i),!n)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let P=new Date().getTime();return!(d.timestamp+n<P)}));m(u)}return{get(n,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),a()[JSON.stringify(n)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(n,s){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(n)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(n){return Promise.resolve().then(()=>{let s=a();delete s[JSON.stringify(n)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,m={miss:()=>Promise.resolve()}){return o.get(t,a,m).catch(()=>w({caches:e}).get(t,a,m))},set(t,a){return o.set(t,a).catch(()=>w({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>w({caches:e}).delete(t))},clear(){return o.clear().catch(()=>w({caches:e}).clear())}}}function S(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let h=t();return h.then(n=>a.miss(n)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var j=1e3,G=2e3,J=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function M(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function Q({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function F(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function W(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function a(){return e==="timed out"&&Date.now()-o<=H}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},x=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends x{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function ae(r,e,o){let t=ne(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(m=>{let h=t[m];a[m.toLowerCase()]=h}),a}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new x(t.message,e,o)}catch{}return new x(r,e,o)}function me({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return~~(r/100)===2}function he(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:m,timeouts:h,requester:n,requestsCache:s,responsesCache:i}){async function u(c){let l=await Promise.all(c.map(p=>e.get(p,()=>Promise.resolve(W(p))))),g=l.filter(p=>p.isUp()),y=l.filter(p=>p.isTimedOut()),q=[...g,...y];return{hosts:q.length>0?q:c,getTimeout(p,E){return(y.length===0&&p===0?1:y.length+3+p)*E}}}async function d(c,l,g=!0){let y=[],q=ie(c,l),T=ce(o,c.headers,l.headers),p=c.method==="GET"?{...c.data,...l.data}:{},E={...a,...c.queryParameters,...p};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?E[f]=l.queryParameters[f]:E[f]=l.queryParameters[f].toString();let v=0,D=async(f,C)=>{let O=f.pop();if(O===void 0)throw new te(he(y));let b={...h,...l.timeouts},N={data:q,headers:T,method:c.method,url:ae(O,c.path,E),connectTimeout:C(v,b.connect),responseTimeout:C(v,g?b.read:b.write)},k=U=>{let I={request:N,response:U,host:O,triesLeft:f.length};return y.push(I),I},R=await n.send(N);if(de(R)){let U=k(R);return R.isTimedOut&&v++,t.info("Retryable failure",K(U)),await e.set(O,W(O,R.isTimedOut?"timed out":"down")),D(f,C)}if(pe(R))return ue(R);throw k(R),le(R,y)},Z=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),_=await u(Z);return D([..._.hosts].reverse(),_.getTimeout)}function P(c,l={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return d(c,l,g);let y=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return y();let T={request:c,requestOptions:l,transporter:{queryParameters:a,headers:o}};return i.get(T,()=>s.get(T,()=>s.set(T,y()).then(p=>Promise.all([s.delete(T),p]),p=>Promise.all([s.delete(T),Promise.reject(p)])).then(([p,E])=>E)),{miss:p=>i.set(T,p)})}return{hostsCache:e,requester:n,timeouts:h,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:a,hosts:r,request:P,requestsCache:s,responsesCache:i}}var A="5.15.0",z=["eu","us"];function fe(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...m}){let h=M(r,e,o),n=V({hosts:fe(a),...m,algoliaAgent:Q({algoliaAgents:t,client:"Personalization",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...m.baseHeaders},baseQueryParameters:{...h.queryParameters(),...m.baseQueryParameters}});return{transporter:n,appId:r,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(s,i){n.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=s:n.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customPost({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},customPut({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},getPersonalizationStrategy(s){let P={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return n.request(P,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!s.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!s.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let c={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:s};return n.request(c,i)}}}function He(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!z.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${z.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:j,read:G,write:J},logger:F(),requester:L(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:S(),requestsCache:S({serializable:!1}),hostsCache:w({caches:[$({key:`${A}-${r}`}),S()]}),...t})}export{A as apiClientVersion,He as personalizationClient};
//# sourceMappingURL=browser.min.js.map

@@ -7,3 +7,3 @@ (function (global, factory) {

function L(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>t.setRequestHeader(n,e.headers[n]));let a=(n,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0});},n),m=a(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(m),h=a(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(m),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}function $(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function m(n){t().setItem(o,JSON.stringify(n));}function h(){let n=r.timeToLive?r.timeToLive*1e3:null,s=a(),i=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(i),!n)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let P=new Date().getTime();return !(d.timestamp+n<P)}));m(u);}return {get(n,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),a()[JSON.stringify(n)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(n,s){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(n)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(n){return Promise.resolve().then(()=>{let s=a();delete s[JSON.stringify(n)],t().setItem(o,JSON.stringify(s));})},clear(){return Promise.resolve().then(()=>{t().removeItem(o);})}}}function ee(){return {get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,m={miss:()=>Promise.resolve()}){return o.get(t,a,m).catch(()=>w({caches:e}).get(t,a,m))},set(t,a){return o.set(t,a).catch(()=>w({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>w({caches:e}).delete(t))},clear(){return o.clear().catch(()=>w({caches:e}).clear())}}}function S(r={serializable:!0}){let e={};return {get(o,t,a={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let h=t();return h.then(n=>a.miss(n)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var j=1e3,G=2e3,J=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function M(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function Q({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function F(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function W(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function a(){return e==="timed out"&&Date.now()-o<=H}return {...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e;}},te=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError");}},x=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e;}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends x{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o;}};function ae(r,e,o){let t=ne(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(m=>{let h=t[m];a[m.toLowerCase()]=h;}),a}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,o):new x(t.message,e,o)}catch{}return new x(r,e,o)}function me({isTimedOut:r,status:e}){return !r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return ~~(r/100)===2}function he(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:m,timeouts:h,requester:n,requestsCache:s,responsesCache:i}){async function u(c){let l=await Promise.all(c.map(p=>e.get(p,()=>Promise.resolve(W(p))))),g=l.filter(p=>p.isUp()),y=l.filter(p=>p.isTimedOut()),q=[...g,...y];return {hosts:q.length>0?q:c,getTimeout(p,E){return (y.length===0&&p===0?1:y.length+3+p)*E}}}async function d(c,l,g=!0){let y=[],q=ie(c,l),T=ce(o,c.headers,l.headers),p=c.method==="GET"?{...c.data,...l.data}:{},E={...a,...c.queryParameters,...p};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?E[f]=l.queryParameters[f]:E[f]=l.queryParameters[f].toString();let v=0,D=async(f,C)=>{let O=f.pop();if(O===void 0)throw new te(he(y));let b={...h,...l.timeouts},N={data:q,headers:T,method:c.method,url:ae(O,c.path,E),connectTimeout:C(v,b.connect),responseTimeout:C(v,g?b.read:b.write)},k=U=>{let I={request:N,response:U,host:O,triesLeft:f.length};return y.push(I),I},R=await n.send(N);if(de(R)){let U=k(R);return R.isTimedOut&&v++,t.info("Retryable failure",K(U)),await e.set(O,W(O,R.isTimedOut?"timed out":"down")),D(f,C)}if(pe(R))return ue(R);throw k(R),le(R,y)},Z=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),_=await u(Z);return D([..._.hosts].reverse(),_.getTimeout)}function P(c,l={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return d(c,l,g);let y=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return y();let T={request:c,requestOptions:l,transporter:{queryParameters:a,headers:o}};return i.get(T,()=>s.get(T,()=>s.set(T,y()).then(p=>Promise.all([s.delete(T),p]),p=>Promise.all([s.delete(T),Promise.reject(p)])).then(([p,E])=>E)),{miss:p=>i.set(T,p)})}return {hostsCache:e,requester:n,timeouts:h,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:a,hosts:r,request:P,requestsCache:s,responsesCache:i}}var A="5.14.2",z=["eu","us"];function fe(r){return [{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...m}){let h=M(r,e,o),n=V({hosts:fe(a),...m,algoliaAgent:Q({algoliaAgents:t,client:"Personalization",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...m.baseHeaders},baseQueryParameters:{...h.queryParameters(),...m.baseQueryParameters}});return {transporter:n,appId:r,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(s,i){n.algoliaAgent.add({segment:s,version:i});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=s:n.baseQueryParameters["x-algolia-api-key"]=s;},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customPost({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},customPut({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},getPersonalizationStrategy(s){let P={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return n.request(P,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!s.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!s.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let c={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:s};return n.request(c,i)}}}function He(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!z.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${z.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:j,read:G,write:J},logger:F(),requester:L(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:S(),requestsCache:S({serializable:!1}),hostsCache:w({caches:[$({key:`${A}-${r}`}),S()]}),...t})}
function L(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>t.setRequestHeader(n,e.headers[n]));let a=(n,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0});},n),m=a(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(m),h=a(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(m),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}function $(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function m(n){t().setItem(o,JSON.stringify(n));}function h(){let n=r.timeToLive?r.timeToLive*1e3:null,s=a(),i=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(i),!n)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let P=new Date().getTime();return !(d.timestamp+n<P)}));m(u);}return {get(n,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),a()[JSON.stringify(n)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(n,s){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(n)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(n){return Promise.resolve().then(()=>{let s=a();delete s[JSON.stringify(n)],t().setItem(o,JSON.stringify(s));})},clear(){return Promise.resolve().then(()=>{t().removeItem(o);})}}}function ee(){return {get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,m={miss:()=>Promise.resolve()}){return o.get(t,a,m).catch(()=>w({caches:e}).get(t,a,m))},set(t,a){return o.set(t,a).catch(()=>w({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>w({caches:e}).delete(t))},clear(){return o.clear().catch(()=>w({caches:e}).clear())}}}function S(r={serializable:!0}){let e={};return {get(o,t,a={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let h=t();return h.then(n=>a.miss(n)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var j=1e3,G=2e3,J=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function M(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function Q({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function F(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function W(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function a(){return e==="timed out"&&Date.now()-o<=H}return {...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e;}},te=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError");}},x=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e;}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends x{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o;}};function ae(r,e,o){let t=ne(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(m=>{let h=t[m];a[m.toLowerCase()]=h;}),a}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,o):new x(t.message,e,o)}catch{}return new x(r,e,o)}function me({isTimedOut:r,status:e}){return !r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return ~~(r/100)===2}function he(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:m,timeouts:h,requester:n,requestsCache:s,responsesCache:i}){async function u(c){let l=await Promise.all(c.map(p=>e.get(p,()=>Promise.resolve(W(p))))),g=l.filter(p=>p.isUp()),y=l.filter(p=>p.isTimedOut()),q=[...g,...y];return {hosts:q.length>0?q:c,getTimeout(p,E){return (y.length===0&&p===0?1:y.length+3+p)*E}}}async function d(c,l,g=!0){let y=[],q=ie(c,l),T=ce(o,c.headers,l.headers),p=c.method==="GET"?{...c.data,...l.data}:{},E={...a,...c.queryParameters,...p};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?E[f]=l.queryParameters[f]:E[f]=l.queryParameters[f].toString();let v=0,D=async(f,C)=>{let O=f.pop();if(O===void 0)throw new te(he(y));let b={...h,...l.timeouts},N={data:q,headers:T,method:c.method,url:ae(O,c.path,E),connectTimeout:C(v,b.connect),responseTimeout:C(v,g?b.read:b.write)},k=U=>{let I={request:N,response:U,host:O,triesLeft:f.length};return y.push(I),I},R=await n.send(N);if(de(R)){let U=k(R);return R.isTimedOut&&v++,t.info("Retryable failure",K(U)),await e.set(O,W(O,R.isTimedOut?"timed out":"down")),D(f,C)}if(pe(R))return ue(R);throw k(R),le(R,y)},Z=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),_=await u(Z);return D([..._.hosts].reverse(),_.getTimeout)}function P(c,l={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return d(c,l,g);let y=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return y();let T={request:c,requestOptions:l,transporter:{queryParameters:a,headers:o}};return i.get(T,()=>s.get(T,()=>s.set(T,y()).then(p=>Promise.all([s.delete(T),p]),p=>Promise.all([s.delete(T),Promise.reject(p)])).then(([p,E])=>E)),{miss:p=>i.set(T,p)})}return {hostsCache:e,requester:n,timeouts:h,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:a,hosts:r,request:P,requestsCache:s,responsesCache:i}}var A="5.15.0",z=["eu","us"];function fe(r){return [{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...m}){let h=M(r,e,o),n=V({hosts:fe(a),...m,algoliaAgent:Q({algoliaAgents:t,client:"Personalization",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...m.baseHeaders},baseQueryParameters:{...h.queryParameters(),...m.baseQueryParameters}});return {transporter:n,appId:r,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(s,i){n.algoliaAgent.add({segment:s,version:i});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=s:n.baseQueryParameters["x-algolia-api-key"]=s;},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customPost({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},customPut({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},getPersonalizationStrategy(s){let P={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return n.request(P,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!s.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!s.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let c={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:s};return n.request(c,i)}}}function He(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!z.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${z.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:j,read:G,write:J},logger:F(),requester:L(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:S(),requestsCache:S({serializable:!1}),hostsCache:w({caches:[$({key:`${A}-${r}`}),S()]}),...t})}

@@ -10,0 +10,0 @@ exports.apiClientVersion = A;

@@ -14,3 +14,3 @@ // builds/fetch.ts

import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.14.2";
var apiClientVersion = "5.15.0";
var REGIONS = ["eu", "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.14.2";
var apiClientVersion = "5.15.0";
var REGIONS = ["eu", "us"];

@@ -17,0 +17,0 @@ function getDefaultHosts(region) {

@@ -167,3 +167,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.14.2";
declare const apiClientVersion = "5.15.0";
declare const REGIONS: readonly ["eu", "us"];

@@ -170,0 +170,0 @@ type Region = (typeof REGIONS)[number];

@@ -167,3 +167,3 @@ import * as _algolia_client_common from '@algolia/client-common';

declare const apiClientVersion = "5.14.2";
declare const apiClientVersion = "5.15.0";
declare const REGIONS: readonly ["eu", "us"];

@@ -170,0 +170,0 @@ type Region = (typeof REGIONS)[number];

// src/personalizationClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.14.2";
var apiClientVersion = "5.15.0";
var REGIONS = ["eu", "us"];

@@ -5,0 +5,0 @@ function getDefaultHosts(region) {

{
"version": "5.14.2",
"version": "5.15.0",
"repository": {

@@ -51,6 +51,6 @@ "type": "git",

"dependencies": {
"@algolia/client-common": "5.14.2",
"@algolia/requester-browser-xhr": "5.14.2",
"@algolia/requester-fetch": "5.14.2",
"@algolia/requester-node-http": "5.14.2"
"@algolia/client-common": "5.15.0",
"@algolia/requester-browser-xhr": "5.15.0",
"@algolia/requester-fetch": "5.15.0",
"@algolia/requester-node-http": "5.15.0"
},

@@ -61,3 +61,3 @@ "devDependencies": {

"publint": "0.2.12",
"rollup": "4.25.0",
"rollup": "4.27.2",
"tsup": "8.3.5",

@@ -64,0 +64,0 @@ "typescript": "5.6.3"

@@ -44,7 +44,7 @@ <p align="center">

```bash
yarn add @algolia/client-personalization@5.14.2
yarn add @algolia/client-personalization@5.15.0
# or
npm install @algolia/client-personalization@5.14.2
npm install @algolia/client-personalization@5.15.0
# or
pnpm add @algolia/client-personalization@5.14.2
pnpm add @algolia/client-personalization@5.15.0
```

@@ -57,3 +57,3 @@

```html
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.14.2/dist/builds/browser.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.15.0/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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc