@algolia/client-query-suggestions
Advanced tools
Comparing version 5.15.0 to 5.16.0
@@ -256,3 +256,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "5.15.0"; | ||
declare const apiClientVersion = "5.16.0"; | ||
declare const REGIONS: readonly ["eu", "us"]; | ||
@@ -259,0 +259,0 @@ type Region = (typeof REGIONS)[number]; |
@@ -7,6 +7,3 @@ // builds/browser.ts | ||
createMemoryCache, | ||
createNullLogger, | ||
DEFAULT_CONNECT_TIMEOUT_BROWSER, | ||
DEFAULT_READ_TIMEOUT_BROWSER, | ||
DEFAULT_WRITE_TIMEOUT_BROWSER | ||
createNullLogger | ||
} from "@algolia/client-common"; | ||
@@ -16,3 +13,3 @@ | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.15.0"; | ||
var apiClientVersion = "5.16.0"; | ||
var REGIONS = ["eu", "us"]; | ||
@@ -372,5 +369,5 @@ function getDefaultHosts(region) { | ||
timeouts: { | ||
connect: DEFAULT_CONNECT_TIMEOUT_BROWSER, | ||
read: DEFAULT_READ_TIMEOUT_BROWSER, | ||
write: DEFAULT_WRITE_TIMEOUT_BROWSER | ||
connect: 1e3, | ||
read: 2e3, | ||
write: 3e4 | ||
}, | ||
@@ -377,0 +374,0 @@ logger: createNullLogger(), |
@@ -1,2 +0,2 @@ | ||
function k(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let i=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},a),m=i(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(p),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(m),clearTimeout(p),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function G(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function i(){return JSON.parse(t().getItem(o)||"{}")}function m(a){t().setItem(o,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,s=i(),n=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let c=Object.fromEntries(Object.entries(n).filter(([,d])=>{let h=new Date().getTime();return!(d.timestamp+a<h)}));m(c)}return{get(a,s,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(c=>Promise.all([c?c.value:s(),c!==void 0])).then(([c,d])=>Promise.all([c,d||n.miss(c)])).then(([c])=>c)},set(a,s){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(n)),s})},delete(a){return Promise.resolve().then(()=>{let s=i();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,o.miss(i)])).then(([i])=>i)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function T(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,i,m={miss:()=>Promise.resolve()}){return o.get(t,i,m).catch(()=>T({caches:e}).get(t,i,m))},set(t,i){return o.set(t,i).catch(()=>T({caches:e}).set(t,i))},delete(t){return o.delete(t).catch(()=>T({caches:e}).delete(t))},clear(){return o.clear().catch(()=>T({caches:e}).clear())}}}function v(r={serializable:!0}){let e={};return{get(o,t,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let p=t();return p.then(a=>i.miss(a)).then(()=>p)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var F=1e3,$=2e3,j=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function M({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(i=>t.add(i)),t}function z(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var W=2*60*1e3;function Q(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>W}function i(){return e==="timed out"&&Date.now()-o<=W}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:i}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends X{constructor(r){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.",r,"RetryError")}},b=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends b{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function ne(r,e,o){let t=ae(o),i=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(i+=`?${t}`),i}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ue(r,e,o){let t={Accept:"application/json",...r,...e,...o},i={};return Object.keys(t).forEach(m=>{let p=t[m];i[m.toLowerCase()]=p}),i}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new b(t.message,e,o)}catch{}return new b(r,e,o)}function me({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ge({status:r}){return~~(r/100)===2}function pe(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:s,responsesCache:n}){async function c(u){let l=await Promise.all(u.map(g=>e.get(g,()=>Promise.resolve(Q(g))))),P=l.filter(g=>g.isUp()),y=l.filter(g=>g.isTimedOut()),w=[...P,...y];return{hosts:w.length>0?w:u,getTimeout(g,E){return(y.length===0&&g===0?1:y.length+3+g)*E}}}async function d(u,l,P=!0){let y=[],w=ie(u,l),q=ue(o,u.headers,l.headers),g=u.method==="GET"?{...u.data,...l.data}:{},E={...i,...u.queryParameters,...g};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?E[f]=l.queryParameters[f]:E[f]=l.queryParameters[f].toString();let O=0,I=async(f,x)=>{let C=f.pop();if(C===void 0)throw new te(pe(y));let A={...p,...l.timeouts},U={data:w,headers:q,method:u.method,url:ne(C,u.path,E),connectTimeout:x(O,A.connect),responseTimeout:x(O,P?A.read:A.write)},L=N=>{let H={request:U,response:N,host:C,triesLeft:f.length};return y.push(H),H},R=await a.send(U);if(de(R)){let N=L(R);return R.isTimedOut&&O++,t.info("Retryable failure",K(N)),await e.set(C,Q(C,R.isTimedOut?"timed out":"down")),I(f,x)}if(ge(R))return ce(R);throw L(R),le(R,y)},Z=r.filter(f=>f.accept==="readWrite"||(P?f.accept==="read":f.accept==="write")),D=await c(Z);return I([...D.hosts].reverse(),D.getTimeout)}function h(u,l={}){let P=u.useReadTransporter||u.method==="GET";if(!P)return d(u,l,P);let y=()=>d(u,l);if((l.cacheable||u.cacheable)!==!0)return y();let q={request:u,requestOptions:l,transporter:{queryParameters:i,headers:o}};return n.get(q,()=>s.get(q,()=>s.set(q,y()).then(g=>Promise.all([s.delete(q),g]),g=>Promise.all([s.delete(q),Promise.reject(g)])).then(([g,E])=>E)),{miss:g=>n.set(q,g)})}return{hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:i,hosts:r,request:h,requestsCache:s,responsesCache:n}}var S="5.15.0",_=["eu","us"];function he(r){return[{url:"query-suggestions.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:i,...m}){let p=J(r,e,o),a=V({hosts:he(i),...m,algoliaAgent:M({algoliaAgents:t,client:"QuerySuggestions",version:S}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,n){a.algoliaAgent.add({segment:s,version:n})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s},createConfig(s,n){if(!s)throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");let u={method:"POST",path:"/1/configs",queryParameters:{},headers:{},data:s};return a.request(u,n)},customDelete({path:s,parameters:n},c){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return a.request(l,c)},customGet({path:s,parameters:n},c){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return a.request(l,c)},customPost({path:s,parameters:n,body:c},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let P={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:c||{}};return a.request(P,d)},customPut({path:s,parameters:n,body:c},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let P={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:c||{}};return a.request(P,d)},deleteConfig({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");let u={method:"DELETE",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getAllConfigs(s){let h={method:"GET",path:"/1/configs",queryParameters:{},headers:{}};return a.request(h,s)},getConfig({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getConfig`.");let u={method:"GET",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getConfigStatus({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");let u={method:"GET",path:"/1/configs/{indexName}/status".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getLogFile({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getLogFile`.");let u={method:"GET",path:"/1/logs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},updateConfig({indexName:s,configuration:n},c){if(!s)throw new Error("Parameter `indexName` is required when calling `updateConfig`.");if(!n)throw new Error("Parameter `configuration` is required when calling `updateConfig`.");if(!n.sourceIndices)throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");let l={method:"PUT",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{},data:n};return a.request(l,c)}}}function $e(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!_.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${_.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:F,read:$,write:j},logger:z(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:v(),requestsCache:v({serializable:!1}),hostsCache:T({caches:[G({key:`${S}-${r}`}),v()]}),...t})}export{S as apiClientVersion,$e as querySuggestionsClient}; | ||
function k(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let i=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},a),m=i(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(p),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(m),clearTimeout(p),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function W(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function i(){return JSON.parse(t().getItem(o)||"{}")}function m(a){t().setItem(o,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,s=i(),n=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let c=Object.fromEntries(Object.entries(n).filter(([,d])=>{let h=new Date().getTime();return!(d.timestamp+a<h)}));m(c)}return{get(a,s,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(c=>Promise.all([c?c.value:s(),c!==void 0])).then(([c,d])=>Promise.all([c,d||n.miss(c)])).then(([c])=>c)},set(a,s){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(n)),s})},delete(a){return Promise.resolve().then(()=>{let s=i();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function V(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,o.miss(i)])).then(([i])=>i)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(r){let e=[...r.caches],o=e.shift();return o===void 0?V():{get(t,i,m={miss:()=>Promise.resolve()}){return o.get(t,i,m).catch(()=>R({caches:e}).get(t,i,m))},set(t,i){return o.set(t,i).catch(()=>R({caches:e}).set(t,i))},delete(t){return o.delete(t).catch(()=>R({caches:e}).delete(t))},clear(){return o.clear().catch(()=>R({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(o,t,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let p=t();return p.then(a=>i.miss(a)).then(()=>p)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function $(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function j({algoliaAgents:r,client:e,version:o}){let t=Y(o).add({segment:e,version:o});return r.forEach(i=>t.add(i)),t}function J(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var Q=2*60*1e3;function G(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>Q}function i(){return e==="timed out"&&Date.now()-o<=Q}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:i}}var F=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},z=class extends F{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},Z=class extends z{constructor(r){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.",r,"RetryError")}},b=class extends z{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},ee=class extends F{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends b{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function te(r,e,o){let t=oe(o),i=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(i+=`?${t}`),i}function oe(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function se(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ne(r,e,o){let t={Accept:"application/json",...r,...e,...o},i={};return Object.keys(t).forEach(m=>{let p=t[m];i[m.toLowerCase()]=p}),i}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,o):new b(t.message,e,o)}catch{}return new b(r,e,o)}function ue({isTimedOut:r,status:e}){return!r&&~~e===0}function ce({isTimedOut:r,status:e}){return r||ue({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>M(e))}function M(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function B({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:s,responsesCache:n}){async function c(u){let l=await Promise.all(u.map(g=>e.get(g,()=>Promise.resolve(G(g))))),P=l.filter(g=>g.isUp()),y=l.filter(g=>g.isTimedOut()),C=[...P,...y];return{hosts:C.length>0?C:u,getTimeout(g,w){return(y.length===0&&g===0?1:y.length+3+g)*w}}}async function d(u,l,P=!0){let y=[],C=se(u,l),q=ne(o,u.headers,l.headers),g=u.method==="GET"?{...u.data,...l.data}:{},w={...i,...u.queryParameters,...g};if(m.value&&(w["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?w[f]=l.queryParameters[f]:w[f]=l.queryParameters[f].toString();let v=0,D=async(f,S)=>{let T=f.pop();if(T===void 0)throw new Z(me(y));let A={...p,...l.timeouts},U={data:C,headers:q,method:u.method,url:te(T,u.path,w),connectTimeout:S(v,A.connect),responseTimeout:S(v,P?A.read:A.write)},L=N=>{let H={request:U,response:N,host:T,triesLeft:f.length};return y.push(H),H},E=await a.send(U);if(ce(E)){let N=L(E);return E.isTimedOut&&v++,t.info("Retryable failure",M(N)),await e.set(T,G(T,E.isTimedOut?"timed out":"down")),D(f,S)}if(le(E))return ae(E);throw L(E),ie(E,y)},K=r.filter(f=>f.accept==="readWrite"||(P?f.accept==="read":f.accept==="write")),_=await c(K);return D([..._.hosts].reverse(),_.getTimeout)}function h(u,l={}){let P=u.useReadTransporter||u.method==="GET";if(!P)return d(u,l,P);let y=()=>d(u,l);if((l.cacheable||u.cacheable)!==!0)return y();let q={request:u,requestOptions:l,transporter:{queryParameters:i,headers:o}};return n.get(q,()=>s.get(q,()=>s.set(q,y()).then(g=>Promise.all([s.delete(q),g]),g=>Promise.all([s.delete(q),Promise.reject(g)])).then(([g,w])=>w)),{miss:g=>n.set(q,g)})}return{hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:i,hosts:r,request:h,requestsCache:s,responsesCache:n}}var x="5.16.0",I=["eu","us"];function de(r){return[{url:"query-suggestions.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:i,...m}){let p=$(r,e,o),a=B({hosts:de(i),...m,algoliaAgent:j({algoliaAgents:t,client:"QuerySuggestions",version:x}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,n){a.algoliaAgent.add({segment:s,version:n})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s},createConfig(s,n){if(!s)throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");let u={method:"POST",path:"/1/configs",queryParameters:{},headers:{},data:s};return a.request(u,n)},customDelete({path:s,parameters:n},c){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return a.request(l,c)},customGet({path:s,parameters:n},c){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return a.request(l,c)},customPost({path:s,parameters:n,body:c},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let P={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:c||{}};return a.request(P,d)},customPut({path:s,parameters:n,body:c},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let P={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:c||{}};return a.request(P,d)},deleteConfig({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");let u={method:"DELETE",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getAllConfigs(s){let h={method:"GET",path:"/1/configs",queryParameters:{},headers:{}};return a.request(h,s)},getConfig({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getConfig`.");let u={method:"GET",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getConfigStatus({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");let u={method:"GET",path:"/1/configs/{indexName}/status".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getLogFile({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getLogFile`.");let u={method:"GET",path:"/1/logs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},updateConfig({indexName:s,configuration:n},c){if(!s)throw new Error("Parameter `indexName` is required when calling `updateConfig`.");if(!n)throw new Error("Parameter `configuration` is required when calling `updateConfig`.");if(!n.sourceIndices)throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");let l={method:"PUT",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{},data:n};return a.request(l,c)}}}function Ge(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!I.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${I.join(", ")}`);return X({appId:r,apiKey:e,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},logger:J(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:R({caches:[W({key:`${x}-${r}`}),O()]}),...t})}export{x as apiClientVersion,Ge as querySuggestionsClient}; | ||
//# sourceMappingURL=browser.min.js.map |
@@ -7,7 +7,7 @@ (function (global, factory) { | ||
function k(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let i=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0});},a),m=i(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(p),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(m),clearTimeout(p),o({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}function G(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function i(){return JSON.parse(t().getItem(o)||"{}")}function m(a){t().setItem(o,JSON.stringify(a));}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,s=i(),n=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let c=Object.fromEntries(Object.entries(n).filter(([,d])=>{let h=new Date().getTime();return !(d.timestamp+a<h)}));m(c);}return {get(a,s,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(c=>Promise.all([c?c.value:s(),c!==void 0])).then(([c,d])=>Promise.all([c,d||n.miss(c)])).then(([c])=>c)},set(a,s){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(n)),s})},delete(a){return Promise.resolve().then(()=>{let s=i();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s));})},clear(){return Promise.resolve().then(()=>{t().removeItem(o);})}}}function ee(){return {get(r,e,o={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,o.miss(i)])).then(([i])=>i)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function T(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,i,m={miss:()=>Promise.resolve()}){return o.get(t,i,m).catch(()=>T({caches:e}).get(t,i,m))},set(t,i){return o.set(t,i).catch(()=>T({caches:e}).set(t,i))},delete(t){return o.delete(t).catch(()=>T({caches:e}).delete(t))},clear(){return o.clear().catch(()=>T({caches:e}).clear())}}}function v(r={serializable:!0}){let e={};return {get(o,t,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let p=t();return p.then(a=>i.miss(a)).then(()=>p)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var F=1e3,$=2e3,j=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function J(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function M({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(i=>t.add(i)),t}function z(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var W=2*60*1e3;function Q(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>W}function i(){return e==="timed out"&&Date.now()-o<=W}return {...r,status:e,lastUpdate:o,isUp:t,isTimedOut:i}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e;}},te=class extends X{constructor(r){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.",r,"RetryError");}},b=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e;}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},se=class extends b{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o;}};function ne(r,e,o){let t=ae(o),i=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(i+=`?${t}`),i}function ae(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ue(r,e,o){let t={Accept:"application/json",...r,...e,...o},i={};return Object.keys(t).forEach(m=>{let p=t[m];i[m.toLowerCase()]=p;}),i}function ce(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return "error"in t?new se(t.message,e,t.error,o):new b(t.message,e,o)}catch{}return new b(r,e,o)}function me({isTimedOut:r,status:e}){return !r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ge({status:r}){return ~~(r/100)===2}function pe(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:s,responsesCache:n}){async function c(u){let l=await Promise.all(u.map(g=>e.get(g,()=>Promise.resolve(Q(g))))),P=l.filter(g=>g.isUp()),y=l.filter(g=>g.isTimedOut()),w=[...P,...y];return {hosts:w.length>0?w:u,getTimeout(g,E){return (y.length===0&&g===0?1:y.length+3+g)*E}}}async function d(u,l,P=!0){let y=[],w=ie(u,l),q=ue(o,u.headers,l.headers),g=u.method==="GET"?{...u.data,...l.data}:{},E={...i,...u.queryParameters,...g};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?E[f]=l.queryParameters[f]:E[f]=l.queryParameters[f].toString();let O=0,I=async(f,x)=>{let C=f.pop();if(C===void 0)throw new te(pe(y));let A={...p,...l.timeouts},U={data:w,headers:q,method:u.method,url:ne(C,u.path,E),connectTimeout:x(O,A.connect),responseTimeout:x(O,P?A.read:A.write)},L=N=>{let H={request:U,response:N,host:C,triesLeft:f.length};return y.push(H),H},R=await a.send(U);if(de(R)){let N=L(R);return R.isTimedOut&&O++,t.info("Retryable failure",K(N)),await e.set(C,Q(C,R.isTimedOut?"timed out":"down")),I(f,x)}if(ge(R))return ce(R);throw L(R),le(R,y)},Z=r.filter(f=>f.accept==="readWrite"||(P?f.accept==="read":f.accept==="write")),D=await c(Z);return I([...D.hosts].reverse(),D.getTimeout)}function h(u,l={}){let P=u.useReadTransporter||u.method==="GET";if(!P)return d(u,l,P);let y=()=>d(u,l);if((l.cacheable||u.cacheable)!==!0)return y();let q={request:u,requestOptions:l,transporter:{queryParameters:i,headers:o}};return n.get(q,()=>s.get(q,()=>s.set(q,y()).then(g=>Promise.all([s.delete(q),g]),g=>Promise.all([s.delete(q),Promise.reject(g)])).then(([g,E])=>E)),{miss:g=>n.set(q,g)})}return {hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:i,hosts:r,request:h,requestsCache:s,responsesCache:n}}var S="5.15.0",_=["eu","us"];function he(r){return [{url:"query-suggestions.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:i,...m}){let p=J(r,e,o),a=V({hosts:he(i),...m,algoliaAgent:M({algoliaAgents:t,client:"QuerySuggestions",version:S}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return {transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,n){a.algoliaAgent.add({segment:s,version:n});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s;},createConfig(s,n){if(!s)throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");let u={method:"POST",path:"/1/configs",queryParameters:{},headers:{},data:s};return a.request(u,n)},customDelete({path:s,parameters:n},c){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return a.request(l,c)},customGet({path:s,parameters:n},c){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return a.request(l,c)},customPost({path:s,parameters:n,body:c},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let P={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:c||{}};return a.request(P,d)},customPut({path:s,parameters:n,body:c},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let P={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:c||{}};return a.request(P,d)},deleteConfig({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");let u={method:"DELETE",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getAllConfigs(s){let h={method:"GET",path:"/1/configs",queryParameters:{},headers:{}};return a.request(h,s)},getConfig({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getConfig`.");let u={method:"GET",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getConfigStatus({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");let u={method:"GET",path:"/1/configs/{indexName}/status".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getLogFile({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getLogFile`.");let u={method:"GET",path:"/1/logs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},updateConfig({indexName:s,configuration:n},c){if(!s)throw new Error("Parameter `indexName` is required when calling `updateConfig`.");if(!n)throw new Error("Parameter `configuration` is required when calling `updateConfig`.");if(!n.sourceIndices)throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");let l={method:"PUT",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{},data:n};return a.request(l,c)}}}function $e(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!_.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${_.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:F,read:$,write:j},logger:z(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:v(),requestsCache:v({serializable:!1}),hostsCache:T({caches:[G({key:`${S}-${r}`}),v()]}),...t})} | ||
function k(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(a=>t.setRequestHeader(a,e.headers[a]));let i=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0});},a),m=i(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(m),p=i(e.responseTimeout,"Socket timeout"));},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(p),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}));},t.onload=()=>{clearTimeout(m),clearTimeout(p),o({content:t.responseText,status:t.status,isTimedOut:!1});},t.send(e.data);})}return {send:r}}function W(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function i(){return JSON.parse(t().getItem(o)||"{}")}function m(a){t().setItem(o,JSON.stringify(a));}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,s=i(),n=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(n),!a)return;let c=Object.fromEntries(Object.entries(n).filter(([,d])=>{let h=new Date().getTime();return !(d.timestamp+a<h)}));m(c);}return {get(a,s,n={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),i()[JSON.stringify(a)])).then(c=>Promise.all([c?c.value:s(),c!==void 0])).then(([c,d])=>Promise.all([c,d||n.miss(c)])).then(([c])=>c)},set(a,s){return Promise.resolve().then(()=>{let n=i();return n[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(n)),s})},delete(a){return Promise.resolve().then(()=>{let s=i();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s));})},clear(){return Promise.resolve().then(()=>{t().removeItem(o);})}}}function V(){return {get(r,e,o={miss:()=>Promise.resolve()}){return e().then(i=>Promise.all([i,o.miss(i)])).then(([i])=>i)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(r){let e=[...r.caches],o=e.shift();return o===void 0?V():{get(t,i,m={miss:()=>Promise.resolve()}){return o.get(t,i,m).catch(()=>R({caches:e}).get(t,i,m))},set(t,i){return o.set(t,i).catch(()=>R({caches:e}).set(t,i))},delete(t){return o.delete(t).catch(()=>R({caches:e}).delete(t))},clear(){return o.clear().catch(()=>R({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return {get(o,t,i={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let p=t();return p.then(a=>i.miss(a)).then(()=>p)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function $(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return {headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function j({algoliaAgents:r,client:e,version:o}){let t=Y(o).add({segment:e,version:o});return r.forEach(i=>t.add(i)),t}function J(){return {debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var Q=2*60*1e3;function G(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>Q}function i(){return e==="timed out"&&Date.now()-o<=Q}return {...r,status:e,lastUpdate:o,isUp:t,isTimedOut:i}}var F=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e);}},z=class extends F{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e;}},Z=class extends z{constructor(r){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.",r,"RetryError");}},b=class extends z{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e;}},ee=class extends F{response;constructor(r,e){super(r,"DeserializationError"),this.response=e;}},re=class extends b{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o;}};function te(r,e,o){let t=oe(o),i=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(i+=`?${t}`),i}function oe(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function se(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ne(r,e,o){let t={Accept:"application/json",...r,...e,...o},i={};return Object.keys(t).forEach(m=>{let p=t[m];i[m.toLowerCase()]=p;}),i}function ae(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},o){try{let t=JSON.parse(r);return "error"in t?new re(t.message,e,t.error,o):new b(t.message,e,o)}catch{}return new b(r,e,o)}function ue({isTimedOut:r,status:e}){return !r&&~~e===0}function ce({isTimedOut:r,status:e}){return r||ue({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return ~~(r/100)===2}function me(r){return r.map(e=>M(e))}function M(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return {...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function B({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:i,algoliaAgent:m,timeouts:p,requester:a,requestsCache:s,responsesCache:n}){async function c(u){let l=await Promise.all(u.map(g=>e.get(g,()=>Promise.resolve(G(g))))),P=l.filter(g=>g.isUp()),y=l.filter(g=>g.isTimedOut()),C=[...P,...y];return {hosts:C.length>0?C:u,getTimeout(g,w){return (y.length===0&&g===0?1:y.length+3+g)*w}}}async function d(u,l,P=!0){let y=[],C=se(u,l),q=ne(o,u.headers,l.headers),g=u.method==="GET"?{...u.data,...l.data}:{},w={...i,...u.queryParameters,...g};if(m.value&&(w["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?w[f]=l.queryParameters[f]:w[f]=l.queryParameters[f].toString();let v=0,D=async(f,S)=>{let T=f.pop();if(T===void 0)throw new Z(me(y));let A={...p,...l.timeouts},U={data:C,headers:q,method:u.method,url:te(T,u.path,w),connectTimeout:S(v,A.connect),responseTimeout:S(v,P?A.read:A.write)},L=N=>{let H={request:U,response:N,host:T,triesLeft:f.length};return y.push(H),H},E=await a.send(U);if(ce(E)){let N=L(E);return E.isTimedOut&&v++,t.info("Retryable failure",M(N)),await e.set(T,G(T,E.isTimedOut?"timed out":"down")),D(f,S)}if(le(E))return ae(E);throw L(E),ie(E,y)},K=r.filter(f=>f.accept==="readWrite"||(P?f.accept==="read":f.accept==="write")),_=await c(K);return D([..._.hosts].reverse(),_.getTimeout)}function h(u,l={}){let P=u.useReadTransporter||u.method==="GET";if(!P)return d(u,l,P);let y=()=>d(u,l);if((l.cacheable||u.cacheable)!==!0)return y();let q={request:u,requestOptions:l,transporter:{queryParameters:i,headers:o}};return n.get(q,()=>s.get(q,()=>s.set(q,y()).then(g=>Promise.all([s.delete(q),g]),g=>Promise.all([s.delete(q),Promise.reject(g)])).then(([g,w])=>w)),{miss:g=>n.set(q,g)})}return {hostsCache:e,requester:a,timeouts:p,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:i,hosts:r,request:h,requestsCache:s,responsesCache:n}}var x="5.16.0",I=["eu","us"];function de(r){return [{url:"query-suggestions.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:i,...m}){let p=$(r,e,o),a=B({hosts:de(i),...m,algoliaAgent:j({algoliaAgents:t,client:"QuerySuggestions",version:x}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return {transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,n){a.algoliaAgent.add({segment:s,version:n});},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s;},createConfig(s,n){if(!s)throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");let u={method:"POST",path:"/1/configs",queryParameters:{},headers:{},data:s};return a.request(u,n)},customDelete({path:s,parameters:n},c){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return a.request(l,c)},customGet({path:s,parameters:n},c){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return a.request(l,c)},customPost({path:s,parameters:n,body:c},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let P={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:c||{}};return a.request(P,d)},customPut({path:s,parameters:n,body:c},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let P={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:c||{}};return a.request(P,d)},deleteConfig({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");let u={method:"DELETE",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getAllConfigs(s){let h={method:"GET",path:"/1/configs",queryParameters:{},headers:{}};return a.request(h,s)},getConfig({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getConfig`.");let u={method:"GET",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getConfigStatus({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");let u={method:"GET",path:"/1/configs/{indexName}/status".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},getLogFile({indexName:s},n){if(!s)throw new Error("Parameter `indexName` is required when calling `getLogFile`.");let u={method:"GET",path:"/1/logs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(u,n)},updateConfig({indexName:s,configuration:n},c){if(!s)throw new Error("Parameter `indexName` is required when calling `updateConfig`.");if(!n)throw new Error("Parameter `configuration` is required when calling `updateConfig`.");if(!n.sourceIndices)throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");let l={method:"PUT",path:"/1/configs/{indexName}".replace("{indexName}",encodeURIComponent(s)),queryParameters:{},headers:{},data:n};return a.request(l,c)}}}function Ge(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!I.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${I.join(", ")}`);return X({appId:r,apiKey:e,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},logger:J(),requester:k(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:R({caches:[W({key:`${x}-${r}`}),O()]}),...t})} | ||
exports.apiClientVersion = S; | ||
exports.querySuggestionsClient = $e; | ||
exports.apiClientVersion = x; | ||
exports.querySuggestionsClient = Ge; | ||
})); |
// builds/fetch.ts | ||
import { | ||
createMemoryCache, | ||
createNullCache, | ||
createNullLogger, | ||
DEFAULT_CONNECT_TIMEOUT_NODE, | ||
DEFAULT_READ_TIMEOUT_NODE, | ||
DEFAULT_WRITE_TIMEOUT_NODE | ||
} from "@algolia/client-common"; | ||
import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common"; | ||
import { createFetchRequester } from "@algolia/requester-fetch"; | ||
@@ -14,3 +7,3 @@ | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.15.0"; | ||
var apiClientVersion = "5.16.0"; | ||
var REGIONS = ["eu", "us"]; | ||
@@ -371,5 +364,5 @@ function getDefaultHosts(region) { | ||
timeouts: { | ||
connect: DEFAULT_CONNECT_TIMEOUT_NODE, | ||
read: DEFAULT_READ_TIMEOUT_NODE, | ||
write: DEFAULT_WRITE_TIMEOUT_NODE | ||
connect: 2e3, | ||
read: 5e3, | ||
write: 3e4 | ||
}, | ||
@@ -376,0 +369,0 @@ logger: createNullLogger(), |
// builds/node.ts | ||
import { createHttpRequester } from "@algolia/requester-node-http"; | ||
import { | ||
createMemoryCache, | ||
createNullCache, | ||
createNullLogger, | ||
DEFAULT_CONNECT_TIMEOUT_NODE, | ||
DEFAULT_READ_TIMEOUT_NODE, | ||
DEFAULT_WRITE_TIMEOUT_NODE | ||
} from "@algolia/client-common"; | ||
import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common"; | ||
// src/querySuggestionsClient.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.15.0"; | ||
var apiClientVersion = "5.16.0"; | ||
var REGIONS = ["eu", "us"]; | ||
@@ -370,5 +363,5 @@ function getDefaultHosts(region) { | ||
timeouts: { | ||
connect: DEFAULT_CONNECT_TIMEOUT_NODE, | ||
read: DEFAULT_READ_TIMEOUT_NODE, | ||
write: DEFAULT_WRITE_TIMEOUT_NODE | ||
connect: 2e3, | ||
read: 5e3, | ||
write: 3e4 | ||
}, | ||
@@ -375,0 +368,0 @@ logger: createNullLogger(), |
@@ -256,3 +256,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "5.15.0"; | ||
declare const apiClientVersion = "5.16.0"; | ||
declare const REGIONS: readonly ["eu", "us"]; | ||
@@ -259,0 +259,0 @@ type Region = (typeof REGIONS)[number]; |
@@ -256,3 +256,3 @@ import * as _algolia_client_common from '@algolia/client-common'; | ||
declare const apiClientVersion = "5.15.0"; | ||
declare const apiClientVersion = "5.16.0"; | ||
declare const REGIONS: readonly ["eu", "us"]; | ||
@@ -259,0 +259,0 @@ type Region = (typeof REGIONS)[number]; |
// src/querySuggestionsClient.ts | ||
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common"; | ||
var apiClientVersion = "5.15.0"; | ||
var apiClientVersion = "5.16.0"; | ||
var REGIONS = ["eu", "us"]; | ||
@@ -5,0 +5,0 @@ function getDefaultHosts(region) { |
{ | ||
"version": "5.15.0", | ||
"version": "5.16.0", | ||
"repository": { | ||
@@ -7,2 +7,3 @@ "type": "git", | ||
}, | ||
"homepage": "https://github.com/algolia/algoliasearch-client-javascript/packages/client-query-suggestions#readme", | ||
"type": "module", | ||
@@ -52,14 +53,14 @@ "license": "MIT", | ||
"dependencies": { | ||
"@algolia/client-common": "5.15.0", | ||
"@algolia/requester-browser-xhr": "5.15.0", | ||
"@algolia/requester-fetch": "5.15.0", | ||
"@algolia/requester-node-http": "5.15.0" | ||
"@algolia/client-common": "5.16.0", | ||
"@algolia/requester-browser-xhr": "5.16.0", | ||
"@algolia/requester-fetch": "5.16.0", | ||
"@algolia/requester-node-http": "5.16.0" | ||
}, | ||
"devDependencies": { | ||
"@arethetypeswrong/cli": "0.17.0", | ||
"@types/node": "22.9.0", | ||
"@arethetypeswrong/cli": "0.17.1", | ||
"@types/node": "22.10.1", | ||
"publint": "0.2.12", | ||
"rollup": "4.27.2", | ||
"rollup": "4.28.1", | ||
"tsup": "8.3.5", | ||
"typescript": "5.6.3" | ||
"typescript": "5.7.2" | ||
}, | ||
@@ -66,0 +67,0 @@ "engines": { |
@@ -44,7 +44,7 @@ <p align="center"> | ||
```bash | ||
yarn add @algolia/client-query-suggestions@5.15.0 | ||
yarn add @algolia/client-query-suggestions@5.16.0 | ||
# or | ||
npm install @algolia/client-query-suggestions@5.15.0 | ||
npm install @algolia/client-query-suggestions@5.16.0 | ||
# or | ||
pnpm add @algolia/client-query-suggestions@5.15.0 | ||
pnpm add @algolia/client-query-suggestions@5.16.0 | ||
``` | ||
@@ -57,3 +57,3 @@ | ||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-query-suggestions@5.15.0/dist/builds/browser.umd.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-query-suggestions@5.16.0/dist/builds/browser.umd.js"></script> | ||
``` | ||
@@ -60,0 +60,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
384387
3534
+ Added@algolia/client-common@5.16.0(transitive)
+ Added@algolia/requester-browser-xhr@5.16.0(transitive)
+ Added@algolia/requester-fetch@5.16.0(transitive)
+ Added@algolia/requester-node-http@5.16.0(transitive)
- Removed@algolia/client-common@5.15.0(transitive)
- Removed@algolia/requester-browser-xhr@5.15.0(transitive)
- Removed@algolia/requester-fetch@5.15.0(transitive)
- Removed@algolia/requester-node-http@5.15.0(transitive)