meilisearch
Advanced tools
Comparing version 0.26.0 to 0.27.0-beta.0
@@ -118,4 +118,5 @@ # Contributing | ||
Make a PR modifying the file [`package.json`](/package.json) with the right version. | ||
Make a PR modifying the following files with the right version: | ||
[`package.json`](/package.json): | ||
```javascript | ||
@@ -125,2 +126,7 @@ "version": "X.X.X", | ||
[`src/package-version`](/src/package-version.ts) | ||
```javascript | ||
export const PACKAGE_VERSION = 'X.X.X' | ||
``` | ||
Once the changes are merged on `main`, you can publish the current draft release via the [GitHub interface](https://github.com/meilisearch/meilisearch-js/releases): on this page, click on `Edit` (related to the draft release) > update the description (be sure you apply [these recommandations](https://github.com/meilisearch/integration-guides/blob/main/resources/integration-release.md#writting-the-release-description)) > when you are ready, click on `Publish release`. | ||
@@ -127,0 +133,0 @@ |
@@ -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,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}; | ||
***************************************************************************** */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 i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((i=i.apply(t,e||[])).next())}))}function s(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var o=function(t){function e(n,i,r,s){var o,u,c,a=this;return(a=t.call(this,n)||this).name="MeiliSearchCommunicationError",i instanceof Response&&(a.message=i.statusText,a.statusCode=i.status),i instanceof Error&&(a.errno=i.errno,a.code=i.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(r," failed, reason: connect ECONNREFUSED")),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Not Found","Not Found: ".concat(r))):Error.captureStackTrace&&Error.captureStackTrace(a,e),a}return n(e,t),e}(Error),u=function(t){function e(e,n){var i=t.call(this,e.message)||this;return i.name="MeiliSearchApiError",i.code=e.code,i.type=e.type,i.link=e.link,i.message=e.message,i.httpStatus=n,Object.setPrototypeOf(i,u.prototype),Error.captureStackTrace&&Error.captureStackTrace(i,u),i}return n(e,t),e}(Error);function c(t){return r(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 i=t.call(this,n)||this;return i.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return n(e,t),e}(Error),d=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return n(e,t),e}(Error);function l(t){return Object.entries(t).reduce((function(t,e){var n=e[0],i=e[1];return void 0!==i&&(t[n]=i),t}),{})}function f(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var p=function(){function t(t){this.headers=function(t){var e="Meilisearch JavaScript (v".concat("0.27.0-beta.0",")");t.headers=t.headers||{};var n=Object.assign({},t.headers);if(t.apiKey&&(n.Authorization="Bearer ".concat(t.apiKey)),t.headers["Content-Type"]||(n["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var i=t.clientAgents.concat(e);n["X-Meilisearch-Client"]=i.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new h('Meilisearch: The header "'.concat("X-Meilisearch-Client",'" should be an array of string(s).\n'));n["X-Meilisearch-Client"]=e}return n}(t);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 r(this,void 0,void 0,(function(){var t,r,d,l;return s(this,(function(s){switch(s.label){case 0:t=new URL(n,this.url),o&&(r=new URLSearchParams,Object.keys(o).filter((function(t){return null!==o[t]})).map((function(t){return r.set(t,o[t])})),t.search=r.toString()),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(t.toString(),i(i({},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 r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,i.sent()]}}))}))},t.prototype.post=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.put=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.patch=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.delete=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t}(),v=function(){function t(t){this.httpRequest=new p(t)}return t.prototype.getTask=function(t){return r(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.getTasks=function(t){var e,n,i;return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var r;return s(this,(function(s){switch(s.label){case 0:return"tasks",r={indexUid:null===(e=null==t?void 0:t.indexUid)||void 0===e?void 0:e.join(","),type:null===(n=null==t?void 0:t.type)||void 0===n?void 0:n.join(","),status:null===(i=null==t?void 0:t.status)||void 0===i?void 0:i.join(","),from:t.from,limit:t.limit},[4,this.httpRequest.get("tasks",l(r))];case 1:return[2,s.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<o?[4,this.getTask(t)]:[3,4];case 2:return n=i.sent(),["enqueued","processing"].includes(n.status)?[4,f(c)]:[2,n];case 3:return i.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.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){var e,n,i,r,u;return s(this,(function(s){switch(s.label){case 0:e=[],n=0,i=t,s.label=1;case 1:return n<i.length?(r=i[n],[4,this.waitForTask(r,{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,e]}}))}))},t}(),y=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new p(t),this.tasks=new v(t)}return t.prototype.search=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(r,l(i({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 r(this,void 0,void 0,(function(){var r,f,p;return s(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/search"),f=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")},p=i(i({q:t},e),{filter:f(null==e?void 0:e.filter),sort:null===(o=null==e?void 0:e.sort)||void 0===o?void 0:o.join(","),facets:null===(u=null==e?void 0:e.facets)||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(r,l(p),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return r(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 r(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 r(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={}),r(this,void 0,void 0,(function(){return s(this,(function(r){return"indexes",[2,new p(n).post("indexes",i(i({},e),{uid:t}))]}))}))},t.prototype.update=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return r(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(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(i(i({},t),{indexUid:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/documents"),n=function(){var e;if(Array.isArray(null==t?void 0:t.fields))return null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}(),[4,this.httpRequest.get(e,l(i(i({},t),{fields:n})))];case 1:return[2,r.sent()]}}))}))},t.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),r(this,void 0,void 0,(function(){var i,r,o,u;return s(this,(function(s){switch(s.label){case 0:i=[],r=0,s.label=1;case 1:return r<t.length?(u=(o=i).push,[4,this.addDocuments(t.slice(r,r+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return r+=e,[3,1];case 4:return[2,i]}}))}))},t.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),r(this,void 0,void 0,(function(){var i,r,o,u;return s(this,(function(s){switch(s.label){case 0:i=[],r=0,s.label=1;case 1:return r<t.length?(u=(o=i).push,[4,this.updateDocuments(t.slice(r,r+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return r+=e,[3,1];case 4:return[2,i]}}))}))},t.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteAllDocuments=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return r(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 r(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.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return r(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 r(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 r(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.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return r(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 r(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 r(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.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return r(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 r(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.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return r(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 p(t),this.tasks=new v(t)}return t.prototype.index=function(t){return new y(this.config,t)},t.prototype.getIndex=function(t){return r(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 r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e,n,r=this;return s(this,(function(s){switch(s.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=s.sent(),n=e.results.map((function(t){return new y(r.config,t.uid,t.primaryKey)})),[2,i(i({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"indexes",[4,this.httpRequest.get("indexes",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(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={}),r(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 r(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 r(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(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"keys",[4,this.httpRequest.get("keys",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getKey=function(t){return r(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 r(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.deleteKey=function(t){return r(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 r(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 r(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 r(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 r(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 r(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.generateTenantToken=function(t,e,n){var i=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(i.stack,"."))},t}();function w(t){return Buffer.from(JSON.stringify(t)).toString("base64")}var g=function(){function e(t){this.config=t}return e.prototype.generateTenantToken=function(e,n,i){var r=(null==i?void 0:i.apiKey)||this.config.apiKey||"",s=e||"",o=null==i?void 0:i.expiresAt;!function(t){var e=t.searchRules,n=t.uid,i=t.apiKey,r=t.expiresAt;if(r){if(!(r instanceof Date))throw new h("Meilisearch: The expiredAt field must be an instance of Date.");if(r.getTime()<Date.now())throw new h("Meilisearch: The expiresAt field must be a date in the future.")}if(e&&"object"!=typeof e&&!Array.isArray(e))throw new h("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!i||"string"!=typeof i)throw new h("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!n||"string"!=typeof n)throw new h("Meilisearch: The uid of the api key used for the token generation must exist, be of type string and comply to the uuid4 format.");if(!/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(n))throw new h("Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().")}({apiKey:r,uid:s,expiresAt:o,searchRules:n});var u=w({alg:"HS256",typ:"JWT"}).replace(/=/g,""),c=function(t){var e=t.searchRules,n=t.uid,i=t.expiresAt;return w({searchRules:e,apiKeyUid:n,exp:null==i?void 0:i.getTime()}).replace(/=/g,"")}({searchRules:n,uid:s,expiresAt:o}),a=function(e,n,i){return t.createHmac("sha256",e).update("".concat(n,".").concat(i)).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(r,u,c);return"".concat(u,".").concat(c,".").concat(a)},e}(),m=function(t){function e(e){var n=t.call(this,e)||this;return n.tokens=new g(e),n}return n(e,t),e.prototype.generateTenantToken=function(e,n,i){return"undefined"==typeof window?this.tokens.generateTenantToken(e,n,i):t.prototype.generateTenantToken.call(this,e,n,i)},e}(b);export{y as Index,m as MeiliSearch,u as MeiliSearchApiError,o as MeiliSearchCommunicationError,h as MeiliSearchError,d as MeiliSearchTimeOutError,m 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,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})})); | ||
***************************************************************************** */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 i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((i=i.apply(t,e||[])).next())}))}function s(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var o=function(t){function e(n,i,r,s){var o,u,c,a=this;return(a=t.call(this,n)||this).name="MeiliSearchCommunicationError",i instanceof Response&&(a.message=i.statusText,a.statusCode=i.status),i instanceof Error&&(a.errno=i.errno,a.code=i.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(r," failed, reason: connect ECONNREFUSED")),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Not Found","Not Found: ".concat(r))):Error.captureStackTrace&&Error.captureStackTrace(a,e),a}return n(e,t),e}(Error),u=function(t){function e(e,n){var i=t.call(this,e.message)||this;return i.name="MeiliSearchApiError",i.code=e.code,i.type=e.type,i.link=e.link,i.message=e.message,i.httpStatus=n,Object.setPrototypeOf(i,u.prototype),Error.captureStackTrace&&Error.captureStackTrace(i,u),i}return n(e,t),e}(Error);function c(t){return r(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 i=t.call(this,n)||this;return i.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return n(e,t),e}(Error),d=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return n(e,t),e}(Error);function l(t){return Object.entries(t).reduce((function(t,e){var n=e[0],i=e[1];return void 0!==i&&(t[n]=i),t}),{})}function f(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var p=function(){function t(t){this.headers=function(t){var e="Meilisearch JavaScript (v".concat("0.27.0-beta.0",")");t.headers=t.headers||{};var n=Object.assign({},t.headers);if(t.apiKey&&(n.Authorization="Bearer ".concat(t.apiKey)),t.headers["Content-Type"]||(n["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var i=t.clientAgents.concat(e);n["X-Meilisearch-Client"]=i.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new h('Meilisearch: The header "'.concat("X-Meilisearch-Client",'" should be an array of string(s).\n'));n["X-Meilisearch-Client"]=e}return n}(t);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 r(this,void 0,void 0,(function(){var t,r,d,l;return s(this,(function(s){switch(s.label){case 0:t=new URL(n,this.url),o&&(r=new URLSearchParams,Object.keys(o).filter((function(t){return null!==o[t]})).map((function(t){return r.set(t,o[t])})),t.search=r.toString()),s.label=1;case 1:return s.trys.push([1,4,,5]),[4,fetch(t.toString(),i(i({},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 r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,i.sent()]}}))}))},t.prototype.post=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.put=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.patch=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.delete=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t}(),v=function(){function t(t){this.httpRequest=new p(t)}return t.prototype.getTask=function(t){return r(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.getTasks=function(t){var e,n,i;return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var r;return s(this,(function(s){switch(s.label){case 0:return"tasks",r={indexUid:null===(e=null==t?void 0:t.indexUid)||void 0===e?void 0:e.join(","),type:null===(n=null==t?void 0:t.type)||void 0===n?void 0:n.join(","),status:null===(i=null==t?void 0:t.status)||void 0===i?void 0:i.join(","),from:t.from,limit:t.limit},[4,this.httpRequest.get("tasks",l(r))];case 1:return[2,s.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<o?[4,this.getTask(t)]:[3,4];case 2:return n=i.sent(),["enqueued","processing"].includes(n.status)?[4,f(c)]:[2,n];case 3:return i.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.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){var e,n,i,r,u;return s(this,(function(s){switch(s.label){case 0:e=[],n=0,i=t,s.label=1;case 1:return n<i.length?(r=i[n],[4,this.waitForTask(r,{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,e]}}))}))},t}(),y=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new p(t),this.tasks=new v(t)}return t.prototype.search=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(r,l(i({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 r(this,void 0,void 0,(function(){var r,f,p;return s(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/search"),f=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")},p=i(i({q:t},e),{filter:f(null==e?void 0:e.filter),sort:null===(o=null==e?void 0:e.sort)||void 0===o?void 0:o.join(","),facets:null===(u=null==e?void 0:e.facets)||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(r,l(p),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return r(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 r(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 r(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={}),r(this,void 0,void 0,(function(){return s(this,(function(r){return"indexes",[2,new p(n).post("indexes",i(i({},e),{uid:t}))]}))}))},t.prototype.update=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return r(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(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(i(i({},t),{indexUid:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return e="indexes/".concat(this.uid,"/documents"),n=function(){var e;if(Array.isArray(null==t?void 0:t.fields))return null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}(),[4,this.httpRequest.get(e,l(i(i({},t),{fields:n})))];case 1:return[2,r.sent()]}}))}))},t.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),r(this,void 0,void 0,(function(){var i,r,o,u;return s(this,(function(s){switch(s.label){case 0:i=[],r=0,s.label=1;case 1:return r<t.length?(u=(o=i).push,[4,this.addDocuments(t.slice(r,r+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return r+=e,[3,1];case 4:return[2,i]}}))}))},t.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),r(this,void 0,void 0,(function(){var i,r,o,u;return s(this,(function(s){switch(s.label){case 0:i=[],r=0,s.label=1;case 1:return r<t.length?(u=(o=i).push,[4,this.updateDocuments(t.slice(r,r+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return r+=e,[3,1];case 4:return[2,i]}}))}))},t.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteAllDocuments=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return r(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 r(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.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return r(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 r(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 r(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.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return r(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 r(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 r(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.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return r(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 r(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.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return r(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 p(t),this.tasks=new v(t)}return t.prototype.index=function(t){return new y(this.config,t)},t.prototype.getIndex=function(t){return r(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 r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new y(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e,n,r=this;return s(this,(function(s){switch(s.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=s.sent(),n=e.results.map((function(t){return new y(r.config,t.uid,t.primaryKey)})),[2,i(i({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"indexes",[4,this.httpRequest.get("indexes",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(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={}),r(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 r(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 r(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(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"keys",[4,this.httpRequest.get("keys",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getKey=function(t){return r(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 r(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 r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.deleteKey=function(t){return r(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 r(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 r(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 r(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 r(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 r(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.generateTenantToken=function(t,e,n){var i=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(i.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 |
import { Index } from '../indexes'; | ||
import { KeyPayload, Config, IndexOptions, IndexResponse, EnqueuedTask, Key, Health, Stats, Version, EnqueuedDump, Task, Result, TokenSearchRules, TokenOptions } from '../types'; | ||
import { KeyCreation, Config, IndexOptions, IndexObject, EnqueuedTask, Key, Health, Stats, Version, Task, TokenSearchRules, TokenOptions, TasksQuery, WaitOptions, KeyUpdate, IndexesQuery, IndexesResults, KeysQuery, KeysResults, TasksResults } from '../types'; | ||
import { HttpRequests } from '../http-requests'; | ||
@@ -39,5 +39,5 @@ import { TaskClient } from '../task'; | ||
* @param {string} indexUid The index UID | ||
* @returns {Promise<IndexResponse>} Promise returning index information | ||
* @returns {Promise<IndexObject>} Promise returning index information | ||
*/ | ||
getRawIndex(indexUid: string): Promise<IndexResponse>; | ||
getRawIndex(indexUid: string): Promise<IndexObject>; | ||
/** | ||
@@ -47,5 +47,7 @@ * Get all the indexes as Index instances. | ||
* @method getIndexes | ||
* @returns {Promise<Index[]>} Promise returning array of raw index information | ||
* @param {IndexesQuery} [parameters={}] - Parameters to browse the indexes | ||
* | ||
* @returns {Promise<IndexesResults<Index[]>>} Promise returning array of raw index information | ||
*/ | ||
getIndexes(): Promise<Index[]>; | ||
getIndexes(parameters?: IndexesQuery): Promise<IndexesResults<Index[]>>; | ||
/** | ||
@@ -55,5 +57,7 @@ * Get all the indexes in their raw value (no Index instances). | ||
* @method getRawIndexes | ||
* @returns {Promise<IndexResponse[]>} Promise returning array of raw index information | ||
* @param {IndexesQuery} [parameters={}] - Parameters to browse the indexes | ||
* | ||
* @returns {Promise<IndexesResults<IndexObject[]>>} Promise returning array of raw index information | ||
*/ | ||
getRawIndexes(): Promise<IndexResponse[]>; | ||
getRawIndexes(parameters?: IndexesQuery): Promise<IndexesResults<IndexObject[]>>; | ||
/** | ||
@@ -99,5 +103,7 @@ * Create a new index | ||
* @method getTasks | ||
* @returns {Promise<Result<Task[]>>} - Promise returning all tasks | ||
* @param {TasksQuery} [parameters={}] - Parameters to browse the tasks | ||
* | ||
* @returns {Promise<TasksResults>} - Promise returning all tasks | ||
*/ | ||
getTasks(): Promise<Result<Task[]>>; | ||
getTasks(parameters?: TasksQuery): Promise<TasksResults>; | ||
/** | ||
@@ -107,25 +113,24 @@ * Get one task on the client scope | ||
* @method getTask | ||
* @param {number} taskId - Task identifier | ||
* @param {number} taskUid - Task identifier | ||
* @returns {Promise<Task>} - Promise returning a task | ||
*/ | ||
getTask(taskId: number): Promise<Task>; | ||
getTask(taskUid: number): Promise<Task>; | ||
/** | ||
* Wait for a batch of tasks to be processed. | ||
* Wait for multiple tasks to be finished. | ||
* | ||
* @memberof MeiliSearch | ||
* @method waitForTasks | ||
* @param {number[]} taskIds - Tasks identifier | ||
* @param {number[]} taskUids - Tasks identifier | ||
* @param {WaitOptions} waitOptions - Options on timeout and interval | ||
* | ||
* @returns {Promise<Result<Task[]>>} - Promise returning an array of tasks | ||
* @returns {Promise<Task[]>} - Promise returning an array of tasks | ||
*/ | ||
waitForTasks(taskIds: number[], { timeOutMs, intervalMs, }?: { | ||
timeOutMs?: number; | ||
intervalMs?: number; | ||
}): Promise<Result<Task[]>>; | ||
waitForTasks(taskUids: number[], { timeOutMs, intervalMs }?: WaitOptions): Promise<Task[]>; | ||
/** | ||
* Wait for a task to be processed. | ||
* Wait for a task to be finished. | ||
* | ||
* @memberof MeiliSearch | ||
* @method waitForTask | ||
* @param {number} taskId - Task identifier | ||
* | ||
* @param {number} taskUid - Task identifier | ||
* @param {WaitOptions} waitOptions - Options on timeout and interval | ||
@@ -135,6 +140,3 @@ * | ||
*/ | ||
waitForTask(taskId: number, { timeOutMs, intervalMs, }?: { | ||
timeOutMs?: number; | ||
intervalMs?: number; | ||
}): Promise<Task>; | ||
waitForTask(taskUid: number, { timeOutMs, intervalMs }?: WaitOptions): Promise<Task>; | ||
/** | ||
@@ -144,5 +146,7 @@ * Get all API keys | ||
* @method getKeys | ||
* @returns {Promise<Keys>} Promise returning an object with keys | ||
* @param {KeysQuery} [parameters={}] - Parameters to browse the indexes | ||
* | ||
* @returns {Promise<KeysResults>} Promise returning an object with keys | ||
*/ | ||
getKeys(): Promise<Result<Key[]>>; | ||
getKeys(parameters?: KeysQuery): Promise<KeysResults>; | ||
/** | ||
@@ -153,6 +157,6 @@ * Get one API key | ||
* | ||
* @param {string} key - Key | ||
* @param {string} keyOrUid - Key or uid of the API key | ||
* @returns {Promise<Keys>} Promise returning a key | ||
*/ | ||
getKey(key: string): Promise<Key>; | ||
getKey(keyOrUid: string): Promise<Key>; | ||
/** | ||
@@ -163,6 +167,6 @@ * Create one API key | ||
* | ||
* @param {KeyPayload} options - Key options | ||
* @param {KeyCreation} options - Key options | ||
* @returns {Promise<Key>} Promise returning an object with keys | ||
*/ | ||
createKey(options: KeyPayload): Promise<Key>; | ||
createKey(options: KeyCreation): Promise<Key>; | ||
/** | ||
@@ -174,6 +178,6 @@ * Update one API key | ||
* @param {string} key - Key | ||
* @param {KeyPayload} options - Key options | ||
* @param {KeyUpdate} options - Key options | ||
* @returns {Promise<Key>} Promise returning an object with keys | ||
*/ | ||
updateKey(key: string, options: KeyPayload): Promise<Key>; | ||
updateKey(key: string, options: KeyUpdate): Promise<Key>; | ||
/** | ||
@@ -217,17 +221,9 @@ * Delete one API key | ||
/** | ||
* Triggers a dump creation process | ||
* Creates a dump | ||
* @memberof MeiliSearch | ||
* @method createDump | ||
* @returns {Promise<EnqueuedDump>} Promise returning object of the enqueued task | ||
* @returns {Promise<EnqueuedTask>} Promise returning object of the enqueued task | ||
*/ | ||
createDump(): Promise<EnqueuedDump>; | ||
createDump(): Promise<EnqueuedTask>; | ||
/** | ||
* Get the status of a dump creation process | ||
* @memberof MeiliSearch | ||
* @method getDumpStatus | ||
* @param {string} dumpUid Dump UID | ||
* @returns {Promise<EnqueuedDump>} Promise returning object of the enqueued task | ||
*/ | ||
getDumpStatus(dumpUid: string): Promise<EnqueuedDump>; | ||
/** | ||
* Generate a tenant token | ||
@@ -237,9 +233,11 @@ * | ||
* @method generateTenantToken | ||
* @param {apiKeyUid} apiKeyUid The uid of the api key used as issuer of the token. | ||
* @param {SearchRules} searchRules Search rules that are applied to every search. | ||
* @param {TokenOptions} options Token options to customize some aspect of the token. | ||
* | ||
* @returns {String} The token in JWT format. | ||
*/ | ||
generateTenantToken(_searchRules: TokenSearchRules, _options?: TokenOptions): string; | ||
generateTenantToken(_apiKeyUid: string, _searchRules: TokenSearchRules, _options?: TokenOptions): string; | ||
} | ||
export { Client }; | ||
//# sourceMappingURL=client.d.ts.map |
@@ -12,9 +12,11 @@ import { Client } from './client'; | ||
* @method generateTenantToken | ||
* @param {apiKeyUid} apiKeyUid The uid of the api key used as issuer of the token. | ||
* @param {SearchRules} searchRules Search rules that are applied to every search. | ||
* @param {TokenOptions} options Token options to customize some aspect of the token. | ||
* | ||
* @returns {String} The token in JWT format. | ||
*/ | ||
generateTenantToken(searchRules: TokenSearchRules, options?: TokenOptions): string; | ||
generateTenantToken(apiKeyUid: string, searchRules: TokenSearchRules, options?: TokenOptions): string; | ||
} | ||
export { MeiliSearch }; | ||
//# sourceMappingURL=node-client.d.ts.map |
@@ -1,2 +0,2 @@ | ||
// Type definitions for meilisearch 0.26.0 | ||
// Type definitions for meilisearch 0.27.0-beta.0 | ||
// Project: https://github.com/meilisearch/meilisearch-js | ||
@@ -3,0 +3,0 @@ // Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch> |
@@ -1,2 +0,2 @@ | ||
import { Config, Task, SearchResponse, SearchParams, IndexResponse, IndexOptions, IndexStats, GetDocumentsParams, GetDocumentsResponse, Document, AddDocumentParams, EnqueuedTask, Settings, Synonyms, StopWords, RankingRules, DistinctAttribute, FilterableAttributes, SortableAttributes, SearchableAttributes, DisplayedAttributes, TypoTolerance, Result } from './types'; | ||
import { Config, Task, SearchResponse, SearchParams, IndexObject, IndexOptions, IndexStats, DocumentsQuery, Document, DocumentOptions, EnqueuedTask, Settings, Synonyms, StopWords, RankingRules, DistinctAttribute, FilterableAttributes, SortableAttributes, SearchableAttributes, DisplayedAttributes, TypoTolerance, WaitOptions, DocumentsResults, TasksQuery, TasksResults } from './types'; | ||
import { HttpRequests } from './http-requests'; | ||
@@ -43,5 +43,6 @@ import { TaskClient } from './task'; | ||
* @method getRawInfo | ||
* @returns {Promise<IndexResponse>} Promise containing index information | ||
* | ||
* @returns {Promise<IndexObject>} Promise containing index information | ||
*/ | ||
getRawInfo(): Promise<IndexResponse>; | ||
getRawInfo(): Promise<IndexObject>; | ||
/** | ||
@@ -88,10 +89,11 @@ * Fetch and update Index information. | ||
/** | ||
* Get the list of all the index tasks. | ||
* Get the list of all the tasks of the index. | ||
* | ||
* @memberof Indexes | ||
* @method getTasks | ||
* @param {TasksQuery} [parameters={}] - Parameters to browse the tasks | ||
* | ||
* @returns {Promise<Result<Task[]>>} - Promise containing all tasks | ||
* @returns {Promise<TasksResults>} - Promise containing all tasks | ||
*/ | ||
getTasks(): Promise<Result<Task[]>>; | ||
getTasks(parameters?: TasksQuery): Promise<TasksResults>; | ||
/** | ||
@@ -102,27 +104,24 @@ * Get one task of the index. | ||
* @method getTask | ||
* @param {number} taskId - Task identifier | ||
* @param {number} taskUid - Task identifier | ||
* | ||
* @returns {Promise<Task>} - Promise containing a task | ||
*/ | ||
getTask(taskId: number): Promise<Task>; | ||
getTask(taskUid: number): Promise<Task>; | ||
/** | ||
* Wait for a batch of an index tasks to be processed. | ||
* Wait for multiple tasks to be processed. | ||
* | ||
* @memberof Indexes | ||
* @method waitForTasks | ||
* @param {number[]} taskIds - Tasks identifier | ||
* @param {number[]} taskUids - Tasks identifier | ||
* @param {WaitOptions} waitOptions - Options on timeout and interval | ||
* | ||
* @returns {Promise<Result<Task[]>>} - Promise containing an array of tasks | ||
* @returns {Promise<Task[]>} - Promise containing an array of tasks | ||
*/ | ||
waitForTasks(taskIds: number[], { timeOutMs, intervalMs, }?: { | ||
timeOutMs?: number; | ||
intervalMs?: number; | ||
}): Promise<Result<Task[]>>; | ||
waitForTasks(taskUids: number[], { timeOutMs, intervalMs }?: WaitOptions): Promise<Task[]>; | ||
/** | ||
* Wait for an index task to be processed. | ||
* Wait for a task to be processed. | ||
* | ||
* @memberof Indexes | ||
* @method waitForTask | ||
* @param {number} taskId - Task identifier | ||
* @param {number} taskUid - Task identifier | ||
* @param {WaitOptions} waitOptions - Options on timeout and interval | ||
@@ -132,6 +131,3 @@ * | ||
*/ | ||
waitForTask(taskId: number, { timeOutMs, intervalMs, }?: { | ||
timeOutMs?: number; | ||
intervalMs?: number; | ||
}): Promise<Task>; | ||
waitForTask(taskUid: number, { timeOutMs, intervalMs }?: WaitOptions): Promise<Task>; | ||
/** | ||
@@ -149,6 +145,6 @@ * get stats of an index | ||
* @template T | ||
* @param {GetDocumentsParams<T>} options? Options to browse the documents | ||
* @returns {Promise<GetDocumentsResponse<T>>} Promise containing Document responses | ||
* @param {DocumentsQuery<T>} [parameters={}] Parameters to browse the documents | ||
* @returns {Promise<DocumentsResults<T>>>} Promise containing Document responses | ||
*/ | ||
getDocuments<T = Record<string, any>>(options?: GetDocumentsParams<T>): Promise<GetDocumentsResponse<T>>; | ||
getDocuments<T = Record<string, any>>(parameters?: DocumentsQuery<T>): Promise<DocumentsResults<T>>; | ||
/** | ||
@@ -169,6 +165,7 @@ * Get one document | ||
* @param {Array<Document<T>>} documents Array of Document objects to add/replace | ||
* @param {AddDocumentParams} options? Query parameters | ||
* @param {DocumentOptions} options? Options on document addition | ||
* | ||
* @returns {Promise<EnqueuedTask>} Promise containing object of the enqueued task | ||
*/ | ||
addDocuments(documents: Array<Document<T>>, options?: AddDocumentParams): Promise<EnqueuedTask>; | ||
addDocuments(documents: Array<Document<T>>, options?: DocumentOptions): Promise<EnqueuedTask>; | ||
/** | ||
@@ -181,6 +178,6 @@ * Add or replace multiples documents to an index in batches | ||
* @param {number} batchSize Size of the batch | ||
* @param {AddDocumentParams} options? Query parameters | ||
* @param {DocumentOptions} options? Options on document addition | ||
* @returns {Promise<EnqueuedTasks>} Promise containing array of enqueued task objects for each batch | ||
*/ | ||
addDocumentsInBatches(documents: Array<Document<T>>, batchSize?: number, options?: AddDocumentParams): Promise<EnqueuedTask[]>; | ||
addDocumentsInBatches(documents: Array<Document<T>>, batchSize?: number, options?: DocumentOptions): Promise<EnqueuedTask[]>; | ||
/** | ||
@@ -191,6 +188,6 @@ * Add or update multiples documents to an index | ||
* @param {Array<Document<Partial<T>>>} documents Array of Document objects to add/update | ||
* @param {AddDocumentParams} options? Query parameters | ||
* @param {DocumentOptions} options? Options on document update | ||
* @returns {Promise<EnqueuedTask>} Promise containing object of the enqueued task | ||
*/ | ||
updateDocuments(documents: Array<Document<Partial<T>>>, options?: AddDocumentParams): Promise<EnqueuedTask>; | ||
updateDocuments(documents: Array<Document<Partial<T>>>, options?: DocumentOptions): Promise<EnqueuedTask>; | ||
/** | ||
@@ -203,6 +200,6 @@ * Add or update multiples documents to an index in batches | ||
* @param {number} batchSize Size of the batch | ||
* @param {AddDocumentParams} options? Query parameters | ||
* @param {DocumentOptions} options? Options on document update | ||
* @returns {Promise<EnqueuedTasks>} Promise containing array of enqueued task objects for each batch | ||
*/ | ||
updateDocumentsInBatches(documents: Array<Document<Partial<T>>>, batchSize?: number, options?: AddDocumentParams): Promise<EnqueuedTask[]>; | ||
updateDocumentsInBatches(documents: Array<Document<Partial<T>>>, batchSize?: number, options?: DocumentOptions): Promise<EnqueuedTask[]>; | ||
/** | ||
@@ -209,0 +206,0 @@ * Delete one document |
@@ -1,2 +0,2 @@ | ||
import { Config, Task, WaitOptions, Result } from './types'; | ||
import { Config, Task, WaitOptions, TasksQuery, TasksResults } from './types'; | ||
import { HttpRequests } from './http-requests'; | ||
@@ -6,32 +6,38 @@ declare class TaskClient { | ||
constructor(config: Config); | ||
getClientTask(uid: string | number): Promise<Task>; | ||
getClientTasks(): Promise<Result<Task[]>>; | ||
getIndexTask(indexUid: string | number, taskId: number): Promise<Task>; | ||
getIndexTasks(indexUid: string | number): Promise<Result<Task[]>>; | ||
/** | ||
* Get one task | ||
* | ||
* @param {number} uid - unique identifier of the task | ||
* | ||
* @returns { Promise<Task> } | ||
*/ | ||
getTask(uid: number): Promise<Task>; | ||
/** | ||
* Get tasks | ||
* | ||
* @param {TasksQuery} [parameters={}] - Parameters to browse the tasks | ||
* | ||
* @returns {Promise<TasksResults>} - Promise containing all tasks | ||
*/ | ||
getTasks(parameters?: TasksQuery): Promise<TasksResults>; | ||
/** | ||
* Wait for a task to be processed. | ||
* | ||
* @param {number} uid Task identifier | ||
* @param {number} taskUid Task identifier | ||
* @param {WaitOptions} options Additional configuration options | ||
* | ||
* @returns {Promise<Task>} Promise returning a task after it has been processed | ||
*/ | ||
waitForClientTask(taskId: number, { timeOutMs, intervalMs }?: WaitOptions): Promise<Task>; | ||
waitForTask(taskUid: number, { timeOutMs, intervalMs }?: WaitOptions): Promise<Task>; | ||
/** | ||
* Waits for multiple tasks to be processed | ||
* | ||
* @param {number} taskIds Tasks identifier list | ||
* @param {number[]} taskUids Tasks identifier list | ||
* @param {WaitOptions} options Wait options | ||
* @returns {Promise<Result<Task[]>>} Promise returning a list of tasks after they have been processed | ||
*/ | ||
waitForClientTasks(taskIds: number[], { timeOutMs, intervalMs }?: WaitOptions): Promise<Result<Task[]>>; | ||
/** | ||
* Waits for a task to be processed | ||
* | ||
* @param {number} taskId Task identifier | ||
* @param {WaitOptions} options Wait options | ||
* @returns {Promise<Task>} Promise returning a task after it has been processed | ||
* @returns {Promise<Task[]>} Promise returning a list of tasks after they have been processed | ||
*/ | ||
waitForIndexTask(indexUid: number | string, taskId: number, { timeOutMs, intervalMs }?: WaitOptions): Promise<Task>; | ||
waitForTasks(taskUids: number[], { timeOutMs, intervalMs }?: WaitOptions): Promise<Task[]>; | ||
} | ||
export { TaskClient }; | ||
//# sourceMappingURL=task.d.ts.map |
@@ -10,9 +10,11 @@ import { Config, TokenSearchRules, TokenOptions } from './types'; | ||
* @method generateTenantToken | ||
* @param {apiKeyUid} apiKeyUid The uid of the api key used as issuer of the token. | ||
* @param {SearchRules} searchRules Search rules that are applied to every search. | ||
* @param {TokenOptions} options Token options to customize some aspect of the token. | ||
* | ||
* @returns {String} The token in JWT format. | ||
*/ | ||
generateTenantToken(searchRules: TokenSearchRules, options?: TokenOptions): string; | ||
generateTenantToken(apiKeyUid: string, searchRules: TokenSearchRules, options?: TokenOptions): string; | ||
} | ||
export { Token }; | ||
//# sourceMappingURL=token.d.ts.map |
export declare type Config = { | ||
host: string; | ||
apiKey?: string; | ||
headers?: object; | ||
clientAgents?: string[]; | ||
headers?: Record<string, any>; | ||
}; | ||
export declare type Result<T> = { | ||
export declare type Pagination = { | ||
offset?: number; | ||
limit?: number; | ||
}; | ||
export declare type ResourceQuery = Pagination & {}; | ||
export declare type ResourceResults<T> = Pagination & { | ||
results: T; | ||
total: number; | ||
}; | ||
export declare type IndexRequest = { | ||
uid: string; | ||
primaryKey?: string; | ||
}; | ||
export declare type IndexOptions = { | ||
primaryKey?: string; | ||
}; | ||
export declare type IndexResponse = { | ||
export declare type IndexObject = { | ||
uid: string; | ||
name?: string; | ||
primaryKey?: string; | ||
@@ -23,10 +25,5 @@ createdAt: Date; | ||
}; | ||
export declare type AddDocumentParams = { | ||
primaryKey?: string; | ||
}; | ||
export declare type IndexesQuery = ResourceQuery & {}; | ||
export declare type IndexesResults<T> = ResourceResults<T> & {}; | ||
export declare type Filter = string | Array<string | string[]>; | ||
export declare type Pagination = { | ||
offset?: number; | ||
limit?: number; | ||
}; | ||
export declare type Query = { | ||
@@ -48,5 +45,5 @@ q?: string | null; | ||
sort?: string[]; | ||
facetsDistribution?: string[]; | ||
facets?: string[]; | ||
attributesToRetrieve?: string[]; | ||
matches?: boolean; | ||
showMatchesPosition?: boolean; | ||
}; | ||
@@ -56,7 +53,7 @@ export declare type SearchRequestGET = Pagination & Query & Omit<Highlight, 'attributesToHighlight'> & Omit<Crop, 'attributesToCrop'> & { | ||
sort?: string; | ||
facetsDistribution?: string; | ||
facets?: string; | ||
attributesToRetrieve?: string; | ||
attributesToHighlight?: string; | ||
attributesToCrop?: string; | ||
matches?: boolean; | ||
showMatchesPosition?: boolean; | ||
}; | ||
@@ -72,10 +69,7 @@ export declare type CategoriesDistribution = { | ||
}>>>; | ||
export declare type document = { | ||
[field: string]: any; | ||
}; | ||
export declare type Hit<T = document> = T & { | ||
export declare type Hit<T = Record<string, any>> = T & { | ||
_formatted?: Partial<T>; | ||
_matchesInfo?: _matchesInfo<T>; | ||
_matchesPosition?: _matchesInfo<T>; | ||
}; | ||
export declare type Hits<T = document> = Array<Hit<T>>; | ||
export declare type Hits<T = Record<string, any>> = Array<Hit<T>>; | ||
export declare type SearchResponse<T = Record<string, any>> = { | ||
@@ -86,7 +80,5 @@ hits: Hits<T>; | ||
processingTimeMs: number; | ||
facetsDistribution?: FacetsDistribution; | ||
exhaustiveFacetsCount?: boolean; | ||
facetDistribution?: FacetsDistribution; | ||
query: string; | ||
nbHits: number; | ||
exhaustiveNbHits: boolean; | ||
estimatedTotalHits: number; | ||
}; | ||
@@ -96,9 +88,11 @@ export declare type FieldDistribution = { | ||
}; | ||
export declare type GetDocumentsParams<T = Record<string, any>> = { | ||
offset?: number; | ||
limit?: number; | ||
attributesToRetrieve?: Array<Extract<keyof T, string>> | Extract<keyof T, string>; | ||
export declare type DocumentOptions = { | ||
primaryKey?: string; | ||
}; | ||
export declare type GetDocumentsResponse<T = Record<string, any>> = Array<Document<T>>; | ||
export declare type DocumentsQuery<T = Record<string, any>> = ResourceQuery & { | ||
fields?: Array<Extract<keyof T, string>> | Extract<keyof T, string>; | ||
}; | ||
export declare type Document<T = Record<string, any>> = T; | ||
export declare type Documents<T = Record<string, any>> = Array<Document<T>>; | ||
export declare type DocumentsResults<T = Record<string, any>> = ResourceResults<Documents<T>> & {}; | ||
export declare type FilterableAttributes = string[] | null; | ||
@@ -116,3 +110,3 @@ export declare type DistinctAttribute = string | null; | ||
enabled?: boolean | null; | ||
disableOnAttributes?: string[] | null; | ||
disabledOnAttributes?: string[] | null; | ||
disableOnWords?: string[] | null; | ||
@@ -124,2 +118,8 @@ minWordSizeForTypos?: { | ||
} | null; | ||
export declare type Faceting = { | ||
maxValuesPerFacet?: number | null; | ||
}; | ||
export declare type PaginationSettings = { | ||
maxTotalHits?: number | null; | ||
}; | ||
export declare type Settings = { | ||
@@ -135,2 +135,4 @@ filterableAttributes?: FilterableAttributes; | ||
typoTolerance?: TypoTolerance; | ||
faceting?: Faceting; | ||
pagination?: PaginationSettings; | ||
}; | ||
@@ -143,13 +145,27 @@ export declare const enum TaskStatus { | ||
} | ||
export declare const enum TaskTypes { | ||
INDEX_CREATION = "indexCreation", | ||
INDEX_UPDATE = "indexUpdate", | ||
INDEX_DELETION = "indexDeletion", | ||
DOCUMENTS_ADDITION_OR_UPDATE = "documentAdditionOrUpdate", | ||
DOCUMENT_DELETION = "documentDeletion", | ||
SETTINGS_UPDATE = "settingsUpdate" | ||
} | ||
export declare type TasksQuery = { | ||
indexUid?: string[]; | ||
type?: TaskTypes[]; | ||
status?: TaskStatus[]; | ||
limit?: number; | ||
from?: number; | ||
}; | ||
export declare type EnqueuedTask = { | ||
uid: number; | ||
indexUid: string; | ||
taskUid: number; | ||
indexUid?: string; | ||
status: TaskStatus; | ||
type: string; | ||
type: TaskTypes; | ||
enqueuedAt: string; | ||
}; | ||
export declare type Task = { | ||
status: TaskStatus; | ||
export declare type Task = Omit<EnqueuedTask, 'taskUid'> & { | ||
uid: number; | ||
type: string; | ||
batchUid: number; | ||
details: { | ||
@@ -169,13 +185,13 @@ receivedDocuments?: number; | ||
}; | ||
error?: MeiliSearchErrorInfo; | ||
duration: string; | ||
enqueuedAt: string; | ||
processedAt: string; | ||
error?: MeiliSearchErrorInfo; | ||
}; | ||
export declare type EnqueuedDump = { | ||
uid: string; | ||
status: 'in_progress' | 'failed' | 'done'; | ||
startedAt: string; | ||
finishedAt: string; | ||
}; | ||
export declare type TasksResults = { | ||
results: Task[]; | ||
limit: number; | ||
from: number; | ||
next: number; | ||
}; | ||
export declare type WaitOptions = { | ||
@@ -201,3 +217,5 @@ timeOutMs?: number; | ||
export declare type Key = { | ||
uid: string; | ||
description: string; | ||
name: string | null; | ||
key: string; | ||
@@ -210,3 +228,5 @@ actions: string[]; | ||
}; | ||
export declare type KeyPayload = { | ||
export declare type KeyCreation = { | ||
uid?: string; | ||
name?: string; | ||
description?: string; | ||
@@ -217,2 +237,8 @@ actions: string[]; | ||
}; | ||
export declare type KeyUpdate = { | ||
name?: string; | ||
description?: string; | ||
}; | ||
export declare type KeysQuery = ResourceQuery & {}; | ||
export declare type KeysResults = ResourceResults<Key[]> & {}; | ||
export declare type Version = { | ||
@@ -309,4 +335,2 @@ commitSha: string; | ||
TASK_NOT_FOUND = "task_not_found", | ||
/** @see https://docs.meilisearch.com/errors/#dump_already_processing */ | ||
DUMP_ALREADY_PROCESSING = "dump_already_processing", | ||
/** @see https://docs.meilisearch.com/errors/#dump_process_failed */ | ||
@@ -313,0 +337,0 @@ DUMP_PROCESS_FAILED = "dump_process_failed", |
@@ -8,3 +8,4 @@ /** | ||
declare function addTrailingSlash(url: string): string; | ||
export { sleep, removeUndefinedFromObject, addProtocolIfNotPresent, addTrailingSlash, }; | ||
declare function validateUuid4(uuid: string): boolean; | ||
export { sleep, removeUndefinedFromObject, addProtocolIfNotPresent, addTrailingSlash, validateUuid4, }; | ||
//# sourceMappingURL=utils.d.ts.map |
{ | ||
"name": "meilisearch", | ||
"version": "0.26.0", | ||
"version": "0.27.0-beta.0", | ||
"description": "The Meilisearch JS client for Node.js and the browser.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -345,3 +345,3 @@ <p align="center"> | ||
This package only guarantees the compatibility with the [version v0.27.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.27.0). | ||
This package only guarantees the compatibility with the [version v0.28.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0). | ||
@@ -397,3 +397,3 @@ ## 💡 Learn More | ||
`index.getDocuments(params: getDocumentsParams): Promise<Document<T>[]>` | ||
`index.getDocuments(parameters: DocumentsQuery = {}): Promise<DocumentsResults<T>>>` | ||
@@ -418,43 +418,40 @@ - [Get one document](https://docs.meilisearch.com/reference/api/documents.html#get-one-document): | ||
- [Get task info using the client](https://docs.meilisearch.com/reference/api/tasks.html#get-all-tasks): | ||
- [Get all tasks](https://docs.meilisearch.com/reference/api/tasks.html#get-all-tasks) | ||
Task list: | ||
`client.getTasks(): Promise<Result<Task[]>>` | ||
`client.getTasks(parameters: TasksQuery): Promise<TasksResults>` | ||
One task: | ||
`client.getTask(uid: number): Promise<Task>` | ||
- [Get one task](https://docs.meilisearch.com/reference/api/tasks.html#get-task) | ||
- [Get task info using the index](https://docs.meilisearch.com/reference/api/tasks.html#get-all-tasks-by-index): | ||
`client.getTask(uid: number): Promise<Task>` | ||
Task list: | ||
`index.getTasks(): Promise<Result<Task[]>>` | ||
- [Get all tasks of an index](https://docs.meilisearch.com/reference/api/tasks.html#get-all-tasks-by-index) | ||
One task: | ||
`index.getTask(uid: number): Promise<Task>` | ||
`index.getTasks(parameters: TasksQuery): Promise<TasksResults>` | ||
- [Get one task of an index](https://docs.meilisearch.com/reference/api/tasks.html#get-task) | ||
`index.getTask(uid: number): Promise<Task>` | ||
- Wait for one task: | ||
Using de client: | ||
`client.waitForTask(uid: number, { timeOutMs?: number, intervalMs?: number }): Promise<Task>` | ||
`client.waitForTask(uid: number, { timeOutMs?: number, intervalMs?: number }): Promise<Task>` | ||
Using the index: | ||
`index.waitForTask(uid: number, { timeOutMs?: number, intervalMs?: number }): Promise<Task>` | ||
With an index instance: | ||
`index.waitForTask(uid: number, { timeOutMs?: number, intervalMs?: number }): Promise<Task>` | ||
- Wait for multiple tasks: | ||
`client.waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise<Task[]>` | ||
Using the client: | ||
`client.waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise<Result<Task[]>>` | ||
With an index instance: | ||
`index.waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise<Task[]>` | ||
Using the index: | ||
`index.waitForTasks(uids: number[], { timeOutMs?: number, intervalMs?: number }): Promise<Result<Task[]>>` | ||
### Indexes <!-- omit in toc --> | ||
- [Get all indexes in Index instances](https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes): | ||
- [Get all indexes as Index instances](https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes): | ||
`client.getIndexes(): Promise<Index[]>` | ||
`client.getIndexes(parameters: IndexesQuery): Promise<IndexesResults<Index[]>>` | ||
- [Get raw indexes in JSON response from Meilisearch](https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes): | ||
- [Get all indexes](https://docs.meilisearch.com/reference/api/indexes.html#list-all-indexes): | ||
`client.getRawIndexes(): Promise<IndexResponse[]>` | ||
`client.getRawIndexes(parameters: IndexesQuery): Promise<IndexesResults<IndexObject[]>>` | ||
@@ -473,6 +470,6 @@ - [Create a new index](https://docs.meilisearch.com/reference/api/indexes.html#create-an-index): | ||
- [Get the raw index JSON response from Meilisearch](https://docs.meilisearch.com/reference/api/indexes.html#get-one-index): | ||
`client.getRawIndex(uid: string): Promise<IndexResponse>` | ||
`client.getRawIndex(uid: string): Promise<IndexObject>` | ||
- [Get an object with information about the index](https://docs.meilisearch.com/reference/api/indexes.html#get-one-index): | ||
`index.getRawInfo(): Promise<IndexResponse>` | ||
`index.getRawInfo(): Promise<IndexObject>` | ||
@@ -627,3 +624,3 @@ - [Update Index](https://docs.meilisearch.com/reference/api/indexes.html#update-an-index): | ||
`client.getKeys(): Promise<Result<Key[]>>` | ||
`client.getKeys(parameters: KeysQuery): Promise<KeysResults>` | ||
@@ -636,7 +633,7 @@ - [Get one key](https://docs.meilisearch.com/reference/api/keys.html#get-one-key): | ||
`client.createKey(options: KeyPayload): Promise<Key>` | ||
`client.createKey(options: KeyCreation): Promise<Key>` | ||
- [Update a key](https://docs.meilisearch.com/reference/api/keys.html#update-a-key): | ||
`client.updateKey(key: string, options: KeyPayload): Promise<Key>` | ||
`client.updateKey(key: string, options: KeyUpdate): Promise<Key>` | ||
@@ -675,10 +672,6 @@ - [Delete a key](https://docs.meilisearch.com/reference/api/keys.html#delete-a-key): | ||
`client.createDump(): Promise<Types.EnqueuedDump>` | ||
`client.createDump(): Promise<EnqueuedTask>` | ||
- [Get the status of a dump creation process](https://docs.meilisearch.com/reference/api/dump.html#get-dump-status): | ||
`client.getDumpStatus(dumpUid: string): Promise<Types.EnqueuedDump>` | ||
<hr> | ||
**Meilisearch** provides and maintains many **SDKs and Integration tools** like this one. We want to provide everyone with an **amazing search experience for any kind of project**. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the [integration-guides](https://github.com/meilisearch/integration-guides) repository. |
@@ -12,6 +12,6 @@ /* | ||
import { | ||
KeyPayload, | ||
KeyCreation, | ||
Config, | ||
IndexOptions, | ||
IndexResponse, | ||
IndexObject, | ||
EnqueuedTask, | ||
@@ -22,8 +22,14 @@ Key, | ||
Version, | ||
EnqueuedDump, | ||
ErrorStatusCode, | ||
Task, | ||
Result, | ||
TokenSearchRules, | ||
TokenOptions, | ||
TasksQuery, | ||
WaitOptions, | ||
KeyUpdate, | ||
IndexesQuery, | ||
IndexesResults, | ||
KeysQuery, | ||
KeysResults, | ||
TasksResults, | ||
} from '../types' | ||
@@ -79,5 +85,5 @@ import { HttpRequests } from '../http-requests' | ||
* @param {string} indexUid The index UID | ||
* @returns {Promise<IndexResponse>} Promise returning index information | ||
* @returns {Promise<IndexObject>} Promise returning index information | ||
*/ | ||
async getRawIndex(indexUid: string): Promise<IndexResponse> { | ||
async getRawIndex(indexUid: string): Promise<IndexObject> { | ||
return new Index(this.config, indexUid).getRawInfo() | ||
@@ -90,10 +96,14 @@ } | ||
* @method getIndexes | ||
* @returns {Promise<Index[]>} Promise returning array of raw index information | ||
* @param {IndexesQuery} [parameters={}] - Parameters to browse the indexes | ||
* | ||
* @returns {Promise<IndexesResults<Index[]>>} Promise returning array of raw index information | ||
*/ | ||
async getIndexes(): Promise<Index[]> { | ||
const response = await this.getRawIndexes() | ||
const indexes: Index[] = response.map( | ||
async getIndexes( | ||
parameters: IndexesQuery = {} | ||
): Promise<IndexesResults<Index[]>> { | ||
const rawIndexes = await this.getRawIndexes(parameters) | ||
const indexes: Index[] = rawIndexes.results.map( | ||
(index) => new Index(this.config, index.uid, index.primaryKey) | ||
) | ||
return indexes | ||
return { ...rawIndexes, results: indexes } | ||
} | ||
@@ -105,7 +115,14 @@ | ||
* @method getRawIndexes | ||
* @returns {Promise<IndexResponse[]>} Promise returning array of raw index information | ||
* @param {IndexesQuery} [parameters={}] - Parameters to browse the indexes | ||
* | ||
* @returns {Promise<IndexesResults<IndexObject[]>>} Promise returning array of raw index information | ||
*/ | ||
async getRawIndexes(): Promise<IndexResponse[]> { | ||
async getRawIndexes( | ||
parameters: IndexesQuery = {} | ||
): Promise<IndexesResults<IndexObject[]>> { | ||
const url = `indexes` | ||
return await this.httpRequest.get<IndexResponse[]>(url) | ||
return await this.httpRequest.get<IndexesResults<IndexObject[]>>( | ||
url, | ||
parameters | ||
) | ||
} | ||
@@ -183,6 +200,8 @@ | ||
* @method getTasks | ||
* @returns {Promise<Result<Task[]>>} - Promise returning all tasks | ||
* @param {TasksQuery} [parameters={}] - Parameters to browse the tasks | ||
* | ||
* @returns {Promise<TasksResults>} - Promise returning all tasks | ||
*/ | ||
async getTasks(): Promise<Result<Task[]>> { | ||
return await this.tasks.getClientTasks() | ||
async getTasks(parameters: TasksQuery = {}): Promise<TasksResults> { | ||
return await this.tasks.getTasks(parameters) | ||
} | ||
@@ -194,26 +213,24 @@ | ||
* @method getTask | ||
* @param {number} taskId - Task identifier | ||
* @param {number} taskUid - Task identifier | ||
* @returns {Promise<Task>} - Promise returning a task | ||
*/ | ||
async getTask(taskId: number): Promise<Task> { | ||
return await this.tasks.getClientTask(taskId) | ||
async getTask(taskUid: number): Promise<Task> { | ||
return await this.tasks.getTask(taskUid) | ||
} | ||
/** | ||
* Wait for a batch of tasks to be processed. | ||
* Wait for multiple tasks to be finished. | ||
* | ||
* @memberof MeiliSearch | ||
* @method waitForTasks | ||
* @param {number[]} taskIds - Tasks identifier | ||
* @param {number[]} taskUids - Tasks identifier | ||
* @param {WaitOptions} waitOptions - Options on timeout and interval | ||
* | ||
* @returns {Promise<Result<Task[]>>} - Promise returning an array of tasks | ||
* @returns {Promise<Task[]>} - Promise returning an array of tasks | ||
*/ | ||
async waitForTasks( | ||
taskIds: number[], | ||
{ | ||
timeOutMs = 5000, | ||
intervalMs = 50, | ||
}: { timeOutMs?: number; intervalMs?: number } = {} | ||
): Promise<Result<Task[]>> { | ||
return await this.tasks.waitForClientTasks(taskIds, { | ||
taskUids: number[], | ||
{ timeOutMs = 5000, intervalMs = 50 }: WaitOptions = {} | ||
): Promise<Task[]> { | ||
return await this.tasks.waitForTasks(taskUids, { | ||
timeOutMs, | ||
@@ -225,7 +242,8 @@ intervalMs, | ||
/** | ||
* Wait for a task to be processed. | ||
* Wait for a task to be finished. | ||
* | ||
* @memberof MeiliSearch | ||
* @method waitForTask | ||
* @param {number} taskId - Task identifier | ||
* | ||
* @param {number} taskUid - Task identifier | ||
* @param {WaitOptions} waitOptions - Options on timeout and interval | ||
@@ -236,9 +254,6 @@ * | ||
async waitForTask( | ||
taskId: number, | ||
{ | ||
timeOutMs = 5000, | ||
intervalMs = 50, | ||
}: { timeOutMs?: number; intervalMs?: number } = {} | ||
taskUid: number, | ||
{ timeOutMs = 5000, intervalMs = 50 }: WaitOptions = {} | ||
): Promise<Task> { | ||
return await this.tasks.waitForClientTask(taskId, { | ||
return await this.tasks.waitForTask(taskUid, { | ||
timeOutMs, | ||
@@ -257,7 +272,9 @@ intervalMs, | ||
* @method getKeys | ||
* @returns {Promise<Keys>} Promise returning an object with keys | ||
* @param {KeysQuery} [parameters={}] - Parameters to browse the indexes | ||
* | ||
* @returns {Promise<KeysResults>} Promise returning an object with keys | ||
*/ | ||
async getKeys(): Promise<Result<Key[]>> { | ||
async getKeys(parameters: KeysQuery = {}): Promise<KeysResults> { | ||
const url = `keys` | ||
return await this.httpRequest.get<Result<Key[]>>(url) | ||
return await this.httpRequest.get<KeysResults>(url, parameters) | ||
} | ||
@@ -270,7 +287,7 @@ | ||
* | ||
* @param {string} key - Key | ||
* @param {string} keyOrUid - Key or uid of the API key | ||
* @returns {Promise<Keys>} Promise returning a key | ||
*/ | ||
async getKey(key: string): Promise<Key> { | ||
const url = `keys/${key}` | ||
async getKey(keyOrUid: string): Promise<Key> { | ||
const url = `keys/${keyOrUid}` | ||
return await this.httpRequest.get<Key>(url) | ||
@@ -284,6 +301,6 @@ } | ||
* | ||
* @param {KeyPayload} options - Key options | ||
* @param {KeyCreation} options - Key options | ||
* @returns {Promise<Key>} Promise returning an object with keys | ||
*/ | ||
async createKey(options: KeyPayload): Promise<Key> { | ||
async createKey(options: KeyCreation): Promise<Key> { | ||
const url = `keys` | ||
@@ -299,6 +316,6 @@ return await this.httpRequest.post(url, options) | ||
* @param {string} key - Key | ||
* @param {KeyPayload} options - Key options | ||
* @param {KeyUpdate} options - Key options | ||
* @returns {Promise<Key>} Promise returning an object with keys | ||
*/ | ||
async updateKey(key: string, options: KeyPayload): Promise<Key> { | ||
async updateKey(key: string, options: KeyUpdate): Promise<Key> { | ||
const url = `keys/${key}` | ||
@@ -387,23 +404,15 @@ return await this.httpRequest.patch(url, options) | ||
/** | ||
* Triggers a dump creation process | ||
* Creates a dump | ||
* @memberof MeiliSearch | ||
* @method createDump | ||
* @returns {Promise<EnqueuedDump>} Promise returning object of the enqueued task | ||
* @returns {Promise<EnqueuedTask>} Promise returning object of the enqueued task | ||
*/ | ||
async createDump(): Promise<EnqueuedDump> { | ||
async createDump(): Promise<EnqueuedTask> { | ||
const url = `dumps` | ||
return await this.httpRequest.post<undefined, EnqueuedDump>(url) | ||
return await this.httpRequest.post<undefined, EnqueuedTask>(url) | ||
} | ||
/** | ||
* Get the status of a dump creation process | ||
* @memberof MeiliSearch | ||
* @method getDumpStatus | ||
* @param {string} dumpUid Dump UID | ||
* @returns {Promise<EnqueuedDump>} Promise returning object of the enqueued task | ||
*/ | ||
async getDumpStatus(dumpUid: string): Promise<EnqueuedDump> { | ||
const url = `dumps/${dumpUid}/status` | ||
return await this.httpRequest.get<EnqueuedDump>(url) | ||
} | ||
/// | ||
/// TOKENS | ||
/// | ||
@@ -415,7 +424,10 @@ /** | ||
* @method generateTenantToken | ||
* @param {apiKeyUid} apiKeyUid The uid of the api key used as issuer of the token. | ||
* @param {SearchRules} searchRules Search rules that are applied to every search. | ||
* @param {TokenOptions} options Token options to customize some aspect of the token. | ||
* | ||
* @returns {String} The token in JWT format. | ||
*/ | ||
generateTenantToken( | ||
_apiKeyUid: string, | ||
_searchRules: TokenSearchRules, | ||
@@ -422,0 +434,0 @@ _options?: TokenOptions |
@@ -18,7 +18,10 @@ import { Client } from './client' | ||
* @method generateTenantToken | ||
* @param {apiKeyUid} apiKeyUid The uid of the api key used as issuer of the token. | ||
* @param {SearchRules} searchRules Search rules that are applied to every search. | ||
* @param {TokenOptions} options Token options to customize some aspect of the token. | ||
* | ||
* @returns {String} The token in JWT format. | ||
*/ | ||
generateTenantToken( | ||
apiKeyUid: string, | ||
searchRules: TokenSearchRules, | ||
@@ -28,7 +31,7 @@ options?: TokenOptions | ||
if (typeof window === 'undefined') { | ||
return this.tokens.generateTenantToken(searchRules, options) | ||
return this.tokens.generateTenantToken(apiKeyUid, searchRules, options) | ||
} | ||
return super.generateTenantToken(searchRules, options) | ||
return super.generateTenantToken(apiKeyUid, searchRules, options) | ||
} | ||
} | ||
export { MeiliSearch } |
@@ -12,6 +12,2 @@ import { MeiliSearchErrorInfo } from '../types' | ||
super(error.message) | ||
// Make errors comparison possible. ex: error instanceof MeiliSearchApiError. | ||
Object.setPrototypeOf(this, MeiliSearchApiError.prototype) | ||
this.name = 'MeiliSearchApiError' | ||
@@ -24,2 +20,4 @@ | ||
this.httpStatus = status | ||
// Make errors comparison possible. ex: error instanceof MeiliSearchApiError. | ||
Object.setPrototypeOf(this, MeiliSearchApiError.prototype) | ||
@@ -26,0 +24,0 @@ if (Error.captureStackTrace) { |
@@ -18,5 +18,2 @@ import 'cross-fetch/polyfill' | ||
// Make errors comparison possible. ex: error instanceof MeiliSearchCommunicationError. | ||
Object.setPrototypeOf(this, MeiliSearchCommunicationError.prototype) | ||
this.name = 'MeiliSearchCommunicationError' | ||
@@ -23,0 +20,0 @@ |
class MeiliSearchError extends Error { | ||
constructor(message: string) { | ||
super(message) | ||
// Make errors comparison possible. ex: error instanceof MeiliSearchError. | ||
Object.setPrototypeOf(this, MeiliSearchError.prototype) | ||
this.name = 'MeiliSearchError' | ||
@@ -9,0 +5,0 @@ |
class MeiliSearchTimeOutError extends Error { | ||
constructor(message: string) { | ||
super(message) | ||
// Make errors comparison possible. ex: error instanceof MeiliSearchTimeOutError. | ||
Object.setPrototypeOf(this, MeiliSearchTimeOutError.prototype) | ||
this.name = 'MeiliSearchTimeOutError' | ||
@@ -9,0 +5,0 @@ |
import 'cross-fetch/polyfill' | ||
import { Config, EnqueuedTask } from './types' | ||
import { PACKAGE_VERSION } from './package-version' | ||
@@ -23,2 +24,35 @@ import { | ||
function createHeaders(config: Config): Record<string, any> { | ||
const agentHeader = 'X-Meilisearch-Client' | ||
const packageAgent = `Meilisearch JavaScript (v${PACKAGE_VERSION})` | ||
const contentType = 'Content-Type' | ||
config.headers = config.headers || {} | ||
const headers: Record<string, any> = Object.assign({}, config.headers) // Create a hard copy and not a reference to config.headers | ||
if (config.apiKey) { | ||
headers['Authorization'] = `Bearer ${config.apiKey}` | ||
} | ||
if (!config.headers[contentType]) { | ||
headers['Content-Type'] = 'application/json' | ||
} | ||
// Creates the custom user agent with information on the package used. | ||
if (config.clientAgents && Array.isArray(config.clientAgents)) { | ||
const clients = config.clientAgents.concat(packageAgent) | ||
headers[agentHeader] = clients.join(' ; ') | ||
} else if (config.clientAgents && !Array.isArray(config.clientAgents)) { | ||
// If the header is defined but not an array | ||
throw new MeiliSearchError( | ||
`Meilisearch: The header "${agentHeader}" should be an array of string(s).\n` | ||
) | ||
} else { | ||
headers[agentHeader] = packageAgent | ||
} | ||
return headers | ||
} | ||
class HttpRequests { | ||
@@ -29,7 +63,4 @@ headers: Record<string, any> | ||
constructor(config: Config) { | ||
this.headers = Object.assign({}, config.headers || {}) // assign to avoid referencing | ||
this.headers['Content-Type'] = 'application/json' | ||
if (config.apiKey) { | ||
this.headers['Authorization'] = `Bearer ${config.apiKey}` | ||
} | ||
this.headers = createHeaders(config) | ||
try { | ||
@@ -36,0 +67,0 @@ const host = constructHostURL(config.host) |
@@ -19,9 +19,8 @@ /* | ||
SearchRequestGET, | ||
IndexResponse, | ||
IndexObject, | ||
IndexOptions, | ||
IndexStats, | ||
GetDocumentsParams, | ||
GetDocumentsResponse, | ||
DocumentsQuery, | ||
Document, | ||
AddDocumentParams, | ||
DocumentOptions, | ||
EnqueuedTask, | ||
@@ -38,3 +37,6 @@ Settings, | ||
TypoTolerance, | ||
Result, | ||
WaitOptions, | ||
DocumentsResults, | ||
TasksQuery, | ||
TasksResults, | ||
} from './types' | ||
@@ -125,3 +127,3 @@ import { removeUndefinedFromObject } from './utils' | ||
sort: options?.sort?.join(','), | ||
facetsDistribution: options?.facetsDistribution?.join(','), | ||
facets: options?.facets?.join(','), | ||
attributesToRetrieve: options?.attributesToRetrieve?.join(','), | ||
@@ -147,7 +149,8 @@ attributesToCrop: options?.attributesToCrop?.join(','), | ||
* @method getRawInfo | ||
* @returns {Promise<IndexResponse>} Promise containing index information | ||
* | ||
* @returns {Promise<IndexObject>} Promise containing index information | ||
*/ | ||
async getRawInfo(): Promise<IndexResponse> { | ||
async getRawInfo(): Promise<IndexObject> { | ||
const url = `indexes/${this.uid}` | ||
const res = await this.httpRequest.get<IndexResponse>(url) | ||
const res = await this.httpRequest.get<IndexObject>(url) | ||
this.primaryKey = res.primaryKey | ||
@@ -210,3 +213,3 @@ this.updatedAt = new Date(res.updatedAt) | ||
const url = `indexes/${this.uid}` | ||
return await this.httpRequest.put(url, data) | ||
return await this.httpRequest.patch(url, data) | ||
} | ||
@@ -230,11 +233,12 @@ | ||
/** | ||
* Get the list of all the index tasks. | ||
* Get the list of all the tasks of the index. | ||
* | ||
* @memberof Indexes | ||
* @method getTasks | ||
* @param {TasksQuery} [parameters={}] - Parameters to browse the tasks | ||
* | ||
* @returns {Promise<Result<Task[]>>} - Promise containing all tasks | ||
* @returns {Promise<TasksResults>} - Promise containing all tasks | ||
*/ | ||
async getTasks(): Promise<Result<Task[]>> { | ||
return await this.tasks.getIndexTasks(this.uid) | ||
async getTasks(parameters: TasksQuery = {}): Promise<TasksResults> { | ||
return await this.tasks.getTasks({ ...parameters, indexUid: [this.uid] }) | ||
} | ||
@@ -247,28 +251,25 @@ | ||
* @method getTask | ||
* @param {number} taskId - Task identifier | ||
* @param {number} taskUid - Task identifier | ||
* | ||
* @returns {Promise<Task>} - Promise containing a task | ||
*/ | ||
async getTask(taskId: number): Promise<Task> { | ||
return await this.tasks.getIndexTask(this.uid, taskId) | ||
async getTask(taskUid: number): Promise<Task> { | ||
return await this.tasks.getTask(taskUid) | ||
} | ||
/** | ||
* Wait for a batch of an index tasks to be processed. | ||
* Wait for multiple tasks to be processed. | ||
* | ||
* @memberof Indexes | ||
* @method waitForTasks | ||
* @param {number[]} taskIds - Tasks identifier | ||
* @param {number[]} taskUids - Tasks identifier | ||
* @param {WaitOptions} waitOptions - Options on timeout and interval | ||
* | ||
* @returns {Promise<Result<Task[]>>} - Promise containing an array of tasks | ||
* @returns {Promise<Task[]>} - Promise containing an array of tasks | ||
*/ | ||
async waitForTasks( | ||
taskIds: number[], | ||
{ | ||
timeOutMs = 5000, | ||
intervalMs = 50, | ||
}: { timeOutMs?: number; intervalMs?: number } = {} | ||
): Promise<Result<Task[]>> { | ||
return await this.tasks.waitForClientTasks(taskIds, { | ||
taskUids: number[], | ||
{ timeOutMs = 5000, intervalMs = 50 }: WaitOptions = {} | ||
): Promise<Task[]> { | ||
return await this.tasks.waitForTasks(taskUids, { | ||
timeOutMs, | ||
@@ -280,7 +281,7 @@ intervalMs, | ||
/** | ||
* Wait for an index task to be processed. | ||
* Wait for a task to be processed. | ||
* | ||
* @memberof Indexes | ||
* @method waitForTask | ||
* @param {number} taskId - Task identifier | ||
* @param {number} taskUid - Task identifier | ||
* @param {WaitOptions} waitOptions - Options on timeout and interval | ||
@@ -291,9 +292,6 @@ * | ||
async waitForTask( | ||
taskId: number, | ||
{ | ||
timeOutMs = 5000, | ||
intervalMs = 50, | ||
}: { timeOutMs?: number; intervalMs?: number } = {} | ||
taskUid: number, | ||
{ timeOutMs = 5000, intervalMs = 50 }: WaitOptions = {} | ||
): Promise<Task> { | ||
return await this.tasks.waitForClientTask(taskId, { | ||
return await this.tasks.waitForTask(taskUid, { | ||
timeOutMs, | ||
@@ -327,18 +325,24 @@ intervalMs, | ||
* @template T | ||
* @param {GetDocumentsParams<T>} options? Options to browse the documents | ||
* @returns {Promise<GetDocumentsResponse<T>>} Promise containing Document responses | ||
* @param {DocumentsQuery<T>} [parameters={}] Parameters to browse the documents | ||
* @returns {Promise<DocumentsResults<T>>>} Promise containing Document responses | ||
*/ | ||
async getDocuments<T = Record<string, any>>( | ||
options?: GetDocumentsParams<T> | ||
): Promise<GetDocumentsResponse<T>> { | ||
parameters: DocumentsQuery<T> = {} | ||
): Promise<DocumentsResults<T>> { | ||
const url = `indexes/${this.uid}/documents` | ||
let attr | ||
if (options !== undefined && Array.isArray(options.attributesToRetrieve)) { | ||
attr = options.attributesToRetrieve.join(',') | ||
} | ||
return await this.httpRequest.get<GetDocumentsResponse<T>>(url, { | ||
...options, | ||
...(attr !== undefined ? { attributesToRetrieve: attr } : {}), | ||
}) | ||
const fields = (() => { | ||
if (Array.isArray(parameters?.fields)) { | ||
return parameters?.fields?.join(',') | ||
} | ||
return undefined | ||
})() | ||
return await this.httpRequest.get<Promise<DocumentsResults<T>>>( | ||
url, | ||
removeUndefinedFromObject({ | ||
...parameters, | ||
fields, | ||
}) | ||
) | ||
} | ||
@@ -365,3 +369,4 @@ | ||
* @param {Array<Document<T>>} documents Array of Document objects to add/replace | ||
* @param {AddDocumentParams} options? Query parameters | ||
* @param {DocumentOptions} options? Options on document addition | ||
* | ||
* @returns {Promise<EnqueuedTask>} Promise containing object of the enqueued task | ||
@@ -371,3 +376,3 @@ */ | ||
documents: Array<Document<T>>, | ||
options?: AddDocumentParams | ||
options?: DocumentOptions | ||
): Promise<EnqueuedTask> { | ||
@@ -385,3 +390,3 @@ const url = `indexes/${this.uid}/documents` | ||
* @param {number} batchSize Size of the batch | ||
* @param {AddDocumentParams} options? Query parameters | ||
* @param {DocumentOptions} options? Options on document addition | ||
* @returns {Promise<EnqueuedTasks>} Promise containing array of enqueued task objects for each batch | ||
@@ -392,3 +397,3 @@ */ | ||
batchSize = 1000, | ||
options?: AddDocumentParams | ||
options?: DocumentOptions | ||
): Promise<EnqueuedTask[]> { | ||
@@ -409,3 +414,3 @@ const updates = [] | ||
* @param {Array<Document<Partial<T>>>} documents Array of Document objects to add/update | ||
* @param {AddDocumentParams} options? Query parameters | ||
* @param {DocumentOptions} options? Options on document update | ||
* @returns {Promise<EnqueuedTask>} Promise containing object of the enqueued task | ||
@@ -415,3 +420,3 @@ */ | ||
documents: Array<Document<Partial<T>>>, | ||
options?: AddDocumentParams | ||
options?: DocumentOptions | ||
): Promise<EnqueuedTask> { | ||
@@ -429,3 +434,3 @@ const url = `indexes/${this.uid}/documents` | ||
* @param {number} batchSize Size of the batch | ||
* @param {AddDocumentParams} options? Query parameters | ||
* @param {DocumentOptions} options? Options on document update | ||
* @returns {Promise<EnqueuedTasks>} Promise containing array of enqueued task objects for each batch | ||
@@ -436,3 +441,3 @@ */ | ||
batchSize = 1000, | ||
options?: AddDocumentParams | ||
options?: DocumentOptions | ||
): Promise<EnqueuedTask[]> { | ||
@@ -511,3 +516,3 @@ const updates = [] | ||
const url = `indexes/${this.uid}/settings` | ||
return await this.httpRequest.post(url, settings) | ||
return await this.httpRequest.patch(url, settings) | ||
} | ||
@@ -550,3 +555,3 @@ | ||
const url = `indexes/${this.uid}/settings/synonyms` | ||
return await this.httpRequest.post(url, synonyms) | ||
return await this.httpRequest.put(url, synonyms) | ||
} | ||
@@ -589,3 +594,3 @@ | ||
const url = `indexes/${this.uid}/settings/stop-words` | ||
return await this.httpRequest.post(url, stopWords) | ||
return await this.httpRequest.put(url, stopWords) | ||
} | ||
@@ -628,3 +633,3 @@ | ||
const url = `indexes/${this.uid}/settings/ranking-rules` | ||
return await this.httpRequest.post(url, rankingRules) | ||
return await this.httpRequest.put(url, rankingRules) | ||
} | ||
@@ -669,3 +674,3 @@ | ||
const url = `indexes/${this.uid}/settings/distinct-attribute` | ||
return await this.httpRequest.post(url, distinctAttribute) | ||
return await this.httpRequest.put(url, distinctAttribute) | ||
} | ||
@@ -710,3 +715,3 @@ | ||
const url = `indexes/${this.uid}/settings/filterable-attributes` | ||
return await this.httpRequest.post(url, filterableAttributes) | ||
return await this.httpRequest.put(url, filterableAttributes) | ||
} | ||
@@ -751,3 +756,3 @@ | ||
const url = `indexes/${this.uid}/settings/sortable-attributes` | ||
return await this.httpRequest.post(url, sortableAttributes) | ||
return await this.httpRequest.put(url, sortableAttributes) | ||
} | ||
@@ -792,3 +797,3 @@ | ||
const url = `indexes/${this.uid}/settings/searchable-attributes` | ||
return await this.httpRequest.post(url, searchableAttributes) | ||
return await this.httpRequest.put(url, searchableAttributes) | ||
} | ||
@@ -833,3 +838,3 @@ | ||
const url = `indexes/${this.uid}/settings/displayed-attributes` | ||
return await this.httpRequest.post(url, displayedAttributes) | ||
return await this.httpRequest.put(url, displayedAttributes) | ||
} | ||
@@ -874,3 +879,3 @@ | ||
const url = `indexes/${this.uid}/settings/typo-tolerance` | ||
return await this.httpRequest.post(url, typoTolerance) | ||
return await this.httpRequest.patch(url, typoTolerance) | ||
} | ||
@@ -877,0 +882,0 @@ |
105
src/task.ts
import { MeiliSearchTimeOutError } from './errors' | ||
import { Config, Task, WaitOptions, TaskStatus, Result } from './types' | ||
import { | ||
Config, | ||
Task, | ||
WaitOptions, | ||
TaskStatus, | ||
TasksQuery, | ||
TasksResults, | ||
} from './types' | ||
import { HttpRequests } from './http-requests' | ||
import { sleep } from './utils' | ||
import { removeUndefinedFromObject, sleep } from './utils' | ||
@@ -13,3 +20,10 @@ class TaskClient { | ||
async getClientTask(uid: string | number): Promise<Task> { | ||
/** | ||
* Get one task | ||
* | ||
* @param {number} uid - unique identifier of the task | ||
* | ||
* @returns { Promise<Task> } | ||
*/ | ||
async getTask(uid: number): Promise<Task> { | ||
const url = `tasks/${uid}` | ||
@@ -19,15 +33,24 @@ return await this.httpRequest.get<Task>(url) | ||
async getClientTasks(): Promise<Result<Task[]>> { | ||
/** | ||
* Get tasks | ||
* | ||
* @param {TasksQuery} [parameters={}] - Parameters to browse the tasks | ||
* | ||
* @returns {Promise<TasksResults>} - Promise containing all tasks | ||
*/ | ||
async getTasks(parameters: TasksQuery = {}): Promise<TasksResults> { | ||
const url = `tasks` | ||
return await this.httpRequest.get<Result<Task[]>>(url) | ||
} | ||
async getIndexTask(indexUid: string | number, taskId: number): Promise<Task> { | ||
const url = `indexes/${indexUid}/tasks/${taskId}` | ||
return await this.httpRequest.get<Task>(url) | ||
} | ||
const queryParams = { | ||
indexUid: parameters?.indexUid?.join(','), | ||
type: parameters?.type?.join(','), | ||
status: parameters?.status?.join(','), | ||
from: parameters.from, | ||
limit: parameters.limit, | ||
} | ||
async getIndexTasks(indexUid: string | number): Promise<Result<Task[]>> { | ||
const url = `indexes/${indexUid}/tasks` | ||
return await this.httpRequest.get<Result<Task[]>>(url) | ||
return await this.httpRequest.get<Promise<TasksResults>>( | ||
url, | ||
removeUndefinedFromObject(queryParams) | ||
) | ||
} | ||
@@ -38,8 +61,9 @@ | ||
* | ||
* @param {number} uid Task identifier | ||
* @param {number} taskUid Task identifier | ||
* @param {WaitOptions} options Additional configuration options | ||
* | ||
* @returns {Promise<Task>} Promise returning a task after it has been processed | ||
*/ | ||
async waitForClientTask( | ||
taskId: number, | ||
async waitForTask( | ||
taskUid: number, | ||
{ timeOutMs = 5000, intervalMs = 50 }: WaitOptions = {} | ||
@@ -49,3 +73,3 @@ ): Promise<Task> { | ||
while (Date.now() - startingTime < timeOutMs) { | ||
const response = await this.getClientTask(taskId) | ||
const response = await this.getTask(taskUid) | ||
if ( | ||
@@ -60,3 +84,3 @@ ![TaskStatus.TASK_ENQUEUED, TaskStatus.TASK_PROCESSING].includes( | ||
throw new MeiliSearchTimeOutError( | ||
`timeout of ${timeOutMs}ms has exceeded on process ${taskId} when waiting a task to be resolved.` | ||
`timeout of ${timeOutMs}ms has exceeded on process ${taskUid} when waiting a task to be resolved.` | ||
) | ||
@@ -68,13 +92,14 @@ } | ||
* | ||
* @param {number} taskIds Tasks identifier list | ||
* @param {number[]} taskUids Tasks identifier list | ||
* @param {WaitOptions} options Wait options | ||
* @returns {Promise<Result<Task[]>>} Promise returning a list of tasks after they have been processed | ||
* | ||
* @returns {Promise<Task[]>} Promise returning a list of tasks after they have been processed | ||
*/ | ||
async waitForClientTasks( | ||
taskIds: number[], | ||
async waitForTasks( | ||
taskUids: number[], | ||
{ timeOutMs = 5000, intervalMs = 50 }: WaitOptions = {} | ||
): Promise<Result<Task[]>> { | ||
): Promise<Task[]> { | ||
const tasks: Task[] = [] | ||
for (const taskId of taskIds) { | ||
const task = await this.waitForClientTask(taskId, { | ||
for (const taskUid of taskUids) { | ||
const task = await this.waitForTask(taskUid, { | ||
timeOutMs, | ||
@@ -85,34 +110,6 @@ intervalMs, | ||
} | ||
return { results: tasks } | ||
return tasks | ||
} | ||
/** | ||
* Waits for a task to be processed | ||
* | ||
* @param {number} taskId Task identifier | ||
* @param {WaitOptions} options Wait options | ||
* @returns {Promise<Task>} Promise returning a task after it has been processed | ||
*/ | ||
async waitForIndexTask( | ||
indexUid: number | string, | ||
taskId: number, | ||
{ timeOutMs = 5000, intervalMs = 50 }: WaitOptions = {} | ||
): Promise<Task> { | ||
const startingTime = Date.now() | ||
while (Date.now() - startingTime < timeOutMs) { | ||
const response = await this.getIndexTask(indexUid, taskId) | ||
if ( | ||
![TaskStatus.TASK_ENQUEUED, TaskStatus.TASK_PROCESSING].includes( | ||
response.status | ||
) | ||
) | ||
return response | ||
await sleep(intervalMs) | ||
} | ||
throw new MeiliSearchTimeOutError( | ||
`timeout of ${timeOutMs}ms has exceeded on process ${taskId} when waiting for pending update to resolve.` | ||
) | ||
} | ||
} | ||
export { TaskClient } |
import { Config, TokenSearchRules, TokenOptions } from './types' | ||
import crypto from 'crypto' | ||
import { MeiliSearchError } from './errors' | ||
import { validateUuid4 } from './utils' | ||
@@ -45,17 +47,22 @@ function encode64(data: any) { | ||
* @param {String} apiKey Api key used as issuer of the token. | ||
* @param {String} uid The uid of the api key used as issuer of the token. | ||
* @param {Date | undefined} expiresAt Date at which the token expires. | ||
*/ | ||
function validatePayload(payloadParams: { | ||
function validateTokenParameters(tokenParams: { | ||
searchRules: TokenSearchRules | ||
uid: string | ||
apiKey: string | ||
expiresAt?: Date | ||
}) { | ||
const { searchRules, apiKey, expiresAt } = payloadParams | ||
const error = new Error() | ||
const { searchRules, uid, apiKey, expiresAt } = tokenParams | ||
if (expiresAt) { | ||
if (!(expiresAt instanceof Date) || expiresAt.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 ${error.stack}.` | ||
if (!(expiresAt instanceof Date)) { | ||
throw new MeiliSearchError( | ||
`Meilisearch: The expiredAt field must be an instance of Date.` | ||
) | ||
} else if (expiresAt.getTime() < Date.now()) { | ||
throw new MeiliSearchError( | ||
`Meilisearch: The expiresAt field must be a date in the future.` | ||
) | ||
} | ||
@@ -66,4 +73,4 @@ } | ||
if (!(typeof searchRules === 'object' || Array.isArray(searchRules))) { | ||
throw new Error( | ||
`Meilisearch: The search rules added in the token generation must be of type array or object. \n ${error.stack}.` | ||
throw new MeiliSearchError( | ||
`Meilisearch: The search rules added in the token generation must be of type array or object.` | ||
) | ||
@@ -74,6 +81,18 @@ } | ||
if (!apiKey || typeof apiKey !== 'string') { | ||
throw new Error( | ||
`Meilisearch: The API key used for the token generation must exist and be of type string. \n ${error.stack}.` | ||
throw new MeiliSearchError( | ||
`Meilisearch: The API key used for the token generation must exist and be of type string.` | ||
) | ||
} | ||
if (!uid || typeof uid !== 'string') { | ||
throw new MeiliSearchError( | ||
`Meilisearch: The uid of the api key used for the token generation must exist, be of type string and comply to the uuid4 format.` | ||
) | ||
} | ||
if (!validateUuid4(uid)) { | ||
throw new MeiliSearchError( | ||
`Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().` | ||
) | ||
} | ||
} | ||
@@ -85,3 +104,3 @@ | ||
* @param {SearchRules} searchRules Search rules that are applied to every search. | ||
* @param {String} apiKey Api key used as issuer of the token. | ||
* @param {String} uid The uid of the api key used as issuer of the token. | ||
* @param {Date | undefined} expiresAt Date at which the token expires. | ||
@@ -92,10 +111,10 @@ * @returns {String} The payload encoded in base64. | ||
searchRules: TokenSearchRules | ||
apiKey: string | ||
uid: string | ||
expiresAt?: Date | ||
}): string { | ||
const { searchRules, apiKey, expiresAt } = payloadParams | ||
validatePayload(payloadParams) | ||
const { searchRules, uid, expiresAt } = payloadParams | ||
const payload = { | ||
searchRules, | ||
apiKeyPrefix: apiKey.substring(0, 8), | ||
apiKeyUid: uid, | ||
exp: expiresAt?.getTime(), | ||
@@ -119,7 +138,10 @@ } | ||
* @method generateTenantToken | ||
* @param {apiKeyUid} apiKeyUid The uid of the api key used as issuer of the token. | ||
* @param {SearchRules} searchRules Search rules that are applied to every search. | ||
* @param {TokenOptions} options Token options to customize some aspect of the token. | ||
* | ||
* @returns {String} The token in JWT format. | ||
*/ | ||
generateTenantToken( | ||
apiKeyUid: string, | ||
searchRules: TokenSearchRules, | ||
@@ -129,6 +151,9 @@ options?: TokenOptions | ||
const apiKey = options?.apiKey || this.config.apiKey || '' | ||
const uid = apiKeyUid || '' | ||
const expiresAt = options?.expiresAt | ||
validateTokenParameters({ apiKey, uid, expiresAt, searchRules }) | ||
const encodedHeader = createHeader() | ||
const encodedPayload = createPayload({ searchRules, apiKey, expiresAt }) | ||
const encodedPayload = createPayload({ searchRules, uid, expiresAt }) | ||
const signature = sign(apiKey, encodedHeader, encodedPayload) | ||
@@ -135,0 +160,0 @@ |
@@ -10,18 +10,26 @@ // Type definitions for meilisearch | ||
apiKey?: string | ||
headers?: object | ||
clientAgents?: string[] | ||
headers?: Record<string, any> | ||
} | ||
export type Result<T> = { | ||
/// | ||
/// Resources | ||
/// | ||
export type Pagination = { | ||
offset?: number | ||
limit?: number | ||
} | ||
export type ResourceQuery = Pagination & {} | ||
export type ResourceResults<T> = Pagination & { | ||
results: T | ||
total: number | ||
} | ||
/// | ||
/// Request specific interfaces | ||
/// Indexes | ||
/// | ||
export type IndexRequest = { | ||
uid: string | ||
primaryKey?: string | ||
} | ||
export type IndexOptions = { | ||
@@ -31,5 +39,4 @@ primaryKey?: string | ||
export type IndexResponse = { | ||
export type IndexObject = { | ||
uid: string | ||
name?: string | ||
primaryKey?: string | ||
@@ -40,6 +47,6 @@ createdAt: Date | ||
export type AddDocumentParams = { | ||
primaryKey?: string | ||
} | ||
export type IndexesQuery = ResourceQuery & {} | ||
export type IndexesResults<T> = ResourceResults<T> & {} | ||
/* | ||
@@ -51,7 +58,2 @@ * SEARCH PARAMETERS | ||
export type Pagination = { | ||
offset?: number | ||
limit?: number | ||
} | ||
export type Query = { | ||
@@ -79,5 +81,5 @@ q?: string | null | ||
sort?: string[] | ||
facetsDistribution?: string[] | ||
facets?: string[] | ||
attributesToRetrieve?: string[] | ||
matches?: boolean | ||
showMatchesPosition?: boolean | ||
} | ||
@@ -93,7 +95,7 @@ | ||
sort?: string | ||
facetsDistribution?: string | ||
facets?: string | ||
attributesToRetrieve?: string | ||
attributesToHighlight?: string | ||
attributesToCrop?: string | ||
matches?: boolean | ||
showMatchesPosition?: boolean | ||
} | ||
@@ -111,12 +113,8 @@ | ||
export type document = { | ||
[field: string]: any | ||
} | ||
export type Hit<T = document> = T & { | ||
export type Hit<T = Record<string, any>> = T & { | ||
_formatted?: Partial<T> | ||
_matchesInfo?: _matchesInfo<T> | ||
_matchesPosition?: _matchesInfo<T> | ||
} | ||
export type Hits<T = document> = Array<Hit<T>> | ||
export type Hits<T = Record<string, any>> = Array<Hit<T>> | ||
@@ -128,7 +126,5 @@ export type SearchResponse<T = Record<string, any>> = { | ||
processingTimeMs: number | ||
facetsDistribution?: FacetsDistribution | ||
exhaustiveFacetsCount?: boolean | ||
facetDistribution?: FacetsDistribution | ||
query: string | ||
nbHits: number | ||
exhaustiveNbHits: boolean | ||
estimatedTotalHits: number | ||
} | ||
@@ -143,14 +139,18 @@ | ||
*/ | ||
export type GetDocumentsParams<T = Record<string, any>> = { | ||
offset?: number | ||
limit?: number | ||
attributesToRetrieve?: | ||
| Array<Extract<keyof T, string>> | ||
| Extract<keyof T, string> | ||
export type DocumentOptions = { | ||
primaryKey?: string | ||
} | ||
export type GetDocumentsResponse<T = Record<string, any>> = Array<Document<T>> | ||
export type DocumentsQuery<T = Record<string, any>> = ResourceQuery & { | ||
fields?: Array<Extract<keyof T, string>> | Extract<keyof T, string> | ||
} | ||
export type Document<T = Record<string, any>> = T | ||
export type Documents<T = Record<string, any>> = Array<Document<T>> | ||
export type DocumentsResults<T = Record<string, any>> = ResourceResults< | ||
Documents<T> | ||
> & {} | ||
/* | ||
@@ -172,3 +172,3 @@ ** Settings | ||
enabled?: boolean | null | ||
disableOnAttributes?: string[] | null | ||
disabledOnAttributes?: string[] | null | ||
disableOnWords?: string[] | null | ||
@@ -181,2 +181,9 @@ minWordSizeForTypos?: { | ||
export type Faceting = { | ||
maxValuesPerFacet?: number | null | ||
} | ||
export type PaginationSettings = { | ||
maxTotalHits?: number | null | ||
} | ||
export type Settings = { | ||
@@ -192,2 +199,4 @@ filterableAttributes?: FilterableAttributes | ||
typoTolerance?: TypoTolerance | ||
faceting?: Faceting | ||
pagination?: PaginationSettings | ||
} | ||
@@ -206,14 +215,30 @@ | ||
export const enum TaskTypes { | ||
INDEX_CREATION = 'indexCreation', | ||
INDEX_UPDATE = 'indexUpdate', | ||
INDEX_DELETION = 'indexDeletion', | ||
DOCUMENTS_ADDITION_OR_UPDATE = 'documentAdditionOrUpdate', | ||
DOCUMENT_DELETION = 'documentDeletion', | ||
SETTINGS_UPDATE = 'settingsUpdate', | ||
} | ||
export type TasksQuery = { | ||
indexUid?: string[] | ||
type?: TaskTypes[] | ||
status?: TaskStatus[] | ||
limit?: number | ||
from?: number | ||
} | ||
export type EnqueuedTask = { | ||
uid: number | ||
indexUid: string | ||
taskUid: number | ||
indexUid?: string | ||
status: TaskStatus | ||
type: string | ||
type: TaskTypes | ||
enqueuedAt: string | ||
} | ||
export type Task = { | ||
status: TaskStatus | ||
export type Task = Omit<EnqueuedTask, 'taskUid'> & { | ||
uid: number | ||
type: string | ||
batchUid: number | ||
details: { | ||
@@ -256,11 +281,4 @@ // Number of documents sent | ||
} | ||
error?: MeiliSearchErrorInfo | ||
duration: string | ||
enqueuedAt: string | ||
processedAt: string | ||
error?: MeiliSearchErrorInfo | ||
} | ||
export type EnqueuedDump = { | ||
uid: string | ||
status: 'in_progress' | 'failed' | 'done' | ||
startedAt: string | ||
@@ -270,2 +288,9 @@ finishedAt: string | ||
export type TasksResults = { | ||
results: Task[] | ||
limit: number | ||
from: number | ||
next: number | ||
} | ||
export type WaitOptions = { | ||
@@ -307,3 +332,5 @@ timeOutMs?: number | ||
export type Key = { | ||
uid: string | ||
description: string | ||
name: string | null | ||
key: string | ||
@@ -317,3 +344,5 @@ actions: string[] | ||
export type KeyPayload = { | ||
export type KeyCreation = { | ||
uid?: string | ||
name?: string | ||
description?: string | ||
@@ -325,2 +354,11 @@ actions: string[] | ||
export type KeyUpdate = { | ||
name?: string | ||
description?: string | ||
} | ||
export type KeysQuery = ResourceQuery & {} | ||
export type KeysResults = ResourceResults<Key[]> & {} | ||
/* | ||
@@ -464,5 +502,2 @@ ** version | ||
/** @see https://docs.meilisearch.com/errors/#dump_already_processing */ | ||
DUMP_ALREADY_PROCESSING = 'dump_already_processing', | ||
/** @see https://docs.meilisearch.com/errors/#dump_process_failed */ | ||
@@ -469,0 +504,0 @@ DUMP_PROCESS_FAILED = 'dump_process_failed', |
@@ -30,2 +30,7 @@ /** | ||
function validateUuid4(uuid: string): boolean { | ||
const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi | ||
return regexExp.test(uuid) | ||
} | ||
export { | ||
@@ -36,2 +41,3 @@ sleep, | ||
addTrailingSlash, | ||
validateUuid4, | ||
} |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
624576
69
13423
671