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.19.0 to 0.20.0

84

dist/bundles/meilisearch.esm.js

@@ -350,3 +350,3 @@ import 'cross-fetch/polyfill';

response = _e.sent();
if (response.status !== 'enqueued')
if (!['enqueued', 'processing'].includes(response.status))
return [2 /*return*/, response];

@@ -370,6 +370,5 @@ return [4 /*yield*/, sleep(intervalMs)];

*/
Index.prototype.search = function (query, options, method, config) {
if (method === void 0) { method = 'POST'; }
Index.prototype.search = function (query, options, config) {
return __awaiter(this, void 0, void 0, function () {
var url, params, getParams;
var url;
return __generator(this, function (_a) {

@@ -379,24 +378,30 @@ switch (_a.label) {

url = "indexes/" + this.uid + "/search";
params = {
q: query,
offset: options === null || options === void 0 ? void 0 : options.offset,
limit: options === null || options === void 0 ? void 0 : options.limit,
cropLength: options === null || options === void 0 ? void 0 : options.cropLength,
filters: options === null || options === void 0 ? void 0 : options.filters,
matches: options === null || options === void 0 ? void 0 : options.matches,
facetFilters: options === null || options === void 0 ? void 0 : options.facetFilters,
facetsDistribution: options === null || options === void 0 ? void 0 : options.facetsDistribution,
attributesToRetrieve: options === null || options === void 0 ? void 0 : options.attributesToRetrieve,
attributesToCrop: options === null || options === void 0 ? void 0 : options.attributesToCrop,
attributesToHighlight: options === null || options === void 0 ? void 0 : options.attributesToHighlight,
return [4 /*yield*/, this.httpRequest.post(url, removeUndefinedFromObject(__assign(__assign({}, options), { q: query })), undefined, config)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Search for documents into an index using the GET method
* @memberof Index
* @method search
*/
Index.prototype.searchGet = function (query, options, config) {
return __awaiter(this, void 0, void 0, function () {
var url, parseFilter, getParams;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "indexes/" + this.uid + "/search";
parseFilter = function (filter) {
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;
};
if (!(method.toUpperCase() === 'POST')) return [3 /*break*/, 2];
return [4 /*yield*/, this.httpRequest.post(url, removeUndefinedFromObject(params), undefined, config)];
case 1: return [2 /*return*/, _a.sent()];
case 2:
if (!(method.toUpperCase() === 'GET')) return [3 /*break*/, 4];
getParams = __assign(__assign({}, params), { facetFilters: Array.isArray(options === null || options === void 0 ? void 0 : options.facetFilters) && (options === null || options === void 0 ? void 0 : options.facetFilters)
? JSON.stringify(options.facetFilters)
: undefined, facetsDistribution: (options === null || options === void 0 ? void 0 : options.facetsDistribution)
? JSON.stringify(options.facetsDistribution)
getParams = __assign(__assign({ q: query }, options), { filter: parseFilter(options === null || options === void 0 ? void 0 : options.filter), facetsDistribution: (options === null || options === void 0 ? void 0 : options.facetsDistribution)
? options.facetsDistribution.join(',')
: undefined, attributesToRetrieve: (options === null || options === void 0 ? void 0 : options.attributesToRetrieve)

@@ -410,4 +415,3 @@ ? options.attributesToRetrieve.join(',')

return [4 /*yield*/, this.httpRequest.get(url, removeUndefinedFromObject(getParams), config)];
case 3: return [2 /*return*/, _a.sent()];
case 4: throw new MeiliSearchError('method parameter should be either POST or GET');
case 1: return [2 /*return*/, _a.sent()];
}

@@ -1048,7 +1052,7 @@ });

/**
* Get the attributes-for-faceting
* Get the filterable-attributes
* @memberof Index
* @method getAttributesForFaceting
* @method getFilterableAttributes
*/
Index.prototype.getAttributesForFaceting = function () {
Index.prototype.getFilterableAttributes = function () {
return __awaiter(this, void 0, void 0, function () {

@@ -1059,3 +1063,3 @@ var url;

case 0:
url = "indexes/" + this.uid + "/settings/attributes-for-faceting";
url = "indexes/" + this.uid + "/settings/filterable-attributes";
return [4 /*yield*/, this.httpRequest.get(url)];

@@ -1068,7 +1072,7 @@ case 1: return [2 /*return*/, _a.sent()];

/**
* Update the attributes-for-faceting.
* Update the filterable-attributes.
* @memberof Index
* @method updateAttributesForFaceting
* @method updateFilterableAttributes
*/
Index.prototype.updateAttributesForFaceting = function (attributesForFaceting) {
Index.prototype.updateFilterableAttributes = function (filterableAttributes) {
return __awaiter(this, void 0, void 0, function () {

@@ -1079,4 +1083,4 @@ var url;

case 0:
url = "indexes/" + this.uid + "/settings/attributes-for-faceting";
return [4 /*yield*/, this.httpRequest.post(url, attributesForFaceting)];
url = "indexes/" + this.uid + "/settings/filterable-attributes";
return [4 /*yield*/, this.httpRequest.post(url, filterableAttributes)];
case 1: return [2 /*return*/, _a.sent()];

@@ -1088,7 +1092,7 @@ }

/**
* Reset the attributes-for-faceting.
* Reset the filterable-attributes.
* @memberof Index
* @method resetAttributesForFaceting
* @method resetFilterableAttributes
*/
Index.prototype.resetAttributesForFaceting = function () {
Index.prototype.resetFilterableAttributes = function () {
return __awaiter(this, void 0, void 0, function () {

@@ -1099,3 +1103,3 @@ var url;

case 0:
url = "indexes/" + this.uid + "/settings/attributes-for-faceting";
url = "indexes/" + this.uid + "/settings/filterable-attributes";
return [4 /*yield*/, this.httpRequest["delete"](url)];

@@ -1102,0 +1106,0 @@ case 1: return [2 /*return*/, _a.sent()];

@@ -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"enqueued"!==(n=r.sent()).status?[2,n]:[4,c(h)];case 3:return r.sent(),[3,1];case 4:throw new u("timeout of "+o+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.search=function(t,e,u,c){return void 0===u&&(u="POST"),r(this,void 0,void 0,(function(){var r,a,h;return i(this,(function(i){switch(i.label){case 0:return r="indexes/"+this.uid+"/search",a={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==u.toUpperCase()?[3,2]:[4,this.httpRequest.post(r,o(a),void 0,c)];case 1:return[2,i.sent()];case 2:return"GET"!==u.toUpperCase()?[3,4]:(h=n(n({},a),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(r,o(h),c)]);case 3:return[2,i.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},t.prototype.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.getAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateAttributesForFaceting=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetAttributesForFaceting=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),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){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),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.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};
//# sourceMappingURL=meilisearch.esm.min.js.map

@@ -505,3 +505,3 @@ (function (global, factory) {

response = _e.sent();
if (response.status !== 'enqueued') return [2
if (!['enqueued', 'processing'].includes(response.status)) return [2
/*return*/

@@ -536,9 +536,5 @@ , response];

Index.prototype.search = function (query, options, method, config) {
if (method === void 0) {
method = 'POST';
}
Index.prototype.search = function (query, options, config) {
return __awaiter(this, void 0, void 0, function () {
var url, params, getParams;
var url;
return __generator(this, function (_a) {

@@ -548,21 +544,7 @@ switch (_a.label) {

url = "indexes/" + this.uid + "/search";
params = {
q: query,
offset: options === null || options === void 0 ? void 0 : options.offset,
limit: options === null || options === void 0 ? void 0 : options.limit,
cropLength: options === null || options === void 0 ? void 0 : options.cropLength,
filters: options === null || options === void 0 ? void 0 : options.filters,
matches: options === null || options === void 0 ? void 0 : options.matches,
facetFilters: options === null || options === void 0 ? void 0 : options.facetFilters,
facetsDistribution: options === null || options === void 0 ? void 0 : options.facetsDistribution,
attributesToRetrieve: options === null || options === void 0 ? void 0 : options.attributesToRetrieve,
attributesToCrop: options === null || options === void 0 ? void 0 : options.attributesToCrop,
attributesToHighlight: options === null || options === void 0 ? void 0 : options.attributesToHighlight
};
if (!(method.toUpperCase() === 'POST')) return [3
/*break*/
, 2];
return [4
/*yield*/
, this.httpRequest.post(url, removeUndefinedFromObject(params), undefined, config)];
, this.httpRequest.post(url, removeUndefinedFromObject(__assign(__assign({}, options), {
q: query
})), undefined, config)];

@@ -573,10 +555,30 @@ case 1:

, _a.sent()];
}
});
});
};
/**
* Search for documents into an index using the GET method
* @memberof Index
* @method search
*/
case 2:
if (!(method.toUpperCase() === 'GET')) return [3
/*break*/
, 4];
getParams = __assign(__assign({}, params), {
facetFilters: Array.isArray(options === null || options === void 0 ? void 0 : options.facetFilters) && (options === null || options === void 0 ? void 0 : options.facetFilters) ? JSON.stringify(options.facetFilters) : undefined,
facetsDistribution: (options === null || options === void 0 ? void 0 : options.facetsDistribution) ? JSON.stringify(options.facetsDistribution) : undefined,
Index.prototype.searchGet = function (query, options, config) {
return __awaiter(this, void 0, void 0, function () {
var url, parseFilter, getParams;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "indexes/" + this.uid + "/search";
parseFilter = function parseFilter(filter) {
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;
};
getParams = __assign(__assign({
q: query
}, options), {
filter: parseFilter(options === null || options === void 0 ? void 0 : options.filter),
facetsDistribution: (options === null || options === void 0 ? void 0 : options.facetsDistribution) ? options.facetsDistribution.join(',') : undefined,
attributesToRetrieve: (options === null || options === void 0 ? void 0 : options.attributesToRetrieve) ? options.attributesToRetrieve.join(',') : undefined,

@@ -590,9 +592,6 @@ attributesToCrop: (options === null || options === void 0 ? void 0 : options.attributesToCrop) ? options.attributesToCrop.join(',') : undefined,

case 3:
case 1:
return [2
/*return*/
, _a.sent()];
case 4:
throw new MeiliSearchError('method parameter should be either POST or GET');
}

@@ -1506,9 +1505,9 @@ });

/**
* Get the attributes-for-faceting
* Get the filterable-attributes
* @memberof Index
* @method getAttributesForFaceting
* @method getFilterableAttributes
*/
Index.prototype.getAttributesForFaceting = function () {
Index.prototype.getFilterableAttributes = function () {
return __awaiter(this, void 0, void 0, function () {

@@ -1519,3 +1518,3 @@ var url;

case 0:
url = "indexes/" + this.uid + "/settings/attributes-for-faceting";
url = "indexes/" + this.uid + "/settings/filterable-attributes";
return [4

@@ -1534,9 +1533,9 @@ /*yield*/

/**
* Update the attributes-for-faceting.
* Update the filterable-attributes.
* @memberof Index
* @method updateAttributesForFaceting
* @method updateFilterableAttributes
*/
Index.prototype.updateAttributesForFaceting = function (attributesForFaceting) {
Index.prototype.updateFilterableAttributes = function (filterableAttributes) {
return __awaiter(this, void 0, void 0, function () {

@@ -1547,6 +1546,6 @@ var url;

case 0:
url = "indexes/" + this.uid + "/settings/attributes-for-faceting";
url = "indexes/" + this.uid + "/settings/filterable-attributes";
return [4
/*yield*/
, this.httpRequest.post(url, attributesForFaceting)];
, this.httpRequest.post(url, filterableAttributes)];

@@ -1562,9 +1561,9 @@ case 1:

/**
* Reset the attributes-for-faceting.
* Reset the filterable-attributes.
* @memberof Index
* @method resetAttributesForFaceting
* @method resetFilterableAttributes
*/
Index.prototype.resetAttributesForFaceting = function () {
Index.prototype.resetFilterableAttributes = function () {
return __awaiter(this, void 0, void 0, function () {

@@ -1575,3 +1574,3 @@ var url;

case 0:
url = "indexes/" + this.uid + "/settings/attributes-for-faceting";
url = "indexes/" + this.uid + "/settings/filterable-attributes";
return [4

@@ -1578,0 +1577,0 @@ /*yield*/

@@ -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 f=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,f;return s(this,(function(p){switch(p.label){case 0:return p.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,p.sent().text()];case 2:f=p.sent();try{return[2,JSON.parse(f)]}catch(t){return[2]}return[3,4];case 3:return function(t){if("MeiliSearchApiError"!==t.type)throw new h(t.message,t);throw t}(p.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return 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}(),p=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new f(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"enqueued"!==(n=r.sent()).status?[2,n]:[4,a(h)];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,o){return void 0===n&&(n="POST"),i(this,void 0,void 0,(function(){var i,a,h;return s(this,(function(s){switch(s.label){case 0:return i="indexes/"+this.uid+"/search",a={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==n.toUpperCase()?[3,2]:[4,this.httpRequest.post(i,c(a),void 0,o)];case 1:return[2,s.sent()];case 2:return"GET"!==n.toUpperCase()?[3,4]:(h=r(r({},a),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(i,c(h),o)]);case 3:return[2,s.sent()];case 4:throw new u("method parameter should be either POST or GET")}}))}))},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 f(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.getAttributesForFaceting=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateAttributesForFaceting=function(t){return i(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetAttributesForFaceting=function(){return i(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return 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=f.addTrailingSlash(t.host),this.config=t,this.httpRequest=new f(t)}return t.prototype.index=function(t){return new p(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new p(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,p.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 p(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 p(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){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),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.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})}));
//# sourceMappingURL=meilisearch.umd.min.js.map

@@ -17,4 +17,10 @@ import * as Types from './types';

*/
search<P extends Types.SearchParams<T>>(query?: string | null, options?: P, method?: Types.Methods, config?: Partial<Request>): Promise<Types.SearchResponse<T, P>>;
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.

@@ -151,3 +157,3 @@ * @memberof Index

*/
updateSynonyms(synonyms: object): Promise<Types.EnqueuedUpdate>;
updateSynonyms(synonyms: Types.Synonyms): Promise<Types.EnqueuedUpdate>;
/**

@@ -170,3 +176,3 @@ * Reset the synonym list to be empty again

*/
updateStopWords(stopWords: string[]): Promise<Types.EnqueuedUpdate>;
updateStopWords(stopWords: Types.StopWords): Promise<Types.EnqueuedUpdate>;
/**

@@ -189,3 +195,3 @@ * Reset the stop-words list to be empty again

*/
updateRankingRules(rankingRules: string[] | null): Promise<Types.EnqueuedUpdate>;
updateRankingRules(rankingRules: Types.RankingRules): Promise<Types.EnqueuedUpdate>;
/**

@@ -208,3 +214,3 @@ * Reset the ranking rules list to its default value

*/
updateDistinctAttribute(distinctAttribute: string | null): Promise<Types.EnqueuedUpdate>;
updateDistinctAttribute(distinctAttribute: Types.DistinctAttribute): Promise<Types.EnqueuedUpdate>;
/**

@@ -217,19 +223,19 @@ * Reset the distinct-attribute.

/**
* Get the attributes-for-faceting
* Get the filterable-attributes
* @memberof Index
* @method getAttributesForFaceting
* @method getFilterableAttributes
*/
getAttributesForFaceting(): Promise<string[]>;
getFilterableAttributes(): Promise<string[]>;
/**
* Update the attributes-for-faceting.
* Update the filterable-attributes.
* @memberof Index
* @method updateAttributesForFaceting
* @method updateFilterableAttributes
*/
updateAttributesForFaceting(attributesForFaceting: string[] | null): Promise<Types.EnqueuedUpdate>;
updateFilterableAttributes(filterableAttributes: Types.FilterableAttributes): Promise<Types.EnqueuedUpdate>;
/**
* Reset the attributes-for-faceting.
* Reset the filterable-attributes.
* @memberof Index
* @method resetAttributesForFaceting
* @method resetFilterableAttributes
*/
resetAttributesForFaceting(): Promise<Types.EnqueuedUpdate>;
resetFilterableAttributes(): Promise<Types.EnqueuedUpdate>;
/**

@@ -246,3 +252,3 @@ * Get the searchable-attributes

*/
updateSearchableAttributes(searchableAttributes: string[] | null): Promise<Types.EnqueuedUpdate>;
updateSearchableAttributes(searchableAttributes: Types.SearchableAttributes): Promise<Types.EnqueuedUpdate>;
/**

@@ -265,3 +271,3 @@ * Reset the searchable-attributes.

*/
updateDisplayedAttributes(displayedAttributes: string[] | null): Promise<Types.EnqueuedUpdate>;
updateDisplayedAttributes(displayedAttributes: Types.DisplayedAttributes): Promise<Types.EnqueuedUpdate>;
/**

@@ -268,0 +274,0 @@ * Reset the displayed-attributes.

@@ -1,2 +0,2 @@

// Type definitions for meilisearch 0.19.0
// Type definitions for meilisearch 0.20.0
// Project: https://github.com/meilisearch/meilisearch-js

@@ -39,3 +39,3 @@ // Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch>

}
export declare type FacetFilter = Array<string | string[]>;
export declare type Filter = string | Array<string | string[]>;
export interface SearchParams<T> {

@@ -48,31 +48,28 @@ offset?: number;

attributesToHighlight?: Array<Extract<keyof T, string> | '*'>;
filters?: string;
facetFilters?: FacetFilter | FacetFilter[];
filter?: Filter;
facetsDistribution?: string[];
matches?: boolean;
}
export interface SearchRequest {
export interface SearchRequestGET {
q?: string | null;
offset?: number;
limit?: number;
attributesToRetrieve?: string;
attributesToCrop?: string;
cropLength?: number;
attributesToRetrieve?: string[];
attributesToCrop?: string[];
attributesToHighlight?: string[];
facetFilters?: FacetFilter | FacetFilter[];
facetsDistribution?: string[];
filters?: string;
attributesToHighlight?: string;
facetsDistribution?: string;
filter?: string;
matches?: boolean;
}
export interface GetSearchRequest {
export interface SearchRequest {
q?: string | null;
offset?: number;
limit?: number;
attributesToRetrieve?: string;
attributesToCrop?: string;
cropLength?: number;
attributesToHighlight?: string;
facetFilters?: string;
facetsDistribution?: string;
filters?: string;
attributesToRetrieve?: string[];
attributesToCrop?: string[];
attributesToHighlight?: string[];
facetsDistribution?: string[];
filter?: Filter;
matches?: boolean;

@@ -105,3 +102,3 @@ }

}
export interface FieldsDistribution {
export interface FieldDistribution {
[field: string]: number;

@@ -116,12 +113,19 @@ }

export declare type Document<T> = T;
export declare type FilterableAttributes = string[] | null;
export declare type DistinctAttribute = string | null;
export declare type SearchableAttributes = string[] | null;
export declare type DisplayedAttributes = string[] | null;
export declare type RankingRules = string[] | null;
export declare type StopWords = string[] | null;
export declare type Synonyms = {
[field: string]: string[];
} | null;
export interface Settings {
attributesForFaceting?: string[];
distinctAttribute?: string;
searchableAttributes?: string[];
displayedAttributes?: string[];
rankingRules?: string[];
stopWords?: string[];
synonyms?: {
[field: string]: string[];
};
filterableAttributes?: FilterableAttributes;
distinctAttribute?: DistinctAttribute;
searchableAttributes?: SearchableAttributes;
displayedAttributes?: DisplayedAttributes;
rankingRules?: RankingRules;
stopWords?: StopWords;
synonyms?: Synonyms;
}

@@ -145,2 +149,4 @@ export interface EnqueuedUpdate {

status: 'in_progress' | 'failed' | 'done';
startedAt: string;
finishedAt: string;
}

@@ -153,3 +159,3 @@ export interface Health {

isIndexing: boolean;
fieldsDistribution: FieldsDistribution;
fieldDistribution: FieldDistribution;
}

@@ -169,3 +175,3 @@ export interface Stats {

commitSha: string;
buildDate: string;
commitDate: string;
pkgVersion: string;

@@ -191,3 +197,2 @@ }

}
export declare type Methods = 'POST' | 'GET';
export interface IndexInterface<T = any> {

@@ -197,3 +202,4 @@ uid: string;

getAllUpdateStatus: () => Promise<Update[]>;
search: <P extends SearchParams<T>>(query?: string | null, options?: P, method?: Methods, config?: Partial<Request>) => Promise<SearchResponse<T, P>>;
search: <P extends SearchParams<T>>(query?: string | null, options?: P, config?: Partial<Request>) => Promise<SearchResponse<T, P>>;
searchGet: <P extends SearchParams<T>>(query?: string | null, options?: P, config?: Partial<Request>) => Promise<SearchResponse<T, P>>;
getRawInfo: () => Promise<IndexResponse>;

@@ -217,21 +223,21 @@ fetchInfo(): Promise<this>;

getSynonyms: () => Promise<object>;
updateSynonyms: (synonyms: object) => Promise<object>;
updateSynonyms: (synonyms: Synonyms) => Promise<object>;
resetSynonyms: () => Promise<object>;
getStopWords: () => Promise<string[]>;
updateStopWords: (stopWords: string[]) => Promise<EnqueuedUpdate>;
updateStopWords: (stopWords: StopWords) => Promise<EnqueuedUpdate>;
resetStopWords: () => Promise<EnqueuedUpdate>;
getRankingRules: () => Promise<string[]>;
updateRankingRules: (rankingRules: string[] | null) => Promise<EnqueuedUpdate>;
updateRankingRules: (rankingRules: RankingRules) => Promise<EnqueuedUpdate>;
resetRankingRules: () => Promise<EnqueuedUpdate>;
getDistinctAttribute: () => Promise<string | null>;
updateDistinctAttribute: (distinctAttribute: string | null) => Promise<EnqueuedUpdate>;
updateDistinctAttribute: (distinctAttribute: DistinctAttribute) => Promise<EnqueuedUpdate>;
resetDistinctAttribute: () => Promise<EnqueuedUpdate>;
getAttributesForFaceting: () => Promise<string[]>;
updateAttributesForFaceting: (attributesForFaceting: string[] | null) => Promise<EnqueuedUpdate>;
resetAttributesForFaceting: () => Promise<EnqueuedUpdate>;
getFilterableAttributes: () => Promise<string[]>;
updateFilterableAttributes: (filterableAttributes: FilterableAttributes) => Promise<EnqueuedUpdate>;
resetFilterableAttributes: () => Promise<EnqueuedUpdate>;
getSearchableAttributes: () => Promise<string[]>;
updateSearchableAttributes: (searchableAttributes: string[] | null) => Promise<EnqueuedUpdate>;
updateSearchableAttributes: (searchableAttributes: SearchableAttributes) => Promise<EnqueuedUpdate>;
resetSearchableAttributes: () => Promise<EnqueuedUpdate>;
getDisplayedAttributes: () => Promise<string[]>;
updateDisplayedAttributes: (displayedAttributes: string[] | null) => Promise<EnqueuedUpdate>;
updateDisplayedAttributes: (displayedAttributes: DisplayedAttributes) => Promise<EnqueuedUpdate>;
resetDisplayedAttributes: () => Promise<EnqueuedUpdate>;

@@ -238,0 +244,0 @@ }

{
"name": "meilisearch",
"version": "0.19.0",
"version": "0.20.0",
"description": "The MeiliSearch JS client for Node.js and the browser.",

@@ -5,0 +5,0 @@ "keywords": [

<p align="center">
<img src="https://res.cloudinary.com/meilisearch/image/upload/v1587402338/SDKs/meilisearch_js.svg" alt="MeiliSearch-JavaScript" width="200" height="200" />
<img src="https://images.meilisearch.workers.dev/v1587402338/SDKs/meilisearch_js.svg" alt="MeiliSearch-JavaScript" width="200" height="200" />
</p>

@@ -121,2 +121,16 @@

#### Deno<!-- omit in toc -->
Usage in a back-end deno environment
```ts
import { MeiliSearch } from "https://esm.sh/meilisearch"
const client = new MeiliSearch({
host: 'http://127.0.0.1:7700',
apiKey: 'masterKey',
})
```
## 🎬 Getting Started

@@ -156,3 +170,3 @@

With the `updateId`, you can check the status (`enqueued`, `processed` or `failed`) of your documents addition using the [update endpoint](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).
With the `updateId`, you can check the status (`enqueued`, `processing`, `processed` or `failed`) of your documents addition using the [update endpoint](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).

@@ -193,5 +207,4 @@ #### Basic Search <!-- omit in toc -->

'wonder',
{
attributesToHighlight: ['*'],
filters: 'id >= 1'
filter: 'id >= 1'
}

@@ -231,3 +244,3 @@ )

{
facetFilters: ['genres:fantasy'],
filter: ['genres = fantasy'],
facetsDistribution: ['genres']

@@ -259,7 +272,4 @@ }

"genres": {
"Drama": 0,
"Action": 2,
"Science Fiction": 0,
"Fantasy": 1,
"Romance": 0,
"Adventure": 1

@@ -278,3 +288,3 @@ }

index
.search('wonder', {}, 'POST', {
.search('wonder', {}, {
signal: controller.signal,

@@ -294,3 +304,3 @@ })

This package only guarantees the compatibility with the [version v0.20.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.20.0).
This package only guarantees the compatibility with the [version v0.21.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.21.0).

@@ -320,4 +330,8 @@ ## 💡 Learn More

`client.index<T>('xxx').search(query: string, options: SearchParams = {}, method: 'POST' | 'GET' = 'POST', config?: Partial<Request>): Promise<SearchResponse<T>>`
`client.index<T>('xxx').search(query: string, options: SearchParams = {}, config?: Partial<Request>): Promise<SearchResponse<T>>`
- Make a search request using GET method (slower than the search method):
`client.index<T>('xxx').searchGet(query: string, options: SearchParams = {}, config?: Partial<Request>): Promise<SearchResponse<T>>`
### Indexes <!-- omit in toc -->

@@ -339,3 +353,3 @@

`client.getIndex<T>(uid: string): Index<T>`
`client.getIndex<T>(uid: string): Promise<Index<T>>`

@@ -352,3 +366,3 @@ - Get or create index if it does not exist

`client.updateIndex(uid): Promise<Index>`
`client.updateIndex(uid: string, options: IndexOptions): Promise<Index>`
Or using the index object:

@@ -442,3 +456,3 @@ `index.update(data: IndexOptions): Promise<Index>`

`index.updateSynonyms(synonyms: object): Promise<EnqueuedUpdate>`
`index.updateSynonyms(synonyms: Synonyms): Promise<EnqueuedUpdate>`

@@ -455,3 +469,3 @@ - Reset synonyms:

- Update Stop Words
`index.updateStopWords(string[]): Promise<EnqueuedUpdate>`
`index.updateStopWords(stopWords: string[] | null ): Promise<EnqueuedUpdate>`

@@ -505,2 +519,13 @@ - Reset Stop Words

### Filterable Attributes <!-- omit in toc -->
- Get Filterable Attributes
`index.getFilterableAttributes(): Promise<string[]>`
- Update Filterable Attributes
`index.updateFilterableAttributes(filterableAttributes: string[] | null): Promise<EnqueuedUpdate>`
- Reset Filterable Attributes
`index.resetFilterableAttributes(): Promise<EnqueuedUpdate>`
### Keys <!-- omit in toc -->

@@ -507,0 +532,0 @@

@@ -41,3 +41,3 @@ /*

const response = await this.getUpdateStatus(updateId)
if (response.status !== 'enqueued') return response
if (!['enqueued', 'processing'].includes(response.status)) return response
await sleep(intervalMs)

@@ -62,57 +62,58 @@ }

options?: P,
method: Types.Methods = 'POST',
config?: Partial<Request>
): Promise<Types.SearchResponse<T, P>> {
const url = `indexes/${this.uid}/search`
const params: Types.SearchRequest = {
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,
offset: options?.offset,
limit: options?.limit,
cropLength: options?.cropLength,
filters: options?.filters,
matches: options?.matches,
facetFilters: options?.facetFilters,
facetsDistribution: options?.facetsDistribution,
attributesToRetrieve: options?.attributesToRetrieve,
attributesToCrop: options?.attributesToCrop,
attributesToHighlight: options?.attributesToHighlight,
...options,
filter: parseFilter(options?.filter),
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,
}
if (method.toUpperCase() === 'POST') {
return await this.httpRequest.post(
url,
removeUndefinedFromObject(params),
undefined,
config
)
} else if (method.toUpperCase() === 'GET') {
const getParams: Types.GetSearchRequest = {
...params,
facetFilters:
Array.isArray(options?.facetFilters) && options?.facetFilters
? JSON.stringify(options.facetFilters)
: undefined,
facetsDistribution: options?.facetsDistribution
? JSON.stringify(options.facetsDistribution)
: undefined,
attributesToRetrieve: options?.attributesToRetrieve
? options.attributesToRetrieve.join(',')
: undefined,
attributesToCrop: options?.attributesToCrop
? options.attributesToCrop.join(',')
: undefined,
attributesToHighlight: options?.attributesToHighlight
? options.attributesToHighlight.join(',')
: undefined,
}
return await this.httpRequest.get<Types.SearchResponse<T, P>>(
url,
removeUndefinedFromObject(getParams),
config
)
} else {
throw new MeiliSearchError(
'method parameter should be either POST or GET'
)
}
return await this.httpRequest.get<Types.SearchResponse<T, P>>(
url,
removeUndefinedFromObject(getParams),
config
)
}

@@ -399,3 +400,5 @@

*/
async updateSynonyms(synonyms: object): Promise<Types.EnqueuedUpdate> {
async updateSynonyms(
synonyms: Types.Synonyms
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/synonyms`

@@ -434,3 +437,5 @@ return await this.httpRequest.post(url, synonyms)

*/
async updateStopWords(stopWords: string[]): Promise<Types.EnqueuedUpdate> {
async updateStopWords(
stopWords: Types.StopWords
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/stop-words`

@@ -470,3 +475,3 @@ return await this.httpRequest.post(url, stopWords)

async updateRankingRules(
rankingRules: string[] | null
rankingRules: Types.RankingRules
): Promise<Types.EnqueuedUpdate> {

@@ -507,3 +512,3 @@ const url = `indexes/${this.uid}/settings/ranking-rules`

async updateDistinctAttribute(
distinctAttribute: string | null
distinctAttribute: Types.DistinctAttribute
): Promise<Types.EnqueuedUpdate> {

@@ -529,8 +534,8 @@ const url = `indexes/${this.uid}/settings/distinct-attribute`

/**
* Get the attributes-for-faceting
* Get the filterable-attributes
* @memberof Index
* @method getAttributesForFaceting
* @method getFilterableAttributes
*/
async getAttributesForFaceting(): Promise<string[]> {
const url = `indexes/${this.uid}/settings/attributes-for-faceting`
async getFilterableAttributes(): Promise<string[]> {
const url = `indexes/${this.uid}/settings/filterable-attributes`
return await this.httpRequest.get<string[]>(url)

@@ -540,20 +545,20 @@ }

/**
* Update the attributes-for-faceting.
* Update the filterable-attributes.
* @memberof Index
* @method updateAttributesForFaceting
* @method updateFilterableAttributes
*/
async updateAttributesForFaceting(
attributesForFaceting: string[] | null
async updateFilterableAttributes(
filterableAttributes: Types.FilterableAttributes
): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/attributes-for-faceting`
return await this.httpRequest.post(url, attributesForFaceting)
const url = `indexes/${this.uid}/settings/filterable-attributes`
return await this.httpRequest.post(url, filterableAttributes)
}
/**
* Reset the attributes-for-faceting.
* Reset the filterable-attributes.
* @memberof Index
* @method resetAttributesForFaceting
* @method resetFilterableAttributes
*/
async resetAttributesForFaceting(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/attributes-for-faceting`
async resetFilterableAttributes(): Promise<Types.EnqueuedUpdate> {
const url = `indexes/${this.uid}/settings/filterable-attributes`
return await this.httpRequest.delete<Types.EnqueuedUpdate>(url)

@@ -582,3 +587,3 @@ }

async updateSearchableAttributes(
searchableAttributes: string[] | null
searchableAttributes: Types.SearchableAttributes
): Promise<Types.EnqueuedUpdate> {

@@ -619,3 +624,3 @@ const url = `indexes/${this.uid}/settings/searchable-attributes`

async updateDisplayedAttributes(
displayedAttributes: string[] | null
displayedAttributes: Types.DisplayedAttributes
): Promise<Types.EnqueuedUpdate> {

@@ -622,0 +627,0 @@ const url = `indexes/${this.uid}/settings/displayed-attributes`

@@ -49,3 +49,3 @@ // Type definitions for meilisearch

export type FacetFilter = Array<string | string[]>
export type Filter = string | Array<string | string[]>

@@ -59,4 +59,3 @@ export interface SearchParams<T> {

attributesToHighlight?: Array<Extract<keyof T, string> | '*'>
filters?: string
facetFilters?: FacetFilter | FacetFilter[]
filter?: Filter
facetsDistribution?: string[]

@@ -66,27 +65,25 @@ matches?: boolean

export interface SearchRequest {
export interface SearchRequestGET {
q?: string | null
offset?: number
limit?: number
attributesToRetrieve?: string
attributesToCrop?: string
cropLength?: number
attributesToRetrieve?: string[]
attributesToCrop?: string[]
attributesToHighlight?: string[]
facetFilters?: FacetFilter | FacetFilter[]
facetsDistribution?: string[]
filters?: string
attributesToHighlight?: string
facetsDistribution?: string
filter?: string
matches?: boolean
}
export interface GetSearchRequest {
export interface SearchRequest {
q?: string | null
offset?: number
limit?: number
attributesToRetrieve?: string
attributesToCrop?: string
cropLength?: number
attributesToHighlight?: string
facetFilters?: string
facetsDistribution?: string
filters?: string
attributesToRetrieve?: string[]
attributesToCrop?: string[]
attributesToHighlight?: string[]
facetsDistribution?: string[]
filter?: Filter
matches?: boolean

@@ -135,3 +132,3 @@ }

export interface FieldsDistribution {
export interface FieldDistribution {
[field: string]: number

@@ -170,12 +167,20 @@ }

export type FilterableAttributes = string[] | null
export type DistinctAttribute = string | null
export type SearchableAttributes = string[] | null
export type DisplayedAttributes = string[] | null
export type RankingRules = string[] | null
export type StopWords = string[] | null
export type Synonyms = {
[field: string]: string[]
} | null
export interface Settings {
attributesForFaceting?: string[]
distinctAttribute?: string
searchableAttributes?: string[]
displayedAttributes?: string[]
rankingRules?: string[]
stopWords?: string[]
synonyms?: {
[field: string]: string[]
}
filterableAttributes?: FilterableAttributes
distinctAttribute?: DistinctAttribute
searchableAttributes?: SearchableAttributes
displayedAttributes?: DisplayedAttributes
rankingRules?: RankingRules
stopWords?: StopWords
synonyms?: Synonyms
}

@@ -206,2 +211,4 @@

status: 'in_progress' | 'failed' | 'done'
startedAt: string
finishedAt: string
}

@@ -224,3 +231,3 @@

isIndexing: boolean
fieldsDistribution: FieldsDistribution
fieldDistribution: FieldDistribution
}

@@ -250,3 +257,3 @@

commitSha: string
buildDate: string
commitDate: string
pkgVersion: string

@@ -284,4 +291,2 @@ }

export type Methods = 'POST' | 'GET'
export interface IndexInterface<T = any> {

@@ -294,5 +299,9 @@ uid: string

options?: P,
method?: Methods,
config?: Partial<Request>
) => Promise<SearchResponse<T, P>>
searchGet: <P extends SearchParams<T>>(
query?: string | null,
options?: P,
config?: Partial<Request>
) => Promise<SearchResponse<T, P>>
getRawInfo: () => Promise<IndexResponse>

@@ -326,23 +335,23 @@ fetchInfo(): Promise<this>

getSynonyms: () => Promise<object>
updateSynonyms: (synonyms: object) => Promise<object>
updateSynonyms: (synonyms: Synonyms) => Promise<object>
resetSynonyms: () => Promise<object>
getStopWords: () => Promise<string[]>
updateStopWords: (stopWords: string[]) => Promise<EnqueuedUpdate>
updateStopWords: (stopWords: StopWords) => Promise<EnqueuedUpdate>
resetStopWords: () => Promise<EnqueuedUpdate>
getRankingRules: () => Promise<string[]>
updateRankingRules: (rankingRules: string[] | null) => Promise<EnqueuedUpdate>
updateRankingRules: (rankingRules: RankingRules) => Promise<EnqueuedUpdate>
resetRankingRules: () => Promise<EnqueuedUpdate>
getDistinctAttribute: () => Promise<string | null>
updateDistinctAttribute: (
distinctAttribute: string | null
distinctAttribute: DistinctAttribute
) => Promise<EnqueuedUpdate>
resetDistinctAttribute: () => Promise<EnqueuedUpdate>
getAttributesForFaceting: () => Promise<string[]>
updateAttributesForFaceting: (
attributesForFaceting: string[] | null
getFilterableAttributes: () => Promise<string[]>
updateFilterableAttributes: (
filterableAttributes: FilterableAttributes
) => Promise<EnqueuedUpdate>
resetAttributesForFaceting: () => Promise<EnqueuedUpdate>
resetFilterableAttributes: () => Promise<EnqueuedUpdate>
getSearchableAttributes: () => Promise<string[]>
updateSearchableAttributes: (
searchableAttributes: string[] | null
searchableAttributes: SearchableAttributes
) => Promise<EnqueuedUpdate>

@@ -352,3 +361,3 @@ resetSearchableAttributes: () => Promise<EnqueuedUpdate>

updateDisplayedAttributes: (
displayedAttributes: string[] | null
displayedAttributes: DisplayedAttributes
) => Promise<EnqueuedUpdate>

@@ -355,0 +364,0 @@ resetDisplayedAttributes: () => Promise<EnqueuedUpdate>

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