Socket
Socket
Sign inDemoInstall

@algolia/client-personalization

Package Overview
Dependencies
Maintainers
86
Versions
180
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.2.5 to 5.3.0

284

dist/browser.d.ts
import * as _algolia_client_common from '@algolia/client-common';
import { ClientOptions } from '@algolia/client-common';
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
/**
* Path of the endpoint, anything after \"/1\" must be specified.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: Record<string, any>;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
/**
* Path of the endpoint, anything after \"/1\" must be specified.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: Record<string, any>;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
/**
* Path of the endpoint, anything after \"/1\" must be specified.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: Record<string, any>;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown>;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
/**
* Path of the endpoint, anything after \"/1\" must be specified.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: Record<string, any>;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown>;
};
/**
* Properties for the `deleteUserProfile` method.
*/
type DeleteUserProfileProps = {
/**
* Unique identifier representing a user for which to fetch the personalization profile.
*/
userToken: string;
};
/**
* Properties for the `getUserTokenProfile` method.
*/
type GetUserTokenProfileProps = {
/**
* Unique identifier representing a user for which to fetch the personalization profile.
*/
userToken: string;
};
type DeleteUserProfileResponse = {

@@ -15,7 +94,15 @@ /**

/**
* Error.
*/
type ErrorBase = Record<string, any> & {
message?: string;
type GetUserTokenResponse = {
/**
* Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
*/
userToken: string;
/**
* Date and time of the last event from this user, in RFC 3339 format.
*/
lastEventAt: string;
/**
* Scores for different facet values. Scores represent the user affinity for a user profile towards specific facet values, given the personalization strategy and past events.
*/
scores: Record<string, unknown>;
};

@@ -51,17 +138,2 @@

type GetUserTokenResponse = {
/**
* Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
*/
userToken: string;
/**
* Date and time of the last event from this user, in RFC 3339 format.
*/
lastEventAt: string;
/**
* Scores for different facet values. Scores represent the user affinity for a user profile towards specific facet values, given the personalization strategy and past events.
*/
scores: Record<string, unknown>;
};
type PersonalizationStrategyParams = {

@@ -89,105 +161,129 @@ /**

/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
declare const apiClientVersion = "5.3.0";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
region: Region;
}): {
transporter: _algolia_client_common.Transporter;
/**
* Path of the endpoint, anything after \"/1\" must be specified.
* The `appId` currently in use.
*/
path: string;
appId: string;
/**
* Query parameters to apply to the current query.
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
*/
parameters?: Record<string, any>;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
clearCache(): Promise<void>;
/**
* Path of the endpoint, anything after \"/1\" must be specified.
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
path: string;
readonly _ua: string;
/**
* Query parameters to apply to the current query.
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
*
* @param segment - The algolia agent (user-agent) segment to add.
* @param version - The version of the agent.
*/
parameters?: Record<string, any>;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
addAlgoliaAgent(segment: string, version?: string): void;
/**
* Path of the endpoint, anything after \"/1\" must be specified.
* Helper method to switch the API key used to authenticate the requests.
*
* @param params - Method params.
* @param params.apiKey - The new API Key to use.
*/
path: string;
setClientApiKey({ apiKey }: {
apiKey: string;
}): void;
/**
* Query parameters to apply to the current query.
* This method allow you to send requests to the Algolia REST API.
*
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
parameters?: Record<string, any>;
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Parameters to send with the custom request.
* This method allow you to send requests to the Algolia REST API.
*
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
body?: Record<string, unknown>;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Path of the endpoint, anything after \"/1\" must be specified.
* This method allow you to send requests to the Algolia REST API.
*
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
path: string;
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Query parameters to apply to the current query.
* This method allow you to send requests to the Algolia REST API.
*
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
parameters?: Record<string, any>;
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Parameters to send with the custom request.
* Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
*
* Required API Key ACLs:
* - recommendation.
*
* @param deleteUserProfile - The deleteUserProfile object.
* @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
body?: Record<string, unknown>;
};
/**
* Properties for the `deleteUserProfile` method.
*/
type DeleteUserProfileProps = {
deleteUserProfile({ userToken }: DeleteUserProfileProps, requestOptions?: RequestOptions): Promise<DeleteUserProfileResponse>;
/**
* Unique identifier representing a user for which to fetch the personalization profile.
* Retrieves the current personalization strategy.
*
* Required API Key ACLs:
* - recommendation.
*
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
userToken: string;
};
/**
* Properties for the `getUserTokenProfile` method.
*/
type GetUserTokenProfileProps = {
getPersonalizationStrategy(requestOptions?: RequestOptions): Promise<PersonalizationStrategyParams>;
/**
* Unique identifier representing a user for which to fetch the personalization profile.
* Retrieves a user profile and their affinities for different facets.
*
* Required API Key ACLs:
* - recommendation.
*
* @param getUserTokenProfile - The getUserTokenProfile object.
* @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
userToken: string;
getUserTokenProfile({ userToken }: GetUserTokenProfileProps, requestOptions?: RequestOptions): Promise<GetUserTokenResponse>;
/**
* Creates a new personalization strategy.
*
* Required API Key ACLs:
* - recommendation.
*
* @param personalizationStrategyParams - The personalizationStrategyParams object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
setPersonalizationStrategy(personalizationStrategyParams: PersonalizationStrategyParams, requestOptions?: RequestOptions): Promise<SetPersonalizationStrategyResponse>;
};
declare const apiClientVersion = "5.2.5";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
/**
* The client type.
* Error.
*/
type PersonalizationClient = ReturnType<typeof personalizationClient>;
declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): {
transporter: _algolia_client_common.Transporter;
appId: string;
clearCache(): Promise<void>;
readonly _ua: string;
addAlgoliaAgent(segment: string, version?: string): void;
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
deleteUserProfile({ userToken }: DeleteUserProfileProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<DeleteUserProfileResponse>;
getPersonalizationStrategy(requestOptions?: _algolia_client_common.RequestOptions): Promise<PersonalizationStrategyParams>;
getUserTokenProfile({ userToken }: GetUserTokenProfileProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<GetUserTokenResponse>;
setPersonalizationStrategy(personalizationStrategyParams: PersonalizationStrategyParams, requestOptions?: _algolia_client_common.RequestOptions): Promise<SetPersonalizationStrategyResponse>;
type ErrorBase = Record<string, any> & {
message?: string;
};
type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;
declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): PersonalizationClient;
export { type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserProfileProps, type DeleteUserProfileResponse, type ErrorBase, type EventScoring, type EventType, type FacetScoring, type GetUserTokenProfileProps, type GetUserTokenResponse, type PersonalizationClient, type PersonalizationStrategyParams, type Region, type SetPersonalizationStrategyResponse, apiClientVersion, personalizationClient };

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

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

@@ -30,22 +30,21 @@ function getDefaultHosts(region) {

const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "Personalization",
version: apiClientVersion
return {
transporter: createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "Personalization",
version: apiClientVersion
}),
baseHeaders: {
"content-type": "text/plain",
...auth.headers(),
...options.baseHeaders
},
baseQueryParameters: {
...auth.queryParameters(),
...options.baseQueryParameters
}
}),
baseHeaders: {
"content-type": "text/plain",
...auth.headers(),
...options.baseHeaders
},
baseQueryParameters: {
...auth.queryParameters(),
...options.baseQueryParameters
}
});
return {
transporter,
/**

@@ -59,3 +58,5 @@ * The `appId` currently in use.

clearCache() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
() => void 0
);
},

@@ -66,3 +67,3 @@ /**

get _ua() {
return transporter.algoliaAgent.value;
return this.transporter.algoliaAgent.value;
},

@@ -76,5 +77,14 @@ /**

addAlgoliaAgent(segment, version) {
transporter.algoliaAgent.add({ segment, version });
this.transporter.algoliaAgent.add({ segment, version });
},
/**
* Helper method to switch the API key used to authenticate the requests.
*
* @param params - Method params.
* @param params.apiKey - The new API Key to use.
*/
setClientApiKey({ apiKey }) {
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
},
/**
* This method allow you to send requests to the Algolia REST API.

@@ -100,3 +110,3 @@ *

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -124,3 +134,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -150,3 +160,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -176,3 +186,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -202,3 +212,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -223,3 +233,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -252,3 +262,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -295,3 +305,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
}

@@ -298,0 +308,0 @@ };

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

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

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

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

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

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

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

@@ -29,22 +29,21 @@ function getDefaultHosts(region) {

const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "Personalization",
version: apiClientVersion
return {
transporter: createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "Personalization",
version: apiClientVersion
}),
baseHeaders: {
"content-type": "text/plain",
...auth.headers(),
...options.baseHeaders
},
baseQueryParameters: {
...auth.queryParameters(),
...options.baseQueryParameters
}
}),
baseHeaders: {
"content-type": "text/plain",
...auth.headers(),
...options.baseHeaders
},
baseQueryParameters: {
...auth.queryParameters(),
...options.baseQueryParameters
}
});
return {
transporter,
/**

@@ -58,3 +57,5 @@ * The `appId` currently in use.

clearCache() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
() => void 0
);
},

@@ -65,3 +66,3 @@ /**

get _ua() {
return transporter.algoliaAgent.value;
return this.transporter.algoliaAgent.value;
},

@@ -75,5 +76,14 @@ /**

addAlgoliaAgent(segment, version) {
transporter.algoliaAgent.add({ segment, version });
this.transporter.algoliaAgent.add({ segment, version });
},
/**
* Helper method to switch the API key used to authenticate the requests.
*
* @param params - Method params.
* @param params.apiKey - The new API Key to use.
*/
setClientApiKey({ apiKey }) {
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
},
/**
* This method allow you to send requests to the Algolia REST API.

@@ -99,3 +109,3 @@ *

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -123,3 +133,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -149,3 +159,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -175,3 +185,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -201,3 +211,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -222,3 +232,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -251,3 +261,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -294,3 +304,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
}

@@ -297,0 +307,0 @@ };

import * as _algolia_client_common from '@algolia/client-common';
import { ClientOptions } from '@algolia/client-common';
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
/**
* Path of the endpoint, anything after \"/1\" must be specified.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: Record<string, any>;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
/**
* Path of the endpoint, anything after \"/1\" must be specified.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: Record<string, any>;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
/**
* Path of the endpoint, anything after \"/1\" must be specified.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: Record<string, any>;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown>;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
/**
* Path of the endpoint, anything after \"/1\" must be specified.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: Record<string, any>;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown>;
};
/**
* Properties for the `deleteUserProfile` method.
*/
type DeleteUserProfileProps = {
/**
* Unique identifier representing a user for which to fetch the personalization profile.
*/
userToken: string;
};
/**
* Properties for the `getUserTokenProfile` method.
*/
type GetUserTokenProfileProps = {
/**
* Unique identifier representing a user for which to fetch the personalization profile.
*/
userToken: string;
};
type DeleteUserProfileResponse = {

@@ -15,7 +94,15 @@ /**

/**
* Error.
*/
type ErrorBase = Record<string, any> & {
message?: string;
type GetUserTokenResponse = {
/**
* Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
*/
userToken: string;
/**
* Date and time of the last event from this user, in RFC 3339 format.
*/
lastEventAt: string;
/**
* Scores for different facet values. Scores represent the user affinity for a user profile towards specific facet values, given the personalization strategy and past events.
*/
scores: Record<string, unknown>;
};

@@ -51,17 +138,2 @@

type GetUserTokenResponse = {
/**
* Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
*/
userToken: string;
/**
* Date and time of the last event from this user, in RFC 3339 format.
*/
lastEventAt: string;
/**
* Scores for different facet values. Scores represent the user affinity for a user profile towards specific facet values, given the personalization strategy and past events.
*/
scores: Record<string, unknown>;
};
type PersonalizationStrategyParams = {

@@ -89,105 +161,129 @@ /**

/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
declare const apiClientVersion = "5.3.0";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
region: Region;
}): {
transporter: _algolia_client_common.Transporter;
/**
* Path of the endpoint, anything after \"/1\" must be specified.
* The `appId` currently in use.
*/
path: string;
appId: string;
/**
* Query parameters to apply to the current query.
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
*/
parameters?: Record<string, any>;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
clearCache(): Promise<void>;
/**
* Path of the endpoint, anything after \"/1\" must be specified.
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
path: string;
readonly _ua: string;
/**
* Query parameters to apply to the current query.
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
*
* @param segment - The algolia agent (user-agent) segment to add.
* @param version - The version of the agent.
*/
parameters?: Record<string, any>;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
addAlgoliaAgent(segment: string, version?: string): void;
/**
* Path of the endpoint, anything after \"/1\" must be specified.
* Helper method to switch the API key used to authenticate the requests.
*
* @param params - Method params.
* @param params.apiKey - The new API Key to use.
*/
path: string;
setClientApiKey({ apiKey }: {
apiKey: string;
}): void;
/**
* Query parameters to apply to the current query.
* This method allow you to send requests to the Algolia REST API.
*
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
parameters?: Record<string, any>;
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Parameters to send with the custom request.
* This method allow you to send requests to the Algolia REST API.
*
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
body?: Record<string, unknown>;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Path of the endpoint, anything after \"/1\" must be specified.
* This method allow you to send requests to the Algolia REST API.
*
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
path: string;
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Query parameters to apply to the current query.
* This method allow you to send requests to the Algolia REST API.
*
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
parameters?: Record<string, any>;
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Parameters to send with the custom request.
* Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
*
* Required API Key ACLs:
* - recommendation.
*
* @param deleteUserProfile - The deleteUserProfile object.
* @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
body?: Record<string, unknown>;
};
/**
* Properties for the `deleteUserProfile` method.
*/
type DeleteUserProfileProps = {
deleteUserProfile({ userToken }: DeleteUserProfileProps, requestOptions?: RequestOptions): Promise<DeleteUserProfileResponse>;
/**
* Unique identifier representing a user for which to fetch the personalization profile.
* Retrieves the current personalization strategy.
*
* Required API Key ACLs:
* - recommendation.
*
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
userToken: string;
};
/**
* Properties for the `getUserTokenProfile` method.
*/
type GetUserTokenProfileProps = {
getPersonalizationStrategy(requestOptions?: RequestOptions): Promise<PersonalizationStrategyParams>;
/**
* Unique identifier representing a user for which to fetch the personalization profile.
* Retrieves a user profile and their affinities for different facets.
*
* Required API Key ACLs:
* - recommendation.
*
* @param getUserTokenProfile - The getUserTokenProfile object.
* @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
userToken: string;
getUserTokenProfile({ userToken }: GetUserTokenProfileProps, requestOptions?: RequestOptions): Promise<GetUserTokenResponse>;
/**
* Creates a new personalization strategy.
*
* Required API Key ACLs:
* - recommendation.
*
* @param personalizationStrategyParams - The personalizationStrategyParams object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
setPersonalizationStrategy(personalizationStrategyParams: PersonalizationStrategyParams, requestOptions?: RequestOptions): Promise<SetPersonalizationStrategyResponse>;
};
declare const apiClientVersion = "5.2.5";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
/**
* The client type.
* Error.
*/
type PersonalizationClient = ReturnType<typeof personalizationClient>;
declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): {
transporter: _algolia_client_common.Transporter;
appId: string;
clearCache(): Promise<void>;
_ua: string;
addAlgoliaAgent(segment: string, version?: string): void;
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
deleteUserProfile({ userToken }: DeleteUserProfileProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<DeleteUserProfileResponse>;
getPersonalizationStrategy(requestOptions?: _algolia_client_common.RequestOptions): Promise<PersonalizationStrategyParams>;
getUserTokenProfile({ userToken }: GetUserTokenProfileProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<GetUserTokenResponse>;
setPersonalizationStrategy(personalizationStrategyParams: PersonalizationStrategyParams, requestOptions?: _algolia_client_common.RequestOptions): Promise<SetPersonalizationStrategyResponse>;
type ErrorBase = Record<string, any> & {
message?: string;
};
type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;
declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): PersonalizationClient;
export { type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserProfileProps, type DeleteUserProfileResponse, type ErrorBase, type EventScoring, type EventType, type FacetScoring, type GetUserTokenProfileProps, type GetUserTokenResponse, type PersonalizationClient, type PersonalizationStrategyParams, type Region, type SetPersonalizationStrategyResponse, apiClientVersion, personalizationClient };
// src/personalizationClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.2.5";
var apiClientVersion = "5.3.0";
var REGIONS = ["eu", "us"];

@@ -18,22 +18,21 @@ function getDefaultHosts(region) {

const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "Personalization",
version: apiClientVersion
return {
transporter: createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "Personalization",
version: apiClientVersion
}),
baseHeaders: {
"content-type": "text/plain",
...auth.headers(),
...options.baseHeaders
},
baseQueryParameters: {
...auth.queryParameters(),
...options.baseQueryParameters
}
}),
baseHeaders: {
"content-type": "text/plain",
...auth.headers(),
...options.baseHeaders
},
baseQueryParameters: {
...auth.queryParameters(),
...options.baseQueryParameters
}
});
return {
transporter,
/**

@@ -47,3 +46,5 @@ * The `appId` currently in use.

clearCache() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(
() => void 0
);
},

@@ -54,3 +55,3 @@ /**

get _ua() {
return transporter.algoliaAgent.value;
return this.transporter.algoliaAgent.value;
},

@@ -64,5 +65,14 @@ /**

addAlgoliaAgent(segment, version) {
transporter.algoliaAgent.add({ segment, version });
this.transporter.algoliaAgent.add({ segment, version });
},
/**
* Helper method to switch the API key used to authenticate the requests.
*
* @param params - Method params.
* @param params.apiKey - The new API Key to use.
*/
setClientApiKey({ apiKey }) {
this.transporter.baseHeaders["x-algolia-api-key"] = apiKey;
},
/**
* This method allow you to send requests to the Algolia REST API.

@@ -88,3 +98,3 @@ *

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -112,3 +122,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -138,3 +148,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -164,3 +174,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -190,3 +200,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -211,3 +221,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -240,3 +250,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
},

@@ -283,3 +293,3 @@ /**

};
return transporter.request(request, requestOptions);
return this.transporter.request(request, requestOptions);
}

@@ -286,0 +296,0 @@ };

{
"version": "5.2.5",
"version": "5.3.0",
"repository": {

@@ -47,5 +47,5 @@ "type": "git",

"dependencies": {
"@algolia/client-common": "5.2.5",
"@algolia/requester-browser-xhr": "5.2.5",
"@algolia/requester-node-http": "5.2.5"
"@algolia/client-common": "5.3.0",
"@algolia/requester-browser-xhr": "5.3.0",
"@algolia/requester-node-http": "5.3.0"
},

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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