@algolia/recommend
Advanced tools
Comparing version 5.6.1 to 5.7.0
@@ -15,3 +15,3 @@ // builds/browser.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent, shuffle } from "@algolia/client-common"; | ||
var apiClientVersion = "5.6.1"; | ||
var apiClientVersion = "5.7.0"; | ||
function getDefaultHosts(appId) { | ||
@@ -116,2 +116,33 @@ return [ | ||
/** | ||
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn\'t require a facet value placeholder (it tries to match the data source item\'s attributes instead). | ||
* | ||
* Required API Key ACLs: | ||
* - editSettings. | ||
* | ||
* @param batchRecommendRules - The batchRecommendRules object. | ||
* @param batchRecommendRules.indexName - Name of the index on which to perform the operation. | ||
* @param batchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). | ||
* @param batchRecommendRules.recommendRule - The recommendRule object. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
batchRecommendRules({ indexName, model, recommendRule }, requestOptions) { | ||
if (!indexName) { | ||
throw new Error("Parameter `indexName` is required when calling `batchRecommendRules`."); | ||
} | ||
if (!model) { | ||
throw new Error("Parameter `model` is required when calling `batchRecommendRules`."); | ||
} | ||
const requestPath = "/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model)); | ||
const headers = {}; | ||
const queryParameters = {}; | ||
const request = { | ||
method: "POST", | ||
path: requestPath, | ||
queryParameters, | ||
headers, | ||
data: recommendRule ? recommendRule : {} | ||
}; | ||
return transporter.request(request, requestOptions); | ||
}, | ||
/** | ||
* This method allow you to send requests to the Algolia REST API. | ||
@@ -118,0 +149,0 @@ * |
@@ -1,2 +0,2 @@ | ||
function G(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function d(s){t().setItem(o,JSON.stringify(s))}function m(){let s=r.timeToLive?r.timeToLive*1e3:null,n=a(),i=Object.fromEntries(Object.entries(n).filter(([,f])=>f.timestamp!==void 0));if(d(i),!s)return;let l=Object.fromEntries(Object.entries(i).filter(([,f])=>{let P=new Date().getTime();return!(f.timestamp+s<P)}));d(l)}return{get(s,n,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(m(),a()[JSON.stringify(s)])).then(l=>Promise.all([l?l.value:n(),l!==void 0])).then(([l,f])=>Promise.all([l,f||i.miss(l)])).then(([l])=>l)},set(s,n){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(s)]={timestamp:new Date().getTime(),value:n},t().setItem(o,JSON.stringify(i)),n})},delete(s){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(s)],t().setItem(o,JSON.stringify(n))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,d={miss:()=>Promise.resolve()}){return o.get(t,a,d).catch(()=>E({caches:e}).get(t,a,d))},set(t,a){return o.set(t,a).catch(()=>E({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>E({caches:e}).delete(t))},clear(){return o.clear().catch(()=>E({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let d=JSON.stringify(o);if(d in e)return Promise.resolve(r.serializable?JSON.parse(e[d]):e[d]);let m=t();return m.then(s=>a.miss(s)).then(()=>m)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var W=1e3,$=2e3,j=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function M({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function Q(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>L}function a(){return e==="timed out"&&Date.now()-o<=L}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var z=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},F=class extends z{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends F{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},D=class extends F{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends z{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends D{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function B(r){let e=r;for(let o=r.length-1;o>0;o--){let t=Math.floor(Math.random()*(o+1)),a=r[o];e[o]=r[t],e[t]=a}return e}function ne(r,e,o){let t=ae(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replaceAll("+","%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function me(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(d=>{let m=t[d];a[d.toLowerCase()]=m}),a}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function ue({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new D(t.message,e,o)}catch{}return new D(r,e,o)}function le({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||le({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return~~(r/100)===2}function fe(r){return r.map(e=>X(e))}function X(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function K({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:d,timeouts:m,requester:s,requestsCache:n,responsesCache:i}){async function l(u){let c=await Promise.all(u.map(p=>e.get(p,()=>Promise.resolve(H(p))))),w=c.filter(p=>p.isUp()),R=c.filter(p=>p.isTimedOut()),q=[...w,...R];return{hosts:q.length>0?q:u,getTimeout(p,x){return(R.length===0&&p===0?1:R.length+3+p)*x}}}async function f(u,c,w=!0){let R=[],q=ie(u,c),g=me(o,u.headers,c.headers),p=u.method==="GET"?{...u.data,...c.data}:{},x={...a,...u.queryParameters,...p};if(d.value&&(x["x-algolia-agent"]=d.value),c&&c.queryParameters)for(let h of Object.keys(c.queryParameters))!c.queryParameters[h]||Object.prototype.toString.call(c.queryParameters[h])==="[object Object]"?x[h]=c.queryParameters[h]:x[h]=c.queryParameters[h].toString();let v=0,N=async(h,S)=>{let T=h.pop();if(T===void 0)throw new te(fe(R));let C={...m,...c.timeouts},I={data:q,headers:g,method:u.method,url:ne(T,u.path,x),connectTimeout:S(v,C.connect),responseTimeout:S(v,w?C.read:C.write)},U=b=>{let k={request:I,response:b,host:T,triesLeft:h.length};return R.push(k),k},y=await s.send(I);if(de(y)){let b=U(y);return y.isTimedOut&&v++,t.info("Retryable failure",X(b)),await e.set(T,H(T,y.isTimedOut?"timed out":"down")),N(h,S)}if(pe(y))return ce(y);throw U(y),ue(y,R)},Z=r.filter(h=>h.accept==="readWrite"||(w?h.accept==="read":h.accept==="write")),_=await l(Z);return N([..._.hosts].reverse(),_.getTimeout)}function P(u,c={}){let w=u.useReadTransporter||u.method==="GET";if(!w)return f(u,c,w);let R=()=>f(u,c);if((c.cacheable||u.cacheable)!==!0)return R();let g={request:u,requestOptions:c,transporter:{queryParameters:a,headers:o}};return i.get(g,()=>n.get(g,()=>n.set(g,R()).then(p=>Promise.all([n.delete(g),p]),p=>Promise.all([n.delete(g),Promise.reject(p)])).then(([p,x])=>x)),{miss:p=>i.set(g,p)})}return{hostsCache:e,requester:s,timeouts:m,logger:t,algoliaAgent:d,baseHeaders:o,baseQueryParameters:a,hosts:r,request:P,requestsCache:n,responsesCache:i}}function V(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(s=>t.setRequestHeader(s,e.headers[s]));let a=(s,n)=>setTimeout(()=>{t.abort(),o({status:0,content:n,isTimedOut:!0})},s),d=a(e.connectTimeout,"Connection timeout"),m;t.onreadystatechange=()=>{t.readyState>t.OPENED&&m===void 0&&(clearTimeout(d),m=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(d),clearTimeout(m),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(d),clearTimeout(m),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var A="5.6.1";function he(r){return[{url:`${r}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${r}.algolia.net`,accept:"write",protocol:"https"}].concat(B([{url:`${r}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${r}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${r}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,...a}){let d=J(r,e,o),m=K({hosts:he(r),...a,algoliaAgent:M({algoliaAgents:t,client:"Recommend",version:A}),baseHeaders:{"content-type":"text/plain",...d.headers(),...a.baseHeaders},baseQueryParameters:{...d.queryParameters(),...a.baseQueryParameters}});return{transporter:m,appId:r,clearCache(){return Promise.all([m.requestsCache.clear(),m.responsesCache.clear()]).then(()=>{})},get _ua(){return m.algoliaAgent.value},addAlgoliaAgent(s,n){m.algoliaAgent.add({segment:s,version:n})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?m.baseHeaders["x-algolia-api-key"]=s:m.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:n},i){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return m.request(u,i)},customGet({path:s,parameters:n},i){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return m.request(u,i)},customPost({path:s,parameters:n,body:i},l){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let c={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:i||{}};return m.request(c,l)},customPut({path:s,parameters:n,body:i},l){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let c={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:i||{}};return m.request(c,l)},deleteRecommendRule({indexName:s,model:n,objectID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `deleteRecommendRule`.");if(!n)throw new Error("Parameter `model` is required when calling `deleteRecommendRule`.");if(!i)throw new Error("Parameter `objectID` is required when calling `deleteRecommendRule`.");let c={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return m.request(c,l)},getRecommendRule({indexName:s,model:n,objectID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `getRecommendRule`.");if(!n)throw new Error("Parameter `model` is required when calling `getRecommendRule`.");if(!i)throw new Error("Parameter `objectID` is required when calling `getRecommendRule`.");let c={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return m.request(c,l)},getRecommendStatus({indexName:s,model:n,taskID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `getRecommendStatus`.");if(!n)throw new Error("Parameter `model` is required when calling `getRecommendStatus`.");if(!i)throw new Error("Parameter `taskID` is required when calling `getRecommendStatus`.");let c={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{taskID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return m.request(c,l)},getRecommendations(s,n){if(s&&Array.isArray(s)&&(s={requests:s}),!s)throw new Error("Parameter `getRecommendationsParams` is required when calling `getRecommendations`.");if(!s.requests)throw new Error("Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.");let P={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:s,useReadTransporter:!0,cacheable:!0};return m.request(P,n)},searchRecommendRules({indexName:s,model:n,searchRecommendRulesParams:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `searchRecommendRules`.");if(!n)throw new Error("Parameter `model` is required when calling `searchRecommendRules`.");let c={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:i||{},useReadTransporter:!0,cacheable:!0};return m.request(c,l)}}}function pt(r,e,o){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return Y({appId:r,apiKey:e,timeouts:{connect:W,read:$,write:j},logger:Q(),requester:V(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:E({caches:[G({key:`${A}-${r}`}),O()]}),...o})}export{A as apiClientVersion,pt as recommendClient}; | ||
function G(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function d(s){t().setItem(o,JSON.stringify(s))}function c(){let s=r.timeToLive?r.timeToLive*1e3:null,n=a(),i=Object.fromEntries(Object.entries(n).filter(([,p])=>p.timestamp!==void 0));if(d(i),!s)return;let l=Object.fromEntries(Object.entries(i).filter(([,p])=>{let h=new Date().getTime();return!(p.timestamp+s<h)}));d(l)}return{get(s,n,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(c(),a()[JSON.stringify(s)])).then(l=>Promise.all([l?l.value:n(),l!==void 0])).then(([l,p])=>Promise.all([l,p||i.miss(l)])).then(([l])=>l)},set(s,n){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(s)]={timestamp:new Date().getTime(),value:n},t().setItem(o,JSON.stringify(i)),n})},delete(s){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(s)],t().setItem(o,JSON.stringify(n))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,d={miss:()=>Promise.resolve()}){return o.get(t,a,d).catch(()=>w({caches:e}).get(t,a,d))},set(t,a){return o.set(t,a).catch(()=>w({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>w({caches:e}).delete(t))},clear(){return o.clear().catch(()=>w({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let d=JSON.stringify(o);if(d in e)return Promise.resolve(r.serializable?JSON.parse(e[d]):e[d]);let c=t();return c.then(s=>a.miss(s)).then(()=>c)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var W=1e3,$=2e3,j=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function Q({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function M(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>L}function a(){return e==="timed out"&&Date.now()-o<=L}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var z=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},B=class extends z{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends B{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},D=class extends B{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends z{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends D{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function F(r){let e=r;for(let o=r.length-1;o>0;o--){let t=Math.floor(Math.random()*(o+1)),a=r[o];e[o]=r[t],e[t]=a}return e}function ne(r,e,o){let t=ae(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replaceAll("+","%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function me(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(d=>{let c=t[d];a[d.toLowerCase()]=c}),a}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function ue({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new D(t.message,e,o)}catch{}return new D(r,e,o)}function le({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||le({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return~~(r/100)===2}function fe(r){return r.map(e=>X(e))}function X(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function K({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:d,timeouts:c,requester:s,requestsCache:n,responsesCache:i}){async function l(u){let m=await Promise.all(u.map(f=>e.get(f,()=>Promise.resolve(H(f))))),q=m.filter(f=>f.isUp()),P=m.filter(f=>f.isTimedOut()),E=[...q,...P];return{hosts:E.length>0?E:u,getTimeout(f,x){return(P.length===0&&f===0?1:P.length+3+f)*x}}}async function p(u,m,q=!0){let P=[],E=ie(u,m),g=me(o,u.headers,m.headers),f=u.method==="GET"?{...u.data,...m.data}:{},x={...a,...u.queryParameters,...f};if(d.value&&(x["x-algolia-agent"]=d.value),m&&m.queryParameters)for(let R of Object.keys(m.queryParameters))!m.queryParameters[R]||Object.prototype.toString.call(m.queryParameters[R])==="[object Object]"?x[R]=m.queryParameters[R]:x[R]=m.queryParameters[R].toString();let v=0,N=async(R,S)=>{let T=R.pop();if(T===void 0)throw new te(fe(P));let C={...c,...m.timeouts},I={data:E,headers:g,method:u.method,url:ne(T,u.path,x),connectTimeout:S(v,C.connect),responseTimeout:S(v,q?C.read:C.write)},_=b=>{let k={request:I,response:b,host:T,triesLeft:R.length};return P.push(k),k},y=await s.send(I);if(de(y)){let b=_(y);return y.isTimedOut&&v++,t.info("Retryable failure",X(b)),await e.set(T,H(T,y.isTimedOut?"timed out":"down")),N(R,S)}if(pe(y))return ce(y);throw _(y),ue(y,P)},Z=r.filter(R=>R.accept==="readWrite"||(q?R.accept==="read":R.accept==="write")),U=await l(Z);return N([...U.hosts].reverse(),U.getTimeout)}function h(u,m={}){let q=u.useReadTransporter||u.method==="GET";if(!q)return p(u,m,q);let P=()=>p(u,m);if((m.cacheable||u.cacheable)!==!0)return P();let g={request:u,requestOptions:m,transporter:{queryParameters:a,headers:o}};return i.get(g,()=>n.get(g,()=>n.set(g,P()).then(f=>Promise.all([n.delete(g),f]),f=>Promise.all([n.delete(g),Promise.reject(f)])).then(([f,x])=>x)),{miss:f=>i.set(g,f)})}return{hostsCache:e,requester:s,timeouts:c,logger:t,algoliaAgent:d,baseHeaders:o,baseQueryParameters:a,hosts:r,request:h,requestsCache:n,responsesCache:i}}function V(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(s=>t.setRequestHeader(s,e.headers[s]));let a=(s,n)=>setTimeout(()=>{t.abort(),o({status:0,content:n,isTimedOut:!0})},s),d=a(e.connectTimeout,"Connection timeout"),c;t.onreadystatechange=()=>{t.readyState>t.OPENED&&c===void 0&&(clearTimeout(d),c=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(d),clearTimeout(c),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(d),clearTimeout(c),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var A="5.7.0";function he(r){return[{url:`${r}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${r}.algolia.net`,accept:"write",protocol:"https"}].concat(F([{url:`${r}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${r}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${r}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,...a}){let d=J(r,e,o),c=K({hosts:he(r),...a,algoliaAgent:Q({algoliaAgents:t,client:"Recommend",version:A}),baseHeaders:{"content-type":"text/plain",...d.headers(),...a.baseHeaders},baseQueryParameters:{...d.queryParameters(),...a.baseQueryParameters}});return{transporter:c,appId:r,clearCache(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then(()=>{})},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent(s,n){c.algoliaAgent.add({segment:s,version:n})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?c.baseHeaders["x-algolia-api-key"]=s:c.baseQueryParameters["x-algolia-api-key"]=s},batchRecommendRules({indexName:s,model:n,recommendRule:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `batchRecommendRules`.");if(!n)throw new Error("Parameter `model` is required when calling `batchRecommendRules`.");let m={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:i||{}};return c.request(m,l)},customDelete({path:s,parameters:n},i){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return c.request(u,i)},customGet({path:s,parameters:n},i){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return c.request(u,i)},customPost({path:s,parameters:n,body:i},l){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let m={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:i||{}};return c.request(m,l)},customPut({path:s,parameters:n,body:i},l){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let m={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:i||{}};return c.request(m,l)},deleteRecommendRule({indexName:s,model:n,objectID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `deleteRecommendRule`.");if(!n)throw new Error("Parameter `model` is required when calling `deleteRecommendRule`.");if(!i)throw new Error("Parameter `objectID` is required when calling `deleteRecommendRule`.");let m={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return c.request(m,l)},getRecommendRule({indexName:s,model:n,objectID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `getRecommendRule`.");if(!n)throw new Error("Parameter `model` is required when calling `getRecommendRule`.");if(!i)throw new Error("Parameter `objectID` is required when calling `getRecommendRule`.");let m={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return c.request(m,l)},getRecommendStatus({indexName:s,model:n,taskID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `getRecommendStatus`.");if(!n)throw new Error("Parameter `model` is required when calling `getRecommendStatus`.");if(!i)throw new Error("Parameter `taskID` is required when calling `getRecommendStatus`.");let m={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{taskID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return c.request(m,l)},getRecommendations(s,n){if(s&&Array.isArray(s)&&(s={requests:s}),!s)throw new Error("Parameter `getRecommendationsParams` is required when calling `getRecommendations`.");if(!s.requests)throw new Error("Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.");let h={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:s,useReadTransporter:!0,cacheable:!0};return c.request(h,n)},searchRecommendRules({indexName:s,model:n,searchRecommendRulesParams:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `searchRecommendRules`.");if(!n)throw new Error("Parameter `model` is required when calling `searchRecommendRules`.");let m={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:i||{},useReadTransporter:!0,cacheable:!0};return c.request(m,l)}}}function ht(r,e,o){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return Y({appId:r,apiKey:e,timeouts:{connect:W,read:$,write:j},logger:M(),requester:V(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:w({caches:[G({key:`${A}-${r}`}),O()]}),...o})}export{A as apiClientVersion,ht as recommendClient}; | ||
//# sourceMappingURL=browser.min.js.map |
@@ -7,7 +7,7 @@ (function (global, factory) { | ||
function G(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function d(s){t().setItem(o,JSON.stringify(s));}function m(){let s=r.timeToLive?r.timeToLive*1e3:null,n=a(),i=Object.fromEntries(Object.entries(n).filter(([,f])=>f.timestamp!==void 0));if(d(i),!s)return;let l=Object.fromEntries(Object.entries(i).filter(([,f])=>{let P=new Date().getTime();return !(f.timestamp+s<P)}));d(l);}return {get(s,n,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(m(),a()[JSON.stringify(s)])).then(l=>Promise.all([l?l.value:n(),l!==void 0])).then(([l,f])=>Promise.all([l,f||i.miss(l)])).then(([l])=>l)},set(s,n){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(s)]={timestamp:new Date().getTime(),value:n},t().setItem(o,JSON.stringify(i)),n})},delete(s){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(s)],t().setItem(o,JSON.stringify(n));})},clear(){return Promise.resolve().then(()=>{t().removeItem(o);})}}}function ee(){return {get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,d={miss:()=>Promise.resolve()}){return o.get(t,a,d).catch(()=>E({caches:e}).get(t,a,d))},set(t,a){return o.set(t,a).catch(()=>E({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>E({caches:e}).delete(t))},clear(){return o.clear().catch(()=>E({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return {get(o,t,a={miss:()=>Promise.resolve()}){let d=JSON.stringify(o);if(d in e)return Promise.resolve(r.serializable?JSON.parse(e[d]):e[d]);let m=t();return m.then(s=>a.miss(s)).then(()=>m)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var W=1e3,$=2e3,j=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function M({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function Q(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>L}function a(){return e==="timed out"&&Date.now()-o<=L}return {...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var z=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},F=class extends z{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e;}},te=class extends F{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError");}},D=class extends F{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e;}},oe=class extends z{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends D{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o;}};function B(r){let e=r;for(let o=r.length-1;o>0;o--){let t=Math.floor(Math.random()*(o+1)),a=r[o];e[o]=r[t],e[t]=a;}return e}function ne(r,e,o){let t=ae(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replaceAll("+","%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function me(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(d=>{let m=t[d];a[d.toLowerCase()]=m;}),a}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function ue({content:r,status:e},o){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,o):new D(t.message,e,o)}catch{}return new D(r,e,o)}function le({isTimedOut:r,status:e}){return !r&&~~e===0}function de({isTimedOut:r,status:e}){return r||le({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return ~~(r/100)===2}function fe(r){return r.map(e=>X(e))}function X(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function K({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:d,timeouts:m,requester:s,requestsCache:n,responsesCache:i}){async function l(u){let c=await Promise.all(u.map(p=>e.get(p,()=>Promise.resolve(H(p))))),w=c.filter(p=>p.isUp()),R=c.filter(p=>p.isTimedOut()),q=[...w,...R];return {hosts:q.length>0?q:u,getTimeout(p,x){return (R.length===0&&p===0?1:R.length+3+p)*x}}}async function f(u,c,w=!0){let R=[],q=ie(u,c),g=me(o,u.headers,c.headers),p=u.method==="GET"?{...u.data,...c.data}:{},x={...a,...u.queryParameters,...p};if(d.value&&(x["x-algolia-agent"]=d.value),c&&c.queryParameters)for(let h of Object.keys(c.queryParameters))!c.queryParameters[h]||Object.prototype.toString.call(c.queryParameters[h])==="[object Object]"?x[h]=c.queryParameters[h]:x[h]=c.queryParameters[h].toString();let v=0,N=async(h,S)=>{let T=h.pop();if(T===void 0)throw new te(fe(R));let C={...m,...c.timeouts},I={data:q,headers:g,method:u.method,url:ne(T,u.path,x),connectTimeout:S(v,C.connect),responseTimeout:S(v,w?C.read:C.write)},U=b=>{let k={request:I,response:b,host:T,triesLeft:h.length};return R.push(k),k},y=await s.send(I);if(de(y)){let b=U(y);return y.isTimedOut&&v++,t.info("Retryable failure",X(b)),await e.set(T,H(T,y.isTimedOut?"timed out":"down")),N(h,S)}if(pe(y))return ce(y);throw U(y),ue(y,R)},Z=r.filter(h=>h.accept==="readWrite"||(w?h.accept==="read":h.accept==="write")),_=await l(Z);return N([..._.hosts].reverse(),_.getTimeout)}function P(u,c={}){let w=u.useReadTransporter||u.method==="GET";if(!w)return f(u,c,w);let R=()=>f(u,c);if((c.cacheable||u.cacheable)!==!0)return R();let g={request:u,requestOptions:c,transporter:{queryParameters:a,headers:o}};return i.get(g,()=>n.get(g,()=>n.set(g,R()).then(p=>Promise.all([n.delete(g),p]),p=>Promise.all([n.delete(g),Promise.reject(p)])).then(([p,x])=>x)),{miss:p=>i.set(g,p)})}return {hostsCache:e,requester:s,timeouts:m,logger:t,algoliaAgent:d,baseHeaders:o,baseQueryParameters:a,hosts:r,request:P,requestsCache:n,responsesCache:i}}function V(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(s=>t.setRequestHeader(s,e.headers[s]));let a=(s,n)=>setTimeout(()=>{t.abort(),o({status:0,content:n,isTimedOut:!0});},s),d=a(e.connectTimeout,"Connection timeout"),m;t.onreadystatechange=()=>{t.readyState>t.OPENED&&m===void 0&&(clearTimeout(d),m=a(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(d),clearTimeout(m),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(d),clearTimeout(m),o({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}var A="5.6.1";function he(r){return [{url:`${r}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${r}.algolia.net`,accept:"write",protocol:"https"}].concat(B([{url:`${r}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${r}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${r}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,...a}){let d=J(r,e,o),m=K({hosts:he(r),...a,algoliaAgent:M({algoliaAgents:t,client:"Recommend",version:A}),baseHeaders:{"content-type":"text/plain",...d.headers(),...a.baseHeaders},baseQueryParameters:{...d.queryParameters(),...a.baseQueryParameters}});return {transporter:m,appId:r,clearCache(){return Promise.all([m.requestsCache.clear(),m.responsesCache.clear()]).then(()=>{})},get _ua(){return m.algoliaAgent.value},addAlgoliaAgent(s,n){m.algoliaAgent.add({segment:s,version:n});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?m.baseHeaders["x-algolia-api-key"]=s:m.baseQueryParameters["x-algolia-api-key"]=s;},customDelete({path:s,parameters:n},i){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return m.request(u,i)},customGet({path:s,parameters:n},i){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return m.request(u,i)},customPost({path:s,parameters:n,body:i},l){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let c={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:i||{}};return m.request(c,l)},customPut({path:s,parameters:n,body:i},l){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let c={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:i||{}};return m.request(c,l)},deleteRecommendRule({indexName:s,model:n,objectID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `deleteRecommendRule`.");if(!n)throw new Error("Parameter `model` is required when calling `deleteRecommendRule`.");if(!i)throw new Error("Parameter `objectID` is required when calling `deleteRecommendRule`.");let c={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return m.request(c,l)},getRecommendRule({indexName:s,model:n,objectID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `getRecommendRule`.");if(!n)throw new Error("Parameter `model` is required when calling `getRecommendRule`.");if(!i)throw new Error("Parameter `objectID` is required when calling `getRecommendRule`.");let c={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return m.request(c,l)},getRecommendStatus({indexName:s,model:n,taskID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `getRecommendStatus`.");if(!n)throw new Error("Parameter `model` is required when calling `getRecommendStatus`.");if(!i)throw new Error("Parameter `taskID` is required when calling `getRecommendStatus`.");let c={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{taskID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return m.request(c,l)},getRecommendations(s,n){if(s&&Array.isArray(s)&&(s={requests:s}),!s)throw new Error("Parameter `getRecommendationsParams` is required when calling `getRecommendations`.");if(!s.requests)throw new Error("Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.");let P={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:s,useReadTransporter:!0,cacheable:!0};return m.request(P,n)},searchRecommendRules({indexName:s,model:n,searchRecommendRulesParams:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `searchRecommendRules`.");if(!n)throw new Error("Parameter `model` is required when calling `searchRecommendRules`.");let c={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:i||{},useReadTransporter:!0,cacheable:!0};return m.request(c,l)}}}function pt(r,e,o){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return Y({appId:r,apiKey:e,timeouts:{connect:W,read:$,write:j},logger:Q(),requester:V(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:E({caches:[G({key:`${A}-${r}`}),O()]}),...o})} | ||
function G(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function d(s){t().setItem(o,JSON.stringify(s));}function c(){let s=r.timeToLive?r.timeToLive*1e3:null,n=a(),i=Object.fromEntries(Object.entries(n).filter(([,p])=>p.timestamp!==void 0));if(d(i),!s)return;let l=Object.fromEntries(Object.entries(i).filter(([,p])=>{let h=new Date().getTime();return !(p.timestamp+s<h)}));d(l);}return {get(s,n,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(c(),a()[JSON.stringify(s)])).then(l=>Promise.all([l?l.value:n(),l!==void 0])).then(([l,p])=>Promise.all([l,p||i.miss(l)])).then(([l])=>l)},set(s,n){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(s)]={timestamp:new Date().getTime(),value:n},t().setItem(o,JSON.stringify(i)),n})},delete(s){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(s)],t().setItem(o,JSON.stringify(n));})},clear(){return Promise.resolve().then(()=>{t().removeItem(o);})}}}function ee(){return {get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,d={miss:()=>Promise.resolve()}){return o.get(t,a,d).catch(()=>w({caches:e}).get(t,a,d))},set(t,a){return o.set(t,a).catch(()=>w({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>w({caches:e}).delete(t))},clear(){return o.clear().catch(()=>w({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return {get(o,t,a={miss:()=>Promise.resolve()}){let d=JSON.stringify(o);if(d in e)return Promise.resolve(r.serializable?JSON.parse(e[d]):e[d]);let c=t();return c.then(s=>a.miss(s)).then(()=>c)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var W=1e3,$=2e3,j=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function Q({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function M(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>L}function a(){return e==="timed out"&&Date.now()-o<=L}return {...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var z=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},B=class extends z{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e;}},te=class extends B{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError");}},D=class extends B{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e;}},oe=class extends z{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends D{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o;}};function F(r){let e=r;for(let o=r.length-1;o>0;o--){let t=Math.floor(Math.random()*(o+1)),a=r[o];e[o]=r[t],e[t]=a;}return e}function ne(r,e,o){let t=ae(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replaceAll("+","%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function me(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(d=>{let c=t[d];a[d.toLowerCase()]=c;}),a}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function ue({content:r,status:e},o){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,o):new D(t.message,e,o)}catch{}return new D(r,e,o)}function le({isTimedOut:r,status:e}){return !r&&~~e===0}function de({isTimedOut:r,status:e}){return r||le({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return ~~(r/100)===2}function fe(r){return r.map(e=>X(e))}function X(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function K({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:d,timeouts:c,requester:s,requestsCache:n,responsesCache:i}){async function l(u){let m=await Promise.all(u.map(f=>e.get(f,()=>Promise.resolve(H(f))))),q=m.filter(f=>f.isUp()),P=m.filter(f=>f.isTimedOut()),E=[...q,...P];return {hosts:E.length>0?E:u,getTimeout(f,x){return (P.length===0&&f===0?1:P.length+3+f)*x}}}async function p(u,m,q=!0){let P=[],E=ie(u,m),g=me(o,u.headers,m.headers),f=u.method==="GET"?{...u.data,...m.data}:{},x={...a,...u.queryParameters,...f};if(d.value&&(x["x-algolia-agent"]=d.value),m&&m.queryParameters)for(let R of Object.keys(m.queryParameters))!m.queryParameters[R]||Object.prototype.toString.call(m.queryParameters[R])==="[object Object]"?x[R]=m.queryParameters[R]:x[R]=m.queryParameters[R].toString();let v=0,N=async(R,S)=>{let T=R.pop();if(T===void 0)throw new te(fe(P));let C={...c,...m.timeouts},I={data:E,headers:g,method:u.method,url:ne(T,u.path,x),connectTimeout:S(v,C.connect),responseTimeout:S(v,q?C.read:C.write)},_=b=>{let k={request:I,response:b,host:T,triesLeft:R.length};return P.push(k),k},y=await s.send(I);if(de(y)){let b=_(y);return y.isTimedOut&&v++,t.info("Retryable failure",X(b)),await e.set(T,H(T,y.isTimedOut?"timed out":"down")),N(R,S)}if(pe(y))return ce(y);throw _(y),ue(y,P)},Z=r.filter(R=>R.accept==="readWrite"||(q?R.accept==="read":R.accept==="write")),U=await l(Z);return N([...U.hosts].reverse(),U.getTimeout)}function h(u,m={}){let q=u.useReadTransporter||u.method==="GET";if(!q)return p(u,m,q);let P=()=>p(u,m);if((m.cacheable||u.cacheable)!==!0)return P();let g={request:u,requestOptions:m,transporter:{queryParameters:a,headers:o}};return i.get(g,()=>n.get(g,()=>n.set(g,P()).then(f=>Promise.all([n.delete(g),f]),f=>Promise.all([n.delete(g),Promise.reject(f)])).then(([f,x])=>x)),{miss:f=>i.set(g,f)})}return {hostsCache:e,requester:s,timeouts:c,logger:t,algoliaAgent:d,baseHeaders:o,baseQueryParameters:a,hosts:r,request:h,requestsCache:n,responsesCache:i}}function V(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(s=>t.setRequestHeader(s,e.headers[s]));let a=(s,n)=>setTimeout(()=>{t.abort(),o({status:0,content:n,isTimedOut:!0});},s),d=a(e.connectTimeout,"Connection timeout"),c;t.onreadystatechange=()=>{t.readyState>t.OPENED&&c===void 0&&(clearTimeout(d),c=a(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(d),clearTimeout(c),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(d),clearTimeout(c),o({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}var A="5.7.0";function he(r){return [{url:`${r}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${r}.algolia.net`,accept:"write",protocol:"https"}].concat(F([{url:`${r}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${r}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${r}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,...a}){let d=J(r,e,o),c=K({hosts:he(r),...a,algoliaAgent:Q({algoliaAgents:t,client:"Recommend",version:A}),baseHeaders:{"content-type":"text/plain",...d.headers(),...a.baseHeaders},baseQueryParameters:{...d.queryParameters(),...a.baseQueryParameters}});return {transporter:c,appId:r,clearCache(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then(()=>{})},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent(s,n){c.algoliaAgent.add({segment:s,version:n});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?c.baseHeaders["x-algolia-api-key"]=s:c.baseQueryParameters["x-algolia-api-key"]=s;},batchRecommendRules({indexName:s,model:n,recommendRule:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `batchRecommendRules`.");if(!n)throw new Error("Parameter `model` is required when calling `batchRecommendRules`.");let m={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:i||{}};return c.request(m,l)},customDelete({path:s,parameters:n},i){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let u={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return c.request(u,i)},customGet({path:s,parameters:n},i){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let u={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return c.request(u,i)},customPost({path:s,parameters:n,body:i},l){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let m={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:i||{}};return c.request(m,l)},customPut({path:s,parameters:n,body:i},l){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let m={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:i||{}};return c.request(m,l)},deleteRecommendRule({indexName:s,model:n,objectID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `deleteRecommendRule`.");if(!n)throw new Error("Parameter `model` is required when calling `deleteRecommendRule`.");if(!i)throw new Error("Parameter `objectID` is required when calling `deleteRecommendRule`.");let m={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return c.request(m,l)},getRecommendRule({indexName:s,model:n,objectID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `getRecommendRule`.");if(!n)throw new Error("Parameter `model` is required when calling `getRecommendRule`.");if(!i)throw new Error("Parameter `objectID` is required when calling `getRecommendRule`.");let m={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return c.request(m,l)},getRecommendStatus({indexName:s,model:n,taskID:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `getRecommendStatus`.");if(!n)throw new Error("Parameter `model` is required when calling `getRecommendStatus`.");if(!i)throw new Error("Parameter `taskID` is required when calling `getRecommendStatus`.");let m={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{taskID}",encodeURIComponent(i)),queryParameters:{},headers:{}};return c.request(m,l)},getRecommendations(s,n){if(s&&Array.isArray(s)&&(s={requests:s}),!s)throw new Error("Parameter `getRecommendationsParams` is required when calling `getRecommendations`.");if(!s.requests)throw new Error("Parameter `getRecommendationsParams.requests` is required when calling `getRecommendations`.");let h={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:s,useReadTransporter:!0,cacheable:!0};return c.request(h,n)},searchRecommendRules({indexName:s,model:n,searchRecommendRulesParams:i},l){if(!s)throw new Error("Parameter `indexName` is required when calling `searchRecommendRules`.");if(!n)throw new Error("Parameter `model` is required when calling `searchRecommendRules`.");let m={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:i||{},useReadTransporter:!0,cacheable:!0};return c.request(m,l)}}}function ht(r,e,o){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");return Y({appId:r,apiKey:e,timeouts:{connect:W,read:$,write:j},logger:M(),requester:V(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:w({caches:[G({key:`${A}-${r}`}),O()]}),...o})} | ||
exports.apiClientVersion = A; | ||
exports.recommendClient = pt; | ||
exports.recommendClient = ht; | ||
})); |
@@ -14,3 +14,3 @@ // builds/fetch.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent, shuffle } from "@algolia/client-common"; | ||
var apiClientVersion = "5.6.1"; | ||
var apiClientVersion = "5.7.0"; | ||
function getDefaultHosts(appId) { | ||
@@ -115,2 +115,33 @@ return [ | ||
/** | ||
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn\'t require a facet value placeholder (it tries to match the data source item\'s attributes instead). | ||
* | ||
* Required API Key ACLs: | ||
* - editSettings. | ||
* | ||
* @param batchRecommendRules - The batchRecommendRules object. | ||
* @param batchRecommendRules.indexName - Name of the index on which to perform the operation. | ||
* @param batchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). | ||
* @param batchRecommendRules.recommendRule - The recommendRule object. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
batchRecommendRules({ indexName, model, recommendRule }, requestOptions) { | ||
if (!indexName) { | ||
throw new Error("Parameter `indexName` is required when calling `batchRecommendRules`."); | ||
} | ||
if (!model) { | ||
throw new Error("Parameter `model` is required when calling `batchRecommendRules`."); | ||
} | ||
const requestPath = "/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model)); | ||
const headers = {}; | ||
const queryParameters = {}; | ||
const request = { | ||
method: "POST", | ||
path: requestPath, | ||
queryParameters, | ||
headers, | ||
data: recommendRule ? recommendRule : {} | ||
}; | ||
return transporter.request(request, requestOptions); | ||
}, | ||
/** | ||
* This method allow you to send requests to the Algolia REST API. | ||
@@ -117,0 +148,0 @@ * |
@@ -14,3 +14,3 @@ // builds/node.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent, shuffle } from "@algolia/client-common"; | ||
var apiClientVersion = "5.6.1"; | ||
var apiClientVersion = "5.7.0"; | ||
function getDefaultHosts(appId) { | ||
@@ -115,2 +115,33 @@ return [ | ||
/** | ||
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn\'t require a facet value placeholder (it tries to match the data source item\'s attributes instead). | ||
* | ||
* Required API Key ACLs: | ||
* - editSettings. | ||
* | ||
* @param batchRecommendRules - The batchRecommendRules object. | ||
* @param batchRecommendRules.indexName - Name of the index on which to perform the operation. | ||
* @param batchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). | ||
* @param batchRecommendRules.recommendRule - The recommendRule object. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
batchRecommendRules({ indexName, model, recommendRule }, requestOptions) { | ||
if (!indexName) { | ||
throw new Error("Parameter `indexName` is required when calling `batchRecommendRules`."); | ||
} | ||
if (!model) { | ||
throw new Error("Parameter `model` is required when calling `batchRecommendRules`."); | ||
} | ||
const requestPath = "/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model)); | ||
const headers = {}; | ||
const queryParameters = {}; | ||
const request = { | ||
method: "POST", | ||
path: requestPath, | ||
queryParameters, | ||
headers, | ||
data: recommendRule ? recommendRule : {} | ||
}; | ||
return transporter.request(request, requestOptions); | ||
}, | ||
/** | ||
* This method allow you to send requests to the Algolia REST API. | ||
@@ -117,0 +148,0 @@ * |
// src/recommendClient.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent, shuffle } from "@algolia/client-common"; | ||
var apiClientVersion = "5.6.1"; | ||
var apiClientVersion = "5.7.0"; | ||
function getDefaultHosts(appId) { | ||
@@ -103,2 +103,33 @@ return [ | ||
/** | ||
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may also specify `true` for `clearExistingRules`, in which case the batch will atomically replace all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the conditions and consequences apply to a [source item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main differences are the following: - Conditions `pattern` and `anchoring` are unavailable. - Condition `filters` triggers if the source item matches the specified filters. - Condition `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. - Consequence `automaticFacetFilters` doesn\'t require a facet value placeholder (it tries to match the data source item\'s attributes instead). | ||
* | ||
* Required API Key ACLs: | ||
* - editSettings. | ||
* | ||
* @param batchRecommendRules - The batchRecommendRules object. | ||
* @param batchRecommendRules.indexName - Name of the index on which to perform the operation. | ||
* @param batchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). | ||
* @param batchRecommendRules.recommendRule - The recommendRule object. | ||
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. | ||
*/ | ||
batchRecommendRules({ indexName, model, recommendRule }, requestOptions) { | ||
if (!indexName) { | ||
throw new Error("Parameter `indexName` is required when calling `batchRecommendRules`."); | ||
} | ||
if (!model) { | ||
throw new Error("Parameter `model` is required when calling `batchRecommendRules`."); | ||
} | ||
const requestPath = "/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model)); | ||
const headers = {}; | ||
const queryParameters = {}; | ||
const request = { | ||
method: "POST", | ||
path: requestPath, | ||
queryParameters, | ||
headers, | ||
data: recommendRule ? recommendRule : {} | ||
}; | ||
return transporter.request(request, requestOptions); | ||
}, | ||
/** | ||
* This method allow you to send requests to the Algolia REST API. | ||
@@ -105,0 +136,0 @@ * |
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. | ||
import type { RecommendModels } from './recommendModels'; | ||
import type { RecommendRule } from './recommendRule'; | ||
import type { RecommendationsRequest } from './recommendationsRequest'; | ||
@@ -8,2 +9,17 @@ import type { SearchRecommendRulesParams } from './searchRecommendRulesParams'; | ||
/** | ||
* Properties for the `batchRecommendRules` method. | ||
*/ | ||
export type BatchRecommendRulesProps = { | ||
/** | ||
* Name of the index on which to perform the operation. | ||
*/ | ||
indexName: string; | ||
/** | ||
* [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models). | ||
*/ | ||
model: RecommendModels; | ||
recommendRule?: RecommendRule[]; | ||
}; | ||
/** | ||
* Properties for the `customDelete` method. | ||
@@ -10,0 +26,0 @@ */ |
@@ -56,2 +56,3 @@ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. | ||
export * from './recommendSearchParams'; | ||
export * from './recommendUpdatedAtResponse'; | ||
export * from './recommendationsHit'; | ||
@@ -85,2 +86,3 @@ export * from './recommendationsHits'; | ||
export * from './taskStatus'; | ||
export * from './timeRange'; | ||
export * from './trendingFacetHit'; | ||
@@ -87,0 +89,0 @@ export * from './trendingFacets'; |
@@ -6,2 +6,3 @@ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. | ||
import type { RuleMetadata } from './ruleMetadata'; | ||
import type { TimeRange } from './timeRange'; | ||
@@ -32,2 +33,7 @@ /** | ||
enabled?: boolean; | ||
/** | ||
* Time periods when the rule is active. | ||
*/ | ||
validity?: TimeRange[]; | ||
}; |
{ | ||
"version": "5.6.1", | ||
"version": "5.7.0", | ||
"repository": { | ||
@@ -52,12 +52,12 @@ "type": "git", | ||
"dependencies": { | ||
"@algolia/client-common": "5.6.1", | ||
"@algolia/requester-browser-xhr": "5.6.1", | ||
"@algolia/requester-fetch": "5.6.1", | ||
"@algolia/requester-node-http": "5.6.1" | ||
"@algolia/client-common": "5.7.0", | ||
"@algolia/requester-browser-xhr": "5.7.0", | ||
"@algolia/requester-fetch": "5.7.0", | ||
"@algolia/requester-node-http": "5.7.0" | ||
}, | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "0.16.4", | ||
"@types/node": "22.5.5", | ||
"@types/node": "22.7.4", | ||
"publint": "0.2.11", | ||
"rollup": "4.22.4", | ||
"rollup": "4.22.5", | ||
"tsup": "8.3.0", | ||
@@ -64,0 +64,0 @@ "typescript": "5.6.2" |
@@ -45,7 +45,7 @@ <p align="center"> | ||
```bash | ||
yarn add @algolia/recommend@5.6.1 | ||
yarn add @algolia/recommend@5.7.0 | ||
# or | ||
npm install @algolia/recommend@5.6.1 | ||
npm install @algolia/recommend@5.7.0 | ||
# or | ||
pnpm add @algolia/recommend@5.6.1 | ||
pnpm add @algolia/recommend@5.7.0 | ||
``` | ||
@@ -58,3 +58,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@algolia/recommend@5.6.1/dist/builds/browser.umd.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@algolia/recommend@5.7.0/dist/builds/browser.umd.js"></script> | ||
``` | ||
@@ -61,0 +61,0 @@ |
Sorry, the diff of this file is too big to display
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 too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
810636
119
8970
+ Added@algolia/client-common@5.7.0(transitive)
+ Added@algolia/requester-browser-xhr@5.7.0(transitive)
+ Added@algolia/requester-fetch@5.7.0(transitive)
+ Added@algolia/requester-node-http@5.7.0(transitive)
- Removed@algolia/client-common@5.6.1(transitive)
- Removed@algolia/requester-browser-xhr@5.6.1(transitive)
- Removed@algolia/requester-fetch@5.6.1(transitive)
- Removed@algolia/requester-node-http@5.6.1(transitive)
Updated@algolia/client-common@5.7.0