@algolia/client-search 5.52.1 → 5.54.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 +145 -323
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +5 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +7 -3
- package/dist/builds/fetch.js +149 -325
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +147 -324
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +149 -325
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +145 -323
- 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 +143 -322
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +147 -328
- package/dist/src/searchClient.js.map +1 -1
- package/dist/worker.d.ts +88 -14
- package/package.json +9 -9
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
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:!0}){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)!==!0)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,!0),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:!0})},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:!1}))},p.onload=()=>{clearTimeout(f),clearTimeout(c),m({content:p.responseText,status:p.status,isTimedOut:!1})},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!1}else if(y!==R)return!1}return!0}})}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!1;throw r}return!0},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:!0};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:!0,cacheable:!0};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:!0,cacheable:!0};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:!0,cacheable:!0};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:!0,cacheable:!0};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:!0,cacheable:!0};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:!0,cacheable:!0};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:!0,cacheable:!0};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:!0,cacheable:!0};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:!1}),hostsCache:I({caches:[_({key:`${v}-${u}`}),U()]}),...l})}export{v as apiClientVersion,Po as searchClient};
|
|
1
|
+
function Y(n){let i,d=`algolia-client-js-${n.key}`;function p(){return i===void 0&&(i=n.localStorage||window.localStorage),i}function l(){return JSON.parse(p().getItem(d)||"{}")}function q(t){p().setItem(d,JSON.stringify(t))}function m(){return new Promise(t=>setTimeout(t,0))}function e(){let t=n.timeToLive?n.timeToLive*1e3:null,r=l(),a=new Date().getTime(),o=!1;return{namespace:Object.fromEntries(Object.entries(r).filter(([,c])=>!c||c.timestamp===void 0||t&&c.timestamp+t<a?(o=!0,!1):!0)),changed:o}}return{get(t,r,a={miss:()=>Promise.resolve()}){return m().then(()=>{let{namespace:o,changed:s}=e(),c=o[JSON.stringify(t)];return s&&q(o),c?c.value:r().then(h=>a.miss(h).then(()=>h))})},set(t,r){return m().then(()=>{let a=l();return a[JSON.stringify(t)]={timestamp:new Date().getTime(),value:r},p().setItem(d,JSON.stringify(a)),r})},delete(t){return m().then(()=>{let r=l();delete r[JSON.stringify(t)],p().setItem(d,JSON.stringify(r))})},clear(){return Promise.resolve().then(()=>{p().removeItem(d)})}}}function ue(){return{get(n,i,d={miss:()=>Promise.resolve()}){return i().then(l=>Promise.all([l,d.miss(l)])).then(([l])=>l)},set(n,i){return Promise.resolve(i)},delete(n){return Promise.resolve()},clear(){return Promise.resolve()}}}function E(n){let i=[...n.caches],d=i.shift();return d===void 0?ue():{get(p,l,q={miss:()=>Promise.resolve()}){return d.get(p,l,q).catch(()=>E({caches:i}).get(p,l,q))},set(p,l){return d.set(p,l).catch(()=>E({caches:i}).set(p,l))},delete(p){return d.delete(p).catch(()=>E({caches:i}).delete(p))},clear(){return d.clear().catch(()=>E({caches:i}).clear())}}}function N(n={serializable:!0}){let i={};return{get(d,p,l={miss:()=>Promise.resolve()}){let q=JSON.stringify(d);if(q in i)return Promise.resolve(n.serializable?JSON.parse(i[q]):i[q]);let m=p();return m.then(e=>l.miss(e)).then(()=>m)},set(d,p){return i[JSON.stringify(d)]=n.serializable?JSON.stringify(p):p,Promise.resolve(p)},delete(d){return delete i[JSON.stringify(d)],Promise.resolve()},clear(){return i={},Promise.resolve()}}}function pe(n){let i={value:`Algolia for JavaScript (${n})`,add(d){let p=`; ${d.segment}${d.version!==void 0?` (${d.version})`:""}`;return i.value.indexOf(p)===-1&&(i.value=`${i.value}${p}`),i}};return i}function Z(n,i,d="WithinHeaders"){let p={"x-algolia-api-key":i,"x-algolia-application-id":n};return{headers(){return d==="WithinHeaders"?p:{}},queryParameters(){return d==="WithinQueryParameters"?p:{}}}}function v({func:n,validate:i,aggregator:d,error:p,timeout:l=()=>0}){let q=m=>new Promise((e,t)=>{n(m).then(async r=>(d&&await d(r),await i(r)?e(r):p&&await p.validate(r)?t(new Error(await p.message(r))):setTimeout(()=>{q(r).then(e).catch(t)},await l()))).catch(r=>{t(r)})});return q()}function ee({algoliaAgents:n,client:i,version:d}){let p=pe(d).add({segment:i,version:d});return n.forEach(l=>p.add(l)),p}function te(){return{debug(n,i){return Promise.resolve()},info(n,i){return Promise.resolve()},error(n,i){return Promise.resolve()}}}var de=10*1024*1024;async function*me(n){let i=n.getReader();try{for(;;){let{done:d,value:p}=await i.read();if(d)return;yield p}}finally{i.releaseLock()}}function he(n){return Symbol.asyncIterator in n?n:me(n)}async function*le(n){let i=new TextDecoder("utf-8"),d=[],p=0,l=!1,q=!0;for await(let e of he(n)){let t=i.decode(e,{stream:!0}),r=0;for(l&&(l=!1,t.length>0&&t[0]===`
|
|
2
|
+
`&&(r=1));r<t.length;){let a=t.indexOf("\r",r),o=t.indexOf(`
|
|
3
|
+
`,r);if(a===-1&&o===-1){let f=t.slice(r);if(d.push(f),p+=f.length,p>de)throw new Error("SSE line buffer exceeded 10MB");break}let s,c;a!==-1&&(o===-1||a<o)?(s=a,a+1<t.length?c=t[a+1]===`
|
|
4
|
+
`?2:1:(l=!0,c=1)):(s=o,c=1);let h=t.slice(r,s);d.push(h);let y=d.length===1?d[0]:d.join("");d.length=0,p=0,q&&(y.startsWith("\uFEFF")&&(y=y.slice(1)),q=!1),yield y,r=s+c}}let m=i.decode();if(m&&d.push(m),d.length>0){let e=d.join("");q&&e.startsWith("\uFEFF")&&(e=e.slice(1)),yield e}}var Pe=class{data=[];eventType="";lastEventId=null;retry=null;decode(n){if(n==="")return this.dispatch();if(n[0]===":")return null;let i=n.indexOf(":"),d,p;switch(i===-1?(d=n,p=""):(d=n.slice(0,i),p=n.slice(i+1),p[0]===" "&&(p=p.slice(1))),d){case"data":this.data.push(p);break;case"event":this.eventType=p;break;case"id":p.includes("\0")||(this.lastEventId=p);break;case"retry":/^[0-9]+$/.test(p)&&(this.retry=parseInt(p,10));break}return null}dispatch(){let n=this.eventType;if(this.eventType="",this.data.length===0)return null;let i={data:this.data.join(`
|
|
5
|
+
`),event:n,id:this.lastEventId,retry:this.retry};return this.data=[],i}};async function*ye(n){let i=new Pe;for await(let d of le(n)){let p=i.decode(d);p!==null&&(yield p)}}var fe=750,$=120*1e3;function W(n,i="up"){let d=Date.now();function p(){return i==="up"||Date.now()-d>$}function l(){return i==="timed out"&&Date.now()-d<=$}return{...n,status:i,lastUpdate:d,isUp:p,isTimedOut:l}}var re=class extends Error{name="AlgoliaError";constructor(n,i){super(n),i&&(this.name=i)}};var se=class extends re{stackTrace;constructor(n,i,d){super(n,d),this.stackTrace=i}},z=class extends se{constructor(n){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",n,"RetryError")}},j=class extends se{status;constructor(n,i,d,p="ApiError"){super(n,d,p),this.status=i}},qe=class extends re{response;constructor(n,i){super(n,"DeserializationError"),this.response=i}},Re=class extends j{error;constructor(n,i,d,p){super(n,i,p,"DetailedApiError"),this.error=d}};function oe(n){let i=n;for(let d=n.length-1;d>0;d--){let p=Math.floor(Math.random()*(d+1)),l=n[d];i[d]=n[p],i[p]=l}return i}function J(n,i,d){let p=xe(d),l=`${n.protocol}://${n.url}${n.port?`:${n.port}`:""}/${i.charAt(0)==="/"?i.substring(1):i}`;return p.length&&(l+=`?${p}`),l}function xe(n){return Object.keys(n).filter(i=>n[i]!==void 0).sort().map(i=>`${i}=${encodeURIComponent(Object.prototype.toString.call(n[i])==="[object Array]"?n[i].join(","):n[i]).replace(/\+/g,"%20")}`).join("&")}function V(n,i){if(n.method==="GET"||n.data===void 0&&i.data===void 0)return;let d=Array.isArray(n.data)?n.data:{...n.data,...i.data};return JSON.stringify(d)}function X(n,i,d){let p={Accept:"application/json",...n,...i,...d},l={};return Object.keys(p).forEach(q=>{let m=p[q];l[q.toLowerCase()]=m}),l}function ge(n){if(!(n.status===204||n.content.length===0))try{return JSON.parse(n.content)}catch(i){throw new qe(i.message,n)}}function Se({content:n,status:i},d){try{let p=JSON.parse(n);return"error"in p?new Re(p.message,i,p.error,d):new j(p.message,i,d)}catch{}return new j(n,i,d)}function Oe({isTimedOut:n,status:i}){return!n&&~~i===0}function be({isTimedOut:n,status:i}){return n||Oe({isTimedOut:n,status:i})||~~(i/100)!==2&&~~(i/100)!==4}function Ie({status:n}){return~~(n/100)===2}function Te(n){return n.map(i=>ae(i))}function ae(n){let i=n.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...n,request:{...n.request,headers:{...n.request.headers,...i}}}}function ne({hosts:n,hostsCache:i,baseHeaders:d,logger:p,baseQueryParameters:l,algoliaAgent:q,timeouts:m,requester:e,requestsCache:t,responsesCache:r,compress:a,compression:o}){async function s(f){let P=await Promise.all(f.map(R=>i.get(R,()=>Promise.resolve(W(R))))),x=P.filter(R=>R.isUp()),S=P.filter(R=>R.isTimedOut()),b=[...x,...S];return{hosts:b.length>0?b:f,getTimeout(R,T){return(S.length===0&&R===0?1:S.length+3+R)*T}}}async function c(f,P,x){let S=[],b=V(f,P),g=X(d,f.headers,P.headers),R=o==="gzip"&&b!==void 0&&b.length>fe&&(f.method==="POST"||f.method==="PUT");R&&a===void 0&&p.info("Compression is disabled because no compress method is available.");let T=R&&a!==void 0,Q=T?await a(b):b;T&&(g["content-encoding"]="gzip");let C=f.method==="GET"?{...f.data,...P.data}:{},A={...l,...f.queryParameters,...C};if(q.value&&(A["x-algolia-agent"]=q.value),P&&P.queryParameters)for(let O of Object.keys(P.queryParameters))!P.queryParameters[O]||Object.prototype.toString.call(P.queryParameters[O])==="[object Object]"?A[O]=P.queryParameters[O]:A[O]=P.queryParameters[O].toString();let w=0,k=async(O,G)=>{let D=O.pop();if(D===void 0)throw new z(Te(S));let L={...m,...P.timeouts},K={data:Q,headers:g,method:f.method,url:J(D,f.path,A),connectTimeout:G(w,L.connect),responseTimeout:G(w,x?L.read:L.write)},_=B=>{let M={request:K,response:B,host:D,triesLeft:O.length};return S.push(M),M},U=await e.send(K);if(be(U)){let B=_(U);return U.isTimedOut&&w++,p.info("Retryable failure",ae(B)),await i.set(D,W(D,U.isTimedOut?"timed out":"down")),k(O,G)}if(Ie(U))return ge(U);throw _(U),Se(U,S)},I=n.filter(O=>O.accept==="readWrite"||(x?O.accept==="read":O.accept==="write")),F=await s(I);return k([...F.hosts].reverse(),F.getTimeout)}function h(f,P={}){let x=()=>c(f,P,S),S=f.useReadTransporter||f.method==="GET";if((P.cacheable||f.cacheable)!==!0)return x();let g={request:f,requestOptions:P,transporter:{queryParameters:l,headers:d}};return r.get(g,()=>t.get(g,()=>t.set(g,x()).then(R=>Promise.all([t.delete(g),R]),R=>Promise.all([t.delete(g),Promise.reject(R)])).then(([R,T])=>T)),{miss:R=>r.set(g,R)})}async function*y(f,P={}){if(!e.sendStream)throw new Error("This requester does not support streaming");let x=V(f,P),S=X(d,f.headers,P.headers);S.accept="text/event-stream";let b=f.method==="GET"?{...f.data,...P.data}:{},g={...l,...f.queryParameters,...b};if(q.value&&(g["x-algolia-agent"]=q.value),P&&P.queryParameters)for(let I of Object.keys(P.queryParameters))!P.queryParameters[I]||Object.prototype.toString.call(P.queryParameters[I])==="[object Object]"?g[I]=P.queryParameters[I]:g[I]=P.queryParameters[I].toString();let R=f.useReadTransporter||f.method==="GET",T=n.filter(I=>I.accept==="readWrite"||(R?I.accept==="read":I.accept==="write")),C=(await s(T)).hosts[0];if(!C)throw new z([]);let A={...m,...P.timeouts},w={data:x,headers:S,method:f.method,url:J(C,f.path,g),connectTimeout:A.connect,responseTimeout:R?A.read:A.write},k=await e.sendStream(w);yield*ye(k)}return{hostsCache:i,requester:e,timeouts:m,logger:p,algoliaAgent:q,baseHeaders:d,baseQueryParameters:l,hosts:n,request:h,requestStream:y,requestsCache:t,responsesCache:r}}function u(n,i,d){if(d==null||typeof d=="string"&&d.length===0)throw new Error(`Parameter \`${n}\` is required when calling \`${i}\`.`)}function ie(){function n(i){return new Promise(d=>{let p=new XMLHttpRequest;p.open(i.method,i.url,!0),Object.keys(i.headers).forEach(e=>p.setRequestHeader(e,i.headers[e]));let l=(e,t)=>setTimeout(()=>{p.abort(),d({status:0,content:t,isTimedOut:!0})},e),q=l(i.connectTimeout,"Connection timeout"),m;p.onreadystatechange=()=>{p.readyState>p.OPENED&&m===void 0&&(clearTimeout(q),m=l(i.responseTimeout,"Socket timeout"))},p.onerror=()=>{p.status===0&&(clearTimeout(q),clearTimeout(m),d({content:p.responseText||"Network request failed",status:p.status,isTimedOut:!1}))},p.onload=()=>{clearTimeout(q),clearTimeout(m),d({content:p.responseText,status:p.status,isTimedOut:!1})},p.send(i.data)})}return{send:n}}var H="5.54.0";function Ae(n){return[{url:`${n}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${n}.algolia.net`,accept:"write",protocol:"https"}].concat(oe([{url:`${n}-1.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${n}-2.algolianet.com`,accept:"readWrite",protocol:"https"},{url:`${n}-3.algolianet.com`,accept:"readWrite",protocol:"https"}]))}function ce({appId:n,apiKey:i,authMode:d,algoliaAgents:p,...l}){let q=Z(n,i,d),m=ne({hosts:Ae(n),...l,algoliaAgent:ee({algoliaAgents:p,client:"Search",version:H}),baseHeaders:{"content-type":"text/plain",...q.headers(),...l.baseHeaders},baseQueryParameters:{...q.queryParameters(),...l.baseQueryParameters}});return{transporter:m,appId:n,apiKey:i,clearCache(){return Promise.all([m.requestsCache.clear(),m.responsesCache.clear()]).then(()=>{})},get _ua(){return m.algoliaAgent.value},addAlgoliaAgent(e,t){m.algoliaAgent.add({segment:e,version:t})},setClientApiKey({apiKey:e}){!d||d==="WithinHeaders"?m.baseHeaders["x-algolia-api-key"]=e:m.baseQueryParameters["x-algolia-api-key"]=e},waitForTask({indexName:e,taskID:t,maxRetries:r=100,timeout:a=s=>Math.min(s*200,5e3)},o){let s=0;return v({func:()=>this.getTask({indexName:e,taskID:t},o),validate:c=>c.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:()=>a(s)})},waitForAppTask({taskID:e,maxRetries:t=100,timeout:r=o=>Math.min(o*200,5e3)},a){let o=0;return v({func:()=>this.getAppTask({taskID:e},a),validate:s=>s.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:()=>r(o)})},waitForApiKey({operation:e,key:t,apiKey:r,maxRetries:a=100,timeout:o=c=>Math.min(c*200,5e3)},s){let c=0,h={aggregator:()=>c+=1,error:{validate:()=>c>=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:()=>o(c)};if(e==="update"){if(!r)throw new Error("`apiKey` is required when waiting for an `update` operation.");return v({...h,func:()=>this.getApiKey({key:t},s),validate:y=>{for(let f of Object.keys(r)){let P=r[f],x=y[f];if(Array.isArray(P)&&Array.isArray(x)){if(P.length!==x.length||P.some((S,b)=>S!==x[b]))return!1}else if(P!==x)return!1}return!0}})}return v({...h,func:()=>this.getApiKey({key:t},s).catch(y=>{if(y.status!==404)throw y}),validate:y=>e==="add"?y!==void 0:y===void 0})},browseObjects({indexName:e,browseParams:t,...r},a){return v({func:o=>this.browse({indexName:e,browseParams:{cursor:o?o.cursor:void 0,hitsPerPage:1e3,...t}},a),validate:o=>o.cursor===void 0,...r})},browseRules({indexName:e,searchRulesParams:t,...r},a){let o={...t,hitsPerPage:t?.hitsPerPage||1e3};return v({func:s=>this.searchRules({indexName:e,searchRulesParams:{...o,page:s?s.page+1:o.page||0}},a),validate:s=>s.hits.length<o.hitsPerPage,...r})},browseSynonyms({indexName:e,searchSynonymsParams:t,...r},a){let o={...t,page:t?.page||0,hitsPerPage:1e3};return v({func:s=>{let c=this.searchSynonyms({indexName:e,searchSynonymsParams:{...o,page:o.page}},a);return o.page+=1,c},validate:s=>s.hits.length<o.hitsPerPage,...r})},async chunkedBatch({indexName:e,objects:t,action:r="addObject",waitForTasks:a,batchSize:o=1e3,maxRetries:s=100},c){let h=[],y=[],f=t.entries();for(let[P,x]of f)h.push({action:r,body:x}),(h.length===o||P===t.length-1)&&(y.push(await this.batch({indexName:e,batchWriteParams:{requests:h}},c)),h=[]);if(a)for(let P of y)await this.waitForTask({indexName:e,taskID:P.taskID,maxRetries:s});return y},async saveObjects({indexName:e,objects:t,waitForTasks:r,batchSize:a,maxRetries:o},s){return await this.chunkedBatch({indexName:e,objects:t,action:"addObject",waitForTasks:r,batchSize:a,maxRetries:o},s)},async deleteObjects({indexName:e,objectIDs:t,waitForTasks:r,batchSize:a,maxRetries:o},s){return await this.chunkedBatch({indexName:e,objects:t.map(c=>({objectID:c})),action:"deleteObject",waitForTasks:r,batchSize:a,maxRetries:o},s)},async partialUpdateObjects({indexName:e,objects:t,createIfNotExists:r,waitForTasks:a,batchSize:o,maxRetries:s},c){return await this.chunkedBatch({indexName:e,objects:t,action:r?"partialUpdateObject":"partialUpdateObjectNoCreate",batchSize:o,waitForTasks:a,maxRetries:s},c)},async replaceAllObjects({indexName:e,objects:t,batchSize:r,scopes:a,maxRetries:o=100},s){let c=Math.floor(Math.random()*1e6)+1e5,h=`${e}_tmp_${c}`;a===void 0&&(a=["settings","rules","synonyms"]);try{let y=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:h,scope:a}},s),f=await this.chunkedBatch({indexName:h,objects:t,waitForTasks:!0,batchSize:r,maxRetries:o},s);await this.waitForTask({indexName:h,taskID:y.taskID,maxRetries:o}),y=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:h,scope:a}},s),await this.waitForTask({indexName:h,taskID:y.taskID,maxRetries:o});let P=await this.operationIndex({indexName:h,operationIndexParams:{operation:"move",destination:e}},s);return await this.waitForTask({indexName:h,taskID:P.taskID,maxRetries:o}),{copyOperationResponse:y,batchResponses:f,moveOperationResponse:P}}catch(y){throw await this.deleteIndex({indexName:h}),y}},async indexExists({indexName:e}){try{await this.getSettings({indexName:e})}catch(t){if(t instanceof j&&t.status===404)return!1;throw t}return!0},searchForHits(e,t){return this.search(e,t)},searchForFacets(e,t){return this.search(e,t)},addApiKey(e,t){u("apiKey","addApiKey",e),u("apiKey.acl","addApiKey",e.acl);let s={method:"POST",path:"/1/keys",queryParameters:{},headers:{},data:e};return m.request(s,t)},addOrUpdateObject({indexName:e,objectID:t,body:r},a){u("indexName","addOrUpdateObject",e),u("objectID","addOrUpdateObject",t),u("body","addOrUpdateObject",r);let h={method:"PUT",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),queryParameters:{},headers:{},data:r};return m.request(h,a)},appendSource(e,t){u("source","appendSource",e),u("source.source","appendSource",e.source);let s={method:"POST",path:"/1/security/sources/append",queryParameters:{},headers:{},data:e};return m.request(s,t)},assignUserId({xAlgoliaUserID:e,assignUserIdParams:t},r){u("xAlgoliaUserID","assignUserId",e),u("assignUserIdParams","assignUserId",t),u("assignUserIdParams.cluster","assignUserId",t.cluster);let a="/1/clusters/mapping",o={},s={};e!==void 0&&(o["X-Algolia-User-ID"]=e.toString());let c={method:"POST",path:a,queryParameters:s,headers:o,data:t};return m.request(c,r)},batch({indexName:e,batchWriteParams:t},r){u("indexName","batch",e),u("batchWriteParams","batch",t),u("batchWriteParams.requests","batch",t.requests);let c={method:"POST",path:"/1/indexes/{indexName}/batch".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return m.request(c,r)},batchAssignUserIds({xAlgoliaUserID:e,batchAssignUserIdsParams:t},r){u("xAlgoliaUserID","batchAssignUserIds",e),u("batchAssignUserIdsParams","batchAssignUserIds",t),u("batchAssignUserIdsParams.cluster","batchAssignUserIds",t.cluster),u("batchAssignUserIdsParams.users","batchAssignUserIds",t.users);let a="/1/clusters/mapping/batch",o={},s={};e!==void 0&&(o["X-Algolia-User-ID"]=e.toString());let c={method:"POST",path:a,queryParameters:s,headers:o,data:t};return m.request(c,r)},batchDictionaryEntries({dictionaryName:e,batchDictionaryEntriesParams:t},r){u("dictionaryName","batchDictionaryEntries",e),u("batchDictionaryEntriesParams","batchDictionaryEntries",t),u("batchDictionaryEntriesParams.requests","batchDictionaryEntries",t.requests);let c={method:"POST",path:"/1/dictionaries/{dictionaryName}/batch".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return m.request(c,r)},browse({indexName:e,browseParams:t},r){u("indexName","browse",e);let c={method:"POST",path:"/1/indexes/{indexName}/browse".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{},useReadTransporter:!0};return m.request(c,r)},clearObjects({indexName:e},t){u("indexName","clearObjects",e);let s={method:"POST",path:"/1/indexes/{indexName}/clear".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},clearRules({indexName:e,forwardToReplicas:t},r){u("indexName","clearRules",e);let a="/1/indexes/{indexName}/rules/clear".replace("{indexName}",encodeURIComponent(e)),o={},s={};t!==void 0&&(s.forwardToReplicas=t.toString());let c={method:"POST",path:a,queryParameters:s,headers:o};return m.request(c,r)},clearSynonyms({indexName:e,forwardToReplicas:t},r){u("indexName","clearSynonyms",e);let a="/1/indexes/{indexName}/synonyms/clear".replace("{indexName}",encodeURIComponent(e)),o={},s={};t!==void 0&&(s.forwardToReplicas=t.toString());let c={method:"POST",path:a,queryParameters:s,headers:o};return m.request(c,r)},customDelete({path:e,parameters:t},r){u("path","customDelete",e);let c={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return m.request(c,r)},customGet({path:e,parameters:t},r){u("path","customGet",e);let c={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return m.request(c,r)},customPost({path:e,parameters:t,body:r},a){u("path","customPost",e);let h={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return m.request(h,a)},customPut({path:e,parameters:t,body:r},a){u("path","customPut",e);let h={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return m.request(h,a)},deleteApiKey({key:e},t){u("key","deleteApiKey",e);let s={method:"DELETE",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},deleteBy({indexName:e,deleteByParams:t},r){u("indexName","deleteBy",e),u("deleteByParams","deleteBy",t);let c={method:"POST",path:"/1/indexes/{indexName}/deleteByQuery".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return m.request(c,r)},deleteIndex({indexName:e},t){u("indexName","deleteIndex",e);let s={method:"DELETE",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},deleteObject({indexName:e,objectID:t},r){u("indexName","deleteObject",e),u("objectID","deleteObject",t);let c={method:"DELETE",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return m.request(c,r)},deleteRule({indexName:e,objectID:t,forwardToReplicas:r},a){u("indexName","deleteRule",e),u("objectID","deleteRule",t);let o="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),s={},c={};r!==void 0&&(c.forwardToReplicas=r.toString());let h={method:"DELETE",path:o,queryParameters:c,headers:s};return m.request(h,a)},deleteSource({source:e},t){u("source","deleteSource",e);let s={method:"DELETE",path:"/1/security/sources/{source}".replace("{source}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},deleteSynonym({indexName:e,objectID:t,forwardToReplicas:r},a){u("indexName","deleteSynonym",e),u("objectID","deleteSynonym",t);let o="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),s={},c={};r!==void 0&&(c.forwardToReplicas=r.toString());let h={method:"DELETE",path:o,queryParameters:c,headers:s};return m.request(h,a)},getApiKey({key:e},t){u("key","getApiKey",e);let s={method:"GET",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},getAppTask({taskID:e},t){u("taskID","getAppTask",e);let s={method:"GET",path:"/1/task/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},getDictionaryLanguages(e){let o={method:"GET",path:"/1/dictionaries/*/languages",queryParameters:{},headers:{}};return m.request(o,e)},getDictionarySettings(e){let o={method:"GET",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{}};return m.request(o,e)},getLogs({offset:e,length:t,indexName:r,type:a}={},o=void 0){let s="/1/logs",c={},h={};e!==void 0&&(h.offset=e.toString()),t!==void 0&&(h.length=t.toString()),r!==void 0&&(h.indexName=r.toString()),a!==void 0&&(h.type=a.toString());let y={method:"GET",path:s,queryParameters:h,headers:c};return m.request(y,o)},getObject({indexName:e,objectID:t,attributesToRetrieve:r},a){u("indexName","getObject",e),u("objectID","getObject",t);let o="/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),s={},c={};r!==void 0&&(c.attributesToRetrieve=r.toString());let h={method:"GET",path:o,queryParameters:c,headers:s};return m.request(h,a)},getObjects(e,t){u("getObjectsParams","getObjects",e),u("getObjectsParams.requests","getObjects",e.requests);let s={method:"POST",path:"/1/indexes/*/objects",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return m.request(s,t)},getRule({indexName:e,objectID:t},r){u("indexName","getRule",e),u("objectID","getRule",t);let c={method:"GET",path:"/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return m.request(c,r)},getSettings({indexName:e,getVersion:t},r){u("indexName","getSettings",e);let a="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),o={},s={};t!==void 0&&(s.getVersion=t.toString());let c={method:"GET",path:a,queryParameters:s,headers:o};return m.request(c,r)},getSources(e){let o={method:"GET",path:"/1/security/sources",queryParameters:{},headers:{}};return m.request(o,e)},getSynonym({indexName:e,objectID:t},r){u("indexName","getSynonym",e),u("objectID","getSynonym",t);let c={method:"GET",path:"/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return m.request(c,r)},getTask({indexName:e,taskID:t},r){u("indexName","getTask",e),u("taskID","getTask",t);let c={method:"GET",path:"/1/indexes/{indexName}/task/{taskID}".replace("{indexName}",encodeURIComponent(e)).replace("{taskID}",encodeURIComponent(t)),queryParameters:{},headers:{}};return m.request(c,r)},getTopUserIds(e){let o={method:"GET",path:"/1/clusters/mapping/top",queryParameters:{},headers:{}};return m.request(o,e)},getUserId({userID:e},t){u("userID","getUserId",e);let s={method:"GET",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},hasPendingMappings({getClusters:e}={},t=void 0){let r="/1/clusters/mapping/pending",a={},o={};e!==void 0&&(o.getClusters=e.toString());let s={method:"GET",path:r,queryParameters:o,headers:a};return m.request(s,t)},listApiKeys(e){let o={method:"GET",path:"/1/keys",queryParameters:{},headers:{}};return m.request(o,e)},listClusters(e){let o={method:"GET",path:"/1/clusters",queryParameters:{},headers:{}};return m.request(o,e)},listIndices({page:e,hitsPerPage:t}={},r=void 0){let a="/1/indexes",o={},s={};e!==void 0&&(s.page=e.toString()),t!==void 0&&(s.hitsPerPage=t.toString());let c={method:"GET",path:a,queryParameters:s,headers:o};return m.request(c,r)},listUserIds({page:e,hitsPerPage:t}={},r=void 0){let a="/1/clusters/mapping",o={},s={};e!==void 0&&(s.page=e.toString()),t!==void 0&&(s.hitsPerPage=t.toString());let c={method:"GET",path:a,queryParameters:s,headers:o};return m.request(c,r)},multipleBatch(e,t){u("batchParams","multipleBatch",e),u("batchParams.requests","multipleBatch",e.requests);let s={method:"POST",path:"/1/indexes/*/batch",queryParameters:{},headers:{},data:e};return m.request(s,t)},operationIndex({indexName:e,operationIndexParams:t},r){u("indexName","operationIndex",e),u("operationIndexParams","operationIndex",t),u("operationIndexParams.operation","operationIndex",t.operation),u("operationIndexParams.destination","operationIndex",t.destination);let c={method:"POST",path:"/1/indexes/{indexName}/operation".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return m.request(c,r)},partialUpdateObject({indexName:e,objectID:t,attributesToUpdate:r,createIfNotExists:a},o){u("indexName","partialUpdateObject",e),u("objectID","partialUpdateObject",t),u("attributesToUpdate","partialUpdateObject",r);let s="/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),c={},h={};a!==void 0&&(h.createIfNotExists=a.toString());let y={method:"POST",path:s,queryParameters:h,headers:c,data:r};return m.request(y,o)},removeUserId({userID:e},t){u("userID","removeUserId",e);let s={method:"DELETE",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},replaceSources({source:e},t){u("source","replaceSources",e);let s={method:"PUT",path:"/1/security/sources",queryParameters:{},headers:{},data:e};return m.request(s,t)},restoreApiKey({key:e},t){u("key","restoreApiKey",e);let s={method:"POST",path:"/1/keys/{key}/restore".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return m.request(s,t)},saveObject({indexName:e,body:t},r){u("indexName","saveObject",e),u("body","saveObject",t);let c={method:"POST",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return m.request(c,r)},saveRule({indexName:e,objectID:t,rule:r,forwardToReplicas:a},o){u("indexName","saveRule",e),u("objectID","saveRule",t),u("rule","saveRule",r),u("rule.objectID","saveRule",r.objectID),u("rule.consequence","saveRule",r.consequence);let s="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),c={},h={};a!==void 0&&(h.forwardToReplicas=a.toString());let y={method:"PUT",path:s,queryParameters:h,headers:c,data:r};return m.request(y,o)},saveRules({indexName:e,rules:t,forwardToReplicas:r,clearExistingRules:a},o){u("indexName","saveRules",e),u("rules","saveRules",t);let s="/1/indexes/{indexName}/rules/batch".replace("{indexName}",encodeURIComponent(e)),c={},h={};r!==void 0&&(h.forwardToReplicas=r.toString()),a!==void 0&&(h.clearExistingRules=a.toString());let y={method:"POST",path:s,queryParameters:h,headers:c,data:t};return m.request(y,o)},saveSynonym({indexName:e,objectID:t,synonymHit:r,forwardToReplicas:a},o){u("indexName","saveSynonym",e),u("objectID","saveSynonym",t),u("synonymHit","saveSynonym",r),u("synonymHit.objectID","saveSynonym",r.objectID),u("synonymHit.type","saveSynonym",r.type);let s="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(t)),c={},h={};a!==void 0&&(h.forwardToReplicas=a.toString());let y={method:"PUT",path:s,queryParameters:h,headers:c,data:r};return m.request(y,o)},saveSynonyms({indexName:e,synonymHit:t,forwardToReplicas:r,replaceExistingSynonyms:a},o){u("indexName","saveSynonyms",e),u("synonymHit","saveSynonyms",t);let s="/1/indexes/{indexName}/synonyms/batch".replace("{indexName}",encodeURIComponent(e)),c={},h={};r!==void 0&&(h.forwardToReplicas=r.toString()),a!==void 0&&(h.replaceExistingSynonyms=a.toString());let y={method:"POST",path:s,queryParameters:h,headers:c,data:t};return m.request(y,o)},search(e,t){e&&Array.isArray(e)&&(e={requests:e.map(({params:h,...y})=>y.type==="facet"?{...y,...h,type:"facet"}:{...y,...h,facet:void 0,maxFacetHits:void 0,facetQuery:void 0})}),u("searchMethodParams","search",e),u("searchMethodParams.requests","search",e.requests);let s={method:"POST",path:"/1/indexes/*/queries",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return m.request(s,t)},searchDictionaryEntries({dictionaryName:e,searchDictionaryEntriesParams:t},r){u("dictionaryName","searchDictionaryEntries",e),u("searchDictionaryEntriesParams","searchDictionaryEntries",t),u("searchDictionaryEntriesParams.query","searchDictionaryEntries",t.query);let c={method:"POST",path:"/1/dictionaries/{dictionaryName}/search".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t,useReadTransporter:!0,cacheable:!0};return m.request(c,r)},searchForFacetValues({indexName:e,facetName:t,searchForFacetValuesRequest:r},a){u("indexName","searchForFacetValues",e),u("facetName","searchForFacetValues",t);let h={method:"POST",path:"/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}",encodeURIComponent(e)).replace("{facetName}",encodeURIComponent(t)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return m.request(h,a)},searchRules({indexName:e,searchRulesParams:t},r){u("indexName","searchRules",e);let c={method:"POST",path:"/1/indexes/{indexName}/rules/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{},useReadTransporter:!0,cacheable:!0};return m.request(c,r)},searchSingleIndex({indexName:e,searchParams:t},r){u("indexName","searchSingleIndex",e);let c={method:"POST",path:"/1/indexes/{indexName}/query".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{},useReadTransporter:!0,cacheable:!0};return m.request(c,r)},searchSynonyms({indexName:e,searchSynonymsParams:t},r){u("indexName","searchSynonyms",e);let c={method:"POST",path:"/1/indexes/{indexName}/synonyms/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t||{},useReadTransporter:!0,cacheable:!0};return m.request(c,r)},searchUserIds(e,t){u("searchUserIdsParams","searchUserIds",e),u("searchUserIdsParams.query","searchUserIds",e.query);let s={method:"POST",path:"/1/clusters/mapping/search",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return m.request(s,t)},setDictionarySettings(e,t){u("dictionarySettingsParams","setDictionarySettings",e),u("dictionarySettingsParams.disableStandardEntries","setDictionarySettings",e.disableStandardEntries);let s={method:"PUT",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{},data:e};return m.request(s,t)},setSettings({indexName:e,indexSettings:t,forwardToReplicas:r},a){u("indexName","setSettings",e),u("indexSettings","setSettings",t);let o="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),s={},c={};r!==void 0&&(c.forwardToReplicas=r.toString());let h={method:"PUT",path:o,queryParameters:c,headers:s,data:t};return m.request(h,a)},updateApiKey({key:e,apiKey:t},r){u("key","updateApiKey",e),u("apiKey","updateApiKey",t),u("apiKey.acl","updateApiKey",t.acl);let c={method:"PUT",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{},data:t};return m.request(c,r)}}}function Uo(n,i,d){if(!n||typeof n!="string")throw new Error("`appId` is missing.");if(!i||typeof i!="string")throw new Error("`apiKey` is missing.");let{compression:p,...l}=d||{};return ce({appId:n,apiKey:i,timeouts:{connect:1e3,read:2e3,write:3e4},logger:te(),requester:ie(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:N(),requestsCache:N({serializable:!1}),hostsCache:E({caches:[Y({key:`${H}-${n}`}),N()]}),...l})}export{H as apiClientVersion,Uo as searchClient};
|
|
2
6
|
//# sourceMappingURL=browser.min.js.map
|