Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

meilisearch

Package Overview
Dependencies
Maintainers
1
Versions
94
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.10.1 to 0.11.0

dist/types/errors/http-error-handler.d.ts

16

CHANGELOG.md

@@ -1,3 +0,17 @@

## V0.10 (released)
## V0.11.1 (released)
- BREAKING: Usage of createIndex changed `createIndex(uid: string, options: IndexOptions): Index` #436
- BREAKING: Changes in types
- `MeiliSearchApiErrorInterface` changes
- Removed `UpdateIndexRequest` and replaced it with `IndexOptions`
- Error Handler improved by adding a new MeiliSearchCommunicationError #436
- Refactor Error handler #436
- Add getOrCreateIndex method to meilisearch client #436
- Faceting (#421)
- Improve tests with v11 (#422)
- Improve code examples (#434)
- Update dependencies
## V0.10.1 (released)
- Fix bug where you could not import the CJS package from a ES6 node environment. #410

@@ -4,0 +18,0 @@

@@ -98,3 +98,3 @@ import instance from 'axios';

var _this = _super.call(this, error.message) || this;
_this.type = _this.constructor.name;
_this.type = 'MeiliSearchApiError';
_this.name = 'MeiliSearchApiError';

@@ -109,3 +109,2 @@ // Fetch the native error message but add our application name in front of it.

method: error.response.config.method,
body: error.response.data,
};

@@ -115,13 +114,8 @@ // If a custom message was sent back by our API

if (((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.message) !== undefined) {
_this.errorCode = error.response.data.errorCode;
_this.errorType = error.response.data.errorType;
_this.errorLink = error.response.data.errorLink;
_this.message = error.response.data.message;
}
}
else {
// If MeiliSearch did not answered
_this.request = {
url: error.request._currentUrl,
path: error.config.url,
method: error.config.method,
};
}
// use cached Stack on error object to keep the call stack

@@ -139,2 +133,26 @@ if (cachedStack !== undefined && error.stack !== undefined) {

var MeiliSearchCommunicationError = /** @class */ (function (_super) {
__extends(MeiliSearchCommunicationError, _super);
function MeiliSearchCommunicationError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchCommunicationError';
_this.type = 'MeiliSearchCommunicationError';
Error.captureStackTrace(_this, MeiliSearchCommunicationError);
return _this;
}
return MeiliSearchCommunicationError;
}(Error));
function httpErrorHandler(e, cachedStack) {
if (e.response !== undefined) {
throw new MeiliSearchApiError(e, cachedStack);
}
else if (e.isAxiosError) {
throw new MeiliSearchCommunicationError(e.message);
}
else {
throw e;
}
}
/*

@@ -184,3 +202,3 @@ * Bundle: Meilisearch

e_1 = _a.sent();
throw new MeiliSearchApiError(e_1, cachedStack);
throw httpErrorHandler(e_1, cachedStack);
case 4: return [2 /*return*/];

@@ -205,3 +223,3 @@ }

e_2 = _a.sent();
throw new MeiliSearchApiError(e_2, cachedStack);
throw httpErrorHandler(e_2, cachedStack);
case 4: return [2 /*return*/];

@@ -226,3 +244,3 @@ }

e_3 = _a.sent();
throw new MeiliSearchApiError(e_3, cachedStack);
throw httpErrorHandler(e_3, cachedStack);
case 4: return [2 /*return*/];

@@ -247,3 +265,3 @@ }

e_4 = _a.sent();
throw new MeiliSearchApiError(e_4, cachedStack);
throw httpErrorHandler(e_4, cachedStack);
case 4: return [2 /*return*/];

@@ -268,3 +286,3 @@ }

e_5 = _a.sent();
throw new MeiliSearchApiError(e_5, cachedStack);
throw httpErrorHandler(e_5, cachedStack);
case 4: return [2 /*return*/];

@@ -424,2 +442,8 @@ }

}
if (options.facetFilters !== undefined) {
params.facetFilters = JSON.stringify(options.facetFilters);
}
if (options.facetsDistribution !== undefined) {
params.facetsDistribution = JSON.stringify(options.facetsDistribution);
}
}

@@ -938,2 +962,59 @@ return [4 /*yield*/, this.get(url, {

///
/// ATTRIBUTES FOR FACETING
///
/**
* Get the attributes-for-faceting
* @memberof Index
* @method getAttributesForFaceting
*/
Index.prototype.getAttributesForFaceting = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/attributes-for-faceting";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the attributes-for-faceting.
* @memberof Index
* @method updateAttributesForFaceting
*/
Index.prototype.updateAttributesForFaceting = function (attributesForFaceting) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/attributes-for-faceting";
return [4 /*yield*/, this.post(url, attributesForFaceting)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Reset the attributes-for-faceting.
* @memberof Index
* @method resetAttributesForFaceting
*/
Index.prototype.resetAttributesForFaceting = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/attributes-for-faceting";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// SEARCHABLE ATTRIBUTE

@@ -1110,3 +1191,3 @@ ///

* @memberof Meilisearch
* @method Index
* @method getIndex
*/

@@ -1117,2 +1198,30 @@ Meilisearch.prototype.getIndex = function (indexUid) {

/**
* Get an index or create it if it does not exist
* @memberof Meilisearch
* @method getOrCreateIndex
*/
Meilisearch.prototype.getOrCreateIndex = function (uid, options) {
if (options === void 0) { options = {}; }
return __awaiter(this, void 0, void 0, function () {
var index, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.createIndex(uid, options)];
case 1:
index = _a.sent();
return [2 /*return*/, index];
case 2:
e_1 = _a.sent();
if (e_1.errorCode === 'index_already_exists') {
return [2 /*return*/, this.getIndex(uid)];
}
throw e_1;
case 3: return [2 /*return*/];
}
});
});
};
/**
* List all indexes in the database

@@ -1140,3 +1249,4 @@ * @memberof Meilisearch

*/
Meilisearch.prototype.createIndex = function (data) {
Meilisearch.prototype.createIndex = function (uid, options) {
if (options === void 0) { options = {}; }
return __awaiter(this, void 0, void 0, function () {

@@ -1148,3 +1258,3 @@ var url, index;

url = '/indexes';
return [4 /*yield*/, this.post(url, data)];
return [4 /*yield*/, this.post(url, __assign(__assign({}, options), { uid: uid }))];
case 1:

@@ -1151,0 +1261,0 @@ index = _a.sent();

2

dist/bundles/meilisearch.esm.min.js

@@ -15,3 +15,3 @@ import t from"axios";

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)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,n)};function n(t,n){function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((i=i.apply(t,e||[])).next())}))}function s(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var o=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchTimeOutError",i.type=i.constructor.name,Error.captureStackTrace(i,e),i}return n(e,t),e}(Error),u=function(t){function e(e,n){var i,r=t.call(this,e.message)||this;return r.type=r.constructor.name,r.name="MeiliSearchApiError",void 0!==e.response?(r.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method,body:e.response.data},void 0!==(null===(i=e.response.data)||void 0===i?void 0:i.message)&&(r.message=e.response.data.message)):r.request={url:e.request._currentUrl,path:e.config.url,method:e.config.method},void 0!==n&&void 0!==e.stack&&(r.stack=r.name+": "+r.message+"\n"+n.split("\n").slice(1).join("\n")),r}return n(e,t),e}(Error),c=function(){function e(e){void 0!==e.apiKey?this.instance=t.create({baseURL:e.host,headers:{"X-Meili-API-Key":e.apiKey}}):this.instance=t.create({baseURL:e.host}),this.cancelTokenSource=t.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?i(i({},t),{data:JSON.stringify(t.data)}):t}))}return e.prototype.get=function(t,e){return r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,r.sent()];case 3:throw i=r.sent(),new u(i,n);case 4:return[2]}}))}))},e.prototype.post=function(t,e,n){return r(this,void 0,void 0,(function(){var i,r;return s(this,(function(s){switch(s.label){case 0:i=(new Error).stack,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,s.sent()];case 3:throw r=s.sent(),new u(r,i);case 4:return[2]}}))}))},e.prototype.put=function(t,e,n){return r(this,void 0,void 0,(function(){var i,r;return s(this,(function(s){switch(s.label){case 0:i=(new Error).stack,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,s.sent()];case 3:throw r=s.sent(),new u(r,i);case 4:return[2]}}))}))},e.prototype.patch=function(t,e,n){return r(this,void 0,void 0,(function(){var i,r;return s(this,(function(s){switch(s.label){case 0:i=(new Error).stack,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,s.sent()];case 3:throw r=s.sent(),new u(r,i);case 4:return[2]}}))}))},e.prototype.delete=function(t,e){return r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,r.sent()];case 3:throw i=r.sent(),new u(i,n);case 4:return[2]}}))}))},e}();function a(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var h=function(t){function e(e,n){var i=t.call(this,e)||this;return i.uid=n,i}return n(e,t),e.prototype.getUpdateStatus=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,u=void 0===i?5e3:i,c=n.intervalMs,h=void 0===c?50:c;return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=i.sent()).status?[2,n]:[4,a(h)];case 3:return i.sent(),[3,1];case 4:throw new o("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return r(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.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.search=function(t,e){return r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/search",i={q:t},void 0!==e&&(void 0!==e.offset&&(i.offset=e.offset),void 0!==e.limit&&(i.limit=e.limit),void 0!==e.attributesToRetrieve&&(Array.isArray(e.attributesToRetrieve)?i.attributesToRetrieve=e.attributesToRetrieve.join(","):i.attributesToRetrieve=e.attributesToRetrieve),void 0!==e.attributesToCrop&&(Array.isArray(e.attributesToCrop)?i.attributesToCrop=e.attributesToCrop.join(","):i.attributesToCrop=e.attributesToCrop),void 0!==e.cropLength&&(i.cropLength=e.cropLength),void 0!==e.attributesToHighlight&&(Array.isArray(e.attributesToHighlight)?i.attributesToHighlight=e.attributesToHighlight.join(","):i.attributesToHighlight=e.attributesToHighlight),void 0!==e.filters&&(i.filters=e.filters),void 0!==e.matches&&(i.matches=e.matches)),[4,this.get(n,{params:i,cancelToken:this.cancelTokenSource.token})];case 1:return[2,r.sent()]}}))}))},e.prototype.show=function(){return r(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.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateIndex=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteIndex=function(){return r(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.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDocuments=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:i(i({},t),void 0!==n?{attributesToRetrieve:n}:{})})];case 1:return[2,r.sent()]}}))}))},e.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.addDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteDocuments=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteAllDocuments=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSettings=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSynonyms=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateStopWords=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateRankingRules=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDistinctAttribute=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSearchableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAcceptNewFields=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAcceptNewFields=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e}(c),d=function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return n(e,t),e.prototype.getIndex=function(t){return new h(this.config,t)},e.prototype.listIndexes=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},e.prototype.createIndex=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return"/indexes",[4,this.post("/indexes",t)];case 1:return e=n.sent(),[2,new h(this.config,e.uid)]}}))}))},e.prototype.getKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},e.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(t){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},e.prototype.setUnhealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},e.prototype.changeHealthTo=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.stats=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},e.prototype.version=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},e.prototype.sysInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/sys-info",[4,this.get("/sys-info")];case 1:return[2,t.sent()]}}))}))},e.prototype.prettySysInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/sys-info/pretty",[4,this.get("/sys-info/pretty")];case 1:return[2,t.sent()]}}))}))},e}(c);export default d;
***************************************************************************** */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)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,n)};function n(t,n){function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((i=i.apply(t,e||[])).next())}))}function s(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var o=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchTimeOutError",i.type=i.constructor.name,Error.captureStackTrace(i,e),i}return n(e,t),e}(Error),u=function(t){function e(e,n){var i,r=t.call(this,e.message)||this;return r.type="MeiliSearchApiError",r.name="MeiliSearchApiError",void 0!==e.response&&(r.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(i=e.response.data)||void 0===i?void 0:i.message)&&(r.errorCode=e.response.data.errorCode,r.errorType=e.response.data.errorType,r.errorLink=e.response.data.errorLink,r.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(r.stack=r.name+": "+r.message+"\n"+n.split("\n").slice(1).join("\n")),r}return n(e,t),e}(Error),c=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",Error.captureStackTrace(i,e),i}return n(e,t),e}(Error);function a(t,e){throw void 0!==t.response?new u(t,e):t.isAxiosError?new c(t.message):t}var h=function(){function e(e){void 0!==e.apiKey?this.instance=t.create({baseURL:e.host,headers:{"X-Meili-API-Key":e.apiKey}}):this.instance=t.create({baseURL:e.host}),this.cancelTokenSource=t.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?i(i({},t),{data:JSON.stringify(t.data)}):t}))}return e.prototype.get=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:n=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,i.sent()];case 3:throw a(i.sent(),n);case 4:return[2]}}))}))},e.prototype.post=function(t,e,n){return r(this,void 0,void 0,(function(){var i;return s(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,r.sent()];case 3:throw a(r.sent(),i);case 4:return[2]}}))}))},e.prototype.put=function(t,e,n){return r(this,void 0,void 0,(function(){var i;return s(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,r.sent()];case 3:throw a(r.sent(),i);case 4:return[2]}}))}))},e.prototype.patch=function(t,e,n){return r(this,void 0,void 0,(function(){var i;return s(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,r.sent()];case 3:throw a(r.sent(),i);case 4:return[2]}}))}))},e.prototype.delete=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:n=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,i.sent()];case 3:throw a(i.sent(),n);case 4:return[2]}}))}))},e}();function d(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var l=function(t){function e(e,n){var i=t.call(this,e)||this;return i.uid=n,i}return n(e,t),e.prototype.getUpdateStatus=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,u=void 0===i?5e3:i,c=n.intervalMs,a=void 0===c?50:c;return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=i.sent()).status?[2,n]:[4,d(a)];case 3:return i.sent(),[3,1];case 4:throw new o("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return r(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.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.search=function(t,e){return r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/search",i={q:t},void 0!==e&&(void 0!==e.offset&&(i.offset=e.offset),void 0!==e.limit&&(i.limit=e.limit),void 0!==e.attributesToRetrieve&&(Array.isArray(e.attributesToRetrieve)?i.attributesToRetrieve=e.attributesToRetrieve.join(","):i.attributesToRetrieve=e.attributesToRetrieve),void 0!==e.attributesToCrop&&(Array.isArray(e.attributesToCrop)?i.attributesToCrop=e.attributesToCrop.join(","):i.attributesToCrop=e.attributesToCrop),void 0!==e.cropLength&&(i.cropLength=e.cropLength),void 0!==e.attributesToHighlight&&(Array.isArray(e.attributesToHighlight)?i.attributesToHighlight=e.attributesToHighlight.join(","):i.attributesToHighlight=e.attributesToHighlight),void 0!==e.filters&&(i.filters=e.filters),void 0!==e.matches&&(i.matches=e.matches),void 0!==e.facetFilters&&(i.facetFilters=JSON.stringify(e.facetFilters)),void 0!==e.facetsDistribution&&(i.facetsDistribution=JSON.stringify(e.facetsDistribution))),[4,this.get(n,{params:i,cancelToken:this.cancelTokenSource.token})];case 1:return[2,r.sent()]}}))}))},e.prototype.show=function(){return r(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.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateIndex=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteIndex=function(){return r(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.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDocuments=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:i(i({},t),void 0!==n?{attributesToRetrieve:n}:{})})];case 1:return[2,r.sent()]}}))}))},e.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.addDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteDocuments=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteAllDocuments=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSettings=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSynonyms=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateStopWords=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateRankingRules=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDistinctAttribute=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAttributesForFaceting=function(){return r(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.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAttributesForFaceting=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetAttributesForFaceting=function(){return r(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.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSearchableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAcceptNewFields=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAcceptNewFields=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e}(h),f=function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return n(e,t),e.prototype.getIndex=function(t){return new l(this.config,t)},e.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,i.sent()];case 2:if("index_already_exists"===(n=i.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},e.prototype.listIndexes=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},e.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var n;return s(this,(function(r){switch(r.label){case 0:return"/indexes",[4,this.post("/indexes",i(i({},e),{uid:t}))];case 1:return n=r.sent(),[2,new l(this.config,n.uid)]}}))}))},e.prototype.getKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},e.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(t){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},e.prototype.setUnhealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},e.prototype.changeHealthTo=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.stats=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},e.prototype.version=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},e.prototype.sysInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/sys-info",[4,this.get("/sys-info")];case 1:return[2,t.sent()]}}))}))},e.prototype.prettySysInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/sys-info/pretty",[4,this.get("/sys-info/pretty")];case 1:return[2,t.sent()]}}))}))},e}(h);export default f;
//# sourceMappingURL=meilisearch.esm.min.js.map

