meilisearch
Advanced tools
Comparing version 0.11.0 to 0.11.1
@@ -1,3 +0,9 @@ | ||
## V0.11.1 (released) | ||
## V0.11.1 | ||
- Feat: Make IndexInterface generic. createIndex and getIndex generic support #442 | ||
- Split bundles into umd and cjs. | ||
- use bundle in package.json `browser` for `umd` | ||
- use bundle in package.json `main` for `cjs` | ||
## V0.11.0 (released) | ||
- BREAKING: Usage of createIndex changed `createIndex(uid: string, options: IndexOptions): Index` #436 | ||
@@ -4,0 +10,0 @@ - BREAKING: Changes in types |
@@ -146,3 +146,3 @@ import instance from 'axios'; | ||
} | ||
else if (e.isAxiosError) { | ||
else if (e.isAxiosError === true) { | ||
throw new MeiliSearchCommunicationError(e.message); | ||
@@ -156,6 +156,6 @@ } | ||
/* | ||
* Bundle: Meilisearch | ||
* Project: Meilisearch - Javascript API | ||
* Bundle: MeiliSearch | ||
* Project: MeiliSearch - Javascript API | ||
* Author: Quentin de Quelen <quentin@meilisearch.com> | ||
* Copyright: 2019, Meilisearch | ||
* Copyright: 2019, MeiliSearch | ||
*/ | ||
@@ -301,6 +301,6 @@ var MeiliAxiosWrapper = /** @class */ (function () { | ||
/* | ||
* Bundle: Meilisearch / Indexes | ||
* Project: Meilisearch - Javascript API | ||
* Bundle: MeiliSearch / Indexes | ||
* Project: MeiliSearch - Javascript API | ||
* Author: Quentin de Quelen <quentin@meilisearch.com> | ||
* Copyright: 2019, Meilisearch | ||
* Copyright: 2019, MeiliSearch | ||
*/ | ||
@@ -1168,10 +1168,10 @@ var Index = /** @class */ (function (_super) { | ||
/* | ||
* Bundle: Meilisearch | ||
* Project: Meilisearch - Javascript API | ||
* Bundle: MeiliSearch | ||
* Project: MeiliSearch - Javascript API | ||
* Author: Quentin de Quelen <quentin@meilisearch.com> | ||
* Copyright: 2019, Meilisearch | ||
* Copyright: 2019, MeiliSearch | ||
*/ | ||
var Meilisearch = /** @class */ (function (_super) { | ||
__extends(Meilisearch, _super); | ||
function Meilisearch(config) { | ||
var MeiliSearch = /** @class */ (function (_super) { | ||
__extends(MeiliSearch, _super); | ||
function MeiliSearch(config) { | ||
var _this = _super.call(this, config) || this; | ||
@@ -1183,6 +1183,6 @@ _this.config = config; | ||
* Return an Index instance | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getIndex | ||
*/ | ||
Meilisearch.prototype.getIndex = function (indexUid) { | ||
MeiliSearch.prototype.getIndex = function (indexUid) { | ||
return new Index(this.config, indexUid); | ||
@@ -1192,6 +1192,6 @@ }; | ||
* Get an index or create it if it does not exist | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getOrCreateIndex | ||
*/ | ||
Meilisearch.prototype.getOrCreateIndex = function (uid, options) { | ||
MeiliSearch.prototype.getOrCreateIndex = function (uid, options) { | ||
if (options === void 0) { options = {}; } | ||
@@ -1221,6 +1221,6 @@ return __awaiter(this, void 0, void 0, function () { | ||
* List all indexes in the database | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method listIndexes | ||
*/ | ||
Meilisearch.prototype.listIndexes = function () { | ||
MeiliSearch.prototype.listIndexes = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1240,6 +1240,6 @@ var url; | ||
* Create a new index | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method createIndex | ||
*/ | ||
Meilisearch.prototype.createIndex = function (uid, options) { | ||
MeiliSearch.prototype.createIndex = function (uid, options) { | ||
if (options === void 0) { options = {}; } | ||
@@ -1265,6 +1265,6 @@ return __awaiter(this, void 0, void 0, function () { | ||
* Get private and public key | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getKey | ||
*/ | ||
Meilisearch.prototype.getKeys = function () { | ||
MeiliSearch.prototype.getKeys = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1287,6 +1287,6 @@ var url; | ||
* Check if the server is healhty | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method isHealthy | ||
*/ | ||
Meilisearch.prototype.isHealthy = function () { | ||
MeiliSearch.prototype.isHealthy = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1306,6 +1306,6 @@ var url; | ||
* Change the healthyness to healthy | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method setHealthy | ||
*/ | ||
Meilisearch.prototype.setHealthy = function () { | ||
MeiliSearch.prototype.setHealthy = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1327,6 +1327,6 @@ var url; | ||
* Change the healthyness to unhealthy | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method setUnhealthy | ||
*/ | ||
Meilisearch.prototype.setUnhealthy = function () { | ||
MeiliSearch.prototype.setUnhealthy = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1348,6 +1348,6 @@ var url; | ||
* Set the healthyness to health value | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method changeHealthTo | ||
*/ | ||
Meilisearch.prototype.changeHealthTo = function (health) { | ||
MeiliSearch.prototype.changeHealthTo = function (health) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1372,6 +1372,6 @@ var url; | ||
* Get the stats of all the database | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method stats | ||
*/ | ||
Meilisearch.prototype.stats = function () { | ||
MeiliSearch.prototype.stats = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1391,6 +1391,6 @@ var url; | ||
* Get the version of MeiliSearch | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method version | ||
*/ | ||
Meilisearch.prototype.version = function () { | ||
MeiliSearch.prototype.version = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1410,6 +1410,6 @@ var url; | ||
* Get the server consuption, RAM / CPU / Network | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method sysInfo | ||
*/ | ||
Meilisearch.prototype.sysInfo = function () { | ||
MeiliSearch.prototype.sysInfo = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1429,6 +1429,6 @@ var url; | ||
* Get the server consuption, RAM / CPU / Network. All information as human readable | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method prettySysInfo | ||
*/ | ||
Meilisearch.prototype.prettySysInfo = function () { | ||
MeiliSearch.prototype.prettySysInfo = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -1446,5 +1446,5 @@ var url; | ||
}; | ||
return Meilisearch; | ||
return MeiliSearch; | ||
}(MeiliAxiosWrapper)); | ||
export default Meilisearch; | ||
export default MeiliSearch; |
@@ -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="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; | ||
***************************************************************************** */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):!0===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 |
import MeiliAxiosWrapper from './meili-axios-wrapper'; | ||
import * as Types from './types'; | ||
declare class Index extends MeiliAxiosWrapper implements Types.IndexInterface { | ||
declare class Index<T> extends MeiliAxiosWrapper implements Types.IndexInterface<T> { | ||
uid: string; | ||
@@ -27,3 +27,3 @@ constructor(config: Types.Config, uid: string); | ||
*/ | ||
search<T = any>(query: string, options?: Types.SearchParams): Promise<Types.SearchResponse<T>>; | ||
search(query: string, options?: Types.SearchParams): Promise<Types.SearchResponse<T>>; | ||
/** | ||
@@ -58,3 +58,3 @@ * Show index information. | ||
*/ | ||
getDocuments(options?: Types.GetDocumentsParams): Promise<Types.Document[]>; | ||
getDocuments(options?: Types.GetDocumentsParams): Promise<Array<Types.Document<T>>>; | ||
/** | ||
@@ -65,3 +65,3 @@ * Get one document | ||
*/ | ||
getDocument(documentId: string | number): Promise<Types.Document>; | ||
getDocument(documentId: string | number): Promise<Types.Document<T>>; | ||
/** | ||
@@ -72,3 +72,3 @@ * Add or replace multiples documents to an index | ||
*/ | ||
addDocuments(documents: Types.Document[], options?: Types.AddDocumentParams): Promise<Types.EnqueuedUpdate>; | ||
addDocuments(documents: Array<Types.Document<T>>, options?: Types.AddDocumentParams): Promise<Types.EnqueuedUpdate>; | ||
/** | ||
@@ -79,3 +79,3 @@ * Add or update multiples documents to an index | ||
*/ | ||
updateDocuments(documents: Types.Document[], options?: Types.AddDocumentParams): Promise<Types.EnqueuedUpdate>; | ||
updateDocuments(documents: Array<Types.Document<T>>, options?: Types.AddDocumentParams): Promise<Types.EnqueuedUpdate>; | ||
/** | ||
@@ -82,0 +82,0 @@ * Delete one document |
import { Index } from './index'; | ||
import MeiliAxiosWrapper from './meili-axios-wrapper'; | ||
import * as Types from './types'; | ||
declare class Meilisearch extends MeiliAxiosWrapper implements Types.MeiliSearchInterface { | ||
declare class MeiliSearch extends MeiliAxiosWrapper implements Types.MeiliSearchInterface { | ||
config: Types.Config; | ||
@@ -9,15 +9,15 @@ constructor(config: Types.Config); | ||
* Return an Index instance | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getIndex | ||
*/ | ||
getIndex(indexUid: string): Index; | ||
getIndex<T = any>(indexUid: string): Index<T>; | ||
/** | ||
* Get an index or create it if it does not exist | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getOrCreateIndex | ||
*/ | ||
getOrCreateIndex(uid: string, options?: Types.IndexOptions): Promise<Index>; | ||
getOrCreateIndex<T = any>(uid: string, options?: Types.IndexOptions): Promise<Index<T>>; | ||
/** | ||
* List all indexes in the database | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method listIndexes | ||
@@ -28,9 +28,9 @@ */ | ||
* Create a new index | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method createIndex | ||
*/ | ||
createIndex(uid: string, options?: Types.IndexOptions): Promise<Index>; | ||
createIndex<T = any>(uid: string, options?: Types.IndexOptions): Promise<Index<T>>; | ||
/** | ||
* Get private and public key | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getKey | ||
@@ -41,3 +41,3 @@ */ | ||
* Check if the server is healhty | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method isHealthy | ||
@@ -48,3 +48,3 @@ */ | ||
* Change the healthyness to healthy | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method setHealthy | ||
@@ -55,3 +55,3 @@ */ | ||
* Change the healthyness to unhealthy | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method setUnhealthy | ||
@@ -62,3 +62,3 @@ */ | ||
* Set the healthyness to health value | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method changeHealthTo | ||
@@ -69,3 +69,3 @@ */ | ||
* Get the stats of all the database | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method stats | ||
@@ -76,3 +76,3 @@ */ | ||
* Get the version of MeiliSearch | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method version | ||
@@ -83,3 +83,3 @@ */ | ||
* Get the server consuption, RAM / CPU / Network | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method sysInfo | ||
@@ -90,3 +90,3 @@ */ | ||
* Get the server consuption, RAM / CPU / Network. All information as human readable | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method prettySysInfo | ||
@@ -96,3 +96,3 @@ */ | ||
} | ||
export default Meilisearch; | ||
export default MeiliSearch; | ||
//# sourceMappingURL=meilisearch.d.ts.map |
@@ -1,2 +0,2 @@ | ||
// Type definitions for meilisearch 0.11.0 | ||
// Type definitions for meilisearch 0.11.1 | ||
// Project: https://github.com/meilisearch/meilisearch-js | ||
@@ -83,5 +83,11 @@ // Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch> | ||
} | ||
export interface Document<T = any> { | ||
[attribute: string]: T; | ||
export declare type DocumentLike = { | ||
[Key in string]?: DocumentField; | ||
}; | ||
export interface DocumentArray extends Array<DocumentField> { | ||
} | ||
export declare type DocumentField = string | number | boolean | null | DocumentLike | DocumentArray; | ||
export declare type Document<T> = DocumentLike & { | ||
[key in keyof T]: T[key]; | ||
}; | ||
export interface Settings { | ||
@@ -168,6 +174,6 @@ attributesForFaceting?: string[]; | ||
config: Config; | ||
getIndex: (indexUid: string) => Index; | ||
getOrCreateIndex: (uid: string, options?: IndexOptions) => Promise<Index>; | ||
getIndex: <T>(indexUid: string) => Index<T>; | ||
getOrCreateIndex: <T>(uid: string, options?: IndexOptions) => Promise<Index<T>>; | ||
listIndexes: () => Promise<IndexResponse[]>; | ||
createIndex: (uid: string, options?: IndexOptions) => Promise<Index>; | ||
createIndex: <T>(uid: string, options?: IndexOptions) => Promise<Index<T>>; | ||
getKeys: () => Promise<Keys>; | ||
@@ -183,7 +189,7 @@ isHealthy: () => Promise<boolean>; | ||
} | ||
export interface IndexInterface extends MeiliAxiosWrapperInterface { | ||
export interface IndexInterface<T = any> extends MeiliAxiosWrapperInterface { | ||
uid: string; | ||
getUpdateStatus: (updateId: number) => Promise<Update>; | ||
getAllUpdateStatus: () => Promise<Update[]>; | ||
search: <T = any>(query: string, options?: SearchParams) => Promise<SearchResponse<T>>; | ||
search: (query: string, options?: SearchParams) => Promise<SearchResponse<T>>; | ||
show: () => Promise<IndexResponse>; | ||
@@ -193,6 +199,6 @@ updateIndex: (indexData: IndexOptions) => Promise<IndexResponse>; | ||
getStats: () => Promise<IndexStats>; | ||
getDocuments: (options?: GetDocumentsParams) => Promise<Document[]>; | ||
getDocument: (documentId: string | number) => Promise<Document>; | ||
addDocuments: (documents: Document[], options?: AddDocumentParams) => Promise<EnqueuedUpdate>; | ||
updateDocuments: (documents: Document[], options?: AddDocumentParams) => Promise<EnqueuedUpdate>; | ||
getDocuments: (options?: GetDocumentsParams) => Promise<Array<Document<T>>>; | ||
getDocument: (documentId: string | number) => Promise<Document<T>>; | ||
addDocuments: (documents: Array<Document<T>>, options?: AddDocumentParams) => Promise<EnqueuedUpdate>; | ||
updateDocuments: (documents: Array<Document<T>>, options?: AddDocumentParams) => Promise<EnqueuedUpdate>; | ||
deleteDocument: (documentId: string | number) => Promise<EnqueuedUpdate>; | ||
@@ -232,3 +238,3 @@ deleteDocuments: (documentsIds: string[] | number[]) => Promise<EnqueuedUpdate>; | ||
get: <T = any, R = AxiosResponse<T>>(url: string, 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>); | ||
post: (<T = any>(url: string, data: IndexRequest, config?: AxiosRequestConfig) => Promise<Index<T>>) & (<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>; | ||
@@ -235,0 +241,0 @@ patch: <T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: AxiosRequestConfig) => Promise<R>; |
{ | ||
"name": "meilisearch", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "The MeiliSearch JS client for Node.js and the browser.", | ||
@@ -19,5 +19,5 @@ "keywords": [ | ||
"license": "MIT", | ||
"main": "./dist/bundles/meilisearch.umd.js", | ||
"main": "./dist/bundles/meilisearch.cjs.js", | ||
"module": "./dist/bundles/meilisearch.esm.js", | ||
"browser": "./dist/bundles/meilisearch.umd.js", | ||
"browser": "./dist/bundles/meilisearch.browser.js", | ||
"typings": "./dist/types/types.d.ts", | ||
@@ -39,3 +39,3 @@ "types": "./dist/types/types.d.ts", | ||
"test:ci": "yarn test --ci", | ||
"size": "node scripts/file-size ./dist/bundles/meilisearch.umd.min.js ./dist/bundles/meilisearch.esm.min.js", | ||
"size": "node scripts/file-size ./dist/bundles/meilisearch.cjs.min.js ./dist/bundles/meilisearch.esm.min.js ./dist/bundles/meilisearch.browser.min.js", | ||
"style": "yarn format && yarn lint", | ||
@@ -82,3 +82,3 @@ "style:fix": "yarn format:fix && yarn lint:fix", | ||
"jest-watch-typeahead": "^0.5.0", | ||
"kleur": "^3.0.3", | ||
"kleur": "^4.0.0", | ||
"lint-staged": "10.2.10", | ||
@@ -85,0 +85,0 @@ "prettier": "^2.0.2", |
@@ -63,2 +63,41 @@ <p align="center"> | ||
## Import | ||
### Front end or ESmodule | ||
```javascript | ||
import MeiliSearch from 'meilisearch' | ||
const client = new MeiliSearch({ | ||
host: 'http://127.0.0.1:7700', | ||
apiKey: 'masterKey', | ||
}) | ||
``` | ||
### HTML import | ||
```javascript | ||
<script src="https://cdn.jsdelivr.net/npm/meilisearch@latest/dist/bundles/meilisearch.browser.js"></script> | ||
<script> | ||
const client = new MeiliSearch({ | ||
host: 'http://127.0.0.1:7700', | ||
apiKey: 'masterKey', | ||
}) | ||
client.listIndexes().then(res => { | ||
console.log({ res }); | ||
}) | ||
</script> | ||
``` | ||
### Back-End CommonJs | ||
```javascript | ||
const MeiliSearch = require('meilisearch'); | ||
const client = new MeiliSearch({ | ||
host: 'http://127.0.0.1:7700', | ||
apiKey: 'masterKey', | ||
}) | ||
``` | ||
## 🎬 Getting started | ||
@@ -319,3 +358,3 @@ | ||
`client.getIndex('xxx').search<T = any>(query: string, options?: SearchParams): Promise<SearchResponse<T>>` | ||
`client.getIndex<T>('xxx').search(query: string, options?: SearchParams): Promise<SearchResponse<T>>` | ||
@@ -330,11 +369,11 @@ ### Indexes <!-- omit in toc --> | ||
`client.createIndex(uid: string, options?: IndexOptions): Promise<Index>` | ||
`client.createIndex<T>(uid: string, options?: IndexOptions): Promise<Index<T>>` | ||
- Get index object: | ||
`client.getIndex(uid: string): Indexes` | ||
`client.getIndex<T>(uid: string): Index<T>` | ||
- Get or create index if it does not exist | ||
`client.getOrCreateIndex(uid: string, options?: IndexOptions): Promise<Index>` | ||
`client.getOrCreateIndex<T>(uid: string, options?: IndexOptions): Promise<Index<T>>` | ||
@@ -375,15 +414,15 @@ - Show Index information: | ||
`index.addDocuments(documents: object[]): Promise<EnqueuedUpdate>` | ||
`index.addDocuments(documents: Document<T>[]): Promise<EnqueuedUpdate>` | ||
- Add or update multiple documents: | ||
`index.updateDocuments(documents: object[]): Promise<EnqueuedUpdate>` | ||
`index.updateDocuments(documents: Document<T>[]): Promise<EnqueuedUpdate>` | ||
- Get Documents: | ||
`index.getDocuments(params: getDocumentsParams): Promise<object[]>` | ||
`index.getDocuments(params: getDocumentsParams): Promise<Document<T>[]>` | ||
- Get one document: | ||
`index.getDocument(documentId: string): Promise<object>` | ||
`index.getDocument(documentId: string): Promise<Document<T>>` | ||
@@ -390,0 +429,0 @@ - Delete one document: |
@@ -8,3 +8,3 @@ import { AxiosError } from 'axios' | ||
throw new MeiliSearchApiError(e, cachedStack) | ||
} else if (e.isAxiosError) { | ||
} else if (e.isAxiosError === true) { | ||
throw new MeiliSearchCommunicationError(e.message) | ||
@@ -11,0 +11,0 @@ } else { |
/* | ||
* Bundle: Meilisearch / Indexes | ||
* Project: Meilisearch - Javascript API | ||
* Bundle: MeiliSearch / Indexes | ||
* Project: MeiliSearch - Javascript API | ||
* Author: Quentin de Quelen <quentin@meilisearch.com> | ||
* Copyright: 2019, Meilisearch | ||
* Copyright: 2019, MeiliSearch | ||
*/ | ||
@@ -15,3 +15,3 @@ | ||
class Index extends MeiliAxiosWrapper implements Types.IndexInterface { | ||
class Index<T> extends MeiliAxiosWrapper implements Types.IndexInterface<T> { | ||
uid: string | ||
@@ -76,3 +76,3 @@ constructor(config: Types.Config, uid: string) { | ||
*/ | ||
async search<T = any>( | ||
async search( | ||
query: string, | ||
@@ -157,5 +157,3 @@ options?: Types.SearchParams | ||
*/ | ||
async updateIndex( | ||
data: Types.IndexOptions | ||
): Promise<Types.IndexResponse> { | ||
async updateIndex(data: Types.IndexOptions): Promise<Types.IndexResponse> { | ||
const url = `/indexes/${this.uid}` | ||
@@ -203,3 +201,3 @@ | ||
options?: Types.GetDocumentsParams | ||
): Promise<Types.Document[]> { | ||
): Promise<Array<Types.Document<T>>> { | ||
const url = `/indexes/${this.uid}/documents` | ||
@@ -224,3 +222,3 @@ let attr | ||
*/ | ||
async getDocument(documentId: string | number): Promise<Types.Document> { | ||
async getDocument(documentId: string | number): Promise<Types.Document<T>> { | ||
const url = `/indexes/${this.uid}/documents/${documentId}` | ||
@@ -237,3 +235,3 @@ | ||
async addDocuments( | ||
documents: Types.Document[], | ||
documents: Array<Types.Document<T>>, | ||
options?: Types.AddDocumentParams | ||
@@ -254,3 +252,3 @@ ): Promise<Types.EnqueuedUpdate> { | ||
async updateDocuments( | ||
documents: Types.Document[], | ||
documents: Array<Types.Document<T>>, | ||
options?: Types.AddDocumentParams | ||
@@ -257,0 +255,0 @@ ): Promise<Types.EnqueuedUpdate> { |
/* | ||
* Bundle: Meilisearch | ||
* Project: Meilisearch - Javascript API | ||
* Bundle: MeiliSearch | ||
* Project: MeiliSearch - Javascript API | ||
* Author: Quentin de Quelen <quentin@meilisearch.com> | ||
* Copyright: 2019, Meilisearch | ||
* Copyright: 2019, MeiliSearch | ||
*/ | ||
@@ -7,0 +7,0 @@ |
/* | ||
* Bundle: Meilisearch | ||
* Project: Meilisearch - Javascript API | ||
* Bundle: MeiliSearch | ||
* Project: MeiliSearch - Javascript API | ||
* Author: Quentin de Quelen <quentin@meilisearch.com> | ||
* Copyright: 2019, Meilisearch | ||
* Copyright: 2019, MeiliSearch | ||
*/ | ||
@@ -14,3 +14,3 @@ | ||
class Meilisearch extends MeiliAxiosWrapper | ||
class MeiliSearch extends MeiliAxiosWrapper | ||
implements Types.MeiliSearchInterface { | ||
@@ -25,7 +25,7 @@ config: Types.Config | ||
* Return an Index instance | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getIndex | ||
*/ | ||
getIndex(indexUid: string): Index { | ||
return new Index(this.config, indexUid) | ||
getIndex<T = any>(indexUid: string): Index<T> { | ||
return new Index<T>(this.config, indexUid) | ||
} | ||
@@ -35,9 +35,9 @@ | ||
* Get an index or create it if it does not exist | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getOrCreateIndex | ||
*/ | ||
async getOrCreateIndex( | ||
async getOrCreateIndex<T = any>( | ||
uid: string, | ||
options: Types.IndexOptions = {} | ||
): Promise<Index> { | ||
): Promise<Index<T>> { | ||
try { | ||
@@ -56,3 +56,3 @@ const index = await this.createIndex(uid, options) | ||
* List all indexes in the database | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method listIndexes | ||
@@ -68,9 +68,9 @@ */ | ||
* Create a new index | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method createIndex | ||
*/ | ||
async createIndex( | ||
async createIndex<T = any>( | ||
uid: string, | ||
options: Types.IndexOptions = {} | ||
): Promise<Index> { | ||
): Promise<Index<T>> { | ||
const url = '/indexes' | ||
@@ -88,3 +88,3 @@ | ||
* Get private and public key | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method getKey | ||
@@ -104,3 +104,3 @@ */ | ||
* Check if the server is healhty | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method isHealthy | ||
@@ -116,3 +116,3 @@ */ | ||
* Change the healthyness to healthy | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method setHealthy | ||
@@ -130,3 +130,3 @@ */ | ||
* Change the healthyness to unhealthy | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method setUnhealthy | ||
@@ -144,3 +144,3 @@ */ | ||
* Set the healthyness to health value | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method changeHealthTo | ||
@@ -162,3 +162,3 @@ */ | ||
* Get the stats of all the database | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method stats | ||
@@ -174,3 +174,3 @@ */ | ||
* Get the version of MeiliSearch | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method version | ||
@@ -186,3 +186,3 @@ */ | ||
* Get the server consuption, RAM / CPU / Network | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method sysInfo | ||
@@ -198,3 +198,3 @@ */ | ||
* Get the server consuption, RAM / CPU / Network. All information as human readable | ||
* @memberof Meilisearch | ||
* @memberof MeiliSearch | ||
* @method prettySysInfo | ||
@@ -209,2 +209,2 @@ */ | ||
export default Meilisearch | ||
export default MeiliSearch |
@@ -1,2 +0,2 @@ | ||
// Type definitions for meilisearch 0.10.0 | ||
// Type definitions for meilisearch | ||
// Project: https://github.com/meilisearch/meilisearch-js | ||
@@ -54,3 +54,3 @@ // Definitions by: qdequele <quentin@meilisearch.com> <https://github.com/meilisearch> | ||
export type FacetFilter = string | FacetFilter[]; | ||
export type FacetFilter = string | FacetFilter[] | ||
@@ -109,4 +109,15 @@ export interface SearchParams { | ||
export interface Document<T = any> { | ||
[attribute: string]: T | ||
export type DocumentLike = { [Key in string]?: DocumentField } | ||
export interface DocumentArray extends Array<DocumentField> {} | ||
export type DocumentField = | ||
| string | ||
| number | ||
| boolean | ||
| null | ||
| DocumentLike | ||
| DocumentArray | ||
export type Document<T> = DocumentLike & | ||
{ | ||
[key in keyof T]: T[key] | ||
} | ||
@@ -230,6 +241,9 @@ | ||
config: Config | ||
getIndex: (indexUid: string) => Index | ||
getOrCreateIndex: (uid: string, options?: IndexOptions) => Promise<Index> | ||
getIndex: <T>(indexUid: string) => Index<T> | ||
getOrCreateIndex: <T>( | ||
uid: string, | ||
options?: IndexOptions | ||
) => Promise<Index<T>> | ||
listIndexes: () => Promise<IndexResponse[]> | ||
createIndex: (uid: string, options?: IndexOptions) => Promise<Index> | ||
createIndex: <T>(uid: string, options?: IndexOptions) => Promise<Index<T>> | ||
getKeys: () => Promise<Keys> | ||
@@ -246,10 +260,7 @@ isHealthy: () => Promise<boolean> | ||
export interface IndexInterface extends MeiliAxiosWrapperInterface { | ||
export interface IndexInterface<T = any> extends MeiliAxiosWrapperInterface { | ||
uid: string | ||
getUpdateStatus: (updateId: number) => Promise<Update> | ||
getAllUpdateStatus: () => Promise<Update[]> | ||
search: <T = any>( | ||
query: string, | ||
options?: SearchParams | ||
) => Promise<SearchResponse<T>> | ||
search: (query: string, options?: SearchParams) => Promise<SearchResponse<T>> | ||
show: () => Promise<IndexResponse> | ||
@@ -259,10 +270,10 @@ updateIndex: (indexData: IndexOptions) => Promise<IndexResponse> | ||
getStats: () => Promise<IndexStats> | ||
getDocuments: (options?: GetDocumentsParams) => Promise<Document[]> | ||
getDocument: (documentId: string | number) => Promise<Document> | ||
getDocuments: (options?: GetDocumentsParams) => Promise<Array<Document<T>>> | ||
getDocument: (documentId: string | number) => Promise<Document<T>> | ||
addDocuments: ( | ||
documents: Document[], | ||
documents: Array<Document<T>>, | ||
options?: AddDocumentParams | ||
) => Promise<EnqueuedUpdate> | ||
updateDocuments: ( | ||
documents: Document[], | ||
documents: Array<Document<T>>, | ||
options?: AddDocumentParams | ||
@@ -318,7 +329,7 @@ ) => Promise<EnqueuedUpdate> | ||
) => Promise<R> | ||
post: (( | ||
post: (<T = any>( | ||
url: string, | ||
data: IndexRequest, | ||
config?: AxiosRequestConfig | ||
) => Promise<Index>) & | ||
) => Promise<Index<T>>) & | ||
(<T = any, R = AxiosResponse<EnqueuedUpdate>>( | ||
@@ -325,0 +336,0 @@ url: string, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
437949
40
7662
564