Socket
Socket
Sign inDemoInstall

meilisearch

Package Overview
Dependencies
Maintainers
4
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meilisearch - npm Package Compare versions

Comparing version 0.20.1 to 0.20.2

dist/types/errors/index.d.ts

105

dist/bundles/meilisearch.esm.js

@@ -83,52 +83,2 @@ import 'cross-fetch/polyfill';

var MeiliSearchError = /** @class */ (function (_super) {
__extends(MeiliSearchError, _super);
function MeiliSearchError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchError';
_this.type = 'MeiliSearchError';
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchError);
}
return _this;
}
return MeiliSearchError;
}(Error));
var MeiliSearchTimeOutError = /** @class */ (function (_super) {
__extends(MeiliSearchTimeOutError, _super);
function MeiliSearchTimeOutError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchTimeOutError';
_this.type = _this.constructor.name;
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchTimeOutError);
}
return _this;
}
return MeiliSearchTimeOutError;
}(Error));
/**
* Removes undefined entries from object
*/
function removeUndefinedFromObject(obj) {
return Object.entries(obj).reduce(function (acc, curEntry) {
var key = curEntry[0], val = curEntry[1];
if (val !== undefined)
acc[key] = val;
return acc;
}, {});
}
function sleep(ms) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
}
var MeiliSearchCommunicationError = /** @class */ (function (_super) {

@@ -167,5 +117,2 @@ __extends(MeiliSearchCommunicationError, _super);

_this.httpStatus = status;
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchApiError);
}
return _this;

@@ -207,2 +154,30 @@ }

var MeiliSearchError = /** @class */ (function (_super) {
__extends(MeiliSearchError, _super);
function MeiliSearchError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchError';
_this.type = 'MeiliSearchError';
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchError);
}
return _this;
}
return MeiliSearchError;
}(Error));
var MeiliSearchTimeOutError = /** @class */ (function (_super) {
__extends(MeiliSearchTimeOutError, _super);
function MeiliSearchTimeOutError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchTimeOutError';
_this.type = _this.constructor.name;
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchTimeOutError);
}
return _this;
}
return MeiliSearchTimeOutError;
}(Error));
var HttpRequests = /** @class */ (function () {

@@ -324,2 +299,24 @@ function HttpRequests(config) {

/**
* Removes undefined entries from object
*/
function removeUndefinedFromObject(obj) {
return Object.entries(obj).reduce(function (acc, curEntry) {
var key = curEntry[0], val = curEntry[1];
if (val !== undefined)
acc[key] = val;
return acc;
}, {});
}
function sleep(ms) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
}
/*

@@ -1579,2 +1576,2 @@ * Bundle: MeiliSearch / Indexes

export { MeiliSearch };
export { HttpRequests, Index, MeiliSearch, MeiliSearchApiError, MeiliSearchCommunicationError, MeiliSearchError, MeiliSearchTimeOutError, MeiliSearch as default, httpErrorHandler, httpResponseErrorHandler, removeUndefinedFromObject, sleep };

@@ -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){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");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=new URL(t.host)}return t.addTrailingSlash=function(t){return t.endsWith("/")||(t+="/"),t},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(f){switch(f.label){case 0:return f.trys.push([0,3,,4]),t=new URL(s,this.url),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:JSON.stringify(o),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,f.sent().text()];case 2:p=f.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}(f.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,n){this.uid=e,this.primaryKey=n,this.httpRequest=new d(t)}return 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 n=r.sent(),["enqueued","processing"].includes(n.status)?[4,c(h)]:[2,n];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.search=function(t,e,s){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return r="indexes/"+this.uid+"/search",[4,this.httpRequest.post(r,o(n(n({},e),{q:t})),void 0,s)];case 1:return[2,i.sent()]}}))}))},t.prototype.searchGet=function(t,e,u){return 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=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new s("The filter query parameter should be in string format when using searchGet")},a=n(n({q:t},e),{filter:c(null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)?e.sort.join(","):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?e.facetsDistribution.join(","):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(r,o(a),u)];case 1:return[2,i.sent()]}}))}))},t.prototype.getRawInfo=function(){return r(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return t="indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,[2,e]}}))}))},t.prototype.fetchInfo=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(e,s,u){return void 0===u&&(u={}),r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return"indexes",[4,new d(e).post("indexes",n(n({},u),{uid:s}))];case 1:return r=i.sent(),[2,new t(e,s,r.primaryKey)]}}))}))},t.prototype.update=function(t){return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),this.primaryKey=n.primaryKey,[2,this]}}))}))},t.prototype.delete=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.deleteIfExists=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.delete()];case 1:return e.sent(),[2,!0];case 2:if("index_not_found"===(t=e.sent()).errorCode)return[2,!1];throw t;case 3:return[2]}}))}))},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.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.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.getFilterableAttributes=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/filterable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=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/filterable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=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/sortable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return 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}(),f=function(){function t(t){t.host=d.addTrailingSlash(t.host),this.config=t,this.httpRequest=new d(t)}return t.prototype.index=function(t){return new p(this.config,t)},t.prototype.getIndex=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new p(this.config,t).fetchInfo()]}))}))},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.getIndex(t)];case 1:return[2,r.sent()];case 2:if("index_not_found"===(n=r.sent()).errorCode)return[2,this.createIndex(t,e)];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(){return i(this,(function(n){switch(n.label){case 0:return[4,p.create(this.config,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,new p(this.config,t).update(e)]}))}))},t.prototype.deleteIndex=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new p(this.config,t).delete()]}))}))},t.prototype.deleteIndexIfExists=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).errorCode)return[2,!1];throw e;case 3:return[2]}}))}))},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.health=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")];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 t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.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{f as MeiliSearch};
***************************************************************************** */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){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");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,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),u=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,r}return e(n,t),n}(Error);function o(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 s(t.statusText,t);case 4:throw new u(e,t.status);case 5:return[2,t]}}))}))}function c(t){if("MeiliSearchApiError"!==t.type)throw new s(t.message,t);throw t}var a=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),h=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),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=new URL(t.host)}return t.addTrailingSlash=function(t){return t.endsWith("/")||(t+="/"),t},t.prototype.request=function(t){var e=t.method,s=t.url,u=t.params,a=t.body,h=t.config;return r(this,void 0,void 0,(function(){var t,r,d;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t=new URL(s,this.url),u&&(r=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return r.set(t,u[t])})),t.search=r.toString()),[4,fetch(t.toString(),n(n({},h),{method:e,body:JSON.stringify(a),headers:this.headers})).then((function(t){return o(t)}))];case 1:return[4,i.sent().text()];case 2:d=i.sent();try{return[2,JSON.parse(d)]}catch(t){return[2]}return[3,4];case 3:return c(i.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}();function p(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 f(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 l=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new d(t)}return t.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,s=n.timeOutMs,u=void 0===s?5e3:s,o=n.intervalMs,c=void 0===o?50:o;return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,f(c)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new h("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.search=function(t,e,s){return r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return r="indexes/"+this.uid+"/search",[4,this.httpRequest.post(r,p(n(n({},e),{q:t})),void 0,s)];case 1:return[2,i.sent()]}}))}))},t.prototype.searchGet=function(t,e,s){return r(this,void 0,void 0,(function(){var r,u,o;return i(this,(function(i){switch(i.label){case 0:return r="indexes/"+this.uid+"/search",u=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new a("The filter query parameter should be in string format when using searchGet")},o=n(n({q:t},e),{filter:u(null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)?e.sort.join(","):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?e.facetsDistribution.join(","):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(r,p(o),s)];case 1:return[2,i.sent()]}}))}))},t.prototype.getRawInfo=function(){return r(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return t="indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,[2,e]}}))}))},t.prototype.fetchInfo=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(e,s,u){return void 0===u&&(u={}),r(this,void 0,void 0,(function(){var r;return i(this,(function(i){switch(i.label){case 0:return"indexes",[4,new d(e).post("indexes",n(n({},u),{uid:s}))];case 1:return r=i.sent(),[2,new t(e,s,r.primaryKey)]}}))}))},t.prototype.update=function(t){return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),this.primaryKey=n.primaryKey,[2,this]}}))}))},t.prototype.delete=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.deleteIfExists=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.delete()];case 1:return e.sent(),[2,!0];case 2:if("index_not_found"===(t=e.sent()).errorCode)return[2,!1];throw t;case 3:return[2]}}))}))},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.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.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.getFilterableAttributes=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/filterable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=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/filterable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=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/sortable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return 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}(),v=function(){function t(t){t.host=d.addTrailingSlash(t.host),this.config=t,this.httpRequest=new d(t)}return t.prototype.index=function(t){return new l(this.config,t)},t.prototype.getIndex=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new l(this.config,t).fetchInfo()]}))}))},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.getIndex(t)];case 1:return[2,r.sent()];case 2:if("index_not_found"===(n=r.sent()).errorCode)return[2,this.createIndex(t,e)];throw new u(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(){return i(this,(function(n){switch(n.label){case 0:return[4,l.create(this.config,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){return i(this,(function(n){return[2,new l(this.config,t).update(e)]}))}))},t.prototype.deleteIndex=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new l(this.config,t).delete()]}))}))},t.prototype.deleteIndexIfExists=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).errorCode)return[2,!1];throw e;case 3:return[2]}}))}))},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.health=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")];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 t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.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{d as HttpRequests,l as Index,v as MeiliSearch,u as MeiliSearchApiError,s as MeiliSearchCommunicationError,a as MeiliSearchError,h as MeiliSearchTimeOutError,v as default,c as httpErrorHandler,o as httpResponseErrorHandler,p as removeUndefinedFromObject,f as sleep};
//# sourceMappingURL=meilisearch.esm.min.js.map

@@ -87,77 +87,2 @@ (function (global, factory) {

var MeiliSearchError =
/** @class */
function (_super) {
__extends(MeiliSearchError, _super);
function MeiliSearchError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchError';
_this.type = 'MeiliSearchError';
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchError);
}
return _this;
}
return MeiliSearchError;
}(Error);
var MeiliSearchTimeOutError =
/** @class */
function (_super) {
__extends(MeiliSearchTimeOutError, _super);
function MeiliSearchTimeOutError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchTimeOutError';
_this.type = _this.constructor.name;
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchTimeOutError);
}
return _this;
}
return MeiliSearchTimeOutError;
}(Error);
/**
* Removes undefined entries from object
*/
function removeUndefinedFromObject(obj) {
return Object.entries(obj).reduce(function (acc, curEntry) {
var key = curEntry[0],
val = curEntry[1];
if (val !== undefined) acc[key] = val;
return acc;
}, {});
}
function sleep(ms) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
return [4
/*yield*/
, new Promise(function (resolve) {
return setTimeout(resolve, ms);
})];
case 1:
return [2
/*return*/
, _a.sent()];
}
});
});
}
var MeiliSearchCommunicationError =

@@ -209,7 +134,2 @@ /** @class */

_this.httpStatus = status;
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchApiError);
}
return _this;

@@ -270,2 +190,44 @@ }

var MeiliSearchError =
/** @class */
function (_super) {
__extends(MeiliSearchError, _super);
function MeiliSearchError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchError';
_this.type = 'MeiliSearchError';
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchError);
}
return _this;
}
return MeiliSearchError;
}(Error);
var MeiliSearchTimeOutError =
/** @class */
function (_super) {
__extends(MeiliSearchTimeOutError, _super);
function MeiliSearchTimeOutError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchTimeOutError';
_this.type = _this.constructor.name;
if (Error.captureStackTrace) {
Error.captureStackTrace(_this, MeiliSearchTimeOutError);
}
return _this;
}
return MeiliSearchTimeOutError;
}(Error);
var HttpRequests =

@@ -464,2 +426,35 @@ /** @class */

/**
* Removes undefined entries from object
*/
function removeUndefinedFromObject(obj) {
return Object.entries(obj).reduce(function (acc, curEntry) {
var key = curEntry[0],
val = curEntry[1];
if (val !== undefined) acc[key] = val;
return acc;
}, {});
}
function sleep(ms) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
return [4
/*yield*/
, new Promise(function (resolve) {
return setTimeout(resolve, ms);
})];
case 1:
return [2
/*return*/
, _a.sent()];
}
});
});
}
/*

@@ -2272,3 +2267,14 @@ * Bundle: MeiliSearch / Indexes

exports.HttpRequests = HttpRequests;
exports.Index = Index;
exports.MeiliSearch = MeiliSearch;
exports.MeiliSearchApiError = MeiliSearchApiError;
exports.MeiliSearchCommunicationError = MeiliSearchCommunicationError;
exports.MeiliSearchError = MeiliSearchError;
exports.MeiliSearchTimeOutError = MeiliSearchTimeOutError;
exports['default'] = MeiliSearch;
exports.httpErrorHandler = httpErrorHandler;
exports.httpResponseErrorHandler = httpResponseErrorHandler;
exports.removeUndefinedFromObject = removeUndefinedFromObject;
exports.sleep = sleep;

@@ -2275,0 +2281,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

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

PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,n,r){return new(n||(n=Promise))((function(i,s){function 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 s(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 u=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),o=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function c(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 a(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var h=function(t){function e(n,r){var i=t.call(this,n)||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,e),i}return n(e,t),e}(Error),d=function(t){function e(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,d),r}return n(e,t),e}(Error);var p=function(){function t(t){this.headers=r(r(r({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=new URL(t.host)}return t.addTrailingSlash=function(t){return t.endsWith("/")||(t+="/"),t},t.prototype.request=function(t){var e=t.method,n=t.url,u=t.params,o=t.body,c=t.config;return i(this,void 0,void 0,(function(){var t,a,p;return s(this,(function(f){switch(f.label){case 0:return f.trys.push([0,3,,4]),t=new URL(n,this.url),u&&(a=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return a.set(t,u[t])})),t.search=a.toString()),[4,fetch(t.toString(),r(r({},c),{method:e,body:JSON.stringify(o),headers:this.headers})).then((function(t){return function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new h(t.statusText,t);case 4:throw new d(e,t.status);case 5:return[2,t]}}))}))}(t)}))];case 1:return[4,f.sent().text()];case 2:p=f.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 h(t.message,t);throw t}(f.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),f=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new p(t)}return t.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,u=void 0===r?5e3:r,c=n.intervalMs,h=void 0===c?50:c;return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,a(h)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new o("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",[4,this.httpRequest.post(i,c(r(r({},e),{q:t})),void 0,n)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){return i(this,void 0,void 0,(function(){var i,o,a;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",o=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new u("The filter query parameter should be in string format when using searchGet")},a=r(r({q:t},e),{filter:o(null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)?e.sort.join(","):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?e.facetsDistribution.join(","):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(i,c(a),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(e,n,u){return void 0===u&&(u={}),i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return"indexes",[4,new p(e).post("indexes",r(r({},u),{uid:n}))];case 1:return i=s.sent(),[2,new t(e,n,i.primaryKey)]}}))}))},t.prototype.update=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),this.primaryKey=n.primaryKey,[2,this]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIfExists=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.delete()];case 1:return e.sent(),[2,!0];case 2:if("index_not_found"===(t=e.sent()).errorCode)return[2,!1];throw t;case 3:return[2]}}))}))},t.prototype.getAllUpdateStatus=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getUpdateStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,r(r({},t),void 0!==n?{attributesToRetrieve:n}:{}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+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 s(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 i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="indexes/"+this.uid+"/documents",[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),l=function(){function t(t){t.host=p.addTrailingSlash(t.host),this.config=t,this.httpRequest=new p(t)}return t.prototype.index=function(t){return new f(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new f(this.config,t).fetchInfo()]}))}))},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getIndex(t)];case 1:return[2,r.sent()];case 2:if("index_not_found"===(n=r.sent()).errorCode)return[2,this.createIndex(t,e)];throw new d(n,n.status);case 3:return[2]}}))}))},t.prototype.listIndexes=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"indexes",[4,this.httpRequest.get("indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,f.create(this.config,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){return[2,new f(this.config,t).update(e)]}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new f(this.config,t).delete()]}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).errorCode)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getKeys=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"keys",[4,this.httpRequest.get("keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"health",[4,this.httpRequest.get("health")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.stats=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"stats",[4,this.httpRequest.get("stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.version=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"version",[4,this.httpRequest.get("version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return[2,t.sent()]}}))}))},t.prototype.getDumpStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t}();t.MeiliSearch=l,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function i(t,e,n,r){return new(n||(n=Promise))((function(i,s){function 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 s(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 u=function(t){function e(n,r){var i=t.call(this,n)||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,e),i}return n(e,t),e}(Error),o=function(t){function e(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,r}return n(e,t),e}(Error);function c(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new u(t.statusText,t);case 4:throw new o(e,t.status);case 5:return[2,t]}}))}))}function a(t){if("MeiliSearchApiError"!==t.type)throw new u(t.message,t);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchError",r.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),d=function(t){function e(n){var r=t.call(this,n)||this;return r.name="MeiliSearchTimeOutError",r.type=r.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),p=function(){function t(t){this.headers=r(r(r({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=new URL(t.host)}return t.addTrailingSlash=function(t){return t.endsWith("/")||(t+="/"),t},t.prototype.request=function(t){var e=t.method,n=t.url,u=t.params,o=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,d;return s(this,(function(s){switch(s.label){case 0:return s.trys.push([0,3,,4]),t=new URL(n,this.url),u&&(i=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return i.set(t,u[t])})),t.search=i.toString()),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(o),headers:this.headers})).then((function(t){return c(t)}))];case 1:return[4,s.sent().text()];case 2:d=s.sent();try{return[2,JSON.parse(d)]}catch(t){return[2]}return[3,4];case 3:return a(s.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}();function f(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 l(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var v=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new p(t)}return t.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,u=void 0===r?5e3:r,o=n.intervalMs,c=void 0===o?50:o;return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,l(c)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new d("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",[4,this.httpRequest.post(i,f(r(r({},e),{q:t})),void 0,n)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){return i(this,void 0,void 0,(function(){var i,u,o;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",u=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},o=r(r({q:t},e),{filter:u(null==e?void 0:e.filter),sort:(null==e?void 0:e.sort)?e.sort.join(","):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?e.facetsDistribution.join(","):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(i,f(o),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(e,n,u){return void 0===u&&(u={}),i(this,void 0,void 0,(function(){var i;return s(this,(function(s){switch(s.label){case 0:return"indexes",[4,new p(e).post("indexes",r(r({},u),{uid:n}))];case 1:return i=s.sent(),[2,new t(e,n,i.primaryKey)]}}))}))},t.prototype.update=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return e="indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return n=r.sent(),this.primaryKey=n.primaryKey,[2,this]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIfExists=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.delete()];case 1:return e.sent(),[2,!0];case 2:if("index_not_found"===(t=e.sent()).errorCode)return[2,!1];throw t;case 3:return[2]}}))}))},t.prototype.getAllUpdateStatus=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getUpdateStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return i(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,r(r({},t),void 0!==n?{attributesToRetrieve:n}:{}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+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 s(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 i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return n="indexes/"+this.uid+"/documents",[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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 s(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.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/filterable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/sortable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),y=function(){function t(t){t.host=p.addTrailingSlash(t.host),this.config=t,this.httpRequest=new p(t)}return t.prototype.index=function(t){return new v(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new v(this.config,t).fetchInfo()]}))}))},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.getIndex(t)];case 1:return[2,r.sent()];case 2:if("index_not_found"===(n=r.sent()).errorCode)return[2,this.createIndex(t,e)];throw new o(n,n.status);case 3:return[2]}}))}))},t.prototype.listIndexes=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"indexes",[4,this.httpRequest.get("indexes")];case 1:return[2,t.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,v.create(this.config,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return s(this,(function(n){return[2,new v(this.config,t).update(e)]}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new v(this.config,t).delete()]}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).errorCode)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getKeys=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"keys",[4,this.httpRequest.get("keys")];case 1:return[2,t.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"health",[4,this.httpRequest.get("health")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.stats=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"stats",[4,this.httpRequest.get("stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.version=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"version",[4,this.httpRequest.get("version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return[2,t.sent()]}}))}))},t.prototype.getDumpStatus=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t}();t.HttpRequests=p,t.Index=v,t.MeiliSearch=y,t.MeiliSearchApiError=o,t.MeiliSearchCommunicationError=u,t.MeiliSearchError=h,t.MeiliSearchTimeOutError=d,t.default=y,t.httpErrorHandler=a,t.httpResponseErrorHandler=c,t.removeUndefinedFromObject=f,t.sleep=l,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=meilisearch.umd.min.js.map

@@ -1,5 +0,5 @@

import * as Types from '../types';
import { FetchError } from '../types';
declare function httpResponseErrorHandler(response: Response): Promise<Response>;
declare function httpErrorHandler(response: Types.FetchError): Promise<void>;
declare function httpErrorHandler(response: FetchError): Promise<void>;
export { httpResponseErrorHandler, httpErrorHandler };
//# sourceMappingURL=http-error-handler.d.ts.map

@@ -1,4 +0,4 @@

import * as Types from '../types';
declare const MeiliSearchApiError: Types.MSApiErrorConstructor;
export default MeiliSearchApiError;
import { MSApiErrorConstructor } from '../types';
declare const MeiliSearchApiError: MSApiErrorConstructor;
export { MeiliSearchApiError };
//# sourceMappingURL=meilisearch-api-error.d.ts.map
import 'cross-fetch/polyfill';
import * as Types from '../types';
import { FetchError } from '../types';
declare class MeiliSearchCommunicationError extends Error {

@@ -8,5 +8,5 @@ type: string;

code?: string;
constructor(message: string, body: Response | Types.FetchError);
constructor(message: string, body: Response | FetchError);
}
export default MeiliSearchCommunicationError;
export { MeiliSearchCommunicationError };
//# sourceMappingURL=meilisearch-communication-error.d.ts.map

@@ -5,3 +5,3 @@ declare class MeiliSearchError extends Error {

}
export default MeiliSearchError;
export { MeiliSearchError };
//# sourceMappingURL=meilisearch-error.d.ts.map

@@ -5,3 +5,3 @@ declare class MeiliSearchTimeOutError extends Error {

}
export default MeiliSearchTimeOutError;
export { MeiliSearchTimeOutError };
//# sourceMappingURL=meilisearch-timeout-error.d.ts.map

@@ -1,291 +0,12 @@

import * as Types from './types';
import HttpRequests from './http-requests';
declare class Index<T> implements Types.IndexInterface<T> {
uid: string;
primaryKey: string | undefined;
httpRequest: HttpRequests;
constructor(config: Types.Config, uid: string, primaryKey?: string);
waitForPendingUpdate(updateId: number, { timeOutMs, intervalMs, }?: {
timeOutMs?: number;
intervalMs?: number;
}): Promise<Types.Update>;
/**
* Search for documents into an index
* @memberof Index
* @method search
*/
search<P extends Types.SearchParams<T>>(query?: string | null, options?: P, config?: Partial<Request>): Promise<Types.SearchResponse<T, P>>;
/**
* Search for documents into an index using the GET method
* @memberof Index
* @method search
*/
searchGet<P extends Types.SearchParams<T>>(query?: string | null, options?: P, config?: Partial<Request>): Promise<Types.SearchResponse<T, P>>;
/**
* Get index information.
* @memberof Index
* @method getRawInfo
*/
getRawInfo(): Promise<Types.IndexResponse>;
/**
* Fetch and update Index information.
* @memberof Index
* @method fetchInfo
*/
fetchInfo(): Promise<this>;
/**
* Get Primary Key.
* @memberof Index
* @method fetchPrimaryKey
*/
fetchPrimaryKey(): Promise<string | undefined>;
/**
* Create an index.
* @memberof Index
* @method create
*/
static create<T = any>(config: Types.Config, uid: string, options?: Types.IndexOptions): Promise<Index<T>>;
/**
* Update an index.
* @memberof Index
* @method update
*/
update(data: Types.IndexOptions): Promise<this>;
/**
* Delete an index.
* @memberof Index
* @method delete
*/
delete(): Promise<void>;
/**
* Deletes an index if it already exists.
* @memberof Index
* @method deleteIfExists
*/
deleteIfExists(): Promise<boolean>;
/**
* Get the list of all updates
* @memberof Index
* @method getAllUpdateStatus
*/
getAllUpdateStatus(): Promise<Types.Update[]>;
/**
* Get the informations about an update status
* @memberof Index
* @method getUpdateStatus
*/
getUpdateStatus(updateId: number): Promise<Types.Update>;
/**
* get stats of an index
* @memberof Index
* @method getStats
*/
getStats(): Promise<Types.IndexStats>;
/**
* get documents of an index
* @memberof Index
* @method getDocuments
*/
getDocuments<P extends Types.GetDocumentsParams<T>>(options?: P): Promise<Types.GetDocumentsResponse<T, P>>;
/**
* Get one document
* @memberof Index
* @method getDocument
*/
getDocument(documentId: string | number): Promise<Types.Document<T>>;
/**
* Add or replace multiples documents to an index
* @memberof Index
* @method addDocuments
*/
addDocuments(documents: Array<Types.Document<T>>, options?: Types.AddDocumentParams): Promise<Types.EnqueuedUpdate>;
/**
* Add or update multiples documents to an index
* @memberof Index
* @method updateDocuments
*/
updateDocuments(documents: Array<Types.Document<T>>, options?: Types.AddDocumentParams): Promise<Types.EnqueuedUpdate>;
/**
* Delete one document
* @memberof Index
* @method deleteDocument
*/
deleteDocument(documentId: string | number): Promise<Types.EnqueuedUpdate>;
/**
* Delete multiples documents of an index
* @memberof Index
* @method deleteDocuments
*/
deleteDocuments(documentsIds: string[] | number[]): Promise<Types.EnqueuedUpdate>;
/**
* Delete all documents of an index
* @memberof Index
* @method deleteAllDocuments
*/
deleteAllDocuments(): Promise<Types.EnqueuedUpdate>;
/**
* Retrieve all settings
* @memberof Index
* @method getSettings
*/
getSettings(): Promise<Types.Settings>;
/**
* Update all settings
* Any parameters not provided will be left unchanged.
* @memberof Index
* @method updateSettings
*/
updateSettings(settings: Types.Settings): Promise<Types.EnqueuedUpdate>;
/**
* Reset settings.
* @memberof Index
* @method resetSettings
*/
resetSettings(): Promise<Types.EnqueuedUpdate>;
/**
* Get the list of all synonyms
* @memberof Index
* @method getSynonyms
*/
getSynonyms(): Promise<object>;
/**
* Update the list of synonyms. Overwrite the old list.
* @memberof Index
* @method updateSynonyms
*/
updateSynonyms(synonyms: Types.Synonyms): Promise<Types.EnqueuedUpdate>;
/**
* Reset the synonym list to be empty again
* @memberof Index
* @method resetSynonyms
*/
resetSynonyms(): Promise<Types.EnqueuedUpdate>;
/**
* Get the list of all stop-words
* @memberof Index
* @method getStopWords
*/
getStopWords(): Promise<string[]>;
/**
* Update the list of stop-words. Overwrite the old list.
* @memberof Index
* @method updateStopWords
*/
updateStopWords(stopWords: Types.StopWords): Promise<Types.EnqueuedUpdate>;
/**
* Reset the stop-words list to be empty again
* @memberof Index
* @method resetStopWords
*/
resetStopWords(): Promise<Types.EnqueuedUpdate>;
/**
* Get the list of all ranking-rules
* @memberof Index
* @method getRankingRules
*/
getRankingRules(): Promise<string[]>;
/**
* Update the list of ranking-rules. Overwrite the old list.
* @memberof Index
* @method updateRankingRules
*/
updateRankingRules(rankingRules: Types.RankingRules): Promise<Types.EnqueuedUpdate>;
/**
* Reset the ranking rules list to its default value
* @memberof Index
* @method resetRankingRules
*/
resetRankingRules(): Promise<Types.EnqueuedUpdate>;
/**
* Get the distinct-attribute
* @memberof Index
* @method getDistinctAttribute
*/
getDistinctAttribute(): Promise<string | null>;
/**
* Update the distinct-attribute.
* @memberof Index
* @method updateDistinctAttribute
*/
updateDistinctAttribute(distinctAttribute: Types.DistinctAttribute): Promise<Types.EnqueuedUpdate>;
/**
* Reset the distinct-attribute.
* @memberof Index
* @method resetDistinctAttribute
*/
resetDistinctAttribute(): Promise<Types.EnqueuedUpdate>;
/**
* Get the filterable-attributes
* @memberof Index
* @method getFilterableAttributes
*/
getFilterableAttributes(): Promise<string[]>;
/**
* Update the filterable-attributes.
* @memberof Index
* @method updateFilterableAttributes
*/
updateFilterableAttributes(filterableAttributes: Types.FilterableAttributes): Promise<Types.EnqueuedUpdate>;
/**
* Reset the filterable-attributes.
* @memberof Index
* @method resetFilterableAttributes
*/
resetFilterableAttributes(): Promise<Types.EnqueuedUpdate>;
/**
* Get the sortable-attributes
* @memberof Index
* @method getSortableAttributes
*/
getSortableAttributes(): Promise<string[]>;
/**
* Update the sortable-attributes.
* @memberof Index
* @method updateSortableAttributes
*/
updateSortableAttributes(sortableAttributes: Types.SortableAttributes): Promise<Types.EnqueuedUpdate>;
/**
* Reset the sortable-attributes.
* @memberof Index
* @method resetSortableAttributes
*/
resetSortableAttributes(): Promise<Types.EnqueuedUpdate>;
/**
* Get the searchable-attributes
* @memberof Index
* @method getSearchableAttributes
*/
getSearchableAttributes(): Promise<string[]>;
/**
* Update the searchable-attributes.
* @memberof Index
* @method updateSearchableAttributes
*/
updateSearchableAttributes(searchableAttributes: Types.SearchableAttributes): Promise<Types.EnqueuedUpdate>;
/**
* Reset the searchable-attributes.
* @memberof Index
* @method resetSearchableAttributes
*/
resetSearchableAttributes(): Promise<Types.EnqueuedUpdate>;
/**
* Get the displayed-attributes
* @memberof Index
* @method getDisplayedAttributes
*/
getDisplayedAttributes(): Promise<string[]>;
/**
* Update the displayed-attributes.
* @memberof Index
* @method updateDisplayedAttributes
*/
updateDisplayedAttributes(displayedAttributes: Types.DisplayedAttributes): Promise<Types.EnqueuedUpdate>;
/**
* Reset the displayed-attributes.
* @memberof Index
* @method resetDisplayedAttributes
*/
resetDisplayedAttributes(): Promise<Types.EnqueuedUpdate>;
}
export { Index };
// Type definitions for meilisearch 0.20.2
// Project: https://github.com/meilisearch/meilisearch-js
// Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch>
// Definitions: https://github.com/meilisearch/meilisearch-js
// TypeScript Version: 4.4.3
export * from './types';
export * from './errors';
export * from './lib';
import { MeiliSearch } from './lib';
export default MeiliSearch;
//# sourceMappingURL=index.d.ts.map
{
"name": "meilisearch",
"version": "0.20.1",
"version": "0.20.2",
"description": "The MeiliSearch JS client for Node.js and the browser.",

@@ -22,4 +22,4 @@ "keywords": [

"browser": "./dist/bundles/meilisearch.umd.js",
"typings": "./dist/types/types.d.ts",
"types": "./dist/types/types.d.ts",
"typings": "./dist/types/index.d.ts",
"types": "./dist/types/index.d.ts",
"sideEffects": false,

@@ -26,0 +26,0 @@ "repository": {

@@ -205,2 +205,3 @@ <p align="center">

'wonder',
{
attributesToHighlight: ['*'],

@@ -207,0 +208,0 @@ filter: 'id >= 1'

@@ -1,4 +0,4 @@

import MeiliSearchCommunicationError from './meilisearch-communication-error'
import MeiliSearchApiError from './meilisearch-api-error'
import * as Types from '../types'
import { MeiliSearchCommunicationError } from './meilisearch-communication-error'
import { MeiliSearchApiError } from './meilisearch-api-error'
import { FetchError } from '../types'

@@ -18,3 +18,3 @@ async function httpResponseErrorHandler(response: Response): Promise<Response> {

function httpErrorHandler(response: Types.FetchError): Promise<void> {
function httpErrorHandler(response: FetchError): Promise<void> {
if (response.type !== 'MeiliSearchApiError') {

@@ -21,0 +21,0 @@ throw new MeiliSearchCommunicationError(response.message, response)

@@ -1,8 +0,12 @@

import * as Types from '../types'
import {
MSApiError,
MeiliSearchApiErrorResponse,
MSApiErrorConstructor,
} from '../types'
const MeiliSearchApiError: Types.MSApiErrorConstructor = class
const MeiliSearchApiError: MSApiErrorConstructor = class
extends Error
implements Types.MSApiError {
implements MSApiError {
httpStatus: number
response?: Types.MeiliSearchApiErrorResponse
response?: MeiliSearchApiErrorResponse
errorCode?: string

@@ -14,3 +18,3 @@ errorType?: string

constructor(error: Types.MSApiError, status: number) {
constructor(error: MSApiError, status: number) {
super(error.message)

@@ -25,8 +29,4 @@ this.type = 'MeiliSearchApiError'

this.httpStatus = status
if (Error.captureStackTrace) {
Error.captureStackTrace(this, MeiliSearchApiError)
}
}
}
export default MeiliSearchApiError
export { MeiliSearchApiError }
import 'cross-fetch/polyfill'
import * as Types from '../types'
import { FetchError } from '../types'

@@ -10,3 +10,3 @@ class MeiliSearchCommunicationError extends Error {

constructor(message: string, body: Response | Types.FetchError) {
constructor(message: string, body: Response | FetchError) {
super(message)

@@ -30,2 +30,2 @@ this.name = 'MeiliSearchCommunicationError'

export default MeiliSearchCommunicationError
export { MeiliSearchCommunicationError }

@@ -14,2 +14,2 @@ class MeiliSearchError extends Error {

export default MeiliSearchError
export { MeiliSearchError }

@@ -14,2 +14,2 @@ class MeiliSearchTimeOutError extends Error {

export default MeiliSearchTimeOutError
export { MeiliSearchTimeOutError }

@@ -1,669 +0,7 @@

/*
* Bundle: MeiliSearch / Indexes
* Project: MeiliSearch - Javascript API
* Author: Quentin de Quelen <quentin@meilisearch.com>
* Copyright: 2019, MeiliSearch
*/
export * from './types'
export * from './errors'
export * from './lib'
'use strict'
import { MeiliSearch } from './lib'
import MeiliSearchError from './errors/meilisearch-error'
import MeiliSearchTimeOutError from './errors/meilisearch-timeout-error'
import * as Types from './types'
import { sleep, removeUndefinedFromObject } from './utils'
import HttpRequests from './http-requests'
class Index<T> implements Types.IndexInterface<T> {
uid: string
primaryKey: string | undefined
httpRequest: HttpRequests
constructor(config: Types.Config, uid: string, primaryKey?: string) {
this.uid = uid
this.primaryKey = primaryKey
this.httpRequest = new HttpRequests(config)
}
///
/// UTILS
///
async waitForPendingUpdate(
updateId: number,
{
timeOutMs = 5000,
intervalMs = 50,
}: { timeOutMs?: number; intervalMs?: number } = {}
): Promise<Types.Update> {
const startingTime = Date.now()
while (Date.now() - startingTime < timeOutMs) {
const response = await this.getUpdateStatus(updateId)
if (!['enqueued', 'processing'].includes(response.status)) return response
await sleep(intervalMs)
}
throw new MeiliSearchTimeOutError(
`timeout of ${timeOutMs}ms has exceeded on process ${updateId} when waiting for pending update to resolve.`
)
}
///
/// SEARCH
///
/**
* Search for documents into an index
* @memberof Index
* @method search
*/
async search<P extends Types.SearchParams<T>>(
query?: string | null,
options?: P,
config?: Partial<Request>
): Promise<Types.SearchResponse<T, P>> {
const url = `indexes/${this.uid}/search`
return await this.httpRequest.post(
url,
removeUndefinedFromObject({ ...options, q: query }),
undefined,
config
)
}
/**
* Search for documents into an index using the GET method
* @memberof Index
* @method search
*/
async searchGet<P extends Types.SearchParams<T>>(
query?: string | null,
options?: P,
config?: Partial<Request>
): Promise<Types.SearchResponse<T, P>> {
const url = `indexes/${this.uid}/search`
const parseFilter = (filter?: Types.Filter): string | undefined => {
if (typeof filter === 'string') return filter
else if (Array.isArray(filter))
throw new MeiliSearchError(
'The filter query parameter should be in string format when using searchGet'
)
else return undefined
}
const getParams: Types.SearchRequestGET = {
q: query,
...options,
filter: parseFilter(options?.filter),
sort: options?.sort ? options.sort.join(',') : undefined,
facetsDistribution: options?.facetsDistribution
? options.facetsDistribution.join(',')
: undefined,
attributesToRetrieve: options?.attributesToRetrieve
? options.attributesToRetrieve.join(',')
: undefined,
attributesToCrop: options?.attributesToCrop
? options.attributesToCrop.join(',')
: undefined,
attributesToHighlight: options?.attributesToHighlight
? options.attributesToHighlight.join(',')
: undefined,
}
return await this.httpRequest.get<Types.SearchResponse<T, P>>(
url,
removeUndefinedFromObject(getParams),
config
)
}
///
/// INDEX
///
/**
* Get index information.
* @memberof Index
* @method getRawInfo
*/
async getRawInfo(): Promise<Types.IndexResponse> {
const url = `indexes/${this.uid}`
const res = await this.httpRequest.get<Types.IndexResponse>(url)
this.primaryKey = res.primaryKey
return res
}
/**
* Fetch and update Index information.
* @memberof Index
* @method fetchInfo
*/
async fetchInfo(): Promise<this> {
await this.getRawInfo()
return this
}
/**
* Get Primary Key.
* @memberof Index
* @method fetchPrimaryKey
*/
async fetchPrimaryKey(): Promise<string | undefined> {
this.primaryKey = (await this.getRawInfo()).primaryKey
return this.primaryKey
}
/**
* Create an index.
* @memberof Index
* @method create
*/
static async create<T = any>(
config: Types.Config,
uid: string,
options: Types.IndexOptions = {}
): Promise<Index<T>> {
const url = `indexes`
const req = new HttpRequests(config)
const index = await req.post(url, { ...options, uid })
return new Index(config, uid, index.primaryKey)
}
/**
* Update an index.
* @memberof Index
* @method update
*/
async update(data: Types.IndexOptions): Promise<this> {
const url = `indexes/${this.uid}`
const index = await this.httpRequest.put(url, data)
this.primaryKey = index.primaryKey
return this
}
/**
* Delete an index.
* @memberof Index
* @method delete
*/
async delete(): Promise<void> {
const url = `indexes/${this.uid}`
return await this.httpRequest.delete(url)
}
/**
* Deletes an index if it already exists.
* @memberof Index
* @method deleteIfExists
*/
async deleteIfExists(): Promise<boolean> {
try {
await this.delete()
return true
} catch (e) {
if (e.errorCode === 'index_not_found') {
return false
}
throw e
}
}
///
/// UPDATES
///
/**
* Get the list of all updates
* @memberof Index
* @method getAllUpdateStatus
*/
async getAllUpdateStatus(): Promise<Types.Update[]> {
const url = `indexes/${this.uid}/updates`
return await this.httpRequest.get<Types.Update[]>(url)
}
/**
* Get the informations about an update status
* @memberof Index
* @method getUpdateStatus
*/
async getUpdateStatus(updateId: number): Promise<Types.Update> {
const url = `indexes/${this.uid}/updates/${updateId}`
return await this.httpRequest.get<Types.Update>(url)
}
///
/// STATS
///
/**
* get stats of an index
* @memberof Index
* @method getStats
*/
async getStats(): Promise<Types.IndexStats> {
const url = `indexes/${this.uid}/stats`
return await this.httpRequest.get<Types.IndexStats>(url)
}
///
/// DOCUMENTS
///
/**
* get documents of an index
* @memberof Index
* @method getDocuments
*/
async getDocuments<P extends Types.GetDocumentsParams<T>>(
options?: P
): Promise<Types.GetDocumentsResponse<T, P>> {
const url = `indexes/${this.uid}/documents`
let attr
if (options !== undefined && Array.isArray(options.attributesToRetrieve)) {
attr = options.attributesToRetrieve.join(',')
}
return await this.httpRequest.get<Types.GetDocumentsResponse<T, P>>(url, {
...options,
...(attr !== undefined ? { attributesToRetrieve: attr } : {}),
})
}
/**
* Get one document
* @memberof Index
* @method getDocument
*/
async getDocument(documentId: string | number): Promise<Types.Document<T>> {
const url = `indexes/${this.uid}/documents/${documentId}`
return await this.httpRequest.get<Types.Document<T>>(url)
}
/**
* Add or replace multiples documents to an index
* @memberof Index
* @method addDocuments
*/
async addDocuments(
documents: Array<Types.Document<T>>,
options?: Types.AddDocumentParams
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/documents`
return await this.httpRequest.post(url, documents, options)
}
/**
* Add or update multiples documents to an index
* @memberof Index
* @method updateDocuments
*/
async updateDocuments(
documents: Array<Types.Document<T>>,
options?: Types.AddDocumentParams
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/documents`
return await this.httpRequest.put(url, documents, options)
}
/**
* Delete one document
* @memberof Index
* @method deleteDocument
*/
async deleteDocument(
documentId: string | number
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/documents/${documentId}`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
/**
* Delete multiples documents of an index
* @memberof Index
* @method deleteDocuments
*/
async deleteDocuments(
documentsIds: string[] | number[]
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/documents/delete-batch`
return await this.httpRequest.post(url, documentsIds)
}
/**
* Delete all documents of an index
* @memberof Index
* @method deleteAllDocuments
*/
async deleteAllDocuments(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/documents`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// SETTINGS
///
/**
* Retrieve all settings
* @memberof Index
* @method getSettings
*/
async getSettings(): Promise<Types.Settings> {
const url = `indexes/${this.uid}/settings`
return await this.httpRequest.get<Types.Settings>(url)
}
/**
* Update all settings
* Any parameters not provided will be left unchanged.
* @memberof Index
* @method updateSettings
*/
async updateSettings(
settings: Types.Settings
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings`
return await this.httpRequest.post(url, settings)
}
/**
* Reset settings.
* @memberof Index
* @method resetSettings
*/
async resetSettings(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// SYNONYMS
///
/**
* Get the list of all synonyms
* @memberof Index
* @method getSynonyms
*/
async getSynonyms(): Promise<object> {
const url = `indexes/${this.uid}/settings/synonyms`
return await this.httpRequest.get<object>(url)
}
/**
* Update the list of synonyms. Overwrite the old list.
* @memberof Index
* @method updateSynonyms
*/
async updateSynonyms(
synonyms: Types.Synonyms
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/synonyms`
return await this.httpRequest.post(url, synonyms)
}
/**
* Reset the synonym list to be empty again
* @memberof Index
* @method resetSynonyms
*/
async resetSynonyms(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/synonyms`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// STOP WORDS
///
/**
* Get the list of all stop-words
* @memberof Index
* @method getStopWords
*/
async getStopWords(): Promise<string[]> {
const url = `indexes/${this.uid}/settings/stop-words`
return await this.httpRequest.get<string[]>(url)
}
/**
* Update the list of stop-words. Overwrite the old list.
* @memberof Index
* @method updateStopWords
*/
async updateStopWords(
stopWords: Types.StopWords
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/stop-words`
return await this.httpRequest.post(url, stopWords)
}
/**
* Reset the stop-words list to be empty again
* @memberof Index
* @method resetStopWords
*/
async resetStopWords(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/stop-words`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// RANKING RULES
///
/**
* Get the list of all ranking-rules
* @memberof Index
* @method getRankingRules
*/
async getRankingRules(): Promise<string[]> {
const url = `indexes/${this.uid}/settings/ranking-rules`
return await this.httpRequest.get<string[]>(url)
}
/**
* Update the list of ranking-rules. Overwrite the old list.
* @memberof Index
* @method updateRankingRules
*/
async updateRankingRules(
rankingRules: Types.RankingRules
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/ranking-rules`
return await this.httpRequest.post(url, rankingRules)
}
/**
* Reset the ranking rules list to its default value
* @memberof Index
* @method resetRankingRules
*/
async resetRankingRules(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/ranking-rules`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// DISTINCT ATTRIBUTE
///
/**
* Get the distinct-attribute
* @memberof Index
* @method getDistinctAttribute
*/
async getDistinctAttribute(): Promise<string | null> {
const url = `indexes/${this.uid}/settings/distinct-attribute`
return await this.httpRequest.get<string | null>(url)
}
/**
* Update the distinct-attribute.
* @memberof Index
* @method updateDistinctAttribute
*/
async updateDistinctAttribute(
distinctAttribute: Types.DistinctAttribute
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/distinct-attribute`
return await this.httpRequest.post(url, distinctAttribute)
}
/**
* Reset the distinct-attribute.
* @memberof Index
* @method resetDistinctAttribute
*/
async resetDistinctAttribute(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/distinct-attribute`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// FILTERABLE ATTRIBUTES
///
/**
* Get the filterable-attributes
* @memberof Index
* @method getFilterableAttributes
*/
async getFilterableAttributes(): Promise<string[]> {
const url = `indexes/${this.uid}/settings/filterable-attributes`
return await this.httpRequest.get<string[]>(url)
}
/**
* Update the filterable-attributes.
* @memberof Index
* @method updateFilterableAttributes
*/
async updateFilterableAttributes(
filterableAttributes: Types.FilterableAttributes
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/filterable-attributes`
return await this.httpRequest.post(url, filterableAttributes)
}
/**
* Reset the filterable-attributes.
* @memberof Index
* @method resetFilterableAttributes
*/
async resetFilterableAttributes(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/filterable-attributes`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// SORTABLE ATTRIBUTES
///
/**
* Get the sortable-attributes
* @memberof Index
* @method getSortableAttributes
*/
async getSortableAttributes(): Promise<string[]> {
const url = `indexes/${this.uid}/settings/sortable-attributes`
return await this.httpRequest.get<string[]>(url)
}
/**
* Update the sortable-attributes.
* @memberof Index
* @method updateSortableAttributes
*/
async updateSortableAttributes(
sortableAttributes: Types.SortableAttributes
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/sortable-attributes`
return await this.httpRequest.post(url, sortableAttributes)
}
/**
* Reset the sortable-attributes.
* @memberof Index
* @method resetSortableAttributes
*/
async resetSortableAttributes(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/sortable-attributes`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// SEARCHABLE ATTRIBUTE
///
/**
* Get the searchable-attributes
* @memberof Index
* @method getSearchableAttributes
*/
async getSearchableAttributes(): Promise<string[]> {
const url = `indexes/${this.uid}/settings/searchable-attributes`
return await this.httpRequest.get<string[]>(url)
}
/**
* Update the searchable-attributes.
* @memberof Index
* @method updateSearchableAttributes
*/
async updateSearchableAttributes(
searchableAttributes: Types.SearchableAttributes
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/searchable-attributes`
return await this.httpRequest.post(url, searchableAttributes)
}
/**
* Reset the searchable-attributes.
* @memberof Index
* @method resetSearchableAttributes
*/
async resetSearchableAttributes(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/searchable-attributes`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
///
/// DISPLAYED ATTRIBUTE
///
/**
* Get the displayed-attributes
* @memberof Index
* @method getDisplayedAttributes
*/
async getDisplayedAttributes(): Promise<string[]> {
const url = `indexes/${this.uid}/settings/displayed-attributes`
return await this.httpRequest.get<string[]>(url)
}
/**
* Update the displayed-attributes.
* @memberof Index
* @method updateDisplayedAttributes
*/
async updateDisplayedAttributes(
displayedAttributes: Types.DisplayedAttributes
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/displayed-attributes`
return await this.httpRequest.post(url, displayedAttributes)
}
/**
* Reset the displayed-attributes.
* @memberof Index
* @method resetDisplayedAttributes
*/
async resetDisplayedAttributes(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/displayed-attributes`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)
}
}
export { Index }
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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc