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

@algolia/client-personalization

Package Overview
Dependencies
Maintainers
86
Versions
194
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.5.0 to 5.5.1

2

dist/browser.d.ts

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

declare const apiClientVersion = "5.5.0";
declare const apiClientVersion = "5.5.1";
declare const REGIONS: readonly ["eu", "us"];

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

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

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

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

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

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

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

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

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

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

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

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

@@ -13,3 +13,3 @@ // builds/node.ts

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

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

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

declare const apiClientVersion = "5.5.0";
declare const apiClientVersion = "5.5.1";
declare const REGIONS: readonly ["eu", "us"];

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

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

declare const apiClientVersion = "5.5.0";
declare const apiClientVersion = "5.5.1";
declare const REGIONS: readonly ["eu", "us"];

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

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

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

{
"version": "5.5.0",
"version": "5.5.1",
"repository": {

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

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

@@ -58,0 +58,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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