@algolia/recommend 5.55.1 → 5.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/browser.d.ts +146 -23
- package/dist/builds/browser.js +282 -1
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +5 -5
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +6 -6
- package/dist/builds/fetch.js +282 -1
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +282 -1
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +282 -1
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +282 -1
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +146 -23
- package/dist/node.d.cts +146 -23
- package/dist/node.d.ts +146 -23
- package/dist/src/recommendClient.cjs +282 -1
- package/dist/src/recommendClient.cjs.map +1 -1
- package/dist/src/recommendClient.js +282 -1
- package/dist/src/recommendClient.js.map +1 -1
- package/dist/worker.d.ts +146 -23
- package/package.json +9 -9
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@algolia/recommend"] = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function
|
|
8
|
-
`&&(a=1));a<
|
|
9
|
-
`,a);if(
|
|
10
|
-
`?2:1:(
|
|
11
|
-
`),event:e,id:this.lastEventId,retry:this.retry};return this.data=[],t}};async function*he(e){let t=new fe;for await(let o of pe(e)){let r=t.decode(o);r!==null&&(yield r);}}var Re=750,J=120*1e3;function M(e,t="up"){let o=Date.now();function r(){return t==="up"||Date.now()-o>J}function i(){return t==="timed out"&&Date.now()-o<=J}return {...e,status:t,lastUpdate:o,isUp:r,isTimedOut:i}}var te=class extends Error{name="AlgoliaError";constructor(e,t){super(e),t&&(this.name=t);}};var re=class extends te{stackTrace;constructor(e,t,o){super(e,o),this.stackTrace=t;}},Q=class extends re{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",e,"RetryError");}},j=class extends re{status;constructor(e,t,o,r="ApiError"){super(e,o,r),this.status=t;}},xe=class extends te{response;constructor(e,t){super(e,"DeserializationError"),this.response=t;}},ge=class extends j{error;constructor(e,t,o,r){super(e,t,r,"DetailedApiError"),this.error=o;}};function oe(e){let t=e;for(let o=e.length-1;o>0;o--){let r=Math.floor(Math.random()*(o+1)),i=e[o];t[o]=e[r],t[r]=i;}return t}function B(e,t,o){let r=ye(o),i=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${t.charAt(0)==="/"?t.substring(1):t}`;return r.length&&(i+=`?${r}`),i}function ye(e){return Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>`${t}=${encodeURIComponent(Object.prototype.toString.call(e[t])==="[object Array]"?e[t].join(","):e[t]).replace(/\+/g,"%20")}`).join("&")}function X(e,t){if(e.method==="GET"||e.data===void 0&&t.data===void 0)return;let o=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(o)}function K(e,t,o){let r={Accept:"application/json",...e,...t,...o},i={};return Object.keys(r).forEach(d=>{let c=r[d];i[d.toLowerCase()]=c;}),i}function Pe(e){if(!(e.status===204||e.content.length===0))try{return JSON.parse(e.content)}catch(t){throw new xe(t.message,e)}}function Te({content:e,status:t},o){try{let r=JSON.parse(e);return "error"in r?new ge(r.message,t,r.error,o):new j(r.message,t,o)}catch{}return new j(e,t,o)}function Ee({isTimedOut:e,status:t}){return !e&&~~t===0}function ve({isTimedOut:e,status:t}){return e||Ee({isTimedOut:e,status:t})||~~(t/100)!==2&&~~(t/100)!==4}function Se({status:e}){return ~~(e/100)===2}function qe(e){return e.map(t=>se(t))}function se(e){let t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function ne({hosts:e,hostsCache:t,baseHeaders:o,logger:r,baseQueryParameters:i,algoliaAgent:d,timeouts:c,requester:n,requestsCache:s,responsesCache:a,compress:m,compression:f}){async function R(u){let l=await Promise.all(u.map(h=>t.get(h,()=>Promise.resolve(M(h))))),S=l.filter(h=>h.isUp()),T=l.filter(h=>h.isTimedOut()),v=[...S,...T];return {hosts:v.length>0?v:u,getTimeout(h,q){return (T.length===0&&h===0?1:T.length+3+h)*q}}}async function p(u,l,S){let T=[],v=X(u,l),y=K(o,u.headers,l.headers),h=f==="gzip"&&v!==void 0&&v.length>Re&&(u.method==="POST"||u.method==="PUT");h&&m===void 0&&r.info("Compression is disabled because no compress method is available.");let q=h&&m!==void 0,_=q?await m(v):v;q&&(y["content-encoding"]="gzip");let D=u.method==="GET"?{...u.data,...l.data}:{},w={...i,...u.queryParameters,...D};if(d.value&&(w["x-algolia-agent"]=d.value),l&&l.queryParameters)for(let P of Object.keys(l.queryParameters))!l.queryParameters[P]||Object.prototype.toString.call(l.queryParameters[P])==="[object Object]"?w[P]=l.queryParameters[P]:w[P]=l.queryParameters[P].toString();let I=0,N=async(P,L)=>{let O=P.pop();if(O===void 0)throw new Q(qe(T));let H={...c,...l.timeouts},F={data:_,headers:y,method:u.method,url:B(O,u.path,w),connectTimeout:L(I,H.connect),responseTimeout:L(I,S?H.read:H.write)},W=$=>{let z={request:F,response:$,host:O,triesLeft:P.length};return T.push(z),z},b=await n.send(F);if(ve(b)){let $=W(b);return b.isTimedOut&&I++,r.info("Retryable failure",se($)),await t.set(O,M(O,b.isTimedOut?"timed out":"down")),N(P,L)}if(Se(b))return Pe(b);throw W(b),Te(b,T)},E=e.filter(P=>P.accept==="readWrite"||(S?P.accept==="read":P.accept==="write")),G=await R(E);return N([...G.hosts].reverse(),G.getTimeout)}function x(u,l={}){let S=()=>p(u,l,T),T=u.useReadTransporter||u.method==="GET";if((l.cacheable||u.cacheable)!==true)return S();let y={request:u,requestOptions:l,transporter:{queryParameters:i,headers:o}};return a.get(y,()=>s.get(y,()=>s.set(y,S()).then(h=>Promise.all([s.delete(y),h]),h=>Promise.all([s.delete(y),Promise.reject(h)])).then(([h,q])=>q)),{miss:h=>a.set(y,h)})}async function*A(u,l={}){if(!n.sendStream)throw new Error("This requester does not support streaming");let S=X(u,l),T=K(o,u.headers,l.headers);T.accept="text/event-stream";let v=u.method==="GET"?{...u.data,...l.data}:{},y={...i,...u.queryParameters,...v};if(d.value&&(y["x-algolia-agent"]=d.value),l&&l.queryParameters)for(let E of Object.keys(l.queryParameters))!l.queryParameters[E]||Object.prototype.toString.call(l.queryParameters[E])==="[object Object]"?y[E]=l.queryParameters[E]:y[E]=l.queryParameters[E].toString();let h=u.useReadTransporter||u.method==="GET",q=e.filter(E=>E.accept==="readWrite"||(h?E.accept==="read":E.accept==="write")),D=(await R(q)).hosts[0];if(!D)throw new Q([]);let w={...c,...l.timeouts},I={data:S,headers:T,method:u.method,url:B(D,u.path,y),connectTimeout:w.connect,responseTimeout:h?w.read:w.write},N=await n.sendStream(I);yield*he(N);}return {hostsCache:t,requester:n,timeouts:c,logger:r,algoliaAgent:d,baseHeaders:o,baseQueryParameters:i,hosts:e,request:x,requestStream:A,requestsCache:s,responsesCache:a}}function g(e,t,o){if(o==null||typeof o=="string"&&o.length===0)throw new Error(`Parameter \`${e}\` is required when calling \`${t}\`.`)}function ae(){function e(t){return new Promise(o=>{let r=new XMLHttpRequest;r.open(t.method,t.url,true),Object.keys(t.headers).forEach(n=>r.setRequestHeader(n,t.headers[n]));let i=(n,s)=>setTimeout(()=>{r.abort(),o({status:0,content:s,isTimedOut:true});},n),d=i(t.connectTimeout,"Connection timeout"),c;r.onreadystatechange=()=>{r.readyState>r.OPENED&&c===void 0&&(clearTimeout(d),c=i(t.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(d),clearTimeout(c),o({content:r.responseText||"Network request failed",status:r.status,isTimedOut:false}));},r.onload=()=>{clearTimeout(d),clearTimeout(c),o({content:r.responseText,status:r.status,isTimedOut:false});},r.send(t.data);})}return {send:e}}var U="5.55.1";function we(e){return [{url:`${e}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${e}.algolia.net`,accept:"write",protocol:"https"}].concat(oe([{url:`${e}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function ie({appId:e,apiKey:t,authMode:o,algoliaAgents:r,...i}){let d=Y(e,t,o),c=ne({hosts:we(e),...i,algoliaAgent:Z({algoliaAgents:r,client:"Recommend",version:U}),baseHeaders:{"content-type":"text/plain",...d.headers(),...i.baseHeaders},baseQueryParameters:{...d.queryParameters(),...i.baseQueryParameters}});return {transporter:c,appId:e,apiKey:t,clearCache(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then(()=>{})},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent(n,s){c.algoliaAgent.add({segment:n,version:s});},setClientApiKey({apiKey:n}){!o||o==="WithinHeaders"?c.baseHeaders["x-algolia-api-key"]=n:c.baseQueryParameters["x-algolia-api-key"]=n;},batchRecommendRules({indexName:n,model:s,recommendRule:a},m){g("indexName","batchRecommendRules",n),g("model","batchRecommendRules",s);let x={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}",encodeURIComponent(n)).replace("{model}",encodeURIComponent(s)),queryParameters:{},headers:{},data:a||{}};return c.request(x,m)},customDelete({path:n,parameters:s},a){g("path","customDelete",n);let p={method:"DELETE",path:"/{path}".replace("{path}",n),queryParameters:s||{},headers:{}};return c.request(p,a)},customGet({path:n,parameters:s},a){g("path","customGet",n);let p={method:"GET",path:"/{path}".replace("{path}",n),queryParameters:s||{},headers:{}};return c.request(p,a)},customPost({path:n,parameters:s,body:a},m){g("path","customPost",n);let x={method:"POST",path:"/{path}".replace("{path}",n),queryParameters:s||{},headers:{},data:a||{}};return c.request(x,m)},customPut({path:n,parameters:s,body:a},m){g("path","customPut",n);let x={method:"PUT",path:"/{path}".replace("{path}",n),queryParameters:s||{},headers:{},data:a||{}};return c.request(x,m)},deleteRecommendRule({indexName:n,model:s,objectID:a},m){g("indexName","deleteRecommendRule",n),g("model","deleteRecommendRule",s),g("objectID","deleteRecommendRule",a);let x={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(n)).replace("{model}",encodeURIComponent(s)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(x,m)},getRecommendRule({indexName:n,model:s,objectID:a},m){g("indexName","getRecommendRule",n),g("model","getRecommendRule",s),g("objectID","getRecommendRule",a);let x={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(n)).replace("{model}",encodeURIComponent(s)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(x,m)},getRecommendStatus({indexName:n,model:s,taskID:a},m){g("indexName","getRecommendStatus",n),g("model","getRecommendStatus",s),g("taskID","getRecommendStatus",a);let x={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(n)).replace("{model}",encodeURIComponent(s)).replace("{taskID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return c.request(x,m)},getRecommendations(n,s){n&&Array.isArray(n)&&(n={requests:n}),g("getRecommendationsParams","getRecommendations",n),g("getRecommendationsParams.requests","getRecommendations",n.requests);let R={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:n,useReadTransporter:true,cacheable:true};return c.request(R,s)},searchRecommendRules({indexName:n,model:s,searchRecommendRulesParams:a},m){g("indexName","searchRecommendRules",n),g("model","searchRecommendRules",s);let x={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(n)).replace("{model}",encodeURIComponent(s)),queryParameters:{},headers:{},data:a||{},useReadTransporter:true,cacheable:true};return c.request(x,m)}}}function Or(e,t,o){if(!e||typeof e!="string")throw new Error("`appId` is missing.");if(!t||typeof t!="string")throw new Error("`apiKey` is missing.");let{compression:r,...i}=o||{};return ie({appId:e,apiKey:t,timeouts:{connect:1e3,read:2e3,write:3e4},logger:ee(),requester:ae(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:k(),requestsCache:k({serializable:false}),hostsCache:C({caches:[V({key:`${U}-${e}`}),k()]}),...i})}
|
|
7
|
+
function Y(e){let t,o=`algolia-client-js-${e.key}`;function r(){return t===void 0&&(t=e.localStorage||window.localStorage),t}function m(){return JSON.parse(r().getItem(o)||"{}")}function P(n){r().setItem(o,JSON.stringify(n));}function i(){return new Promise(n=>setTimeout(n,0))}function s(){let n=e.timeToLive?e.timeToLive*1e3:null,a=m(),c=new Date().getTime(),p=false;return {namespace:Object.fromEntries(Object.entries(a).filter(([,d])=>!d||d.timestamp===void 0||n&&d.timestamp+n<c?(p=true,false):true)),changed:p}}return {get(n,a,c={miss:()=>Promise.resolve()}){return i().then(()=>{let{namespace:p,changed:h}=s(),d=p[JSON.stringify(n)];return h&&P(p),d?d.value:a().then(l=>c.miss(l).then(()=>l))})},set(n,a){return i().then(()=>{let c=m();return c[JSON.stringify(n)]={timestamp:new Date().getTime(),value:a},r().setItem(o,JSON.stringify(c)),a})},delete(n){return i().then(()=>{let a=m();delete a[JSON.stringify(n)],r().setItem(o,JSON.stringify(a));})},clear(){return Promise.resolve().then(()=>{r().removeItem(o);})}}}function ue(){return {get(e,t,o={miss:()=>Promise.resolve()}){return t().then(m=>Promise.all([m,o.miss(m)])).then(([m])=>m)},set(e,t){return Promise.resolve(t)},delete(e){return Promise.resolve()},clear(){return Promise.resolve()}}}function A(e){let t=[...e.caches],o=t.shift();return o===void 0?ue():{get(r,m,P={miss:()=>Promise.resolve()}){return o.get(r,m,P).catch(()=>A({caches:t}).get(r,m,P))},set(r,m){return o.set(r,m).catch(()=>A({caches:t}).set(r,m))},delete(r){return o.delete(r).catch(()=>A({caches:t}).delete(r))},clear(){return o.clear().catch(()=>A({caches:t}).clear())}}}function N(e={serializable:true}){let t={};return {get(o,r,m={miss:()=>Promise.resolve()}){let P=JSON.stringify(o);if(P in t)return Promise.resolve(e.serializable?JSON.parse(t[P]):t[P]);let i=r();return i.then(s=>m.miss(s)).then(()=>i)},set(o,r){return t[JSON.stringify(o)]=e.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(o){return delete t[JSON.stringify(o)],Promise.resolve()},clear(){return t={},Promise.resolve()}}}function de(e){let t={value:`Algolia for JavaScript (${e})`,add(o){let r=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return t.value.indexOf(r)===-1&&(t.value=`${t.value}${r}`),t}};return t}function Z(e,t,o="WithinHeaders"){let r={"x-algolia-api-key":t,"x-algolia-application-id":e};return {headers(){return o==="WithinHeaders"?r:{}},queryParameters(){return o==="WithinQueryParameters"?r:{}}}}function ee({algoliaAgents:e,client:t,version:o}){let r=de(o).add({segment:t,version:o});return e.forEach(m=>r.add(m)),r}function te(){return {debug(e,t){return Promise.resolve()},info(e,t){return Promise.resolve()},error(e,t){return Promise.resolve()}}}var le=10*1024*1024;async function*pe(e){let t=e.getReader();try{for(;;){let{done:o,value:r}=await t.read();if(o)return;yield r;}}finally{t.releaseLock();}}function he(e){return Symbol.asyncIterator in e?e:pe(e)}async function*fe(e){let t=new TextDecoder("utf-8"),o=[],r=0,m=false,P=true;for await(let s of he(e)){let n=t.decode(s,{stream:true}),a=0;for(m&&(m=false,n.length>0&&n[0]===`
|
|
8
|
+
`&&(a=1));a<n.length;){let c=n.indexOf("\r",a),p=n.indexOf(`
|
|
9
|
+
`,a);if(c===-1&&p===-1){let O=n.slice(a);if(o.push(O),r+=O.length,r>le)throw new Error("SSE line buffer exceeded 10MB");break}let h,d;c!==-1&&(p===-1||c<p)?(h=c,c+1<n.length?d=n[c+1]===`
|
|
10
|
+
`?2:1:(m=true,d=1)):(h=p,d=1);let l=n.slice(a,h);o.push(l);let w=o.length===1?o[0]:o.join("");o.length=0,r=0,P&&(w.startsWith("\uFEFF")&&(w=w.slice(1)),P=false),yield w,a=h+d;}}let i=t.decode();if(i&&o.push(i),o.length>0){let s=o.join("");P&&s.startsWith("\uFEFF")&&(s=s.slice(1)),yield s;}}var Re=class{data=[];eventType="";lastEventId=null;retry=null;decode(e){if(e==="")return this.dispatch();if(e[0]===":")return null;let t=e.indexOf(":"),o,r;switch(t===-1?(o=e,r=""):(o=e.slice(0,t),r=e.slice(t+1),r[0]===" "&&(r=r.slice(1))),o){case "data":this.data.push(r);break;case "event":this.eventType=r;break;case "id":r.includes("\0")||(this.lastEventId=r);break;case "retry":/^[0-9]+$/.test(r)&&(this.retry=parseInt(r,10));break}return null}dispatch(){let e=this.eventType;if(this.eventType="",this.data.length===0)return null;let t={data:this.data.join(`
|
|
11
|
+
`),event:e,id:this.lastEventId,retry:this.retry};return this.data=[],t}};async function*Pe(e){let t=new Re;for await(let o of fe(e)){let r=t.decode(o);r!==null&&(yield r);}}var ye=750,J=120*1e3;function M(e,t="up"){let o=Date.now();function r(){return t==="up"||Date.now()-o>J}function m(){return t==="timed out"&&Date.now()-o<=J}return {...e,status:t,lastUpdate:o,isUp:r,isTimedOut:m}}var re=class extends Error{name="AlgoliaError";constructor(e,t){super(e),t&&(this.name=t);}};var oe=class extends re{stackTrace;constructor(e,t,o){super(e,o),this.stackTrace=t;}},B=class extends oe{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",e,"RetryError");}},j=class extends oe{status;constructor(e,t,o,r="ApiError"){super(e,o,r),this.status=t;}},ge=class extends re{response;constructor(e,t){super(e,"DeserializationError"),this.response=t;}},xe=class extends j{error;constructor(e,t,o,r){super(e,t,r,"DetailedApiError"),this.error=o;}};function se(e){let t=e;for(let o=e.length-1;o>0;o--){let r=Math.floor(Math.random()*(o+1)),m=e[o];t[o]=e[r],t[r]=m;}return t}function X(e,t,o){let r=Te(o),m=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${t.charAt(0)==="/"?t.substring(1):t}`;return r.length&&(m+=`?${r}`),m}function Te(e){return Object.keys(e).filter(t=>e[t]!==void 0).sort().map(t=>`${t}=${encodeURIComponent(Object.prototype.toString.call(e[t])==="[object Array]"?e[t].join(","):e[t]).replace(/\+/g,"%20")}`).join("&")}function K(e,t){if(e.method==="GET"||e.data===void 0&&t.data===void 0)return;let o=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(o)}function V(e,t,o){let r={Accept:"application/json",...e,...t,...o},m={};return Object.keys(r).forEach(P=>{let i=r[P];m[P.toLowerCase()]=i;}),m}function ne(e){if(!(e.status===204||e.content.length===0))try{return JSON.parse(e.content)}catch(t){throw new ge(t.message,e)}}function qe(e){return {status:e.status,headers:e.headers,content:e.content,data:ne(e)}}function Ie({content:e,status:t},o){try{let r=JSON.parse(e);return "error"in r?new xe(r.message,t,r.error,o):new j(r.message,t,o)}catch{}return new j(e,t,o)}function Ee({isTimedOut:e,status:t}){return !e&&~~t===0}function ve({isTimedOut:e,status:t}){return e||Ee({isTimedOut:e,status:t})||~~(t/100)!==2&&~~(t/100)!==4}function He({status:e}){return ~~(e/100)===2}function Se(e){return e.map(t=>ae(t))}function ae(e){let t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function ce({hosts:e,hostsCache:t,baseHeaders:o,logger:r,baseQueryParameters:m,algoliaAgent:P,timeouts:i,requester:s,requestsCache:n,responsesCache:a,compress:c,compression:p}){async function h(f){let R=await Promise.all(f.map(y=>t.get(y,()=>Promise.resolve(M(y))))),I=R.filter(y=>y.isUp()),x=R.filter(y=>y.isTimedOut()),E=[...I,...x];return {hosts:E.length>0?E:f,getTimeout(y,v){return (x.length===0&&y===0?1:x.length+3+y)*v}}}async function d(f,R,I){let x=[],E=K(f,R),g=V(o,f.headers,R.headers),y=p==="gzip"&&E!==void 0&&E.length>ye&&(f.method==="POST"||f.method==="PUT");y&&c===void 0&&r.info("Compression is disabled because no compress method is available.");let v=y&&c!==void 0,k=v?await c(E):E;v&&(g["content-encoding"]="gzip");let W=f.method==="GET"?{...f.data,...R.data}:{},H={...m,...f.queryParameters,...W};if(P.value&&(H["x-algolia-agent"]=P.value),R&&R.queryParameters)for(let T of Object.keys(R.queryParameters))!R.queryParameters[T]||Object.prototype.toString.call(R.queryParameters[T])==="[object Object]"?H[T]=R.queryParameters[T]:H[T]=R.queryParameters[T].toString();let b=0,D=async(T,_)=>{let C=T.pop();if(C===void 0)throw new B(Se(x));let G={...i,...R.timeouts},Q={data:k,headers:g,method:f.method,url:X(C,f.path,H),connectTimeout:_(b,G.connect),responseTimeout:_(b,I?G.read:G.write)},F=L=>{let z={request:Q,response:L,host:C,triesLeft:T.length};return x.push(z),z},S=await s.send(Q);if(ve(S)){let L=F(S);return S.isTimedOut&&b++,r.info("Retryable failure",ae(L)),await t.set(C,M(C,S.isTimedOut?"timed out":"down")),D(T,_)}if(He(S))return S;throw F(S),Ie(S,x)},q=e.filter(T=>T.accept==="readWrite"||(I?T.accept==="read":T.accept==="write")),$=await h(q);return D([...$.hosts].reverse(),$.getTimeout)}function l(f,R={}){let I=()=>d(f,R,x).then(y=>ne(y)),x=f.useReadTransporter||f.method==="GET";if((R.cacheable||f.cacheable)!==true)return I();let g={request:f,requestOptions:R,transporter:{queryParameters:m,headers:o}};return a.get(g,()=>n.get(g,()=>n.set(g,I()).then(y=>Promise.all([n.delete(g),y]),y=>Promise.all([n.delete(g),Promise.reject(y)])).then(([y,v])=>v)),{miss:y=>a.set(g,y)})}function w(f,R={}){let I=f.useReadTransporter||f.method==="GET";return d(f,R,I).then(x=>qe(x))}async function*O(f,R={}){if(!s.sendStream)throw new Error("This requester does not support streaming");let I=K(f,R),x=V(o,f.headers,R.headers);x.accept="text/event-stream";let E=f.method==="GET"?{...f.data,...R.data}:{},g={...m,...f.queryParameters,...E};if(P.value&&(g["x-algolia-agent"]=P.value),R&&R.queryParameters)for(let q of Object.keys(R.queryParameters))!R.queryParameters[q]||Object.prototype.toString.call(R.queryParameters[q])==="[object Object]"?g[q]=R.queryParameters[q]:g[q]=R.queryParameters[q].toString();let y=f.useReadTransporter||f.method==="GET",v=e.filter(q=>q.accept==="readWrite"||(y?q.accept==="read":q.accept==="write")),W=(await h(v)).hosts[0];if(!W)throw new B([]);let H={...i,...R.timeouts},b={data:I,headers:x,method:f.method,url:X(W,f.path,g),connectTimeout:H.connect,responseTimeout:y?H.read:H.write},D=await s.sendStream(b);yield*Pe(D);}return {hostsCache:t,requester:s,timeouts:i,logger:r,algoliaAgent:P,baseHeaders:o,baseQueryParameters:m,hosts:e,request:l,requestWithHttpInfo:w,requestStream:O,requestsCache:n,responsesCache:a}}function u(e,t,o){if(o==null||typeof o=="string"&&o.length===0)throw new Error(`Parameter \`${e}\` is required when calling \`${t}\`.`)}function we(e){let t={};for(let o of e.trim().split(/[\r\n]+/)){let r=o.indexOf(": ");r>0&&(t[o.slice(0,r).toLowerCase()]=o.slice(r+2));}return t}function ie(){function e(t){return new Promise(o=>{let r=new XMLHttpRequest;r.open(t.method,t.url,true),Object.keys(t.headers).forEach(s=>r.setRequestHeader(s,t.headers[s]));let m=(s,n)=>setTimeout(()=>{r.abort(),o({status:0,content:n,isTimedOut:true});},s),P=m(t.connectTimeout,"Connection timeout"),i;r.onreadystatechange=()=>{r.readyState>r.OPENED&&i===void 0&&(clearTimeout(P),i=m(t.responseTimeout,"Socket timeout"));},r.onerror=()=>{r.status===0&&(clearTimeout(P),clearTimeout(i),o({content:r.responseText||"Network request failed",status:r.status,isTimedOut:false}));},r.onload=()=>{clearTimeout(P),clearTimeout(i),o({content:r.responseText,headers:we(r.getAllResponseHeaders()),status:r.status,isTimedOut:false});},r.send(t.data);})}return {send:e}}var U="5.56.0";function Ae(e){return [{url:`${e}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${e}.algolia.net`,accept:"write",protocol:"https"}].concat(se([{url:`${e}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${e}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function me({appId:e,apiKey:t,authMode:o,algoliaAgents:r,...m}){let P=Z(e,t,o),i=ce({hosts:Ae(e),...m,algoliaAgent:ee({algoliaAgents:r,client:"Recommend",version:U}),baseHeaders:{"content-type":"text/plain",...P.headers(),...m.baseHeaders},baseQueryParameters:{...P.queryParameters(),...m.baseQueryParameters}});return {transporter:i,appId:e,apiKey:t,clearCache(){return Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then(()=>{})},get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(s,n){i.algoliaAgent.add({segment:s,version:n});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?i.baseHeaders["x-algolia-api-key"]=s:i.baseQueryParameters["x-algolia-api-key"]=s;},batchRecommendRules({indexName:s,model:n,recommendRule:a},c){u("indexName","batchRecommendRules",s),u("model","batchRecommendRules",n);let l={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:a||{}};return i.request(l,c)},batchRecommendRulesWithHTTPInfo({indexName:s,model:n,recommendRule:a},c){u("indexName","batchRecommendRulesWithHTTPInfo",s),u("model","batchRecommendRulesWithHTTPInfo",n);let l={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:a||{}};return i.requestWithHttpInfo(l,c)},customDelete({path:s,parameters:n},a){u("path","customDelete",s);let d={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return i.request(d,a)},customDeleteWithHTTPInfo({path:s,parameters:n},a){u("path","customDeleteWithHTTPInfo",s);let d={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return i.requestWithHttpInfo(d,a)},customGet({path:s,parameters:n},a){u("path","customGet",s);let d={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return i.request(d,a)},customGetWithHTTPInfo({path:s,parameters:n},a){u("path","customGetWithHTTPInfo",s);let d={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return i.requestWithHttpInfo(d,a)},customPost({path:s,parameters:n,body:a},c){u("path","customPost",s);let l={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:a||{}};return i.request(l,c)},customPostWithHTTPInfo({path:s,parameters:n,body:a},c){u("path","customPostWithHTTPInfo",s);let l={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:a||{}};return i.requestWithHttpInfo(l,c)},customPut({path:s,parameters:n,body:a},c){u("path","customPut",s);let l={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:a||{}};return i.request(l,c)},customPutWithHTTPInfo({path:s,parameters:n,body:a},c){u("path","customPutWithHTTPInfo",s);let l={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:a||{}};return i.requestWithHttpInfo(l,c)},deleteRecommendRule({indexName:s,model:n,objectID:a},c){u("indexName","deleteRecommendRule",s),u("model","deleteRecommendRule",n),u("objectID","deleteRecommendRule",a);let l={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return i.request(l,c)},deleteRecommendRuleWithHTTPInfo({indexName:s,model:n,objectID:a},c){u("indexName","deleteRecommendRuleWithHTTPInfo",s),u("model","deleteRecommendRuleWithHTTPInfo",n),u("objectID","deleteRecommendRuleWithHTTPInfo",a);let l={method:"DELETE",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return i.requestWithHttpInfo(l,c)},getRecommendRule({indexName:s,model:n,objectID:a},c){u("indexName","getRecommendRule",s),u("model","getRecommendRule",n),u("objectID","getRecommendRule",a);let l={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return i.request(l,c)},getRecommendRuleWithHTTPInfo({indexName:s,model:n,objectID:a},c){u("indexName","getRecommendRuleWithHTTPInfo",s),u("model","getRecommendRuleWithHTTPInfo",n),u("objectID","getRecommendRuleWithHTTPInfo",a);let l={method:"GET",path:"/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{objectID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return i.requestWithHttpInfo(l,c)},getRecommendStatus({indexName:s,model:n,taskID:a},c){u("indexName","getRecommendStatus",s),u("model","getRecommendStatus",n),u("taskID","getRecommendStatus",a);let l={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{taskID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return i.request(l,c)},getRecommendStatusWithHTTPInfo({indexName:s,model:n,taskID:a},c){u("indexName","getRecommendStatusWithHTTPInfo",s),u("model","getRecommendStatusWithHTTPInfo",n),u("taskID","getRecommendStatusWithHTTPInfo",a);let l={method:"GET",path:"/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)).replace("{taskID}",encodeURIComponent(a)),queryParameters:{},headers:{}};return i.requestWithHttpInfo(l,c)},getRecommendations(s,n){s&&Array.isArray(s)&&(s={requests:s}),u("getRecommendationsParams","getRecommendations",s),u("getRecommendationsParams.requests","getRecommendations",s.requests);let h={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:s,useReadTransporter:true,cacheable:true};return i.request(h,n)},getRecommendationsWithHTTPInfo(s,n){s&&Array.isArray(s)&&(s={requests:s}),u("getRecommendationsParams","getRecommendationsWithHTTPInfo",s),u("getRecommendationsParams.requests","getRecommendationsWithHTTPInfo",s.requests);let h={method:"POST",path:"/1/indexes/*/recommendations",queryParameters:{},headers:{},data:s,useReadTransporter:true,cacheable:true};return i.requestWithHttpInfo(h,n)},searchRecommendRules({indexName:s,model:n,searchRecommendRulesParams:a},c){u("indexName","searchRecommendRules",s),u("model","searchRecommendRules",n);let l={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:a||{},useReadTransporter:true,cacheable:true};return i.request(l,c)},searchRecommendRulesWithHTTPInfo({indexName:s,model:n,searchRecommendRulesParams:a},c){u("indexName","searchRecommendRulesWithHTTPInfo",s),u("model","searchRecommendRulesWithHTTPInfo",n);let l={method:"POST",path:"/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}",encodeURIComponent(s)).replace("{model}",encodeURIComponent(n)),queryParameters:{},headers:{},data:a||{},useReadTransporter:true,cacheable:true};return i.requestWithHttpInfo(l,c)}}}function Dr(e,t,o){if(!e||typeof e!="string")throw new Error("`appId` is missing.");if(!t||typeof t!="string")throw new Error("`apiKey` is missing.");let{compression:r,...m}=o||{};return me({appId:e,apiKey:t,timeouts:{connect:1e3,read:2e3,write:3e4},logger:te(),requester:ie(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:N(),requestsCache:N({serializable:false}),hostsCache:A({caches:[Y({key:`${U}-${e}`}),N()]}),...m})}
|
|
12
12
|
|
|
13
13
|
exports.apiClientVersion = U;
|
|
14
|
-
exports.recommendClient =
|
|
14
|
+
exports.recommendClient = Dr;
|
|
15
15
|
|
|
16
16
|
}));
|
package/dist/builds/fetch.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createFetchRequester } from "@algolia/requester-fetch";
|
|
|
5
5
|
|
|
6
6
|
// src/recommendClient.ts
|
|
7
7
|
import { createAuth, createTransporter, getAlgoliaAgent, shuffle, validateRequired } from "@algolia/client-common";
|
|
8
|
-
var apiClientVersion = "5.
|
|
8
|
+
var apiClientVersion = "5.56.0";
|
|
9
9
|
function getDefaultHosts(appId) {
|
|
10
10
|
return [
|
|
11
11
|
{
|
|
@@ -134,6 +134,35 @@ function createRecommendClient({
|
|
|
134
134
|
};
|
|
135
135
|
return transporter.request(request, requestOptions);
|
|
136
136
|
},
|
|
137
|
+
/**
|
|
138
|
+
* 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).
|
|
139
|
+
*
|
|
140
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
141
|
+
*
|
|
142
|
+
* Required API Key ACLs:
|
|
143
|
+
* - editSettings
|
|
144
|
+
* @param batchRecommendRules - The batchRecommendRules object.
|
|
145
|
+
* @param batchRecommendRules.indexName - Name of the index on which to perform the operation.
|
|
146
|
+
* @param batchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
147
|
+
* @param batchRecommendRules.recommendRule - The recommendRule object.
|
|
148
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
149
|
+
* @see batchRecommendRules for the plain version.
|
|
150
|
+
*/
|
|
151
|
+
batchRecommendRulesWithHTTPInfo({ indexName, model, recommendRule }, requestOptions) {
|
|
152
|
+
validateRequired("indexName", "batchRecommendRulesWithHTTPInfo", indexName);
|
|
153
|
+
validateRequired("model", "batchRecommendRulesWithHTTPInfo", model);
|
|
154
|
+
const requestPath = "/1/indexes/{indexName}/{model}/recommend/rules/batch".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model));
|
|
155
|
+
const headers = {};
|
|
156
|
+
const queryParameters = {};
|
|
157
|
+
const request = {
|
|
158
|
+
method: "POST",
|
|
159
|
+
path: requestPath,
|
|
160
|
+
queryParameters,
|
|
161
|
+
headers,
|
|
162
|
+
data: recommendRule ? recommendRule : {}
|
|
163
|
+
};
|
|
164
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
165
|
+
},
|
|
137
166
|
/**
|
|
138
167
|
* This method lets you send requests to the Algolia REST API.
|
|
139
168
|
* @param customDelete - The customDelete object.
|
|
@@ -154,6 +183,29 @@ function createRecommendClient({
|
|
|
154
183
|
};
|
|
155
184
|
return transporter.request(request, requestOptions);
|
|
156
185
|
},
|
|
186
|
+
/**
|
|
187
|
+
* This method lets you send requests to the Algolia REST API.
|
|
188
|
+
*
|
|
189
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
190
|
+
* @param customDelete - The customDelete object.
|
|
191
|
+
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
|
|
192
|
+
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
193
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
194
|
+
* @see customDelete for the plain version.
|
|
195
|
+
*/
|
|
196
|
+
customDeleteWithHTTPInfo({ path, parameters }, requestOptions) {
|
|
197
|
+
validateRequired("path", "customDeleteWithHTTPInfo", path);
|
|
198
|
+
const requestPath = "/{path}".replace("{path}", path);
|
|
199
|
+
const headers = {};
|
|
200
|
+
const queryParameters = parameters ? parameters : {};
|
|
201
|
+
const request = {
|
|
202
|
+
method: "DELETE",
|
|
203
|
+
path: requestPath,
|
|
204
|
+
queryParameters,
|
|
205
|
+
headers
|
|
206
|
+
};
|
|
207
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
208
|
+
},
|
|
157
209
|
/**
|
|
158
210
|
* This method lets you send requests to the Algolia REST API.
|
|
159
211
|
* @param customGet - The customGet object.
|
|
@@ -174,6 +226,29 @@ function createRecommendClient({
|
|
|
174
226
|
};
|
|
175
227
|
return transporter.request(request, requestOptions);
|
|
176
228
|
},
|
|
229
|
+
/**
|
|
230
|
+
* This method lets you send requests to the Algolia REST API.
|
|
231
|
+
*
|
|
232
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
233
|
+
* @param customGet - The customGet object.
|
|
234
|
+
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
|
|
235
|
+
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
236
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
237
|
+
* @see customGet for the plain version.
|
|
238
|
+
*/
|
|
239
|
+
customGetWithHTTPInfo({ path, parameters }, requestOptions) {
|
|
240
|
+
validateRequired("path", "customGetWithHTTPInfo", path);
|
|
241
|
+
const requestPath = "/{path}".replace("{path}", path);
|
|
242
|
+
const headers = {};
|
|
243
|
+
const queryParameters = parameters ? parameters : {};
|
|
244
|
+
const request = {
|
|
245
|
+
method: "GET",
|
|
246
|
+
path: requestPath,
|
|
247
|
+
queryParameters,
|
|
248
|
+
headers
|
|
249
|
+
};
|
|
250
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
251
|
+
},
|
|
177
252
|
/**
|
|
178
253
|
* This method lets you send requests to the Algolia REST API.
|
|
179
254
|
* @param customPost - The customPost object.
|
|
@@ -196,6 +271,31 @@ function createRecommendClient({
|
|
|
196
271
|
};
|
|
197
272
|
return transporter.request(request, requestOptions);
|
|
198
273
|
},
|
|
274
|
+
/**
|
|
275
|
+
* This method lets you send requests to the Algolia REST API.
|
|
276
|
+
*
|
|
277
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
278
|
+
* @param customPost - The customPost object.
|
|
279
|
+
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
|
|
280
|
+
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
281
|
+
* @param customPost.body - Parameters to send with the custom request.
|
|
282
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
283
|
+
* @see customPost for the plain version.
|
|
284
|
+
*/
|
|
285
|
+
customPostWithHTTPInfo({ path, parameters, body }, requestOptions) {
|
|
286
|
+
validateRequired("path", "customPostWithHTTPInfo", path);
|
|
287
|
+
const requestPath = "/{path}".replace("{path}", path);
|
|
288
|
+
const headers = {};
|
|
289
|
+
const queryParameters = parameters ? parameters : {};
|
|
290
|
+
const request = {
|
|
291
|
+
method: "POST",
|
|
292
|
+
path: requestPath,
|
|
293
|
+
queryParameters,
|
|
294
|
+
headers,
|
|
295
|
+
data: body ? body : {}
|
|
296
|
+
};
|
|
297
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
298
|
+
},
|
|
199
299
|
/**
|
|
200
300
|
* This method lets you send requests to the Algolia REST API.
|
|
201
301
|
* @param customPut - The customPut object.
|
|
@@ -218,6 +318,31 @@ function createRecommendClient({
|
|
|
218
318
|
};
|
|
219
319
|
return transporter.request(request, requestOptions);
|
|
220
320
|
},
|
|
321
|
+
/**
|
|
322
|
+
* This method lets you send requests to the Algolia REST API.
|
|
323
|
+
*
|
|
324
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
325
|
+
* @param customPut - The customPut object.
|
|
326
|
+
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
|
|
327
|
+
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
328
|
+
* @param customPut.body - Parameters to send with the custom request.
|
|
329
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
330
|
+
* @see customPut for the plain version.
|
|
331
|
+
*/
|
|
332
|
+
customPutWithHTTPInfo({ path, parameters, body }, requestOptions) {
|
|
333
|
+
validateRequired("path", "customPutWithHTTPInfo", path);
|
|
334
|
+
const requestPath = "/{path}".replace("{path}", path);
|
|
335
|
+
const headers = {};
|
|
336
|
+
const queryParameters = parameters ? parameters : {};
|
|
337
|
+
const request = {
|
|
338
|
+
method: "PUT",
|
|
339
|
+
path: requestPath,
|
|
340
|
+
queryParameters,
|
|
341
|
+
headers,
|
|
342
|
+
data: body ? body : {}
|
|
343
|
+
};
|
|
344
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
345
|
+
},
|
|
221
346
|
/**
|
|
222
347
|
* Deletes a Recommend rule from a recommendation scenario.
|
|
223
348
|
*
|
|
@@ -244,6 +369,35 @@ function createRecommendClient({
|
|
|
244
369
|
};
|
|
245
370
|
return transporter.request(request, requestOptions);
|
|
246
371
|
},
|
|
372
|
+
/**
|
|
373
|
+
* Deletes a Recommend rule from a recommendation scenario.
|
|
374
|
+
*
|
|
375
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
376
|
+
*
|
|
377
|
+
* Required API Key ACLs:
|
|
378
|
+
* - editSettings
|
|
379
|
+
* @param deleteRecommendRule - The deleteRecommendRule object.
|
|
380
|
+
* @param deleteRecommendRule.indexName - Name of the index on which to perform the operation.
|
|
381
|
+
* @param deleteRecommendRule.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
382
|
+
* @param deleteRecommendRule.objectID - Unique record identifier.
|
|
383
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
384
|
+
* @see deleteRecommendRule for the plain version.
|
|
385
|
+
*/
|
|
386
|
+
deleteRecommendRuleWithHTTPInfo({ indexName, model, objectID }, requestOptions) {
|
|
387
|
+
validateRequired("indexName", "deleteRecommendRuleWithHTTPInfo", indexName);
|
|
388
|
+
validateRequired("model", "deleteRecommendRuleWithHTTPInfo", model);
|
|
389
|
+
validateRequired("objectID", "deleteRecommendRuleWithHTTPInfo", objectID);
|
|
390
|
+
const requestPath = "/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model)).replace("{objectID}", encodeURIComponent(objectID));
|
|
391
|
+
const headers = {};
|
|
392
|
+
const queryParameters = {};
|
|
393
|
+
const request = {
|
|
394
|
+
method: "DELETE",
|
|
395
|
+
path: requestPath,
|
|
396
|
+
queryParameters,
|
|
397
|
+
headers
|
|
398
|
+
};
|
|
399
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
400
|
+
},
|
|
247
401
|
/**
|
|
248
402
|
* Retrieves a Recommend rule that you previously created in the Algolia dashboard.
|
|
249
403
|
*
|
|
@@ -270,6 +424,35 @@ function createRecommendClient({
|
|
|
270
424
|
};
|
|
271
425
|
return transporter.request(request, requestOptions);
|
|
272
426
|
},
|
|
427
|
+
/**
|
|
428
|
+
* Retrieves a Recommend rule that you previously created in the Algolia dashboard.
|
|
429
|
+
*
|
|
430
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
431
|
+
*
|
|
432
|
+
* Required API Key ACLs:
|
|
433
|
+
* - settings
|
|
434
|
+
* @param getRecommendRule - The getRecommendRule object.
|
|
435
|
+
* @param getRecommendRule.indexName - Name of the index on which to perform the operation.
|
|
436
|
+
* @param getRecommendRule.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
437
|
+
* @param getRecommendRule.objectID - Unique record identifier.
|
|
438
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
439
|
+
* @see getRecommendRule for the plain version.
|
|
440
|
+
*/
|
|
441
|
+
getRecommendRuleWithHTTPInfo({ indexName, model, objectID }, requestOptions) {
|
|
442
|
+
validateRequired("indexName", "getRecommendRuleWithHTTPInfo", indexName);
|
|
443
|
+
validateRequired("model", "getRecommendRuleWithHTTPInfo", model);
|
|
444
|
+
validateRequired("objectID", "getRecommendRuleWithHTTPInfo", objectID);
|
|
445
|
+
const requestPath = "/1/indexes/{indexName}/{model}/recommend/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model)).replace("{objectID}", encodeURIComponent(objectID));
|
|
446
|
+
const headers = {};
|
|
447
|
+
const queryParameters = {};
|
|
448
|
+
const request = {
|
|
449
|
+
method: "GET",
|
|
450
|
+
path: requestPath,
|
|
451
|
+
queryParameters,
|
|
452
|
+
headers
|
|
453
|
+
};
|
|
454
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
455
|
+
},
|
|
273
456
|
/**
|
|
274
457
|
* Checks the status of a given task. Deleting a Recommend rule is asynchronous. When you delete a rule, a task is created on a queue and completed depending on the load on the server. The API response includes a task ID that you can use to check the status.
|
|
275
458
|
*
|
|
@@ -296,6 +479,35 @@ function createRecommendClient({
|
|
|
296
479
|
};
|
|
297
480
|
return transporter.request(request, requestOptions);
|
|
298
481
|
},
|
|
482
|
+
/**
|
|
483
|
+
* Checks the status of a given task. Deleting a Recommend rule is asynchronous. When you delete a rule, a task is created on a queue and completed depending on the load on the server. The API response includes a task ID that you can use to check the status.
|
|
484
|
+
*
|
|
485
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
486
|
+
*
|
|
487
|
+
* Required API Key ACLs:
|
|
488
|
+
* - editSettings
|
|
489
|
+
* @param getRecommendStatus - The getRecommendStatus object.
|
|
490
|
+
* @param getRecommendStatus.indexName - Name of the index on which to perform the operation.
|
|
491
|
+
* @param getRecommendStatus.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
492
|
+
* @param getRecommendStatus.taskID - Unique task identifier.
|
|
493
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
494
|
+
* @see getRecommendStatus for the plain version.
|
|
495
|
+
*/
|
|
496
|
+
getRecommendStatusWithHTTPInfo({ indexName, model, taskID }, requestOptions) {
|
|
497
|
+
validateRequired("indexName", "getRecommendStatusWithHTTPInfo", indexName);
|
|
498
|
+
validateRequired("model", "getRecommendStatusWithHTTPInfo", model);
|
|
499
|
+
validateRequired("taskID", "getRecommendStatusWithHTTPInfo", taskID);
|
|
500
|
+
const requestPath = "/1/indexes/{indexName}/{model}/task/{taskID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model)).replace("{taskID}", encodeURIComponent(taskID));
|
|
501
|
+
const headers = {};
|
|
502
|
+
const queryParameters = {};
|
|
503
|
+
const request = {
|
|
504
|
+
method: "GET",
|
|
505
|
+
path: requestPath,
|
|
506
|
+
queryParameters,
|
|
507
|
+
headers
|
|
508
|
+
};
|
|
509
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
510
|
+
},
|
|
299
511
|
/**
|
|
300
512
|
* Retrieves recommendations from selected AI models.
|
|
301
513
|
*
|
|
@@ -327,6 +539,44 @@ function createRecommendClient({
|
|
|
327
539
|
};
|
|
328
540
|
return transporter.request(request, requestOptions);
|
|
329
541
|
},
|
|
542
|
+
/**
|
|
543
|
+
* Retrieves recommendations from selected AI models.
|
|
544
|
+
*
|
|
545
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
546
|
+
*
|
|
547
|
+
* Required API Key ACLs:
|
|
548
|
+
* - search
|
|
549
|
+
* @param getRecommendationsParams - The getRecommendationsParams object.
|
|
550
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
551
|
+
* @see getRecommendations for the plain version.
|
|
552
|
+
*/
|
|
553
|
+
getRecommendationsWithHTTPInfo(getRecommendationsParams, requestOptions) {
|
|
554
|
+
if (getRecommendationsParams && Array.isArray(getRecommendationsParams)) {
|
|
555
|
+
const newSignatureRequest = {
|
|
556
|
+
requests: getRecommendationsParams
|
|
557
|
+
};
|
|
558
|
+
getRecommendationsParams = newSignatureRequest;
|
|
559
|
+
}
|
|
560
|
+
validateRequired("getRecommendationsParams", "getRecommendationsWithHTTPInfo", getRecommendationsParams);
|
|
561
|
+
validateRequired(
|
|
562
|
+
"getRecommendationsParams.requests",
|
|
563
|
+
"getRecommendationsWithHTTPInfo",
|
|
564
|
+
getRecommendationsParams.requests
|
|
565
|
+
);
|
|
566
|
+
const requestPath = "/1/indexes/*/recommendations";
|
|
567
|
+
const headers = {};
|
|
568
|
+
const queryParameters = {};
|
|
569
|
+
const request = {
|
|
570
|
+
method: "POST",
|
|
571
|
+
path: requestPath,
|
|
572
|
+
queryParameters,
|
|
573
|
+
headers,
|
|
574
|
+
data: getRecommendationsParams,
|
|
575
|
+
useReadTransporter: true,
|
|
576
|
+
cacheable: true
|
|
577
|
+
};
|
|
578
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
579
|
+
},
|
|
330
580
|
/**
|
|
331
581
|
* Searches for Recommend rules. Use an empty query to list all rules for this recommendation scenario.
|
|
332
582
|
*
|
|
@@ -354,6 +604,37 @@ function createRecommendClient({
|
|
|
354
604
|
cacheable: true
|
|
355
605
|
};
|
|
356
606
|
return transporter.request(request, requestOptions);
|
|
607
|
+
},
|
|
608
|
+
/**
|
|
609
|
+
* Searches for Recommend rules. Use an empty query to list all rules for this recommendation scenario.
|
|
610
|
+
*
|
|
611
|
+
* Resolves with the full HTTP response information: status code, headers (when the requester captures them), raw body and deserialized data. Bypasses the requests and responses caches: always performs the API call.
|
|
612
|
+
*
|
|
613
|
+
* Required API Key ACLs:
|
|
614
|
+
* - settings
|
|
615
|
+
* @param searchRecommendRules - The searchRecommendRules object.
|
|
616
|
+
* @param searchRecommendRules.indexName - Name of the index on which to perform the operation.
|
|
617
|
+
* @param searchRecommendRules.model - [Recommend model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
|
|
618
|
+
* @param searchRecommendRules.searchRecommendRulesParams - The searchRecommendRulesParams object.
|
|
619
|
+
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
620
|
+
* @see searchRecommendRules for the plain version.
|
|
621
|
+
*/
|
|
622
|
+
searchRecommendRulesWithHTTPInfo({ indexName, model, searchRecommendRulesParams }, requestOptions) {
|
|
623
|
+
validateRequired("indexName", "searchRecommendRulesWithHTTPInfo", indexName);
|
|
624
|
+
validateRequired("model", "searchRecommendRulesWithHTTPInfo", model);
|
|
625
|
+
const requestPath = "/1/indexes/{indexName}/{model}/recommend/rules/search".replace("{indexName}", encodeURIComponent(indexName)).replace("{model}", encodeURIComponent(model));
|
|
626
|
+
const headers = {};
|
|
627
|
+
const queryParameters = {};
|
|
628
|
+
const request = {
|
|
629
|
+
method: "POST",
|
|
630
|
+
path: requestPath,
|
|
631
|
+
queryParameters,
|
|
632
|
+
headers,
|
|
633
|
+
data: searchRecommendRulesParams ? searchRecommendRulesParams : {},
|
|
634
|
+
useReadTransporter: true,
|
|
635
|
+
cacheable: true
|
|
636
|
+
};
|
|
637
|
+
return transporter.requestWithHttpInfo(request, requestOptions);
|
|
357
638
|
}
|
|
358
639
|
};
|
|
359
640
|
}
|