@@ -1,1330 +0,1436 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('axios')) :
typeof define === 'function' && define.amd ? define(['axios'], factory) :
(global = global || self, global.Meilisearch = factory(global.axios));
}(this, (function (instance) { 'use strict';
'use strict';
instance = instance && Object.prototype.hasOwnProperty.call(instance, 'default') ? instance['default'] : instance;
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
var instance = _interopDefault(require('axios'));
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
return t;
};
return __assign.apply(this, arguments);
};
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
var MeiliSearchTimeOutError = /** @class */ (function (_super) {
__extends(MeiliSearchTimeOutError, _super);
function MeiliSearchTimeOutError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchTimeOutError';
_this.type = _this.constructor.name;
Error.captureStackTrace(_this, MeiliSearchTimeOutError);
return _this;
}
return MeiliSearchTimeOutError;
}(Error));
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
var MeiliSearchApiError = /** @class */ (function (_super) {
__extends(class_1, _super);
function class_1(error, cachedStack) {
var _a;
var _this = _super.call(this, error.message) || this;
_this.type = 'MeiliSearchApiError';
_this.name = 'MeiliSearchApiError';
// Fetch the native error message but add our application name in front of it.
// This means slicing the "Error" string at the start of the message.
if (error.response !== undefined) {
_this.response = {
status: error.response.status,
statusText: error.response.statusText,
path: error.response.config.url,
method: error.response.config.method,
};
// If a custom message was sent back by our API
// We change the error message to be more explicit
if (((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.message) !== undefined) {
_this.errorCode = error.response.data.errorCode;
_this.errorType = error.response.data.errorType;
_this.errorLink = error.response.data.errorLink;
_this.message = error.response.data.message;
}
}
// use cached Stack on error object to keep the call stack
if (cachedStack !== undefined && error.stack !== undefined) {
_this.stack = _this.name + ": " + _this.message + "\n" + cachedStack
.split('\n')
.slice(1)
.join('\n');
}
return _this;
}
return class_1;
}(Error));
var MeiliSearchTimeOutError = /** @class */ (function (_super) {
__extends(MeiliSearchTimeOutError, _super);
function MeiliSearchTimeOutError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchTimeOutError';
_this.type = _this.constructor.name;
Error.captureStackTrace(_this, MeiliSearchTimeOutError);
return _this;
}
return MeiliSearchTimeOutError;
}(Error));
var MeiliSearchCommunicationError = /** @class */ (function (_super) {
__extends(MeiliSearchCommunicationError, _super);
function MeiliSearchCommunicationError(message) {
var _this = _super.call(this, message) || this;
_this.name = 'MeiliSearchCommunicationError';
_this.type = 'MeiliSearchCommunicationError';
Error.captureStackTrace(_this, MeiliSearchCommunicationError);
return _this;
}
return MeiliSearchCommunicationError;
}(Error));
var MeiliSearchApiError = /** @class */ (function (_super) {
__extends(class_1, _super);
function class_1(error, cachedStack) {
var _a;
var _this = _super.call(this, error.message) || this;
_this.type = _this.constructor.name;
_this.name = 'MeiliSearchApiError';
// Fetch the native error message but add our application name in front of it.
// This means slicing the "Error" string at the start of the message.
if (error.response !== undefined) {
_this.response = {
status: error.response.status,
statusText: error.response.statusText,
path: error.response.config.url,
method: error.response.config.method,
body: error.response.data,
};
// If a custom message was sent back by our API
// We change the error message to be more explicit
if (((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.message) !== undefined) {
_this.message = error.response.data.message;
}
}
else {
// If MeiliSearch did not answered
_this.request = {
url: error.request._currentUrl,
path: error.config.url,
method: error.config.method,
};
}
// use cached Stack on error object to keep the call stack
if (cachedStack !== undefined && error.stack !== undefined) {
_this.stack = _this.name + ": " + _this.message + "\n" + cachedStack
.split('\n')
.slice(1)
.join('\n');
}
return _this;
}
return class_1;
}(Error));
function httpErrorHandler(e, cachedStack) {
if (e.response !== undefined) {
throw new MeiliSearchApiError(e, cachedStack);
}
else if (e.isAxiosError) {
throw new MeiliSearchCommunicationError(e.message);
}
else {
throw e;
}
}
/*
* Bundle: Meilisearch
* Project: Meilisearch - Javascript API
* Author: Quentin de Quelen <quentin@meilisearch.com>
* Copyright: 2019, Meilisearch
*/
var MeiliAxiosWrapper = /** @class */ (function () {
function MeiliAxiosWrapper(config) {
if (config.apiKey !== undefined) {
this.instance = instance.create({
baseURL: config.host,
headers: {
'X-Meili-API-Key': config.apiKey,
},
});
}
else {
this.instance = instance.create({
baseURL: config.host,
});
}
this.cancelTokenSource = instance.CancelToken.source();
this.instance.interceptors.response.use(function (response) { return response.data; });
this.instance.interceptors.request.use(function (request) {
if (request.data !== undefined) {
return __assign(__assign({}, request), { data: JSON.stringify(request.data) });
}
return request;
/*
* Bundle: Meilisearch
* Project: Meilisearch - Javascript API
* Author: Quentin de Quelen <quentin@meilisearch.com>
* Copyright: 2019, Meilisearch
*/
var MeiliAxiosWrapper = /** @class */ (function () {
function MeiliAxiosWrapper(config) {
if (config.apiKey !== undefined) {
this.instance = instance.create({
baseURL: config.host,
headers: {
'X-Meili-API-Key': config.apiKey,
},
});
}
MeiliAxiosWrapper.prototype.get = function (url, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance.get(url, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_1 = _a.sent();
throw new MeiliSearchApiError(e_1, cachedStack);
case 4: return [2 /*return*/];
}
});
else {
this.instance = instance.create({
baseURL: config.host,
});
};
MeiliAxiosWrapper.prototype.post = function (url, data, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance.post(url, data, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_2 = _a.sent();
throw new MeiliSearchApiError(e_2, cachedStack);
case 4: return [2 /*return*/];
}
});
}
this.cancelTokenSource = instance.CancelToken.source();
this.instance.interceptors.response.use(function (response) { return response.data; });
this.instance.interceptors.request.use(function (request) {
if (request.data !== undefined) {
return __assign(__assign({}, request), { data: JSON.stringify(request.data) });
}
return request;
});
}
MeiliAxiosWrapper.prototype.get = function (url, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance.get(url, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_1 = _a.sent();
throw httpErrorHandler(e_1, cachedStack);
case 4: return [2 /*return*/];
}
});
};
MeiliAxiosWrapper.prototype.put = function (url, data, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance.put(url, data, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_3 = _a.sent();
throw new MeiliSearchApiError(e_3, cachedStack);
case 4: return [2 /*return*/];
}
});
});
};
MeiliAxiosWrapper.prototype.post = function (url, data, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_2;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance.post(url, data, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_2 = _a.sent();
throw httpErrorHandler(e_2, cachedStack);
case 4: return [2 /*return*/];
}
});
};
MeiliAxiosWrapper.prototype.patch = function (url, data, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance.patch(url, data, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_4 = _a.sent();
throw new MeiliSearchApiError(e_4, cachedStack);
case 4: return [2 /*return*/];
}
});
});
};
MeiliAxiosWrapper.prototype.put = function (url, data, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_3;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance.put(url, data, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_3 = _a.sent();
throw httpErrorHandler(e_3, cachedStack);
case 4: return [2 /*return*/];
}
});
};
MeiliAxiosWrapper.prototype["delete"] = function (url, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance["delete"](url, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_5 = _a.sent();
throw new MeiliSearchApiError(e_5, cachedStack);
case 4: return [2 /*return*/];
}
});
});
};
MeiliAxiosWrapper.prototype.patch = function (url, data, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_4;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance.patch(url, data, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_4 = _a.sent();
throw httpErrorHandler(e_4, cachedStack);
case 4: return [2 /*return*/];
}
});
};
return MeiliAxiosWrapper;
}());
function sleep(ms) {
});
};
MeiliAxiosWrapper.prototype["delete"] = function (url, config) {
return __awaiter(this, void 0, void 0, function () {
var cachedStack, e_5;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })];
case 1: return [2 /*return*/, _a.sent()];
case 0:
cachedStack = new Error().stack;
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.instance["delete"](url, config)];
case 2: return [2 /*return*/, _a.sent()];
case 3:
e_5 = _a.sent();
throw httpErrorHandler(e_5, cachedStack);
case 4: return [2 /*return*/];
}
});
});
};
return MeiliAxiosWrapper;
}());
function sleep(ms) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, ms); })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
}
/*
* Bundle: Meilisearch / Indexes
* Project: Meilisearch - Javascript API
* Author: Quentin de Quelen <quentin@meilisearch.com>
* Copyright: 2019, Meilisearch
*/
var Index = /** @class */ (function (_super) {
__extends(Index, _super);
function Index(config, uid) {
var _this = _super.call(this, config) || this;
_this.uid = uid;
return _this;
}
/*
* Bundle: Meilisearch / Indexes
* Project: Meilisearch - Javascript API
* Author: Quentin de Quelen <quentin@meilisearch.com>
* Copyright: 2019, Meilisearch
///
/// UPDATES
///
/**
* Get the informations about an update status
* @memberof Index
* @method getUpdateStatus
*/
var Index = /** @class */ (function (_super) {
__extends(Index, _super);
function Index(config, uid) {
var _this = _super.call(this, config) || this;
_this.uid = uid;
return _this;
}
///
/// UPDATES
///
/**
* Get the informations about an update status
* @memberof Index
* @method getUpdateStatus
*/
Index.prototype.getUpdateStatus = function (updateId) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/updates/" + updateId;
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
Index.prototype.getUpdateStatus = function (updateId) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/updates/" + updateId;
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
Index.prototype.waitForPendingUpdate = function (updateId, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.timeOutMs, timeOutMs = _c === void 0 ? 5000 : _c, _d = _b.intervalMs, intervalMs = _d === void 0 ? 50 : _d;
return __awaiter(this, void 0, void 0, function () {
var startingTime, response;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
startingTime = Date.now();
_e.label = 1;
case 1:
if (!(Date.now() - startingTime < timeOutMs)) return [3 /*break*/, 4];
return [4 /*yield*/, this.getUpdateStatus(updateId)];
case 2:
response = _e.sent();
if (response.status !== 'enqueued')
return [2 /*return*/, response];
return [4 /*yield*/, sleep(intervalMs)];
case 3:
_e.sent();
return [3 /*break*/, 1];
case 4: throw new MeiliSearchTimeOutError("timeout of " + timeOutMs + "ms has exceeded on process " + updateId + " when waiting for pending update to resolve.");
}
});
});
};
Index.prototype.waitForPendingUpdate = function (updateId, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.timeOutMs, timeOutMs = _c === void 0 ? 5000 : _c, _d = _b.intervalMs, intervalMs = _d === void 0 ? 50 : _d;
return __awaiter(this, void 0, void 0, function () {
var startingTime, response;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
startingTime = Date.now();
_e.label = 1;
case 1:
if (!(Date.now() - startingTime < timeOutMs)) return [3 /*break*/, 4];
return [4 /*yield*/, this.getUpdateStatus(updateId)];
case 2:
response = _e.sent();
if (response.status !== 'enqueued')
return [2 /*return*/, response];
return [4 /*yield*/, sleep(intervalMs)];
case 3:
_e.sent();
return [3 /*break*/, 1];
case 4: throw new MeiliSearchTimeOutError("timeout of " + timeOutMs + "ms has exceeded on process " + updateId + " when waiting for pending update to resolve.");
}
});
};
/**
* Get the list of all updates
* @memberof Index
* @method getAllUpdateStatus
*/
Index.prototype.getAllUpdateStatus = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/updates";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Get the list of all updates
* @memberof Index
* @method getAllUpdateStatus
*/
Index.prototype.getAllUpdateStatus = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/updates";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// SEARCH
///
/**
* Search for documents into an index
* @memberof Index
* @method search
*/
Index.prototype.search = function (query, options) {
return __awaiter(this, void 0, void 0, function () {
var url, params;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/search";
params = {
q: query,
};
if (options !== undefined) {
if (options.offset !== undefined) {
params.offset = options.offset;
});
};
///
/// SEARCH
///
/**
* Search for documents into an index
* @memberof Index
* @method search
*/
Index.prototype.search = function (query, options) {
return __awaiter(this, void 0, void 0, function () {
var url, params;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/search";
params = {
q: query,
};
if (options !== undefined) {
if (options.offset !== undefined) {
params.offset = options.offset;
}
if (options.limit !== undefined) {
params.limit = options.limit;
}
if (options.attributesToRetrieve !== undefined) {
if (Array.isArray(options.attributesToRetrieve)) {
params.attributesToRetrieve = options.attributesToRetrieve.join(',');
}
if (options.limit !== undefined) {
params.limit = options.limit;
else {
params.attributesToRetrieve = options.attributesToRetrieve;
}
if (options.attributesToRetrieve !== undefined) {
if (Array.isArray(options.attributesToRetrieve)) {
params.attributesToRetrieve = options.attributesToRetrieve.join(',');
}
else {
params.attributesToRetrieve = options.attributesToRetrieve;
}
}
if (options.attributesToCrop !== undefined) {
if (Array.isArray(options.attributesToCrop)) {
params.attributesToCrop = options.attributesToCrop.join(',');
}
if (options.attributesToCrop !== undefined) {
if (Array.isArray(options.attributesToCrop)) {
params.attributesToCrop = options.attributesToCrop.join(',');
}
else {
params.attributesToCrop = options.attributesToCrop;
}
else {
params.attributesToCrop = options.attributesToCrop;
}
if (options.cropLength !== undefined) {
params.cropLength = options.cropLength;
}
if (options.cropLength !== undefined) {
params.cropLength = options.cropLength;
}
if (options.attributesToHighlight !== undefined) {
if (Array.isArray(options.attributesToHighlight)) {
params.attributesToHighlight = options.attributesToHighlight.join(',');
}
if (options.attributesToHighlight !== undefined) {
if (Array.isArray(options.attributesToHighlight)) {
params.attributesToHighlight = options.attributesToHighlight.join(',');
}
else {
params.attributesToHighlight = options.attributesToHighlight;
}
else {
params.attributesToHighlight = options.attributesToHighlight;
}
if (options.filters !== undefined) {
params.filters = options.filters;
}
if (options.matches !== undefined) {
params.matches = options.matches;
}
}
return [4 /*yield*/, this.get(url, {
params: params,
cancelToken: this.cancelTokenSource.token,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
if (options.filters !== undefined) {
params.filters = options.filters;
}
if (options.matches !== undefined) {
params.matches = options.matches;
}
if (options.facetFilters !== undefined) {
params.facetFilters = JSON.stringify(options.facetFilters);
}
if (options.facetsDistribution !== undefined) {
params.facetsDistribution = JSON.stringify(options.facetsDistribution);
}
}
return [4 /*yield*/, this.get(url, {
params: params,
cancelToken: this.cancelTokenSource.token,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// INDEX
///
/**
* Show index information.
* @memberof Index
* @method show
*/
Index.prototype.show = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid;
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// INDEX
///
/**
* Show index information.
* @memberof Index
* @method show
*/
Index.prototype.show = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid;
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update an index.
* @memberof Index
* @method updateIndex
*/
Index.prototype.updateIndex = function (data) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid;
return [4 /*yield*/, this.put(url, data)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update an index.
* @memberof Index
* @method updateIndex
*/
Index.prototype.updateIndex = function (data) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid;
return [4 /*yield*/, this.put(url, data)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Delete an index.
* @memberof Index
* @method deleteIndex
*/
Index.prototype.deleteIndex = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid;
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Delete an index.
* @memberof Index
* @method deleteIndex
*/
Index.prototype.deleteIndex = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid;
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// STATS
///
/**
* get stats of an index
* @memberof Index
* @method getStats
*/
Index.prototype.getStats = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/stats";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// STATS
///
/**
* get stats of an index
* @memberof Index
* @method getStats
*/
Index.prototype.getStats = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/stats";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// DOCUMENTS
///
/**
* get documents of an index
* @memberof Index
* @method getDocuments
*/
Index.prototype.getDocuments = function (options) {
return __awaiter(this, void 0, void 0, function () {
var url, attr;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents";
if (options !== undefined && Array.isArray(options.attributesToRetrieve)) {
attr = options.attributesToRetrieve.join(',');
}
return [4 /*yield*/, this.get(url, {
params: __assign(__assign({}, options), (attr !== undefined ? { attributesToRetrieve: attr } : {})),
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// DOCUMENTS
///
/**
* get documents of an index
* @memberof Index
* @method getDocuments
*/
Index.prototype.getDocuments = function (options) {
return __awaiter(this, void 0, void 0, function () {
var url, attr;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents";
if (options !== undefined && Array.isArray(options.attributesToRetrieve)) {
attr = options.attributesToRetrieve.join(',');
}
return [4 /*yield*/, this.get(url, {
params: __assign(__assign({}, options), (attr !== undefined ? { attributesToRetrieve: attr } : {})),
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Get one document
* @memberof Index
* @method getDocument
*/
Index.prototype.getDocument = function (documentId) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents/" + documentId;
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Get one document
* @memberof Index
* @method getDocument
*/
Index.prototype.getDocument = function (documentId) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents/" + documentId;
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Add or replace multiples documents to an index
* @memberof Index
* @method addDocuments
*/
Index.prototype.addDocuments = function (documents, options) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents";
return [4 /*yield*/, this.post(url, documents, {
params: options,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Add or replace multiples documents to an index
* @memberof Index
* @method addDocuments
*/
Index.prototype.addDocuments = function (documents, options) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents";
return [4 /*yield*/, this.post(url, documents, {
params: options,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Add or update multiples documents to an index
* @memberof Index
* @method updateDocuments
*/
Index.prototype.updateDocuments = function (documents, options) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents";
return [4 /*yield*/, this.put(url, documents, {
params: options,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Add or update multiples documents to an index
* @memberof Index
* @method updateDocuments
*/
Index.prototype.updateDocuments = function (documents, options) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents";
return [4 /*yield*/, this.put(url, documents, {
params: options,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Delete one document
* @memberof Index
* @method deleteDocument
*/
Index.prototype.deleteDocument = function (documentId) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents/" + documentId;
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Delete one document
* @memberof Index
* @method deleteDocument
*/
Index.prototype.deleteDocument = function (documentId) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents/" + documentId;
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Delete multiples documents of an index
* @memberof Index
* @method deleteDocuments
*/
Index.prototype.deleteDocuments = function (documentsIds) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents/delete-batch";
return [4 /*yield*/, this.post(url, documentsIds)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Delete multiples documents of an index
* @memberof Index
* @method deleteDocuments
*/
Index.prototype.deleteDocuments = function (documentsIds) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents/delete-batch";
return [4 /*yield*/, this.post(url, documentsIds)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Delete all documents of an index
* @memberof Index
* @method deleteAllDocuments
*/
Index.prototype.deleteAllDocuments = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Delete all documents of an index
* @memberof Index
* @method deleteAllDocuments
*/
Index.prototype.deleteAllDocuments = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/documents";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// SETTINGS
///
/**
* Retrieve all settings
* @memberof Index
* @method getSettings
*/
Index.prototype.getSettings = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// SETTINGS
///
/**
* Retrieve all settings
* @memberof Index
* @method getSettings
*/
Index.prototype.getSettings = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update all settings
* Any parameters not provided will be left unchanged.
* @memberof Index
* @method updateSettings
*/
Index.prototype.updateSettings = function (settings) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings";
return [4 /*yield*/, this.post(url, settings)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update all settings
* Any parameters not provided will be left unchanged.
* @memberof Index
* @method updateSettings
*/
Index.prototype.updateSettings = function (settings) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings";
return [4 /*yield*/, this.post(url, settings)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Reset settings.
* @memberof Index
* @method resetSettings
*/
Index.prototype.resetSettings = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Reset settings.
* @memberof Index
* @method resetSettings
*/
Index.prototype.resetSettings = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// SYNONYMS
///
/**
* Get the list of all synonyms
* @memberof Index
* @method getSynonyms
*/
Index.prototype.getSynonyms = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/synonyms";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// SYNONYMS
///
/**
* Get the list of all synonyms
* @memberof Index
* @method getSynonyms
*/
Index.prototype.getSynonyms = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/synonyms";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update the list of synonyms. Overwrite the old list.
* @memberof Index
* @method updateSynonyms
*/
Index.prototype.updateSynonyms = function (synonyms) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/synonyms";
return [4 /*yield*/, this.post(url, synonyms)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the list of synonyms. Overwrite the old list.
* @memberof Index
* @method updateSynonyms
*/
Index.prototype.updateSynonyms = function (synonyms) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/synonyms";
return [4 /*yield*/, this.post(url, synonyms)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Reset the synonym list to be empty again
* @memberof Index
* @method resetSynonyms
*/
Index.prototype.resetSynonyms = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/synonyms";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Reset the synonym list to be empty again
* @memberof Index
* @method resetSynonyms
*/
Index.prototype.resetSynonyms = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/synonyms";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// STOP WORDS
///
/**
* Get the list of all stop-words
* @memberof Index
* @method getStopWords
*/
Index.prototype.getStopWords = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/stop-words";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// STOP WORDS
///
/**
* Get the list of all stop-words
* @memberof Index
* @method getStopWords
*/
Index.prototype.getStopWords = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/stop-words";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update the list of stop-words. Overwrite the old list.
* @memberof Index
* @method updateStopWords
*/
Index.prototype.updateStopWords = function (stopWords) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/stop-words";
return [4 /*yield*/, this.post(url, stopWords)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the list of stop-words. Overwrite the old list.
* @memberof Index
* @method updateStopWords
*/
Index.prototype.updateStopWords = function (stopWords) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/stop-words";
return [4 /*yield*/, this.post(url, stopWords)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Reset the stop-words list to be empty again
* @memberof Index
* @method resetStopWords
*/
Index.prototype.resetStopWords = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/stop-words";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Reset the stop-words list to be empty again
* @memberof Index
* @method resetStopWords
*/
Index.prototype.resetStopWords = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/stop-words";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// RANKING RULES
///
/**
* Get the list of all ranking-rules
* @memberof Index
* @method getRankingRules
*/
Index.prototype.getRankingRules = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/ranking-rules";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// RANKING RULES
///
/**
* Get the list of all ranking-rules
* @memberof Index
* @method getRankingRules
*/
Index.prototype.getRankingRules = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/ranking-rules";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update the list of ranking-rules. Overwrite the old list.
* @memberof Index
* @method updateRankingRules
*/
Index.prototype.updateRankingRules = function (rankingRules) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/ranking-rules";
return [4 /*yield*/, this.post(url, rankingRules)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the list of ranking-rules. Overwrite the old list.
* @memberof Index
* @method updateRankingRules
*/
Index.prototype.updateRankingRules = function (rankingRules) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/ranking-rules";
return [4 /*yield*/, this.post(url, rankingRules)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Reset the ranking rules list to its default value
* @memberof Index
* @method resetRankingRules
*/
Index.prototype.resetRankingRules = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/ranking-rules";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Reset the ranking rules list to its default value
* @memberof Index
* @method resetRankingRules
*/
Index.prototype.resetRankingRules = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/ranking-rules";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// DISTINCT ATTRIBUTE
///
/**
* Get the distinct-attribute
* @memberof Index
* @method getDistinctAttribute
*/
Index.prototype.getDistinctAttribute = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/distinct-attribute";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// DISTINCT ATTRIBUTE
///
/**
* Get the distinct-attribute
* @memberof Index
* @method getDistinctAttribute
*/
Index.prototype.getDistinctAttribute = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/distinct-attribute";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update the distinct-attribute.
* @memberof Index
* @method updateDistinctAttribute
*/
Index.prototype.updateDistinctAttribute = function (distinctAttribute) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/distinct-attribute";
return [4 /*yield*/, this.post(url, distinctAttribute)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the distinct-attribute.
* @memberof Index
* @method updateDistinctAttribute
*/
Index.prototype.updateDistinctAttribute = function (distinctAttribute) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/distinct-attribute";
return [4 /*yield*/, this.post(url, distinctAttribute)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Reset the distinct-attribute.
* @memberof Index
* @method resetDistinctAttribute
*/
Index.prototype.resetDistinctAttribute = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/distinct-attribute";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Reset the distinct-attribute.
* @memberof Index
* @method resetDistinctAttribute
*/
Index.prototype.resetDistinctAttribute = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/distinct-attribute";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// SEARCHABLE ATTRIBUTE
///
/**
* Get the searchable-attributes
* @memberof Index
* @method getSearchableAttributes
*/
Index.prototype.getSearchableAttributes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/searchable-attributes";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// ATTRIBUTES FOR FACETING
///
/**
* Get the attributes-for-faceting
* @memberof Index
* @method getAttributesForFaceting
*/
Index.prototype.getAttributesForFaceting = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/attributes-for-faceting";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update the searchable-attributes.
* @memberof Index
* @method updateSearchableAttributes
*/
Index.prototype.updateSearchableAttributes = function (searchableAttributes) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/searchable-attributes";
return [4 /*yield*/, this.post(url, searchableAttributes)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the attributes-for-faceting.
* @memberof Index
* @method updateAttributesForFaceting
*/
Index.prototype.updateAttributesForFaceting = function (attributesForFaceting) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/attributes-for-faceting";
return [4 /*yield*/, this.post(url, attributesForFaceting)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Reset the searchable-attributes.
* @memberof Index
* @method resetSearchableAttributes
*/
Index.prototype.resetSearchableAttributes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/searchable-attributes";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Reset the attributes-for-faceting.
* @memberof Index
* @method resetAttributesForFaceting
*/
Index.prototype.resetAttributesForFaceting = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/attributes-for-faceting";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// DISPLAYED ATTRIBUTE
///
/**
* Get the displayed-attributes
* @memberof Index
* @method getDisplayedAttributes
*/
Index.prototype.getDisplayedAttributes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/displayed-attributes";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// SEARCHABLE ATTRIBUTE
///
/**
* Get the searchable-attributes
* @memberof Index
* @method getSearchableAttributes
*/
Index.prototype.getSearchableAttributes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/searchable-attributes";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update the displayed-attributes.
* @memberof Index
* @method updateDisplayedAttributes
*/
Index.prototype.updateDisplayedAttributes = function (displayedAttributes) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/displayed-attributes";
return [4 /*yield*/, this.post(url, displayedAttributes)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the searchable-attributes.
* @memberof Index
* @method updateSearchableAttributes
*/
Index.prototype.updateSearchableAttributes = function (searchableAttributes) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/searchable-attributes";
return [4 /*yield*/, this.post(url, searchableAttributes)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Reset the displayed-attributes.
* @memberof Index
* @method resetDisplayedAttributes
*/
Index.prototype.resetDisplayedAttributes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/displayed-attributes";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Reset the searchable-attributes.
* @memberof Index
* @method resetSearchableAttributes
*/
Index.prototype.resetSearchableAttributes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/searchable-attributes";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// ACCEPT NEW FIELDS
///
/**
* Get the accept-new-fields value.
* @memberof Index
* @method getAcceptNewFields
*/
Index.prototype.getAcceptNewFields = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/accept-new-fields";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// DISPLAYED ATTRIBUTE
///
/**
* Get the displayed-attributes
* @memberof Index
* @method getDisplayedAttributes
*/
Index.prototype.getDisplayedAttributes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/displayed-attributes";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Update the accept-new-fields value.
* @memberof Index
* @method updateAcceptNewFields
*/
Index.prototype.updateAcceptNewFields = function (acceptNewFields) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/accept-new-fields";
return [4 /*yield*/, this.post(url, acceptNewFields)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the displayed-attributes.
* @memberof Index
* @method updateDisplayedAttributes
*/
Index.prototype.updateDisplayedAttributes = function (displayedAttributes) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/displayed-attributes";
return [4 /*yield*/, this.post(url, displayedAttributes)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
return Index;
}(MeiliAxiosWrapper));
});
};
/**
* Reset the displayed-attributes.
* @memberof Index
* @method resetDisplayedAttributes
*/
Index.prototype.resetDisplayedAttributes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/displayed-attributes";
return [4 /*yield*/, this["delete"](url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// ACCEPT NEW FIELDS
///
/**
* Get the accept-new-fields value.
* @memberof Index
* @method getAcceptNewFields
*/
Index.prototype.getAcceptNewFields = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/accept-new-fields";
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Update the accept-new-fields value.
* @memberof Index
* @method updateAcceptNewFields
*/
Index.prototype.updateAcceptNewFields = function (acceptNewFields) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = "/indexes/" + this.uid + "/settings/accept-new-fields";
return [4 /*yield*/, this.post(url, acceptNewFields)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return Index;
}(MeiliAxiosWrapper));
/*
* Bundle: Meilisearch
* Project: Meilisearch - Javascript API
* Author: Quentin de Quelen <quentin@meilisearch.com>
* Copyright: 2019, Meilisearch
/*
* Bundle: Meilisearch
* Project: Meilisearch - Javascript API
* Author: Quentin de Quelen <quentin@meilisearch.com>
* Copyright: 2019, Meilisearch
*/
var Meilisearch = /** @class */ (function (_super) {
__extends(Meilisearch, _super);
function Meilisearch(config) {
var _this = _super.call(this, config) || this;
_this.config = config;
return _this;
}
/**
* Return an Index instance
* @memberof Meilisearch
* @method getIndex
*/
var Meilisearch = /** @class */ (function (_super) {
__extends(Meilisearch, _super);
function Meilisearch(config) {
var _this = _super.call(this, config) || this;
_this.config = config;
return _this;
}
/**
* Return an Index instance
* @memberof Meilisearch
* @method Index
*/
Meilisearch.prototype.getIndex = function (indexUid) {
return new Index(this.config, indexUid);
};
/**
* List all indexes in the database
* @memberof Meilisearch
* @method listIndexes
*/
Meilisearch.prototype.listIndexes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/indexes';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
Meilisearch.prototype.getIndex = function (indexUid) {
return new Index(this.config, indexUid);
};
/**
* Get an index or create it if it does not exist
* @memberof Meilisearch
* @method getOrCreateIndex
*/
Meilisearch.prototype.getOrCreateIndex = function (uid, options) {
if (options === void 0) { options = {}; }
return __awaiter(this, void 0, void 0, function () {
var index, e_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
_a.trys.push([0, 2, , 3]);
return [4 /*yield*/, this.createIndex(uid, options)];
case 1:
index = _a.sent();
return [2 /*return*/, index];
case 2:
e_1 = _a.sent();
if (e_1.errorCode === 'index_already_exists') {
return [2 /*return*/, this.getIndex(uid)];
}
throw e_1;
case 3: return [2 /*return*/];
}
});
};
/**
* Create a new index
* @memberof Meilisearch
* @method createIndex
*/
Meilisearch.prototype.createIndex = function (data) {
return __awaiter(this, void 0, void 0, function () {
var url, index;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/indexes';
return [4 /*yield*/, this.post(url, data)];
case 1:
index = _a.sent();
return [2 /*return*/, new Index(this.config, index.uid)];
}
});
});
};
/**
* List all indexes in the database
* @memberof Meilisearch
* @method listIndexes
*/
Meilisearch.prototype.listIndexes = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/indexes';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// KEYS
///
/**
* Get private and public key
* @memberof Meilisearch
* @method getKey
*/
Meilisearch.prototype.getKeys = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/keys';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Create a new index
* @memberof Meilisearch
* @method createIndex
*/
Meilisearch.prototype.createIndex = function (uid, options) {
if (options === void 0) { options = {}; }
return __awaiter(this, void 0, void 0, function () {
var url, index;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/indexes';
return [4 /*yield*/, this.post(url, __assign(__assign({}, options), { uid: uid }))];
case 1:
index = _a.sent();
return [2 /*return*/, new Index(this.config, index.uid)];
}
});
};
///
/// HEALTH
///
/**
* Check if the server is healhty
* @memberof Meilisearch
* @method isHealthy
*/
Meilisearch.prototype.isHealthy = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/health';
return [4 /*yield*/, this.get(url).then(function (_) { return true; })];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// KEYS
///
/**
* Get private and public key
* @memberof Meilisearch
* @method getKey
*/
Meilisearch.prototype.getKeys = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/keys';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Change the healthyness to healthy
* @memberof Meilisearch
* @method setHealthy
*/
Meilisearch.prototype.setHealthy = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/health';
return [4 /*yield*/, this.put(url, {
health: true,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// HEALTH
///
/**
* Check if the server is healhty
* @memberof Meilisearch
* @method isHealthy
*/
Meilisearch.prototype.isHealthy = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/health';
return [4 /*yield*/, this.get(url).then(function (_) { return true; })];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Change the healthyness to unhealthy
* @memberof Meilisearch
* @method setUnhealthy
*/
Meilisearch.prototype.setUnhealthy = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/health';
return [4 /*yield*/, this.put(url, {
health: false,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Change the healthyness to healthy
* @memberof Meilisearch
* @method setHealthy
*/
Meilisearch.prototype.setHealthy = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/health';
return [4 /*yield*/, this.put(url, {
health: true,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Set the healthyness to health value
* @memberof Meilisearch
* @method changeHealthTo
*/
Meilisearch.prototype.changeHealthTo = function (health) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/health';
return [4 /*yield*/, this.put(url, {
health: health,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Change the healthyness to unhealthy
* @memberof Meilisearch
* @method setUnhealthy
*/
Meilisearch.prototype.setUnhealthy = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/health';
return [4 /*yield*/, this.put(url, {
health: false,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
///
/// STATS
///
/**
* Get the stats of all the database
* @memberof Meilisearch
* @method stats
*/
Meilisearch.prototype.stats = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/stats';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Set the healthyness to health value
* @memberof Meilisearch
* @method changeHealthTo
*/
Meilisearch.prototype.changeHealthTo = function (health) {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/health';
return [4 /*yield*/, this.put(url, {
health: health,
})];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Get the version of MeiliSearch
* @memberof Meilisearch
* @method version
*/
Meilisearch.prototype.version = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/version';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
///
/// STATS
///
/**
* Get the stats of all the database
* @memberof Meilisearch
* @method stats
*/
Meilisearch.prototype.stats = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/stats';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Get the server consuption, RAM / CPU / Network
* @memberof Meilisearch
* @method sysInfo
*/
Meilisearch.prototype.sysInfo = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/sys-info';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Get the version of MeiliSearch
* @memberof Meilisearch
* @method version
*/
Meilisearch.prototype.version = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/version';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
/**
* Get the server consuption, RAM / CPU / Network. All information as human readable
* @memberof Meilisearch
* @method prettySysInfo
*/
Meilisearch.prototype.prettySysInfo = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/sys-info/pretty';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* Get the server consuption, RAM / CPU / Network
* @memberof Meilisearch
* @method sysInfo
*/
Meilisearch.prototype.sysInfo = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/sys-info';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
};
return Meilisearch;
}(MeiliAxiosWrapper));
});
};
/**
* Get the server consuption, RAM / CPU / Network. All information as human readable
* @memberof Meilisearch
* @method prettySysInfo
*/
Meilisearch.prototype.prettySysInfo = function () {
return __awaiter(this, void 0, void 0, function () {
var url;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = '/sys-info/pretty';
return [4 /*yield*/, this.get(url)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
return Meilisearch;
}(MeiliAxiosWrapper));
})));
module.exports = Meilisearch;

@@ -1,17 +0,16 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("axios")):"function"==typeof define&&define.amd?define(["axios"],e):(t=t||self).Meilisearch=e(t.axios)}(this,(function(t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;
"use strict";var t,e=(t=require("axios"))&&"object"==typeof t&&"default"in t?t.default:t,n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
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)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,n)};function n(t,n){function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){return(i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function r(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((i=i.apply(t,e||[])).next())}))}function s(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var o=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchTimeOutError",i.type=i.constructor.name,Error.captureStackTrace(i,e),i}return n(e,t),e}(Error),u=function(t){function e(e,n){var i,r=t.call(this,e.message)||this;return r.type=r.constructor.name,r.name="MeiliSearchApiError",void 0!==e.response?(r.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method,body:e.response.data},void 0!==(null===(i=e.response.data)||void 0===i?void 0:i.message)&&(r.message=e.response.data.message)):r.request={url:e.request._currentUrl,path:e.config.url,method:e.config.method},void 0!==n&&void 0!==e.stack&&(r.stack=r.name+": "+r.message+"\n"+n.split("\n").slice(1).join("\n")),r}return n(e,t),e}(Error),c=function(){function e(e){void 0!==e.apiKey?this.instance=t.create({baseURL:e.host,headers:{"X-Meili-API-Key":e.apiKey}}):this.instance=t.create({baseURL:e.host}),this.cancelTokenSource=t.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?i(i({},t),{data:JSON.stringify(t.data)}):t}))}return e.prototype.get=function(t,e){return r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,r.sent()];case 3:throw i=r.sent(),new u(i,n);case 4:return[2]}}))}))},e.prototype.post=function(t,e,n){return r(this,void 0,void 0,(function(){var i,r;return s(this,(function(s){switch(s.label){case 0:i=(new Error).stack,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,s.sent()];case 3:throw r=s.sent(),new u(r,i);case 4:return[2]}}))}))},e.prototype.put=function(t,e,n){return r(this,void 0,void 0,(function(){var i,r;return s(this,(function(s){switch(s.label){case 0:i=(new Error).stack,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,s.sent()];case 3:throw r=s.sent(),new u(r,i);case 4:return[2]}}))}))},e.prototype.patch=function(t,e,n){return r(this,void 0,void 0,(function(){var i,r;return s(this,(function(s){switch(s.label){case 0:i=(new Error).stack,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,s.sent()];case 3:throw r=s.sent(),new u(r,i);case 4:return[2]}}))}))},e.prototype.delete=function(t,e){return r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:n=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,r.sent()];case 3:throw i=r.sent(),new u(i,n);case 4:return[2]}}))}))},e}();function a(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var h=function(t){function e(e,n){var i=t.call(this,e)||this;return i.uid=n,i}return n(e,t),e.prototype.getUpdateStatus=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,u=void 0===i?5e3:i,c=n.intervalMs,h=void 0===c?50:c;return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=i.sent()).status?[2,n]:[4,a(h)];case 3:return i.sent(),[3,1];case 4:throw new o("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return r(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.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.search=function(t,e){return r(this,void 0,void 0,(function(){var n,i;return s(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/search",i={q:t},void 0!==e&&(void 0!==e.offset&&(i.offset=e.offset),void 0!==e.limit&&(i.limit=e.limit),void 0!==e.attributesToRetrieve&&(Array.isArray(e.attributesToRetrieve)?i.attributesToRetrieve=e.attributesToRetrieve.join(","):i.attributesToRetrieve=e.attributesToRetrieve),void 0!==e.attributesToCrop&&(Array.isArray(e.attributesToCrop)?i.attributesToCrop=e.attributesToCrop.join(","):i.attributesToCrop=e.attributesToCrop),void 0!==e.cropLength&&(i.cropLength=e.cropLength),void 0!==e.attributesToHighlight&&(Array.isArray(e.attributesToHighlight)?i.attributesToHighlight=e.attributesToHighlight.join(","):i.attributesToHighlight=e.attributesToHighlight),void 0!==e.filters&&(i.filters=e.filters),void 0!==e.matches&&(i.matches=e.matches)),[4,this.get(n,{params:i,cancelToken:this.cancelTokenSource.token})];case 1:return[2,r.sent()]}}))}))},e.prototype.show=function(){return r(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.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateIndex=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteIndex=function(){return r(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.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStats=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDocuments=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.get(e,{params:i(i({},t),void 0!==n?{attributesToRetrieve:n}:{})})];case 1:return[2,r.sent()]}}))}))},e.prototype.getDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.addDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteDocuments=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteAllDocuments=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSettings=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSynonyms=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateStopWords=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateRankingRules=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDistinctAttribute=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSearchableAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAcceptNewFields=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAcceptNewFields=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e}(c);return function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return n(e,t),e.prototype.getIndex=function(t){return new h(this.config,t)},e.prototype.listIndexes=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},e.prototype.createIndex=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return"/indexes",[4,this.post("/indexes",t)];case 1:return e=n.sent(),[2,new h(this.config,e.uid)]}}))}))},e.prototype.getKeys=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},e.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(t){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},e.prototype.setUnhealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},e.prototype.changeHealthTo=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.stats=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},e.prototype.version=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},e.prototype.sysInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/sys-info",[4,this.get("/sys-info")];case 1:return[2,t.sent()]}}))}))},e.prototype.prettySysInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"/sys-info/pretty",[4,this.get("/sys-info/pretty")];case 1:return[2,t.sent()]}}))}))},e}(c)}));
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function i(t,e){function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function s(t,e,n,i){return new(n||(n=Promise))((function(r,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((i=i.apply(t,e||[])).next())}))}function o(t,e){var n,i,r,s,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return s={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function u(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,i=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){o.label=s[1];break}if(6===s[0]&&o.label<r[1]){o.label=r[1],r=s;break}if(r&&o.label<r[2]){o.label=r[2],o.ops.push(s);break}r[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}var u=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchTimeOutError",i.type=i.constructor.name,Error.captureStackTrace(i,e),i}return i(e,t),e}(Error),c=function(t){function e(e,n){var i,r=t.call(this,e.message)||this;return r.type="MeiliSearchApiError",r.name="MeiliSearchApiError",void 0!==e.response&&(r.response={status:e.response.status,statusText:e.response.statusText,path:e.response.config.url,method:e.response.config.method},void 0!==(null===(i=e.response.data)||void 0===i?void 0:i.message)&&(r.errorCode=e.response.data.errorCode,r.errorType=e.response.data.errorType,r.errorLink=e.response.data.errorLink,r.message=e.response.data.message)),void 0!==n&&void 0!==e.stack&&(r.stack=r.name+": "+r.message+"\n"+n.split("\n").slice(1).join("\n")),r}return i(e,t),e}(Error),a=function(t){function e(n){var i=t.call(this,n)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",Error.captureStackTrace(i,e),i}return i(e,t),e}(Error);function h(t,e){throw void 0!==t.response?new c(t,e):t.isAxiosError?new a(t.message):t}var d=function(){function t(t){void 0!==t.apiKey?this.instance=e.create({baseURL:t.host,headers:{"X-Meili-API-Key":t.apiKey}}):this.instance=e.create({baseURL:t.host}),this.cancelTokenSource=e.CancelToken.source(),this.instance.interceptors.response.use((function(t){return t.data})),this.instance.interceptors.request.use((function(t){return void 0!==t.data?r(r({},t),{data:JSON.stringify(t.data)}):t}))}return t.prototype.get=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(i){switch(i.label){case 0:n=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.get(t,e)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),n);case 4:return[2]}}))}))},t.prototype.post=function(t,e,n){return s(this,void 0,void 0,(function(){var i;return o(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.post(t,e,n)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),i);case 4:return[2]}}))}))},t.prototype.put=function(t,e,n){return s(this,void 0,void 0,(function(){var i;return o(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.put(t,e,n)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),i);case 4:return[2]}}))}))},t.prototype.patch=function(t,e,n){return s(this,void 0,void 0,(function(){var i;return o(this,(function(r){switch(r.label){case 0:i=(new Error).stack,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.instance.patch(t,e,n)];case 2:return[2,r.sent()];case 3:throw h(r.sent(),i);case 4:return[2]}}))}))},t.prototype.delete=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(i){switch(i.label){case 0:n=(new Error).stack,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.instance.delete(t,e)];case 2:return[2,i.sent()];case 3:throw h(i.sent(),n);case 4:return[2]}}))}))},t}();function l(t){return s(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var f=function(t){function e(e,n){var i=t.call(this,e)||this;return i.uid=n,i}return i(e,t),e.prototype.getUpdateStatus=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.waitForPendingUpdate=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,r=void 0===i?5e3:i,c=n.intervalMs,a=void 0===c?50:c;return s(this,void 0,void 0,(function(){var e,n;return o(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<r?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(n=i.sent()).status?[2,n]:[4,l(a)];case 3:return i.sent(),[3,1];case 4:throw new u("timeout of "+r+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},e.prototype.getAllUpdateStatus=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.search=function(t,e){return s(this,void 0,void 0,(function(){var n,i;return o(this,(function(r){switch(r.label){case 0:return n="/indexes/"+this.uid+"/search",i={q:t},void 0!==e&&(void 0!==e.offset&&(i.offset=e.offset),void 0!==e.limit&&(i.limit=e.limit),void 0!==e.attributesToRetrieve&&(Array.isArray(e.attributesToRetrieve)?i.attributesToRetrieve=e.attributesToRetrieve.join(","):i.attributesToRetrieve=e.attributesToRetrieve),void 0!==e.attributesToCrop&&(Array.isArray(e.attributesToCrop)?i.attributesToCrop=e.attributesToCrop.join(","):i.attributesToCrop=e.attributesToCrop),void 0!==e.cropLength&&(i.cropLength=e.cropLength),void 0!==e.attributesToHighlight&&(Array.isArray(e.attributesToHighlight)?i.attributesToHighlight=e.attributesToHighlight.join(","):i.attributesToHighlight=e.attributesToHighlight),void 0!==e.filters&&(i.filters=e.filters),void 0!==e.matches&&(i.matches=e.matches),void 0!==e.facetFilters&&(i.facetFilters=JSON.stringify(e.facetFilters)),void 0!==e.facetsDistribution&&(i.facetsDistribution=JSON.stringify(e.facetsDistribution))),[4,this.get(n,{params:i,cancelToken:this.cancelTokenSource.token})];case 1:return[2,r.sent()]}}))}))},e.prototype.show=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateIndex=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.put(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteIndex=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStats=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDocuments=function(t){return s(this,void 0,void 0,(function(){var e,n;return o(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.get(e,{params:r(r({},t),void 0!==n?{attributesToRetrieve:n}:{})})];case 1:return[2,i.sent()]}}))}))},e.prototype.getDocument=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.get(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.addDocuments=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.post(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.updateDocuments=function(t,e){return s(this,void 0,void 0,(function(){var n;return o(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/documents",[4,this.put(n,t,{params:e})];case 1:return[2,i.sent()]}}))}))},e.prototype.deleteDocument=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.delete(e)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteDocuments=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.deleteAllDocuments=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSettings=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSettings=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSettings=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSynonyms=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSynonyms=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSynonyms=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getStopWords=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateStopWords=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetStopWords=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getRankingRules=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateRankingRules=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetRankingRules=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDistinctAttribute=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDistinctAttribute=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDistinctAttribute=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAttributesForFaceting=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAttributesForFaceting=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetAttributesForFaceting=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getSearchableAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateSearchableAttributes=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetSearchableAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getDisplayedAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateDisplayedAttributes=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.resetDisplayedAttributes=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.delete(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.getAcceptNewFields=function(){return s(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.get(t)];case 1:return[2,e.sent()]}}))}))},e.prototype.updateAcceptNewFields=function(t){return s(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid+"/settings/accept-new-fields",[4,this.post(e,t)];case 1:return[2,n.sent()]}}))}))},e}(d),p=function(t){function e(e){var n=t.call(this,e)||this;return n.config=e,n}return i(e,t),e.prototype.getIndex=function(t){return new f(this.config,t)},e.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n;return o(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.createIndex(t,e)];case 1:return[2,i.sent()];case 2:if("index_already_exists"===(n=i.sent()).errorCode)return[2,this.getIndex(t)];throw n;case 3:return[2]}}))}))},e.prototype.listIndexes=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/indexes",[4,this.get("/indexes")];case 1:return[2,t.sent()]}}))}))},e.prototype.createIndex=function(t,e){return void 0===e&&(e={}),s(this,void 0,void 0,(function(){var n;return o(this,(function(i){switch(i.label){case 0:return"/indexes",[4,this.post("/indexes",r(r({},e),{uid:t}))];case 1:return n=i.sent(),[2,new f(this.config,n.uid)]}}))}))},e.prototype.getKeys=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/keys",[4,this.get("/keys")];case 1:return[2,t.sent()]}}))}))},e.prototype.isHealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.get("/health").then((function(t){return!0}))];case 1:return[2,t.sent()]}}))}))},e.prototype.setHealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!0})];case 1:return[2,t.sent()]}}))}))},e.prototype.setUnhealthy=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/health",[4,this.put("/health",{health:!1})];case 1:return[2,t.sent()]}}))}))},e.prototype.changeHealthTo=function(t){return s(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return"/health",[4,this.put("/health",{health:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.stats=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/stats",[4,this.get("/stats")];case 1:return[2,t.sent()]}}))}))},e.prototype.version=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/version",[4,this.get("/version")];case 1:return[2,t.sent()]}}))}))},e.prototype.sysInfo=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/sys-info",[4,this.get("/sys-info")];case 1:return[2,t.sent()]}}))}))},e.prototype.prettySysInfo=function(){return s(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return"/sys-info/pretty",[4,this.get("/sys-info/pretty")];case 1:return[2,t.sent()]}}))}))},e}(d);module.exports=p;
//# sourceMappingURL=meilisearch.umd.min.js.map

@@ -27,3 +27,3 @@ import MeiliAxiosWrapper from './meili-axios-wrapper';

*/
search(query: string, options?: Types.SearchParams): Promise<Types.SearchResponse>;
search<T = any>(query: string, options?: Types.SearchParams): Promise<Types.SearchResponse<T>>;
/**

@@ -40,3 +40,3 @@ * Show index information.

*/
updateIndex(data: Types.UpdateIndexRequest): Promise<Types.IndexResponse>;
updateIndex(data: Types.IndexOptions): Promise<Types.IndexResponse>;
/**

@@ -188,2 +188,20 @@ * Delete an index.

/**
* Get the attributes-for-faceting
* @memberof Index
* @method getAttributesForFaceting
*/
getAttributesForFaceting(): Promise<string[]>;
/**
* Update the attributes-for-faceting.
* @memberof Index
* @method updateAttributesForFaceting
*/
updateAttributesForFaceting(attributesForFaceting: string[]): Promise<Types.EnqueuedUpdate>;
/**
* Reset the attributes-for-faceting.
* @memberof Index
* @method resetAttributesForFaceting
*/
resetAttributesForFaceting(): Promise<Types.EnqueuedUpdate>;
/**
* Get the searchable-attributes

@@ -190,0 +208,0 @@ * @memberof Index

@@ -10,6 +10,12 @@ import { Index } from './index';

* @memberof Meilisearch
* @method Index
* @method getIndex
*/
getIndex(indexUid: string): Index;
/**
* Get an index or create it if it does not exist
* @memberof Meilisearch
* @method getOrCreateIndex
*/
getOrCreateIndex(uid: string, options?: Types.IndexOptions): Promise<Index>;
/**
* List all indexes in the database

@@ -25,3 +31,3 @@ * @memberof Meilisearch

*/
createIndex(data: Types.IndexRequest): Promise<Index>;
createIndex(uid: string, options?: Types.IndexOptions): Promise<Index>;
/**

@@ -28,0 +34,0 @@ * Get private and public key

@@ -1,6 +0,6 @@

// Type definitions for meilisearch 0.10.1
// Type definitions for meilisearch 0.11.0
// Project: https://github.com/meilisearch/meilisearch-js
// Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch>
// Definitions: https://github.com/meilisearch/meilisearch-js
// TypeScript Version: 3.9.3
// TypeScript Version: 3.9.5

@@ -11,4 +11,4 @@ import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosResponse, CancelTokenSource } from 'axios';

import MeiliSearch from './meilisearch';
import MeiliSearchApiError from './custom-errors/meilisearch-error';
import MeiliSearchTimeOutError from './custom-errors/meilisearch-timeout-error';
import MeiliSearchApiError from './errors/meilisearch-api-error';
import MeiliSearchTimeOutError from './errors/meilisearch-timeout-error';
export { Index };

@@ -25,2 +25,5 @@ export { MeiliSearchApiError };

}
export interface IndexOptions {
primaryKey?: string;
}
export interface IndexResponse {

@@ -33,8 +36,6 @@ uid: string;

}
export interface UpdateIndexRequest {
primaryKey?: string;
}
export interface AddDocumentParams {
primaryKey?: string;
}
export declare type FacetFilter = string | FacetFilter[];
export interface SearchParams {

@@ -48,2 +49,4 @@ offset?: number;

filters?: string;
facetFilters?: FacetFilter[];
facetsDistribution?: string[];
matches?: boolean;

@@ -59,2 +62,4 @@ }

attributesToHighlight?: string;
facetFilters?: string;
facetsDistribution?: string;
filters?: string;

@@ -71,2 +76,4 @@ matches?: boolean;

processingTimeMs: number;
facetsDistribution?: object;
exhaustiveFacetsCount?: boolean;
query: string;

@@ -86,2 +93,3 @@ }

export interface Settings {
attributesForFaceting?: string[];
distinctAttribute?: string;

@@ -167,4 +175,5 @@ searchableAttributes?: string[];

getIndex: (indexUid: string) => Index;
getOrCreateIndex: (uid: string, options?: IndexOptions) => Promise<Index>;
listIndexes: () => Promise<IndexResponse[]>;
createIndex: (data: IndexRequest) => Promise<Index>;
createIndex: (uid: string, options?: IndexOptions) => Promise<Index>;
getKeys: () => Promise<Keys>;

@@ -184,5 +193,5 @@ isHealthy: () => Promise<boolean>;

getAllUpdateStatus: () => Promise<Update[]>;
search: (query: string, options?: SearchParams) => Promise<SearchResponse>;
search: <T = any>(query: string, options?: SearchParams) => Promise<SearchResponse<T>>;
show: () => Promise<IndexResponse>;
updateIndex: (data: UpdateIndexRequest) => Promise<IndexResponse>;
updateIndex: (indexData: IndexOptions) => Promise<IndexResponse>;
deleteIndex: () => Promise<string>;

@@ -212,2 +221,5 @@ getStats: () => Promise<IndexStats>;

resetDistinctAttribute: () => Promise<EnqueuedUpdate>;
getAttributesForFaceting: () => Promise<string[]>;
updateAttributesForFaceting: (attributesForFaceting: string[]) => Promise<EnqueuedUpdate>;
resetAttributesForFaceting: () => Promise<EnqueuedUpdate>;
getSearchableAttributes: () => Promise<string[]>;

@@ -226,3 +238,3 @@ updateSearchableAttributes: (searchableAttributes: string[]) => Promise<EnqueuedUpdate>;

get: <T = any, R = AxiosResponse<T>>(url: string, config?: AxiosRequestConfig) => Promise<R>;
post: ((url: string, data: IndexRequest, config?: AxiosRequestConfig) => Promise<IndexResponse>) & (<T = any, R = AxiosResponse<EnqueuedUpdate>>(url: string, data?: T, config?: AxiosRequestConfig) => Promise<R>);
post: ((url: string, data: IndexRequest, config?: AxiosRequestConfig) => Promise<Index>) & (<T = any, R = AxiosResponse<EnqueuedUpdate>>(url: string, data?: T, config?: AxiosRequestConfig) => Promise<R>);
put: <T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig) => Promise<R>;

@@ -236,2 +248,7 @@ patch: <T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig) => Promise<R>;

stack?: string;
errorCode?: string;
errorType?: string;
errorLink?: string;
response?: MeiliSearchApiErrorResponse;
request?: MeiliSearchApiErrorRequest;
}

@@ -238,0 +255,0 @@ export interface MeiliSearchApiErrorResponse {

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

@@ -19,3 +19,3 @@ "keywords": [

"license": "MIT",
"main": "./dist/bundles/meilisearch.cjs.js",
"main": "./dist/bundles/meilisearch.umd.js",
"module": "./dist/bundles/meilisearch.esm.js",

@@ -63,6 +63,6 @@ "browser": "./dist/bundles/meilisearch.umd.js",

"devDependencies": {
"@rollup/plugin-commonjs": "12.0.0",
"@rollup/plugin-commonjs": "13.0.0",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "8.0.0",
"@types/jest": "25.2.3",
"@rollup/plugin-node-resolve": "8.0.1",
"@types/jest": "26.0.0",
"@types/prettier": "^2.0.0",

@@ -75,3 +75,3 @@ "@typescript-eslint/eslint-plugin": "2.34.0",

"eslint-plugin-import": "2",
"eslint-plugin-jsdoc": "^25.4.2",
"eslint-plugin-jsdoc": "^27.0.2",
"eslint-plugin-node": "11",

@@ -84,3 +84,3 @@ "eslint-plugin-promise": "4",

"kleur": "^3.0.3",
"lint-staged": "10.2.6",
"lint-staged": "10.2.10",
"prettier": "^2.0.2",

@@ -93,4 +93,4 @@ "pretty-bytes": "^5.3.0",

"ts-jest": "^25.3.0",
"typescript": "3.9.3"
"typescript": "3.9.5"
}
}

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

const index = await client.createIndex({ uid: 'books' }) // If your index does not exists
const index = await client.createIndex('books') // If your index does not exist
// OR

@@ -127,3 +127,3 @@ const index = client.getIndex('books') // If your index exists

- `v0.10.X`
- `v0.11.X`

@@ -145,5 +145,5 @@ ## 🎬 Examples

// Create an index
const index = await client.createIndex({ uid: 'books' })
const index = await client.createIndex('books')
// Create an index and give the primary-key
const index = await client.createIndex({ uid: 'books', primaryKey: 'book_id' })
const index = await client.createIndex('books', { primaryKey: 'book_id' })
```

@@ -268,3 +268,3 @@

If you want to contribute, this sections describes the steps to follow.
If you want to contribute, this section describes the steps to follow.

@@ -322,3 +322,3 @@ Thank you for your interest in a MeiliSearch tool! ♥️

`client.getIndex('xxx').search(query: string, options?: SearchParams): Promise<SearchResponse>`
`client.getIndex('xxx').search<T = any>(query: string, options?: SearchParams): Promise<SearchResponse<T>>`

@@ -333,3 +333,3 @@ ### Indexes <!-- omit in toc -->

`client.createIndex(data: IndexRequest): Promise<Index>`
`client.createIndex(uid: string, options?: IndexOptions): Promise<Index>`

@@ -340,2 +340,6 @@ - Get index object:

- Get or create index if it does not exist
`client.getOrCreateIndex(uid: string, options?: IndexOptions): Promise<Index>`
- Show Index information:

@@ -347,3 +351,3 @@

`index.updateIndex(data: UpdateIndexRequest): Promise<IndexResponse>`
`index.updateIndex(data: IndexOptions): Promise<IndexResponse>`

@@ -350,0 +354,0 @@ - Delete Index:

@@ -10,3 +10,3 @@ /*

import MeiliSearchTimeOutError from './custom-errors/meilisearch-timeout-error'
import MeiliSearchTimeOutError from './errors/meilisearch-timeout-error'
import MeiliAxiosWrapper from './meili-axios-wrapper'

@@ -76,6 +76,6 @@ import * as Types from './types'

*/
async search(
async search<T = any>(
query: string,
options?: Types.SearchParams
): Promise<Types.SearchResponse> {
): Promise<Types.SearchResponse<T>> {
const url = `/indexes/${this.uid}/search`

@@ -121,6 +121,11 @@

}
if (options.matches !== undefined) {
params.matches = options.matches
}
if (options.facetFilters !== undefined) {
params.facetFilters = JSON.stringify(options.facetFilters)
}
if (options.facetsDistribution !== undefined) {
params.facetsDistribution = JSON.stringify(options.facetsDistribution)
}
}

@@ -154,3 +159,3 @@

async updateIndex(
data: Types.UpdateIndexRequest
data: Types.IndexOptions
): Promise<Types.IndexResponse> {

@@ -487,2 +492,41 @@ const url = `/indexes/${this.uid}`

///
/// ATTRIBUTES FOR FACETING
///
/**
* Get the attributes-for-faceting
* @memberof Index
* @method getAttributesForFaceting
*/
async getAttributesForFaceting(): Promise<string[]> {
const url = `/indexes/${this.uid}/settings/attributes-for-faceting`
return await this.get(url)
}
/**
* Update the attributes-for-faceting.
* @memberof Index
* @method updateAttributesForFaceting
*/
async updateAttributesForFaceting(
attributesForFaceting: string[]
): Promise<Types.EnqueuedUpdate> {
const url = `/indexes/${this.uid}/settings/attributes-for-faceting`
return await this.post(url, attributesForFaceting)
}
/**
* Reset the attributes-for-faceting.
* @memberof Index
* @method resetAttributesForFaceting
*/
async resetAttributesForFaceting(): Promise<Types.EnqueuedUpdate> {
const url = `/indexes/${this.uid}/settings/attributes-for-faceting`
return await this.delete(url)
}
///
/// SEARCHABLE ATTRIBUTE

@@ -489,0 +533,0 @@ ///

@@ -16,3 +16,3 @@ /*

} from 'axios'
import MeiliSearchApiError from './custom-errors/meilisearch-error'
import { httpErrorHandler } from './errors/http-error-handler'
import * as Types from './types'

@@ -59,3 +59,3 @@

} catch (e) {
throw new MeiliSearchApiError(e, cachedStack)
throw httpErrorHandler(e, cachedStack)
}

@@ -86,3 +86,3 @@ }

} catch (e) {
throw new MeiliSearchApiError(e, cachedStack)
throw httpErrorHandler(e, cachedStack)
}

@@ -100,3 +100,3 @@ }

} catch (e) {
throw new MeiliSearchApiError(e, cachedStack)
throw httpErrorHandler(e, cachedStack)
}

@@ -114,3 +114,3 @@ }

} catch (e) {
throw new MeiliSearchApiError(e, cachedStack)
throw httpErrorHandler(e, cachedStack)
}

@@ -127,3 +127,3 @@ }

} catch (e) {
throw new MeiliSearchApiError(e, cachedStack)
throw httpErrorHandler(e, cachedStack)
}

@@ -130,0 +130,0 @@ }

@@ -25,3 +25,3 @@ /*

* @memberof Meilisearch
* @method Index
* @method getIndex
*/

@@ -33,2 +33,22 @@ getIndex(indexUid: string): Index {

/**
* Get an index or create it if it does not exist
* @memberof Meilisearch
* @method getOrCreateIndex
*/
async getOrCreateIndex(
uid: string,
options: Types.IndexOptions = {}
): Promise<Index> {
try {
const index = await this.createIndex(uid, options)
return index
} catch (e) {
if (e.errorCode === 'index_already_exists') {
return this.getIndex(uid)
}
throw e
}
}
/**
* List all indexes in the database

@@ -49,6 +69,9 @@ * @memberof Meilisearch

*/
async createIndex(data: Types.IndexRequest): Promise<Index> {
async createIndex(
uid: string,
options: Types.IndexOptions = {}
): Promise<Index> {
const url = '/indexes'
const index = await this.post(url, data)
const index = await this.post(url, { ...options, uid })

@@ -55,0 +78,0 @@ return new Index(this.config, index.uid)

@@ -18,4 +18,4 @@ // Type definitions for meilisearch 0.10.0

import MeiliSearch from './meilisearch'
import MeiliSearchApiError from './custom-errors/meilisearch-error'
import MeiliSearchTimeOutError from './custom-errors/meilisearch-timeout-error'
import MeiliSearchApiError from './errors/meilisearch-api-error'
import MeiliSearchTimeOutError from './errors/meilisearch-timeout-error'
export { Index }

@@ -39,2 +39,6 @@ export { MeiliSearchApiError }

export interface IndexOptions {
primaryKey?: string
}
export interface IndexResponse {

@@ -48,6 +52,2 @@ uid: string

export interface UpdateIndexRequest {
primaryKey?: string
}
export interface AddDocumentParams {

@@ -57,2 +57,4 @@ primaryKey?: string

export type FacetFilter = string | FacetFilter[];
export interface SearchParams {

@@ -66,2 +68,4 @@ offset?: number

filters?: string
facetFilters?: FacetFilter[]
facetsDistribution?: string[]
matches?: boolean

@@ -78,2 +82,4 @@ }

attributesToHighlight?: string
facetFilters?: string
facetsDistribution?: string
filters?: string

@@ -90,2 +96,4 @@ matches?: boolean

processingTimeMs: number
facetsDistribution?: object
exhaustiveFacetsCount?: boolean
query: string

@@ -114,3 +122,5 @@ }

*/
export interface Settings {
attributesForFaceting?: string[]
distinctAttribute?: string

@@ -227,4 +237,5 @@ searchableAttributes?: string[]

getIndex: (indexUid: string) => Index
getOrCreateIndex: (uid: string, options?: IndexOptions) => Promise<Index>
listIndexes: () => Promise<IndexResponse[]>
createIndex: (data: IndexRequest) => Promise<Index>
createIndex: (uid: string, options?: IndexOptions) => Promise<Index>
getKeys: () => Promise<Keys>

@@ -245,5 +256,8 @@ isHealthy: () => Promise<boolean>

getAllUpdateStatus: () => Promise<Update[]>
search: (query: string, options?: SearchParams) => Promise<SearchResponse>
search: <T = any>(
query: string,
options?: SearchParams
) => Promise<SearchResponse<T>>
show: () => Promise<IndexResponse>
updateIndex: (data: UpdateIndexRequest) => Promise<IndexResponse>
updateIndex: (indexData: IndexOptions) => Promise<IndexResponse>
deleteIndex: () => Promise<string>

@@ -283,2 +297,7 @@ getStats: () => Promise<IndexStats>

resetDistinctAttribute: () => Promise<EnqueuedUpdate>
getAttributesForFaceting: () => Promise<string[]>
updateAttributesForFaceting: (
attributesForFaceting: string[]
) => Promise<EnqueuedUpdate>
resetAttributesForFaceting: () => Promise<EnqueuedUpdate>
getSearchableAttributes: () => Promise<string[]>

@@ -309,3 +328,3 @@ updateSearchableAttributes: (

config?: AxiosRequestConfig
) => Promise<IndexResponse>) &
) => Promise<Index>) &
(<T = any, R = AxiosResponse<EnqueuedUpdate>>(

@@ -340,2 +359,7 @@ url: string,

stack?: string
errorCode?: string
errorType?: string
errorLink?: string
response?: MeiliSearchApiErrorResponse
request?: MeiliSearchApiErrorRequest
}

@@ -342,0 +366,0 @@ export interface MeiliSearchApiErrorResponse {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc