Socket
Socket
Sign inDemoInstall

meilisearch

Package Overview
Dependencies
Maintainers
4
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meilisearch - npm Package Compare versions

Comparing version 0.26.0-beta.0 to 0.26.0

dist/types/clients/browser-client.d.ts

11

CONTRIBUTING.md

@@ -43,3 +43,12 @@ # Contributing

You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml).
Example of running all the checks with docker:
```bash
docker-compose run --rm package bash -c "yarn install && yarn test && yarn lint"
```
To install dependencies:
```bash
yarn --dev

@@ -133,3 +142,3 @@ ```

- Change the version in `package.json` by `vX.X.X-beta.0` and commit it to the `vX.X.X-beta.0` branch
- Change the version in `package.json` with `X.X.X-beta.0` and commit it to the `vX.X.X-beta.0` branch

@@ -136,0 +145,0 @@ - Go to the [GitHub interface for releasing](https://github.com/meilisearch/meilisearch-js/releases): on this page, click on `Draft a new release`.

2

dist/bundles/meilisearch.esm.min.js

@@ -15,3 +15,3 @@ import"cross-fetch/polyfill";import t from"crypto";

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)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");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,r,i,s){var o,u,c,a=this;return(a=t.call(this,n)||this).name="MeiliSearchCommunicationError",a.type="MeiliSearchCommunicationError",r instanceof Response&&(a.message=r.statusText,a.statusCode=r.status),r instanceof Error&&(a.errno=r.errno,a.code=r.code),s?(a.stack=s,a.stack=null===(o=a.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,a.name),a.stack=null===(u=a.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(a,e),a}return n(e,t),e}(Error),u=function(t){function e(e,n){var r=t.call(this,e.message)||this;return r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Object.setPrototypeOf(r,u.prototype),Error.captureStackTrace&&Error.captureStackTrace(r,u),r}return n(e,t),e}(Error);function c(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new o(t.statusText,t,t.url);case 4:throw new u(e,t.status);case 5:return[2,t]}}))}))}function a(t,e,n){if("MeiliSearchApiError"!==t.type)throw new o(t.message,t,n,e);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),d=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function l(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function p(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()]}}))}))}function f(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}function v(t){return t.endsWith("/")||(t+="/"),t}var y=function(){function t(t){this.headers=Object.assign({},t.headers||{}),this.headers["Content-Type"]="application/json",t.apiKey&&(this.headers.Authorization="Bearer ".concat(t.apiKey));try{var e=function(t){try{return v(t=f(t))}catch(t){throw new h("The provided host is not valid.")}}(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e=t.method,n=t.url,o=t.params,u=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,d,l,p;return s(this,(function(s){switch(s.label){case 0:t=new URL(n,this.url),o&&(i=new URLSearchParams,Object.keys(o).filter((function(t){return null!==o[t]})).map((function(t){return i.set(t,o[t])})),t.search=i.toString()),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(u),headers:this.headers})).then((function(t){return c(t)}))];case 2:return[4,s.sent().text()];case 3:d=s.sent();try{return[2,JSON.parse(d)]}catch(t){return[2]}return[3,5];case 4:return l=s.sent(),p=l.stack,a(l,p,t.toString()),[3,5];case 5:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),b=function(){function t(t){this.httpRequest=new y(t)}return t.prototype.getClientTask=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getClientTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"tasks",[4,this.httpRequest.get("tasks")];case 1:return[2,t.sent()]}}))}))},t.prototype.getIndexTask=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/".concat(t,"/tasks/").concat(e),[4,this.httpRequest.get(n)];case 1:return[2,r.sent()]}}))}))},t.prototype.getIndexTasks=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/".concat(t,"/tasks"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForClientTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;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.getClientTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,p(c)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new d("timeout of ".concat(o,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForClientTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){var e,n,r,i,u;return s(this,(function(s){switch(s.label){case 0:e=[],n=0,r=t,s.label=1;case 1:return n<r.length?(i=r[n],[4,this.waitForClientTask(i,{timeOutMs:o,intervalMs:c})]):[3,4];case 2:u=s.sent(),e.push(u),s.label=3;case 3:return n++,[3,1];case 4:return[2,{results:e}]}}))}))},t.prototype.waitForIndexTask=function(t,e,n){var r=void 0===n?{}:n,o=r.timeOutMs,u=void 0===o?5e3:o,c=r.intervalMs,a=void 0===c?50:c;return i(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){switch(i.label){case 0:n=Date.now(),i.label=1;case 1:return Date.now()-n<u?[4,this.getIndexTask(t,e)]:[3,4];case 2:return r=i.sent(),["enqueued","processing"].includes(r.status)?[4,p(a)]:[2,r];case 3:return i.sent(),[3,1];case 4:throw new d("timeout of ".concat(u,"ms has exceeded on process ").concat(e," when waiting for pending update to resolve."))}}))}))},t}(),w=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new y(t),this.tasks=new b(t)}return t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,l(r(r({},e),{q:t})),void 0,n)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){return i(this,void 0,void 0,(function(){var i,o,u;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),o=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},u=r(r({q:t},e),{filter:o(null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)?e.sort.join(","):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?e.facetsDistribution.join(","):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.httpRequest.get(i,l(u),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(i){return"indexes",[2,new y(n).post("indexes",r(r({},e),{uid:t}))]}))}))},t.prototype.update=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/".concat(this.uid),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getIndexTasks(this.uid)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getIndexTask(this.uid,t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,r(r({},t),void 0!==n?{attributesToRetrieve:n}:{}))];case 1:return[2,i.sent()]}}))}))},t.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/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.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/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=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/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=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/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=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/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),g=function(){function t(t){this.config=t,this.httpRequest=new y(t),this.tasks=new b(t)}return t.prototype.index=function(t){return new w(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new w(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new w(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(){return i(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(n){switch(n.label){case 0:return[4,this.getRawIndexes()];case 1:return t=n.sent(),[2,t.map((function(t){return new w(e.config,t.uid,t.primaryKey)}))]}}))}))},t.prototype.getRawIndexes=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"indexes",[4,this.httpRequest.get("indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,w.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,new w(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new w(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getClientTasks()];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getClientTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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.httpRequest.get("keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.getKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"keys",[4,this.httpRequest.post("keys",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateKey=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="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"health",[4,this.httpRequest.get("health")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"stats",[4,this.httpRequest.get("stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.getVersion=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"version",[4,this.httpRequest.get("version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return[2,t.sent()]}}))}))},t.prototype.getDumpStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="dumps/".concat(t,"/status"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.generateTenantToken=function(t,e){var n=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(n.stack,"."))},t}();function m(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function k(t){var e=t.searchRules,n=t.apiKey,r=t.expiresAt;return function(t){var e=t.searchRules,n=t.apiKey,r=t.expiresAt,i=new Error;if(r&&(!(r instanceof Date)||r.getTime()<Date.now()))throw new Error("Meilisearch: When the expiresAt field in the token generation has a value, it must be a date set in the future and not in the past. \n ".concat(i.stack,"."));if(e&&"object"!=typeof e&&!Array.isArray(e))throw new Error("Meilisearch: The search rules added in the token generation must be of type array or object. \n ".concat(i.stack,"."));if(!n||"string"!=typeof n)throw new Error("Meilisearch: The API key used for the token generation must exist and be of type string. \n ".concat(i.stack,"."))}(t),m({searchRules:e,apiKeyPrefix:n.substring(0,8),exp:null==r?void 0:r.getTime()}).replace(/=/g,"")}var R=function(){function e(t){this.config=t}return e.prototype.generateTenantToken=function(e,n){var r=(null==n?void 0:n.apiKey)||this.config.apiKey||"",i=null==n?void 0:n.expiresAt,s=m({alg:"HS256",typ:"JWT"}).replace(/=/g,""),o=k({searchRules:e,apiKey:r,expiresAt:i}),u=function(e,n,r){return t.createHmac("sha256",e).update("".concat(n,".").concat(r)).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(r,s,o);return"".concat(s,".").concat(o,".").concat(u)},e}(),x=function(t){function e(e){var n=t.call(this,e)||this;return n.tokens=new R(e),n}return n(e,t),e.prototype.generateTenantToken=function(e,n){return"undefined"==typeof window?this.tokens.generateTenantToken(e,n):t.prototype.generateTenantToken.call(this,e,n)},e}(g);export{y as HttpRequests,w as Index,x as MeiliSearch,u as MeiliSearchApiError,o as MeiliSearchCommunicationError,h as MeiliSearchError,d as MeiliSearchTimeOutError,f as addProtocolIfNotPresent,v as addTrailingSlash,x as default,a as httpErrorHandler,c as httpResponseErrorHandler,l as removeUndefinedFromObject,p as sleep};
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");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,r,i,s){var o,u,c,a=this;return a=t.call(this,n)||this,Object.setPrototypeOf(a,e.prototype),a.name="MeiliSearchCommunicationError",r instanceof Response&&(a.message=r.statusText,a.statusCode=r.status),r instanceof Error&&(a.errno=r.errno,a.code=r.code),s?(a.stack=s,a.stack=null===(o=a.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,a.name),a.stack=null===(u=a.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(a,e),a}return n(e,t),e}(Error),u=function(t){function e(e,n){var r=t.call(this,e.message)||this;return Object.setPrototypeOf(r,u.prototype),r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,u),r}return n(e,t),e}(Error);function c(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new o(t.statusText,t,t.url);case 4:throw new u(e,t.status);case 5:return[2,t]}}))}))}function a(t,e,n){if("MeiliSearchApiError"!==t.name)throw new o(t.message,t,n,e);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),d=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function l(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function p(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 f=function(){function t(t){this.headers=Object.assign({},t.headers||{}),this.headers["Content-Type"]="application/json",t.apiKey&&(this.headers.Authorization="Bearer ".concat(t.apiKey));try{var e=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new h("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e=t.method,n=t.url,o=t.params,u=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,d,l;return s(this,(function(s){switch(s.label){case 0:t=new URL(n,this.url),o&&(i=new URLSearchParams,Object.keys(o).filter((function(t){return null!==o[t]})).map((function(t){return i.set(t,o[t])})),t.search=i.toString()),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(u),headers:this.headers})).then((function(t){return c(t)}))];case 2:return[4,s.sent().json().catch((function(){}))];case 3:return[2,s.sent()];case 4:return d=s.sent(),l=d.stack,a(d,l,t.toString()),[3,5];case 5:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),v=function(){function t(t){this.httpRequest=new f(t)}return t.prototype.getClientTask=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getClientTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"tasks",[4,this.httpRequest.get("tasks")];case 1:return[2,t.sent()]}}))}))},t.prototype.getIndexTask=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/".concat(t,"/tasks/").concat(e),[4,this.httpRequest.get(n)];case 1:return[2,r.sent()]}}))}))},t.prototype.getIndexTasks=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/".concat(t,"/tasks"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForClientTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;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.getClientTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,p(c)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new d("timeout of ".concat(o,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForClientTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){var e,n,r,i,u;return s(this,(function(s){switch(s.label){case 0:e=[],n=0,r=t,s.label=1;case 1:return n<r.length?(i=r[n],[4,this.waitForClientTask(i,{timeOutMs:o,intervalMs:c})]):[3,4];case 2:u=s.sent(),e.push(u),s.label=3;case 3:return n++,[3,1];case 4:return[2,{results:e}]}}))}))},t.prototype.waitForIndexTask=function(t,e,n){var r=void 0===n?{}:n,o=r.timeOutMs,u=void 0===o?5e3:o,c=r.intervalMs,a=void 0===c?50:c;return i(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){switch(i.label){case 0:n=Date.now(),i.label=1;case 1:return Date.now()-n<u?[4,this.getIndexTask(t,e)]:[3,4];case 2:return r=i.sent(),["enqueued","processing"].includes(r.status)?[4,p(a)]:[2,r];case 3:return i.sent(),[3,1];case 4:throw new d("timeout of ".concat(u,"ms has exceeded on process ").concat(e," when waiting for pending update to resolve."))}}))}))},t}(),y=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new f(t),this.tasks=new v(t)}return t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,l(r({q:t},e)),void 0,n)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var o,u,c,a,d;return i(this,void 0,void 0,(function(){var i,p,f;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),p=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},f=r(r({q:t},e),{filter:p(null==e?void 0:e.filter),sort:null===(o=null==e?void 0:e.sort)||void 0===o?void 0:o.join(","),facetsDistribution:null===(u=null==e?void 0:e.facetsDistribution)||void 0===u?void 0:u.join(","),attributesToRetrieve:null===(c=null==e?void 0:e.attributesToRetrieve)||void 0===c?void 0:c.join(","),attributesToCrop:null===(a=null==e?void 0:e.attributesToCrop)||void 0===a?void 0:a.join(","),attributesToHighlight:null===(d=null==e?void 0:e.attributesToHighlight)||void 0===d?void 0:d.join(",")}),[4,this.httpRequest.get(i,l(f),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(i){return"indexes",[2,new f(n).post("indexes",r(r({},e),{uid:t}))]}))}))},t.prototype.update=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/".concat(this.uid),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getIndexTasks(this.uid)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getIndexTask(this.uid,t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,r(r({},t),void 0!==n?{attributesToRetrieve:n}:{}))];case 1:return[2,i.sent()]}}))}))},t.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/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.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/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=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/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=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/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=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/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),b=function(){function t(t){this.config=t,this.httpRequest=new f(t),this.tasks=new v(t)}return t.prototype.index=function(t){return new y(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(){return i(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(n){switch(n.label){case 0:return[4,this.getRawIndexes()];case 1:return t=n.sent(),[2,t.map((function(t){return new y(e.config,t.uid,t.primaryKey)}))]}}))}))},t.prototype.getRawIndexes=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"indexes",[4,this.httpRequest.get("indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,y.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,new y(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new y(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getClientTasks()];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getClientTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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.httpRequest.get("keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.getKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"keys",[4,this.httpRequest.post("keys",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateKey=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="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"health",[4,this.httpRequest.get("health")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"stats",[4,this.httpRequest.get("stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.getVersion=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"version",[4,this.httpRequest.get("version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return[2,t.sent()]}}))}))},t.prototype.getDumpStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="dumps/".concat(t,"/status"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.generateTenantToken=function(t,e){var n=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(n.stack,"."))},t}();function w(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function g(t){var e=t.searchRules,n=t.apiKey,r=t.expiresAt;return function(t){var e=t.searchRules,n=t.apiKey,r=t.expiresAt,i=new Error;if(r&&(!(r instanceof Date)||r.getTime()<Date.now()))throw new Error("Meilisearch: When the expiresAt field in the token generation has a value, it must be a date set in the future and not in the past. \n ".concat(i.stack,"."));if(e&&"object"!=typeof e&&!Array.isArray(e))throw new Error("Meilisearch: The search rules added in the token generation must be of type array or object. \n ".concat(i.stack,"."));if(!n||"string"!=typeof n)throw new Error("Meilisearch: The API key used for the token generation must exist and be of type string. \n ".concat(i.stack,"."))}(t),w({searchRules:e,apiKeyPrefix:n.substring(0,8),exp:null==r?void 0:r.getTime()}).replace(/=/g,"")}var m=function(){function e(t){this.config=t}return e.prototype.generateTenantToken=function(e,n){var r=(null==n?void 0:n.apiKey)||this.config.apiKey||"",i=null==n?void 0:n.expiresAt,s=w({alg:"HS256",typ:"JWT"}).replace(/=/g,""),o=g({searchRules:e,apiKey:r,expiresAt:i}),u=function(e,n,r){return t.createHmac("sha256",e).update("".concat(n,".").concat(r)).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(r,s,o);return"".concat(s,".").concat(o,".").concat(u)},e}(),k=function(t){function e(e){var n=t.call(this,e)||this;return n.tokens=new m(e),n}return n(e,t),e.prototype.generateTenantToken=function(e,n){return"undefined"==typeof window?this.tokens.generateTenantToken(e,n):t.prototype.generateTenantToken.call(this,e,n)},e}(b);export{y as Index,k as MeiliSearch,u as MeiliSearchApiError,o as MeiliSearchCommunicationError,h as MeiliSearchError,d as MeiliSearchTimeOutError,k as default,a as httpErrorHandler,c as httpResponseErrorHandler};
//# sourceMappingURL=meilisearch.esm.min.js.map

@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("cross-fetch/polyfill")):"function"==typeof define&&define.amd?define(["exports","cross-fetch/polyfill"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";

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)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");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,r,i,s){var o,u,c,a=this;return(a=t.call(this,n)||this).name="MeiliSearchCommunicationError",a.type="MeiliSearchCommunicationError",r instanceof Response&&(a.message=r.statusText,a.statusCode=r.status),r instanceof Error&&(a.errno=r.errno,a.code=r.code),s?(a.stack=s,a.stack=null===(o=a.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,a.name),a.stack=null===(u=a.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(a,e),a}return n(e,t),e}(Error),u=function(t){function e(e,n){var r=t.call(this,e.message)||this;return r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Object.setPrototypeOf(r,u.prototype),Error.captureStackTrace&&Error.captureStackTrace(r,u),r}return n(e,t),e}(Error);function c(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new o(t.statusText,t,t.url);case 4:throw new u(e,t.status);case 5:return[2,t]}}))}))}function a(t,e,n){if("MeiliSearchApiError"!==t.type)throw new o(t.message,t,n,e);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),d=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function l(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function p(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()]}}))}))}function f(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}function v(t){return t.endsWith("/")||(t+="/"),t}var y=function(){function t(t){this.headers=Object.assign({},t.headers||{}),this.headers["Content-Type"]="application/json",t.apiKey&&(this.headers.Authorization="Bearer ".concat(t.apiKey));try{var e=function(t){try{return v(t=f(t))}catch(t){throw new h("The provided host is not valid.")}}(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e=t.method,n=t.url,o=t.params,u=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,d,l,p;return s(this,(function(s){switch(s.label){case 0:t=new URL(n,this.url),o&&(i=new URLSearchParams,Object.keys(o).filter((function(t){return null!==o[t]})).map((function(t){return i.set(t,o[t])})),t.search=i.toString()),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(u),headers:this.headers})).then((function(t){return c(t)}))];case 2:return[4,s.sent().text()];case 3:d=s.sent();try{return[2,JSON.parse(d)]}catch(t){return[2]}return[3,5];case 4:return l=s.sent(),p=l.stack,a(l,p,t.toString()),[3,5];case 5:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),b=function(){function t(t){this.httpRequest=new y(t)}return t.prototype.getClientTask=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getClientTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"tasks",[4,this.httpRequest.get("tasks")];case 1:return[2,t.sent()]}}))}))},t.prototype.getIndexTask=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/".concat(t,"/tasks/").concat(e),[4,this.httpRequest.get(n)];case 1:return[2,r.sent()]}}))}))},t.prototype.getIndexTasks=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/".concat(t,"/tasks"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForClientTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;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.getClientTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,p(c)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new d("timeout of ".concat(o,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForClientTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){var e,n,r,i,u;return s(this,(function(s){switch(s.label){case 0:e=[],n=0,r=t,s.label=1;case 1:return n<r.length?(i=r[n],[4,this.waitForClientTask(i,{timeOutMs:o,intervalMs:c})]):[3,4];case 2:u=s.sent(),e.push(u),s.label=3;case 3:return n++,[3,1];case 4:return[2,{results:e}]}}))}))},t.prototype.waitForIndexTask=function(t,e,n){var r=void 0===n?{}:n,o=r.timeOutMs,u=void 0===o?5e3:o,c=r.intervalMs,a=void 0===c?50:c;return i(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){switch(i.label){case 0:n=Date.now(),i.label=1;case 1:return Date.now()-n<u?[4,this.getIndexTask(t,e)]:[3,4];case 2:return r=i.sent(),["enqueued","processing"].includes(r.status)?[4,p(a)]:[2,r];case 3:return i.sent(),[3,1];case 4:throw new d("timeout of ".concat(u,"ms has exceeded on process ").concat(e," when waiting for pending update to resolve."))}}))}))},t}(),w=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new y(t),this.tasks=new b(t)}return t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,l(r(r({},e),{q:t})),void 0,n)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){return i(this,void 0,void 0,(function(){var i,o,u;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),o=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},u=r(r({q:t},e),{filter:o(null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)?e.sort.join(","):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?e.facetsDistribution.join(","):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.httpRequest.get(i,l(u),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(i){return"indexes",[2,new y(n).post("indexes",r(r({},e),{uid:t}))]}))}))},t.prototype.update=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/".concat(this.uid),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getIndexTasks(this.uid)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getIndexTask(this.uid,t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,r(r({},t),void 0!==n?{attributesToRetrieve:n}:{}))];case 1:return[2,i.sent()]}}))}))},t.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/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.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/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=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/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=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/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=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/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),g=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new y(t),this.tasks=new b(t)}return t.prototype.index=function(t){return new w(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new w(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new w(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(){return i(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(n){switch(n.label){case 0:return[4,this.getRawIndexes()];case 1:return t=n.sent(),[2,t.map((function(t){return new w(e.config,t.uid,t.primaryKey)}))]}}))}))},t.prototype.getRawIndexes=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"indexes",[4,this.httpRequest.get("indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,w.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,new w(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new w(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getClientTasks()];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getClientTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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.httpRequest.get("keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.getKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"keys",[4,this.httpRequest.post("keys",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateKey=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="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"health",[4,this.httpRequest.get("health")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"stats",[4,this.httpRequest.get("stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.getVersion=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"version",[4,this.httpRequest.get("version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return[2,t.sent()]}}))}))},t.prototype.getDumpStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="dumps/".concat(t,"/status"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.generateTenantToken=function(t,e){var n=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(n.stack,"."))},t}());t.HttpRequests=y,t.Index=w,t.MeiliSearch=g,t.MeiliSearchApiError=u,t.MeiliSearchCommunicationError=o,t.MeiliSearchError=h,t.MeiliSearchTimeOutError=d,t.addProtocolIfNotPresent=f,t.addTrailingSlash=v,t.default=g,t.httpErrorHandler=a,t.httpResponseErrorHandler=c,t.removeUndefinedFromObject=l,t.sleep=p,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");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,r,i,s){var o,u,c,a=this;return a=t.call(this,n)||this,Object.setPrototypeOf(a,e.prototype),a.name="MeiliSearchCommunicationError",r instanceof Response&&(a.message=r.statusText,a.statusCode=r.status),r instanceof Error&&(a.errno=r.errno,a.code=r.code),s?(a.stack=s,a.stack=null===(o=a.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,a.name),a.stack=null===(u=a.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(a,e),a}return n(e,t),e}(Error),u=function(t){function e(e,n){var r=t.call(this,e.message)||this;return Object.setPrototypeOf(r,u.prototype),r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,u),r}return n(e,t),e}(Error);function c(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new o(t.statusText,t,t.url);case 4:throw new u(e,t.status);case 5:return[2,t]}}))}))}function a(t,e,n){if("MeiliSearchApiError"!==t.name)throw new o(t.message,t,n,e);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),d=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function l(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function p(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 f=function(){function t(t){this.headers=Object.assign({},t.headers||{}),this.headers["Content-Type"]="application/json",t.apiKey&&(this.headers.Authorization="Bearer ".concat(t.apiKey));try{var e=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new h("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e=t.method,n=t.url,o=t.params,u=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,d,l;return s(this,(function(s){switch(s.label){case 0:t=new URL(n,this.url),o&&(i=new URLSearchParams,Object.keys(o).filter((function(t){return null!==o[t]})).map((function(t){return i.set(t,o[t])})),t.search=i.toString()),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(u),headers:this.headers})).then((function(t){return c(t)}))];case 2:return[4,s.sent().json().catch((function(){}))];case 3:return[2,s.sent()];case 4:return d=s.sent(),l=d.stack,a(d,l,t.toString()),[3,5];case 5:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),v=function(){function t(t){this.httpRequest=new f(t)}return t.prototype.getClientTask=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getClientTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"tasks",[4,this.httpRequest.get("tasks")];case 1:return[2,t.sent()]}}))}))},t.prototype.getIndexTask=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/".concat(t,"/tasks/").concat(e),[4,this.httpRequest.get(n)];case 1:return[2,r.sent()]}}))}))},t.prototype.getIndexTasks=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/".concat(t,"/tasks"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForClientTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;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.getClientTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,p(c)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new d("timeout of ".concat(o,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForClientTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){var e,n,r,i,u;return s(this,(function(s){switch(s.label){case 0:e=[],n=0,r=t,s.label=1;case 1:return n<r.length?(i=r[n],[4,this.waitForClientTask(i,{timeOutMs:o,intervalMs:c})]):[3,4];case 2:u=s.sent(),e.push(u),s.label=3;case 3:return n++,[3,1];case 4:return[2,{results:e}]}}))}))},t.prototype.waitForIndexTask=function(t,e,n){var r=void 0===n?{}:n,o=r.timeOutMs,u=void 0===o?5e3:o,c=r.intervalMs,a=void 0===c?50:c;return i(this,void 0,void 0,(function(){var n,r;return s(this,(function(i){switch(i.label){case 0:n=Date.now(),i.label=1;case 1:return Date.now()-n<u?[4,this.getIndexTask(t,e)]:[3,4];case 2:return r=i.sent(),["enqueued","processing"].includes(r.status)?[4,p(a)]:[2,r];case 3:return i.sent(),[3,1];case 4:throw new d("timeout of ".concat(u,"ms has exceeded on process ").concat(e," when waiting for pending update to resolve."))}}))}))},t}(),y=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new f(t),this.tasks=new v(t)}return t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,l(r({q:t},e)),void 0,n)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var o,u,c,a,d;return i(this,void 0,void 0,(function(){var i,p,f;return s(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/search"),p=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},f=r(r({q:t},e),{filter:p(null==e?void 0:e.filter),sort:null===(o=null==e?void 0:e.sort)||void 0===o?void 0:o.join(","),facetsDistribution:null===(u=null==e?void 0:e.facetsDistribution)||void 0===u?void 0:u.join(","),attributesToRetrieve:null===(c=null==e?void 0:e.attributesToRetrieve)||void 0===c?void 0:c.join(","),attributesToCrop:null===(a=null==e?void 0:e.attributesToCrop)||void 0===a?void 0:a.join(","),attributesToHighlight:null===(d=null==e?void 0:e.attributesToHighlight)||void 0===d?void 0:d.join(",")}),[4,this.httpRequest.get(i,l(f),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(i){return"indexes",[2,new f(n).post("indexes",r(r({},e),{uid:t}))]}))}))},t.prototype.update=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/".concat(this.uid),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getIndexTasks(this.uid)];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getIndexTask(this.uid,t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,r(r({},t),void 0!==n?{attributesToRetrieve:n}:{}))];case 1:return[2,i.sent()]}}))}))},t.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/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,o,u;return s(this,(function(s){switch(s.label){case 0:r=[],i=0,s.label=1;case 1:return i<t.length?(u=(o=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.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/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=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/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=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/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=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/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),b=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new f(t),this.tasks=new v(t)}return t.prototype.index=function(t){return new y(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(){return i(this,void 0,void 0,(function(){var t,e=this;return s(this,(function(n){switch(n.label){case 0:return[4,this.getRawIndexes()];case 1:return t=n.sent(),[2,t.map((function(t){return new y(e.config,t.uid,t.primaryKey)}))]}}))}))},t.prototype.getRawIndexes=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"indexes",[4,this.httpRequest.get("indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,y.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,new y(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new y(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getTasks=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.tasks.getClientTasks()];case 1:return[2,t.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getClientTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,o=void 0===r?5e3:r,u=n.intervalMs,c=void 0===u?50:u;return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForClientTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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.httpRequest.get("keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.getKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"keys",[4,this.httpRequest.post("keys",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateKey=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="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"health",[4,this.httpRequest.get("health")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"stats",[4,this.httpRequest.get("stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.getVersion=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"version",[4,this.httpRequest.get("version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return[2,t.sent()]}}))}))},t.prototype.getDumpStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="dumps/".concat(t,"/status"),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.generateTenantToken=function(t,e){var n=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(n.stack,"."))},t}());t.Index=y,t.MeiliSearch=b,t.MeiliSearchApiError=u,t.MeiliSearchCommunicationError=o,t.MeiliSearchError=h,t.MeiliSearchTimeOutError=d,t.default=b,t.httpErrorHandler=a,t.httpResponseErrorHandler=c,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=meilisearch.umd.min.js.map
export * from './types';
export * from './errors';
export * from './lib';
import { MeiliSearch } from './lib/clients/browser-client';
export * from './indexes';
import { MeiliSearch } from './clients/browser-client';
export { MeiliSearch };
export default MeiliSearch;
//# sourceMappingURL=browser.d.ts.map
/// <reference types="node" />
import { MeiliSearchErrorInterface } from '../types';
import { MeiliSearchErrorInfo } from '../types';
declare const MeiliSearchApiError: {
new (error: MeiliSearchErrorInterface, status: number): {
new (error: MeiliSearchErrorInfo, status: number): {
httpStatus: number;
code?: string | undefined;
link?: string | undefined;
code: string;
link: string;
type: string;
stack?: string | undefined;
type?: string | undefined;
name: string;

@@ -11,0 +11,0 @@ message: string;

import 'cross-fetch/polyfill';
import { FetchError } from '../types';
declare class MeiliSearchCommunicationError extends Error {
type: string;
statusCode?: number;

@@ -6,0 +5,0 @@ errno?: string;

declare class MeiliSearchError extends Error {
type: string;
constructor(message: string);

@@ -4,0 +3,0 @@ }

declare class MeiliSearchTimeOutError extends Error {
type: string;
constructor(message: string);

@@ -4,0 +3,0 @@ }

@@ -1,13 +0,13 @@

// Type definitions for meilisearch 0.26.0-beta.0
// Type definitions for meilisearch 0.26.0
// Project: https://github.com/meilisearch/meilisearch-js
// Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch>
// Definitions: https://github.com/meilisearch/meilisearch-js
// TypeScript Version: 4.6.2
// TypeScript Version: 4.6.4
export * from './types';
export * from './errors';
export * from './lib';
import { MeiliSearch } from './lib/clients/node-client';
export * from './indexes';
import { MeiliSearch } from './clients/node-client';
export { MeiliSearch };
export default MeiliSearch;
//# sourceMappingURL=index.d.ts.map

@@ -44,3 +44,3 @@ export declare type Config = {

};
export declare type SearchParams = Pagination & Highlight & Crop & {
export declare type SearchParams = Query & Pagination & Highlight & Crop & {
filter?: Filter;

@@ -52,3 +52,2 @@ sort?: string[];

};
export declare type SearchRequest = SearchParams & Query;
export declare type SearchRequestGET = Pagination & Query & Omit<Highlight, 'attributesToHighlight'> & Omit<Crop, 'attributesToCrop'> & {

@@ -113,3 +112,3 @@ filter?: string;

enabled?: boolean | null;
disabledOnAttributes?: string[] | null;
disableOnAttributes?: string[] | null;
disableOnWords?: string[] | null;

@@ -143,3 +142,3 @@ minWordSizeForTypos?: {

type: string;
enqueuedTask: string;
enqueuedAt: string;
};

@@ -167,3 +166,3 @@ export declare type Task = {

processedAt: string;
error?: MeiliSearchErrorBody;
error?: MeiliSearchErrorInfo;
};

@@ -215,8 +214,2 @@ export declare type EnqueuedDump = {

};
export interface MeiliSearchErrorInterface extends Error {
code?: string;
link?: string;
stack?: string;
type?: string;
}
export interface FetchError extends Error {

@@ -227,3 +220,3 @@ type: string;

}
export declare type MeiliSearchErrorBody = {
export declare type MeiliSearchErrorInfo = {
code: string;

@@ -230,0 +223,0 @@ link: string;

{
"name": "meilisearch",
"version": "0.26.0-beta.0",
"version": "0.26.0",
"description": "The Meilisearch JS client for Node.js and the browser.",

@@ -75,8 +75,8 @@ "keywords": [

"devDependencies": {
"@babel/preset-env": "^7.16.11",
"@babel/preset-env": "^7.18.2",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "21.0.2",
"@rollup/plugin-commonjs": "22.0.0",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "13.1.3",
"@types/jest": "^27.4.1",
"@rollup/plugin-node-resolve": "13.3.0",
"@types/jest": "^27.5.0",
"@types/prettier": "^2.2.3",

@@ -99,9 +99,10 @@ "@typescript-eslint/eslint-plugin": "2.34.0",

"jest": "^26.6.3",
"jest-fetch-mock": "^3.0.3",
"jest-watch-typeahead": "^0.6.3",
"kleur": "^4.1.4",
"lint-staged": "11.1.2",
"nodemon": "^2.0.15",
"nodemon": "^2.0.16",
"prettier": "^2.2.1",
"pretty-bytes": "^5.6.0",
"rollup": "^2.70.0",
"rollup": "^2.75.5",
"rollup-plugin-terser": "^7.0.0",

@@ -111,4 +112,4 @@ "rollup-plugin-typescript2": "^0.31.2",

"ts-jest": "^26.5.6",
"typescript": "4.6.2"
"typescript": "4.6.4"
}
}

@@ -388,7 +388,7 @@ <p align="center">

`index.updateDocuments(documents: Document<T>[]): Promise<EnqueuedTask>`
`index.updateDocuments(documents: Array<Document<Partial<T>>>): Promise<EnqueuedTask>`
- [Add or update multiple documents in batches](https://docs.meilisearch.com/reference/api/documents.html#add-or-update-documents):
`index.updateDocumentsInBatches(documents: Document<T>[], batchSize = 1000): Promise<EnqueuedTask[]>`
`index.updateDocumentsInBatches(documents: Array<Document<Partial<T>>>, batchSize = 1000): Promise<EnqueuedTask[]>`

@@ -395,0 +395,0 @@ - [Get Documents](https://docs.meilisearch.com/reference/api/documents.html#get-documents):

export * from './types'
export * from './errors'
export * from './lib'
import { MeiliSearch } from './lib/clients/browser-client'
export * from './indexes'
import { MeiliSearch } from './clients/browser-client'
export { MeiliSearch }
export default MeiliSearch

@@ -7,6 +7,9 @@ import { MeiliSearchCommunicationError } from './meilisearch-communication-error'

if (!response.ok) {
let err
let responseBody
try {
err = await response.json()
// If it is not possible to parse the return body it means there is none
// In which case it is a communication error with the Meilisearch instance
responseBody = await response.json()
} catch (e: any) {
// Not sure on how to test this part of the code.
throw new MeiliSearchCommunicationError(

@@ -18,4 +21,7 @@ response.statusText,

}
throw new MeiliSearchApiError(err, response.status)
// If the body is parsable, then it means Meilisearch returned a body with
// information on the error.
throw new MeiliSearchApiError(responseBody, response.status)
}
return response

@@ -29,3 +35,3 @@ }

): Promise<void> {
if (response.type !== 'MeiliSearchApiError') {
if (response.name !== 'MeiliSearchApiError') {
throw new MeiliSearchCommunicationError(

@@ -32,0 +38,0 @@ response.message,

@@ -1,12 +0,16 @@

import { MeiliSearchErrorInterface } from '../types'
import { MeiliSearchErrorInfo } from '../types'
const MeiliSearchApiError = class extends Error {
httpStatus: number
code?: string
link?: string
code: string
link: string
type: string
stack?: string
type?: string
constructor(error: MeiliSearchErrorInterface, status: number) {
constructor(error: MeiliSearchErrorInfo, status: number) {
super(error.message)
// Make errors comparison possible. ex: error instanceof MeiliSearchApiError.
Object.setPrototypeOf(this, MeiliSearchApiError.prototype)
this.name = 'MeiliSearchApiError'

@@ -19,4 +23,2 @@

this.httpStatus = status
// Make errors comparison possible. ex: error instanceof MeiliSearchApiError.
Object.setPrototypeOf(this, MeiliSearchApiError.prototype)

@@ -23,0 +25,0 @@ if (Error.captureStackTrace) {

@@ -5,3 +5,2 @@ import 'cross-fetch/polyfill'

class MeiliSearchCommunicationError extends Error {
type: string
statusCode?: number

@@ -20,4 +19,6 @@ errno?: string

// Make errors comparison possible. ex: error instanceof MeiliSearchCommunicationError.
Object.setPrototypeOf(this, MeiliSearchCommunicationError.prototype)
this.name = 'MeiliSearchCommunicationError'
this.type = 'MeiliSearchCommunicationError'

@@ -24,0 +25,0 @@ if (body instanceof Response) {

class MeiliSearchError extends Error {
type: string
constructor(message: string) {
super(message)
// Make errors comparison possible. ex: error instanceof MeiliSearchError.
Object.setPrototypeOf(this, MeiliSearchError.prototype)
this.name = 'MeiliSearchError'
this.type = 'MeiliSearchError'

@@ -8,0 +10,0 @@ if (Error.captureStackTrace) {

class MeiliSearchTimeOutError extends Error {
type: string
constructor(message: string) {
super(message)
// Make errors comparison possible. ex: error instanceof MeiliSearchTimeOutError.
Object.setPrototypeOf(this, MeiliSearchTimeOutError.prototype)
this.name = 'MeiliSearchTimeOutError'
this.type = this.constructor.name

@@ -8,0 +10,0 @@ if (Error.captureStackTrace) {

export * from './types'
export * from './errors'
export * from './lib'
import { MeiliSearch } from './lib/clients/node-client'
export * from './indexes'
import { MeiliSearch } from './clients/node-client'
export { MeiliSearch }
export default MeiliSearch

@@ -69,3 +69,4 @@ // Type definitions for meilisearch

export type SearchParams = Pagination &
export type SearchParams = Query &
Pagination &
Highlight &

@@ -80,4 +81,2 @@ Crop & {

export type SearchRequest = SearchParams & Query
// Search parameters for searches made with the GET method

@@ -166,3 +165,3 @@ // Are different than the parameters for the POST method

enabled?: boolean | null
disabledOnAttributes?: string[] | null
disableOnAttributes?: string[] | null
disableOnWords?: string[] | null

@@ -203,3 +202,3 @@ minWordSizeForTypos?: {

type: string
enqueuedTask: string
enqueuedAt: string
}

@@ -251,3 +250,3 @@

processedAt: string
error?: MeiliSearchErrorBody
error?: MeiliSearchErrorInfo
}

@@ -327,9 +326,2 @@

export interface MeiliSearchErrorInterface extends Error {
code?: string
link?: string
stack?: string
type?: string
}
export interface FetchError extends Error {

@@ -341,3 +333,3 @@ type: string

export type MeiliSearchErrorBody = {
export type MeiliSearchErrorInfo = {
code: string

@@ -344,0 +336,0 @@ link: string

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc