@algolia/client-search 5.15.0 → 5.16.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 +23 -35
- package/dist/builds/browser.js +30 -22
- 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 +30 -27
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +29 -18
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +30 -27
- package/dist/builds/node.js.map +1 -1
- package/dist/fetch.d.ts +23 -35
- package/dist/node.d.cts +23 -35
- package/dist/node.d.ts +23 -35
- package/dist/src/searchClient.cjs +26 -15
- package/dist/src/searchClient.cjs.map +1 -1
- package/dist/src/searchClient.js +26 -15
- package/dist/src/searchClient.js.map +1 -1
- package/package.json +10 -9
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@algolia/client-search"] = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
function Q(){function u(i){return new Promise(p=>{let m=new XMLHttpRequest;m.open(i.method,i.url,!0),Object.keys(i.headers).forEach(e=>m.setRequestHeader(e,i.headers[e]));let h=(e,r)=>setTimeout(()=>{m.abort(),p({status:0,content:r,isTimedOut:!0});},e),P=h(i.connectTimeout,"Connection timeout"),c;m.onreadystatechange=()=>{m.readyState>m.OPENED&&c===void 0&&(clearTimeout(P),c=h(i.responseTimeout,"Socket timeout"));},m.onerror=()=>{m.status===0&&(clearTimeout(P),clearTimeout(c),p({content:m.responseText||"Network request failed",status:m.status,isTimedOut:!1}));},m.onload=()=>{clearTimeout(P),clearTimeout(c),p({content:m.responseText,status:m.status,isTimedOut:!1});},m.send(i.data);})}return {send:u}}function L(u){let i,p=`algolia-client-js-${u.key}`;function m(){return i===void 0&&(i=u.localStorage||window.localStorage),i}function h(){return JSON.parse(m().getItem(p)||"{}")}function P(e){m().setItem(p,JSON.stringify(e));}function c(){let e=u.timeToLive?u.timeToLive*1e3:null,r=h(),t=Object.fromEntries(Object.entries(r).filter(([,o])=>o.timestamp!==void 0));if(P(t),!e)return;let a=Object.fromEntries(Object.entries(t).filter(([,o])=>{let s=new Date().getTime();return !(o.timestamp+e<s)}));P(a);}return {get(e,r,t={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(c(),h()[JSON.stringify(e)])).then(a=>Promise.all([a?a.value:r(),a!==void 0])).then(([a,o])=>Promise.all([a,o||t.miss(a)])).then(([a])=>a)},set(e,r){return Promise.resolve().then(()=>{let t=h();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=h();delete r[JSON.stringify(e)],m().setItem(p,JSON.stringify(r));})},clear(){return Promise.resolve().then(()=>{m().removeItem(p);})}}}function re(){return {get(u,i,p={miss:()=>Promise.resolve()}){return i().then(h=>Promise.all([h,p.miss(h)])).then(([h])=>h)},set(u,i){return Promise.resolve(i)},delete(u){return Promise.resolve()},clear(){return Promise.resolve()}}}function O(u){let i=[...u.caches],p=i.shift();return p===void 0?re():{get(m,h,P={miss:()=>Promise.resolve()}){return p.get(m,h,P).catch(()=>O({caches:i}).get(m,h,P))},set(m,h){return p.set(m,h).catch(()=>O({caches:i}).set(m,h))},delete(m){return p.delete(m).catch(()=>O({caches:i}).delete(m))},clear(){return p.clear().catch(()=>O({caches:i}).clear())}}}function I(u={serializable:!0}){let i={};return {get(p,m,h={miss:()=>Promise.resolve()}){let P=JSON.stringify(p);if(P in i)return Promise.resolve(u.serializable?JSON.parse(i[P]):i[P]);let c=m();return c.then(e=>h.miss(e)).then(()=>c)},set(p,m){return i[JSON.stringify(p)]=u.serializable?JSON.stringify(m):m,Promise.resolve(m)},delete(p){return delete i[JSON.stringify(p)],Promise.resolve()},clear(){return i={},Promise.resolve()}}}var K=1e3,F=2e3,_=3e4;function te(u){let i={value:`Algolia for JavaScript (${u})`,add(p){let m=`; ${p.segment}${p.version!==void 0?` (${p.version})`:""}`;return i.value.indexOf(m)===-1&&(i.value=`${i.value}${m}`),i}};return i}function M(u,i,p="WithinHeaders"){let m={"x-algolia-api-key":i,"x-algolia-application-id":u};return {headers(){return p==="WithinHeaders"?m:{}},queryParameters(){return p==="WithinQueryParameters"?m:{}}}}function S({func:u,validate:i,aggregator:p,error:m,timeout:h=()=>0}){let P=c=>new Promise((e,r)=>{u(c).then(t=>(p&&p(t),i(t)?e(t):m&&m.validate(t)?r(new Error(m.message(t))):setTimeout(()=>{P(t).then(e).catch(r);},h()))).catch(t=>{r(t);});});return P()}function W({algoliaAgents:u,client:i,version:p}){let m=te(p).add({segment:i,version:p});return u.forEach(h=>m.add(h)),m}function $(){return {debug(u,i){return Promise.resolve()},info(u,i){return Promise.resolve()},error(u,i){return Promise.resolve()}}}var G=2*60*1e3;function B(u,i="up"){let p=Date.now();function m(){return i==="up"||Date.now()-p>G}function h(){return i==="timed out"&&Date.now()-p<=G}return {...u,status:i,lastUpdate:p,isUp:m,isTimedOut:h}}var J=class extends Error{name="AlgoliaError";constructor(u,i){super(u),i&&(this.name=i);}},z=class extends J{stackTrace;constructor(u,i,p){super(u,p),this.stackTrace=i;}},se=class extends z{constructor(u){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",u,"RetryError");}},b=class extends z{status;constructor(u,i,p,m="ApiError"){super(u,p,m),this.status=i;}},oe=class extends J{response;constructor(u,i){super(u,"DeserializationError"),this.response=i;}},ae=class extends b{error;constructor(u,i,p,m){super(u,i,m,"DetailedApiError"),this.error=p;}};function V(u){let i=u;for(let p=u.length-1;p>0;p--){let m=Math.floor(Math.random()*(p+1)),h=u[p];i[p]=u[m],i[m]=h;}return i}function ne(u,i,p){let m=ie(p),h=`${u.protocol}://${u.url}${u.port?`:${u.port}`:""}/${i.charAt(0)==="/"?i.substring(1):i}`;return m.length&&(h+=`?${m}`),h}function ie(u){return Object.keys(u).filter(i=>u[i]!==void 0).sort().map(i=>`${i}=${encodeURIComponent(Object.prototype.toString.call(u[i])==="[object Array]"?u[i].join(","):u[i]).replace(/\+/g,"%20")}`).join("&")}function ue(u,i){if(u.method==="GET"||u.data===void 0&&i.data===void 0)return;let p=Array.isArray(u.data)?u.data:{...u.data,...i.data};return JSON.stringify(p)}function ce(u,i,p){let m={Accept:"application/json",...u,...i,...p},h={};return Object.keys(m).forEach(P=>{let c=m[P];h[P.toLowerCase()]=c;}),h}function me(u){try{return JSON.parse(u.content)}catch(i){throw new oe(i.message,u)}}function pe({content:u,status:i},p){try{let m=JSON.parse(u);return "error"in m?new ae(m.message,i,m.error,p):new b(m.message,i,p)}catch{}return new b(u,i,p)}function de({isTimedOut:u,status:i}){return !u&&~~i===0}function he({isTimedOut:u,status:i}){return u||de({isTimedOut:u,status:i})||~~(i/100)!==2&&~~(i/100)!==4}function le({status:u}){return ~~(u/100)===2}function Pe(u){return u.map(i=>X(i))}function X(u){let i=u.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...u,request:{...u.request,headers:{...u.request.headers,...i}}}}function Y({hosts:u,hostsCache:i,baseHeaders:p,logger:m,baseQueryParameters:h,algoliaAgent:P,timeouts:c,requester:e,requestsCache:r,responsesCache:t}){async function a(n){let d=await Promise.all(n.map(q=>i.get(q,()=>Promise.resolve(B(q))))),l=d.filter(q=>q.isUp()),f=d.filter(q=>q.isTimedOut()),g=[...l,...f];return {hosts:g.length>0?g:n,getTimeout(q,w){return (f.length===0&&q===0?1:f.length+3+q)*w}}}async function o(n,d,l=!0){let f=[],g=ue(n,d),y=ce(p,n.headers,d.headers),q=n.method==="GET"?{...n.data,...d.data}:{},w={...h,...n.queryParameters,...q};if(P.value&&(w["x-algolia-agent"]=P.value),d&&d.queryParameters)for(let R of Object.keys(d.queryParameters))!d.queryParameters[R]||Object.prototype.toString.call(d.queryParameters[R])==="[object Object]"?w[R]=d.queryParameters[R]:w[R]=d.queryParameters[R].toString();let T=0,j=async(R,U)=>{let E=R.pop();if(E===void 0)throw new se(Pe(f));let D={...c,...d.timeouts},N={data:g,headers:y,method:n.method,url:ne(E,n.path,w),connectTimeout:U(T,D.connect),responseTimeout:U(T,l?D.read:D.write)},k=v=>{let H={request:N,response:v,host:E,triesLeft:R.length};return f.push(H),H},x=await e.send(N);if(he(x)){let v=k(x);return x.isTimedOut&&T++,m.info("Retryable failure",X(v)),await i.set(E,B(E,x.isTimedOut?"timed out":"down")),j(R,U)}if(le(x))return me(x);throw k(x),pe(x,f)},ee=u.filter(R=>R.accept==="readWrite"||(l?R.accept==="read":R.accept==="write")),C=await a(ee);return j([...C.hosts].reverse(),C.getTimeout)}function s(n,d={}){let l=n.useReadTransporter||n.method==="GET";if(!l)return o(n,d,l);let f=()=>o(n,d);if((d.cacheable||n.cacheable)!==!0)return f();let y={request:n,requestOptions:d,transporter:{queryParameters:h,headers:p}};return t.get(y,()=>r.get(y,()=>r.set(y,f()).then(q=>Promise.all([r.delete(y),q]),q=>Promise.all([r.delete(y),Promise.reject(q)])).then(([q,w])=>w)),{miss:q=>t.set(y,q)})}return {hostsCache:i,requester:e,timeouts:c,logger:m,algoliaAgent:P,baseHeaders:p,baseQueryParameters:h,hosts:u,request:s,requestsCache:r,responsesCache:t}}var A="5.15.0";function qe(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 Z({appId:u,apiKey:i,authMode:p,algoliaAgents:m,...h}){let P=M(u,i,p),c=Y({hosts:qe(u),...h,algoliaAgent:W({algoliaAgents:m,client:"Search",version:A}),baseHeaders:{"content-type":"text/plain",...P.headers(),...h.baseHeaders},baseQueryParameters:{...P.queryParameters(),...h.baseQueryParameters}});return {transporter:c,appId:u,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:a=s=>Math.min(s*200,5e3)},o){let s=0;return S({func:()=>this.getTask({indexName:e,taskID:r},o),validate:n=>n.status==="published",aggregator:()=>s+=1,error:{validate:()=>s>=t,message:()=>`The maximum number of retries exceeded. (${s}/${t})`},timeout:()=>a(s)})},waitForAppTask({taskID:e,maxRetries:r=50,timeout:t=o=>Math.min(o*200,5e3)},a){let o=0;return S({func:()=>this.getAppTask({taskID:e},a),validate:s=>s.status==="published",aggregator:()=>o+=1,error:{validate:()=>o>=r,message:()=>`The maximum number of retries exceeded. (${o}/${r})`},timeout:()=>t(o)})},waitForApiKey({operation:e,key:r,apiKey:t,maxRetries:a=50,timeout:o=n=>Math.min(n*200,5e3)},s){let n=0,d={aggregator:()=>n+=1,error:{validate:()=>n>=a,message:()=>`The maximum number of retries exceeded. (${n}/${a})`},timeout:()=>o(n)};if(e==="update"){if(!t)throw new Error("`apiKey` is required when waiting for an `update` operation.");return S({...d,func:()=>this.getApiKey({key:r},s),validate:l=>{for(let f of Object.keys(t)){let g=t[f],y=l[f];if(Array.isArray(g)&&Array.isArray(y)){if(g.length!==y.length||g.some((q,w)=>q!==y[w]))return !1}else if(g!==y)return !1}return !0}})}return S({...d,func:()=>this.getApiKey({key:r},s).catch(l=>{if(l.status!==404)throw l}),validate:l=>e==="add"?l!==void 0:l===void 0})},browseObjects({indexName:e,browseParams:r,...t},a){return S({func:o=>this.browse({indexName:e,browseParams:{cursor:o?o.cursor:void 0,hitsPerPage:1e3,...r}},a),validate:o=>o.cursor===void 0,...t})},browseRules({indexName:e,searchRulesParams:r,...t},a){let o={hitsPerPage:1e3,...r};return S({func:s=>this.searchRules({indexName:e,searchRulesParams:{...o,page:s?s.page+1:o.page||0}},a),validate:s=>s.hits.length<o.hitsPerPage,...t})},browseSynonyms({indexName:e,searchSynonymsParams:r,...t},a){let o={page:0,...r,hitsPerPage:1e3};return S({func:s=>{let n=this.searchSynonyms({indexName:e,searchSynonymsParams:{...o,page:o.page}},a);return o.page+=1,n},validate:s=>s.hits.length<o.hitsPerPage,...t})},async chunkedBatch({indexName:e,objects:r,action:t="addObject",waitForTasks:a,batchSize:o=1e3},s){let n=[],d=[],l=r.entries();for(let[f,g]of l)n.push({action:t,body:g}),(n.length===o||f===r.length-1)&&(d.push(await this.batch({indexName:e,batchWriteParams:{requests:n}},s)),n=[]);if(a)for(let f of d)await this.waitForTask({indexName:e,taskID:f.taskID});return d},async saveObjects({indexName:e,objects:r,waitForTasks:t},a){return await this.chunkedBatch({indexName:e,objects:r,action:"addObject",waitForTasks:t},a)},async deleteObjects({indexName:e,objectIDs:r,waitForTasks:t},a){return await this.chunkedBatch({indexName:e,objects:r.map(o=>({objectID:o})),action:"deleteObject",waitForTasks:t},a)},async partialUpdateObjects({indexName:e,objects:r,createIfNotExists:t,waitForTasks:a},o){return await this.chunkedBatch({indexName:e,objects:r,action:t?"partialUpdateObject":"partialUpdateObjectNoCreate",waitForTasks:a},o)},async replaceAllObjects({indexName:e,objects:r,batchSize:t},a){let o=Math.floor(Math.random()*1e6)+1e5,s=`${e}_tmp_${o}`,n=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:s,scope:["settings","rules","synonyms"]}},a),d=await this.chunkedBatch({indexName:s,objects:r,waitForTasks:!0,batchSize:t},a);await this.waitForTask({indexName:s,taskID:n.taskID}),n=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:s,scope:["settings","rules","synonyms"]}},a),await this.waitForTask({indexName:s,taskID:n.taskID});let l=await this.operationIndex({indexName:s,operationIndexParams:{operation:"move",destination:e}},a);return await this.waitForTask({indexName:s,taskID:l.taskID}),{copyOperationResponse:n,batchResponses:d,moveOperationResponse:l}},async indexExists({indexName:e}){try{await this.getSettings({indexName:e});}catch(r){if(r instanceof b&&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 s={method:"POST",path:"/1/keys",queryParameters:{},headers:{},data:e};return c.request(s,r)},addOrUpdateObject({indexName:e,objectID:r,body:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");if(!t)throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");let d={method:"PUT",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{},data:t};return c.request(d,a)},appendSource(e,r){if(!e)throw new Error("Parameter `source` is required when calling `appendSource`.");if(!e.source)throw new Error("Parameter `source.source` is required when calling `appendSource`.");let s={method:"POST",path:"/1/security/sources/append",queryParameters:{},headers:{},data:e};return c.request(s,r)},assignUserId({xAlgoliaUserID:e,assignUserIdParams:r},t){if(!e)throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");if(!r)throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");if(!r.cluster)throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");let a="/1/clusters/mapping",o={},s={};e!==void 0&&(o["X-Algolia-User-ID"]=e.toString());let n={method:"POST",path:a,queryParameters:s,headers:o,data:r};return c.request(n,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 n={method:"POST",path:"/1/indexes/{indexName}/batch".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},batchAssignUserIds({xAlgoliaUserID:e,batchAssignUserIdsParams:r},t){if(!e)throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");if(!r)throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");if(!r.cluster)throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");if(!r.users)throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");let a="/1/clusters/mapping/batch",o={},s={};e!==void 0&&(o["X-Algolia-User-ID"]=e.toString());let n={method:"POST",path:a,queryParameters:s,headers:o,data:r};return c.request(n,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 n={method:"POST",path:"/1/dictionaries/{dictionaryName}/batch".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},browse({indexName:e,browseParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `browse`.");let n={method:"POST",path:"/1/indexes/{indexName}/browse".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0};return c.request(n,t)},clearObjects({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `clearObjects`.");let s={method:"POST",path:"/1/indexes/{indexName}/clear".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},clearRules({indexName:e,forwardToReplicas:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `clearRules`.");let a="/1/indexes/{indexName}/rules/clear".replace("{indexName}",encodeURIComponent(e)),o={},s={};r!==void 0&&(s.forwardToReplicas=r.toString());let n={method:"POST",path:a,queryParameters:s,headers:o};return c.request(n,t)},clearSynonyms({indexName:e,forwardToReplicas:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");let a="/1/indexes/{indexName}/synonyms/clear".replace("{indexName}",encodeURIComponent(e)),o={},s={};r!==void 0&&(s.forwardToReplicas=r.toString());let n={method:"POST",path:a,queryParameters:s,headers:o};return c.request(n,t)},customDelete({path:e,parameters:r},t){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let n={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{}};return c.request(n,t)},customGet({path:e,parameters:r},t){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let n={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{}};return c.request(n,t)},customPost({path:e,parameters:r,body:t},a){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let d={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{},data:t||{}};return c.request(d,a)},customPut({path:e,parameters:r,body:t},a){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let d={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{},data:t||{}};return c.request(d,a)},deleteApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `deleteApiKey`.");let s={method:"DELETE",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,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 n={method:"POST",path:"/1/indexes/{indexName}/deleteByQuery".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},deleteIndex({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");let s={method:"DELETE",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,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 n={method:"DELETE",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(n,t)},deleteRule({indexName:e,objectID:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteRule`.");let o="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),s={},n={};t!==void 0&&(n.forwardToReplicas=t.toString());let d={method:"DELETE",path:o,queryParameters:n,headers:s};return c.request(d,a)},deleteSource({source:e},r){if(!e)throw new Error("Parameter `source` is required when calling `deleteSource`.");let s={method:"DELETE",path:"/1/security/sources/{source}".replace("{source}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},deleteSynonym({indexName:e,objectID:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");let o="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),s={},n={};t!==void 0&&(n.forwardToReplicas=t.toString());let d={method:"DELETE",path:o,queryParameters:n,headers:s};return c.request(d,a)},getApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `getApiKey`.");let s={method:"GET",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},getAppTask({taskID:e},r){if(!e)throw new Error("Parameter `taskID` is required when calling `getAppTask`.");let s={method:"GET",path:"/1/task/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},getDictionaryLanguages(e){let o={method:"GET",path:"/1/dictionaries/*/languages",queryParameters:{},headers:{}};return c.request(o,e)},getDictionarySettings(e){let o={method:"GET",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{}};return c.request(o,e)},getLogs({offset:e,length:r,indexName:t,type:a}={},o=void 0){let s="/1/logs",n={},d={};e!==void 0&&(d.offset=e.toString()),r!==void 0&&(d.length=r.toString()),t!==void 0&&(d.indexName=t.toString()),a!==void 0&&(d.type=a.toString());let l={method:"GET",path:s,queryParameters:d,headers:n};return c.request(l,o)},getObject({indexName:e,objectID:r,attributesToRetrieve:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getObject`.");let o="/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),s={},n={};t!==void 0&&(n.attributesToRetrieve=t.toString());let d={method:"GET",path:o,queryParameters:n,headers:s};return c.request(d,a)},getObjects(e,r){if(!e)throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");if(!e.requests)throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");let s={method:"POST",path:"/1/indexes/*/objects",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(s,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 n={method:"GET",path:"/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(n,t)},getSettings({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `getSettings`.");let s={method:"GET",path:"/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},getSources(e){let o={method:"GET",path:"/1/security/sources",queryParameters:{},headers:{}};return c.request(o,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 n={method:"GET",path:"/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(n,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 n={method:"GET",path:"/1/indexes/{indexName}/task/{taskID}".replace("{indexName}",encodeURIComponent(e)).replace("{taskID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(n,t)},getTopUserIds(e){let o={method:"GET",path:"/1/clusters/mapping/top",queryParameters:{},headers:{}};return c.request(o,e)},getUserId({userID:e},r){if(!e)throw new Error("Parameter `userID` is required when calling `getUserId`.");let s={method:"GET",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},hasPendingMappings({getClusters:e}={},r=void 0){let t="/1/clusters/mapping/pending",a={},o={};e!==void 0&&(o.getClusters=e.toString());let s={method:"GET",path:t,queryParameters:o,headers:a};return c.request(s,r)},listApiKeys(e){let o={method:"GET",path:"/1/keys",queryParameters:{},headers:{}};return c.request(o,e)},listClusters(e){let o={method:"GET",path:"/1/clusters",queryParameters:{},headers:{}};return c.request(o,e)},listIndices({page:e,hitsPerPage:r}={},t=void 0){let a="/1/indexes",o={},s={};e!==void 0&&(s.page=e.toString()),r!==void 0&&(s.hitsPerPage=r.toString());let n={method:"GET",path:a,queryParameters:s,headers:o};return c.request(n,t)},listUserIds({page:e,hitsPerPage:r}={},t=void 0){let a="/1/clusters/mapping",o={},s={};e!==void 0&&(s.page=e.toString()),r!==void 0&&(s.hitsPerPage=r.toString());let n={method:"GET",path:a,queryParameters:s,headers:o};return c.request(n,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 s={method:"POST",path:"/1/indexes/*/batch",queryParameters:{},headers:{},data:e};return c.request(s,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 n={method:"POST",path:"/1/indexes/{indexName}/operation".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},partialUpdateObject({indexName:e,objectID:r,attributesToUpdate:t,createIfNotExists:a},o){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 s="/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),n={},d={};a!==void 0&&(d.createIfNotExists=a.toString());let l={method:"POST",path:s,queryParameters:d,headers:n,data:t};return c.request(l,o)},removeUserId({userID:e},r){if(!e)throw new Error("Parameter `userID` is required when calling `removeUserId`.");let s={method:"DELETE",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},replaceSources({source:e},r){if(!e)throw new Error("Parameter `source` is required when calling `replaceSources`.");let s={method:"PUT",path:"/1/security/sources",queryParameters:{},headers:{},data:e};return c.request(s,r)},restoreApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `restoreApiKey`.");let s={method:"POST",path:"/1/keys/{key}/restore".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,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 n={method:"POST",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},saveRule({indexName:e,objectID:r,rule:t,forwardToReplicas:a},o){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`.");let s="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),n={},d={};a!==void 0&&(d.forwardToReplicas=a.toString());let l={method:"PUT",path:s,queryParameters:d,headers:n,data:t};return c.request(l,o)},saveRules({indexName:e,rules:r,forwardToReplicas:t,clearExistingRules:a},o){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 s="/1/indexes/{indexName}/rules/batch".replace("{indexName}",encodeURIComponent(e)),n={},d={};t!==void 0&&(d.forwardToReplicas=t.toString()),a!==void 0&&(d.clearExistingRules=a.toString());let l={method:"POST",path:s,queryParameters:d,headers:n,data:r};return c.request(l,o)},saveSynonym({indexName:e,objectID:r,synonymHit:t,forwardToReplicas:a},o){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 s="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),n={},d={};a!==void 0&&(d.forwardToReplicas=a.toString());let l={method:"PUT",path:s,queryParameters:d,headers:n,data:t};return c.request(l,o)},saveSynonyms({indexName:e,synonymHit:r,forwardToReplicas:t,replaceExistingSynonyms:a},o){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 s="/1/indexes/{indexName}/synonyms/batch".replace("{indexName}",encodeURIComponent(e)),n={},d={};t!==void 0&&(d.forwardToReplicas=t.toString()),a!==void 0&&(d.replaceExistingSynonyms=a.toString());let l={method:"POST",path:s,queryParameters:d,headers:n,data:r};return c.request(l,o)},search(e,r){if(e&&Array.isArray(e)&&(e={requests:e.map(({params:d,...l})=>l.type==="facet"?{...l,...d,type:"facet"}:{...l,...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 s={method:"POST",path:"/1/indexes/*/queries",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(s,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 n={method:"POST",path:"/1/dictionaries/{dictionaryName}/search".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r,useReadTransporter:!0,cacheable:!0};return c.request(n,t)},searchForFacetValues({indexName:e,facetName:r,searchForFacetValuesRequest:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");if(!r)throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");let d={method:"POST",path:"/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}",encodeURIComponent(e)).replace("{facetName}",encodeURIComponent(r)),queryParameters:{},headers:{},data:t||{},useReadTransporter:!0,cacheable:!0};return c.request(d,a)},searchRules({indexName:e,searchRulesParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchRules`.");let n={method:"POST",path:"/1/indexes/{indexName}/rules/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return c.request(n,t)},searchSingleIndex({indexName:e,searchParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");let n={method:"POST",path:"/1/indexes/{indexName}/query".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return c.request(n,t)},searchSynonyms({indexName:e,searchSynonymsParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");let n={method:"POST",path:"/1/indexes/{indexName}/synonyms/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return c.request(n,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 s={method:"POST",path:"/1/clusters/mapping/search",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(s,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 s={method:"PUT",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{},data:e};return c.request(s,r)},setSettings({indexName:e,indexSettings:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `setSettings`.");if(!r)throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");let o="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),s={},n={};t!==void 0&&(n.forwardToReplicas=t.toString());let d={method:"PUT",path:o,queryParameters:n,headers:s,data:r};return c.request(d,a)},updateApiKey({key:e,apiKey:r},t){if(!e)throw new Error("Parameter `key` is required when calling `updateApiKey`.");if(!r)throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");if(!r.acl)throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");let n={method:"PUT",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)}}}function Vs(u,i,p){if(!u||typeof u!="string")throw new Error("`appId` is missing.");if(!i||typeof i!="string")throw new Error("`apiKey` is missing.");return Z({appId:u,apiKey:i,timeouts:{connect:K,read:F,write:_},logger:$(),requester:Q(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:I(),requestsCache:I({serializable:!1}),hostsCache:O({caches:[L({key:`${A}-${u}`}),I()]}),...p})}
|
|
7
|
+
function Q(){function u(i){return new Promise(p=>{let m=new XMLHttpRequest;m.open(i.method,i.url,!0),Object.keys(i.headers).forEach(e=>m.setRequestHeader(e,i.headers[e]));let h=(e,r)=>setTimeout(()=>{m.abort(),p({status:0,content:r,isTimedOut:!0});},e),P=h(i.connectTimeout,"Connection timeout"),c;m.onreadystatechange=()=>{m.readyState>m.OPENED&&c===void 0&&(clearTimeout(P),c=h(i.responseTimeout,"Socket timeout"));},m.onerror=()=>{m.status===0&&(clearTimeout(P),clearTimeout(c),p({content:m.responseText||"Network request failed",status:m.status,isTimedOut:!1}));},m.onload=()=>{clearTimeout(P),clearTimeout(c),p({content:m.responseText,status:m.status,isTimedOut:!1});},m.send(i.data);})}return {send:u}}function L(u){let i,p=`algolia-client-js-${u.key}`;function m(){return i===void 0&&(i=u.localStorage||window.localStorage),i}function h(){return JSON.parse(m().getItem(p)||"{}")}function P(e){m().setItem(p,JSON.stringify(e));}function c(){let e=u.timeToLive?u.timeToLive*1e3:null,r=h(),t=Object.fromEntries(Object.entries(r).filter(([,o])=>o.timestamp!==void 0));if(P(t),!e)return;let a=Object.fromEntries(Object.entries(t).filter(([,o])=>{let s=new Date().getTime();return !(o.timestamp+e<s)}));P(a);}return {get(e,r,t={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(c(),h()[JSON.stringify(e)])).then(a=>Promise.all([a?a.value:r(),a!==void 0])).then(([a,o])=>Promise.all([a,o||t.miss(a)])).then(([a])=>a)},set(e,r){return Promise.resolve().then(()=>{let t=h();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=h();delete r[JSON.stringify(e)],m().setItem(p,JSON.stringify(r));})},clear(){return Promise.resolve().then(()=>{m().removeItem(p);})}}}function Y(){return {get(u,i,p={miss:()=>Promise.resolve()}){return i().then(h=>Promise.all([h,p.miss(h)])).then(([h])=>h)},set(u,i){return Promise.resolve(i)},delete(u){return Promise.resolve()},clear(){return Promise.resolve()}}}function O(u){let i=[...u.caches],p=i.shift();return p===void 0?Y():{get(m,h,P={miss:()=>Promise.resolve()}){return p.get(m,h,P).catch(()=>O({caches:i}).get(m,h,P))},set(m,h){return p.set(m,h).catch(()=>O({caches:i}).set(m,h))},delete(m){return p.delete(m).catch(()=>O({caches:i}).delete(m))},clear(){return p.clear().catch(()=>O({caches:i}).clear())}}}function T(u={serializable:!0}){let i={};return {get(p,m,h={miss:()=>Promise.resolve()}){let P=JSON.stringify(p);if(P in i)return Promise.resolve(u.serializable?JSON.parse(i[P]):i[P]);let c=m();return c.then(e=>h.miss(e)).then(()=>c)},set(p,m){return i[JSON.stringify(p)]=u.serializable?JSON.stringify(m):m,Promise.resolve(m)},delete(p){return delete i[JSON.stringify(p)],Promise.resolve()},clear(){return i={},Promise.resolve()}}}function Z(u){let i={value:`Algolia for JavaScript (${u})`,add(p){let m=`; ${p.segment}${p.version!==void 0?` (${p.version})`:""}`;return i.value.indexOf(m)===-1&&(i.value=`${i.value}${m}`),i}};return i}function K(u,i,p="WithinHeaders"){let m={"x-algolia-api-key":i,"x-algolia-application-id":u};return {headers(){return p==="WithinHeaders"?m:{}},queryParameters(){return p==="WithinQueryParameters"?m:{}}}}function S({func:u,validate:i,aggregator:p,error:m,timeout:h=()=>0}){let P=c=>new Promise((e,r)=>{u(c).then(async t=>(p&&await p(t),await i(t)?e(t):m&&await m.validate(t)?r(new Error(await m.message(t))):setTimeout(()=>{P(t).then(e).catch(r);},await h()))).catch(t=>{r(t);});});return P()}function F({algoliaAgents:u,client:i,version:p}){let m=Z(p).add({segment:i,version:p});return u.forEach(h=>m.add(h)),m}function _(){return {debug(u,i){return Promise.resolve()},info(u,i){return Promise.resolve()},error(u,i){return Promise.resolve()}}}var G=2*60*1e3;function B(u,i="up"){let p=Date.now();function m(){return i==="up"||Date.now()-p>G}function h(){return i==="timed out"&&Date.now()-p<=G}return {...u,status:i,lastUpdate:p,isUp:m,isTimedOut:h}}var M=class extends Error{name="AlgoliaError";constructor(u,i){super(u),i&&(this.name=i);}},W=class extends M{stackTrace;constructor(u,i,p){super(u,p),this.stackTrace=i;}},ee=class extends W{constructor(u){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",u,"RetryError");}},b=class extends W{status;constructor(u,i,p,m="ApiError"){super(u,p,m),this.status=i;}},re=class extends M{response;constructor(u,i){super(u,"DeserializationError"),this.response=i;}},te=class extends b{error;constructor(u,i,p,m){super(u,i,m,"DetailedApiError"),this.error=p;}};function $(u){let i=u;for(let p=u.length-1;p>0;p--){let m=Math.floor(Math.random()*(p+1)),h=u[p];i[p]=u[m],i[m]=h;}return i}function se(u,i,p){let m=oe(p),h=`${u.protocol}://${u.url}${u.port?`:${u.port}`:""}/${i.charAt(0)==="/"?i.substring(1):i}`;return m.length&&(h+=`?${m}`),h}function oe(u){return Object.keys(u).filter(i=>u[i]!==void 0).sort().map(i=>`${i}=${encodeURIComponent(Object.prototype.toString.call(u[i])==="[object Array]"?u[i].join(","):u[i]).replace(/\+/g,"%20")}`).join("&")}function ae(u,i){if(u.method==="GET"||u.data===void 0&&i.data===void 0)return;let p=Array.isArray(u.data)?u.data:{...u.data,...i.data};return JSON.stringify(p)}function ne(u,i,p){let m={Accept:"application/json",...u,...i,...p},h={};return Object.keys(m).forEach(P=>{let c=m[P];h[P.toLowerCase()]=c;}),h}function ie(u){try{return JSON.parse(u.content)}catch(i){throw new re(i.message,u)}}function ue({content:u,status:i},p){try{let m=JSON.parse(u);return "error"in m?new te(m.message,i,m.error,p):new b(m.message,i,p)}catch{}return new b(u,i,p)}function ce({isTimedOut:u,status:i}){return !u&&~~i===0}function me({isTimedOut:u,status:i}){return u||ce({isTimedOut:u,status:i})||~~(i/100)!==2&&~~(i/100)!==4}function pe({status:u}){return ~~(u/100)===2}function de(u){return u.map(i=>J(i))}function J(u){let i=u.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...u,request:{...u.request,headers:{...u.request.headers,...i}}}}function z({hosts:u,hostsCache:i,baseHeaders:p,logger:m,baseQueryParameters:h,algoliaAgent:P,timeouts:c,requester:e,requestsCache:r,responsesCache:t}){async function a(n){let d=await Promise.all(n.map(q=>i.get(q,()=>Promise.resolve(B(q))))),l=d.filter(q=>q.isUp()),f=d.filter(q=>q.isTimedOut()),g=[...l,...f];return {hosts:g.length>0?g:n,getTimeout(q,w){return (f.length===0&&q===0?1:f.length+3+q)*w}}}async function o(n,d,l=!0){let f=[],g=ae(n,d),y=ne(p,n.headers,d.headers),q=n.method==="GET"?{...n.data,...d.data}:{},w={...h,...n.queryParameters,...q};if(P.value&&(w["x-algolia-agent"]=P.value),d&&d.queryParameters)for(let R of Object.keys(d.queryParameters))!d.queryParameters[R]||Object.prototype.toString.call(d.queryParameters[R])==="[object Object]"?w[R]=d.queryParameters[R]:w[R]=d.queryParameters[R].toString();let I=0,j=async(R,U)=>{let E=R.pop();if(E===void 0)throw new ee(de(f));let D={...c,...d.timeouts},N={data:g,headers:y,method:n.method,url:se(E,n.path,w),connectTimeout:U(I,D.connect),responseTimeout:U(I,l?D.read:D.write)},k=v=>{let H={request:N,response:v,host:E,triesLeft:R.length};return f.push(H),H},x=await e.send(N);if(me(x)){let v=k(x);return x.isTimedOut&&I++,m.info("Retryable failure",J(v)),await i.set(E,B(E,x.isTimedOut?"timed out":"down")),j(R,U)}if(pe(x))return ie(x);throw k(x),ue(x,f)},X=u.filter(R=>R.accept==="readWrite"||(l?R.accept==="read":R.accept==="write")),C=await a(X);return j([...C.hosts].reverse(),C.getTimeout)}function s(n,d={}){let l=n.useReadTransporter||n.method==="GET";if(!l)return o(n,d,l);let f=()=>o(n,d);if((d.cacheable||n.cacheable)!==!0)return f();let y={request:n,requestOptions:d,transporter:{queryParameters:h,headers:p}};return t.get(y,()=>r.get(y,()=>r.set(y,f()).then(q=>Promise.all([r.delete(y),q]),q=>Promise.all([r.delete(y),Promise.reject(q)])).then(([q,w])=>w)),{miss:q=>t.set(y,q)})}return {hostsCache:i,requester:e,timeouts:c,logger:m,algoliaAgent:P,baseHeaders:p,baseQueryParameters:h,hosts:u,request:s,requestsCache:r,responsesCache:t}}var A="5.16.0";function he(u){return [{url:`${u}-dsn.algolia.net`,accept:"read",protocol:"https"},{url:`${u}.algolia.net`,accept:"write",protocol:"https"}].concat($([{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 V({appId:u,apiKey:i,authMode:p,algoliaAgents:m,...h}){let P=K(u,i,p),c=z({hosts:he(u),...h,algoliaAgent:F({algoliaAgents:m,client:"Search",version:A}),baseHeaders:{"content-type":"text/plain",...P.headers(),...h.baseHeaders},baseQueryParameters:{...P.queryParameters(),...h.baseQueryParameters}});return {transporter:c,appId:u,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:a=s=>Math.min(s*200,5e3)},o){let s=0;return S({func:()=>this.getTask({indexName:e,taskID:r},o),validate:n=>n.status==="published",aggregator:()=>s+=1,error:{validate:()=>s>=t,message:()=>`The maximum number of retries exceeded. (${s}/${t})`},timeout:()=>a(s)})},waitForAppTask({taskID:e,maxRetries:r=50,timeout:t=o=>Math.min(o*200,5e3)},a){let o=0;return S({func:()=>this.getAppTask({taskID:e},a),validate:s=>s.status==="published",aggregator:()=>o+=1,error:{validate:()=>o>=r,message:()=>`The maximum number of retries exceeded. (${o}/${r})`},timeout:()=>t(o)})},waitForApiKey({operation:e,key:r,apiKey:t,maxRetries:a=50,timeout:o=n=>Math.min(n*200,5e3)},s){let n=0,d={aggregator:()=>n+=1,error:{validate:()=>n>=a,message:()=>`The maximum number of retries exceeded. (${n}/${a})`},timeout:()=>o(n)};if(e==="update"){if(!t)throw new Error("`apiKey` is required when waiting for an `update` operation.");return S({...d,func:()=>this.getApiKey({key:r},s),validate:l=>{for(let f of Object.keys(t)){let g=t[f],y=l[f];if(Array.isArray(g)&&Array.isArray(y)){if(g.length!==y.length||g.some((q,w)=>q!==y[w]))return !1}else if(g!==y)return !1}return !0}})}return S({...d,func:()=>this.getApiKey({key:r},s).catch(l=>{if(l.status!==404)throw l}),validate:l=>e==="add"?l!==void 0:l===void 0})},browseObjects({indexName:e,browseParams:r,...t},a){return S({func:o=>this.browse({indexName:e,browseParams:{cursor:o?o.cursor:void 0,hitsPerPage:1e3,...r}},a),validate:o=>o.cursor===void 0,...t})},browseRules({indexName:e,searchRulesParams:r,...t},a){let o={hitsPerPage:1e3,...r};return S({func:s=>this.searchRules({indexName:e,searchRulesParams:{...o,page:s?s.page+1:o.page||0}},a),validate:s=>s.hits.length<o.hitsPerPage,...t})},browseSynonyms({indexName:e,searchSynonymsParams:r,...t},a){let o={page:0,...r,hitsPerPage:1e3};return S({func:s=>{let n=this.searchSynonyms({indexName:e,searchSynonymsParams:{...o,page:o.page}},a);return o.page+=1,n},validate:s=>s.hits.length<o.hitsPerPage,...t})},async chunkedBatch({indexName:e,objects:r,action:t="addObject",waitForTasks:a,batchSize:o=1e3},s){let n=[],d=[],l=r.entries();for(let[f,g]of l)n.push({action:t,body:g}),(n.length===o||f===r.length-1)&&(d.push(await this.batch({indexName:e,batchWriteParams:{requests:n}},s)),n=[]);if(a)for(let f of d)await this.waitForTask({indexName:e,taskID:f.taskID});return d},async saveObjects({indexName:e,objects:r,waitForTasks:t,batchSize:a},o){return await this.chunkedBatch({indexName:e,objects:r,action:"addObject",waitForTasks:t,batchSize:a},o)},async deleteObjects({indexName:e,objectIDs:r,waitForTasks:t,batchSize:a},o){return await this.chunkedBatch({indexName:e,objects:r.map(s=>({objectID:s})),action:"deleteObject",waitForTasks:t,batchSize:a},o)},async partialUpdateObjects({indexName:e,objects:r,createIfNotExists:t,waitForTasks:a,batchSize:o},s){return await this.chunkedBatch({indexName:e,objects:r,action:t?"partialUpdateObject":"partialUpdateObjectNoCreate",batchSize:o,waitForTasks:a},s)},async replaceAllObjects({indexName:e,objects:r,batchSize:t},a){let o=Math.floor(Math.random()*1e6)+1e5,s=`${e}_tmp_${o}`,n=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:s,scope:["settings","rules","synonyms"]}},a),d=await this.chunkedBatch({indexName:s,objects:r,waitForTasks:!0,batchSize:t},a);await this.waitForTask({indexName:s,taskID:n.taskID}),n=await this.operationIndex({indexName:e,operationIndexParams:{operation:"copy",destination:s,scope:["settings","rules","synonyms"]}},a),await this.waitForTask({indexName:s,taskID:n.taskID});let l=await this.operationIndex({indexName:s,operationIndexParams:{operation:"move",destination:e}},a);return await this.waitForTask({indexName:s,taskID:l.taskID}),{copyOperationResponse:n,batchResponses:d,moveOperationResponse:l}},async indexExists({indexName:e}){try{await this.getSettings({indexName:e});}catch(r){if(r instanceof b&&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 s={method:"POST",path:"/1/keys",queryParameters:{},headers:{},data:e};return c.request(s,r)},addOrUpdateObject({indexName:e,objectID:r,body:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `addOrUpdateObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `addOrUpdateObject`.");if(!t)throw new Error("Parameter `body` is required when calling `addOrUpdateObject`.");let d={method:"PUT",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{},data:t};return c.request(d,a)},appendSource(e,r){if(!e)throw new Error("Parameter `source` is required when calling `appendSource`.");if(!e.source)throw new Error("Parameter `source.source` is required when calling `appendSource`.");let s={method:"POST",path:"/1/security/sources/append",queryParameters:{},headers:{},data:e};return c.request(s,r)},assignUserId({xAlgoliaUserID:e,assignUserIdParams:r},t){if(!e)throw new Error("Parameter `xAlgoliaUserID` is required when calling `assignUserId`.");if(!r)throw new Error("Parameter `assignUserIdParams` is required when calling `assignUserId`.");if(!r.cluster)throw new Error("Parameter `assignUserIdParams.cluster` is required when calling `assignUserId`.");let a="/1/clusters/mapping",o={},s={};e!==void 0&&(o["X-Algolia-User-ID"]=e.toString());let n={method:"POST",path:a,queryParameters:s,headers:o,data:r};return c.request(n,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 n={method:"POST",path:"/1/indexes/{indexName}/batch".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},batchAssignUserIds({xAlgoliaUserID:e,batchAssignUserIdsParams:r},t){if(!e)throw new Error("Parameter `xAlgoliaUserID` is required when calling `batchAssignUserIds`.");if(!r)throw new Error("Parameter `batchAssignUserIdsParams` is required when calling `batchAssignUserIds`.");if(!r.cluster)throw new Error("Parameter `batchAssignUserIdsParams.cluster` is required when calling `batchAssignUserIds`.");if(!r.users)throw new Error("Parameter `batchAssignUserIdsParams.users` is required when calling `batchAssignUserIds`.");let a="/1/clusters/mapping/batch",o={},s={};e!==void 0&&(o["X-Algolia-User-ID"]=e.toString());let n={method:"POST",path:a,queryParameters:s,headers:o,data:r};return c.request(n,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 n={method:"POST",path:"/1/dictionaries/{dictionaryName}/batch".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},browse({indexName:e,browseParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `browse`.");let n={method:"POST",path:"/1/indexes/{indexName}/browse".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0};return c.request(n,t)},clearObjects({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `clearObjects`.");let s={method:"POST",path:"/1/indexes/{indexName}/clear".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},clearRules({indexName:e,forwardToReplicas:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `clearRules`.");let a="/1/indexes/{indexName}/rules/clear".replace("{indexName}",encodeURIComponent(e)),o={},s={};r!==void 0&&(s.forwardToReplicas=r.toString());let n={method:"POST",path:a,queryParameters:s,headers:o};return c.request(n,t)},clearSynonyms({indexName:e,forwardToReplicas:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `clearSynonyms`.");let a="/1/indexes/{indexName}/synonyms/clear".replace("{indexName}",encodeURIComponent(e)),o={},s={};r!==void 0&&(s.forwardToReplicas=r.toString());let n={method:"POST",path:a,queryParameters:s,headers:o};return c.request(n,t)},customDelete({path:e,parameters:r},t){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");let n={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{}};return c.request(n,t)},customGet({path:e,parameters:r},t){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");let n={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{}};return c.request(n,t)},customPost({path:e,parameters:r,body:t},a){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");let d={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{},data:t||{}};return c.request(d,a)},customPut({path:e,parameters:r,body:t},a){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");let d={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:r||{},headers:{},data:t||{}};return c.request(d,a)},deleteApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `deleteApiKey`.");let s={method:"DELETE",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,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 n={method:"POST",path:"/1/indexes/{indexName}/deleteByQuery".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},deleteIndex({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteIndex`.");let s={method:"DELETE",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,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 n={method:"DELETE",path:"/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(n,t)},deleteRule({indexName:e,objectID:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteRule`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteRule`.");let o="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),s={},n={};t!==void 0&&(n.forwardToReplicas=t.toString());let d={method:"DELETE",path:o,queryParameters:n,headers:s};return c.request(d,a)},deleteSource({source:e},r){if(!e)throw new Error("Parameter `source` is required when calling `deleteSource`.");let s={method:"DELETE",path:"/1/security/sources/{source}".replace("{source}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},deleteSynonym({indexName:e,objectID:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `deleteSynonym`.");if(!r)throw new Error("Parameter `objectID` is required when calling `deleteSynonym`.");let o="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),s={},n={};t!==void 0&&(n.forwardToReplicas=t.toString());let d={method:"DELETE",path:o,queryParameters:n,headers:s};return c.request(d,a)},getApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `getApiKey`.");let s={method:"GET",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},getAppTask({taskID:e},r){if(!e)throw new Error("Parameter `taskID` is required when calling `getAppTask`.");let s={method:"GET",path:"/1/task/{taskID}".replace("{taskID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},getDictionaryLanguages(e){let o={method:"GET",path:"/1/dictionaries/*/languages",queryParameters:{},headers:{}};return c.request(o,e)},getDictionarySettings(e){let o={method:"GET",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{}};return c.request(o,e)},getLogs({offset:e,length:r,indexName:t,type:a}={},o=void 0){let s="/1/logs",n={},d={};e!==void 0&&(d.offset=e.toString()),r!==void 0&&(d.length=r.toString()),t!==void 0&&(d.indexName=t.toString()),a!==void 0&&(d.type=a.toString());let l={method:"GET",path:s,queryParameters:d,headers:n};return c.request(l,o)},getObject({indexName:e,objectID:r,attributesToRetrieve:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `getObject`.");if(!r)throw new Error("Parameter `objectID` is required when calling `getObject`.");let o="/1/indexes/{indexName}/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),s={},n={};t!==void 0&&(n.attributesToRetrieve=t.toString());let d={method:"GET",path:o,queryParameters:n,headers:s};return c.request(d,a)},getObjects(e,r){if(!e)throw new Error("Parameter `getObjectsParams` is required when calling `getObjects`.");if(!e.requests)throw new Error("Parameter `getObjectsParams.requests` is required when calling `getObjects`.");let s={method:"POST",path:"/1/indexes/*/objects",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(s,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 n={method:"GET",path:"/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(n,t)},getSettings({indexName:e},r){if(!e)throw new Error("Parameter `indexName` is required when calling `getSettings`.");let s={method:"GET",path:"/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},getSources(e){let o={method:"GET",path:"/1/security/sources",queryParameters:{},headers:{}};return c.request(o,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 n={method:"GET",path:"/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(n,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 n={method:"GET",path:"/1/indexes/{indexName}/task/{taskID}".replace("{indexName}",encodeURIComponent(e)).replace("{taskID}",encodeURIComponent(r)),queryParameters:{},headers:{}};return c.request(n,t)},getTopUserIds(e){let o={method:"GET",path:"/1/clusters/mapping/top",queryParameters:{},headers:{}};return c.request(o,e)},getUserId({userID:e},r){if(!e)throw new Error("Parameter `userID` is required when calling `getUserId`.");let s={method:"GET",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},hasPendingMappings({getClusters:e}={},r=void 0){let t="/1/clusters/mapping/pending",a={},o={};e!==void 0&&(o.getClusters=e.toString());let s={method:"GET",path:t,queryParameters:o,headers:a};return c.request(s,r)},listApiKeys(e){let o={method:"GET",path:"/1/keys",queryParameters:{},headers:{}};return c.request(o,e)},listClusters(e){let o={method:"GET",path:"/1/clusters",queryParameters:{},headers:{}};return c.request(o,e)},listIndices({page:e,hitsPerPage:r}={},t=void 0){let a="/1/indexes",o={},s={};e!==void 0&&(s.page=e.toString()),r!==void 0&&(s.hitsPerPage=r.toString());let n={method:"GET",path:a,queryParameters:s,headers:o};return c.request(n,t)},listUserIds({page:e,hitsPerPage:r}={},t=void 0){let a="/1/clusters/mapping",o={},s={};e!==void 0&&(s.page=e.toString()),r!==void 0&&(s.hitsPerPage=r.toString());let n={method:"GET",path:a,queryParameters:s,headers:o};return c.request(n,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 s={method:"POST",path:"/1/indexes/*/batch",queryParameters:{},headers:{},data:e};return c.request(s,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 n={method:"POST",path:"/1/indexes/{indexName}/operation".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},partialUpdateObject({indexName:e,objectID:r,attributesToUpdate:t,createIfNotExists:a},o){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 s="/1/indexes/{indexName}/{objectID}/partial".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),n={},d={};a!==void 0&&(d.createIfNotExists=a.toString());let l={method:"POST",path:s,queryParameters:d,headers:n,data:t};return c.request(l,o)},removeUserId({userID:e},r){if(!e)throw new Error("Parameter `userID` is required when calling `removeUserId`.");let s={method:"DELETE",path:"/1/clusters/mapping/{userID}".replace("{userID}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,r)},replaceSources({source:e},r){if(!e)throw new Error("Parameter `source` is required when calling `replaceSources`.");let s={method:"PUT",path:"/1/security/sources",queryParameters:{},headers:{},data:e};return c.request(s,r)},restoreApiKey({key:e},r){if(!e)throw new Error("Parameter `key` is required when calling `restoreApiKey`.");let s={method:"POST",path:"/1/keys/{key}/restore".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{}};return c.request(s,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 n={method:"POST",path:"/1/indexes/{indexName}".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)},saveRule({indexName:e,objectID:r,rule:t,forwardToReplicas:a},o){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 s="/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),n={},d={};a!==void 0&&(d.forwardToReplicas=a.toString());let l={method:"PUT",path:s,queryParameters:d,headers:n,data:t};return c.request(l,o)},saveRules({indexName:e,rules:r,forwardToReplicas:t,clearExistingRules:a},o){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 s="/1/indexes/{indexName}/rules/batch".replace("{indexName}",encodeURIComponent(e)),n={},d={};t!==void 0&&(d.forwardToReplicas=t.toString()),a!==void 0&&(d.clearExistingRules=a.toString());let l={method:"POST",path:s,queryParameters:d,headers:n,data:r};return c.request(l,o)},saveSynonym({indexName:e,objectID:r,synonymHit:t,forwardToReplicas:a},o){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 s="/1/indexes/{indexName}/synonyms/{objectID}".replace("{indexName}",encodeURIComponent(e)).replace("{objectID}",encodeURIComponent(r)),n={},d={};a!==void 0&&(d.forwardToReplicas=a.toString());let l={method:"PUT",path:s,queryParameters:d,headers:n,data:t};return c.request(l,o)},saveSynonyms({indexName:e,synonymHit:r,forwardToReplicas:t,replaceExistingSynonyms:a},o){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 s="/1/indexes/{indexName}/synonyms/batch".replace("{indexName}",encodeURIComponent(e)),n={},d={};t!==void 0&&(d.forwardToReplicas=t.toString()),a!==void 0&&(d.replaceExistingSynonyms=a.toString());let l={method:"POST",path:s,queryParameters:d,headers:n,data:r};return c.request(l,o)},search(e,r){if(e&&Array.isArray(e)&&(e={requests:e.map(({params:d,...l})=>l.type==="facet"?{...l,...d,type:"facet"}:{...l,...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 s={method:"POST",path:"/1/indexes/*/queries",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(s,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 n={method:"POST",path:"/1/dictionaries/{dictionaryName}/search".replace("{dictionaryName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r,useReadTransporter:!0,cacheable:!0};return c.request(n,t)},searchForFacetValues({indexName:e,facetName:r,searchForFacetValuesRequest:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `searchForFacetValues`.");if(!r)throw new Error("Parameter `facetName` is required when calling `searchForFacetValues`.");let d={method:"POST",path:"/1/indexes/{indexName}/facets/{facetName}/query".replace("{indexName}",encodeURIComponent(e)).replace("{facetName}",encodeURIComponent(r)),queryParameters:{},headers:{},data:t||{},useReadTransporter:!0,cacheable:!0};return c.request(d,a)},searchRules({indexName:e,searchRulesParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchRules`.");let n={method:"POST",path:"/1/indexes/{indexName}/rules/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return c.request(n,t)},searchSingleIndex({indexName:e,searchParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchSingleIndex`.");let n={method:"POST",path:"/1/indexes/{indexName}/query".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return c.request(n,t)},searchSynonyms({indexName:e,searchSynonymsParams:r},t){if(!e)throw new Error("Parameter `indexName` is required when calling `searchSynonyms`.");let n={method:"POST",path:"/1/indexes/{indexName}/synonyms/search".replace("{indexName}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r||{},useReadTransporter:!0,cacheable:!0};return c.request(n,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 s={method:"POST",path:"/1/clusters/mapping/search",queryParameters:{},headers:{},data:e,useReadTransporter:!0,cacheable:!0};return c.request(s,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 s={method:"PUT",path:"/1/dictionaries/*/settings",queryParameters:{},headers:{},data:e};return c.request(s,r)},setSettings({indexName:e,indexSettings:r,forwardToReplicas:t},a){if(!e)throw new Error("Parameter `indexName` is required when calling `setSettings`.");if(!r)throw new Error("Parameter `indexSettings` is required when calling `setSettings`.");let o="/1/indexes/{indexName}/settings".replace("{indexName}",encodeURIComponent(e)),s={},n={};t!==void 0&&(n.forwardToReplicas=t.toString());let d={method:"PUT",path:o,queryParameters:n,headers:s,data:r};return c.request(d,a)},updateApiKey({key:e,apiKey:r},t){if(!e)throw new Error("Parameter `key` is required when calling `updateApiKey`.");if(!r)throw new Error("Parameter `apiKey` is required when calling `updateApiKey`.");if(!r.acl)throw new Error("Parameter `apiKey.acl` is required when calling `updateApiKey`.");let n={method:"PUT",path:"/1/keys/{key}".replace("{key}",encodeURIComponent(e)),queryParameters:{},headers:{},data:r};return c.request(n,t)}}}function Ws(u,i,p){if(!u||typeof u!="string")throw new Error("`appId` is missing.");if(!i||typeof i!="string")throw new Error("`apiKey` is missing.");return V({appId:u,apiKey:i,timeouts:{connect:1e3,read:2e3,write:3e4},logger:_(),requester:Q(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:T(),requestsCache:T({serializable:!1}),hostsCache:O({caches:[L({key:`${A}-${u}`}),T()]}),...p})}
|
|
8
8
|
|
|
9
9
|
exports.apiClientVersion = A;
|
|
10
|
-
exports.searchClient =
|
|
10
|
+
exports.searchClient = Ws;
|
|
11
11
|
|
|
12
12
|
}));
|
package/dist/builds/fetch.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
// builds/fetch.ts
|
|
2
|
-
import {
|
|
3
|
-
createMemoryCache,
|
|
4
|
-
createNullCache,
|
|
5
|
-
createNullLogger,
|
|
6
|
-
DEFAULT_CONNECT_TIMEOUT_NODE,
|
|
7
|
-
DEFAULT_READ_TIMEOUT_NODE,
|
|
8
|
-
DEFAULT_WRITE_TIMEOUT_NODE,
|
|
9
|
-
serializeQueryParameters
|
|
10
|
-
} from "@algolia/client-common";
|
|
2
|
+
import { createMemoryCache, createNullCache, createNullLogger, serializeQueryParameters } from "@algolia/client-common";
|
|
11
3
|
import { createFetchRequester } from "@algolia/requester-fetch";
|
|
12
4
|
|
|
13
5
|
// src/searchClient.ts
|
|
@@ -19,7 +11,7 @@ import {
|
|
|
19
11
|
getAlgoliaAgent,
|
|
20
12
|
shuffle
|
|
21
13
|
} from "@algolia/client-common";
|
|
22
|
-
var apiClientVersion = "5.
|
|
14
|
+
var apiClientVersion = "5.16.0";
|
|
23
15
|
function getDefaultHosts(appId) {
|
|
24
16
|
return [
|
|
25
17
|
{
|
|
@@ -376,11 +368,15 @@ function createSearchClient({
|
|
|
376
368
|
* @param saveObjects - The `saveObjects` object.
|
|
377
369
|
* @param saveObjects.indexName - The `indexName` to save `objects` in.
|
|
378
370
|
* @param saveObjects.objects - The array of `objects` to store in the given Algolia `indexName`.
|
|
371
|
+
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
379
372
|
* @param saveObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
380
373
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
381
374
|
*/
|
|
382
|
-
async saveObjects({ indexName, objects, waitForTasks }, requestOptions) {
|
|
383
|
-
return await this.chunkedBatch(
|
|
375
|
+
async saveObjects({ indexName, objects, waitForTasks, batchSize }, requestOptions) {
|
|
376
|
+
return await this.chunkedBatch(
|
|
377
|
+
{ indexName, objects, action: "addObject", waitForTasks, batchSize },
|
|
378
|
+
requestOptions
|
|
379
|
+
);
|
|
384
380
|
},
|
|
385
381
|
/**
|
|
386
382
|
* Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under the hood, which creates a `batch` requests with at most 1000 objectIDs in it.
|
|
@@ -389,16 +385,18 @@ function createSearchClient({
|
|
|
389
385
|
* @param deleteObjects - The `deleteObjects` object.
|
|
390
386
|
* @param deleteObjects.indexName - The `indexName` to delete `objectIDs` from.
|
|
391
387
|
* @param deleteObjects.objectIDs - The objectIDs to delete.
|
|
388
|
+
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
392
389
|
* @param deleteObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
393
390
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `batch` method and merged with the transporter requestOptions.
|
|
394
391
|
*/
|
|
395
|
-
async deleteObjects({ indexName, objectIDs, waitForTasks }, requestOptions) {
|
|
392
|
+
async deleteObjects({ indexName, objectIDs, waitForTasks, batchSize }, requestOptions) {
|
|
396
393
|
return await this.chunkedBatch(
|
|
397
394
|
{
|
|
398
395
|
indexName,
|
|
399
396
|
objects: objectIDs.map((objectID) => ({ objectID })),
|
|
400
397
|
action: "deleteObject",
|
|
401
|
-
waitForTasks
|
|
398
|
+
waitForTasks,
|
|
399
|
+
batchSize
|
|
402
400
|
},
|
|
403
401
|
requestOptions
|
|
404
402
|
);
|
|
@@ -411,15 +409,17 @@ function createSearchClient({
|
|
|
411
409
|
* @param partialUpdateObjects.indexName - The `indexName` to update `objects` in.
|
|
412
410
|
* @param partialUpdateObjects.objects - The array of `objects` to update in the given Algolia `indexName`.
|
|
413
411
|
* @param partialUpdateObjects.createIfNotExists - To be provided if non-existing objects are passed, otherwise, the call will fail..
|
|
412
|
+
* @param chunkedBatch.batchSize - The size of the chunk of `objects`. The number of `batch` calls will be equal to `length(objects) / batchSize`. Defaults to 1000.
|
|
414
413
|
* @param partialUpdateObjects.waitForTasks - Whether or not we should wait until every `batch` tasks has been processed, this operation may slow the total execution time of this method but is more reliable.
|
|
415
414
|
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `getTask` method and merged with the transporter requestOptions.
|
|
416
415
|
*/
|
|
417
|
-
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks }, requestOptions) {
|
|
416
|
+
async partialUpdateObjects({ indexName, objects, createIfNotExists, waitForTasks, batchSize }, requestOptions) {
|
|
418
417
|
return await this.chunkedBatch(
|
|
419
418
|
{
|
|
420
419
|
indexName,
|
|
421
420
|
objects,
|
|
422
421
|
action: createIfNotExists ? "partialUpdateObject" : "partialUpdateObjectNoCreate",
|
|
422
|
+
batchSize,
|
|
423
423
|
waitForTasks
|
|
424
424
|
},
|
|
425
425
|
requestOptions
|
|
@@ -642,7 +642,7 @@ function createSearchClient({
|
|
|
642
642
|
return transporter.request(request, requestOptions);
|
|
643
643
|
},
|
|
644
644
|
/**
|
|
645
|
-
* Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they\'re specified. - Actions are equivalent to the individual API requests of the same name.
|
|
645
|
+
* Adds, updates, or deletes records in one index with a single API request. Batching index updates reduces latency and increases data integrity. - Actions are applied in the order they\'re specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
646
646
|
* @param batch - The batch object.
|
|
647
647
|
* @param batch.indexName - Name of the index on which to perform the operation.
|
|
648
648
|
* @param batch.batchWriteParams - The batchWriteParams object.
|
|
@@ -773,7 +773,7 @@ function createSearchClient({
|
|
|
773
773
|
return transporter.request(request, requestOptions);
|
|
774
774
|
},
|
|
775
775
|
/**
|
|
776
|
-
* Deletes only the records from an index while keeping settings, synonyms, and rules.
|
|
776
|
+
* Deletes only the records from an index while keeping settings, synonyms, and rules. This operation is resource-intensive and subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
777
777
|
*
|
|
778
778
|
* Required API Key ACLs:
|
|
779
779
|
* - deleteIndex
|
|
@@ -969,7 +969,7 @@ function createSearchClient({
|
|
|
969
969
|
return transporter.request(request, requestOptions);
|
|
970
970
|
},
|
|
971
971
|
/**
|
|
972
|
-
* This operation doesn\'t accept empty
|
|
972
|
+
* This operation doesn\'t accept empty filters. This operation is resource-intensive. You should only use it if you can\'t get the object IDs of the records you want to delete. It\'s more efficient to get a list of object IDs with the [`browse` operation](#tag/Search/operation/browse), and then delete the records using the [`batch` operation](#tag/Records/operation/batch). This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
973
973
|
*
|
|
974
974
|
* Required API Key ACLs:
|
|
975
975
|
* - deleteIndex
|
|
@@ -1606,7 +1606,7 @@ function createSearchClient({
|
|
|
1606
1606
|
return transporter.request(request, requestOptions);
|
|
1607
1607
|
},
|
|
1608
1608
|
/**
|
|
1609
|
-
* Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name.
|
|
1609
|
+
* Adds, updates, or deletes records in multiple indices with a single API request. - Actions are applied in the order they are specified. - Actions are equivalent to the individual API requests of the same name. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
1610
1610
|
* @param batchParams - The batchParams object.
|
|
1611
1611
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
1612
1612
|
*/
|
|
@@ -1630,7 +1630,7 @@ function createSearchClient({
|
|
|
1630
1630
|
return transporter.request(request, requestOptions);
|
|
1631
1631
|
},
|
|
1632
1632
|
/**
|
|
1633
|
-
* Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn\'t exist yet, it\'ll be created. **Copy** - Copying a source index that doesn\'t exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can\'t copy the `enableReRanking`, `mode`, and `replicas` settings. - You can\'t copy to a destination index that already has replicas. - Be aware of the [size limits](https://www.algolia.com/doc/guides/scaling/algolia-service-limits/#application-record-and-index-limits). - Related guide: [Copy indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/copy-indices/) **Move** - Moving a source index that doesn\'t exist is ignored without returning an error. - When moving an index, the analytics data keeps its original name, and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: [Move indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/move-indices/).
|
|
1633
|
+
* Copies or moves (renames) an index within the same Algolia application. - Existing destination indices are overwritten, except for their analytics data. - If the destination index doesn\'t exist yet, it\'ll be created. - This operation is resource-intensive. **Copy** - Copying a source index that doesn\'t exist creates a new index with 0 records and default settings. - The API keys of the source index are merged with the existing keys in the destination index. - You can\'t copy the `enableReRanking`, `mode`, and `replicas` settings. - You can\'t copy to a destination index that already has replicas. - Be aware of the [size limits](https://www.algolia.com/doc/guides/scaling/algolia-service-limits/#application-record-and-index-limits). - Related guide: [Copy indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/copy-indices/) **Move** - Moving a source index that doesn\'t exist is ignored without returning an error. - When moving an index, the analytics data keeps its original name, and a new set of analytics data is started for the new name. To access the original analytics in the dashboard, create an index with the original name. - If the destination index has replicas, moving will overwrite the existing index and copy the data to the replica indices. - Related guide: [Move indices](https://www.algolia.com/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/move-indices/). This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
1634
1634
|
*
|
|
1635
1635
|
* Required API Key ACLs:
|
|
1636
1636
|
* - addObject
|
|
@@ -1665,7 +1665,7 @@ function createSearchClient({
|
|
|
1665
1665
|
return transporter.request(request, requestOptions);
|
|
1666
1666
|
},
|
|
1667
1667
|
/**
|
|
1668
|
-
* Adds new attributes to a record, or updates existing ones. - If a record with the specified object ID doesn\'t exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn\'t exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute,
|
|
1668
|
+
* Adds new attributes to a record, or updates existing ones. - If a record with the specified object ID doesn\'t exist, a new record is added to the index **if** `createIfNotExists` is true. - If the index doesn\'t exist yet, this method creates a new index. - You can use any first-level attribute but not nested attributes. If you specify a nested attribute, this operation replaces its first-level ancestor. To update an attribute without pushing the entire record, you can use these built-in operations. These operations can be helpful if you don\'t have access to your initial data. - Increment: increment a numeric attribute - Decrement: decrement a numeric attribute - Add: append a number or string element to an array attribute - Remove: remove all matching number or string elements from an array attribute made of numbers or strings - AddUnique: add a number or string element to an array attribute made of numbers or strings only if it\'s not already present - IncrementFrom: increment a numeric integer attribute only if the provided value matches the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementFrom value of 2 for the version attribute, but the current value of the attribute is 1, the engine ignores the update. If the object doesn\'t exist, the engine only creates it if you pass an IncrementFrom value of 0. - IncrementSet: increment a numeric integer attribute only if the provided value is greater than the current value, and otherwise ignore the whole object update. For example, if you pass an IncrementSet value of 2 for the version attribute, and the current value of the attribute is 1, the engine updates the object. If the object doesn\'t exist yet, the engine only creates it if you pass an IncrementSet value greater than 0. You can specify an operation by providing an object with the attribute to update as the key and its value being an object with the following properties: - _operation: the operation to apply on the attribute - value: the right-hand side argument to the operation, for example, increment or decrement step, value to add or remove. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
1669
1669
|
*
|
|
1670
1670
|
* Required API Key ACLs:
|
|
1671
1671
|
* - addObject
|
|
@@ -1775,7 +1775,7 @@ function createSearchClient({
|
|
|
1775
1775
|
return transporter.request(request, requestOptions);
|
|
1776
1776
|
},
|
|
1777
1777
|
/**
|
|
1778
|
-
* Adds a record to an index or replace it. - If the record doesn\'t have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn\'t exist, a new record is added to your index. - If you add a record to an index that doesn\'t exist yet, a new index is created. To update _some_ attributes of a record, use the [`partial` operation](#tag/Records/operation/partialUpdateObject). To add, update, or replace multiple records, use the [`batch` operation](#tag/Records/operation/batch).
|
|
1778
|
+
* Adds a record to an index or replace it. - If the record doesn\'t have an object ID, a new record with an auto-generated object ID is added to your index. - If a record with the specified object ID exists, the existing record is replaced. - If a record with the specified object ID doesn\'t exist, a new record is added to your index. - If you add a record to an index that doesn\'t exist yet, a new index is created. To update _some_ attributes of a record, use the [`partial` operation](#tag/Records/operation/partialUpdateObject). To add, update, or replace multiple records, use the [`batch` operation](#tag/Records/operation/batch). This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
1779
1779
|
*
|
|
1780
1780
|
* Required API Key ACLs:
|
|
1781
1781
|
* - addObject
|
|
@@ -1828,6 +1828,9 @@ function createSearchClient({
|
|
|
1828
1828
|
if (!rule.objectID) {
|
|
1829
1829
|
throw new Error("Parameter `rule.objectID` is required when calling `saveRule`.");
|
|
1830
1830
|
}
|
|
1831
|
+
if (!rule.consequence) {
|
|
1832
|
+
throw new Error("Parameter `rule.consequence` is required when calling `saveRule`.");
|
|
1833
|
+
}
|
|
1831
1834
|
const requestPath = "/1/indexes/{indexName}/rules/{objectID}".replace("{indexName}", encodeURIComponent(indexName)).replace("{objectID}", encodeURIComponent(objectID));
|
|
1832
1835
|
const headers = {};
|
|
1833
1836
|
const queryParameters = {};
|
|
@@ -1844,7 +1847,7 @@ function createSearchClient({
|
|
|
1844
1847
|
return transporter.request(request, requestOptions);
|
|
1845
1848
|
},
|
|
1846
1849
|
/**
|
|
1847
|
-
* Create or update multiple rules. If a rule with the specified object ID doesn\'t exist, Algolia creates a new one. Otherwise, existing rules are replaced.
|
|
1850
|
+
* Create or update multiple rules. If a rule with the specified object ID doesn\'t exist, Algolia creates a new one. Otherwise, existing rules are replaced. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
1848
1851
|
*
|
|
1849
1852
|
* Required API Key ACLs:
|
|
1850
1853
|
* - editSettings
|
|
@@ -1924,7 +1927,7 @@ function createSearchClient({
|
|
|
1924
1927
|
return transporter.request(request, requestOptions);
|
|
1925
1928
|
},
|
|
1926
1929
|
/**
|
|
1927
|
-
* If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced.
|
|
1930
|
+
* If a synonym with the `objectID` doesn\'t exist, Algolia adds a new one. Otherwise, existing synonyms are replaced. This operation is subject to [indexing rate limits](https://support.algolia.com/hc/en-us/articles/4406975251089-Is-there-a-rate-limit-for-indexing-on-Algolia).
|
|
1928
1931
|
*
|
|
1929
1932
|
* Required API Key ACLs:
|
|
1930
1933
|
* - editSettings
|
|
@@ -2310,9 +2313,9 @@ function searchClient(appId, apiKey, options) {
|
|
|
2310
2313
|
appId,
|
|
2311
2314
|
apiKey,
|
|
2312
2315
|
timeouts: {
|
|
2313
|
-
connect:
|
|
2314
|
-
read:
|
|
2315
|
-
write:
|
|
2316
|
+
connect: 2e3,
|
|
2317
|
+
read: 5e3,
|
|
2318
|
+
write: 3e4
|
|
2316
2319
|
},
|
|
2317
2320
|
logger: createNullLogger(),
|
|
2318
2321
|
algoliaAgents: [{ segment: "Fetch" }],
|