meilisearch
Advanced tools
Comparing version 0.14.2 to 0.15.0
@@ -107,7 +107,6 @@ # Contributing | ||
The draft PR can be very useful if you want to show that you are working on something and make your work visible. | ||
- The branch related to the PR must be **up-to-date with `master`** before merging. You need to [rebase your branch](https://gist.github.com/curquiza/5f7ce615f85331f083cd467fc4e19398) if it is not. | ||
- The branch related to the PR must be **up-to-date with `master`** before merging. [Bors](https://github.com/bors-ng/bors-ng) will rebase your branch if it is not. Ask a maintainer to run it. | ||
- All PRs must be reviewed and approved by at least one maintainer. | ||
- All PRs have to be **squashed and merged**. | ||
- The PR title should be accurate and descriptive of the changes. The title of the PR will be indeed automatically added to the next [release changlogs](https://github.com/meilisearch/meilisearch-js/releases/). | ||
- The PR title should be accurate and descriptive of the changes. The title of the PR will be indeed automatically added to the next [release changelogs](https://github.com/meilisearch/meilisearch-js/releases/). | ||
Thank you again for reading this through, we can not wait to begin to work with you if you made your way through this contributing guide ❤️ |
@@ -87,3 +87,5 @@ import 'cross-fetch/polyfill'; | ||
_this.type = 'MeiliSearchError'; | ||
Error.captureStackTrace(_this, MeiliSearchError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_this, MeiliSearchError); | ||
} | ||
return _this; | ||
@@ -100,3 +102,5 @@ } | ||
_this.type = _this.constructor.name; | ||
Error.captureStackTrace(_this, MeiliSearchTimeOutError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_this, MeiliSearchTimeOutError); | ||
} | ||
return _this; | ||
@@ -143,3 +147,5 @@ } | ||
} | ||
Error.captureStackTrace(_this, MeiliSearchCommunicationError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_this, MeiliSearchCommunicationError); | ||
} | ||
return _this; | ||
@@ -161,3 +167,5 @@ } | ||
_this.httpStatus = status; | ||
Error.captureStackTrace(_this, MeiliSearchApiError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_this, MeiliSearchApiError); | ||
} | ||
return _this; | ||
@@ -393,3 +401,3 @@ } | ||
*/ | ||
Index.prototype.search = function (query, options, method) { | ||
Index.prototype.search = function (query, options, method, config) { | ||
if (method === void 0) { method = 'POST'; } | ||
@@ -416,3 +424,3 @@ return __awaiter(this, void 0, void 0, function () { | ||
if (!(method.toUpperCase() === 'POST')) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, this.httpRequest.post(url, removeUndefinedFromObject(params))]; | ||
return [4 /*yield*/, this.httpRequest.post(url, removeUndefinedFromObject(params), undefined, config)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
@@ -428,3 +436,3 @@ case 2: | ||
: undefined }); | ||
return [4 /*yield*/, this.httpRequest.get(url, removeUndefinedFromObject(getParams))]; | ||
return [4 /*yield*/, this.httpRequest.get(url, removeUndefinedFromObject(getParams), config)]; | ||
case 3: return [2 /*return*/, _a.sent()]; | ||
@@ -1217,3 +1225,4 @@ case 4: throw new MeiliSearchError('method parameter should be either POST or GET'); | ||
/** | ||
* Check if the server is healhty | ||
* Checks if the server is healthy, otherwise an error will be thrown. | ||
* | ||
* @memberof MeiliSearch | ||
@@ -1220,0 +1229,0 @@ * @method isHealthy |
@@ -15,3 +15,3 @@ import"cross-fetch/polyfill"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};function e(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,n,r){return new(n||(n=Promise))((function(i,s){function u(t){try{c(r.next(t))}catch(t){s(t)}}function o(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(u,o)}c((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:s[1],done:!1};case 5:u.label++,r=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=e.call(t,u)}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,o])}}}var s=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),u=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace(r,n),r}return e(n,t),n}(Error);function o(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 c(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var a=function(t){function n(e,r){var i=t.call(this,e)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",r instanceof Response&&(i.message=r.statusText,i.statusCode=r.status),r instanceof Error&&(i.errno=r.errno,i.code=r.code),Error.captureStackTrace(i,n),i}return e(n,t),n}(Error),h=function(t){function n(e,n){var r=t.call(this,e.message)||this;return r.type="MeiliSearchApiError",r.name="MeiliSearchApiError",r.errorCode=e.errorCode,r.errorType=e.errorType,r.errorLink=e.errorLink,r.message=e.message,r.httpStatus=n,Error.captureStackTrace(r,h),r}return e(n,t),n}(Error);var d=function(){function t(t){this.headers=n(n(n({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=t.host}return t.prototype.request=function(t){var e=t.method,s=t.url,u=t.params,o=t.body,c=t.config;return r(this,void 0,void 0,(function(){var t,d,p;return i(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),(t=new URL(this.url)).pathname=t.pathname+s,u&&(d=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return d.set(t,u[t])})),t.search=d.toString()),[4,fetch(t.toString(),n(n({},c),{method:e,body:o?JSON.stringify(o):void 0,headers:this.headers})).then((function(t){return function(t){return r(this,void 0,void 0,(function(){var e;return i(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 a(t.statusText,t);case 4:throw new h(e,t.status);case 5:return[2,t]}}))}))}(t)}))];case 1:return[4,l.sent().text()];case 2:p=l.sent();try{return[2,JSON.parse(p)]}catch(t){return[2]}return[3,4];case 3:return function(t){if("MeiliSearchApiError"!==t.type)throw new a(t.message,t);throw t}(l.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,n){return r(this,void 0,void 0,(function(){return i(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,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t.prototype.put=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t.prototype.delete=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t}(),p=function(){function t(t,e){this.uid=e,this.httpRequest=new d(t)}return t.prototype.getUpdateStatus=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,s=n.timeOutMs,o=void 0===s?5e3:s,a=n.intervalMs,h=void 0===a?50:a;return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<o?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,c(h)];case 3:return r.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.getAllUpdateStatus=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.search=function(t,e,u){return void 0===u&&(u="POST"),r(this,void 0,void 0,(function(){var r,c,a;return i(this,(function(i){switch(i.label){case 0:return r="/indexes/"+this.uid+"/search",c={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==u.toUpperCase()?[3,2]:[4,this.httpRequest.post(r,o(c))];case 1:return[2,i.sent()];case 2:return"GET"!==u.toUpperCase()?[3,4]:(a=n(n({},c),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(r,o(a))]);case 3:return[2,i.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},t.prototype.show=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateIndex=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return r(this,void 0,void 0,(function(){var e,r;return i(this,(function(i){switch(i.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(r=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,n(n({},t),void 0!==r?{attributesToRetrieve:r}:{}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.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 i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateAttributesForFaceting=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),l=function(){function t(t){this.config=t,this.httpRequest=new d(t)}return t.prototype.getIndex=function(t){return new p(this.config,t)},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw new h(n,n.status);case 3:return[2]}}))}))},t.prototype.listIndexes=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.httpRequest.get("/indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return"/indexes",[4,this.httpRequest.post("/indexes",n(n({},e),{uid:t}))];case 1:return r=i.sent(),[2,new p(this.config,r.uid)]}}))}))},t.prototype.getKeys=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.httpRequest.get("/keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},t.prototype.setHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.setUnhealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},t.prototype.changeHealthTo=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},t.prototype.stats=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.httpRequest.get("/stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.version=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/version",[4,this.httpRequest.get("/version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t}();export default l; | ||
***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};function e(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,n,r){return new(n||(n=Promise))((function(i,s){function u(t){try{c(r.next(t))}catch(t){s(t)}}function o(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(u,o)}c((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:s[1],done:!1};case 5:u.label++,r=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=e.call(t,u)}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,o])}}}var s=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),u=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(r,n),r}return e(n,t),n}(Error);function o(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 c(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var a=function(t){function n(e,r){var i=t.call(this,e)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",r instanceof Response&&(i.message=r.statusText,i.statusCode=r.status),r instanceof Error&&(i.errno=r.errno,i.code=r.code),Error.captureStackTrace&&Error.captureStackTrace(i,n),i}return e(n,t),n}(Error),h=function(t){function n(e,n){var r=t.call(this,e.message)||this;return r.type="MeiliSearchApiError",r.name="MeiliSearchApiError",r.errorCode=e.errorCode,r.errorType=e.errorType,r.errorLink=e.errorLink,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,h),r}return e(n,t),n}(Error);var d=function(){function t(t){this.headers=n(n(n({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=t.host}return t.prototype.request=function(t){var e=t.method,s=t.url,u=t.params,o=t.body,c=t.config;return r(this,void 0,void 0,(function(){var t,d,p;return i(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),(t=new URL(this.url)).pathname=t.pathname+s,u&&(d=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return d.set(t,u[t])})),t.search=d.toString()),[4,fetch(t.toString(),n(n({},c),{method:e,body:o?JSON.stringify(o):void 0,headers:this.headers})).then((function(t){return function(t){return r(this,void 0,void 0,(function(){var e;return i(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 a(t.statusText,t);case 4:throw new h(e,t.status);case 5:return[2,t]}}))}))}(t)}))];case 1:return[4,l.sent().text()];case 2:p=l.sent();try{return[2,JSON.parse(p)]}catch(t){return[2]}return[3,4];case 3:return function(t){if("MeiliSearchApiError"!==t.type)throw new a(t.message,t);throw t}(l.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,n){return r(this,void 0,void 0,(function(){return i(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,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t.prototype.put=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t.prototype.delete=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t}(),p=function(){function t(t,e){this.uid=e,this.httpRequest=new d(t)}return t.prototype.getUpdateStatus=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,s=n.timeOutMs,o=void 0===s?5e3:s,a=n.intervalMs,h=void 0===a?50:a;return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<o?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,c(h)];case 3:return r.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.getAllUpdateStatus=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.search=function(t,e,u,c){return void 0===u&&(u="POST"),r(this,void 0,void 0,(function(){var r,a,h;return i(this,(function(i){switch(i.label){case 0:return r="/indexes/"+this.uid+"/search",a={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==u.toUpperCase()?[3,2]:[4,this.httpRequest.post(r,o(a),void 0,c)];case 1:return[2,i.sent()];case 2:return"GET"!==u.toUpperCase()?[3,4]:(h=n(n({},a),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(r,o(h),c)]);case 3:return[2,i.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},t.prototype.show=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateIndex=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return r(this,void 0,void 0,(function(){var e,r;return i(this,(function(i){switch(i.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(r=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,n(n({},t),void 0!==r?{attributesToRetrieve:r}:{}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.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 i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateAttributesForFaceting=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),l=function(){function t(t){this.config=t,this.httpRequest=new d(t)}return t.prototype.getIndex=function(t){return new p(this.config,t)},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw new h(n,n.status);case 3:return[2]}}))}))},t.prototype.listIndexes=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.httpRequest.get("/indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return"/indexes",[4,this.httpRequest.post("/indexes",n(n({},e),{uid:t}))];case 1:return r=i.sent(),[2,new p(this.config,r.uid)]}}))}))},t.prototype.getKeys=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.httpRequest.get("/keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},t.prototype.setHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.setUnhealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},t.prototype.changeHealthTo=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},t.prototype.stats=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.httpRequest.get("/stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.version=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/version",[4,this.httpRequest.get("/version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t}();export default l; | ||
//# sourceMappingURL=meilisearch.esm.min.js.map |
@@ -95,3 +95,7 @@ (function (global, factory) { | ||
_this.type = 'MeiliSearchError'; | ||
Error.captureStackTrace(_this, MeiliSearchError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_this, MeiliSearchError); | ||
} | ||
return _this; | ||
@@ -113,3 +117,7 @@ } | ||
_this.type = _this.constructor.name; | ||
Error.captureStackTrace(_this, MeiliSearchTimeOutError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_this, MeiliSearchTimeOutError); | ||
} | ||
return _this; | ||
@@ -175,3 +183,6 @@ } | ||
Error.captureStackTrace(_this, MeiliSearchCommunicationError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_this, MeiliSearchCommunicationError); | ||
} | ||
return _this; | ||
@@ -198,3 +209,7 @@ } | ||
_this.httpStatus = status; | ||
Error.captureStackTrace(_this, MeiliSearchApiError); | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(_this, MeiliSearchApiError); | ||
} | ||
return _this; | ||
@@ -566,3 +581,3 @@ } | ||
Index.prototype.search = function (query, options, method) { | ||
Index.prototype.search = function (query, options, method, config) { | ||
if (method === void 0) { | ||
@@ -596,3 +611,3 @@ method = 'POST'; | ||
/*yield*/ | ||
, this.httpRequest.post(url, removeUndefinedFromObject(params))]; | ||
, this.httpRequest.post(url, removeUndefinedFromObject(params), undefined, config)]; | ||
@@ -617,3 +632,3 @@ case 1: | ||
/*yield*/ | ||
, this.httpRequest.get(url, removeUndefinedFromObject(getParams))]; | ||
, this.httpRequest.get(url, removeUndefinedFromObject(getParams), config)]; | ||
@@ -1750,3 +1765,4 @@ case 3: | ||
/** | ||
* Check if the server is healhty | ||
* Checks if the server is healthy, otherwise an error will be thrown. | ||
* | ||
* @memberof MeiliSearch | ||
@@ -1753,0 +1769,0 @@ * @method isHealthy |
@@ -15,3 +15,3 @@ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("cross-fetch/polyfill")):"function"==typeof define&&define.amd?define(["cross-fetch/polyfill"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).MeiliSearch=e()}(this,(function(){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};function e(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var n=function(){return(n=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 i(t,e,n,i){return new(n||(n=Promise))((function(r,s){function u(t){try{c(i.next(t))}catch(t){s(t)}}function o(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(u,o)}c((i=i.apply(t,e||[])).next())}))}function r(t,e){var n,i,r,s,u={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:s[1],done:!1};case 5:u.label++,i=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(r=u.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){u.label=s[1];break}if(6===s[0]&&u.label<r[1]){u.label=r[1],r=s;break}if(r&&u.label<r[2]){u.label=r[2],u.ops.push(s);break}r[2]&&u.ops.pop(),u.trys.pop();continue}s=e.call(t,u)}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,o])}}}var s=function(t){function n(e){var i=t.call(this,e)||this;return i.name="MeiliSearchError",i.type="MeiliSearchError",Error.captureStackTrace(i,n),i}return e(n,t),n}(Error),u=function(t){function n(e){var i=t.call(this,e)||this;return i.name="MeiliSearchTimeOutError",i.type=i.constructor.name,Error.captureStackTrace(i,n),i}return e(n,t),n}(Error);function o(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 c(t){return i(this,void 0,void 0,(function(){return r(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 a=function(t){function n(e,i){var r=t.call(this,e)||this;return r.name="MeiliSearchCommunicationError",r.type="MeiliSearchCommunicationError",i instanceof Response&&(r.message=i.statusText,r.statusCode=i.status),i instanceof Error&&(r.errno=i.errno,r.code=i.code),Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),h=function(t){function n(e,n){var i=t.call(this,e.message)||this;return i.type="MeiliSearchApiError",i.name="MeiliSearchApiError",i.errorCode=e.errorCode,i.errorType=e.errorType,i.errorLink=e.errorLink,i.message=e.message,i.httpStatus=n,Error.captureStackTrace(i,h),i}return e(n,t),n}(Error);var d=function(){function t(t){this.headers=n(n(n({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=t.host}return t.prototype.request=function(t){var e=t.method,s=t.url,u=t.params,o=t.body,c=t.config;return i(this,void 0,void 0,(function(){var t,d,l;return r(this,(function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),(t=new URL(this.url)).pathname=t.pathname+s,u&&(d=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return d.set(t,u[t])})),t.search=d.toString()),[4,fetch(t.toString(),n(n({},c),{method:e,body:o?JSON.stringify(o):void 0,headers:this.headers})).then((function(t){return function(t){return i(this,void 0,void 0,(function(){var e;return r(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 a(t.statusText,t);case 4:throw new h(e,t.status);case 5:return[2,t]}}))}))}(t)}))];case 1:return[4,p.sent().text()];case 2:l=p.sent();try{return[2,JSON.parse(l)]}catch(t){return[2]}return[3,4];case 3:return function(t){if("MeiliSearchApiError"!==t.type)throw new a(t.message,t);throw t}(p.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return r(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,s){return i(this,void 0,void 0,(function(){return r(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:s})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,s){return i(this,void 0,void 0,(function(){return r(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:s})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,s){return i(this,void 0,void 0,(function(){return r(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:s})];case 1:return[2,i.sent()]}}))}))},t}(),l=function(){function t(t,e){this.uid=e,this.httpRequest=new d(t)}return t.prototype.getUpdateStatus=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,s=n.timeOutMs,o=void 0===s?5e3:s,a=n.intervalMs,h=void 0===a?50:a;return i(this,void 0,void 0,(function(){var e,n;return r(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<o?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=i.sent()).status?[2,n]:[4,c(h)];case 3:return i.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.getAllUpdateStatus=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.search=function(t,e,u){return void 0===u&&(u="POST"),i(this,void 0,void 0,(function(){var i,c,a;return r(this,(function(r){switch(r.label){case 0:return i="/indexes/"+this.uid+"/search",c={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==u.toUpperCase()?[3,2]:[4,this.httpRequest.post(i,o(c))];case 1:return[2,r.sent()];case 2:return"GET"!==u.toUpperCase()?[3,4]:(a=n(n({},c),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(i,o(a))]);case 3:return[2,r.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},t.prototype.show=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateIndex=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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,i;return r(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(i=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,n(n({},t),void 0!==i?{attributesToRetrieve:i}:{}))];case 1:return[2,r.sent()]}}))}))},t.prototype.getDocument=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+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 r(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.httpRequest.post(n,t,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return r(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.httpRequest.put(n,t,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+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 r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getAttributesForFaceting=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateAttributesForFaceting=function(t){return i(this,void 0,void 0,(function(){var e;return r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetAttributesForFaceting=function(){return i(this,void 0,void 0,(function(){var t;return r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 r(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 r(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}();return function(){function t(t){this.config=t,this.httpRequest=new d(t)}return t.prototype.getIndex=function(t){return new l(this.config,t)},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var n;return r(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,i.sent()];case 2:if("index_already_exists"===(n=i.sent()).errorCode)return[2,this.getIndex(t)];throw new h(n,n.status);case 3:return[2]}}))}))},t.prototype.listIndexes=function(){return i(this,void 0,void 0,(function(){return r(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(){var i;return r(this,(function(r){switch(r.label){case 0:return"/indexes",[4,this.httpRequest.post("/indexes",n(n({},e),{uid:t}))];case 1:return i=r.sent(),[2,new l(this.config,i.uid)]}}))}))},t.prototype.getKeys=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.httpRequest.get("/keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},t.prototype.setHealthy=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.setUnhealthy=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},t.prototype.changeHealthTo=function(t){return i(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},t.prototype.stats=function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.httpRequest.get("/stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.version=function(){return i(this,void 0,void 0,(function(){return r(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 r(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 r(this,(function(n){switch(n.label){case 0:return e="/dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t}()})); | ||
***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(e,n)};function e(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var n=function(){return(n=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function r(t,e,n,r){return new(n||(n=Promise))((function(i,s){function u(t){try{c(r.next(t))}catch(t){s(t)}}function o(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(u,o)}c((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,i,s,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(s){return function(o){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;u;)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 u.label++,{value:s[1],done:!1};case 5:u.label++,r=s[1],s=[0];continue;case 7:s=u.ops.pop(),u.trys.pop();continue;default:if(!(i=u.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){u=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){u.label=s[1];break}if(6===s[0]&&u.label<i[1]){u.label=i[1],i=s;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(s);break}i[2]&&u.ops.pop(),u.trys.pop();continue}s=e.call(t,u)}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,o])}}}var s=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,n),r}return e(n,t),n}(Error),u=function(t){function n(e){var r=t.call(this,e)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(r,n),r}return e(n,t),n}(Error);function o(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 c(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var a=function(t){function n(e,r){var i=t.call(this,e)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",r instanceof Response&&(i.message=r.statusText,i.statusCode=r.status),r instanceof Error&&(i.errno=r.errno,i.code=r.code),Error.captureStackTrace&&Error.captureStackTrace(i,n),i}return e(n,t),n}(Error),h=function(t){function n(e,n){var r=t.call(this,e.message)||this;return r.type="MeiliSearchApiError",r.name="MeiliSearchApiError",r.errorCode=e.errorCode,r.errorType=e.errorType,r.errorLink=e.errorLink,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,h),r}return e(n,t),n}(Error);var d=function(){function t(t){this.headers=n(n(n({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=t.host}return t.prototype.request=function(t){var e=t.method,s=t.url,u=t.params,o=t.body,c=t.config;return r(this,void 0,void 0,(function(){var t,d,p;return i(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),(t=new URL(this.url)).pathname=t.pathname+s,u&&(d=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return d.set(t,u[t])})),t.search=d.toString()),[4,fetch(t.toString(),n(n({},c),{method:e,body:o?JSON.stringify(o):void 0,headers:this.headers})).then((function(t){return function(t){return r(this,void 0,void 0,(function(){var e;return i(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 a(t.statusText,t);case 4:throw new h(e,t.status);case 5:return[2,t]}}))}))}(t)}))];case 1:return[4,l.sent().text()];case 2:p=l.sent();try{return[2,JSON.parse(p)]}catch(t){return[2]}return[3,4];case 3:return function(t){if("MeiliSearchApiError"!==t.type)throw new a(t.message,t);throw t}(l.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,n){return r(this,void 0,void 0,(function(){return i(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,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t.prototype.put=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t.prototype.delete=function(t,e,n,s){return r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:s})];case 1:return[2,r.sent()]}}))}))},t}(),p=function(){function t(t,e){this.uid=e,this.httpRequest=new d(t)}return t.prototype.getUpdateStatus=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,s=n.timeOutMs,o=void 0===s?5e3:s,a=n.intervalMs,h=void 0===a?50:a;return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<o?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=r.sent()).status?[2,n]:[4,c(h)];case 3:return r.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.getAllUpdateStatus=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.search=function(t,e,u,c){return void 0===u&&(u="POST"),r(this,void 0,void 0,(function(){var r,a,h;return i(this,(function(i){switch(i.label){case 0:return r="/indexes/"+this.uid+"/search",a={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==u.toUpperCase()?[3,2]:[4,this.httpRequest.post(r,o(a),void 0,c)];case 1:return[2,i.sent()];case 2:return"GET"!==u.toUpperCase()?[3,4]:(h=n(n({},a),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(r,o(h),c)]);case 3:return[2,i.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},t.prototype.show=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateIndex=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return r(this,void 0,void 0,(function(){var e,r;return i(this,(function(i){switch(i.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(r=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,n(n({},t),void 0!==r?{attributesToRetrieve:r}:{}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.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 i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+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 i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateAttributesForFaceting=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.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 i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}();return function(){function t(t){this.config=t,this.httpRequest=new d(t)}return t.prototype.getIndex=function(t){return new p(this.config,t)},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,r.sent()];case 2:if("index_already_exists"===(n=r.sent()).errorCode)return[2,this.getIndex(t)];throw new h(n,n.status);case 3:return[2]}}))}))},t.prototype.listIndexes=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.httpRequest.get("/indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return"/indexes",[4,this.httpRequest.post("/indexes",n(n({},e),{uid:t}))];case 1:return r=i.sent(),[2,new p(this.config,r.uid)]}}))}))},t.prototype.getKeys=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.httpRequest.get("/keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.get("/health").then((function(){return!0}))];case 1:return[2,t.sent()]}}))}))},t.prototype.setHealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},t.prototype.setUnhealthy=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},t.prototype.changeHealthTo=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return"/health",[4,this.httpRequest.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},t.prototype.stats=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.httpRequest.get("/stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.version=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return"/version",[4,this.httpRequest.get("/version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return r(this,void 0,void 0,(function(){return i(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 r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="/dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t}()})); | ||
//# sourceMappingURL=meilisearch.umd.min.js.map |
@@ -14,30 +14,30 @@ import 'cross-fetch/polyfill'; | ||
body?: any; | ||
config?: Request; | ||
config?: Partial<Request>; | ||
}): Promise<any>; | ||
get(url: string, params?: { | ||
[key: string]: any; | ||
}, config?: Request): Promise<void>; | ||
}, config?: Partial<Request>): Promise<void>; | ||
get<T = any>(url: string, params?: { | ||
[key: string]: any; | ||
}, config?: Request): Promise<T>; | ||
}, config?: Partial<Request>): Promise<T>; | ||
post(url: string, data: Types.IndexRequest, params?: { | ||
[key: string]: any; | ||
}, config?: Request): Promise<Types.IndexResponse>; | ||
}, config?: Partial<Request>): Promise<Types.IndexResponse>; | ||
post<T = any, R = Types.EnqueuedUpdate>(url: string, data?: T, params?: { | ||
[key: string]: any; | ||
}, config?: Request): Promise<R>; | ||
}, config?: Partial<Request>): Promise<R>; | ||
put(url: string, data: Types.IndexOptions | Types.IndexRequest, params?: { | ||
[key: string]: any; | ||
}, config?: Request): Promise<Types.IndexResponse>; | ||
}, config?: Partial<Request>): Promise<Types.IndexResponse>; | ||
put<T = any, R = Types.EnqueuedUpdate>(url: string, data?: T, params?: { | ||
[key: string]: any; | ||
}, config?: Request): Promise<R>; | ||
}, config?: Partial<Request>): Promise<R>; | ||
delete(url: string, data?: any, params?: { | ||
[key: string]: any; | ||
}, config?: Request): Promise<void>; | ||
}, config?: Partial<Request>): Promise<void>; | ||
delete<T>(url: string, data?: any, params?: { | ||
[key: string]: any; | ||
}, config?: Request): Promise<T>; | ||
}, config?: Partial<Request>): Promise<T>; | ||
} | ||
export default HttpRequests; | ||
//# sourceMappingURL=http-requests.d.ts.map |
@@ -28,3 +28,3 @@ import * as Types from './types'; | ||
*/ | ||
search<P extends Types.SearchParams<T>>(query?: string | null, options?: P, method?: Types.Methods): Promise<Types.SearchResponse<T, P>>; | ||
search<P extends Types.SearchParams<T>>(query?: string | null, options?: P, method?: Types.Methods, config?: Partial<Request>): Promise<Types.SearchResponse<T, P>>; | ||
/** | ||
@@ -31,0 +31,0 @@ * Show index information. |
@@ -39,7 +39,8 @@ import { Index } from './index'; | ||
/** | ||
* Check if the server is healhty | ||
* Checks if the server is healthy, otherwise an error will be thrown. | ||
* | ||
* @memberof MeiliSearch | ||
* @method isHealthy | ||
*/ | ||
isHealthy(): Promise<boolean>; | ||
isHealthy(): Promise<true>; | ||
/** | ||
@@ -46,0 +47,0 @@ * Change the healthyness to healthy |
@@ -1,2 +0,2 @@ | ||
// Type definitions for meilisearch 0.14.2 | ||
// Type definitions for meilisearch 0.15.0 | ||
// Project: https://github.com/meilisearch/meilisearch-js | ||
@@ -99,10 +99,3 @@ // Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch> | ||
export declare type GetDocumentsResponse<T, P extends GetDocumentsParams<T>> = P['attributesToRetrieve'] extends keyof T ? Array<Document<Pick<T, Exclude<keyof T, Exclude<keyof T, P['attributesToRetrieve']>>>>> : P['attributesToRetrieve'] extends Array<infer K> ? Array<Document<Pick<T, Exclude<keyof T, Exclude<keyof T, K>>>>> : Array<Document<T>>; | ||
export declare type DocumentLike = { | ||
[Key in string]?: DocumentField; | ||
}; | ||
export declare type DocumentArray = DocumentField[]; | ||
export declare type DocumentField = string | number | boolean | null | DocumentLike | DocumentArray; | ||
export declare type Document<T> = DocumentLike & { | ||
[key in keyof T]: T[key]; | ||
}; | ||
export declare type Document<T> = T; | ||
export interface Settings { | ||
@@ -165,3 +158,3 @@ attributesForFaceting?: string[]; | ||
getKeys: () => Promise<Keys>; | ||
isHealthy: () => Promise<boolean>; | ||
isHealthy: () => Promise<true>; | ||
setHealthy: () => Promise<void>; | ||
@@ -180,3 +173,3 @@ setUnhealthy: () => Promise<void>; | ||
getAllUpdateStatus: () => Promise<Update[]>; | ||
search: <P extends SearchParams<T>>(query?: string | null, options?: P, method?: Methods) => Promise<SearchResponse<T, P>>; | ||
search: <P extends SearchParams<T>>(query?: string | null, options?: P, method?: Methods, config?: Partial<Request>) => Promise<SearchResponse<T, P>>; | ||
show: () => Promise<IndexResponse>; | ||
@@ -245,3 +238,59 @@ updateIndex: (indexData: IndexOptions) => Promise<IndexResponse>; | ||
} | ||
export declare const enum ErrorStatusCode { | ||
/** @see https://docs.meilisearch.com/errors/#index_creation_failed */ | ||
INDEX_CREATION_FAILED = "index_creation_failed", | ||
/** @see https://docs.meilisearch.com/errors/#index_already_exists */ | ||
INDEX_ALREADY_EXISTS = "index_already_exists", | ||
/** @see https://docs.meilisearch.com/errors/#index_not_found */ | ||
INDEX_NOT_FOUND = "index_not_found", | ||
/** @see https://docs.meilisearch.com/errors/#invalid_index_uid */ | ||
INVALID_INDEX_UID = "invalid_index_uid", | ||
/** @see https://docs.meilisearch.com/errors/#index_not_accessible */ | ||
INDEX_NOT_ACCESSIBLE = "index_not_accessible", | ||
/** @see https://docs.meilisearch.com/errors/#invalid_state */ | ||
INVALID_STATE = "invalid_state", | ||
/** @see https://docs.meilisearch.com/errors/#missing_primary_key */ | ||
MISSING_PRIMARY_KEY = "missing_primary_key", | ||
/** @see https://docs.meilisearch.com/errors/#primary_key_already_present */ | ||
PRIMARY_KEY_ALREADY_PRESENT = "primary_key_already_present", | ||
/** @see https://docs.meilisearch.com/errors/#max_fields_limit_exceeded */ | ||
MAX_FIELDS_LIMIT_EXCEEDED = "max_fields_limit_exceeded", | ||
/** @see https://docs.meilisearch.com/errors/#missing_document_id */ | ||
MISSING_DOCUMENT_ID = "missing_document_id", | ||
/** @see https://docs.meilisearch.com/errors/#invalid_facet */ | ||
INVALID_FACET = "invalid_facet", | ||
/** @see https://docs.meilisearch.com/errors/#invalid_filter */ | ||
INVALID_FILTER = "invalid_filter", | ||
/** @see https://docs.meilisearch.com/errors/#bad_parameter */ | ||
BAD_PARAMETER = "bad_parameter", | ||
/** @see https://docs.meilisearch.com/errors/#bad_request */ | ||
BAD_REQUEST = "bad_request", | ||
/** @see https://docs.meilisearch.com/errors/#document_not_found */ | ||
DOCUMENT_NOT_FOUND = "document_not_found", | ||
/** @see https://docs.meilisearch.com/errors/#internal */ | ||
INTERNAL = "internal", | ||
/** @see https://docs.meilisearch.com/errors/#invalid_token */ | ||
INVALID_TOKEN = "invalid_token", | ||
/** @see https://docs.meilisearch.com/errors/#maintenance */ | ||
MAINTENANCE = "maintenance", | ||
/** @see https://docs.meilisearch.com/errors/#missing_authorization_header */ | ||
MISSING_AUTHORIZATION_HEADER = "missing_authorization_header", | ||
/** @see https://docs.meilisearch.com/errors/#missing_header */ | ||
MISSING_HEADER = "missing_header", | ||
/** @see https://docs.meilisearch.com/errors/#not_found */ | ||
NOT_FOUND = "not_found", | ||
/** @see https://docs.meilisearch.com/errors/#payload_too_large */ | ||
PAYLOAD_TOO_LARGE = "payload_too_large", | ||
/** @see https://docs.meilisearch.com/errors/#unretrievable_document */ | ||
UNRETRIEVABLE_DOCUMENT = "unretrievable_document", | ||
/** @see https://docs.meilisearch.com/errors/#search_error */ | ||
SEARCH_ERROR = "search_error", | ||
/** @see https://docs.meilisearch.com/errors/#unsupported_media_type */ | ||
UNSUPPORTED_MEDIA_TYPE = "unsupported_media_type", | ||
/** @see https://docs.meilisearch.com/errors/#dump_already_in_progress */ | ||
DUMP_ALREADY_IN_PROGRESS = "dump_already_in_progress", | ||
/** @see https://docs.meilisearch.com/errors/#dump_process_failed */ | ||
DUMP_PROCESS_FAILED = "dump_process_failed" | ||
} | ||
export default MeiliSearch; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "meilisearch", | ||
"version": "0.14.2", | ||
"version": "0.15.0", | ||
"description": "The MeiliSearch JS client for Node.js and the browser.", | ||
@@ -39,4 +39,5 @@ "keywords": [ | ||
"test:ci": "yarn test --ci", | ||
"test:env": "yarn build && yarn test:env:browser && yarn test:env:nodejs && yarn test:env:esm", | ||
"test:env": "yarn build && yarn test:env:browser && yarn test:env:nodejs && yarn test:env:esm && yarn test:env:node-ts", | ||
"test:env:browser": "yarn --cwd tests/env/express && yarn --cwd tests/env/express test", | ||
"test:env:node-ts": "yarn --cwd tests/env/typescript-node build", | ||
"test:env:nodejs": "node tests/env/node/index.js", | ||
@@ -74,2 +75,3 @@ "test:env:esm": "yarn --cwd tests/env/esm && yarn --cwd tests/env/esm start", | ||
"@typescript-eslint/parser": "2.34.0", | ||
"abort-controller": "^3.0.0", | ||
"brotli-size": "^4.0.0", | ||
@@ -90,3 +92,3 @@ "eslint": "^7.5.0", | ||
"kleur": "^4.0.0", | ||
"lint-staged": "10.4.0", | ||
"lint-staged": "10.4.2", | ||
"prettier": "^2.0.2", | ||
@@ -96,3 +98,3 @@ "pretty-bytes": "^5.3.0", | ||
"rollup-plugin-terser": "^7.0.0", | ||
"rollup-plugin-typescript2": "^0.27.0", | ||
"rollup-plugin-typescript2": "^0.28.0", | ||
"shx": "^0.3.2", | ||
@@ -99,0 +101,0 @@ "ts-jest": "^25.3.0", |
235
README.md
@@ -9,6 +9,6 @@ <p align="center"> | ||
<a href="https://github.com/meilisearch/MeiliSearch">MeiliSearch</a> | | ||
<a href="https://docs.meilisearch.com">Documentation</a> | | ||
<a href="https://www.meilisearch.com">Website</a> | | ||
<a href="https://blog.meilisearch.com">Blog</a> | | ||
<a href="https://twitter.com/meilisearch">Twitter</a> | | ||
<a href="https://docs.meilisearch.com">Documentation</a> | | ||
<a href="https://docs.meilisearch.com/faq">FAQ</a> | ||
@@ -18,4 +18,3 @@ </h4> | ||
<p align="center"> | ||
<a href="https://www.npmjs.com/package/meilisearch"><img src="https://img.shields.io/npm/v/meilisearch.svg" alt="NPM version"></a> | ||
<a href="https://github.com/conventional-changelog/standard-version"><img src="https://img.shields.io/badge/release-standard%20version-brightgreen.svg" alt="Standard Version"></a> | ||
<a href="https://www.npmjs.com/package/meilisearch"><img src="https://img.shields.io/npm/v/meilisearch.svg" alt="npm version"></a> | ||
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/styled_with-prettier-ff69b4.svg" alt="Prettier"></a> | ||
@@ -26,21 +25,24 @@ <a href="https://github.com/meilisearch/meilisearch-js/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-informational" alt="License"></a> | ||
<p align="center">⚡ Lightning Fast, Ultra Relevant, and Typo-Tolerant Search Engine MeiliSearch client written in JavaScript</p> | ||
<p align="center">⚡ The MeiliSearch API client written for JavaScript</p> | ||
**MeiliSearch JavaScript** is a client for **MeiliSearch** written in JavaScript. **MeiliSearch** is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box. | ||
**MeiliSearch JavaScript** is the MeiliSearch API client for JavaScript developers. **MeiliSearch** is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box. | ||
## Table of Contents <!-- omit in toc --> | ||
- [📖 Documentation](#-documentation) | ||
- [🔧 Installation](#-installation) | ||
- [🎬 Getting started](#-getting-started) | ||
- [🎬 Getting Started](#-getting-started) | ||
- [🤖 Compatibility with MeiliSearch](#-compatibility-with-meilisearch) | ||
- [🎬 Examples](#-examples) | ||
- [Indexes](#indexes) | ||
- [Documents](#documents) | ||
- [Update status](#update-status) | ||
- [Search](#search) | ||
- [💡 Learn More](#-learn-more) | ||
- [⚙️ Development Workflow and Contributing](#️-development-workflow-and-contributing) | ||
- [📜 API Resources](#-api-resources) | ||
## 📖 Documentation | ||
See our [Documentation](https://docs.meilisearch.com/guides/introduction/quick_start_guide.html) or our [API References](https://docs.meilisearch.com/references/). | ||
## 🔧 Installation | ||
With `npm`: | ||
```sh | ||
@@ -50,2 +52,4 @@ npm install meilisearch | ||
With `yarn`: | ||
```sh | ||
@@ -107,5 +111,5 @@ yarn add meilisearch | ||
## 🎬 Getting started | ||
## 🎬 Getting Started | ||
Here is a quickstart for a search request | ||
#### Add Documents <!-- omit in toc --> | ||
@@ -116,2 +120,3 @@ ```js | ||
import MeiliSearch from 'meilisearch' | ||
;(async () => { | ||
@@ -132,4 +137,4 @@ const client = new MeiliSearch({ | ||
{ book_id: 1344, title: 'The Hobbit' }, | ||
{ book_id: 4, title: 'Harry Potter and the Half-Blood Prince' }, | ||
{ book_id: 42, title: "The Hitchhiker's Guide to the Galaxy" }, | ||
{ book_id: 4, title: 'Harry Potter and the Half-Blood Prince', genre: 'fantasy' }, | ||
{ book_id: 42, title: "The Hitchhiker's Guide to the Galaxy", genre: 'fantasy' } | ||
] | ||
@@ -142,5 +147,5 @@ | ||
With the `updateId`, you can check the status (`processed` or `failed`) of your documents addition thanks to this [method](#update-status). | ||
With the `updateId`, you can check the status (`enqueued`, `processed` or `failed`) of your documents addition using the [update endpoint](https://docs.meilisearch.com/references/updates.html#get-an-update-status). | ||
#### Search in index <!-- omit in toc --> | ||
#### Basic Search <!-- omit in toc --> | ||
@@ -165,2 +170,4 @@ ```javascript | ||
"limit": 20, | ||
"nbHits": 1, | ||
"exhaustiveNbHits": false, | ||
"processingTimeMs": 1, | ||
@@ -171,127 +178,21 @@ "query": "harry pottre" | ||
## 🤖 Compatibility with MeiliSearch | ||
#### Custom Search <!-- omit in toc --> | ||
This package only guarantees the compatibility with the [version v0.15.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.15.0). | ||
All the supported options are described in the [search parameters](https://docs.meilisearch.com/guides/advanced_guides/search_parameters.html) section of the documentation. | ||
## 🎬 Examples | ||
All HTTP routes of MeiliSearch are accessible via methods in this SDK.</br> | ||
You can check out [the API documentation](https://docs.meilisearch.com/references/). | ||
Go checkout [examples](./examples)! | ||
In this section, the examples contain the [`await` keyword](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await). | ||
### Indexes | ||
#### Create an index <!-- omit in toc --> | ||
```javascript | ||
// Create an index | ||
const index = await client.createIndex('books') | ||
// Create an index and give the primary-key | ||
const index = await client.createIndex('books', { primaryKey: 'book_id' }) | ||
await index.search( | ||
'prince', | ||
{ | ||
attributesToHighlight: ['*'], | ||
filters: 'book_id > 10' | ||
} | ||
) | ||
``` | ||
#### List all indexes <!-- omit in toc --> | ||
```javascript | ||
const indexes = await client.listIndexes() | ||
``` | ||
#### Get an index object <!-- omit in toc --> | ||
```javascript | ||
const index = client.getIndex('books') | ||
``` | ||
### Documents | ||
#### Fetch documents <!-- omit in toc --> | ||
```javascript | ||
// Get one document | ||
const document = await index.getDocument(123) | ||
// Get documents by batch | ||
const documents = await index.getDocuments({ offset: 4, limit: 20 }) | ||
``` | ||
#### Add documents <!-- omit in toc --> | ||
```javascript | ||
await index.addDocuments([{ book_id: 2, title: 'Madame Bovary' }]) | ||
``` | ||
Response: | ||
```json | ||
{ | ||
"updateId": 1 | ||
} | ||
``` | ||
With this `updateId` you can track your [operation update](#update-status). | ||
#### Delete documents <!-- omit in toc --> | ||
```javascript | ||
// Delete one document | ||
await index.deleteDocument(2) | ||
// Delete several documents | ||
await index.deleteDocuments([1, 42]) | ||
// Delete all documents /!\ | ||
await index.deleteAllDocuments() | ||
``` | ||
### Update status | ||
```javascript | ||
// Get one update | ||
// Parameter: the updateId got after an asynchronous request (e.g. documents addition) | ||
await index.getUpdateStatus(1) | ||
// Get all update satus | ||
await index.getAllUpdateStatus() | ||
``` | ||
### Search | ||
#### Basic search <!-- omit in toc --> | ||
```javascript | ||
const search = await index.search('prince') | ||
``` | ||
```json | ||
{ | ||
"hits": [ | ||
{ | ||
"book_id": 456, | ||
"title": "Le Petit Prince" | ||
}, | ||
{ | ||
"book_id": 4, | ||
"title": "Harry Potter and the Half-Blood Prince" | ||
} | ||
], | ||
"offset": 0, | ||
"limit": 20, | ||
"processingTimeMs": 13, | ||
"query": "prince" | ||
} | ||
``` | ||
#### Custom search <!-- omit in toc --> | ||
All the supported options are described in [this documentation section](https://docs.meilisearch.com/references/search.html#search-in-an-index). | ||
```javascript | ||
await index.search('prince', { limit: 1, attributesToHighlight: '*' }) | ||
``` | ||
```json | ||
{ | ||
"hits": [ | ||
{ | ||
"book_id": 456, | ||
"title": "Le Petit Prince", | ||
@@ -305,3 +206,5 @@ "_formatted": { | ||
"offset": 0, | ||
"limit": 1, | ||
"limit": 20, | ||
"nbHits": 1, | ||
"exhaustiveNbHits": false, | ||
"processingTimeMs": 0, | ||
@@ -312,12 +215,14 @@ "query": "prince" | ||
#### Placeholder Search | ||
#### Placeholder Search <!-- omit in toc --> | ||
Placeholder search makes it possible to receive hits based on your parameters without having any query (`q`). | ||
To enable this behavior, instead of sending an empty string, the query should be `null` or `undefined`. | ||
```javascript | ||
await index.search(null, { | ||
facetFilters: ['genre:fantasy'], | ||
facetsDistribution: ['genre'] | ||
}) | ||
await index.search( | ||
'', | ||
{ | ||
facetFilters: ['genre:fantasy'], | ||
facetsDistribution: ['genre'] | ||
} | ||
) | ||
``` | ||
@@ -329,11 +234,10 @@ | ||
{ | ||
"genre": "fantasy", | ||
"id": 4, | ||
"title": "Harry Potter and the Half-Blood Prince", | ||
"comment": "The best book" | ||
"genre": "fantasy" | ||
}, | ||
{ | ||
"genre": "fantasy", | ||
"id": 42, | ||
"title": "The Hitchhiker's Guide to the Galaxy" | ||
"title": "The Hitchhiker's Guide to the Galaxy", | ||
"genre": "fantasy" | ||
} | ||
@@ -347,3 +251,3 @@ ], | ||
"query": "", | ||
"facetsDistribution": { "genre": { "fantasy": 2, "romance": 0, "sci fi": 0, "adventure": 0 } }, | ||
"facetsDistribution": { "genre": { "fantasy": 2 } }, | ||
"exhaustiveFacetsCount": true | ||
@@ -353,2 +257,38 @@ } | ||
#### Abortable Search <!-- omit in toc --> | ||
You can abort a pending search request by providing an [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to the request. | ||
```js | ||
const controller = new AbortController() | ||
index | ||
.search('prince', {}, 'POST', { | ||
signal: controller.signal, | ||
}) | ||
.then((response) => { | ||
/** ... */ | ||
}) | ||
.catch((e) => { | ||
/** Catch AbortError here. */ | ||
}) | ||
controller.abort() | ||
``` | ||
## 🤖 Compatibility with MeiliSearch | ||
This package only guarantees the compatibility with the [version v0.15.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.15.0). | ||
## 💡 Learn More | ||
The following sections may interest you: | ||
- **Manipulate documents**: see the [API references](https://docs.meilisearch.com/references/documents.html) or read more about [documents](https://docs.meilisearch.com/guides/main_concepts/documents.html). | ||
- **Search**: see the [API references](https://docs.meilisearch.com/references/search.html) or follow our guide on [search parameters](https://docs.meilisearch.com/guides/advanced_guides/search_parameters.html). | ||
- **Manage the indexes**: see the [API references](https://docs.meilisearch.com/references/indexes.html) or read more about [indexes](https://docs.meilisearch.com/guides/main_concepts/indexes.html). | ||
- **Configure the index settings**: see the [API references](https://docs.meilisearch.com/references/settings.html) or follow our guide on [settings parameters](https://docs.meilisearch.com/guides/advanced_guides/settings.html). | ||
This repository also contains [more examples](./examples). | ||
## ⚙️ Development Workflow and Contributing | ||
@@ -366,3 +306,3 @@ | ||
`client.getIndex<T>('xxx').search(query: string, options: SearchParams = {}, method: 'POST' | 'GET' = 'POST'): Promise<SearchResponse<T>>` | ||
`client.getIndex<T>('xxx').search(query: string, options: SearchParams = {}, method: 'POST' | 'GET' = 'POST', config?: Partial<Request>): Promise<SearchResponse<T>>` | ||
@@ -444,4 +384,5 @@ ### Indexes <!-- omit in toc --> | ||
- Delete all documents: | ||
`index.deleteAllDocuments(): Promise<Types.EnqueuedUpdate>` | ||
`index.deleteAllDocuments(): Promise<Types.EnqueuedUpdate>` | ||
### Settings <!-- omit in toc --> | ||
@@ -540,3 +481,3 @@ | ||
`client.isHealthy(): Promise<void>` | ||
`client.isHealthy(): Promise<true>` | ||
@@ -543,0 +484,0 @@ ### Stats <!-- omit in toc --> |
@@ -24,5 +24,8 @@ import * as Types from '../types' | ||
this.httpStatus = status | ||
Error.captureStackTrace(this, MeiliSearchApiError) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, MeiliSearchApiError) | ||
} | ||
} | ||
} | ||
export default MeiliSearchApiError |
@@ -23,3 +23,5 @@ import 'cross-fetch/polyfill' | ||
Error.captureStackTrace(this, MeiliSearchCommunicationError) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, MeiliSearchCommunicationError) | ||
} | ||
} | ||
@@ -26,0 +28,0 @@ } |
@@ -7,3 +7,6 @@ class MeiliSearchError extends Error { | ||
this.type = 'MeiliSearchError' | ||
Error.captureStackTrace(this, MeiliSearchError) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, MeiliSearchError) | ||
} | ||
} | ||
@@ -10,0 +13,0 @@ } |
@@ -7,3 +7,6 @@ class MeiliSearchTimeOutError extends Error { | ||
this.type = this.constructor.name | ||
Error.captureStackTrace(this, MeiliSearchTimeOutError) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, MeiliSearchTimeOutError) | ||
} | ||
} | ||
@@ -10,0 +13,0 @@ } |
@@ -32,3 +32,3 @@ import 'cross-fetch/polyfill' | ||
body?: any | ||
config?: Request | ||
config?: Partial<Request> | ||
}) { | ||
@@ -68,3 +68,3 @@ try { | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<void> | ||
@@ -75,3 +75,3 @@ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<T> | ||
@@ -82,3 +82,3 @@ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<any> { | ||
@@ -97,3 +97,3 @@ return await this.request({ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<Types.IndexResponse> | ||
@@ -105,3 +105,3 @@ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<R> | ||
@@ -113,3 +113,3 @@ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<any> { | ||
@@ -129,3 +129,3 @@ return await this.request({ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<Types.IndexResponse> | ||
@@ -137,3 +137,3 @@ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<R> | ||
@@ -145,3 +145,3 @@ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<any> { | ||
@@ -161,3 +161,3 @@ return await this.request({ | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<void> | ||
@@ -168,3 +168,3 @@ async delete<T>( | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<T> | ||
@@ -175,3 +175,3 @@ async delete( | ||
params?: { [key: string]: any }, | ||
config?: Request | ||
config?: Partial<Request> | ||
): Promise<any> { | ||
@@ -178,0 +178,0 @@ return await this.request({ |
@@ -81,3 +81,4 @@ /* | ||
options?: P, | ||
method: Types.Methods = 'POST' | ||
method: Types.Methods = 'POST', | ||
config?: Partial<Request> | ||
): Promise<Types.SearchResponse<T, P>> { | ||
@@ -99,3 +100,8 @@ const url = `/indexes/${this.uid}/search` | ||
if (method.toUpperCase() === 'POST') { | ||
return await this.httpRequest.post(url, removeUndefinedFromObject(params)) | ||
return await this.httpRequest.post( | ||
url, | ||
removeUndefinedFromObject(params), | ||
undefined, | ||
config | ||
) | ||
} else if (method.toUpperCase() === 'GET') { | ||
@@ -124,3 +130,4 @@ const getParams: Types.GetSearchRequest = { | ||
url, | ||
removeUndefinedFromObject(getParams) | ||
removeUndefinedFromObject(getParams), | ||
config | ||
) | ||
@@ -127,0 +134,0 @@ } else { |
@@ -99,7 +99,8 @@ /* | ||
/** | ||
* Check if the server is healhty | ||
* Checks if the server is healthy, otherwise an error will be thrown. | ||
* | ||
* @memberof MeiliSearch | ||
* @method isHealthy | ||
*/ | ||
async isHealthy(): Promise<boolean> { | ||
async isHealthy(): Promise<true> { | ||
const url = '/health' | ||
@@ -106,0 +107,0 @@ |
103
src/types.ts
@@ -138,17 +138,4 @@ // Type definitions for meilisearch | ||
export type DocumentLike = { [Key in string]?: DocumentField } | ||
export type DocumentArray = DocumentField[] | ||
export type DocumentField = | ||
| string | ||
| number | ||
| boolean | ||
| null | ||
| DocumentLike | ||
| DocumentArray | ||
export type Document<T> = T | ||
export type Document<T> = DocumentLike & | ||
{ | ||
[key in keyof T]: T[key] | ||
} | ||
/* | ||
@@ -245,3 +232,3 @@ ** Settings | ||
getKeys: () => Promise<Keys> | ||
isHealthy: () => Promise<boolean> | ||
isHealthy: () => Promise<true> | ||
setHealthy: () => Promise<void> | ||
@@ -265,3 +252,4 @@ setUnhealthy: () => Promise<void> | ||
options?: P, | ||
method?: Methods | ||
method?: Methods, | ||
config?: Partial<Request> | ||
) => Promise<SearchResponse<T, P>> | ||
@@ -361,2 +349,85 @@ show: () => Promise<IndexResponse> | ||
export const enum ErrorStatusCode { | ||
/** @see https://docs.meilisearch.com/errors/#index_creation_failed */ | ||
INDEX_CREATION_FAILED = 'index_creation_failed', | ||
/** @see https://docs.meilisearch.com/errors/#index_already_exists */ | ||
INDEX_ALREADY_EXISTS = 'index_already_exists', | ||
/** @see https://docs.meilisearch.com/errors/#index_not_found */ | ||
INDEX_NOT_FOUND = 'index_not_found', | ||
/** @see https://docs.meilisearch.com/errors/#invalid_index_uid */ | ||
INVALID_INDEX_UID = 'invalid_index_uid', | ||
/** @see https://docs.meilisearch.com/errors/#index_not_accessible */ | ||
INDEX_NOT_ACCESSIBLE = 'index_not_accessible', | ||
/** @see https://docs.meilisearch.com/errors/#invalid_state */ | ||
INVALID_STATE = 'invalid_state', | ||
/** @see https://docs.meilisearch.com/errors/#missing_primary_key */ | ||
MISSING_PRIMARY_KEY = 'missing_primary_key', | ||
/** @see https://docs.meilisearch.com/errors/#primary_key_already_present */ | ||
PRIMARY_KEY_ALREADY_PRESENT = 'primary_key_already_present', | ||
/** @see https://docs.meilisearch.com/errors/#max_fields_limit_exceeded */ | ||
MAX_FIELDS_LIMIT_EXCEEDED = 'max_fields_limit_exceeded', | ||
/** @see https://docs.meilisearch.com/errors/#missing_document_id */ | ||
MISSING_DOCUMENT_ID = 'missing_document_id', | ||
/** @see https://docs.meilisearch.com/errors/#invalid_facet */ | ||
INVALID_FACET = 'invalid_facet', | ||
/** @see https://docs.meilisearch.com/errors/#invalid_filter */ | ||
INVALID_FILTER = 'invalid_filter', | ||
/** @see https://docs.meilisearch.com/errors/#bad_parameter */ | ||
BAD_PARAMETER = 'bad_parameter', | ||
/** @see https://docs.meilisearch.com/errors/#bad_request */ | ||
BAD_REQUEST = 'bad_request', | ||
/** @see https://docs.meilisearch.com/errors/#document_not_found */ | ||
DOCUMENT_NOT_FOUND = 'document_not_found', | ||
/** @see https://docs.meilisearch.com/errors/#internal */ | ||
INTERNAL = 'internal', | ||
/** @see https://docs.meilisearch.com/errors/#invalid_token */ | ||
INVALID_TOKEN = 'invalid_token', | ||
/** @see https://docs.meilisearch.com/errors/#maintenance */ | ||
MAINTENANCE = 'maintenance', | ||
/** @see https://docs.meilisearch.com/errors/#missing_authorization_header */ | ||
MISSING_AUTHORIZATION_HEADER = 'missing_authorization_header', | ||
/** @see https://docs.meilisearch.com/errors/#missing_header */ | ||
MISSING_HEADER = 'missing_header', | ||
/** @see https://docs.meilisearch.com/errors/#not_found */ | ||
NOT_FOUND = 'not_found', | ||
/** @see https://docs.meilisearch.com/errors/#payload_too_large */ | ||
PAYLOAD_TOO_LARGE = 'payload_too_large', | ||
/** @see https://docs.meilisearch.com/errors/#unretrievable_document */ | ||
UNRETRIEVABLE_DOCUMENT = 'unretrievable_document', | ||
/** @see https://docs.meilisearch.com/errors/#search_error */ | ||
SEARCH_ERROR = 'search_error', | ||
/** @see https://docs.meilisearch.com/errors/#unsupported_media_type */ | ||
UNSUPPORTED_MEDIA_TYPE = 'unsupported_media_type', | ||
/** @see https://docs.meilisearch.com/errors/#dump_already_in_progress */ | ||
DUMP_ALREADY_IN_PROGRESS = 'dump_already_in_progress', | ||
/** @see https://docs.meilisearch.com/errors/#dump_process_failed */ | ||
DUMP_PROCESS_FAILED = 'dump_process_failed', | ||
} | ||
export default MeiliSearch |
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
260535
5263
34
491