Socket
Socket
Sign inDemoInstall

@algolia/client-personalization

Package Overview
Dependencies
Maintainers
67
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.0.0-alpha.2 to 5.0.0-alpha.3

4

dist/builds/browser.d.ts

@@ -1,6 +0,6 @@

import type { InitClientOptions } from '@algolia/client-common';
import type { ClientOptions } from '@algolia/client-common';
import type { PersonalizationClient, Region } from '../src/personalizationClient';
export { apiClientVersion, PersonalizationClient, } from '../src/personalizationClient';
export * from '../model';
export declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: InitClientOptions): PersonalizationClient;
export declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): PersonalizationClient;
//# sourceMappingURL=browser.d.ts.map

@@ -1,6 +0,6 @@

import type { InitClientOptions } from '@algolia/client-common';
import type { ClientOptions } from '@algolia/client-common';
import type { PersonalizationClient, Region } from '../src/personalizationClient';
export { apiClientVersion, PersonalizationClient, } from '../src/personalizationClient';
export * from '../model';
export declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: InitClientOptions): PersonalizationClient;
export declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): PersonalizationClient;
//# sourceMappingURL=node.d.ts.map

@@ -9,3 +9,3 @@ 'use strict';

// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
const apiClientVersion = '5.0.0-alpha.2';
const apiClientVersion = '5.0.0-alpha.3';
const REGIONS = ['eu', 'us'];

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

@@ -713,3 +713,3 @@ function createAuth(appId, apiKey, authMode = 'WithinHeaders') {

// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
const apiClientVersion = '5.0.0-alpha.2';
const apiClientVersion = '5.0.0-alpha.3';
const REGIONS = ['eu', 'us'];

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

@@ -5,3 +5,3 @@ import { createAuth, createTransporter, getAlgoliaAgent, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_WRITE_TIMEOUT_NODE, createNullCache, createMemoryCache } from '@algolia/client-common';

// This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.
const apiClientVersion = '5.0.0-alpha.2';
const apiClientVersion = '5.0.0-alpha.3';
const REGIONS = ['eu', 'us'];

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

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

/*! client-personalization.umd.js | 5.0.0-alpha.2 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-personalization"]={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e){let t;const r=`algolia-client-js-${e.key}`;function a(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function n(){return JSON.parse(a().getItem(r)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),a=n()[r];return Promise.all([a||t(),void 0!==a])})).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const s=n();return s[JSON.stringify(e)]=t,a().setItem(r,JSON.stringify(s)),t})),delete:e=>Promise.resolve().then((()=>{const t=n();delete t[JSON.stringify(e)],a().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{a().removeItem(r)}))}}function a(e){const t=[...e.caches],r=t.shift();return void 0===r?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,n,s={miss:()=>Promise.resolve()})=>r.get(e,n,s).catch((()=>a({caches:t}).get(e,n,s))),set:(e,n)=>r.set(e,n).catch((()=>a({caches:t}).set(e,n))),delete:e=>r.delete(e).catch((()=>a({caches:t}).delete(e))),clear:()=>r.clear().catch((()=>a({caches:t}).clear()))}}function n(e={serializable:!0}){let t={};return{get(r,a,n={miss:()=>Promise.resolve()}){const s=JSON.stringify(r);if(s in t)return Promise.resolve(e.serializable?JSON.parse(t[s]):t[s]);const o=a();return o.then((e=>n.miss(e))).then((()=>o))},set:(r,a)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(a):a,Promise.resolve(a)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const s=12e4;function o(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>s},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=s}}}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class c extends Error{constructor(e,t){super(e),i(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends c{constructor(e,t,r){super(e,r),i(this,"stackTrace",void 0),this.stackTrace=t}}class l extends u{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class p extends u{constructor(e,t,r){super(e,r,"ApiError"),i(this,"status",void 0),this.status=t}}class h extends c{constructor(e,t){super(e,"DeserializationError"),i(this,"response",void 0),this.response=t}}function d(e,t,r){const a=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${t(e[r])?JSON.stringify(e[r]):e[r]}`)).join("&")}(r);let n=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return a.length&&(n+=`?${a}`),n}function m(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function f({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:a,algoliaAgent:n,timeouts:s,requester:i,requestsCache:c,responsesCache:u}){async function f(c,u,f=!0){const g=[],y=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(c,u),P=function(e,t,r){const a={Accept:"application/json",...e,...t,...r},n={};return Object.keys(a).forEach((e=>{const t=a[e];n[e.toLowerCase()]=t})),n}(r,c.headers,u.headers),O="GET"===c.method?{...c.data,...u.data}:{},b={"x-algolia-agent":n.value,...a,...c.queryParameters,...O};if(u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?b[e]=u.queryParameters[e].toString():b[e]=u.queryParameters[e];let w=0;const v=async(e,r)=>{const a=e.pop();if(void 0===a)throw new l(function(e){return e.map((e=>m(e)))}(g));let n=u.timeout;void 0===n&&(n=f?s.read:s.write);const O={data:y,headers:P,method:c.method,url:d(a,c.path,b),connectTimeout:r(w,s.connect),responseTimeout:r(w,n)},q=t=>{const r={request:O,response:t,host:a,triesLeft:e.length};return g.push(r),r},T=await i.send(O);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(T)){const n=q(T);return T.isTimedOut&&w++,console.log("Retryable failure",m(n)),await t.set(a,o(a,T.isTimedOut?"timed out":"down")),v(e,r)}if(function({status:e}){return 2==~~(e/100)}(T))return function(e){try{return JSON.parse(e.content)}catch(t){throw new h(t.message,e)}}(T);throw q(T),function({content:e,status:t},r){let a=e;try{a=JSON.parse(e).message}catch(e){}return new p(a,t,r)}(T,g)},q=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),T=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(o(e))))))),a=r.filter((e=>e.isUp())),n=r.filter((e=>e.isTimedOut())),s=[...a,...n];return{hosts:s.length>0?s:e,getTimeout:(e,t)=>(0===n.length&&0===e?1:n.length+3+e)*t}}(q);return v([...T.hosts].reverse(),T.getTimeout)}return{hostsCache:t,requester:i,timeouts:s,algoliaAgent:n,baseHeaders:r,baseQueryParameters:a,hosts:e,request:function(e,t={}){const n=e.useReadTransporter||"GET"===e.method;if(!n)return f(e,t,n);const s=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return s();const o={request:e,requestOptions:t,transporter:{queryParameters:a,headers:r}};return u.get(o,(()=>c.get(o,(()=>c.set(o,s()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>u.set(o,e)})},requestsCache:c,responsesCache:u}}function g({algoliaAgents:e,client:t,version:r}){const a=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>a.add(e))),a}function y(e,t){if(null==e)return{};var r,a,n=function(e,t){if(null==e)return{};var r,a,n={},s=Object.keys(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var P=["appId","apiKey","authMode","algoliaAgents","region"];function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function b(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?O(Object(a),!0).forEach((function(r){t(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):O(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}var w="5.0.0-alpha.2",v=["eu","us"];function q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}e.apiClientVersion=w,e.personalizationClient=function(e,s,o,i){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!s||"string"!=typeof s)throw new Error("`apiKey` is missing.");if(!o)throw new Error("`region` is missing.");if(o&&("string"!=typeof o||!v.includes(o)))throw new Error("`region` must be one of the following: ".concat(v.join(", ")));return function(e){var t,r=e.appId,a=e.apiKey,n=e.authMode,s=e.algoliaAgents,o=e.region,i=y(e,P),c=function(e,t,r="WithinHeaders"){const a={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?a:{},queryParameters:()=>"WithinQueryParameters"===r?a:{}}}(r,a,n),u=f(b(b({hosts:(t=o,[{url:"personalization.{region}.algolia.com".replace("{region}",t),accept:"readWrite",protocol:"https"}])},i),{},{algoliaAgent:g({algoliaAgents:s,client:"Personalization",version:w}),baseHeaders:b(b({"content-type":"text/plain"},c.headers()),i.baseHeaders),baseQueryParameters:b(b({},c.queryParameters()),i.baseQueryParameters)}));return{transporter:u,get _ua(){return u.algoliaAgent.value},addAlgoliaAgent:function(e,t){u.algoliaAgent.add({segment:e,version:t})},del:function(e,t){var r=e.path,a=e.parameters;if(!r)throw new Error("Parameter `path` is required when calling `del`.");var n={method:"DELETE",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{}};return u.request(n,t)},deleteUserProfile:function(e,t){var r=e.userToken;if(!r)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");var a={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(r)),queryParameters:{},headers:{}};return u.request(a,t)},get:function(e,t){var r=e.path,a=e.parameters;if(!r)throw new Error("Parameter `path` is required when calling `get`.");var n={method:"GET",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{}};return u.request(n,t)},getPersonalizationStrategy:function(e){var t={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return u.request(t,e)},getUserTokenProfile:function(e,t){var r=e.userToken;if(!r)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");var a={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(r)),queryParameters:{},headers:{}};return u.request(a,t)},post:function(e,t){var r=e.path,a=e.parameters,n=e.body;if(!r)throw new Error("Parameter `path` is required when calling `post`.");var s={method:"POST",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{},data:n||{}};return u.request(s,t)},put:function(e,t){var r=e.path,a=e.parameters,n=e.body;if(!r)throw new Error("Parameter `path` is required when calling `put`.");var s={method:"PUT",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{},data:n||{}};return u.request(s,t)},setPersonalizationStrategy:function(e,t){if(!e)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!e.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!e.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!e.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");var r={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:e};return u.request(r,t)}}}(function(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?q(Object(a),!0).forEach((function(r){t(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):q(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({appId:e,apiKey:s,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const a=(e,a)=>setTimeout((()=>{r.abort(),t({status:0,content:a,isTimedOut:!0})}),e),n=a(e.connectTimeout,"Connection timeout");let s;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===s&&(clearTimeout(n),s=a(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(n),clearTimeout(s),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(n),clearTimeout(s),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:n(),requestsCache:n({serializable:!1}),hostsCache:a({caches:[r({key:"".concat(w,"-").concat(e)}),n()]})},i))}}));
/*! client-personalization.umd.js | 5.0.0-alpha.3 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-personalization"]={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e){let t;const r=`algolia-client-js-${e.key}`;function a(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function n(){return JSON.parse(a().getItem(r)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),a=n()[r];return Promise.all([a||t(),void 0!==a])})).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const s=n();return s[JSON.stringify(e)]=t,a().setItem(r,JSON.stringify(s)),t})),delete:e=>Promise.resolve().then((()=>{const t=n();delete t[JSON.stringify(e)],a().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{a().removeItem(r)}))}}function a(e){const t=[...e.caches],r=t.shift();return void 0===r?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,n,s={miss:()=>Promise.resolve()})=>r.get(e,n,s).catch((()=>a({caches:t}).get(e,n,s))),set:(e,n)=>r.set(e,n).catch((()=>a({caches:t}).set(e,n))),delete:e=>r.delete(e).catch((()=>a({caches:t}).delete(e))),clear:()=>r.clear().catch((()=>a({caches:t}).clear()))}}function n(e={serializable:!0}){let t={};return{get(r,a,n={miss:()=>Promise.resolve()}){const s=JSON.stringify(r);if(s in t)return Promise.resolve(e.serializable?JSON.parse(t[s]):t[s]);const o=a();return o.then((e=>n.miss(e))).then((()=>o))},set:(r,a)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(a):a,Promise.resolve(a)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const s=12e4;function o(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>s},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=s}}}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class c extends Error{constructor(e,t){super(e),i(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends c{constructor(e,t,r){super(e,r),i(this,"stackTrace",void 0),this.stackTrace=t}}class l extends u{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class p extends u{constructor(e,t,r){super(e,r,"ApiError"),i(this,"status",void 0),this.status=t}}class h extends c{constructor(e,t){super(e,"DeserializationError"),i(this,"response",void 0),this.response=t}}function d(e,t,r){const a=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${t(e[r])?JSON.stringify(e[r]):e[r]}`)).join("&")}(r);let n=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return a.length&&(n+=`?${a}`),n}function m(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function f({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:a,algoliaAgent:n,timeouts:s,requester:i,requestsCache:c,responsesCache:u}){async function f(c,u,f=!0){const g=[],y=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(c,u),P=function(e,t,r){const a={Accept:"application/json",...e,...t,...r},n={};return Object.keys(a).forEach((e=>{const t=a[e];n[e.toLowerCase()]=t})),n}(r,c.headers,u.headers),O="GET"===c.method?{...c.data,...u.data}:{},b={"x-algolia-agent":n.value,...a,...c.queryParameters,...O};if(u&&u.queryParameters)for(const e of Object.keys(u.queryParameters))u.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(u.queryParameters[e])?b[e]=u.queryParameters[e].toString():b[e]=u.queryParameters[e];let w=0;const v=async(e,r)=>{const a=e.pop();if(void 0===a)throw new l(function(e){return e.map((e=>m(e)))}(g));let n=u.timeout;void 0===n&&(n=f?s.read:s.write);const O={data:y,headers:P,method:c.method,url:d(a,c.path,b),connectTimeout:r(w,s.connect),responseTimeout:r(w,n)},q=t=>{const r={request:O,response:t,host:a,triesLeft:e.length};return g.push(r),r},T=await i.send(O);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(T)){const n=q(T);return T.isTimedOut&&w++,console.log("Retryable failure",m(n)),await t.set(a,o(a,T.isTimedOut?"timed out":"down")),v(e,r)}if(function({status:e}){return 2==~~(e/100)}(T))return function(e){try{return JSON.parse(e.content)}catch(t){throw new h(t.message,e)}}(T);throw q(T),function({content:e,status:t},r){let a=e;try{a=JSON.parse(e).message}catch(e){}return new p(a,t,r)}(T,g)},q=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),T=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(o(e))))))),a=r.filter((e=>e.isUp())),n=r.filter((e=>e.isTimedOut())),s=[...a,...n];return{hosts:s.length>0?s:e,getTimeout:(e,t)=>(0===n.length&&0===e?1:n.length+3+e)*t}}(q);return v([...T.hosts].reverse(),T.getTimeout)}return{hostsCache:t,requester:i,timeouts:s,algoliaAgent:n,baseHeaders:r,baseQueryParameters:a,hosts:e,request:function(e,t={}){const n=e.useReadTransporter||"GET"===e.method;if(!n)return f(e,t,n);const s=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return s();const o={request:e,requestOptions:t,transporter:{queryParameters:a,headers:r}};return u.get(o,(()=>c.get(o,(()=>c.set(o,s()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>u.set(o,e)})},requestsCache:c,responsesCache:u}}function g({algoliaAgents:e,client:t,version:r}){const a=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>a.add(e))),a}function y(e,t){if(null==e)return{};var r,a,n=function(e,t){if(null==e)return{};var r,a,n={},s=Object.keys(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)>=0||(n[r]=e[r]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(a=0;a<s.length;a++)r=s[a],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}var P=["appId","apiKey","authMode","algoliaAgents","region"];function O(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function b(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?O(Object(a),!0).forEach((function(r){t(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):O(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}var w="5.0.0-alpha.3",v=["eu","us"];function q(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}e.apiClientVersion=w,e.personalizationClient=function(e,s,o,i){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!s||"string"!=typeof s)throw new Error("`apiKey` is missing.");if(!o)throw new Error("`region` is missing.");if(o&&("string"!=typeof o||!v.includes(o)))throw new Error("`region` must be one of the following: ".concat(v.join(", ")));return function(e){var t,r=e.appId,a=e.apiKey,n=e.authMode,s=e.algoliaAgents,o=e.region,i=y(e,P),c=function(e,t,r="WithinHeaders"){const a={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?a:{},queryParameters:()=>"WithinQueryParameters"===r?a:{}}}(r,a,n),u=f(b(b({hosts:(t=o,[{url:"personalization.{region}.algolia.com".replace("{region}",t),accept:"readWrite",protocol:"https"}])},i),{},{algoliaAgent:g({algoliaAgents:s,client:"Personalization",version:w}),baseHeaders:b(b({"content-type":"text/plain"},c.headers()),i.baseHeaders),baseQueryParameters:b(b({},c.queryParameters()),i.baseQueryParameters)}));return{transporter:u,get _ua(){return u.algoliaAgent.value},addAlgoliaAgent:function(e,t){u.algoliaAgent.add({segment:e,version:t})},del:function(e,t){var r=e.path,a=e.parameters;if(!r)throw new Error("Parameter `path` is required when calling `del`.");var n={method:"DELETE",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{}};return u.request(n,t)},deleteUserProfile:function(e,t){var r=e.userToken;if(!r)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");var a={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(r)),queryParameters:{},headers:{}};return u.request(a,t)},get:function(e,t){var r=e.path,a=e.parameters;if(!r)throw new Error("Parameter `path` is required when calling `get`.");var n={method:"GET",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{}};return u.request(n,t)},getPersonalizationStrategy:function(e){var t={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return u.request(t,e)},getUserTokenProfile:function(e,t){var r=e.userToken;if(!r)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");var a={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(r)),queryParameters:{},headers:{}};return u.request(a,t)},post:function(e,t){var r=e.path,a=e.parameters,n=e.body;if(!r)throw new Error("Parameter `path` is required when calling `post`.");var s={method:"POST",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{},data:n||{}};return u.request(s,t)},put:function(e,t){var r=e.path,a=e.parameters,n=e.body;if(!r)throw new Error("Parameter `path` is required when calling `put`.");var s={method:"PUT",path:"/1{path}".replace("{path}",r),queryParameters:a||{},headers:{},data:n||{}};return u.request(s,t)},setPersonalizationStrategy:function(e,t){if(!e)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!e.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!e.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!e.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");var r={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:e};return u.request(r,t)}}}(function(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?q(Object(a),!0).forEach((function(r){t(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):q(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}({appId:e,apiKey:s,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const a=(e,a)=>setTimeout((()=>{r.abort(),t({status:0,content:a,isTimedOut:!0})}),e),n=a(e.connectTimeout,"Connection timeout");let s;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===s&&(clearTimeout(n),s=a(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(n),clearTimeout(s),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(n),clearTimeout(s),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:n(),requestsCache:n({serializable:!1}),hostsCache:a({caches:[r({key:"".concat(w,"-").concat(e)}),n()]})},i))}}));

@@ -7,3 +7,3 @@ import type { CreateClientOptions, RequestOptions } from '@algolia/client-common';

import type { SetPersonalizationStrategyResponse } from '../model/setPersonalizationStrategyResponse';
export declare const apiClientVersion = "5.0.0-alpha.2";
export declare const apiClientVersion = "5.0.0-alpha.3";
export declare const REGIONS: readonly ["eu", "us"];

@@ -10,0 +10,0 @@ export declare type Region = typeof REGIONS[number];

@@ -8,2 +8,3 @@ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.

userToken: string;
/**

@@ -10,0 +11,0 @@ * A date until which the data can safely be considered as deleted for the given user. Any data received after the `deletedUntil` date will start building a new user profile.

@@ -8,2 +8,3 @@ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.

score: number;
/**

@@ -13,2 +14,3 @@ * The name of the event.

eventName: string;
/**

@@ -15,0 +17,0 @@ * The type of the event.

@@ -8,2 +8,3 @@ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.

score: number;
/**

@@ -10,0 +11,0 @@ * The name of the facet.

@@ -8,2 +8,3 @@ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.

userToken: string;
/**

@@ -13,2 +14,3 @@ * Date of last event update. (ISO-8601 format).

lastEventAt: string;
/**

@@ -15,0 +17,0 @@ * The userToken scores.

@@ -11,2 +11,3 @@ // This file is generated, manual changes will be lost - read more on https://github.com/algolia/api-clients-automation.

eventScoring: EventScoring[];
/**

@@ -16,2 +17,3 @@ * Scores associated with the facets.

facetScoring: FacetScoring[];
/**

@@ -18,0 +20,0 @@ * The impact that personalization has on search results: a number between 0 (personalization disabled) and 100 (personalization fully enabled).

{
"name": "@algolia/client-personalization",
"version": "5.0.0-alpha.2",
"version": "5.0.0-alpha.3",
"description": "JavaScript client for client-personalization",

@@ -24,5 +24,5 @@ "repository": "algolia/algoliasearch-client-javascript",

"dependencies": {
"@algolia/client-common": "5.0.0-alpha.2",
"@algolia/requester-browser-xhr": "5.0.0-alpha.2",
"@algolia/requester-node-http": "5.0.0-alpha.2"
"@algolia/client-common": "5.0.0-alpha.3",
"@algolia/requester-browser-xhr": "5.0.0-alpha.3",
"@algolia/requester-node-http": "5.0.0-alpha.3"
},

@@ -29,0 +29,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

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