meilisearch
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).MeiliSearch=e()}(this,(function(){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(e,n)};function e(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var s=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),o=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),u=function(t,e){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return t.apply(e,n)}},a=Object.prototype.toString;function c(t){return"[object Array]"===a.call(t)}function h(t){return void 0===t}function f(t){return null!==t&&"object"==typeof t}function d(t){return"[object Function]"===a.call(t)}function l(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),c(t))for(var n=0,r=t.length;n<r;n++)e.call(null,t[n],n,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}var p={isArray:c,isArrayBuffer:function(t){return"[object ArrayBuffer]"===a.call(t)},isBuffer:function(t){return null!==t&&!h(t)&&null!==t.constructor&&!h(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:f,isUndefined:h,isDate:function(t){return"[object Date]"===a.call(t)},isFile:function(t){return"[object File]"===a.call(t)},isBlob:function(t){return"[object Blob]"===a.call(t)},isFunction:d,isStream:function(t){return f(t)&&d(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:l,merge:function t(){var e={};function n(n,r){"object"==typeof e[r]&&"object"==typeof n?e[r]=t(e[r],n):e[r]=n}for(var r=0,i=arguments.length;r<i;r++)l(arguments[r],n);return e},deepMerge:function t(){var e={};function n(n,r){"object"==typeof e[r]&&"object"==typeof n?e[r]=t(e[r],n):e[r]="object"==typeof n?t({},n):n}for(var r=0,i=arguments.length;r<i;r++)l(arguments[r],n);return e},extend:function(t,e,n){return l(e,(function(e,r){t[r]=n&&"function"==typeof e?u(e,n):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}};function v(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var y=function(t,e,n){if(!e)return t;var r;if(n)r=n(e);else if(p.isURLSearchParams(e))r=e.toString();else{var i=[];p.forEach(e,(function(t,e){null!=t&&(p.isArray(t)?e+="[]":t=[t],p.forEach(t,(function(t){p.isDate(t)?t=t.toISOString():p.isObject(t)&&(t=JSON.stringify(t)),i.push(v(e)+"="+v(t))})))})),r=i.join("&")}if(r){var s=t.indexOf("#");-1!==s&&(t=t.slice(0,s)),t+=(-1===t.indexOf("?")?"?":"&")+r}return t};function g(){this.handlers=[]}g.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},g.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},g.prototype.forEach=function(t){p.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var b=g,m=function(t,e,n){return p.forEach(n,(function(n){t=n(t,e)})),t},w=function(t){return!(!t||!t.__CANCEL__)},x=function(t,e){p.forEach(t,(function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])}))},S=function(t,e,n,r,i){return function(t,e,n,r,i){return t.config=e,n&&(t.code=n),t.request=r,t.response=i,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}(new Error(t),e,n,r,i)},T=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],E=p.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=r(window.location.href),function(e){var n=p.isString(e)?r(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0},A=p.isStandardBrowserEnv()?{write:function(t,e,n,r,i,s){var o=[];o.push(t+"="+encodeURIComponent(e)),p.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),p.isString(r)&&o.push("path="+r),p.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},R=function(t){return new Promise((function(e,n){var r=t.data,i=t.headers;p.isFormData(r)&&delete i["Content-Type"];var s=new XMLHttpRequest;if(t.auth){var o=t.auth.username||"",u=t.auth.password||"";i.Authorization="Basic "+btoa(o+":"+u)}var a,c,h=(a=t.baseURL,c=t.url,a&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(c)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(a,c):c);if(s.open(t.method.toUpperCase(),y(h,t.params,t.paramsSerializer),!0),s.timeout=t.timeout,s.onreadystatechange=function(){if(s&&4===s.readyState&&(0!==s.status||s.responseURL&&0===s.responseURL.indexOf("file:"))){var r,i,o,u,a,c="getAllResponseHeaders"in s?(r=s.getAllResponseHeaders(),a={},r?(p.forEach(r.split("\n"),(function(t){if(u=t.indexOf(":"),i=p.trim(t.substr(0,u)).toLowerCase(),o=p.trim(t.substr(u+1)),i){if(a[i]&&T.indexOf(i)>=0)return;a[i]="set-cookie"===i?(a[i]?a[i]:[]).concat([o]):a[i]?a[i]+", "+o:o}})),a):a):null,h={data:t.responseType&&"text"!==t.responseType?s.response:s.responseText,status:s.status,statusText:s.statusText,headers:c,config:t,request:s};!function(t,e,n){var r=n.config.validateStatus;!r||r(n.status)?t(n):e(S("Request failed with status code "+n.status,n.config,null,n.request,n))}(e,n,h),s=null}},s.onabort=function(){s&&(n(S("Request aborted",t,"ECONNABORTED",s)),s=null)},s.onerror=function(){n(S("Network Error",t,null,s)),s=null},s.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(S(e,t,"ECONNABORTED",s)),s=null},p.isStandardBrowserEnv()){var f=A,d=(t.withCredentials||E(h))&&t.xsrfCookieName?f.read(t.xsrfCookieName):void 0;d&&(i[t.xsrfHeaderName]=d)}if("setRequestHeader"in s&&p.forEach(i,(function(t,e){void 0===r&&"content-type"===e.toLowerCase()?delete i[e]:s.setRequestHeader(e,t)})),p.isUndefined(t.withCredentials)||(s.withCredentials=!!t.withCredentials),t.responseType)try{s.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&s.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&s.upload&&s.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){s&&(s.abort(),n(t),s=null)})),void 0===r&&(r=null),s.send(r)}))},k={"Content-Type":"application/x-www-form-urlencoded"};function C(t,e){!p.isUndefined(t)&&p.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var j,O={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(j=R),j),transformRequest:[function(t,e){return x(e,"Accept"),x(e,"Content-Type"),p.isFormData(t)||p.isArrayBuffer(t)||p.isBuffer(t)||p.isStream(t)||p.isFile(t)||p.isBlob(t)?t:p.isArrayBufferView(t)?t.buffer:p.isURLSearchParams(t)?(C(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):p.isObject(t)?(C(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(t){return t>=200&&t<300}};O.headers={common:{Accept:"application/json, text/plain, */*"}},p.forEach(["delete","get","head"],(function(t){O.headers[t]={}})),p.forEach(["post","put","patch"],(function(t){O.headers[t]=p.merge(k)}));var D=O;function N(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var U=function(t){return N(t),t.headers=t.headers||{},t.data=m(t.data,t.headers,t.transformRequest),t.headers=p.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),p.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||D.adapter)(t).then((function(e){return N(t),e.data=m(e.data,e.headers,t.transformResponse),e}),(function(e){return w(e)||(N(t),e&&e.response&&(e.response.data=m(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},P=function(t,e){e=e||{};var n={},r=["url","method","params","data"],i=["headers","auth","proxy"],s=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];p.forEach(r,(function(t){void 0!==e[t]&&(n[t]=e[t])})),p.forEach(i,(function(r){p.isObject(e[r])?n[r]=p.deepMerge(t[r],e[r]):void 0!==e[r]?n[r]=e[r]:p.isObject(t[r])?n[r]=p.deepMerge(t[r]):void 0!==t[r]&&(n[r]=t[r])})),p.forEach(s,(function(r){void 0!==e[r]?n[r]=e[r]:void 0!==t[r]&&(n[r]=t[r])}));var o=r.concat(i).concat(s),u=Object.keys(e).filter((function(t){return-1===o.indexOf(t)}));return p.forEach(u,(function(r){void 0!==e[r]?n[r]=e[r]:void 0!==t[r]&&(n[r]=t[r])})),n};function L(t){this.defaults=t,this.interceptors={request:new b,response:new b}}L.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=P(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[U,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)n=n.then(e.shift(),e.shift());return n},L.prototype.getUri=function(t){return t=P(this.defaults,t),y(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},p.forEach(["delete","get","head","options"],(function(t){L.prototype[t]=function(e,n){return this.request(p.merge(n||{},{method:t,url:e}))}})),p.forEach(["post","put","patch"],(function(t){L.prototype[t]=function(e,n,r){return this.request(p.merge(r||{},{method:t,url:e,data:n}))}}));var F=L;function B(t){this.message=t}B.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},B.prototype.__CANCEL__=!0;var q=B;function M(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var n=this;t((function(t){n.reason||(n.reason=new q(t),e(n.reason))}))}M.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},M.source=function(){var t;return{token:new M((function(e){t=e})),cancel:t}};var _=M;function H(t){var e=new F(t),n=u(F.prototype.request,e);return p.extend(n,F.prototype,e),p.extend(n,e),n}var I=H(D);I.Axios=F,I.create=function(t){return H(P(I.defaults,t))},I.Cancel=q,I.CancelToken=_,I.isCancel=w,I.all=function(t){return Promise.all(t)},I.spread=function(t){return function(e){return t.apply(null,e)}};var z=I,J=I;z.default=J;var K=z,X=function(t){function n(e,n){var r,i=t.call(this,e.message)||this;return i.type="MeiliSearchApiError",i.name="MeiliSearchApiError",void 0!==e.response&&(i.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(r=e.response.data)||void 0===r?void 0:r.message)&&(i.errorCode=e.response.data.errorCode,i.errorType=e.response.data.errorType,i.errorLink=e.response.data.errorLink,i.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(i.stack=i.name+": "+i.message+"\n"+n.split("\n").slice(1).join("\n")),i}return e(n,t),n}(Error),G=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchCommunicationError",r.type="MeiliSearchCommunicationError",Error.captureStackTrace(r,n),r}return e(n,t),n}(Error);function V(t,e){throw void 0!==t.response?new X(t,e):!0===t.isAxiosError?new G(t.message):t}var $=function(){function t(t){void 0!==t.apiKey?this.instance=K.create({baseURL:t.host,headers:{"X-Meili-API-Key":t.apiKey}}):this.instance=K.create({baseURL:t.host}),this.cancelTokenSource=K.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?n(n({},t),{data:JSON.stringify(t.data)}):t}))}return t.prototype.get=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,r.sent()];case 3:throw V(r.sent(),n);case 4:return[2]}}))}))},t.prototype.post=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,i.sent()];case 3:throw V(i.sent(),r);case 4:return[2]}}))}))},t.prototype.put=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,i.sent()];case 3:throw V(i.sent(),r);case 4:return[2]}}))}))},t.prototype.patch=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,i.sent()];case 3:throw V(i.sent(),r);case 4:return[2]}}))}))},t.prototype.delete=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,r.sent()];case 3:throw V(r.sent(),n);case 4:return[2]}}))}))},t}();function W(t){var e=Object.entries(t).filter((function(t){return void 0!==t[1]}));return Object.fromEntries(e)}function Q(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var Y=function(t){function u(e,n){var r=t.call(this,e)||this;return r.uid=n,r}return e(u,t),u.prototype.getUpdateStatus=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,s=n.timeOutMs,u=void 0===s?5e3:s,a=n.intervalMs,c=void 0===a?50:a;return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,Q(c)];case 3:return r.sent(),[3,1];case 4:throw new o("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},u.prototype.getAllUpdateStatus=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.search=function(t,e,o){return void 0===o&&(o="POST"),r(this,void 0,void 0,(function(){var r,u,a;return i(this,(function(i){switch(i.label){case 0:return r="/indexes/"+this.uid+"/search",u={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==o.toUpperCase()?[3,2]:[4,this.post(r,W(u),{cancelToken:this.cancelTokenSource.token})];case 1:return[2,i.sent()];case 2:return"GET"!==o.toUpperCase()?[3,4]:(a=n(n({},u),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.get(r,{params:W(a),cancelToken:this.cancelTokenSource.token})]);case 3:return[2,i.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},u.prototype.show=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateIndex=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.deleteIndex=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getDocuments=function(t){return r(this,void 0,void 0,(function(){var e,r;return i(this,(function(i){switch(i.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(r=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:n(n({},t),void 0!==r?{attributesToRetrieve:r}:{})})];case 1:return[2,i.sent()]}}))}))},u.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.addDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},u.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},u.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.deleteDocuments=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.deleteAllDocuments=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getSettings=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateSettings=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateSynonyms=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateStopWords=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateRankingRules=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateDistinctAttribute=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateAttributesForFaceting=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateSearchableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u}($);return function(t){function s(e){var n=t.call(this,e)||this;return n.config=e,n}return e(s,t),s.prototype.getIndex=function(t){return new Y(this.config,t)},s.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},s.prototype.listIndexes=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},s.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return"/indexes",[4,this.post("/indexes",n(n({},e),{uid:t}))];case 1:return r=i.sent(),[2,new Y(this.config,r.uid)]}}))}))},s.prototype.getKeys=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},s.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},s.prototype.setHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},s.prototype.setUnhealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},s.prototype.changeHealthTo=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},s.prototype.stats=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},s.prototype.version=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},s}($)})); | ||
***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};function e(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{a(r.next(t))}catch(t){s(t)}}function u(t){try{a(r.throw(t))}catch(t){s(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}a((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var s=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),o=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),u=function(t,e){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return t.apply(e,n)}},a=Object.prototype.toString;function c(t){return"[object Array]"===a.call(t)}function h(t){return void 0===t}function f(t){return null!==t&&"object"==typeof t}function d(t){return"[object Function]"===a.call(t)}function l(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),c(t))for(var n=0,r=t.length;n<r;n++)e.call(null,t[n],n,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}var p={isArray:c,isArrayBuffer:function(t){return"[object ArrayBuffer]"===a.call(t)},isBuffer:function(t){return null!==t&&!h(t)&&null!==t.constructor&&!h(t.constructor)&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)},isFormData:function(t){return"undefined"!=typeof FormData&&t instanceof FormData},isArrayBufferView:function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):t&&t.buffer&&t.buffer instanceof ArrayBuffer},isString:function(t){return"string"==typeof t},isNumber:function(t){return"number"==typeof t},isObject:f,isUndefined:h,isDate:function(t){return"[object Date]"===a.call(t)},isFile:function(t){return"[object File]"===a.call(t)},isBlob:function(t){return"[object Blob]"===a.call(t)},isFunction:d,isStream:function(t){return f(t)&&d(t.pipe)},isURLSearchParams:function(t){return"undefined"!=typeof URLSearchParams&&t instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:l,merge:function t(){var e={};function n(n,r){"object"==typeof e[r]&&"object"==typeof n?e[r]=t(e[r],n):e[r]=n}for(var r=0,i=arguments.length;r<i;r++)l(arguments[r],n);return e},deepMerge:function t(){var e={};function n(n,r){"object"==typeof e[r]&&"object"==typeof n?e[r]=t(e[r],n):e[r]="object"==typeof n?t({},n):n}for(var r=0,i=arguments.length;r<i;r++)l(arguments[r],n);return e},extend:function(t,e,n){return l(e,(function(e,r){t[r]=n&&"function"==typeof e?u(e,n):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}};function v(t){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var y=function(t,e,n){if(!e)return t;var r;if(n)r=n(e);else if(p.isURLSearchParams(e))r=e.toString();else{var i=[];p.forEach(e,(function(t,e){null!=t&&(p.isArray(t)?e+="[]":t=[t],p.forEach(t,(function(t){p.isDate(t)?t=t.toISOString():p.isObject(t)&&(t=JSON.stringify(t)),i.push(v(e)+"="+v(t))})))})),r=i.join("&")}if(r){var s=t.indexOf("#");-1!==s&&(t=t.slice(0,s)),t+=(-1===t.indexOf("?")?"?":"&")+r}return t};function g(){this.handlers=[]}g.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},g.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},g.prototype.forEach=function(t){p.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var b=g,m=function(t,e,n){return p.forEach(n,(function(n){t=n(t,e)})),t},w=function(t){return!(!t||!t.__CANCEL__)},x=function(t,e){p.forEach(t,(function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])}))},S=function(t,e,n,r,i){return function(t,e,n,r,i){return t.config=e,n&&(t.code=n),t.request=r,t.response=i,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}(new Error(t),e,n,r,i)},T=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],E=p.isStandardBrowserEnv()?function(){var t,e=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(t){var r=t;return e&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return t=r(window.location.href),function(e){var n=p.isString(e)?r(e):e;return n.protocol===t.protocol&&n.host===t.host}}():function(){return!0},A=p.isStandardBrowserEnv()?{write:function(t,e,n,r,i,s){var o=[];o.push(t+"="+encodeURIComponent(e)),p.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),p.isString(r)&&o.push("path="+r),p.isString(i)&&o.push("domain="+i),!0===s&&o.push("secure"),document.cookie=o.join("; ")},read:function(t){var e=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return e?decodeURIComponent(e[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},C=function(t){return new Promise((function(e,n){var r=t.data,i=t.headers;p.isFormData(r)&&delete i["Content-Type"];var s=new XMLHttpRequest;if(t.auth){var o=t.auth.username||"",u=t.auth.password||"";i.Authorization="Basic "+btoa(o+":"+u)}var a,c,h=(a=t.baseURL,c=t.url,a&&!/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(c)?function(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}(a,c):c);if(s.open(t.method.toUpperCase(),y(h,t.params,t.paramsSerializer),!0),s.timeout=t.timeout,s.onreadystatechange=function(){if(s&&4===s.readyState&&(0!==s.status||s.responseURL&&0===s.responseURL.indexOf("file:"))){var r,i,o,u,a,c="getAllResponseHeaders"in s?(r=s.getAllResponseHeaders(),a={},r?(p.forEach(r.split("\n"),(function(t){if(u=t.indexOf(":"),i=p.trim(t.substr(0,u)).toLowerCase(),o=p.trim(t.substr(u+1)),i){if(a[i]&&T.indexOf(i)>=0)return;a[i]="set-cookie"===i?(a[i]?a[i]:[]).concat([o]):a[i]?a[i]+", "+o:o}})),a):a):null,h={data:t.responseType&&"text"!==t.responseType?s.response:s.responseText,status:s.status,statusText:s.statusText,headers:c,config:t,request:s};!function(t,e,n){var r=n.config.validateStatus;!r||r(n.status)?t(n):e(S("Request failed with status code "+n.status,n.config,null,n.request,n))}(e,n,h),s=null}},s.onabort=function(){s&&(n(S("Request aborted",t,"ECONNABORTED",s)),s=null)},s.onerror=function(){n(S("Network Error",t,null,s)),s=null},s.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(S(e,t,"ECONNABORTED",s)),s=null},p.isStandardBrowserEnv()){var f=A,d=(t.withCredentials||E(h))&&t.xsrfCookieName?f.read(t.xsrfCookieName):void 0;d&&(i[t.xsrfHeaderName]=d)}if("setRequestHeader"in s&&p.forEach(i,(function(t,e){void 0===r&&"content-type"===e.toLowerCase()?delete i[e]:s.setRequestHeader(e,t)})),p.isUndefined(t.withCredentials)||(s.withCredentials=!!t.withCredentials),t.responseType)try{s.responseType=t.responseType}catch(e){if("json"!==t.responseType)throw e}"function"==typeof t.onDownloadProgress&&s.addEventListener("progress",t.onDownloadProgress),"function"==typeof t.onUploadProgress&&s.upload&&s.upload.addEventListener("progress",t.onUploadProgress),t.cancelToken&&t.cancelToken.promise.then((function(t){s&&(s.abort(),n(t),s=null)})),void 0===r&&(r=null),s.send(r)}))},k={"Content-Type":"application/x-www-form-urlencoded"};function R(t,e){!p.isUndefined(t)&&p.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var j,O={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(j=C),j),transformRequest:[function(t,e){return x(e,"Accept"),x(e,"Content-Type"),p.isFormData(t)||p.isArrayBuffer(t)||p.isBuffer(t)||p.isStream(t)||p.isFile(t)||p.isBlob(t)?t:p.isArrayBufferView(t)?t.buffer:p.isURLSearchParams(t)?(R(e,"application/x-www-form-urlencoded;charset=utf-8"),t.toString()):p.isObject(t)?(R(e,"application/json;charset=utf-8"),JSON.stringify(t)):t}],transformResponse:[function(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(t){return t>=200&&t<300}};O.headers={common:{Accept:"application/json, text/plain, */*"}},p.forEach(["delete","get","head"],(function(t){O.headers[t]={}})),p.forEach(["post","put","patch"],(function(t){O.headers[t]=p.merge(k)}));var D=O;function N(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var U=function(t){return N(t),t.headers=t.headers||{},t.data=m(t.data,t.headers,t.transformRequest),t.headers=p.merge(t.headers.common||{},t.headers[t.method]||{},t.headers),p.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete t.headers[e]})),(t.adapter||D.adapter)(t).then((function(e){return N(t),e.data=m(e.data,e.headers,t.transformResponse),e}),(function(e){return w(e)||(N(t),e&&e.response&&(e.response.data=m(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},P=function(t,e){e=e||{};var n={},r=["url","method","params","data"],i=["headers","auth","proxy"],s=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];p.forEach(r,(function(t){void 0!==e[t]&&(n[t]=e[t])})),p.forEach(i,(function(r){p.isObject(e[r])?n[r]=p.deepMerge(t[r],e[r]):void 0!==e[r]?n[r]=e[r]:p.isObject(t[r])?n[r]=p.deepMerge(t[r]):void 0!==t[r]&&(n[r]=t[r])})),p.forEach(s,(function(r){void 0!==e[r]?n[r]=e[r]:void 0!==t[r]&&(n[r]=t[r])}));var o=r.concat(i).concat(s),u=Object.keys(e).filter((function(t){return-1===o.indexOf(t)}));return p.forEach(u,(function(r){void 0!==e[r]?n[r]=e[r]:void 0!==t[r]&&(n[r]=t[r])})),n};function L(t){this.defaults=t,this.interceptors={request:new b,response:new b}}L.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=P(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[U,void 0],n=Promise.resolve(t);for(this.interceptors.request.forEach((function(t){e.unshift(t.fulfilled,t.rejected)})),this.interceptors.response.forEach((function(t){e.push(t.fulfilled,t.rejected)}));e.length;)n=n.then(e.shift(),e.shift());return n},L.prototype.getUri=function(t){return t=P(this.defaults,t),y(t.url,t.params,t.paramsSerializer).replace(/^\?/,"")},p.forEach(["delete","get","head","options"],(function(t){L.prototype[t]=function(e,n){return this.request(p.merge(n||{},{method:t,url:e}))}})),p.forEach(["post","put","patch"],(function(t){L.prototype[t]=function(e,n,r){return this.request(p.merge(r||{},{method:t,url:e,data:n}))}}));var F=L;function B(t){this.message=t}B.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},B.prototype.__CANCEL__=!0;var q=B;function M(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var e;this.promise=new Promise((function(t){e=t}));var n=this;t((function(t){n.reason||(n.reason=new q(t),e(n.reason))}))}M.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},M.source=function(){var t;return{token:new M((function(e){t=e})),cancel:t}};var _=M;function H(t){var e=new F(t),n=u(F.prototype.request,e);return p.extend(n,F.prototype,e),p.extend(n,e),n}var I=H(D);I.Axios=F,I.create=function(t){return H(P(I.defaults,t))},I.Cancel=q,I.CancelToken=_,I.isCancel=w,I.all=function(t){return Promise.all(t)},I.spread=function(t){return function(e){return t.apply(null,e)}};var z=I,J=I;z.default=J;var K=z,X=function(t){function n(e,n){var r,i=t.call(this,e.message)||this;return i.type="MeiliSearchApiError",i.name="MeiliSearchApiError",void 0!==e.response&&(i.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(r=e.response.data)||void 0===r?void 0:r.message)&&(i.errorCode=e.response.data.errorCode,i.errorType=e.response.data.errorType,i.errorLink=e.response.data.errorLink,i.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(i.stack=i.name+": "+i.message+"\n"+n.split("\n").slice(1).join("\n")),i}return e(n,t),n}(Error),G=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchCommunicationError",r.type="MeiliSearchCommunicationError",Error.captureStackTrace(r,n),r}return e(n,t),n}(Error);function V(t,e){throw void 0!==t.response?new X(t,e):!0===t.isAxiosError?new G(t.message):t}var $=function(){function t(t){var e=n(n({},t.headers||{}),{"Content-Type":"application/json"});void 0!==t.apiKey&&(e["X-Meili-API-Key"]=t.apiKey),this.instance=K.create({baseURL:t.host,headers:e}),this.cancelTokenSource=K.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?n(n({},t),{data:JSON.stringify(t.data)}):t}))}return t.prototype.get=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,r.sent()];case 3:throw V(r.sent(),n);case 4:return[2]}}))}))},t.prototype.post=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,i.sent()];case 3:throw V(i.sent(),r);case 4:return[2]}}))}))},t.prototype.put=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,i.sent()];case 3:throw V(i.sent(),r);case 4:return[2]}}))}))},t.prototype.patch=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,i.sent()];case 3:throw V(i.sent(),r);case 4:return[2]}}))}))},t.prototype.delete=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,r.sent()];case 3:throw V(r.sent(),n);case 4:return[2]}}))}))},t}();function W(t){var e=Object.entries(t).filter((function(t){return void 0!==t[1]}));return Object.fromEntries(e)}function Q(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var Y=function(t){function u(e,n){var r=t.call(this,e)||this;return r.uid=n,r}return e(u,t),u.prototype.getUpdateStatus=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,s=n.timeOutMs,u=void 0===s?5e3:s,a=n.intervalMs,c=void 0===a?50:a;return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,Q(c)];case 3:return r.sent(),[3,1];case 4:throw new o("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},u.prototype.getAllUpdateStatus=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.search=function(t,e,o){return void 0===o&&(o="POST"),r(this,void 0,void 0,(function(){var r,u,a;return i(this,(function(i){switch(i.label){case 0:return r="/indexes/"+this.uid+"/search",u={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==o.toUpperCase()?[3,2]:[4,this.post(r,W(u),{cancelToken:this.cancelTokenSource.token})];case 1:return[2,i.sent()];case 2:return"GET"!==o.toUpperCase()?[3,4]:(a=n(n({},u),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.get(r,{params:W(a),cancelToken:this.cancelTokenSource.token})]);case 3:return[2,i.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},u.prototype.show=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateIndex=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.deleteIndex=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getDocuments=function(t){return r(this,void 0,void 0,(function(){var e,r;return i(this,(function(i){switch(i.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(r=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:n(n({},t),void 0!==r?{attributesToRetrieve:r}:{})})];case 1:return[2,i.sent()]}}))}))},u.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.addDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},u.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},u.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},u.prototype.deleteDocuments=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.deleteAllDocuments=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getSettings=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateSettings=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateSynonyms=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateStopWords=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateRankingRules=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateDistinctAttribute=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateAttributesForFaceting=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateSearchableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},u.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},u.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},u}($);return function(t){function s(e){var n=t.call(this,e)||this;return n.config=e,n}return e(s,t),s.prototype.getIndex=function(t){return new Y(this.config,t)},s.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},s.prototype.listIndexes=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},s.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return"/indexes",[4,this.post("/indexes",n(n({},e),{uid:t}))];case 1:return r=i.sent(),[2,new Y(this.config,r.uid)]}}))}))},s.prototype.getKeys=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},s.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},s.prototype.setHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},s.prototype.setUnhealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},s.prototype.changeHealthTo=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},s.prototype.stats=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},s.prototype.version=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},s}($)})); | ||
//# sourceMappingURL=meilisearch.browser.min.js.map |
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var instance = require('axios'); | ||
var instance = _interopDefault(require('axios')); | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var instance__default = /*#__PURE__*/_interopDefaultLegacy(instance); | ||
/*! ***************************************************************************** | ||
@@ -26,3 +28,3 @@ Copyright (c) Microsoft Corporation. | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -179,16 +181,11 @@ }; | ||
function MeiliAxiosWrapper(config) { | ||
var headers = __assign(__assign({}, (config.headers || {})), { 'Content-Type': 'application/json' }); | ||
if (config.apiKey !== undefined) { | ||
this.instance = instance.create({ | ||
baseURL: config.host, | ||
headers: { | ||
'X-Meili-API-Key': config.apiKey, | ||
}, | ||
}); | ||
headers['X-Meili-API-Key'] = config.apiKey; | ||
} | ||
else { | ||
this.instance = instance.create({ | ||
baseURL: config.host, | ||
}); | ||
} | ||
this.cancelTokenSource = instance.CancelToken.source(); | ||
this.instance = instance__default['default'].create({ | ||
baseURL: config.host, | ||
headers: headers, | ||
}); | ||
this.cancelTokenSource = instance__default['default'].CancelToken.source(); | ||
this.instance.interceptors.response.use(function (response) { return response.data; }); | ||
@@ -195,0 +192,0 @@ this.instance.interceptors.request.use(function (request) { |
@@ -1,2 +0,2 @@ | ||
"use strict";var t,e=(t=require("axios"))&&"object"==typeof t&&"default"in t?t.default:t,n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)}; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=t(require("axios")),n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)}; | ||
/*! ***************************************************************************** | ||
@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function r(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function s(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function u(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var u=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace(r,e),r}return r(e,t),e}(Error),c=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace(r,e),r}return r(e,t),e}(Error),a=function(t){function e(e,n){var r,i=t.call(this,e.message)||this;return i.type="MeiliSearchApiError",i.name="MeiliSearchApiError",void 0!==e.response&&(i.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(r=e.response.data)||void 0===r?void 0:r.message)&&(i.errorCode=e.response.data.errorCode,i.errorType=e.response.data.errorType,i.errorLink=e.response.data.errorLink,i.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(i.stack=i.name+": "+i.message+"\n"+n.split("\n").slice(1).join("\n")),i}return r(e,t),e}(Error),h=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchCommunicationError",r.type="MeiliSearchCommunicationError",Error.captureStackTrace(r,e),r}return r(e,t),e}(Error);function d(t,e){throw void 0!==t.response?new a(t,e):!0===t.isAxiosError?new h(t.message):t}var l=function(){function t(t){void 0!==t.apiKey?this.instance=e.create({baseURL:t.host,headers:{"X-Meili-API-Key":t.apiKey}}):this.instance=e.create({baseURL:t.host}),this.cancelTokenSource=e.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?i(i({},t),{data:JSON.stringify(t.data)}):t}))}return t.prototype.get=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,r.sent()];case 3:throw d(r.sent(),n);case 4:return[2]}}))}))},t.prototype.post=function(t,e,n){return s(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,i.sent()];case 3:throw d(i.sent(),r);case 4:return[2]}}))}))},t.prototype.put=function(t,e,n){return s(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,i.sent()];case 3:throw d(i.sent(),r);case 4:return[2]}}))}))},t.prototype.patch=function(t,e,n){return s(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,i.sent()];case 3:throw d(i.sent(),r);case 4:return[2]}}))}))},t.prototype.delete=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,r.sent()];case 3:throw d(r.sent(),n);case 4:return[2]}}))}))},t}();function f(t){var e=Object.entries(t).filter((function(t){return void 0!==t[1]}));return Object.fromEntries(e)}function p(t){return s(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var v=function(t){function e(e,n){var r=t.call(this,e)||this;return r.uid=n,r}return r(e,t),e.prototype.getUpdateStatus=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return s(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<i?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,p(a)];case 3:return r.sent(),[3,1];case 4:throw new c("timeout of "+i+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.search=function(t,e,n){return void 0===n&&(n="POST"),s(this,void 0,void 0,(function(){var r,s,c;return o(this,(function(o){switch(o.label){case 0:return r="/indexes/"+this.uid+"/search",s={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==n.toUpperCase()?[3,2]:[4,this.post(r,f(s),{cancelToken:this.cancelTokenSource.token})];case 1:return[2,o.sent()];case 2:return"GET"!==n.toUpperCase()?[3,4]:(c=i(i({},s),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.get(r,{params:f(c),cancelToken:this.cancelTokenSource.token})]);case 3:return[2,o.sent()];case 4:throw new u("method parameter should be either POST or GET")}}))}))},e.prototype.show=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateIndex=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteIndex=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStats=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDocuments=function(t){return s(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:i(i({},t),void 0!==n?{attributesToRetrieve:n}:{})})];case 1:return[2,r.sent()]}}))}))},e.prototype.getDocument=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.addDocuments=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},e.prototype.deleteDocument=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteDocuments=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteAllDocuments=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSettings=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSettings=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSettings=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSynonyms=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSynonyms=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSynonyms=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStopWords=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateStopWords=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetStopWords=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getRankingRules=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateRankingRules=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetRankingRules=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDistinctAttribute=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDistinctAttribute=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDistinctAttribute=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAttributesForFaceting=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAttributesForFaceting=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetAttributesForFaceting=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSearchableAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSearchableAttributes=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSearchableAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDisplayedAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDisplayedAttributes=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDisplayedAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e}(l),b=function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return r(e,t),e.prototype.getIndex=function(t){return new v(this.config,t)},e.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},e.prototype.listIndexes=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},e.prototype.createIndex=function(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return"/indexes",[4,this.post("/indexes",i(i({},e),{uid:t}))];case 1:return n=r.sent(),[2,new v(this.config,n.uid)]}}))}))},e.prototype.getKeys=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},e.prototype.isHealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},e.prototype.setUnhealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},e.prototype.changeHealthTo=function(t){return s(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.stats=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},e.prototype.version=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},e}(l);module.exports=b; | ||
***************************************************************************** */function r(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function s(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function u(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var u=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace(r,e),r}return r(e,t),e}(Error),c=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace(r,e),r}return r(e,t),e}(Error),a=function(t){function e(e,n){var r,i=t.call(this,e.message)||this;return i.type="MeiliSearchApiError",i.name="MeiliSearchApiError",void 0!==e.response&&(i.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(r=e.response.data)||void 0===r?void 0:r.message)&&(i.errorCode=e.response.data.errorCode,i.errorType=e.response.data.errorType,i.errorLink=e.response.data.errorLink,i.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(i.stack=i.name+": "+i.message+"\n"+n.split("\n").slice(1).join("\n")),i}return r(e,t),e}(Error),h=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchCommunicationError",r.type="MeiliSearchCommunicationError",Error.captureStackTrace(r,e),r}return r(e,t),e}(Error);function d(t,e){throw void 0!==t.response?new a(t,e):!0===t.isAxiosError?new h(t.message):t}var l=function(){function t(t){var n=i(i({},t.headers||{}),{"Content-Type":"application/json"});void 0!==t.apiKey&&(n["X-Meili-API-Key"]=t.apiKey),this.instance=e.default.create({baseURL:t.host,headers:n}),this.cancelTokenSource=e.default.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?i(i({},t),{data:JSON.stringify(t.data)}):t}))}return t.prototype.get=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,r.sent()];case 3:throw d(r.sent(),n);case 4:return[2]}}))}))},t.prototype.post=function(t,e,n){return s(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,i.sent()];case 3:throw d(i.sent(),r);case 4:return[2]}}))}))},t.prototype.put=function(t,e,n){return s(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,i.sent()];case 3:throw d(i.sent(),r);case 4:return[2]}}))}))},t.prototype.patch=function(t,e,n){return s(this,void 0,void 0,(function(){var r;return o(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,i.sent()];case 3:throw d(i.sent(),r);case 4:return[2]}}))}))},t.prototype.delete=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,r.sent()];case 3:throw d(r.sent(),n);case 4:return[2]}}))}))},t}();function f(t){var e=Object.entries(t).filter((function(t){return void 0!==t[1]}));return Object.fromEntries(e)}function p(t){return s(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var v=function(t){function e(e,n){var r=t.call(this,e)||this;return r.uid=n,r}return r(e,t),e.prototype.getUpdateStatus=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,i=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return s(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<i?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,p(a)];case 3:return r.sent(),[3,1];case 4:throw new c("timeout of "+i+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.search=function(t,e,n){return void 0===n&&(n="POST"),s(this,void 0,void 0,(function(){var r,s,c;return o(this,(function(o){switch(o.label){case 0:return r="/indexes/"+this.uid+"/search",s={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==n.toUpperCase()?[3,2]:[4,this.post(r,f(s),{cancelToken:this.cancelTokenSource.token})];case 1:return[2,o.sent()];case 2:return"GET"!==n.toUpperCase()?[3,4]:(c=i(i({},s),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.get(r,{params:f(c),cancelToken:this.cancelTokenSource.token})]);case 3:return[2,o.sent()];case 4:throw new u("method parameter should be either POST or GET")}}))}))},e.prototype.show=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateIndex=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteIndex=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStats=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDocuments=function(t){return s(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:i(i({},t),void 0!==n?{attributesToRetrieve:n}:{})})];case 1:return[2,r.sent()]}}))}))},e.prototype.getDocument=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.addDocuments=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},e.prototype.deleteDocument=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteDocuments=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteAllDocuments=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSettings=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSettings=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSettings=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSynonyms=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSynonyms=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSynonyms=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStopWords=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateStopWords=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetStopWords=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getRankingRules=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateRankingRules=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetRankingRules=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDistinctAttribute=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDistinctAttribute=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDistinctAttribute=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAttributesForFaceting=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAttributesForFaceting=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetAttributesForFaceting=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSearchableAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSearchableAttributes=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSearchableAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDisplayedAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDisplayedAttributes=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDisplayedAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e}(l),b=function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return r(e,t),e.prototype.getIndex=function(t){return new v(this.config,t)},e.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},e.prototype.listIndexes=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},e.prototype.createIndex=function(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return"/indexes",[4,this.post("/indexes",i(i({},e),{uid:t}))];case 1:return n=r.sent(),[2,new v(this.config,n.uid)]}}))}))},e.prototype.getKeys=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},e.prototype.isHealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},e.prototype.setUnhealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},e.prototype.changeHealthTo=function(t){return s(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.stats=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},e.prototype.version=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},e}(l);module.exports=b; | ||
//# sourceMappingURL=meilisearch.cjs.min.js.map |
@@ -22,3 +22,3 @@ import instance from 'axios'; | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -175,15 +175,10 @@ }; | ||
function MeiliAxiosWrapper(config) { | ||
var headers = __assign(__assign({}, (config.headers || {})), { 'Content-Type': 'application/json' }); | ||
if (config.apiKey !== undefined) { | ||
this.instance = instance.create({ | ||
baseURL: config.host, | ||
headers: { | ||
'X-Meili-API-Key': config.apiKey, | ||
}, | ||
}); | ||
headers['X-Meili-API-Key'] = config.apiKey; | ||
} | ||
else { | ||
this.instance = instance.create({ | ||
baseURL: config.host, | ||
}); | ||
} | ||
this.instance = instance.create({ | ||
baseURL: config.host, | ||
headers: headers, | ||
}); | ||
this.cancelTokenSource = instance.CancelToken.source(); | ||
@@ -190,0 +185,0 @@ this.instance.interceptors.response.use(function (response) { return response.data; }); |
@@ -15,3 +15,3 @@ import t from"axios"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,n)};function n(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function u(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var o=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),u=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),c=function(t){function e(e,n){var r,i=t.call(this,e.message)||this;return i.type="MeiliSearchApiError",i.name="MeiliSearchApiError",void 0!==e.response&&(i.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(r=e.response.data)||void 0===r?void 0:r.message)&&(i.errorCode=e.response.data.errorCode,i.errorType=e.response.data.errorType,i.errorLink=e.response.data.errorLink,i.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(i.stack=i.name+": "+i.message+"\n"+n.split("\n").slice(1).join("\n")),i}return n(e,t),e}(Error),a=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchCommunicationError",r.type="MeiliSearchCommunicationError",Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function h(t,e){throw void 0!==t.response?new c(t,e):!0===t.isAxiosError?new a(t.message):t}var d=function(){function e(e){void 0!==e.apiKey?this.instance=t.create({baseURL:e.host,headers:{"X-Meili-API-Key":e.apiKey}}):this.instance=t.create({baseURL:e.host}),this.cancelTokenSource=t.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?r(r({},t),{data:JSON.stringify(t.data)}):t}))}return e.prototype.get=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),n);case 4:return[2]}}))}))},e.prototype.post=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),r);case 4:return[2]}}))}))},e.prototype.put=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),r);case 4:return[2]}}))}))},e.prototype.patch=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),r);case 4:return[2]}}))}))},e.prototype.delete=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),n);case 4:return[2]}}))}))},e}();function l(t){var e=Object.entries(t).filter((function(t){return void 0!==t[1]}));return Object.fromEntries(e)}function f(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var p=function(t){function e(e,n){var r=t.call(this,e)||this;return r.uid=n,r}return n(e,t),e.prototype.getUpdateStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,c=n.intervalMs,a=void 0===c?50:c;return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<o?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,f(a)];case 3:return r.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.search=function(t,e,n){return void 0===n&&(n="POST"),i(this,void 0,void 0,(function(){var i,u,c;return s(this,(function(s){switch(s.label){case 0:return i="/indexes/"+this.uid+"/search",u={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==n.toUpperCase()?[3,2]:[4,this.post(i,l(u),{cancelToken:this.cancelTokenSource.token})];case 1:return[2,s.sent()];case 2:return"GET"!==n.toUpperCase()?[3,4]:(c=r(r({},u),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.get(i,{params:l(c),cancelToken:this.cancelTokenSource.token})]);case 3:return[2,s.sent()];case 4:throw new o("method parameter should be either POST or GET")}}))}))},e.prototype.show=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateIndex=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteIndex=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDocuments=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:r(r({},t),void 0!==n?{attributesToRetrieve:n}:{})})];case 1:return[2,i.sent()]}}))}))},e.prototype.getDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.addDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},e.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteDocuments=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteAllDocuments=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSettings=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSettings=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSettings=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSynonyms=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStopWords=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateStopWords=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetStopWords=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateRankingRules=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDistinctAttribute=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAttributesForFaceting=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAttributesForFaceting=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetAttributesForFaceting=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSearchableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDisplayedAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e}(d),v=function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return n(e,t),e.prototype.getIndex=function(t){return new p(this.config,t)},e.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},e.prototype.listIndexes=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},e.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return"/indexes",[4,this.post("/indexes",r(r({},e),{uid:t}))];case 1:return n=i.sent(),[2,new p(this.config,n.uid)]}}))}))},e.prototype.getKeys=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},e.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},e.prototype.setUnhealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},e.prototype.changeHealthTo=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.stats=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},e.prototype.version=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},e}(d);export default v; | ||
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function u(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var o=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),u=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),c=function(t){function e(e,n){var r,i=t.call(this,e.message)||this;return i.type="MeiliSearchApiError",i.name="MeiliSearchApiError",void 0!==e.response&&(i.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(r=e.response.data)||void 0===r?void 0:r.message)&&(i.errorCode=e.response.data.errorCode,i.errorType=e.response.data.errorType,i.errorLink=e.response.data.errorLink,i.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(i.stack=i.name+": "+i.message+"\n"+n.split("\n").slice(1).join("\n")),i}return n(e,t),e}(Error),a=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchCommunicationError",r.type="MeiliSearchCommunicationError",Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function h(t,e){throw void 0!==t.response?new c(t,e):!0===t.isAxiosError?new a(t.message):t}var d=function(){function e(e){var n=r(r({},e.headers||{}),{"Content-Type":"application/json"});void 0!==e.apiKey&&(n["X-Meili-API-Key"]=e.apiKey),this.instance=t.create({baseURL:e.host,headers:n}),this.cancelTokenSource=t.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?r(r({},t),{data:JSON.stringify(t.data)}):t}))}return e.prototype.get=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),n);case 4:return[2]}}))}))},e.prototype.post=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),r);case 4:return[2]}}))}))},e.prototype.put=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),r);case 4:return[2]}}))}))},e.prototype.patch=function(t,e,n){return i(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:r=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),r);case 4:return[2]}}))}))},e.prototype.delete=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),n);case 4:return[2]}}))}))},e}();function l(t){var e=Object.entries(t).filter((function(t){return void 0!==t[1]}));return Object.fromEntries(e)}function f(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var p=function(t){function e(e,n){var r=t.call(this,e)||this;return r.uid=n,r}return n(e,t),e.prototype.getUpdateStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,c=n.intervalMs,a=void 0===c?50:c;return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<o?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,f(a)];case 3:return r.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.search=function(t,e,n){return void 0===n&&(n="POST"),i(this,void 0,void 0,(function(){var i,u,c;return s(this,(function(s){switch(s.label){case 0:return i="/indexes/"+this.uid+"/search",u={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==n.toUpperCase()?[3,2]:[4,this.post(i,l(u),{cancelToken:this.cancelTokenSource.token})];case 1:return[2,s.sent()];case 2:return"GET"!==n.toUpperCase()?[3,4]:(c=r(r({},u),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.get(i,{params:l(c),cancelToken:this.cancelTokenSource.token})]);case 3:return[2,s.sent()];case 4:throw new o("method parameter should be either POST or GET")}}))}))},e.prototype.show=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateIndex=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteIndex=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDocuments=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:r(r({},t),void 0!==n?{attributesToRetrieve:n}:{})})];case 1:return[2,i.sent()]}}))}))},e.prototype.getDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.addDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,r.sent()]}}))}))},e.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteDocuments=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteAllDocuments=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSettings=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSettings=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSettings=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSynonyms=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStopWords=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateStopWords=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetStopWords=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateRankingRules=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDistinctAttribute=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAttributesForFaceting=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAttributesForFaceting=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetAttributesForFaceting=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSearchableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDisplayedAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e}(d),v=function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return n(e,t),e.prototype.getIndex=function(t){return new p(this.config,t)},e.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},e.prototype.listIndexes=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},e.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return"/indexes",[4,this.post("/indexes",r(r({},e),{uid:t}))];case 1:return n=i.sent(),[2,new p(this.config,n.uid)]}}))}))},e.prototype.getKeys=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},e.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},e.prototype.setUnhealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},e.prototype.changeHealthTo=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.stats=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},e.prototype.version=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},e}(d);export default v; | ||
//# sourceMappingURL=meilisearch.esm.min.js.map |
@@ -27,3 +27,3 @@ import MeiliAxiosWrapper from './meili-axios-wrapper'; | ||
*/ | ||
search<P extends Types.SearchParams<T>>(query?: string, options?: P, method?: Types.Methods): Promise<Types.SearchResponse<T, P>>; | ||
search<P extends Types.SearchParams<T>>(query?: string | null, options?: P, method?: Types.Methods): Promise<Types.SearchResponse<T, P>>; | ||
/** | ||
@@ -30,0 +30,0 @@ * Show index information. |
@@ -1,2 +0,2 @@ | ||
// Type definitions for meilisearch 0.12.0 | ||
// Type definitions for meilisearch 0.13.0 | ||
// Project: https://github.com/meilisearch/meilisearch-js | ||
@@ -21,2 +21,3 @@ // Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch> | ||
apiKey?: string; | ||
headers?: object; | ||
} | ||
@@ -54,3 +55,3 @@ export interface IndexRequest { | ||
export interface SearchRequest { | ||
q?: string; | ||
q?: string | null; | ||
offset?: number; | ||
@@ -68,3 +69,3 @@ limit?: number; | ||
export interface GetSearchRequest { | ||
q?: string; | ||
q?: string | null; | ||
offset?: number; | ||
@@ -93,3 +94,3 @@ limit?: number; | ||
} | ||
export interface FieldFrequency { | ||
export interface FieldsDistribution { | ||
[field: string]: number; | ||
@@ -139,3 +140,3 @@ } | ||
isIndexing: boolean; | ||
fieldsFrequency: FieldFrequency; | ||
fieldsDistribution: FieldsDistribution; | ||
} | ||
@@ -177,3 +178,3 @@ export interface Stats { | ||
getAllUpdateStatus: () => Promise<Update[]>; | ||
search: <P extends SearchParams<T>>(query: string, options?: P, method?: Methods) => Promise<SearchResponse<T, P>>; | ||
search: <P extends SearchParams<T>>(query?: string | null, options?: P, method?: Methods) => Promise<SearchResponse<T, P>>; | ||
show: () => Promise<IndexResponse>; | ||
@@ -180,0 +181,0 @@ updateIndex: (indexData: IndexOptions) => Promise<IndexResponse>; |
{ | ||
"name": "meilisearch", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "The MeiliSearch JS client for Node.js and the browser.", | ||
@@ -59,6 +59,6 @@ "keywords": [ | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "14.0.0", | ||
"@rollup/plugin-commonjs": "15.0.0", | ||
"@rollup/plugin-json": "^4.0.2", | ||
"@rollup/plugin-node-resolve": "8.4.0", | ||
"@types/jest": "26.0.8", | ||
"@rollup/plugin-node-resolve": "9.0.0", | ||
"@types/jest": "26.0.10", | ||
"@types/prettier": "^2.0.0", | ||
@@ -86,3 +86,3 @@ "@typescript-eslint/eslint-plugin": "2.34.0", | ||
"rollup": "^2.2.0", | ||
"rollup-plugin-terser": "^6.1.0", | ||
"rollup-plugin-terser": "^7.0.0", | ||
"rollup-plugin-typescript2": "^0.27.0", | ||
@@ -89,0 +89,0 @@ "shx": "^0.3.2", |
@@ -303,2 +303,40 @@ <p align="center"> | ||
#### Placeholder Search | ||
Placeholder search makes it possible to receive hits based on your parameters without having any query (`q`). | ||
To enable this behavior, instead of sending an empty string, the query should be `null` or `undefined`. | ||
```javascript | ||
await index.search(null, { | ||
facetFilters: ['genre:fantasy'], | ||
facetsDistribution: ['genre'] | ||
}) | ||
``` | ||
```json | ||
{ | ||
"hits": [ | ||
{ | ||
"genre": "fantasy", | ||
"id": 4, | ||
"title": "Harry Potter and the Half-Blood Prince", | ||
"comment": "The best book" | ||
}, | ||
{ | ||
"genre": "fantasy", | ||
"id": 42, | ||
"title": "The Hitchhiker's Guide to the Galaxy" | ||
} | ||
], | ||
"offset": 0, | ||
"limit": 20, | ||
"nbHits": 2, | ||
"exhaustiveNbHits": false, | ||
"processingTimeMs": 0, | ||
"query": "", | ||
"facetsDistribution": { "genre": { "fantasy": 2, "romance": 0, "sci fi": 0, "adventure": 0 } }, | ||
"exhaustiveFacetsCount": true | ||
} | ||
``` | ||
## ⚙️ Development Workflow and Contributing | ||
@@ -305,0 +343,0 @@ |
@@ -77,3 +77,3 @@ /* | ||
async search<P extends Types.SearchParams<T>>( | ||
query?: string, | ||
query?: string | null, | ||
options?: P, | ||
@@ -80,0 +80,0 @@ method: Types.Methods = 'POST' |
@@ -24,14 +24,13 @@ /* | ||
constructor(config: Types.Config) { | ||
const headers: { [index: string]: any } = { | ||
...(config.headers || {}), | ||
'Content-Type': 'application/json', | ||
} | ||
if (config.apiKey !== undefined) { | ||
this.instance = instance.create({ | ||
baseURL: config.host, | ||
headers: { | ||
'X-Meili-API-Key': config.apiKey, | ||
}, | ||
}) | ||
} else { | ||
this.instance = instance.create({ | ||
baseURL: config.host, | ||
}) | ||
headers['X-Meili-API-Key'] = config.apiKey | ||
} | ||
this.instance = instance.create({ | ||
baseURL: config.host, | ||
headers: headers, | ||
}) | ||
this.cancelTokenSource = instance.CancelToken.source() | ||
@@ -38,0 +37,0 @@ this.instance.interceptors.response.use((response) => response.data) |
@@ -29,2 +29,3 @@ // Type definitions for meilisearch | ||
apiKey?: string | ||
headers?: object | ||
} | ||
@@ -73,3 +74,3 @@ | ||
export interface SearchRequest { | ||
q?: string | ||
q?: string | null | ||
offset?: number | ||
@@ -88,3 +89,3 @@ limit?: number | ||
export interface GetSearchRequest { | ||
q?: string | ||
q?: string | null | ||
offset?: number | ||
@@ -120,3 +121,3 @@ limit?: number | ||
export interface FieldFrequency { | ||
export interface FieldsDistribution { | ||
[field: string]: number | ||
@@ -207,3 +208,3 @@ } | ||
isIndexing: boolean | ||
fieldsFrequency: FieldFrequency | ||
fieldsDistribution: FieldsDistribution | ||
} | ||
@@ -266,3 +267,3 @@ | ||
search: <P extends SearchParams<T>>( | ||
query: string, | ||
query?: string | null, | ||
options?: P, | ||
@@ -269,0 +270,0 @@ method?: Methods |
Sorry, the diff of this file is too big to display
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
439023
542
7342