@algolia/client-search 5.50.1 → 5.51.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 +113 -6
- package/dist/builds/browser.js +10 -10
- 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 +2 -2
- package/dist/builds/fetch.js +10 -10
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +10 -10
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +10 -10
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +10 -10
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +113 -6
- package/dist/node.d.cts +113 -6
- package/dist/node.d.ts +113 -6
- package/dist/src/searchClient.cjs +10 -10
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +10 -10
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +113 -6
- package/package.json +6 -6
|
@@ -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,p=`algolia-client-js-${u.key}`;function m(){return n===void 0&&(n=u.localStorage||window.localStorage),n}function l(){return JSON.parse(m().getItem(p)||"{}")}function f(e){m().setItem(p,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},m().setItem(p,JSON.stringify(t)),r})},delete(e){return Promise.resolve().then(()=>{let r=l();delete r[JSON.stringify(e)],m().setItem(p,JSON.stringify(r));})},clear(){return Promise.resolve().then(()=>{m().removeItem(p);})}}}function se(){return {get(u,n,p={miss:()=>Promise.resolve()}){return n().then(l=>Promise.all([l,p.miss(l)])).then(([l])=>l)},set(u,n){return Promise.resolve(n)},delete(u){return Promise.resolve()},clear(){return Promise.resolve()}}}function b(u){let n=[...u.caches],p=n.shift();return p===void 0?se():{get(m,l,f={miss:()=>Promise.resolve()}){return p.get(m,l,f).catch(()=>b({caches:n}).get(m,l,f))},set(m,l){return p.set(m,l).catch(()=>b({caches:n}).set(m,l))},delete(m){return p.delete(m).catch(()=>b({caches:n}).delete(m))},clear(){return p.clear().catch(()=>b({caches:n}).clear())}}}function U(u={serializable:true}){let n={};return {get(p,m,l={miss:()=>Promise.resolve()}){let f=JSON.stringify(p);if(f in n)return Promise.resolve(u.serializable?JSON.parse(n[f]):n[f]);let c=m();return c.then(e=>l.miss(e)).then(()=>c)},set(p,m){return n[JSON.stringify(p)]=u.serializable?JSON.stringify(m):m,Promise.resolve(m)},delete(p){return delete n[JSON.stringify(p)],Promise.resolve()},clear(){return n={},Promise.resolve()}}}function oe(u){let n={value:`Algolia for JavaScript (${u})`,add(p){let m=`; ${p.segment}${p.version!==void 0?` (${p.version})`:""}`;return n.value.indexOf(m)===-1&&(n.value=`${n.value}${m}`),n}};return n}function M(u,n,p="WithinHeaders"){let m={"x-algolia-api-key":n,"x-algolia-application-id":u};return {headers(){return p==="WithinHeaders"?m:{}},queryParameters(){return p==="WithinQueryParameters"?m:{}}}}function O({func:u,validate:n,aggregator:p,error:m,timeout:l=()=>0}){let f=c=>new Promise((e,r)=>{u(c).then(async t=>(p&&await p(t),await n(t)?e(t):m&&await m.validate(t)?r(new Error(await m.message(t))):setTimeout(()=>{f(t).then(e).catch(r);},await l()))).catch(t=>{r(t);});});return f()}function $({algoliaAgents:u,client:n,version:p}){let m=oe(p).add({segment:n,version:p});return u.forEach(l=>m.add(l)),m}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 p=Date.now();function m(){return n==="up"||Date.now()-p>K}function l(){return n==="timed out"&&Date.now()-p<=K}return {...u,status:n,lastUpdate:p,isUp:m,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,p){super(u,p),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,p,m="ApiError"){super(u,p,m),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,p,m){super(u,n,m,"DetailedApiError"),this.error=p;}};function V(u){let n=u;for(let p=u.length-1;p>0;p--){let m=Math.floor(Math.random()*(p+1)),l=u[p];n[p]=u[m],n[m]=l;}return n}function ce(u,n,p){let m=me(p),l=`${u.protocol}://${u.url}${u.port?`:${u.port}`:""}/${n.charAt(0)==="/"?n.substring(1):n}`;return m.length&&(l+=`?${m}`),l}function me(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 pe(u,n){if(u.method==="GET"||u.data===void 0&&n.data===void 0)return;let p=Array.isArray(u.data)?u.data:{...u.data,...n.data};return JSON.stringify(p)}function de(u,n,p){let m={Accept:"application/json",...u,...n,...p},l={};return Object.keys(m).forEach(f=>{let c=m[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},p){try{let m=JSON.parse(u);return "error"in m?new ue(m.message,n,m.error,p):new T(m.message,n,p)}catch{}return new T(u,n,p)}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:p,logger:m,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=pe(h,P),w=de(p,h.headers,P.headers),q=s==="gzip"&&x!==void 0&&x.length>ae&&(h.method==="POST"||h.method==="PUT");q&&o===void 0&&m.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 I=g.pop();if(I===void 0)throw new ne(ye(R));let C={...c,...P.timeouts},G={data:k,headers:w,method:h.method,url:ce(I,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:I,triesLeft:g.length};return R.push(L),L},S=await e.send(G);if(fe(S)){let N=B(S);return S.isTimedOut&&D++,m.info("Retryable failure",X(N)),await n.set(I,F(I,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:p}};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:m,algoliaAgent:f,baseHeaders:p,baseQueryParameters:l,hosts:u,request:d,requestsCache:r,responsesCache:t}}function Z(){function u(n){return new Promise(p=>{let m=new XMLHttpRequest;m.open(n.method,n.url,true),Object.keys(n.headers).forEach(e=>m.setRequestHeader(e,n.headers[e]));let l=(e,r)=>setTimeout(()=>{m.abort(),p({status:0,content:r,isTimedOut:true});},e),f=l(n.connectTimeout,"Connection timeout"),c;m.onreadystatechange=()=>{m.readyState>m.OPENED&&c===void 0&&(clearTimeout(f),c=l(n.responseTimeout,"Socket timeout"));},m.onerror=()=>{m.status===0&&(clearTimeout(f),clearTimeout(c),p({content:m.responseText||"Network request failed",status:m.status,isTimedOut:false}));},m.onload=()=>{clearTimeout(f),clearTimeout(c),p({content:m.responseText,status:m.status,isTimedOut:false});},m.send(n.data);})}return {send:u}}var v="5.50.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:p,algoliaAgents:m,...l}){let f=M(u,n,p),c=Y({hosts:Re(u),...l,algoliaAgent:$({algoliaAgents:m,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}){!p||p==="WithinHeaders"?c.baseHeaders["x-algolia-api-key"]=e:c.baseQueryParameters["x-algolia-api-key"]=e;},waitForTask({indexName:e,taskID:r,maxRetries:t=50,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:()=>`The maximum number of retries exceeded. (${a}/${t})`},timeout:()=>o(a)})},waitForAppTask({taskID:e,maxRetries:r=50,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:()=>`The maximum number of retries exceeded. (${s}/${r})`},timeout:()=>t(s)})},waitForApiKey({operation:e,key:r,apiKey:t,maxRetries:o=50,timeout:s=i=>Math.min(i*200,5e3)},a){let i=0,d={aggregator:()=>i+=1,error:{validate:()=>i>=o,message:()=>`The maximum number of retries exceeded. (${i}/${o})`},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 oo(u,n,p){if(!u||typeof u!="string")throw new Error("`appId` is missing.");if(!n||typeof n!="string")throw new Error("`apiKey` is missing.");let{compression:m,...l}=p||{};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:b({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 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.51.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 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})}
|
|
8
8
|
|
|
9
9
|
exports.apiClientVersion = v;
|
|
10
|
-
exports.searchClient =
|
|
10
|
+
exports.searchClient = Po;
|
|
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.51.0";
|
|
26
26
|
function getDefaultHosts(appId) {
|
|
27
27
|
return [
|
|
28
28
|
{
|
|
@@ -132,14 +132,14 @@ function createSearchClient({
|
|
|
132
132
|
* @param waitForTaskOptions - The `waitForTaskOptions` object.
|
|
133
133
|
* @param waitForTaskOptions.indexName - The `indexName` where the operation was performed.
|
|
134
134
|
* @param waitForTaskOptions.taskID - The `taskID` returned in the method response.
|
|
135
|
-
* @param waitForTaskOptions.maxRetries - The maximum number of retries.
|
|
135
|
+
* @param waitForTaskOptions.maxRetries - The maximum number of retries. 100 by default.
|
|
136
136
|
* @param waitForTaskOptions.timeout - The function to decide how long to wait between retries.
|
|
137
137
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
138
138
|
*/
|
|
139
139
|
waitForTask({
|
|
140
140
|
indexName,
|
|
141
141
|
taskID,
|
|
142
|
-
maxRetries =
|
|
142
|
+
maxRetries = 100,
|
|
143
143
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
144
144
|
}, requestOptions) {
|
|
145
145
|
let retryCount = 0;
|
|
@@ -149,7 +149,7 @@ function createSearchClient({
|
|
|
149
149
|
aggregator: () => retryCount += 1,
|
|
150
150
|
error: {
|
|
151
151
|
validate: () => retryCount >= maxRetries,
|
|
152
|
-
message: () => `
|
|
152
|
+
message: () => `Stopped waiting for the task after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`
|
|
153
153
|
},
|
|
154
154
|
timeout: () => timeout(retryCount)
|
|
155
155
|
});
|
|
@@ -160,13 +160,13 @@ function createSearchClient({
|
|
|
160
160
|
* @summary Helper method that waits for a task to be published (completed).
|
|
161
161
|
* @param waitForAppTaskOptions - The `waitForTaskOptions` object.
|
|
162
162
|
* @param waitForAppTaskOptions.taskID - The `taskID` returned in the method response.
|
|
163
|
-
* @param waitForAppTaskOptions.maxRetries - The maximum number of retries.
|
|
163
|
+
* @param waitForAppTaskOptions.maxRetries - The maximum number of retries. 100 by default.
|
|
164
164
|
* @param waitForAppTaskOptions.timeout - The function to decide how long to wait between retries.
|
|
165
165
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
166
166
|
*/
|
|
167
167
|
waitForAppTask({
|
|
168
168
|
taskID,
|
|
169
|
-
maxRetries =
|
|
169
|
+
maxRetries = 100,
|
|
170
170
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
171
171
|
}, requestOptions) {
|
|
172
172
|
let retryCount = 0;
|
|
@@ -176,7 +176,7 @@ function createSearchClient({
|
|
|
176
176
|
aggregator: () => retryCount += 1,
|
|
177
177
|
error: {
|
|
178
178
|
validate: () => retryCount >= maxRetries,
|
|
179
|
-
message: () => `
|
|
179
|
+
message: () => `Stopped waiting for the task after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`
|
|
180
180
|
},
|
|
181
181
|
timeout: () => timeout(retryCount)
|
|
182
182
|
});
|
|
@@ -189,7 +189,7 @@ function createSearchClient({
|
|
|
189
189
|
* @param waitForApiKeyOptions.operation - The `operation` that was done on a `key`.
|
|
190
190
|
* @param waitForApiKeyOptions.key - The `key` that has been added, deleted or updated.
|
|
191
191
|
* @param waitForApiKeyOptions.apiKey - Necessary to know if an `update` operation has been processed, compare fields of the response with it.
|
|
192
|
-
* @param waitForApiKeyOptions.maxRetries - The maximum number of retries.
|
|
192
|
+
* @param waitForApiKeyOptions.maxRetries - The maximum number of retries. 100 by default.
|
|
193
193
|
* @param waitForApiKeyOptions.timeout - The function to decide how long to wait between retries.
|
|
194
194
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getApikey` method and merged with the transporter requestOptions.
|
|
195
195
|
*/
|
|
@@ -197,7 +197,7 @@ function createSearchClient({
|
|
|
197
197
|
operation,
|
|
198
198
|
key,
|
|
199
199
|
apiKey,
|
|
200
|
-
maxRetries =
|
|
200
|
+
maxRetries = 100,
|
|
201
201
|
timeout = (retryCount) => Math.min(retryCount * 200, 5e3)
|
|
202
202
|
}, requestOptions) {
|
|
203
203
|
let retryCount = 0;
|
|
@@ -205,7 +205,7 @@ function createSearchClient({
|
|
|
205
205
|
aggregator: () => retryCount += 1,
|
|
206
206
|
error: {
|
|
207
207
|
validate: () => retryCount >= maxRetries,
|
|
208
|
-
message: () => `
|
|
208
|
+
message: () => `Stopped waiting for the API key operation after ${maxRetries} retries. This does not mean the operation failed; it may still complete. If you need to keep polling, retry with a higher maxRetries.`
|
|
209
209
|
},
|
|
210
210
|
timeout: () => timeout(retryCount)
|
|
211
211
|
};
|