@algolia/client-search 5.52.1 → 5.53.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 +88 -14
- package/dist/builds/browser.js +31 -14
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +3 -3
- package/dist/builds/fetch.js +35 -16
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +35 -16
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +35 -16
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +31 -14
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +88 -14
- package/dist/node.d.cts +88 -14
- package/dist/node.d.ts +88 -14
- package/dist/src/searchClient.cjs +31 -14
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +33 -19
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +88 -14
- package/package.json +9 -9
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@algolia/client-search"] = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function _(u){let n,m=`algolia-client-js-${u.key}`;function p(){return n===void 0&&(n=u.localStorage||window.localStorage),n}function l(){return JSON.parse(p().getItem(m)||"{}")}function f(e){p().setItem(m,JSON.stringify(e));}function c(){let e=u.timeToLive?u.timeToLive*1e3:null,r=l(),t=Object.fromEntries(Object.entries(r).filter(([,s])=>s.timestamp!==void 0));if(f(t),!e)return;let o=Object.fromEntries(Object.entries(t).filter(([,s])=>{let a=new Date().getTime();return !(s.timestamp+e<a)}));f(o);}return {get(e,r,t={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(c(),l()[JSON.stringify(e)])).then(o=>Promise.all([o?o.value:r(),o!==void 0])).then(([o,s])=>Promise.all([o,s||t.miss(o)])).then(([o])=>o)},set(e,r){return Promise.resolve().then(()=>{let t=l();return t[JSON.stringify(e)]={timestamp:new Date().getTime(),value:r},p().setItem(m,JSON.stringify(t)),r})},delete(e){return Promise.resolve().then(()=>{let r=l();delete r[JSON.stringify(e)],p().setItem(m,JSON.stringify(r));})},clear(){return Promise.resolve().then(()=>{p().removeItem(m);})}}}function se(){return {get(u,n,m={miss:()=>Promise.resolve()}){return n().then(l=>Promise.all([l,m.miss(l)])).then(([l])=>l)},set(u,n){return Promise.resolve(n)},delete(u){return Promise.resolve()},clear(){return Promise.resolve()}}}function I(u){let n=[...u.caches],m=n.shift();return m===void 0?se():{get(p,l,f={miss:()=>Promise.resolve()}){return m.get(p,l,f).catch(()=>I({caches:n}).get(p,l,f))},set(p,l){return m.set(p,l).catch(()=>I({caches:n}).set(p,l))},delete(p){return m.delete(p).catch(()=>I({caches:n}).delete(p))},clear(){return m.clear().catch(()=>I({caches:n}).clear())}}}function U(u={serializable:true}){let n={};return {get(m,p,l={miss:()=>Promise.resolve()}){let f=JSON.stringify(m);if(f in n)return Promise.resolve(u.serializable?JSON.parse(n[f]):n[f]);let c=p();return c.then(e=>l.miss(e)).then(()=>c)},set(m,p){return n[JSON.stringify(m)]=u.serializable?JSON.stringify(p):p,Promise.resolve(p)},delete(m){return delete n[JSON.stringify(m)],Promise.resolve()},clear(){return n={},Promise.resolve()}}}function oe(u){let n={value:`Algolia for JavaScript (${u})`,add(m){let p=`; ${m.segment}${m.version!==void 0?` (${m.version})`:""}`;return n.value.indexOf(p)===-1&&(n.value=`${n.value}${p}`),n}};return n}function M(u,n,m="WithinHeaders"){let p={"x-algolia-api-key":n,"x-algolia-application-id":u};return {headers(){return m==="WithinHeaders"?p:{}},queryParameters(){return m==="WithinQueryParameters"?p:{}}}}function O({func:u,validate:n,aggregator:m,error:p,timeout:l=()=>0}){let f=c=>new Promise((e,r)=>{u(c).then(async t=>(m&&await m(t),await n(t)?e(t):p&&await p.validate(t)?r(new Error(await p.message(t))):setTimeout(()=>{f(t).then(e).catch(r);},await l()))).catch(t=>{r(t);});});return f()}function W({algoliaAgents:u,client:n,version:m}){let p=oe(m).add({segment:n,version:m});return u.forEach(l=>p.add(l)),p}function $(){return {debug(u,n){return Promise.resolve()},info(u,n){return Promise.resolve()},error(u,n){return Promise.resolve()}}}var ae=750,K=120*1e3;function F(u,n="up"){let m=Date.now();function p(){return n==="up"||Date.now()-m>K}function l(){return n==="timed out"&&Date.now()-m<=K}return {...u,status:n,lastUpdate:m,isUp:p,isTimedOut:l}}var z=class extends Error{name="AlgoliaError";constructor(u,n){super(u),n&&(this.name=n);}};var J=class extends z{stackTrace;constructor(u,n,m){super(u,m),this.stackTrace=n;}},ne=class extends J{constructor(u){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",u,"RetryError");}},T=class extends J{status;constructor(u,n,m,p="ApiError"){super(u,m,p),this.status=n;}},ie=class extends z{response;constructor(u,n){super(u,"DeserializationError"),this.response=n;}},ue=class extends T{error;constructor(u,n,m,p){super(u,n,p,"DetailedApiError"),this.error=m;}};function V(u){let n=u;for(let m=u.length-1;m>0;m--){let p=Math.floor(Math.random()*(m+1)),l=u[m];n[m]=u[p],n[p]=l;}return n}function ce(u,n,m){let p=pe(m),l=`${u.protocol}://${u.url}${u.port?`:${u.port}`:""}/${n.charAt(0)==="/"?n.substring(1):n}`;return p.length&&(l+=`?${p}`),l}function pe(u){return Object.keys(u).filter(n=>u[n]!==void 0).sort().map(n=>`${n}=${encodeURIComponent(Object.prototype.toString.call(u[n])==="[object Array]"?u[n].join(","):u[n]).replace(/\+/g,"%20")}`).join("&")}function me(u,n){if(u.method==="GET"||u.data===void 0&&n.data===void 0)return;let m=Array.isArray(u.data)?u.data:{...u.data,...n.data};return JSON.stringify(m)}function de(u,n,m){let p={Accept:"application/json",...u,...n,...m},l={};return Object.keys(p).forEach(f=>{let c=p[f];l[f.toLowerCase()]=c;}),l}function he(u){try{return JSON.parse(u.content)}catch(n){throw new ie(n.message,u)}}function le({content:u,status:n},m){try{let p=JSON.parse(u);return "error"in p?new ue(p.message,n,p.error,m):new T(p.message,n,m)}catch{}return new T(u,n,m)}function Pe({isTimedOut:u,status:n}){return !u&&~~n===0}function fe({isTimedOut:u,status:n}){return u||Pe({isTimedOut:u,status:n})||~~(n/100)!==2&&~~(n/100)!==4}function qe({status:u}){return ~~(u/100)===2}function ye(u){return u.map(n=>X(n))}function X(u){let n=u.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...u,request:{...u.request,headers:{...u.request.headers,...n}}}}function Y({hosts:u,hostsCache:n,baseHeaders:m,logger:p,baseQueryParameters:l,algoliaAgent:f,timeouts:c,requester:e,requestsCache:r,responsesCache:t,compress:o,compression:s}){async function a(h){let P=await Promise.all(h.map(q=>n.get(q,()=>Promise.resolve(F(q))))),y=P.filter(q=>q.isUp()),R=P.filter(q=>q.isTimedOut()),x=[...y,...R];return {hosts:x.length>0?x:h,getTimeout(q,E){return (R.length===0&&q===0?1:R.length+3+q)*E}}}async function i(h,P,y){let R=[],x=me(h,P),w=de(m,h.headers,P.headers),q=s==="gzip"&&x!==void 0&&x.length>ae&&(h.method==="POST"||h.method==="PUT");q&&o===void 0&&p.info("Compression is disabled because no compress method is available.");let E=q&&o!==void 0,k=E?await o(x):x;E&&(w["content-encoding"]="gzip");let re=h.method==="GET"?{...h.data,...P.data}:{},A={...l,...h.queryParameters,...re};if(f.value&&(A["x-algolia-agent"]=f.value),P&&P.queryParameters)for(let g of Object.keys(P.queryParameters))!P.queryParameters[g]||Object.prototype.toString.call(P.queryParameters[g])==="[object Object]"?A[g]=P.queryParameters[g]:A[g]=P.queryParameters[g].toString();let D=0,H=async(g,j)=>{let b=g.pop();if(b===void 0)throw new ne(ye(R));let C={...c,...P.timeouts},G={data:k,headers:w,method:h.method,url:ce(b,h.path,A),connectTimeout:j(D,C.connect),responseTimeout:j(D,y?C.read:C.write)},B=N=>{let L={request:G,response:N,host:b,triesLeft:g.length};return R.push(L),L},S=await e.send(G);if(fe(S)){let N=B(S);return S.isTimedOut&&D++,p.info("Retryable failure",X(N)),await n.set(b,F(b,S.isTimedOut?"timed out":"down")),H(g,j)}if(qe(S))return he(S);throw B(S),le(S,R)},te=u.filter(g=>g.accept==="readWrite"||(y?g.accept==="read":g.accept==="write")),Q=await a(te);return H([...Q.hosts].reverse(),Q.getTimeout)}function d(h,P={}){let y=()=>i(h,P,R),R=h.useReadTransporter||h.method==="GET";if((P.cacheable||h.cacheable)!==true)return y();let w={request:h,requestOptions:P,transporter:{queryParameters:l,headers:m}};return t.get(w,()=>r.get(w,()=>r.set(w,y()).then(q=>Promise.all([r.delete(w),q]),q=>Promise.all([r.delete(w),Promise.reject(q)])).then(([q,E])=>E)),{miss:q=>t.set(w,q)})}return {hostsCache:n,requester:e,timeouts:c,logger:p,algoliaAgent:f,baseHeaders:m,baseQueryParameters:l,hosts:u,request:d,requestsCache:r,responsesCache:t}}function Z(){function u(n){return new Promise(m=>{let p=new XMLHttpRequest;p.open(n.method,n.url,true),Object.keys(n.headers).forEach(e=>p.setRequestHeader(e,n.headers[e]));let l=(e,r)=>setTimeout(()=>{p.abort(),m({status:0,content:r,isTimedOut:true});},e),f=l(n.connectTimeout,"Connection timeout"),c;p.onreadystatechange=()=>{p.readyState>p.OPENED&&c===void 0&&(clearTimeout(f),c=l(n.responseTimeout,"Socket timeout"));},p.onerror=()=>{p.status===0&&(clearTimeout(f),clearTimeout(c),m({content:p.responseText||"Network request failed",status:p.status,isTimedOut:false}));},p.onload=()=>{clearTimeout(f),clearTimeout(c),m({content:p.responseText,status:p.status,isTimedOut:false});},p.send(n.data);})}return {send:u}}var v="5.52.1";function Re(u){return [{url:`${u}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${u}.algolia.net`,accept:"write",protocol:"https"}].concat(V([{url:`${u}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${u}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${u}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function ee({appId:u,apiKey:n,authMode:m,algoliaAgents:p,...l}){let f=M(u,n,m),c=Y({hosts:Re(u),...l,algoliaAgent:W({algoliaAgents:p,client:"Search",version:v}),baseHeaders:{"content-type":"text/plain",...f.headers(),...l.baseHeaders},baseQueryParameters:{...f.queryParameters(),...l.baseQueryParameters}});return {transporter:c,appId:u,apiKey:n,clearCache(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then(()=>{})},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent(e,r){c.algoliaAgent.add({segment:e,version:r});},setClientApiKey({apiKey:e}){!m||m==="WithinHeaders"?c.baseHeaders["x-algolia-api-key"]=e:c.baseQueryParameters["x-algolia-api-key"]=e;},waitForTask({indexName:e,taskID:r,maxRetries:t=100,timeout:o=a=>Math.min(a*200,5e3)},s){let a=0;return O({func:()=>this.getTask({indexName:e,taskID:r},s),validate:i=>i.status==="published",aggregator:()=>a+=1,error:{validate:()=>a>=t,message:()=>`Stopped waiting for the task after ${t} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`},timeout:()=>o(a)})},waitForAppTask({taskID:e,maxRetries:r=100,timeout:t=s=>Math.min(s*200,5e3)},o){let s=0;return O({func:()=>this.getAppTask({taskID:e},o),validate:a=>a.status==="published",aggregator:()=>s+=1,error:{validate:()=>s>=r,message:()=>`Stopped waiting for the task after ${r} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`},timeout:()=>t(s)})},waitForApiKey({operation:e,key:r,apiKey:t,maxRetries:o=100,timeout:s=i=>Math.min(i*200,5e3)},a){let i=0,d={aggregator:()=>i+=1,error:{validate:()=>i>=o,message:()=>`Stopped waiting for the API key operation after ${o} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`},timeout:()=>s(i)};if(e==="update"){if(!t)throw new Error("`apiKey` is required when waiting for an `update` operation.");return O({...d,func:()=>this.getApiKey({key:r},a),validate:h=>{for(let P of Object.keys(t)){let y=t[P],R=h[P];if(Array.isArray(y)&&Array.isArray(R)){if(y.length!==R.length||y.some((x,w)=>x!==R[w]))return false}else if(y!==R)return false}return true}})}return O({...d,func:()=>this.getApiKey({key:r},a).catch(h=>{if(h.status!==404)throw h}),validate:h=>e==="add"?h!==void 0:h===void 0})},browseObjects({indexName:e,browseParams:r,...t},o){return O({func:s=>this.browse({indexName:e,browseParams:{cursor:s?s.cursor:void 0,hitsPerPage:1e3,...r}},o),validate:s=>s.cursor===void 0,...t})},browseRules({indexName:e,searchRulesParams:r,...t},o){let s={...r,hitsPerPage:r?.hitsPerPage||1e3};return O({func:a=>this.searchRules({indexName:e,searchRulesParams:{...s,page:a?a.page+1:s.page||0}},o),validate:a=>a.hits.length<s.hitsPerPage,...t})},browseSynonyms({indexName:e,searchSynonymsParams:r,...t},o){let s={...r,page:r?.page||0,hitsPerPage:1e3};return O({func:a=>{let i=this.searchSynonyms({indexName:e,searchSynonymsParams:{...s,page:s.page}},o);return s.page+=1,i},validate:a=>a.hits.length<s.hitsPerPage,...t})},async chunkedBatch({indexName:e,objects:r,action:t="addObject",waitForTasks:o,batchSize:s=1e3},a){let i=[],d=[],h=r.entries();for(let[P,y]of h)i.push({action:t,body:y}),(i.length===s||P===r.length-1)&&(d.push(await this.batch({indexName:e,batchWriteParams:{requests:i}},a)),i=[]);if(o)for(let P of d)await this.waitForTask({indexName:e,taskID:P.taskID});return d},async saveObjects({indexName:e,objects:r,waitForTasks:t,batchSize:o},s){return await this.chunkedBatch({indexName:e,objects:r,action:"addObject",waitForTasks:t,batchSize:o},s)},async deleteObjects({indexName:e,objectIDs:r,waitForTasks:t,batchSize:o},s){return await this.chunkedBatch({indexName:e,objects:r.map(a=>({objectID:a})),action:"deleteObject",waitForTasks:t,batchSize:o},s)},async partialUpdateObjects({indexName:e,objects:r,createIfNotExists:t,waitForTasks:o,batchSize:s},a){return await this.chunkedBatch({indexName:e,objects:r,action:t?"partialUpdateObject":"partialUpdateObjectNoCreate",batchSize:s,waitForTasks:o},a)},async replaceAllObjects({indexName:e,objects:r,batchSize:t,scopes:o},s){let a=Math.floor(Math.random()*1e6)+1e5,i=`${e}_tmp_${a}`;o===void 0&&(o=["settings","rules","synonyms"]);try{let d=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:i,scope:o}},s),h=await this.chunkedBatch({indexName:i,objects:r,waitForTasks:!0,batchSize:t},s);await this.waitForTask({indexName:i,taskID:d.taskID}),d=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:i,scope:o}},s),await this.waitForTask({indexName:i,taskID:d.taskID});let P=await this.operationIndex({indexName:i,operationIndexParams:{operation:"move",destination:e}},s);return await this.waitForTask({indexName:i,taskID:P.taskID}),{copyOperationResponse:d,batchResponses:h,moveOperationResponse:P}}catch(d){throw await this.deleteIndex({indexName:i}),d}},async indexExists({indexName:e}){try{await this.getSettings({indexName:e});}catch(r){if(r instanceof T&&r.status===404)return false;throw r}return true},searchForHits(e,r){return this.search(e,r)},searchForFacets(e,r){return this.search(e,r)},addApiKey(e,r){if(!e)throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");if(!e.acl)throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");let a={method:"POST",path:"/1/keys",queryParameters:{},headers:{},data:e};return c.request(a,r)},addOrUpdateObject({indexName:e,objectID:r,body:t},o){if(!e)throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");if(!t)throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");let d={method:"PUT",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{},data:t};return c.request(d,o)},appendSource(e,r){if(!e)throw new Error("Parameter `source` is required when calling `appendSource`.");if(!e.source)throw new Error("Parameter `source.source` is required when calling `appendSource`.");let a={method:"POST",path:"/1/security/sources/append",queryParameters:{},headers:{},data:e};return c.request(a,r)},assignUserId({xAlgoliaUserID:e,assignUserIdParams:r},t){if(!e)throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");if(!r)throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");if(!r.cluster)throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");let o="/1/clusters/mapping",s={},a={};e!==void 0&&(s["X-Algolia-User-ID"]=e.toString());let i={method:"POST",path:o,queryParameters:a,headers:s,data:r};return c.request(i,t)},batch({indexName:e,batchWriteParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `batch`.");if(!r)throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");if(!r.requests)throw new Error("Parameter `batchWriteParams.requests` is required when calling `batch`.");let i={method:"POST",path:"/1/indexes/{indexName}/batch".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},batchAssignUserIds({xAlgoliaUserID:e,batchAssignUserIdsParams:r},t){if(!e)throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");if(!r)throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");if(!r.cluster)throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");if(!r.users)throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");let o="/1/clusters/mapping/batch",s={},a={};e!==void 0&&(s["X-Algolia-User-ID"]=e.toString());let i={method:"POST",path:o,queryParameters:a,headers:s,data:r};return c.request(i,t)},batchDictionaryEntries({dictionaryName:e,batchDictionaryEntriesParams:r},t){if(!e)throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");if(!r)throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");if(!r.requests)throw new Error("Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`.");let i={method:"POST",path:"/1/dictionaries/{dictionaryName}/batch".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},browse({indexName:e,browseParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `browse`.");let i={method:"POST",path:"/1/indexes/{indexName}/browse".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:true};return c.request(i,t)},clearObjects({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `clearObjects`.");let a={method:"POST",path:"/1/indexes/{indexName}/clear".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},clearRules({indexName:e,forwardToReplicas:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `clearRules`.");let o="/1/indexes/{indexName}/rules/clear".replace("{indexName}",encodeURIComponent(e)),s={},a={};r!==void 0&&(a.forwardToReplicas=r.toString());let i={method:"POST",path:o,queryParameters:a,headers:s};return c.request(i,t)},clearSynonyms({indexName:e,forwardToReplicas:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");let o="/1/indexes/{indexName}/synonyms/clear".replace("{indexName}",encodeURIComponent(e)),s={},a={};r!==void 0&&(a.forwardToReplicas=r.toString());let i={method:"POST",path:o,queryParameters:a,headers:s};return c.request(i,t)},customDelete({path:e,parameters:r},t){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let i={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{}};return c.request(i,t)},customGet({path:e,parameters:r},t){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let i={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{}};return c.request(i,t)},customPost({path:e,parameters:r,body:t},o){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let d={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{},data:t||{}};return c.request(d,o)},customPut({path:e,parameters:r,body:t},o){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let d={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{},data:t||{}};return c.request(d,o)},deleteApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `deleteApiKey`.");let a={method:"DELETE",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},deleteBy({indexName:e,deleteByParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteBy`.");if(!r)throw new Error("Parameter `deleteByParams` is required when calling `deleteBy`.");let i={method:"POST",path:"/1/indexes/{indexName}/deleteByQuery".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},deleteIndex({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");let a={method:"DELETE",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},deleteObject({indexName:e,objectID:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteObject`.");let i={method:"DELETE",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(i,t)},deleteRule({indexName:e,objectID:r,forwardToReplicas:t},o){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteRule`.");let s="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),a={},i={};t!==void 0&&(i.forwardToReplicas=t.toString());let d={method:"DELETE",path:s,queryParameters:i,headers:a};return c.request(d,o)},deleteSource({source:e},r){if(!e)throw new Error("Parameter `source` is required when calling `deleteSource`.");let a={method:"DELETE",path:"/1/security/sources/{source}".replace("{source}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},deleteSynonym({indexName:e,objectID:r,forwardToReplicas:t},o){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");let s="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),a={},i={};t!==void 0&&(i.forwardToReplicas=t.toString());let d={method:"DELETE",path:s,queryParameters:i,headers:a};return c.request(d,o)},getApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `getApiKey`.");let a={method:"GET",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},getAppTask({taskID:e},r){if(!e)throw new Error("Parameter `taskID` is required when calling `getAppTask`.");let a={method:"GET",path:"/1/task/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},getDictionaryLanguages(e){let s={method:"GET",path:"/1/dictionaries/*/languages",queryParameters:{},headers:{}};return c.request(s,e)},getDictionarySettings(e){let s={method:"GET",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{}};return c.request(s,e)},getLogs({offset:e,length:r,indexName:t,type:o}={},s=void 0){let a="/1/logs",i={},d={};e!==void 0&&(d.offset=e.toString()),r!==void 0&&(d.length=r.toString()),t!==void 0&&(d.indexName=t.toString()),o!==void 0&&(d.type=o.toString());let h={method:"GET",path:a,queryParameters:d,headers:i};return c.request(h,s)},getObject({indexName:e,objectID:r,attributesToRetrieve:t},o){if(!e)throw new Error("Parameter `indexName` is required when calling `getObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getObject`.");let s="/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),a={},i={};t!==void 0&&(i.attributesToRetrieve=t.toString());let d={method:"GET",path:s,queryParameters:i,headers:a};return c.request(d,o)},getObjects(e,r){if(!e)throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");if(!e.requests)throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");let a={method:"POST",path:"/1/indexes/*/objects",queryParameters:{},headers:{},data:e,useReadTransporter:true,cacheable:true};return c.request(a,r)},getRule({indexName:e,objectID:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getRule`.");let i={method:"GET",path:"/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(i,t)},getSettings({indexName:e,getVersion:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getSettings`.");let o="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),s={},a={};r!==void 0&&(a.getVersion=r.toString());let i={method:"GET",path:o,queryParameters:a,headers:s};return c.request(i,t)},getSources(e){let s={method:"GET",path:"/1/security/sources",queryParameters:{},headers:{}};return c.request(s,e)},getSynonym({indexName:e,objectID:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getSynonym`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getSynonym`.");let i={method:"GET",path:"/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(i,t)},getTask({indexName:e,taskID:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getTask`.");if(!r)throw new Error("Parameter `taskID` is required when calling `getTask`.");let i={method:"GET",path:"/1/indexes/{indexName}/task/{taskID}".replace("{indexName}",encodeURIComponent(e)).replace("{taskID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(i,t)},getTopUserIds(e){let s={method:"GET",path:"/1/clusters/mapping/top",queryParameters:{},headers:{}};return c.request(s,e)},getUserId({userID:e},r){if(!e)throw new Error("Parameter `userID` is required when calling `getUserId`.");let a={method:"GET",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},hasPendingMappings({getClusters:e}={},r=void 0){let t="/1/clusters/mapping/pending",o={},s={};e!==void 0&&(s.getClusters=e.toString());let a={method:"GET",path:t,queryParameters:s,headers:o};return c.request(a,r)},listApiKeys(e){let s={method:"GET",path:"/1/keys",queryParameters:{},headers:{}};return c.request(s,e)},listClusters(e){let s={method:"GET",path:"/1/clusters",queryParameters:{},headers:{}};return c.request(s,e)},listIndices({page:e,hitsPerPage:r}={},t=void 0){let o="/1/indexes",s={},a={};e!==void 0&&(a.page=e.toString()),r!==void 0&&(a.hitsPerPage=r.toString());let i={method:"GET",path:o,queryParameters:a,headers:s};return c.request(i,t)},listUserIds({page:e,hitsPerPage:r}={},t=void 0){let o="/1/clusters/mapping",s={},a={};e!==void 0&&(a.page=e.toString()),r!==void 0&&(a.hitsPerPage=r.toString());let i={method:"GET",path:o,queryParameters:a,headers:s};return c.request(i,t)},multipleBatch(e,r){if(!e)throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");if(!e.requests)throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");let a={method:"POST",path:"/1/indexes/*/batch",queryParameters:{},headers:{},data:e};return c.request(a,r)},operationIndex({indexName:e,operationIndexParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `operationIndex`.");if(!r)throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");if(!r.operation)throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");if(!r.destination)throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");let i={method:"POST",path:"/1/indexes/{indexName}/operation".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},partialUpdateObject({indexName:e,objectID:r,attributesToUpdate:t,createIfNotExists:o},s){if(!e)throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");if(!t)throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");let a="/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),i={},d={};o!==void 0&&(d.createIfNotExists=o.toString());let h={method:"POST",path:a,queryParameters:d,headers:i,data:t};return c.request(h,s)},removeUserId({userID:e},r){if(!e)throw new Error("Parameter `userID` is required when calling `removeUserId`.");let a={method:"DELETE",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},replaceSources({source:e},r){if(!e)throw new Error("Parameter `source` is required when calling `replaceSources`.");let a={method:"PUT",path:"/1/security/sources",queryParameters:{},headers:{},data:e};return c.request(a,r)},restoreApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `restoreApiKey`.");let a={method:"POST",path:"/1/keys/{key}/restore".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(a,r)},saveObject({indexName:e,body:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `saveObject`.");if(!r)throw new Error("Parameter `body` is required when calling `saveObject`.");let i={method:"POST",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},saveRule({indexName:e,objectID:r,rule:t,forwardToReplicas:o},s){if(!e)throw new Error("Parameter `indexName` is required when calling `saveRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `saveRule`.");if(!t)throw new Error("Parameter `rule` is required when calling `saveRule`.");if(!t.objectID)throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");if(!t.consequence)throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");let a="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),i={},d={};o!==void 0&&(d.forwardToReplicas=o.toString());let h={method:"PUT",path:a,queryParameters:d,headers:i,data:t};return c.request(h,s)},saveRules({indexName:e,rules:r,forwardToReplicas:t,clearExistingRules:o},s){if(!e)throw new Error("Parameter `indexName` is required when calling `saveRules`.");if(!r)throw new Error("Parameter `rules` is required when calling `saveRules`.");let a="/1/indexes/{indexName}/rules/batch".replace("{indexName}",encodeURIComponent(e)),i={},d={};t!==void 0&&(d.forwardToReplicas=t.toString()),o!==void 0&&(d.clearExistingRules=o.toString());let h={method:"POST",path:a,queryParameters:d,headers:i,data:r};return c.request(h,s)},saveSynonym({indexName:e,objectID:r,synonymHit:t,forwardToReplicas:o},s){if(!e)throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");if(!r)throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");if(!t)throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");if(!t.objectID)throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");if(!t.type)throw new Error("Parameter `synonymHit.type` is required when calling `saveSynonym`.");let a="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),i={},d={};o!==void 0&&(d.forwardToReplicas=o.toString());let h={method:"PUT",path:a,queryParameters:d,headers:i,data:t};return c.request(h,s)},saveSynonyms({indexName:e,synonymHit:r,forwardToReplicas:t,replaceExistingSynonyms:o},s){if(!e)throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");if(!r)throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");let a="/1/indexes/{indexName}/synonyms/batch".replace("{indexName}",encodeURIComponent(e)),i={},d={};t!==void 0&&(d.forwardToReplicas=t.toString()),o!==void 0&&(d.replaceExistingSynonyms=o.toString());let h={method:"POST",path:a,queryParameters:d,headers:i,data:r};return c.request(h,s)},search(e,r){if(e&&Array.isArray(e)&&(e={requests:e.map(({params:d,...h})=>h.type==="facet"?{...h,...d,type:"facet"}:{...h,...d,facet:void 0,maxFacetHits:void 0,facetQuery:void 0})}),!e)throw new Error("Parameter `searchMethodParams` is required when calling `search`.");if(!e.requests)throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");let a={method:"POST",path:"/1/indexes/*/queries",queryParameters:{},headers:{},data:e,useReadTransporter:true,cacheable:true};return c.request(a,r)},searchDictionaryEntries({dictionaryName:e,searchDictionaryEntriesParams:r},t){if(!e)throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");if(!r)throw new Error("Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`.");if(!r.query)throw new Error("Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`.");let i={method:"POST",path:"/1/dictionaries/{dictionaryName}/search".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r,useReadTransporter:true,cacheable:true};return c.request(i,t)},searchForFacetValues({indexName:e,facetName:r,searchForFacetValuesRequest:t},o){if(!e)throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");if(!r)throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");let d={method:"POST",path:"/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}",encodeURIComponent(e)).replace("{facetName}",encodeURIComponent(r)),queryParameters:{},headers:{},data:t||{},useReadTransporter:true,cacheable:true};return c.request(d,o)},searchRules({indexName:e,searchRulesParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchRules`.");let i={method:"POST",path:"/1/indexes/{indexName}/rules/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:true,cacheable:true};return c.request(i,t)},searchSingleIndex({indexName:e,searchParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");let i={method:"POST",path:"/1/indexes/{indexName}/query".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:true,cacheable:true};return c.request(i,t)},searchSynonyms({indexName:e,searchSynonymsParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");let i={method:"POST",path:"/1/indexes/{indexName}/synonyms/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:true,cacheable:true};return c.request(i,t)},searchUserIds(e,r){if(!e)throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");if(!e.query)throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");let a={method:"POST",path:"/1/clusters/mapping/search",queryParameters:{},headers:{},data:e,useReadTransporter:true,cacheable:true};return c.request(a,r)},setDictionarySettings(e,r){if(!e)throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");if(!e.disableStandardEntries)throw new Error("Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`.");let a={method:"PUT",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{},data:e};return c.request(a,r)},setSettings({indexName:e,indexSettings:r,forwardToReplicas:t},o){if(!e)throw new Error("Parameter `indexName` is required when calling `setSettings`.");if(!r)throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");let s="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),a={},i={};t!==void 0&&(i.forwardToReplicas=t.toString());let d={method:"PUT",path:s,queryParameters:i,headers:a,data:r};return c.request(d,o)},updateApiKey({key:e,apiKey:r},t){if(!e)throw new Error("Parameter `key` is required when calling `updateApiKey`.");if(!r)throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");if(!r.acl)throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");let i={method:"PUT",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)}}}function Po(u,n,m){if(!u||typeof u!="string")throw new Error("`appId` is missing.");if(!n||typeof n!="string")throw new Error("`apiKey` is missing.");let{compression:p,...l}=m||{};return ee({appId:u,apiKey:n,timeouts:{connect:1e3,read:2e3,write:3e4},logger:$(),requester:Z(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:U(),requestsCache:U({serializable:false}),hostsCache:I({caches:[_({key:`${v}-${u}`}),U()]}),...l})}
|
|
7
|
+
function _(u){let n,m=`algolia-client-js-${u.key}`;function p(){return n===void 0&&(n=u.localStorage||window.localStorage),n}function l(){return JSON.parse(p().getItem(m)||"{}")}function P(r){p().setItem(m,JSON.stringify(r));}function c(){return new Promise(r=>setTimeout(r,0))}function e(){let r=u.timeToLive?u.timeToLive*1e3:null,t=l(),a=new Date().getTime(),s=false;return {namespace:Object.fromEntries(Object.entries(t).filter(([,i])=>!i||i.timestamp===void 0||r&&i.timestamp+r<a?(s=true,false):true)),changed:s}}return {get(r,t,a={miss:()=>Promise.resolve()}){return c().then(()=>{let{namespace:s,changed:o}=e(),i=s[JSON.stringify(r)];return o&&P(s),i?i.value:t().then(d=>a.miss(d).then(()=>d))})},set(r,t){return c().then(()=>{let a=l();return a[JSON.stringify(r)]={timestamp:new Date().getTime(),value:t},p().setItem(m,JSON.stringify(a)),t})},delete(r){return c().then(()=>{let t=l();delete t[JSON.stringify(r)],p().setItem(m,JSON.stringify(t));})},clear(){return Promise.resolve().then(()=>{p().removeItem(m);})}}}function se(){return {get(u,n,m={miss:()=>Promise.resolve()}){return n().then(l=>Promise.all([l,m.miss(l)])).then(([l])=>l)},set(u,n){return Promise.resolve(n)},delete(u){return Promise.resolve()},clear(){return Promise.resolve()}}}function I(u){let n=[...u.caches],m=n.shift();return m===void 0?se():{get(p,l,P={miss:()=>Promise.resolve()}){return m.get(p,l,P).catch(()=>I({caches:n}).get(p,l,P))},set(p,l){return m.set(p,l).catch(()=>I({caches:n}).set(p,l))},delete(p){return m.delete(p).catch(()=>I({caches:n}).delete(p))},clear(){return m.clear().catch(()=>I({caches:n}).clear())}}}function U(u={serializable:true}){let n={};return {get(m,p,l={miss:()=>Promise.resolve()}){let P=JSON.stringify(m);if(P in n)return Promise.resolve(u.serializable?JSON.parse(n[P]):n[P]);let c=p();return c.then(e=>l.miss(e)).then(()=>c)},set(m,p){return n[JSON.stringify(m)]=u.serializable?JSON.stringify(p):p,Promise.resolve(p)},delete(m){return delete n[JSON.stringify(m)],Promise.resolve()},clear(){return n={},Promise.resolve()}}}function oe(u){let n={value:`Algolia for JavaScript (${u})`,add(m){let p=`; ${m.segment}${m.version!==void 0?` (${m.version})`:""}`;return n.value.indexOf(p)===-1&&(n.value=`${n.value}${p}`),n}};return n}function M(u,n,m="WithinHeaders"){let p={"x-algolia-api-key":n,"x-algolia-application-id":u};return {headers(){return m==="WithinHeaders"?p:{}},queryParameters(){return m==="WithinQueryParameters"?p:{}}}}function O({func:u,validate:n,aggregator:m,error:p,timeout:l=()=>0}){let P=c=>new Promise((e,r)=>{u(c).then(async t=>(m&&await m(t),await n(t)?e(t):p&&await p.validate(t)?r(new Error(await p.message(t))):setTimeout(()=>{P(t).then(e).catch(r);},await l()))).catch(t=>{r(t);});});return P()}function $({algoliaAgents:u,client:n,version:m}){let p=oe(m).add({segment:n,version:m});return u.forEach(l=>p.add(l)),p}function W(){return {debug(u,n){return Promise.resolve()},info(u,n){return Promise.resolve()},error(u,n){return Promise.resolve()}}}var ae=750,K=120*1e3;function F(u,n="up"){let m=Date.now();function p(){return n==="up"||Date.now()-m>K}function l(){return n==="timed out"&&Date.now()-m<=K}return {...u,status:n,lastUpdate:m,isUp:p,isTimedOut:l}}var z=class extends Error{name="AlgoliaError";constructor(u,n){super(u),n&&(this.name=n);}};var J=class extends z{stackTrace;constructor(u,n,m){super(u,m),this.stackTrace=n;}},ne=class extends J{constructor(u){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",u,"RetryError");}},T=class extends J{status;constructor(u,n,m,p="ApiError"){super(u,m,p),this.status=n;}},ie=class extends z{response;constructor(u,n){super(u,"DeserializationError"),this.response=n;}},ue=class extends T{error;constructor(u,n,m,p){super(u,n,p,"DetailedApiError"),this.error=m;}};function V(u){let n=u;for(let m=u.length-1;m>0;m--){let p=Math.floor(Math.random()*(m+1)),l=u[m];n[m]=u[p],n[p]=l;}return n}function ce(u,n,m){let p=pe(m),l=`${u.protocol}://${u.url}${u.port?`:${u.port}`:""}/${n.charAt(0)==="/"?n.substring(1):n}`;return p.length&&(l+=`?${p}`),l}function pe(u){return Object.keys(u).filter(n=>u[n]!==void 0).sort().map(n=>`${n}=${encodeURIComponent(Object.prototype.toString.call(u[n])==="[object Array]"?u[n].join(","):u[n]).replace(/\+/g,"%20")}`).join("&")}function me(u,n){if(u.method==="GET"||u.data===void 0&&n.data===void 0)return;let m=Array.isArray(u.data)?u.data:{...u.data,...n.data};return JSON.stringify(m)}function de(u,n,m){let p={Accept:"application/json",...u,...n,...m},l={};return Object.keys(p).forEach(P=>{let c=p[P];l[P.toLowerCase()]=c;}),l}function he(u){try{return JSON.parse(u.content)}catch(n){throw new ie(n.message,u)}}function le({content:u,status:n},m){try{let p=JSON.parse(u);return "error"in p?new ue(p.message,n,p.error,m):new T(p.message,n,m)}catch{}return new T(u,n,m)}function Pe({isTimedOut:u,status:n}){return !u&&~~n===0}function fe({isTimedOut:u,status:n}){return u||Pe({isTimedOut:u,status:n})||~~(n/100)!==2&&~~(n/100)!==4}function qe({status:u}){return ~~(u/100)===2}function ye(u){return u.map(n=>X(n))}function X(u){let n=u.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...u,request:{...u.request,headers:{...u.request.headers,...n}}}}function Y({hosts:u,hostsCache:n,baseHeaders:m,logger:p,baseQueryParameters:l,algoliaAgent:P,timeouts:c,requester:e,requestsCache:r,responsesCache:t,compress:a,compression:s}){async function o(h){let f=await Promise.all(h.map(y=>n.get(y,()=>Promise.resolve(F(y))))),q=f.filter(y=>y.isUp()),R=f.filter(y=>y.isTimedOut()),x=[...q,...R];return {hosts:x.length>0?x:h,getTimeout(y,E){return (R.length===0&&y===0?1:R.length+3+y)*E}}}async function i(h,f,q){let R=[],x=me(h,f),w=de(m,h.headers,f.headers),y=s==="gzip"&&x!==void 0&&x.length>ae&&(h.method==="POST"||h.method==="PUT");y&&a===void 0&&p.info("Compression is disabled because no compress method is available.");let E=y&&a!==void 0,k=E?await a(x):x;E&&(w["content-encoding"]="gzip");let re=h.method==="GET"?{...h.data,...f.data}:{},A={...l,...h.queryParameters,...re};if(P.value&&(A["x-algolia-agent"]=P.value),f&&f.queryParameters)for(let g of Object.keys(f.queryParameters))!f.queryParameters[g]||Object.prototype.toString.call(f.queryParameters[g])==="[object Object]"?A[g]=f.queryParameters[g]:A[g]=f.queryParameters[g].toString();let v=0,H=async(g,j)=>{let b=g.pop();if(b===void 0)throw new ne(ye(R));let C={...c,...f.timeouts},G={data:k,headers:w,method:h.method,url:ce(b,h.path,A),connectTimeout:j(v,C.connect),responseTimeout:j(v,q?C.read:C.write)},B=N=>{let L={request:G,response:N,host:b,triesLeft:g.length};return R.push(L),L},S=await e.send(G);if(fe(S)){let N=B(S);return S.isTimedOut&&v++,p.info("Retryable failure",X(N)),await n.set(b,F(b,S.isTimedOut?"timed out":"down")),H(g,j)}if(qe(S))return he(S);throw B(S),le(S,R)},te=u.filter(g=>g.accept==="readWrite"||(q?g.accept==="read":g.accept==="write")),Q=await o(te);return H([...Q.hosts].reverse(),Q.getTimeout)}function d(h,f={}){let q=()=>i(h,f,R),R=h.useReadTransporter||h.method==="GET";if((f.cacheable||h.cacheable)!==true)return q();let w={request:h,requestOptions:f,transporter:{queryParameters:l,headers:m}};return t.get(w,()=>r.get(w,()=>r.set(w,q()).then(y=>Promise.all([r.delete(w),y]),y=>Promise.all([r.delete(w),Promise.reject(y)])).then(([y,E])=>E)),{miss:y=>t.set(w,y)})}return {hostsCache:n,requester:e,timeouts:c,logger:p,algoliaAgent:P,baseHeaders:m,baseQueryParameters:l,hosts:u,request:d,requestsCache:r,responsesCache:t}}function Z(){function u(n){return new Promise(m=>{let p=new XMLHttpRequest;p.open(n.method,n.url,true),Object.keys(n.headers).forEach(e=>p.setRequestHeader(e,n.headers[e]));let l=(e,r)=>setTimeout(()=>{p.abort(),m({status:0,content:r,isTimedOut:true});},e),P=l(n.connectTimeout,"Connection timeout"),c;p.onreadystatechange=()=>{p.readyState>p.OPENED&&c===void 0&&(clearTimeout(P),c=l(n.responseTimeout,"Socket timeout"));},p.onerror=()=>{p.status===0&&(clearTimeout(P),clearTimeout(c),m({content:p.responseText||"Network request failed",status:p.status,isTimedOut:false}));},p.onload=()=>{clearTimeout(P),clearTimeout(c),m({content:p.responseText,status:p.status,isTimedOut:false});},p.send(n.data);})}return {send:u}}var D="5.53.0";function Re(u){return [{url:`${u}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${u}.algolia.net`,accept:"write",protocol:"https"}].concat(V([{url:`${u}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${u}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${u}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function ee({appId:u,apiKey:n,authMode:m,algoliaAgents:p,...l}){let P=M(u,n,m),c=Y({hosts:Re(u),...l,algoliaAgent:$({algoliaAgents:p,client:"Search",version:D}),baseHeaders:{"content-type":"text/plain",...P.headers(),...l.baseHeaders},baseQueryParameters:{...P.queryParameters(),...l.baseQueryParameters}});return {transporter:c,appId:u,apiKey:n,clearCache(){return Promise.all([c.requestsCache.clear(),c.responsesCache.clear()]).then(()=>{})},get _ua(){return c.algoliaAgent.value},addAlgoliaAgent(e,r){c.algoliaAgent.add({segment:e,version:r});},setClientApiKey({apiKey:e}){!m||m==="WithinHeaders"?c.baseHeaders["x-algolia-api-key"]=e:c.baseQueryParameters["x-algolia-api-key"]=e;},waitForTask({indexName:e,taskID:r,maxRetries:t=100,timeout:a=o=>Math.min(o*200,5e3)},s){let o=0;return O({func:()=>this.getTask({indexName:e,taskID:r},s),validate:i=>i.status==="published",aggregator:()=>o+=1,error:{validate:()=>o>=t,message:()=>`Stopped waiting for the task after ${t} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`},timeout:()=>a(o)})},waitForAppTask({taskID:e,maxRetries:r=100,timeout:t=s=>Math.min(s*200,5e3)},a){let s=0;return O({func:()=>this.getAppTask({taskID:e},a),validate:o=>o.status==="published",aggregator:()=>s+=1,error:{validate:()=>s>=r,message:()=>`Stopped waiting for the task after ${r} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`},timeout:()=>t(s)})},waitForApiKey({operation:e,key:r,apiKey:t,maxRetries:a=100,timeout:s=i=>Math.min(i*200,5e3)},o){let i=0,d={aggregator:()=>i+=1,error:{validate:()=>i>=a,message:()=>`Stopped waiting for the API key operation after ${a} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`},timeout:()=>s(i)};if(e==="update"){if(!t)throw new Error("`apiKey` is required when waiting for an `update` operation.");return O({...d,func:()=>this.getApiKey({key:r},o),validate:h=>{for(let f of Object.keys(t)){let q=t[f],R=h[f];if(Array.isArray(q)&&Array.isArray(R)){if(q.length!==R.length||q.some((x,w)=>x!==R[w]))return false}else if(q!==R)return false}return true}})}return O({...d,func:()=>this.getApiKey({key:r},o).catch(h=>{if(h.status!==404)throw h}),validate:h=>e==="add"?h!==void 0:h===void 0})},browseObjects({indexName:e,browseParams:r,...t},a){return O({func:s=>this.browse({indexName:e,browseParams:{cursor:s?s.cursor:void 0,hitsPerPage:1e3,...r}},a),validate:s=>s.cursor===void 0,...t})},browseRules({indexName:e,searchRulesParams:r,...t},a){let s={...r,hitsPerPage:r?.hitsPerPage||1e3};return O({func:o=>this.searchRules({indexName:e,searchRulesParams:{...s,page:o?o.page+1:s.page||0}},a),validate:o=>o.hits.length<s.hitsPerPage,...t})},browseSynonyms({indexName:e,searchSynonymsParams:r,...t},a){let s={...r,page:r?.page||0,hitsPerPage:1e3};return O({func:o=>{let i=this.searchSynonyms({indexName:e,searchSynonymsParams:{...s,page:s.page}},a);return s.page+=1,i},validate:o=>o.hits.length<s.hitsPerPage,...t})},async chunkedBatch({indexName:e,objects:r,action:t="addObject",waitForTasks:a,batchSize:s=1e3,maxRetries:o=100},i){let d=[],h=[],f=r.entries();for(let[q,R]of f)d.push({action:t,body:R}),(d.length===s||q===r.length-1)&&(h.push(await this.batch({indexName:e,batchWriteParams:{requests:d}},i)),d=[]);if(a)for(let q of h)await this.waitForTask({indexName:e,taskID:q.taskID,maxRetries:o});return h},async saveObjects({indexName:e,objects:r,waitForTasks:t,batchSize:a,maxRetries:s},o){return await this.chunkedBatch({indexName:e,objects:r,action:"addObject",waitForTasks:t,batchSize:a,maxRetries:s},o)},async deleteObjects({indexName:e,objectIDs:r,waitForTasks:t,batchSize:a,maxRetries:s},o){return await this.chunkedBatch({indexName:e,objects:r.map(i=>({objectID:i})),action:"deleteObject",waitForTasks:t,batchSize:a,maxRetries:s},o)},async partialUpdateObjects({indexName:e,objects:r,createIfNotExists:t,waitForTasks:a,batchSize:s,maxRetries:o},i){return await this.chunkedBatch({indexName:e,objects:r,action:t?"partialUpdateObject":"partialUpdateObjectNoCreate",batchSize:s,waitForTasks:a,maxRetries:o},i)},async replaceAllObjects({indexName:e,objects:r,batchSize:t,scopes:a,maxRetries:s=100},o){let i=Math.floor(Math.random()*1e6)+1e5,d=`${e}_tmp_${i}`;a===void 0&&(a=["settings","rules","synonyms"]);try{let h=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:d,scope:a}},o),f=await this.chunkedBatch({indexName:d,objects:r,waitForTasks:!0,batchSize:t,maxRetries:s},o);await this.waitForTask({indexName:d,taskID:h.taskID,maxRetries:s}),h=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:d,scope:a}},o),await this.waitForTask({indexName:d,taskID:h.taskID,maxRetries:s});let q=await this.operationIndex({indexName:d,operationIndexParams:{operation:"move",destination:e}},o);return await this.waitForTask({indexName:d,taskID:q.taskID,maxRetries:s}),{copyOperationResponse:h,batchResponses:f,moveOperationResponse:q}}catch(h){throw await this.deleteIndex({indexName:d}),h}},async indexExists({indexName:e}){try{await this.getSettings({indexName:e});}catch(r){if(r instanceof T&&r.status===404)return false;throw r}return true},searchForHits(e,r){return this.search(e,r)},searchForFacets(e,r){return this.search(e,r)},addApiKey(e,r){if(!e)throw new Error("Parameter `apiKey` is required when calling `addApiKey`.");if(!e.acl)throw new Error("Parameter `apiKey.acl` is required when calling `addApiKey`.");let o={method:"POST",path:"/1/keys",queryParameters:{},headers:{},data:e};return c.request(o,r)},addOrUpdateObject({indexName:e,objectID:r,body:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");if(!t)throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");let d={method:"PUT",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{},data:t};return c.request(d,a)},appendSource(e,r){if(!e)throw new Error("Parameter `source` is required when calling `appendSource`.");if(!e.source)throw new Error("Parameter `source.source` is required when calling `appendSource`.");let o={method:"POST",path:"/1/security/sources/append",queryParameters:{},headers:{},data:e};return c.request(o,r)},assignUserId({xAlgoliaUserID:e,assignUserIdParams:r},t){if(!e)throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");if(!r)throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");if(!r.cluster)throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");let a="/1/clusters/mapping",s={},o={};e!==void 0&&(s["X-Algolia-User-ID"]=e.toString());let i={method:"POST",path:a,queryParameters:o,headers:s,data:r};return c.request(i,t)},batch({indexName:e,batchWriteParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `batch`.");if(!r)throw new Error("Parameter `batchWriteParams` is required when calling `batch`.");if(!r.requests)throw new Error("Parameter `batchWriteParams.requests` is required when calling `batch`.");let i={method:"POST",path:"/1/indexes/{indexName}/batch".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},batchAssignUserIds({xAlgoliaUserID:e,batchAssignUserIdsParams:r},t){if(!e)throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");if(!r)throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");if(!r.cluster)throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");if(!r.users)throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");let a="/1/clusters/mapping/batch",s={},o={};e!==void 0&&(s["X-Algolia-User-ID"]=e.toString());let i={method:"POST",path:a,queryParameters:o,headers:s,data:r};return c.request(i,t)},batchDictionaryEntries({dictionaryName:e,batchDictionaryEntriesParams:r},t){if(!e)throw new Error("Parameter `dictionaryName` is required when calling `batchDictionaryEntries`.");if(!r)throw new Error("Parameter `batchDictionaryEntriesParams` is required when calling `batchDictionaryEntries`.");if(!r.requests)throw new Error("Parameter `batchDictionaryEntriesParams.requests` is required when calling `batchDictionaryEntries`.");let i={method:"POST",path:"/1/dictionaries/{dictionaryName}/batch".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},browse({indexName:e,browseParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `browse`.");let i={method:"POST",path:"/1/indexes/{indexName}/browse".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:true};return c.request(i,t)},clearObjects({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `clearObjects`.");let o={method:"POST",path:"/1/indexes/{indexName}/clear".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},clearRules({indexName:e,forwardToReplicas:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `clearRules`.");let a="/1/indexes/{indexName}/rules/clear".replace("{indexName}",encodeURIComponent(e)),s={},o={};r!==void 0&&(o.forwardToReplicas=r.toString());let i={method:"POST",path:a,queryParameters:o,headers:s};return c.request(i,t)},clearSynonyms({indexName:e,forwardToReplicas:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");let a="/1/indexes/{indexName}/synonyms/clear".replace("{indexName}",encodeURIComponent(e)),s={},o={};r!==void 0&&(o.forwardToReplicas=r.toString());let i={method:"POST",path:a,queryParameters:o,headers:s};return c.request(i,t)},customDelete({path:e,parameters:r},t){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let i={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{}};return c.request(i,t)},customGet({path:e,parameters:r},t){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let i={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{}};return c.request(i,t)},customPost({path:e,parameters:r,body:t},a){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let d={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{},data:t||{}};return c.request(d,a)},customPut({path:e,parameters:r,body:t},a){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let d={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{},data:t||{}};return c.request(d,a)},deleteApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `deleteApiKey`.");let o={method:"DELETE",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},deleteBy({indexName:e,deleteByParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteBy`.");if(!r)throw new Error("Parameter `deleteByParams` is required when calling `deleteBy`.");let i={method:"POST",path:"/1/indexes/{indexName}/deleteByQuery".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},deleteIndex({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");let o={method:"DELETE",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},deleteObject({indexName:e,objectID:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteObject`.");let i={method:"DELETE",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(i,t)},deleteRule({indexName:e,objectID:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteRule`.");let s="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),o={},i={};t!==void 0&&(i.forwardToReplicas=t.toString());let d={method:"DELETE",path:s,queryParameters:i,headers:o};return c.request(d,a)},deleteSource({source:e},r){if(!e)throw new Error("Parameter `source` is required when calling `deleteSource`.");let o={method:"DELETE",path:"/1/security/sources/{source}".replace("{source}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},deleteSynonym({indexName:e,objectID:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");let s="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),o={},i={};t!==void 0&&(i.forwardToReplicas=t.toString());let d={method:"DELETE",path:s,queryParameters:i,headers:o};return c.request(d,a)},getApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `getApiKey`.");let o={method:"GET",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},getAppTask({taskID:e},r){if(!e)throw new Error("Parameter `taskID` is required when calling `getAppTask`.");let o={method:"GET",path:"/1/task/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},getDictionaryLanguages(e){let s={method:"GET",path:"/1/dictionaries/*/languages",queryParameters:{},headers:{}};return c.request(s,e)},getDictionarySettings(e){let s={method:"GET",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{}};return c.request(s,e)},getLogs({offset:e,length:r,indexName:t,type:a}={},s=void 0){let o="/1/logs",i={},d={};e!==void 0&&(d.offset=e.toString()),r!==void 0&&(d.length=r.toString()),t!==void 0&&(d.indexName=t.toString()),a!==void 0&&(d.type=a.toString());let h={method:"GET",path:o,queryParameters:d,headers:i};return c.request(h,s)},getObject({indexName:e,objectID:r,attributesToRetrieve:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getObject`.");let s="/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),o={},i={};t!==void 0&&(i.attributesToRetrieve=t.toString());let d={method:"GET",path:s,queryParameters:i,headers:o};return c.request(d,a)},getObjects(e,r){if(!e)throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");if(!e.requests)throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");let o={method:"POST",path:"/1/indexes/*/objects",queryParameters:{},headers:{},data:e,useReadTransporter:true,cacheable:true};return c.request(o,r)},getRule({indexName:e,objectID:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getRule`.");let i={method:"GET",path:"/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(i,t)},getSettings({indexName:e,getVersion:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getSettings`.");let a="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),s={},o={};r!==void 0&&(o.getVersion=r.toString());let i={method:"GET",path:a,queryParameters:o,headers:s};return c.request(i,t)},getSources(e){let s={method:"GET",path:"/1/security/sources",queryParameters:{},headers:{}};return c.request(s,e)},getSynonym({indexName:e,objectID:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getSynonym`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getSynonym`.");let i={method:"GET",path:"/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(i,t)},getTask({indexName:e,taskID:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `getTask`.");if(!r)throw new Error("Parameter `taskID` is required when calling `getTask`.");let i={method:"GET",path:"/1/indexes/{indexName}/task/{taskID}".replace("{indexName}",encodeURIComponent(e)).replace("{taskID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(i,t)},getTopUserIds(e){let s={method:"GET",path:"/1/clusters/mapping/top",queryParameters:{},headers:{}};return c.request(s,e)},getUserId({userID:e},r){if(!e)throw new Error("Parameter `userID` is required when calling `getUserId`.");let o={method:"GET",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},hasPendingMappings({getClusters:e}={},r=void 0){let t="/1/clusters/mapping/pending",a={},s={};e!==void 0&&(s.getClusters=e.toString());let o={method:"GET",path:t,queryParameters:s,headers:a};return c.request(o,r)},listApiKeys(e){let s={method:"GET",path:"/1/keys",queryParameters:{},headers:{}};return c.request(s,e)},listClusters(e){let s={method:"GET",path:"/1/clusters",queryParameters:{},headers:{}};return c.request(s,e)},listIndices({page:e,hitsPerPage:r}={},t=void 0){let a="/1/indexes",s={},o={};e!==void 0&&(o.page=e.toString()),r!==void 0&&(o.hitsPerPage=r.toString());let i={method:"GET",path:a,queryParameters:o,headers:s};return c.request(i,t)},listUserIds({page:e,hitsPerPage:r}={},t=void 0){let a="/1/clusters/mapping",s={},o={};e!==void 0&&(o.page=e.toString()),r!==void 0&&(o.hitsPerPage=r.toString());let i={method:"GET",path:a,queryParameters:o,headers:s};return c.request(i,t)},multipleBatch(e,r){if(!e)throw new Error("Parameter `batchParams` is required when calling `multipleBatch`.");if(!e.requests)throw new Error("Parameter `batchParams.requests` is required when calling `multipleBatch`.");let o={method:"POST",path:"/1/indexes/*/batch",queryParameters:{},headers:{},data:e};return c.request(o,r)},operationIndex({indexName:e,operationIndexParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `operationIndex`.");if(!r)throw new Error("Parameter `operationIndexParams` is required when calling `operationIndex`.");if(!r.operation)throw new Error("Parameter `operationIndexParams.operation` is required when calling `operationIndex`.");if(!r.destination)throw new Error("Parameter `operationIndexParams.destination` is required when calling `operationIndex`.");let i={method:"POST",path:"/1/indexes/{indexName}/operation".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},partialUpdateObject({indexName:e,objectID:r,attributesToUpdate:t,createIfNotExists:a},s){if(!e)throw new Error("Parameter `indexName` is required when calling `partialUpdateObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `partialUpdateObject`.");if(!t)throw new Error("Parameter `attributesToUpdate` is required when calling `partialUpdateObject`.");let o="/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),i={},d={};a!==void 0&&(d.createIfNotExists=a.toString());let h={method:"POST",path:o,queryParameters:d,headers:i,data:t};return c.request(h,s)},removeUserId({userID:e},r){if(!e)throw new Error("Parameter `userID` is required when calling `removeUserId`.");let o={method:"DELETE",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},replaceSources({source:e},r){if(!e)throw new Error("Parameter `source` is required when calling `replaceSources`.");let o={method:"PUT",path:"/1/security/sources",queryParameters:{},headers:{},data:e};return c.request(o,r)},restoreApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `restoreApiKey`.");let o={method:"POST",path:"/1/keys/{key}/restore".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(o,r)},saveObject({indexName:e,body:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `saveObject`.");if(!r)throw new Error("Parameter `body` is required when calling `saveObject`.");let i={method:"POST",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)},saveRule({indexName:e,objectID:r,rule:t,forwardToReplicas:a},s){if(!e)throw new Error("Parameter `indexName` is required when calling `saveRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `saveRule`.");if(!t)throw new Error("Parameter `rule` is required when calling `saveRule`.");if(!t.objectID)throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");if(!t.consequence)throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");let o="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),i={},d={};a!==void 0&&(d.forwardToReplicas=a.toString());let h={method:"PUT",path:o,queryParameters:d,headers:i,data:t};return c.request(h,s)},saveRules({indexName:e,rules:r,forwardToReplicas:t,clearExistingRules:a},s){if(!e)throw new Error("Parameter `indexName` is required when calling `saveRules`.");if(!r)throw new Error("Parameter `rules` is required when calling `saveRules`.");let o="/1/indexes/{indexName}/rules/batch".replace("{indexName}",encodeURIComponent(e)),i={},d={};t!==void 0&&(d.forwardToReplicas=t.toString()),a!==void 0&&(d.clearExistingRules=a.toString());let h={method:"POST",path:o,queryParameters:d,headers:i,data:r};return c.request(h,s)},saveSynonym({indexName:e,objectID:r,synonymHit:t,forwardToReplicas:a},s){if(!e)throw new Error("Parameter `indexName` is required when calling `saveSynonym`.");if(!r)throw new Error("Parameter `objectID` is required when calling `saveSynonym`.");if(!t)throw new Error("Parameter `synonymHit` is required when calling `saveSynonym`.");if(!t.objectID)throw new Error("Parameter `synonymHit.objectID` is required when calling `saveSynonym`.");if(!t.type)throw new Error("Parameter `synonymHit.type` is required when calling `saveSynonym`.");let o="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),i={},d={};a!==void 0&&(d.forwardToReplicas=a.toString());let h={method:"PUT",path:o,queryParameters:d,headers:i,data:t};return c.request(h,s)},saveSynonyms({indexName:e,synonymHit:r,forwardToReplicas:t,replaceExistingSynonyms:a},s){if(!e)throw new Error("Parameter `indexName` is required when calling `saveSynonyms`.");if(!r)throw new Error("Parameter `synonymHit` is required when calling `saveSynonyms`.");let o="/1/indexes/{indexName}/synonyms/batch".replace("{indexName}",encodeURIComponent(e)),i={},d={};t!==void 0&&(d.forwardToReplicas=t.toString()),a!==void 0&&(d.replaceExistingSynonyms=a.toString());let h={method:"POST",path:o,queryParameters:d,headers:i,data:r};return c.request(h,s)},search(e,r){if(e&&Array.isArray(e)&&(e={requests:e.map(({params:d,...h})=>h.type==="facet"?{...h,...d,type:"facet"}:{...h,...d,facet:void 0,maxFacetHits:void 0,facetQuery:void 0})}),!e)throw new Error("Parameter `searchMethodParams` is required when calling `search`.");if(!e.requests)throw new Error("Parameter `searchMethodParams.requests` is required when calling `search`.");let o={method:"POST",path:"/1/indexes/*/queries",queryParameters:{},headers:{},data:e,useReadTransporter:true,cacheable:true};return c.request(o,r)},searchDictionaryEntries({dictionaryName:e,searchDictionaryEntriesParams:r},t){if(!e)throw new Error("Parameter `dictionaryName` is required when calling `searchDictionaryEntries`.");if(!r)throw new Error("Parameter `searchDictionaryEntriesParams` is required when calling `searchDictionaryEntries`.");if(!r.query)throw new Error("Parameter `searchDictionaryEntriesParams.query` is required when calling `searchDictionaryEntries`.");let i={method:"POST",path:"/1/dictionaries/{dictionaryName}/search".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r,useReadTransporter:true,cacheable:true};return c.request(i,t)},searchForFacetValues({indexName:e,facetName:r,searchForFacetValuesRequest:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");if(!r)throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");let d={method:"POST",path:"/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}",encodeURIComponent(e)).replace("{facetName}",encodeURIComponent(r)),queryParameters:{},headers:{},data:t||{},useReadTransporter:true,cacheable:true};return c.request(d,a)},searchRules({indexName:e,searchRulesParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchRules`.");let i={method:"POST",path:"/1/indexes/{indexName}/rules/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:true,cacheable:true};return c.request(i,t)},searchSingleIndex({indexName:e,searchParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");let i={method:"POST",path:"/1/indexes/{indexName}/query".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:true,cacheable:true};return c.request(i,t)},searchSynonyms({indexName:e,searchSynonymsParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");let i={method:"POST",path:"/1/indexes/{indexName}/synonyms/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:true,cacheable:true};return c.request(i,t)},searchUserIds(e,r){if(!e)throw new Error("Parameter `searchUserIdsParams` is required when calling `searchUserIds`.");if(!e.query)throw new Error("Parameter `searchUserIdsParams.query` is required when calling `searchUserIds`.");let o={method:"POST",path:"/1/clusters/mapping/search",queryParameters:{},headers:{},data:e,useReadTransporter:true,cacheable:true};return c.request(o,r)},setDictionarySettings(e,r){if(!e)throw new Error("Parameter `dictionarySettingsParams` is required when calling `setDictionarySettings`.");if(!e.disableStandardEntries)throw new Error("Parameter `dictionarySettingsParams.disableStandardEntries` is required when calling `setDictionarySettings`.");let o={method:"PUT",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{},data:e};return c.request(o,r)},setSettings({indexName:e,indexSettings:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `setSettings`.");if(!r)throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");let s="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),o={},i={};t!==void 0&&(i.forwardToReplicas=t.toString());let d={method:"PUT",path:s,queryParameters:i,headers:o,data:r};return c.request(d,a)},updateApiKey({key:e,apiKey:r},t){if(!e)throw new Error("Parameter `key` is required when calling `updateApiKey`.");if(!r)throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");if(!r.acl)throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");let i={method:"PUT",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(i,t)}}}function Ro(u,n,m){if(!u||typeof u!="string")throw new Error("`appId` is missing.");if(!n||typeof n!="string")throw new Error("`apiKey` is missing.");let{compression:p,...l}=m||{};return ee({appId:u,apiKey:n,timeouts:{connect:1e3,read:2e3,write:3e4},logger:W(),requester:Z(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:U(),requestsCache:U({serializable:false}),hostsCache:I({caches:[_({key:`${D}-${u}`}),U()]}),...l})}
|
|
8
8
|
|
|
9
|
-
exports.apiClientVersion =
|
|
10
|
-
exports.searchClient =
|
|
9
|
+
exports.apiClientVersion = D;
|
|
10
|
+
exports.searchClient = Ro;
|
|
11
11
|
|
|
12
12
|
}));
|
package/dist/builds/fetch.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
getAlgoliaAgent,
|
|
23
23
|
shuffle
|
|
24
24
|
} from "@algolia/client-common";
|
|
25
|
-
var apiClientVersion = "5.
|
|
25
|
+
var apiClientVersion = "5.53.0";
|
|
26
26
|
function getDefaultHosts(appId) {
|
|
27
27
|
return [
|
|
28
28
|
{
|
|
@@ -356,9 +356,17 @@ function createSearchClient({
|
|
|
356
356
|
* @param chunkedBatch.action - The `batch` `action` to perform on the given array of `objects`, defaults to `addObject`.
|
|
357
357
|
* @param chunkedBatch.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
358
358
|
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
359
|
+
* @param chunkedBatch.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
359
360
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
360
361
|
*/
|
|
361
|
-
async chunkedBatch({
|
|
362
|
+
async chunkedBatch({
|
|
363
|
+
indexName,
|
|
364
|
+
objects,
|
|
365
|
+
action = "addObject",
|
|
366
|
+
waitForTasks,
|
|
367
|
+
batchSize = 1e3,
|
|
368
|
+
maxRetries = 100
|
|
369
|
+
}, requestOptions) {
|
|
362
370
|
let requests = [];
|
|
363
371
|
const responses = [];
|
|
364
372
|
const objectEntries = objects.entries();
|
|
@@ -371,7 +379,7 @@ function createSearchClient({
|
|
|
371
379
|
}
|
|
372
380
|
if (waitForTasks) {
|
|
373
381
|
for (const resp of responses) {
|
|
374
|
-
await this.waitForTask({ indexName, taskID: resp.taskID });
|
|
382
|
+
await this.waitForTask({ indexName, taskID: resp.taskID, maxRetries });
|
|
375
383
|
}
|
|
376
384
|
}
|
|
377
385
|
return responses;
|
|
@@ -385,11 +393,12 @@ function createSearchClient({
|
|
|
385
393
|
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
386
394
|
* @param saveObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
387
395
|
* @param saveObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
396
|
+
* @param saveObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
388
397
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
389
398
|
*/
|
|
390
|
-
async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
|
|
399
|
+
async saveObjects({ indexName, objects, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
391
400
|
return await this.chunkedBatch(
|
|
392
|
-
{ indexName, objects, action: "addObject", waitForTasks, batchSize },
|
|
401
|
+
{ indexName, objects, action: "addObject", waitForTasks, batchSize, maxRetries },
|
|
393
402
|
requestOptions
|
|
394
403
|
);
|
|
395
404
|
},
|
|
@@ -402,16 +411,18 @@ function createSearchClient({
|
|
|
402
411
|
* @param deleteObjects.objectIDs - The objectIDs to delete.
|
|
403
412
|
* @param deleteObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
404
413
|
* @param deleteObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
414
|
+
* @param deleteObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
405
415
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
406
416
|
*/
|
|
407
|
-
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
|
|
417
|
+
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
408
418
|
return await this.chunkedBatch(
|
|
409
419
|
{
|
|
410
420
|
indexName,
|
|
411
421
|
objects: objectIDs.map((objectID) => ({ objectID })),
|
|
412
422
|
action: "deleteObject",
|
|
413
423
|
waitForTasks,
|
|
414
|
-
batchSize
|
|
424
|
+
batchSize,
|
|
425
|
+
maxRetries
|
|
415
426
|
},
|
|
416
427
|
requestOptions
|
|
417
428
|
);
|
|
@@ -426,16 +437,18 @@ function createSearchClient({
|
|
|
426
437
|
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail.
|
|
427
438
|
* @param partialUpdateObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
428
439
|
* @param partialUpdateObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
440
|
+
* @param partialUpdateObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
429
441
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
430
442
|
*/
|
|
431
|
-
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
|
|
443
|
+
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize, maxRetries }, requestOptions) {
|
|
432
444
|
return await this.chunkedBatch(
|
|
433
445
|
{
|
|
434
446
|
indexName,
|
|
435
447
|
objects,
|
|
436
448
|
action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
|
|
437
449
|
batchSize,
|
|
438
|
-
waitForTasks
|
|
450
|
+
waitForTasks,
|
|
451
|
+
maxRetries
|
|
439
452
|
},
|
|
440
453
|
requestOptions
|
|
441
454
|
);
|
|
@@ -450,9 +463,10 @@ function createSearchClient({
|
|
|
450
463
|
* @param replaceAllObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
451
464
|
* @param replaceAllObjects.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `objects.length / batchSize`. Defaults to 1000.
|
|
452
465
|
* @param replaceAllObjects.scopes - The `scopes` to keep from the index. Defaults to ['settings', 'rules', 'synonyms'].
|
|
466
|
+
* @param replaceAllObjects.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
453
467
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch`, `operationIndex` and `getTask` method and merged with the transporter requestOptions.
|
|
454
468
|
*/
|
|
455
|
-
async replaceAllObjects({ indexName, objects, batchSize, scopes }, requestOptions) {
|
|
469
|
+
async replaceAllObjects({ indexName, objects, batchSize, scopes, maxRetries = 100 }, requestOptions) {
|
|
456
470
|
const randomSuffix = Math.floor(Math.random() * 1e6) + 1e5;
|
|
457
471
|
const tmpIndexName = `${indexName}_tmp_${randomSuffix}`;
|
|
458
472
|
if (scopes === void 0) {
|
|
@@ -471,12 +485,13 @@ function createSearchClient({
|
|
|
471
485
|
requestOptions
|
|
472
486
|
);
|
|
473
487
|
const batchResponses = await this.chunkedBatch(
|
|
474
|
-
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize },
|
|
488
|
+
{ indexName: tmpIndexName, objects, waitForTasks: true, batchSize, maxRetries },
|
|
475
489
|
requestOptions
|
|
476
490
|
);
|
|
477
491
|
await this.waitForTask({
|
|
478
492
|
indexName: tmpIndexName,
|
|
479
|
-
taskID: copyOperationResponse.taskID
|
|
493
|
+
taskID: copyOperationResponse.taskID,
|
|
494
|
+
maxRetries
|
|
480
495
|
});
|
|
481
496
|
copyOperationResponse = await this.operationIndex(
|
|
482
497
|
{
|
|
@@ -491,7 +506,8 @@ function createSearchClient({
|
|
|
491
506
|
);
|
|
492
507
|
await this.waitForTask({
|
|
493
508
|
indexName: tmpIndexName,
|
|
494
|
-
taskID: copyOperationResponse.taskID
|
|
509
|
+
taskID: copyOperationResponse.taskID,
|
|
510
|
+
maxRetries
|
|
495
511
|
});
|
|
496
512
|
const moveOperationResponse = await this.operationIndex(
|
|
497
513
|
{
|
|
@@ -502,7 +518,8 @@ function createSearchClient({
|
|
|
502
518
|
);
|
|
503
519
|
await this.waitForTask({
|
|
504
520
|
indexName: tmpIndexName,
|
|
505
|
-
taskID: moveOperationResponse.taskID
|
|
521
|
+
taskID: moveOperationResponse.taskID,
|
|
522
|
+
maxRetries
|
|
506
523
|
});
|
|
507
524
|
return { copyOperationResponse, batchResponses, moveOperationResponse };
|
|
508
525
|
} catch (error) {
|
|
@@ -2420,6 +2437,7 @@ function searchClient(appId, apiKey, options) {
|
|
|
2420
2437
|
* @param accountCopyIndex.destinationApiKey - The API Key of the `destinationAppID` to write the index to, must have write ACLs.
|
|
2421
2438
|
* @param accountCopyIndex.destinationIndexName - The name of the index to write the copied index to.
|
|
2422
2439
|
* @param accountCopyIndex.batchSize - The size of the chunk of `objects`. Defaults to 1000.
|
|
2440
|
+
* @param accountCopyIndex.maxRetries - The maximum number of retries when polling for task completion. 100 by default.
|
|
2423
2441
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `setSettings`, `saveRules`, `saveSynonyms` and `saveObjects` method and merged with the transporter requestOptions.
|
|
2424
2442
|
*/
|
|
2425
2443
|
async accountCopyIndex({
|
|
@@ -2427,7 +2445,8 @@ function searchClient(appId, apiKey, options) {
|
|
|
2427
2445
|
destinationAppID,
|
|
2428
2446
|
destinationApiKey,
|
|
2429
2447
|
destinationIndexName,
|
|
2430
|
-
batchSize
|
|
2448
|
+
batchSize,
|
|
2449
|
+
maxRetries = 100
|
|
2431
2450
|
}, requestOptions) {
|
|
2432
2451
|
const responses = [];
|
|
2433
2452
|
if (this.appId === destinationAppID) {
|
|
@@ -2499,7 +2518,7 @@ function searchClient(appId, apiKey, options) {
|
|
|
2499
2518
|
}
|
|
2500
2519
|
});
|
|
2501
2520
|
for (const response of responses) {
|
|
2502
|
-
await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID });
|
|
2521
|
+
await destinationClient.waitForTask({ indexName: destinationIndexName, taskID: response.taskID, maxRetries });
|
|
2503
2522
|
}
|
|
2504
2523
|
},
|
|
2505
2524
|
/**
|