meilisearch
Advanced tools
Comparing version 0.11.3 to 0.12.0
@@ -44,2 +44,3 @@ # Contributing | ||
# Tests | ||
$ docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub | ||
$ docker run -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey --no-analytics | ||
@@ -78,3 +79,3 @@ $ yarn test | ||
```javascript | ||
"version": X.X.X | ||
"version": "X.X.X", | ||
``` | ||
@@ -81,0 +82,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).MeiliSearch=e()}(this,(function(){"use strict"; | ||
!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"; | ||
/*! ***************************************************************************** | ||
@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation. | ||
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="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),o=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)}},u=Object.prototype.toString;function a(t){return"[object Array]"===u.call(t)}function c(t){return void 0===t}function h(t){return null!==t&&"object"==typeof t}function f(t){return"[object Function]"===u.call(t)}function d(t,e){if(null!=t)if("object"!=typeof t&&(t=[t]),a(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:a,isArrayBuffer:function(t){return"[object ArrayBuffer]"===u.call(t)},isBuffer:function(t){return null!==t&&!c(t)&&null!==t.constructor&&!c(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:h,isUndefined:c,isDate:function(t){return"[object Date]"===u.call(t)},isFile:function(t){return"[object File]"===u.call(t)},isBlob:function(t){return"[object Blob]"===u.call(t)},isFunction:f,isStream:function(t){return h(t)&&f(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:d,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++)d(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++)d(arguments[r],n);return e},extend:function(t,e,n){return d(e,(function(e,r){t[r]=n&&"function"==typeof e?o(e,n):e})),t},trim:function(t){return t.replace(/^\s*/,"").replace(/\s*$/,"")}};function l(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 v=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(l(e)+"="+l(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 y(){this.handlers=[]}y.prototype.use=function(t,e){return this.handlers.push({fulfilled:t,rejected:e}),this.handlers.length-1},y.prototype.eject=function(t){this.handlers[t]&&(this.handlers[t]=null)},y.prototype.forEach=function(t){p.forEach(this.handlers,(function(e){null!==e&&t(e)}))};var g=y,b=function(t,e,n){return p.forEach(n,(function(n){t=n(t,e)})),t},m=function(t){return!(!t||!t.__CANCEL__)},w=function(t,e){p.forEach(t,(function(n,r){r!==e&&r.toUpperCase()===e.toUpperCase()&&(t[e]=n,delete t[r])}))},x=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)},S=["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"],T=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(){}},E=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(),v(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]&&S.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(x("Request failed with status code "+n.status,n.config,null,n.request,n))}(e,n,h),s=null}},s.onabort=function(){s&&(n(x("Request aborted",t,"ECONNABORTED",s)),s=null)},s.onerror=function(){n(x("Network Error",t,null,s)),s=null},s.ontimeout=function(){var e="timeout of "+t.timeout+"ms exceeded";t.timeoutErrorMessage&&(e=t.timeoutErrorMessage),n(x(e,t,"ECONNABORTED",s)),s=null},p.isStandardBrowserEnv()){var f=A,d=(t.withCredentials||T(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)}))},R={"Content-Type":"application/x-www-form-urlencoded"};function C(t,e){!p.isUndefined(t)&&p.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}var k,j={adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(k=E),k),transformRequest:[function(t,e){return w(e,"Accept"),w(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}};j.headers={common:{Accept:"application/json, text/plain, */*"}},p.forEach(["delete","get","head"],(function(t){j.headers[t]={}})),p.forEach(["post","put","patch"],(function(t){j.headers[t]=p.merge(R)}));var O=j;function N(t){t.cancelToken&&t.cancelToken.throwIfRequested()}var D=function(t){return N(t),t.headers=t.headers||{},t.data=b(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||O.adapter)(t).then((function(e){return N(t),e.data=b(e.data,e.headers,t.transformResponse),e}),(function(e){return m(e)||(N(t),e&&e.response&&(e.response.data=b(e.response.data,e.response.headers,t.transformResponse))),Promise.reject(e)}))},U=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 g,response:new g}}L.prototype.request=function(t){"string"==typeof t?(t=arguments[1]||{}).url=arguments[0]:t=t||{},(t=U(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var e=[D,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=U(this.defaults,t),v(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 P=L;function B(t){this.message=t}B.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},B.prototype.__CANCEL__=!0;var F=B;function q(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 F(t),e(n.reason))}))}q.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},q.source=function(){var t;return{token:new q((function(e){t=e})),cancel:t}};var H=q;function _(t){var e=new P(t),n=o(P.prototype.request,e);return p.extend(n,P.prototype,e),p.extend(n,e),n}var I=_(O);I.Axios=P,I.create=function(t){return _(U(I.defaults,t))},I.Cancel=F,I.CancelToken=H,I.isCancel=m,I.all=function(t){return Promise.all(t)},I.spread=function(t){return function(e){return t.apply(null,e)}};var M=I,z=I;M.default=z;var J=M,K=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),X=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 K(t,e):!0===t.isAxiosError?new X(t.message):t}var $=function(){function t(t){void 0!==t.apiKey?this.instance=J.create({baseURL:t.host,headers:{"X-Meili-API-Key":t.apiKey}}):this.instance=J.create({baseURL:t.host}),this.cancelTokenSource=J.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){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 G=function(t){function o(e,n){var r=t.call(this,e)||this;return r.uid=n,r}return e(o,t),o.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()]}}))}))},o.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,o=n.timeOutMs,u=void 0===o?5e3:o,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,W(c)];case 3:return r.sent(),[3,1];case 4:throw new s("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},o.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()]}}))}))},o.prototype.search=function(t,e){return r(this,void 0,void 0,(function(){var n,r;return i(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/search",r={q:t},void 0!==e&&(void 0!==e.offset&&(r.offset=e.offset),void 0!==e.limit&&(r.limit=e.limit),void 0!==e.attributesToRetrieve&&(Array.isArray(e.attributesToRetrieve)?r.attributesToRetrieve=e.attributesToRetrieve.join(","):r.attributesToRetrieve=e.attributesToRetrieve),void 0!==e.attributesToCrop&&(Array.isArray(e.attributesToCrop)?r.attributesToCrop=e.attributesToCrop.join(","):r.attributesToCrop=e.attributesToCrop),void 0!==e.cropLength&&(r.cropLength=e.cropLength),void 0!==e.attributesToHighlight&&(Array.isArray(e.attributesToHighlight)?r.attributesToHighlight=e.attributesToHighlight.join(","):r.attributesToHighlight=e.attributesToHighlight),void 0!==e.filters&&(r.filters=e.filters),void 0!==e.matches&&(r.matches=e.matches),void 0!==e.facetFilters&&(r.facetFilters=JSON.stringify(e.facetFilters)),void 0!==e.facetsDistribution&&(r.facetsDistribution=JSON.stringify(e.facetsDistribution))),[4,this.get(n,{params:r,cancelToken:this.cancelTokenSource.token})];case 1:return[2,i.sent()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.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()]}}))}))},o.prototype.getAcceptNewFields=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/accept-new-fields",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},o.prototype.updateAcceptNewFields=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/accept-new-fields",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},o}($);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 G(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 G(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(t){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.prototype.sysInfo=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/sys-info",[4,this.get("/sys-info")];case 1:return[2,t.sent()]}}))}))},s.prototype.prettySysInfo=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/sys-info/pretty",[4,this.get("/sys-info/pretty")];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)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}($)})); | ||
//# sourceMappingURL=meilisearch.browser.min.js.map |
@@ -85,2 +85,14 @@ 'use strict'; | ||
var MeiliSearchError = /** @class */ (function (_super) { | ||
__extends(MeiliSearchError, _super); | ||
function MeiliSearchError(message) { | ||
var _this = _super.call(this, message) || this; | ||
_this.name = 'MeiliSearchError'; | ||
_this.type = 'MeiliSearchError'; | ||
Error.captureStackTrace(_this, MeiliSearchError); | ||
return _this; | ||
} | ||
return MeiliSearchError; | ||
}(Error)); | ||
var MeiliSearchTimeOutError = /** @class */ (function (_super) { | ||
@@ -292,2 +304,7 @@ __extends(MeiliSearchTimeOutError, _super); | ||
function removeUndefinedFromObject(obj) { | ||
// remove undefined | ||
var cleaned = Object.entries(obj).filter(function (x) { return x[1] !== undefined; }); | ||
return Object.fromEntries(cleaned); | ||
} | ||
function sleep(ms) { | ||
@@ -389,5 +406,6 @@ return __awaiter(this, void 0, void 0, function () { | ||
*/ | ||
Index.prototype.search = function (query, options) { | ||
Index.prototype.search = function (query, options, method) { | ||
if (method === void 0) { method = 'POST'; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, params; | ||
var url, params, getParams; | ||
return __generator(this, function (_a) { | ||
@@ -399,55 +417,33 @@ switch (_a.label) { | ||
q: query, | ||
offset: options === null || options === void 0 ? void 0 : options.offset, | ||
limit: options === null || options === void 0 ? void 0 : options.limit, | ||
cropLength: options === null || options === void 0 ? void 0 : options.cropLength, | ||
filters: options === null || options === void 0 ? void 0 : options.filters, | ||
matches: options === null || options === void 0 ? void 0 : options.matches, | ||
facetFilters: options === null || options === void 0 ? void 0 : options.facetFilters, | ||
facetsDistribution: options === null || options === void 0 ? void 0 : options.facetsDistribution, | ||
attributesToRetrieve: options === null || options === void 0 ? void 0 : options.attributesToRetrieve, | ||
attributesToCrop: options === null || options === void 0 ? void 0 : options.attributesToCrop, | ||
attributesToHighlight: options === null || options === void 0 ? void 0 : options.attributesToHighlight, | ||
}; | ||
if (options !== undefined) { | ||
if (options.offset !== undefined) { | ||
params.offset = options.offset; | ||
} | ||
if (options.limit !== undefined) { | ||
params.limit = options.limit; | ||
} | ||
if (options.attributesToRetrieve !== undefined) { | ||
if (Array.isArray(options.attributesToRetrieve)) { | ||
params.attributesToRetrieve = options.attributesToRetrieve.join(','); | ||
} | ||
else { | ||
params.attributesToRetrieve = options.attributesToRetrieve; | ||
} | ||
} | ||
if (options.attributesToCrop !== undefined) { | ||
if (Array.isArray(options.attributesToCrop)) { | ||
params.attributesToCrop = options.attributesToCrop.join(','); | ||
} | ||
else { | ||
params.attributesToCrop = options.attributesToCrop; | ||
} | ||
} | ||
if (options.cropLength !== undefined) { | ||
params.cropLength = options.cropLength; | ||
} | ||
if (options.attributesToHighlight !== undefined) { | ||
if (Array.isArray(options.attributesToHighlight)) { | ||
params.attributesToHighlight = options.attributesToHighlight.join(','); | ||
} | ||
else { | ||
params.attributesToHighlight = options.attributesToHighlight; | ||
} | ||
} | ||
if (options.filters !== undefined) { | ||
params.filters = options.filters; | ||
} | ||
if (options.matches !== undefined) { | ||
params.matches = options.matches; | ||
} | ||
if (options.facetFilters !== undefined) { | ||
params.facetFilters = JSON.stringify(options.facetFilters); | ||
} | ||
if (options.facetsDistribution !== undefined) { | ||
params.facetsDistribution = JSON.stringify(options.facetsDistribution); | ||
} | ||
} | ||
if (!(method.toUpperCase() === 'POST')) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.post(url, removeUndefinedFromObject(params), { | ||
cancelToken: this.cancelTokenSource.token, | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
if (!(method.toUpperCase() === 'GET')) return [3 /*break*/, 4]; | ||
getParams = __assign(__assign({}, params), { facetFilters: Array.isArray(options === null || options === void 0 ? void 0 : options.facetFilters) && (options === null || options === void 0 ? void 0 : options.facetFilters) | ||
? JSON.stringify(options.facetFilters) | ||
: undefined, facetsDistribution: (options === null || options === void 0 ? void 0 : options.facetsDistribution) ? JSON.stringify(options.facetsDistribution) | ||
: undefined, attributesToRetrieve: (options === null || options === void 0 ? void 0 : options.attributesToRetrieve) ? options.attributesToRetrieve.join(',') | ||
: undefined, attributesToCrop: (options === null || options === void 0 ? void 0 : options.attributesToCrop) ? options.attributesToCrop.join(',') | ||
: undefined, attributesToHighlight: (options === null || options === void 0 ? void 0 : options.attributesToHighlight) ? options.attributesToHighlight.join(',') | ||
: undefined }); | ||
return [4 /*yield*/, this.get(url, { | ||
params: params, | ||
params: removeUndefinedFromObject(getParams), | ||
cancelToken: this.cancelTokenSource.token, | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
case 4: throw new MeiliSearchError('method parameter should be either POST or GET'); | ||
} | ||
@@ -1130,41 +1126,2 @@ }); | ||
}; | ||
/// | ||
/// ACCEPT NEW FIELDS | ||
/// | ||
/** | ||
* Get the accept-new-fields value. | ||
* @memberof Index | ||
* @method getAcceptNewFields | ||
*/ | ||
Index.prototype.getAcceptNewFields = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = "/indexes/" + this.uid + "/settings/accept-new-fields"; | ||
return [4 /*yield*/, this.get(url)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Update the accept-new-fields value. | ||
* @memberof Index | ||
* @method updateAcceptNewFields | ||
*/ | ||
Index.prototype.updateAcceptNewFields = function (acceptNewFields) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = "/indexes/" + this.uid + "/settings/accept-new-fields"; | ||
return [4 /*yield*/, this.post(url, acceptNewFields)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return Index; | ||
@@ -1297,3 +1254,3 @@ }(MeiliAxiosWrapper)); | ||
url = '/health'; | ||
return [4 /*yield*/, this.get(url).then(function (_) { return true; })]; | ||
return [4 /*yield*/, this.get(url).then(function () { return true; })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -1403,38 +1360,2 @@ } | ||
}; | ||
/** | ||
* Get the server consuption, RAM / CPU / Network | ||
* @memberof MeiliSearch | ||
* @method sysInfo | ||
*/ | ||
MeiliSearch.prototype.sysInfo = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = '/sys-info'; | ||
return [4 /*yield*/, this.get(url)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Get the server consuption, RAM / CPU / Network. All information as human readable | ||
* @memberof MeiliSearch | ||
* @method prettySysInfo | ||
*/ | ||
MeiliSearch.prototype.prettySysInfo = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = '/sys-info/pretty'; | ||
return [4 /*yield*/, this.get(url)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return MeiliSearch; | ||
@@ -1441,0 +1362,0 @@ }(MeiliAxiosWrapper)); |
@@ -15,3 +15,3 @@ "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)}; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function i(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function s(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((i=i.apply(t,e||[])).next())}))}function o(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[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,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=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 i=t.call(this,n)||this;return i.name="MeiliSearchTimeOutError",i.type=i.constructor.name,Error.captureStackTrace(i,e),i}return i(e,t),e}(Error),c=function(t){function e(e,n){var i,r=t.call(this,e.message)||this;return r.type="MeiliSearchApiError",r.name="MeiliSearchApiError",void 0!==e.response&&(r.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(i=e.response.data)||void 0===i?void 0:i.message)&&(r.errorCode=e.response.data.errorCode,r.errorType=e.response.data.errorType,r.errorLink=e.response.data.errorLink,r.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(r.stack=r.name+": "+r.message+"\n"+n.split("\n").slice(1).join("\n")),r}return i(e,t),e}(Error),a=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",Error.captureStackTrace(i,e),i}return i(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 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?r(r({},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(i){switch(i.label){case 0:n=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),n);case 4:return[2]}}))}))},t.prototype.post=function(t,e,n){return s(this,void 0,void 0,(function(){var i;return o(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),i);case 4:return[2]}}))}))},t.prototype.put=function(t,e,n){return s(this,void 0,void 0,(function(){var i;return o(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),i);case 4:return[2]}}))}))},t.prototype.patch=function(t,e,n){return s(this,void 0,void 0,(function(){var i;return o(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),i);case 4:return[2]}}))}))},t.prototype.delete=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(i){switch(i.label){case 0:n=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),n);case 4:return[2]}}))}))},t}();function l(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 f=function(t){function e(e,n){var i=t.call(this,e)||this;return i.uid=n,i}return i(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,i=n.timeOutMs,r=void 0===i?5e3:i,c=n.intervalMs,a=void 0===c?50:c;return s(this,void 0,void 0,(function(){var e,n;return o(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<r?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=i.sent()).status?[2,n]:[4,l(a)];case 3:return i.sent(),[3,1];case 4:throw new u("timeout of "+r+"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){return s(this,void 0,void 0,(function(){var n,i;return o(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/search",i={q:t},void 0!==e&&(void 0!==e.offset&&(i.offset=e.offset),void 0!==e.limit&&(i.limit=e.limit),void 0!==e.attributesToRetrieve&&(Array.isArray(e.attributesToRetrieve)?i.attributesToRetrieve=e.attributesToRetrieve.join(","):i.attributesToRetrieve=e.attributesToRetrieve),void 0!==e.attributesToCrop&&(Array.isArray(e.attributesToCrop)?i.attributesToCrop=e.attributesToCrop.join(","):i.attributesToCrop=e.attributesToCrop),void 0!==e.cropLength&&(i.cropLength=e.cropLength),void 0!==e.attributesToHighlight&&(Array.isArray(e.attributesToHighlight)?i.attributesToHighlight=e.attributesToHighlight.join(","):i.attributesToHighlight=e.attributesToHighlight),void 0!==e.filters&&(i.filters=e.filters),void 0!==e.matches&&(i.matches=e.matches),void 0!==e.facetFilters&&(i.facetFilters=JSON.stringify(e.facetFilters)),void 0!==e.facetsDistribution&&(i.facetsDistribution=JSON.stringify(e.facetsDistribution))),[4,this.get(n,{params:i,cancelToken:this.cancelTokenSource.token})];case 1:return[2,r.sent()]}}))}))},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(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 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(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,i.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.prototype.getAcceptNewFields=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/accept-new-fields",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAcceptNewFields=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/accept-new-fields",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e}(d),p=function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return i(e,t),e.prototype.getIndex=function(t){return new f(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(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,i.sent()];case 2:if("index_already_exists"===(n=i.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(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 f(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(t){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.prototype.sysInfo=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/sys-info",[4,this.get("/sys-info")];case 1:return[2,t.sent()]}}))}))},e.prototype.prettySysInfo=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/sys-info/pretty",[4,this.get("/sys-info/pretty")];case 1:return[2,t.sent()]}}))}))},e}(d);module.exports=p; | ||
***************************************************************************** */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; | ||
//# sourceMappingURL=meilisearch.cjs.min.js.map |
@@ -81,2 +81,14 @@ import instance from 'axios'; | ||
var MeiliSearchError = /** @class */ (function (_super) { | ||
__extends(MeiliSearchError, _super); | ||
function MeiliSearchError(message) { | ||
var _this = _super.call(this, message) || this; | ||
_this.name = 'MeiliSearchError'; | ||
_this.type = 'MeiliSearchError'; | ||
Error.captureStackTrace(_this, MeiliSearchError); | ||
return _this; | ||
} | ||
return MeiliSearchError; | ||
}(Error)); | ||
var MeiliSearchTimeOutError = /** @class */ (function (_super) { | ||
@@ -288,2 +300,7 @@ __extends(MeiliSearchTimeOutError, _super); | ||
function removeUndefinedFromObject(obj) { | ||
// remove undefined | ||
var cleaned = Object.entries(obj).filter(function (x) { return x[1] !== undefined; }); | ||
return Object.fromEntries(cleaned); | ||
} | ||
function sleep(ms) { | ||
@@ -385,5 +402,6 @@ return __awaiter(this, void 0, void 0, function () { | ||
*/ | ||
Index.prototype.search = function (query, options) { | ||
Index.prototype.search = function (query, options, method) { | ||
if (method === void 0) { method = 'POST'; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, params; | ||
var url, params, getParams; | ||
return __generator(this, function (_a) { | ||
@@ -395,55 +413,33 @@ switch (_a.label) { | ||
q: query, | ||
offset: options === null || options === void 0 ? void 0 : options.offset, | ||
limit: options === null || options === void 0 ? void 0 : options.limit, | ||
cropLength: options === null || options === void 0 ? void 0 : options.cropLength, | ||
filters: options === null || options === void 0 ? void 0 : options.filters, | ||
matches: options === null || options === void 0 ? void 0 : options.matches, | ||
facetFilters: options === null || options === void 0 ? void 0 : options.facetFilters, | ||
facetsDistribution: options === null || options === void 0 ? void 0 : options.facetsDistribution, | ||
attributesToRetrieve: options === null || options === void 0 ? void 0 : options.attributesToRetrieve, | ||
attributesToCrop: options === null || options === void 0 ? void 0 : options.attributesToCrop, | ||
attributesToHighlight: options === null || options === void 0 ? void 0 : options.attributesToHighlight, | ||
}; | ||
if (options !== undefined) { | ||
if (options.offset !== undefined) { | ||
params.offset = options.offset; | ||
} | ||
if (options.limit !== undefined) { | ||
params.limit = options.limit; | ||
} | ||
if (options.attributesToRetrieve !== undefined) { | ||
if (Array.isArray(options.attributesToRetrieve)) { | ||
params.attributesToRetrieve = options.attributesToRetrieve.join(','); | ||
} | ||
else { | ||
params.attributesToRetrieve = options.attributesToRetrieve; | ||
} | ||
} | ||
if (options.attributesToCrop !== undefined) { | ||
if (Array.isArray(options.attributesToCrop)) { | ||
params.attributesToCrop = options.attributesToCrop.join(','); | ||
} | ||
else { | ||
params.attributesToCrop = options.attributesToCrop; | ||
} | ||
} | ||
if (options.cropLength !== undefined) { | ||
params.cropLength = options.cropLength; | ||
} | ||
if (options.attributesToHighlight !== undefined) { | ||
if (Array.isArray(options.attributesToHighlight)) { | ||
params.attributesToHighlight = options.attributesToHighlight.join(','); | ||
} | ||
else { | ||
params.attributesToHighlight = options.attributesToHighlight; | ||
} | ||
} | ||
if (options.filters !== undefined) { | ||
params.filters = options.filters; | ||
} | ||
if (options.matches !== undefined) { | ||
params.matches = options.matches; | ||
} | ||
if (options.facetFilters !== undefined) { | ||
params.facetFilters = JSON.stringify(options.facetFilters); | ||
} | ||
if (options.facetsDistribution !== undefined) { | ||
params.facetsDistribution = JSON.stringify(options.facetsDistribution); | ||
} | ||
} | ||
if (!(method.toUpperCase() === 'POST')) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.post(url, removeUndefinedFromObject(params), { | ||
cancelToken: this.cancelTokenSource.token, | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
if (!(method.toUpperCase() === 'GET')) return [3 /*break*/, 4]; | ||
getParams = __assign(__assign({}, params), { facetFilters: Array.isArray(options === null || options === void 0 ? void 0 : options.facetFilters) && (options === null || options === void 0 ? void 0 : options.facetFilters) | ||
? JSON.stringify(options.facetFilters) | ||
: undefined, facetsDistribution: (options === null || options === void 0 ? void 0 : options.facetsDistribution) ? JSON.stringify(options.facetsDistribution) | ||
: undefined, attributesToRetrieve: (options === null || options === void 0 ? void 0 : options.attributesToRetrieve) ? options.attributesToRetrieve.join(',') | ||
: undefined, attributesToCrop: (options === null || options === void 0 ? void 0 : options.attributesToCrop) ? options.attributesToCrop.join(',') | ||
: undefined, attributesToHighlight: (options === null || options === void 0 ? void 0 : options.attributesToHighlight) ? options.attributesToHighlight.join(',') | ||
: undefined }); | ||
return [4 /*yield*/, this.get(url, { | ||
params: params, | ||
params: removeUndefinedFromObject(getParams), | ||
cancelToken: this.cancelTokenSource.token, | ||
})]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
case 4: throw new MeiliSearchError('method parameter should be either POST or GET'); | ||
} | ||
@@ -1126,41 +1122,2 @@ }); | ||
}; | ||
/// | ||
/// ACCEPT NEW FIELDS | ||
/// | ||
/** | ||
* Get the accept-new-fields value. | ||
* @memberof Index | ||
* @method getAcceptNewFields | ||
*/ | ||
Index.prototype.getAcceptNewFields = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = "/indexes/" + this.uid + "/settings/accept-new-fields"; | ||
return [4 /*yield*/, this.get(url)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Update the accept-new-fields value. | ||
* @memberof Index | ||
* @method updateAcceptNewFields | ||
*/ | ||
Index.prototype.updateAcceptNewFields = function (acceptNewFields) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = "/indexes/" + this.uid + "/settings/accept-new-fields"; | ||
return [4 /*yield*/, this.post(url, acceptNewFields)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return Index; | ||
@@ -1293,3 +1250,3 @@ }(MeiliAxiosWrapper)); | ||
url = '/health'; | ||
return [4 /*yield*/, this.get(url).then(function (_) { return true; })]; | ||
return [4 /*yield*/, this.get(url).then(function () { return true; })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -1399,38 +1356,2 @@ } | ||
}; | ||
/** | ||
* Get the server consuption, RAM / CPU / Network | ||
* @memberof MeiliSearch | ||
* @method sysInfo | ||
*/ | ||
MeiliSearch.prototype.sysInfo = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = '/sys-info'; | ||
return [4 /*yield*/, this.get(url)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Get the server consuption, RAM / CPU / Network. All information as human readable | ||
* @memberof MeiliSearch | ||
* @method prettySysInfo | ||
*/ | ||
MeiliSearch.prototype.prettySysInfo = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = '/sys-info/pretty'; | ||
return [4 /*yield*/, this.get(url)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return MeiliSearch; | ||
@@ -1437,0 +1358,0 @@ }(MeiliAxiosWrapper)); |
@@ -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 i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((i=i.apply(t,e||[])).next())}))}function s(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[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,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=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 i=t.call(this,n)||this;return i.name="MeiliSearchTimeOutError",i.type=i.constructor.name,Error.captureStackTrace(i,e),i}return n(e,t),e}(Error),u=function(t){function e(e,n){var i,r=t.call(this,e.message)||this;return r.type="MeiliSearchApiError",r.name="MeiliSearchApiError",void 0!==e.response&&(r.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(i=e.response.data)||void 0===i?void 0:i.message)&&(r.errorCode=e.response.data.errorCode,r.errorType=e.response.data.errorType,r.errorLink=e.response.data.errorLink,r.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(r.stack=r.name+": "+r.message+"\n"+n.split("\n").slice(1).join("\n")),r}return n(e,t),e}(Error),c=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",Error.captureStackTrace(i,e),i}return n(e,t),e}(Error);function a(t,e){throw void 0!==t.response?new u(t,e):!0===t.isAxiosError?new c(t.message):t}var h=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?i(i({},t),{data:JSON.stringify(t.data)}):t}))}return e.prototype.get=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:n=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,i.sent()];case 3:throw a(i.sent(),n);case 4:return[2]}}))}))},e.prototype.post=function(t,e,n){return r(this,void 0,void 0,(function(){var i;return s(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,r.sent()];case 3:throw a(r.sent(),i);case 4:return[2]}}))}))},e.prototype.put=function(t,e,n){return r(this,void 0,void 0,(function(){var i;return s(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,r.sent()];case 3:throw a(r.sent(),i);case 4:return[2]}}))}))},e.prototype.patch=function(t,e,n){return r(this,void 0,void 0,(function(){var i;return s(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,r.sent()];case 3:throw a(r.sent(),i);case 4:return[2]}}))}))},e.prototype.delete=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:n=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,i.sent()];case 3:throw a(i.sent(),n);case 4:return[2]}}))}))},e}();function d(t){return r(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 l=function(t){function e(e,n){var i=t.call(this,e)||this;return i.uid=n,i}return n(e,t),e.prototype.getUpdateStatus=function(t){return r(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,i=n.timeOutMs,u=void 0===i?5e3:i,c=n.intervalMs,a=void 0===c?50:c;return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=i.sent()).status?[2,n]:[4,d(a)];case 3:return i.sent(),[3,1];case 4:throw new o("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return r(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){return r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/search",i={q:t},void 0!==e&&(void 0!==e.offset&&(i.offset=e.offset),void 0!==e.limit&&(i.limit=e.limit),void 0!==e.attributesToRetrieve&&(Array.isArray(e.attributesToRetrieve)?i.attributesToRetrieve=e.attributesToRetrieve.join(","):i.attributesToRetrieve=e.attributesToRetrieve),void 0!==e.attributesToCrop&&(Array.isArray(e.attributesToCrop)?i.attributesToCrop=e.attributesToCrop.join(","):i.attributesToCrop=e.attributesToCrop),void 0!==e.cropLength&&(i.cropLength=e.cropLength),void 0!==e.attributesToHighlight&&(Array.isArray(e.attributesToHighlight)?i.attributesToHighlight=e.attributesToHighlight.join(","):i.attributesToHighlight=e.attributesToHighlight),void 0!==e.filters&&(i.filters=e.filters),void 0!==e.matches&&(i.matches=e.matches),void 0!==e.facetFilters&&(i.facetFilters=JSON.stringify(e.facetFilters)),void 0!==e.facetsDistribution&&(i.facetsDistribution=JSON.stringify(e.facetsDistribution))),[4,this.get(n,{params:i,cancelToken:this.cancelTokenSource.token})];case 1:return[2,r.sent()]}}))}))},e.prototype.show=function(){return r(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 r(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 r(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 r(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 r(this,void 0,void 0,(function(){var e,n;return s(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 r(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.deleteDocument=function(t){return r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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 r(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.prototype.getAcceptNewFields=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAcceptNewFields=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e}(h),f=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 l(this.config,t)},e.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,i.sent()];case 2:if("index_already_exists"===(n=i.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},e.prototype.listIndexes=function(){return r(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={}),r(this,void 0,void 0,(function(){var n;return s(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 l(this.config,n.uid)]}}))}))},e.prototype.getKeys=function(){return r(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 r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(t){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return r(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 r(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 r(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 r(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 r(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.prototype.sysInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/sys-info",[4,this.get("/sys-info")];case 1:return[2,t.sent()]}}))}))},e.prototype.prettySysInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/sys-info/pretty",[4,this.get("/sys-info/pretty")];case 1:return[2,t.sent()]}}))}))},e}(h);export default f; | ||
***************************************************************************** */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; | ||
//# 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): Promise<Types.SearchResponse<T, P>>; | ||
search<P extends Types.SearchParams<T>>(query?: string, options?: P, method?: Types.Methods): Promise<Types.SearchResponse<T, P>>; | ||
/** | ||
@@ -240,16 +240,4 @@ * Show index information. | ||
resetDisplayedAttributes(): Promise<Types.EnqueuedUpdate>; | ||
/** | ||
* Get the accept-new-fields value. | ||
* @memberof Index | ||
* @method getAcceptNewFields | ||
*/ | ||
getAcceptNewFields(): Promise<boolean>; | ||
/** | ||
* Update the accept-new-fields value. | ||
* @memberof Index | ||
* @method updateAcceptNewFields | ||
*/ | ||
updateAcceptNewFields(acceptNewFields: boolean): Promise<Types.EnqueuedUpdate>; | ||
} | ||
export { Index }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -73,16 +73,4 @@ import { Index } from './index'; | ||
version(): Promise<Types.Version>; | ||
/** | ||
* Get the server consuption, RAM / CPU / Network | ||
* @memberof MeiliSearch | ||
* @method sysInfo | ||
*/ | ||
sysInfo(): Promise<Types.SysInfo>; | ||
/** | ||
* Get the server consuption, RAM / CPU / Network. All information as human readable | ||
* @memberof MeiliSearch | ||
* @method prettySysInfo | ||
*/ | ||
prettySysInfo(): Promise<Types.SysInfoPretty>; | ||
} | ||
export default MeiliSearch; | ||
//# sourceMappingURL=meilisearch.d.ts.map |
@@ -1,2 +0,2 @@ | ||
// Type definitions for meilisearch 0.11.3 | ||
// Type definitions for meilisearch 0.12.0 | ||
// Project: https://github.com/meilisearch/meilisearch-js | ||
@@ -13,4 +13,6 @@ // Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch> | ||
import MeiliSearchTimeOutError from './errors/meilisearch-timeout-error'; | ||
import MeiliSearchError from './errors/meilisearch-error'; | ||
export { Index }; | ||
export { MeiliSearchApiError }; | ||
export { MeiliSearchError }; | ||
export { MeiliSearchTimeOutError }; | ||
@@ -38,12 +40,12 @@ export interface Config { | ||
} | ||
export declare type FacetFilter = (string | string[])[]; | ||
export declare type FacetFilter = Array<string | string[]>; | ||
export interface SearchParams<T> { | ||
offset?: number; | ||
limit?: number; | ||
attributesToRetrieve?: Extract<keyof T, string>[] | Extract<keyof T, string>; | ||
attributesToCrop?: (Extract<keyof T, string> | '*')[] | (Extract<keyof T, string> | '*'); | ||
attributesToRetrieve?: Array<Extract<keyof T, string> | '*'>; | ||
attributesToCrop?: Array<Extract<keyof T, string> | '*'>; | ||
cropLength?: number; | ||
attributesToHighlight?: (Extract<keyof T, string> | '*')[] | (Extract<keyof T, string> | '*'); | ||
attributesToHighlight?: Array<Extract<keyof T, string> | '*'>; | ||
filters?: string; | ||
facetFilters?: string | FacetFilter | FacetFilter[]; | ||
facetFilters?: FacetFilter | FacetFilter[]; | ||
facetsDistribution?: string[]; | ||
@@ -53,5 +55,18 @@ matches?: boolean; | ||
export interface SearchRequest { | ||
q: string; | ||
q?: string; | ||
offset?: number; | ||
limit?: number; | ||
cropLength?: number; | ||
attributesToRetrieve?: string[]; | ||
attributesToCrop?: string[]; | ||
attributesToHighlight?: string[]; | ||
facetFilters?: FacetFilter | FacetFilter[]; | ||
facetsDistribution?: string[]; | ||
filters?: string; | ||
matches?: boolean; | ||
} | ||
export interface GetSearchRequest { | ||
q?: string; | ||
offset?: number; | ||
limit?: number; | ||
attributesToRetrieve?: string; | ||
@@ -70,3 +85,3 @@ attributesToCrop?: string; | ||
export interface SearchResponse<T, P extends SearchParams<T>> { | ||
hits: P['attributesToRetrieve'] extends keyof T ? Array<Hit<Pick<T, Exclude<keyof T, Exclude<keyof T, P['attributesToRetrieve']>>>>> : P['attributesToRetrieve'] extends Array<infer K> ? Array<Hit<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>> : Array<Hit<T>>; | ||
hits: P['attributesToRetrieve'] extends Array<infer K> ? Array<Hit<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>> : Array<Hit<T>>; | ||
offset: number; | ||
@@ -85,3 +100,3 @@ limit: number; | ||
limit?: number; | ||
attributesToRetrieve?: Extract<keyof T, string>[] | Extract<keyof T, string>; | ||
attributesToRetrieve?: Array<Extract<keyof T, string>> | Extract<keyof T, string>; | ||
} | ||
@@ -92,4 +107,3 @@ export declare type GetDocumentsResponse<T, P extends GetDocumentsParams<T>> = P['attributesToRetrieve'] extends keyof T ? Array<Document<Pick<T, Exclude<keyof T, Exclude<keyof T, P['attributesToRetrieve']>>>>> : P['attributesToRetrieve'] extends Array<infer K> ? Array<Document<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>> : Array<Document<T>>; | ||
}; | ||
export interface DocumentArray extends Array<DocumentField> { | ||
} | ||
export declare type DocumentArray = DocumentField[]; | ||
export declare type DocumentField = string | number | boolean | null | DocumentLike | DocumentArray; | ||
@@ -109,3 +123,2 @@ export declare type Document<T> = DocumentLike & { | ||
}; | ||
acceptNewFields?: boolean; | ||
} | ||
@@ -147,34 +160,2 @@ export interface EnqueuedUpdate { | ||
} | ||
export interface SysInfo { | ||
memoryUsage: number; | ||
processorUsage: number[]; | ||
global: { | ||
totalMemory: number; | ||
usedMemory: number; | ||
totalSwap: number; | ||
usedSwap: number; | ||
inputData: number; | ||
outputData: number; | ||
}; | ||
process: { | ||
memory: number; | ||
cpu: number; | ||
}; | ||
} | ||
export interface SysInfoPretty { | ||
memoryUsage: string; | ||
processorUsage: string[]; | ||
global: { | ||
totalMemory: string; | ||
usedMemory: string; | ||
totalSwap: string; | ||
usedSwap: string; | ||
inputData: string; | ||
outputData: string; | ||
}; | ||
process: { | ||
memory: string; | ||
cpu: string; | ||
}; | ||
} | ||
export interface MeiliSearchInterface extends MeiliAxiosWrapper { | ||
@@ -193,5 +174,4 @@ config: Config; | ||
version: () => Promise<Version>; | ||
sysInfo: () => Promise<SysInfo>; | ||
prettySysInfo: () => Promise<SysInfoPretty>; | ||
} | ||
export declare type Methods = 'POST' | 'GET'; | ||
export interface IndexInterface<T = any> extends MeiliAxiosWrapperInterface { | ||
@@ -201,3 +181,3 @@ uid: string; | ||
getAllUpdateStatus: () => Promise<Update[]>; | ||
search: <P extends SearchParams<T>>(query: string, options?: P) => Promise<SearchResponse<T, P>>; | ||
search: <P extends SearchParams<T>>(query: string, options?: P, method?: Methods) => Promise<SearchResponse<T, P>>; | ||
show: () => Promise<IndexResponse>; | ||
@@ -238,4 +218,2 @@ updateIndex: (indexData: IndexOptions) => Promise<IndexResponse>; | ||
resetDisplayedAttributes: () => Promise<EnqueuedUpdate>; | ||
getAcceptNewFields: () => Promise<boolean>; | ||
updateAcceptNewFields: (acceptNewFields: boolean) => Promise<EnqueuedUpdate>; | ||
} | ||
@@ -242,0 +220,0 @@ export interface MeiliAxiosWrapperInterface { |
@@ -0,3 +1,4 @@ | ||
declare function removeUndefinedFromObject(obj: object): object; | ||
declare function sleep(ms: number): Promise<void>; | ||
export { sleep }; | ||
export { sleep, removeUndefinedFromObject }; | ||
//# sourceMappingURL=utils.d.ts.map |
{ | ||
"name": "meilisearch", | ||
"version": "0.11.3", | ||
"version": "0.12.0", | ||
"description": "The MeiliSearch JS client for Node.js and the browser.", | ||
@@ -39,9 +39,6 @@ "keywords": [ | ||
"size": "node scripts/file-size ./dist/bundles/meilisearch.cjs.min.js ./dist/bundles/meilisearch.esm.min.js ./dist/bundles/meilisearch.browser.min.js", | ||
"style": "yarn format && yarn lint", | ||
"style:fix": "yarn format:fix && yarn lint:fix", | ||
"prettier": "prettier \"**/*.{ts,tsx,js,jsx,css,scss,sass,less,md}\"", | ||
"format": "yarn prettier --debug-check", | ||
"format:fix": "yarn prettier --write", | ||
"lint": "eslint '{src,types}/**/*.{ts,js}'", | ||
"lint:fix": "yarn lint --fix", | ||
"style": "yarn lint", | ||
"style:fix": "yarn lint:fix", | ||
"lint": "eslint --ext .js,.ts,.tsx .", | ||
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .", | ||
"typingsheader": "node scripts/build.js" | ||
@@ -66,3 +63,3 @@ }, | ||
"@rollup/plugin-node-resolve": "8.4.0", | ||
"@types/jest": "26.0.5", | ||
"@types/jest": "26.0.8", | ||
"@types/prettier": "^2.0.0", | ||
@@ -72,7 +69,10 @@ "@typescript-eslint/eslint-plugin": "2.34.0", | ||
"brotli-size": "^4.0.0", | ||
"eslint": "6", | ||
"eslint": "^7.5.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-config-standard-with-typescript": "^17.0.0", | ||
"eslint-plugin-import": "2", | ||
"eslint-plugin-jest": "^23.18.0", | ||
"eslint-plugin-jsdoc": "^30.0.0", | ||
"eslint-plugin-node": "11", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"eslint-plugin-promise": "4", | ||
@@ -79,0 +79,0 @@ "eslint-plugin-standard": "4", |
@@ -58,2 +58,3 @@ <p align="center"> | ||
```bash | ||
$ docker pull getmeili/meilisearch:latest # Fetch the latest version of MeiliSearch image from Docker Hub | ||
$ docker run -it --rm -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --master-key=masterKey | ||
@@ -166,4 +167,3 @@ ``` | ||
- `v0.12.X` | ||
- `v0.11.X` | ||
- `v0.13.X` | ||
@@ -317,3 +317,3 @@ ## 🎬 Examples | ||
`client.getIndex<T>('xxx').search(query: string, options?: SearchParams): Promise<SearchResponse<T>>` | ||
`client.getIndex<T>('xxx').search(query: string, options: SearchParams = {}, method: 'POST' | 'GET' = 'POST'): Promise<SearchResponse<T>>` | ||
@@ -480,10 +480,2 @@ ### Indexes <!-- omit in toc --> | ||
### Accept new fields <!-- omit in toc --> | ||
- Get Accept new fields | ||
`index.getAcceptNewFields(): Promise<boolean>` | ||
- Update Accept new fields | ||
`index.updateAcceptNewFields(acceptNewFields: boolean): Promise<EnqueuedUpdate>` | ||
### Keys <!-- omit in toc --> | ||
@@ -513,14 +505,4 @@ | ||
### System <!-- omit in toc --> | ||
- Get system information | ||
`client.systemInformation(): Promise<SysInfo>` | ||
- Get system information (pretty mode) | ||
`client.systemInformationPretty(): Promise<SysInfoPretty>` | ||
<hr> | ||
**MeiliSearch** provides and maintains many **SDKs and Integration tools** like this one. We want to provide everyone with an **amazing search experience for any kind of project**. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the [integration-guides](https://github.com/meilisearch/integration-guides) repository. |
125
src/index.ts
@@ -10,6 +10,7 @@ /* | ||
import MeiliSearchError from './errors/meilisearch-error' | ||
import MeiliSearchTimeOutError from './errors/meilisearch-timeout-error' | ||
import MeiliAxiosWrapper from './meili-axios-wrapper' | ||
import * as Types from './types' | ||
import { sleep } from './utils' | ||
import { sleep, removeUndefinedFromObject } from './utils' | ||
@@ -77,60 +78,54 @@ class Index<T> extends MeiliAxiosWrapper implements Types.IndexInterface<T> { | ||
async search<P extends Types.SearchParams<T>>( | ||
query: string, | ||
options?: P | ||
query?: string, | ||
options?: P, | ||
method: Types.Methods = 'POST' | ||
): Promise<Types.SearchResponse<T, P>> { | ||
const url = `/indexes/${this.uid}/search` | ||
const params: Types.SearchRequest = { | ||
q: query, | ||
offset: options?.offset, | ||
limit: options?.limit, | ||
cropLength: options?.cropLength, | ||
filters: options?.filters, | ||
matches: options?.matches, | ||
facetFilters: options?.facetFilters, | ||
facetsDistribution: options?.facetsDistribution, | ||
attributesToRetrieve: options?.attributesToRetrieve, | ||
attributesToCrop: options?.attributesToCrop, | ||
attributesToHighlight: options?.attributesToHighlight, | ||
} | ||
if (options !== undefined) { | ||
if (options.offset !== undefined) { | ||
params.offset = options.offset | ||
if (method.toUpperCase() === 'POST') { | ||
return await this.post(url, removeUndefinedFromObject(params), { | ||
cancelToken: this.cancelTokenSource.token, | ||
}) | ||
} else if (method.toUpperCase() === 'GET') { | ||
const getParams: Types.GetSearchRequest = { | ||
...params, | ||
facetFilters: | ||
Array.isArray(options?.facetFilters) && options?.facetFilters | ||
? JSON.stringify(options.facetFilters) | ||
: undefined, | ||
facetsDistribution: options?.facetsDistribution | ||
? JSON.stringify(options.facetsDistribution) | ||
: undefined, | ||
attributesToRetrieve: options?.attributesToRetrieve | ||
? options.attributesToRetrieve.join(',') | ||
: undefined, | ||
attributesToCrop: options?.attributesToCrop | ||
? options.attributesToCrop.join(',') | ||
: undefined, | ||
attributesToHighlight: options?.attributesToHighlight | ||
? options.attributesToHighlight.join(',') | ||
: undefined, | ||
} | ||
if (options.limit !== undefined) { | ||
params.limit = options.limit | ||
} | ||
if (options.attributesToRetrieve !== undefined) { | ||
if (Array.isArray(options.attributesToRetrieve)) { | ||
params.attributesToRetrieve = options.attributesToRetrieve.join(',') | ||
} else { | ||
params.attributesToRetrieve = options.attributesToRetrieve | ||
} | ||
} | ||
if (options.attributesToCrop !== undefined) { | ||
if (Array.isArray(options.attributesToCrop)) { | ||
params.attributesToCrop = options.attributesToCrop.join(',') | ||
} else { | ||
params.attributesToCrop = options.attributesToCrop | ||
} | ||
} | ||
if (options.cropLength !== undefined) { | ||
params.cropLength = options.cropLength | ||
} | ||
if (options.attributesToHighlight !== undefined) { | ||
if (Array.isArray(options.attributesToHighlight)) { | ||
params.attributesToHighlight = options.attributesToHighlight.join(',') | ||
} else { | ||
params.attributesToHighlight = options.attributesToHighlight | ||
} | ||
} | ||
if (options.filters !== undefined) { | ||
params.filters = options.filters | ||
} | ||
if (options.matches !== undefined) { | ||
params.matches = options.matches | ||
} | ||
if (options.facetFilters !== undefined) { | ||
params.facetFilters = JSON.stringify(options.facetFilters) | ||
} | ||
if (options.facetsDistribution !== undefined) { | ||
params.facetsDistribution = JSON.stringify(options.facetsDistribution) | ||
} | ||
return await this.get(url, { | ||
params: removeUndefinedFromObject(getParams), | ||
cancelToken: this.cancelTokenSource.token, | ||
}) | ||
} else { | ||
throw new MeiliSearchError( | ||
'method parameter should be either POST or GET' | ||
) | ||
} | ||
return await this.get(url, { | ||
params, | ||
cancelToken: this.cancelTokenSource.token, | ||
}) | ||
} | ||
@@ -603,32 +598,4 @@ | ||
} | ||
/// | ||
/// ACCEPT NEW FIELDS | ||
/// | ||
/** | ||
* Get the accept-new-fields value. | ||
* @memberof Index | ||
* @method getAcceptNewFields | ||
*/ | ||
async getAcceptNewFields(): Promise<boolean> { | ||
const url = `/indexes/${this.uid}/settings/accept-new-fields` | ||
return await this.get(url) | ||
} | ||
/** | ||
* Update the accept-new-fields value. | ||
* @memberof Index | ||
* @method updateAcceptNewFields | ||
*/ | ||
async updateAcceptNewFields( | ||
acceptNewFields: boolean | ||
): Promise<Types.EnqueuedUpdate> { | ||
const url = `/indexes/${this.uid}/settings/accept-new-fields` | ||
return await this.post(url, acceptNewFields) | ||
} | ||
} | ||
export { Index } |
@@ -104,3 +104,3 @@ /* | ||
return await this.get(url).then((_) => true) | ||
return await this.get(url).then(() => true) | ||
} | ||
@@ -172,26 +172,4 @@ | ||
} | ||
/** | ||
* Get the server consuption, RAM / CPU / Network | ||
* @memberof MeiliSearch | ||
* @method sysInfo | ||
*/ | ||
async sysInfo(): Promise<Types.SysInfo> { | ||
const url = '/sys-info' | ||
return await this.get(url) | ||
} | ||
/** | ||
* Get the server consuption, RAM / CPU / Network. All information as human readable | ||
* @memberof MeiliSearch | ||
* @method prettySysInfo | ||
*/ | ||
async prettySysInfo(): Promise<Types.SysInfoPretty> { | ||
const url = '/sys-info/pretty' | ||
return await this.get(url) | ||
} | ||
} | ||
export default MeiliSearch |
101
src/types.ts
@@ -20,4 +20,6 @@ // Type definitions for meilisearch | ||
import MeiliSearchTimeOutError from './errors/meilisearch-timeout-error' | ||
import MeiliSearchError from './errors/meilisearch-error' | ||
export { Index } | ||
export { MeiliSearchApiError } | ||
export { MeiliSearchError } | ||
export { MeiliSearchTimeOutError } | ||
@@ -55,3 +57,3 @@ | ||
export type FacetFilter = (string | string[])[] | ||
export type FacetFilter = Array<string | string[]> | ||
@@ -61,12 +63,8 @@ export interface SearchParams<T> { | ||
limit?: number | ||
attributesToRetrieve?: Extract<keyof T, string>[] | Extract<keyof T, string> | ||
attributesToCrop?: | ||
| (Extract<keyof T, string> | '*')[] | ||
| (Extract<keyof T, string> | '*') | ||
attributesToRetrieve?: Array<Extract<keyof T, string> | '*'> | ||
attributesToCrop?: Array<Extract<keyof T, string> | '*'> | ||
cropLength?: number | ||
attributesToHighlight?: | ||
| (Extract<keyof T, string> | '*')[] | ||
| (Extract<keyof T, string> | '*') | ||
attributesToHighlight?: Array<Extract<keyof T, string> | '*'> | ||
filters?: string | ||
facetFilters?: string | FacetFilter | FacetFilter[] | ||
facetFilters?: FacetFilter | FacetFilter[] | ||
facetsDistribution?: string[] | ||
@@ -77,5 +75,19 @@ matches?: boolean | ||
export interface SearchRequest { | ||
q: string | ||
q?: string | ||
offset?: number | ||
limit?: number | ||
cropLength?: number | ||
attributesToRetrieve?: string[] | ||
attributesToCrop?: string[] | ||
attributesToHighlight?: string[] | ||
facetFilters?: FacetFilter | FacetFilter[] | ||
facetsDistribution?: string[] | ||
filters?: string | ||
matches?: boolean | ||
} | ||
export interface GetSearchRequest { | ||
q?: string | ||
offset?: number | ||
limit?: number | ||
attributesToRetrieve?: string | ||
@@ -93,12 +105,10 @@ attributesToCrop?: string | ||
// The second generic P is used to capture the SearchParams type | ||
export interface SearchResponse<T, P extends SearchParams<T>> { | ||
hits: P['attributesToRetrieve'] extends keyof T | ||
? Array< | ||
Hit< | ||
Pick<T, Exclude<keyof T, Exclude<keyof T, P['attributesToRetrieve']>>> | ||
> | ||
> | ||
: P['attributesToRetrieve'] extends Array<infer K> | ||
? Array<Hit<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>> | ||
: Array<Hit<T>> | ||
// P represents the SearchParams | ||
// and by using the indexer P['attributesToRetrieve'], we're able to pick the type of `attributesToRetrieve` | ||
// and check whether the attribute is a single key present in the generic | ||
hits: P['attributesToRetrieve'] extends Array<infer K> // if P['attributesToRetrieve'] is an array, we use `infer K` to extract the keys in the array in place | ||
? Array<Hit<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>> // Same extraction method as above when we have a single `attributesToRetrieve` | ||
: Array<Hit<T>> // Finally return the full type as `attributesToRetrieve` is neither a single key nor an array of keys | ||
offset: number | ||
@@ -122,3 +132,5 @@ limit: number | ||
limit?: number | ||
attributesToRetrieve?: Extract<keyof T, string>[] | Extract<keyof T, string> | ||
attributesToRetrieve?: | ||
| Array<Extract<keyof T, string>> | ||
| Extract<keyof T, string> | ||
} | ||
@@ -140,3 +152,3 @@ | ||
export type DocumentLike = { [Key in string]?: DocumentField } | ||
export interface DocumentArray extends Array<DocumentField> {} | ||
export type DocumentArray = DocumentField[] | ||
export type DocumentField = | ||
@@ -169,3 +181,2 @@ | string | ||
} | ||
acceptNewFields?: boolean | ||
} | ||
@@ -230,39 +241,2 @@ | ||
/* | ||
** SYS-INFO | ||
*/ | ||
export interface SysInfo { | ||
memoryUsage: number | ||
processorUsage: number[] | ||
global: { | ||
totalMemory: number | ||
usedMemory: number | ||
totalSwap: number | ||
usedSwap: number | ||
inputData: number | ||
outputData: number | ||
} | ||
process: { | ||
memory: number | ||
cpu: number | ||
} | ||
} | ||
export interface SysInfoPretty { | ||
memoryUsage: string | ||
processorUsage: string[] | ||
global: { | ||
totalMemory: string | ||
usedMemory: string | ||
totalSwap: string | ||
usedSwap: string | ||
inputData: string | ||
outputData: string | ||
} | ||
process: { | ||
memory: string | ||
cpu: string | ||
} | ||
} | ||
/* | ||
** MeiliSearch Class Interfaces | ||
@@ -287,6 +261,6 @@ */ | ||
version: () => Promise<Version> | ||
sysInfo: () => Promise<SysInfo> | ||
prettySysInfo: () => Promise<SysInfoPretty> | ||
} | ||
export type Methods = 'POST' | 'GET' | ||
export interface IndexInterface<T = any> extends MeiliAxiosWrapperInterface { | ||
@@ -298,3 +272,4 @@ uid: string | ||
query: string, | ||
options?: P | ||
options?: P, | ||
method?: Methods | ||
) => Promise<SearchResponse<T, P>> | ||
@@ -354,4 +329,2 @@ show: () => Promise<IndexResponse> | ||
resetDisplayedAttributes: () => Promise<EnqueuedUpdate> | ||
getAcceptNewFields: () => Promise<boolean> | ||
updateAcceptNewFields: (acceptNewFields: boolean) => Promise<EnqueuedUpdate> | ||
} | ||
@@ -358,0 +331,0 @@ |
@@ -0,1 +1,7 @@ | ||
function removeUndefinedFromObject(obj: object): object { | ||
// remove undefined | ||
const cleaned = Object.entries(obj).filter((x) => x[1] !== undefined) | ||
return Object.fromEntries(cleaned) | ||
} | ||
async function sleep(ms: number): Promise<void> { | ||
@@ -5,2 +11,2 @@ return await new Promise((resolve) => setTimeout(resolve, ms)) | ||
export { sleep } | ||
export { sleep, removeUndefinedFromObject } |
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
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
44
437699
31
7354
504