meilisearch
Advanced tools
Comparing version 0.33.0 to 0.35.0-v1.3.0-pre-release.0
@@ -1,2 +0,2 @@ | ||
import t from"crypto";var e={ALL:"all",LAST:"last"},n={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},i(t,e)};function r(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var s=function(){return s=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},s.apply(this,arguments)};function o(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 u(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 c=function(t){function e(n,i,r,s){var o,u,c,a=this;return a=t.call(this,n)||this,Object.setPrototypeOf(a,e.prototype),a.name="MeiliSearchCommunicationError",i instanceof Response&&(a.message=i.statusText,a.statusCode=i.status),i instanceof Error&&(a.errno=i.errno,a.code=i.code),s?(a.stack=s,a.stack=null===(o=a.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,a.name),a.stack=null===(u=a.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(r," failed, reason: connect ECONNREFUSED")),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Not Found","Not Found: ".concat(r))):Error.captureStackTrace&&Error.captureStackTrace(a,e),a}return r(e,t),e}(Error),a=function(t){function e(e,n){var i=t.call(this,e.message)||this;return Object.setPrototypeOf(i,a.prototype),i.name="MeiliSearchApiError",i.code=e.code,i.type=e.type,i.link=e.link,i.message=e.message,i.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(i,a),i}return r(e,t),e}(Error);function h(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new c(t.statusText,t,t.url);case 4:throw new a(e,t.status);case 5:return[2,t]}}))}))}function d(t,e,n){if("MeiliSearchApiError"!==t.name)throw new c(t.message,t,n,e);throw t}var l=function(t){function e(n){var i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return r(e,t),e}(Error),f=function(t){function e(n){var i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return r(e,t),e}(Error);function p(t,e){return"".concat(t,"\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ").concat(e," call requires.")}function v(t){return Object.entries(t).reduce((function(t,e){var n=e[0],i=e[1];return void 0!==i&&(t[n]=i),t}),{})}function y(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}function w(t){return Object.keys(t).reduce((function(e,n){var i,r,o,u=t[n];return void 0===u?e:Array.isArray(u)?s(s({},e),((i={})[n]=u.join(","),i)):u instanceof Date?s(s({},e),((r={})[n]=u.toISOString(),r)):s(s({},e),((o={})[n]=u,o))}),{})}function b(t){var e,n,i="X-Meilisearch-Client",r="Meilisearch JavaScript (v".concat("0.33.0",")"),s=function(t){if(Array.isArray(t))return t.reduce((function(t,e){return t[e[0]]=e[1],t}),{});if("has"in t){var e={};return t.forEach((function(t,n){return e[n]=t})),e}return Object.assign({},t)}(null!==(n=null===(e=t.requestConfig)||void 0===e?void 0:e.headers)&&void 0!==n?n:{});if(t.apiKey&&!s.Authorization&&(s.Authorization="Bearer ".concat(t.apiKey)),s["Content-Type"]||(s["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var o=t.clientAgents.concat(r);s[i]=o.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new l('Meilisearch: The header "'.concat(i,'" should be an array of string(s).\n'));s[i]=r}return s}var g=function(){function t(t){this.headers=b(t),this.requestConfig=t.requestConfig,this.httpClient=t.httpClient;try{var e=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new l("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new l("The provided host is not valid.")}}return t.prototype.request=function(t){var e,n=t.method,i=t.url,r=t.params,c=t.body,a=t.config,l=void 0===a?{}:a;return o(this,void 0,void 0,(function(){var t,o,a,f,p,v,y;return u(this,(function(u){switch(u.label){case 0:"undefined"==typeof fetch&&require("cross-fetch/polyfill"),t=new URL(i,this.url),r&&(o=new URLSearchParams,Object.keys(r).filter((function(t){return null!==r[t]})).map((function(t){return o.set(t,r[t])})),t.search=o.toString()),(null===(e=l.headers)||void 0===e?void 0:e["Content-Type"])||(c=JSON.stringify(c)),a=s(s({},this.headers),l.headers),u.label=1;case 1:return u.trys.push([1,6,,7]),f=this.httpClient?this.httpClient:fetch,p=f(t.toString(),s(s(s({},l),this.requestConfig),{method:n,body:c,headers:a})),this.httpClient?[4,p]:[3,3];case 2:return[2,u.sent()];case 3:return[4,p.then((function(t){return h(t)}))];case 4:return[4,u.sent().json().catch((function(){}))];case 5:return[2,u.sent()];case 6:return v=u.sent(),y=v.stack,d(v,y,t.toString()),[3,7];case 7:return[2]}}))}))},t.prototype.get=function(t,e,n){return o(this,void 0,void 0,(function(){return u(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,i.sent()]}}))}))},t.prototype.post=function(t,e,n,i){return o(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.put=function(t,e,n,i){return o(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.patch=function(t,e,n,i){return o(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.delete=function(t,e,n,i){return o(this,void 0,void 0,(function(){return u(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t}(),q=function(t){this.taskUid=t.taskUid,this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.enqueuedAt=new Date(t.enqueuedAt)},m=function(t){this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.uid=t.uid,this.details=t.details,this.canceledBy=t.canceledBy,this.error=t.error,this.duration=t.duration,this.startedAt=new Date(t.startedAt),this.enqueuedAt=new Date(t.enqueuedAt),this.finishedAt=new Date(t.finishedAt)},k=function(){function t(t){this.httpRequest=new g(t)}return t.prototype.getTask=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return n=i.sent(),[2,new m(n)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return"tasks",[4,this.httpRequest.get("tasks",w(t))];case 1:return e=n.sent(),[2,s(s({},e),{results:e.results.map((function(t){return new m(t)}))})]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,r=void 0===i?5e3:i,s=n.intervalMs,c=void 0===s?50:s;return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:e=Date.now(),i.label=1;case 1:return Date.now()-e<r?[4,this.getTask(t)]:[3,4];case 2:return n=i.sent(),["enqueued","processing"].includes(n.status)?[4,y(c)]:[2,n];case 3:return i.sent(),[3,1];case 4:throw new f("timeout of ".concat(r,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,r=void 0===i?5e3:i,s=n.intervalMs,c=void 0===s?50:s;return o(this,void 0,void 0,(function(){var e,n,i,s,o;return u(this,(function(u){switch(u.label){case 0:e=[],n=0,i=t,u.label=1;case 1:return n<i.length?(s=i[n],[4,this.waitForTask(s,{timeOutMs:r,intervalMs:c})]):[3,4];case 2:o=u.sent(),e.push(o),u.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},t.prototype.cancelTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return"tasks/cancel",[4,this.httpRequest.post("tasks/cancel",{},w(t))];case 1:return e=n.sent(),[2,new q(e)]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return"tasks",[4,this.httpRequest.delete("tasks",{},w(t))];case 1:return e=n.sent(),[2,new q(e)]}}))}))},t}(),A=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new g(t),this.tasks=new k(t)}return t.prototype.search=function(t,e,n){return o(this,void 0,void 0,(function(){var i;return u(this,(function(r){switch(r.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,v(s({q:t},e)),void 0,n)];case 1:return[2,r.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var i,r,c,a,h;return o(this,void 0,void 0,(function(){var o,d,f;return u(this,(function(u){switch(u.label){case 0:return o="indexes/".concat(this.uid,"/search"),d=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new l("The filter query parameter should be in string format when using searchGet")},f=s(s({q:t},e),{filter:d(null==e?void 0:e.filter),sort:null===(i=null==e?void 0:e.sort)||void 0===i?void 0:i.join(","),facets:null===(r=null==e?void 0:e.facets)||void 0===r?void 0:r.join(","),attributesToRetrieve:null===(c=null==e?void 0:e.attributesToRetrieve)||void 0===c?void 0:c.join(","),attributesToCrop:null===(a=null==e?void 0:e.attributesToCrop)||void 0===a?void 0:a.join(","),attributesToHighlight:null===(h=null==e?void 0:e.attributesToHighlight)||void 0===h?void 0:h.join(",")}),[4,this.httpRequest.get(o,v(f),n)];case 1:return[2,u.sent()]}}))}))},t.prototype.getRawInfo=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return o(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),o(this,void 0,void 0,(function(){var i;return u(this,(function(r){switch(r.label){case 0:return"indexes",[4,new g(n).post("indexes",s(s({},e),{uid:t}))];case 1:return i=r.sent(),[2,new q(i)]}}))}))},t.prototype.update=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return(n=i.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.delete=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new q(e)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(s(s({},t),{indexUids:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,r=void 0===i?5e3:i,s=n.intervalMs,c=void 0===s?50:s;return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:r,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,r=void 0===i?5e3:i,s=n.intervalMs,c=void 0===s?50:s;return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:r,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){var e;return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var n,i,r;return u(this,(function(o){switch(o.label){case 0:if(void 0===(t=v(t)).filter)return[3,5];o.label=1;case 1:return o.trys.push([1,3,,4]),i="indexes/".concat(this.uid,"/documents/fetch"),[4,this.httpRequest.post(i,t)];case 2:return[2,o.sent()];case 3:throw((n=o.sent())instanceof c||n instanceof a)&&(n.message=p(n.message,"getDocuments")),n;case 4:return[3,7];case 5:return i="indexes/".concat(this.uid,"/documents"),r=Array.isArray(null==t?void 0:t.fields)?{fields:null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}:{},[4,this.httpRequest.get(i,s(s({},t),r))];case 6:return[2,o.sent()];case 7:return[2]}}))}))},t.prototype.getDocument=function(t,e){return o(this,void 0,void 0,(function(){var n,i;return u(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents/").concat(t),i=function(){var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")}(),[4,this.httpRequest.get(n,v(s(s({},e),{fields:i})))];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return o(this,void 0,void 0,(function(){var n,i;return u(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return i=r.sent(),[2,new q(i)]}}))}))},t.prototype.addDocumentsFromString=function(t,e,n){return o(this,void 0,void 0,(function(){var i,r;return u(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(i,t,n,{headers:{"Content-Type":e}})];case 1:return r=s.sent(),[2,new q(r)]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),o(this,void 0,void 0,(function(){var i,r,s,o;return u(this,(function(u){switch(u.label){case 0:i=[],r=0,u.label=1;case 1:return r<t.length?(o=(s=i).push,[4,this.addDocuments(t.slice(r,r+e),n)]):[3,4];case 2:o.apply(s,[u.sent()]),u.label=3;case 3:return r+=e,[3,1];case 4:return[2,i]}}))}))},t.prototype.updateDocuments=function(t,e){return o(this,void 0,void 0,(function(){var n,i;return u(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return i=r.sent(),[2,new q(i)]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),o(this,void 0,void 0,(function(){var i,r,s,o;return u(this,(function(u){switch(u.label){case 0:i=[],r=0,u.label=1;case 1:return r<t.length?(o=(s=i).push,[4,this.updateDocuments(t.slice(r,r+e),n)]):[3,4];case 2:o.apply(s,[u.sent()]),u.label=3;case 3:return r+=e,[3,1];case 4:return[2,i]}}))}))},t.prototype.updateDocumentsFromString=function(t,e,n){return o(this,void 0,void 0,(function(){var i,r;return u(this,(function(s){switch(s.label){case 0:return i="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(i,t,n,{headers:{"Content-Type":e}})];case 1:return r=s.sent(),[2,new q(r)]}}))}))},t.prototype.deleteDocument=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return(n=i.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.deleteDocuments=function(t){return o(this,void 0,void 0,(function(){var e,n,i,r,s;return u(this,(function(o){switch(o.label){case 0:e=!Array.isArray(t)&&"object"==typeof t,n=e?"documents/delete":"documents/delete-batch",i="indexes/".concat(this.uid,"/").concat(n),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.httpRequest.post(i,t)];case 2:return r=o.sent(),[2,new q(r)];case 3:throw((s=o.sent())instanceof c&&e||s instanceof a)&&(s.message=p(s.message,"deleteDocuments")),s;case 4:return[2]}}))}))},t.prototype.deleteAllDocuments=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSettings=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return(n=i.sent()).enqueued=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.resetSettings=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getPagination=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updatePagination=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.patch(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetPagination=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new q(e)]}}))}))},t.prototype.getSynonyms=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetSynonyms=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getStopWords=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetStopWords=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getRankingRules=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetRankingRules=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getDistinctAttribute=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetDistinctAttribute=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getFilterableAttributes=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetFilterableAttributes=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSortableAttributes=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetSortableAttributes=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSearchableAttributes=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetSearchableAttributes=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getDisplayedAttributes=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetDisplayedAttributes=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getTypoTolerance=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.patch(e,t)];case 1:return(n=i.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.resetTypoTolerance=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getFaceting=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFaceting=function(t){return o(this,void 0,void 0,(function(){var e,n;return u(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.patch(e,t)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.resetFaceting=function(){return o(this,void 0,void 0,(function(){var t,e;return u(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new q(e)]}}))}))},t}(),x=function(){function t(t){this.config=t,this.httpRequest=new g(t),this.tasks=new k(t)}return t.prototype.index=function(t){return new A(this.config,t)},t.prototype.getIndex=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){return[2,new A(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){return[2,new A(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e,n,i=this;return u(this,(function(r){switch(r.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=r.sent(),n=e.results.map((function(t){return new A(i.config,t.uid,t.primaryKey)})),[2,s(s({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return"indexes",[4,this.httpRequest.get("indexes",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),o(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,A.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),o(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return[4,new A(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,new A(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.swapIndexes=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return"/swap-indexes",[4,this.httpRequest.post("/swap-indexes",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.multiSearch=function(t,e){return o(this,void 0,void 0,(function(){return u(this,(function(n){switch(n.label){case 0:return"multi-search",[4,this.httpRequest.post("multi-search",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,r=void 0===i?5e3:i,s=n.intervalMs,c=void 0===s?50:s;return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:r,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,r=void 0===i?5e3:i,s=n.intervalMs,c=void 0===s?50:s;return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:r,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.cancelTasks=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.cancelTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return[4,this.tasks.deleteTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return"keys",[4,this.httpRequest.get("keys",t)];case 1:return(e=n.sent()).results=e.results.map((function(t){return s(s({},t),{createdAt:new Date(t.createdAt),updateAt:new Date(t.updateAt)})})),[2,e]}}))}))},t.prototype.getKey=function(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return o(this,void 0,void 0,(function(){return u(this,(function(e){switch(e.label){case 0:return"keys",[4,this.httpRequest.post("keys",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateKey=function(t,e){return o(this,void 0,void 0,(function(){var n;return u(this,(function(i){switch(i.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.deleteKey=function(t){return o(this,void 0,void 0,(function(){var e;return u(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return o(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return"health",[4,this.httpRequest.get("health")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return o(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return o(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return"stats",[4,this.httpRequest.get("stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.getVersion=function(){return o(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return"version",[4,this.httpRequest.get("version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return o(this,void 0,void 0,(function(){var t;return u(this,(function(e){switch(e.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return t=e.sent(),[2,new q(t)]}}))}))},t.prototype.generateTenantToken=function(t,e,n){var i=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(i.stack,"."))},t}();function R(t){return Buffer.from(JSON.stringify(t)).toString("base64")}var T=function(){function e(t){this.config=t}return e.prototype.generateTenantToken=function(e,n,i){var r=(null==i?void 0:i.apiKey)||this.config.apiKey||"",s=e||"",o=null==i?void 0:i.expiresAt;!function(t){var e=t.searchRules,n=t.uid,i=t.apiKey,r=t.expiresAt;if(r){if(!(r instanceof Date))throw new l("Meilisearch: The expiredAt field must be an instance of Date.");if(r.getTime()<Date.now())throw new l("Meilisearch: The expiresAt field must be a date in the future.")}if(e&&"object"!=typeof e&&!Array.isArray(e))throw new l("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!i||"string"!=typeof i)throw new l("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!n||"string"!=typeof n)throw new l("Meilisearch: The uid of the api key used for the token generation must exist, be of type string and comply to the uuid4 format.");if(!/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(n))throw new l("Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().")}({apiKey:r,uid:s,expiresAt:o,searchRules:n});var u=R({alg:"HS256",typ:"JWT"}).replace(/=/g,""),c=function(t){var e=t.searchRules,n=t.uid,i=t.expiresAt;return R({searchRules:e,apiKeyUid:n,exp:i?Math.floor(i.getTime()/1e3):void 0}).replace(/=/g,"")}({searchRules:n,uid:s,expiresAt:o}),a=function(e,n,i){return t.createHmac("sha256",e).update("".concat(n,".").concat(i)).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(r,u,c);return"".concat(u,".").concat(c,".").concat(a)},e}(),D=function(t){function e(e){var n=t.call(this,e)||this;return n.tokens=new T(e),n}return r(e,t),e.prototype.generateTenantToken=function(e,n,i){return"undefined"==typeof window?this.tokens.generateTenantToken(e,n,i):t.prototype.generateTenantToken.call(this,e,n,i)},e}(x);export{n as ContentTypeEnum,q as EnqueuedTask,A as Index,e as MatchingStrategies,D as MeiliSearch,a as MeiliSearchApiError,c as MeiliSearchCommunicationError,l as MeiliSearchError,f as MeiliSearchTimeOutError,m as Task,k as TaskClient,D as default,d as httpErrorHandler,h as httpResponseErrorHandler,p as versionErrorHintMessage}; | ||
import t from"crypto";const e={ALL:"all",LAST:"last"},i={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"};function s(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{d(s.next(t))}catch(t){r(t)}}function u(t){try{d(s.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,u)}d((s=s.apply(t,e||[])).next())}))}class n extends Error{constructor(t,e,i,s){var r,o,u;super(t),Object.setPrototypeOf(this,n.prototype),this.name="MeiliSearchCommunicationError",e instanceof Response&&(this.message=e.statusText,this.statusCode=e.status),e instanceof Error&&(this.errno=e.errno,this.code=e.code),s?(this.stack=s,this.stack=null===(r=this.stack)||void 0===r?void 0:r.replace(/(TypeError|FetchError)/,this.name),this.stack=null===(o=this.stack)||void 0===o?void 0:o.replace("Failed to fetch",`request to ${i} failed, reason: connect ECONNREFUSED`),this.stack=null===(u=this.stack)||void 0===u?void 0:u.replace("Not Found",`Not Found: ${i}`)):Error.captureStackTrace&&Error.captureStackTrace(this,n)}}const r=class extends Error{constructor(t,e){super(t.message),Object.setPrototypeOf(this,r.prototype),this.name="MeiliSearchApiError",this.code=t.code,this.type=t.type,this.link=t.link,this.message=t.message,this.httpStatus=e,Error.captureStackTrace&&Error.captureStackTrace(this,r)}};function o(t){return s(this,void 0,void 0,(function*(){if(!t.ok){let e;try{e=yield t.json()}catch(e){throw new n(t.statusText,t,t.url)}throw new r(e,t.status)}return t}))}function u(t,e,i){if("MeiliSearchApiError"!==t.name)throw new n(t.message,t,i,e);throw t}class d extends Error{constructor(t){super(t),Object.setPrototypeOf(this,d.prototype),this.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(this,d)}}class a extends Error{constructor(t){super(t),Object.setPrototypeOf(this,a.prototype),this.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(this,a)}}function h(t,e){return`${t}\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ${e} call requires.`}function c(t){return Object.entries(t).reduce(((t,e)=>{const[i,s]=e;return void 0!==s&&(t[i]=s),t}),{})}function l(t){return s(this,void 0,void 0,(function*(){return yield new Promise((e=>setTimeout(e,t)))}))}function v(t){return Object.keys(t).reduce(((e,i)=>{const s=t[i];return void 0===s?e:Array.isArray(s)?Object.assign(Object.assign({},e),{[i]:s.join(",")}):s instanceof Date?Object.assign(Object.assign({},e),{[i]:s.toISOString()}):Object.assign(Object.assign({},e),{[i]:s})}),{})}function p(t){var e,i;const s="X-Meilisearch-Client",n="Meilisearch JavaScript (v0.35.0-v1.3.0-pre-release.0)",r=function(t){if(Array.isArray(t))return t.reduce(((t,e)=>(t[e[0]]=e[1],t)),{});if("has"in t){const e={};return t.forEach(((t,i)=>e[i]=t)),e}return Object.assign({},t)}(null!==(i=null===(e=t.requestConfig)||void 0===e?void 0:e.headers)&&void 0!==i?i:{});if(t.apiKey&&!r.Authorization&&(r.Authorization=`Bearer ${t.apiKey}`),r["Content-Type"]||(r["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){const e=t.clientAgents.concat(n);r[s]=e.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new d(`Meilisearch: The header "${s}" should be an array of string(s).\n`);r[s]=n}return r}class f{constructor(t){this.headers=p(t),this.requestConfig=t.requestConfig,this.httpClient=t.httpClient;try{const e=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:`http://${t}`}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new d("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new d("The provided host is not valid.")}}request({method:t,url:e,params:i,body:n,config:r={}}){var d;return s(this,void 0,void 0,(function*(){"undefined"==typeof fetch&&require("cross-fetch/polyfill");const s=new URL(e,this.url);if(i){const t=new URLSearchParams;Object.keys(i).filter((t=>null!==i[t])).map((e=>t.set(e,i[e]))),s.search=t.toString()}(null===(d=r.headers)||void 0===d?void 0:d["Content-Type"])||(n=JSON.stringify(n));const a=Object.assign(Object.assign({},this.headers),r.headers);try{const e=(this.httpClient?this.httpClient:fetch)(s.toString(),Object.assign(Object.assign(Object.assign({},r),this.requestConfig),{method:t,body:n,headers:a}));if(this.httpClient)return yield e;const i=yield e.then((t=>o(t)));return yield i.json().catch((()=>{}))}catch(t){u(t,t.stack,s.toString())}}))}get(t,e,i){return s(this,void 0,void 0,(function*(){return yield this.request({method:"GET",url:t,params:e,config:i})}))}post(t,e,i,n){return s(this,void 0,void 0,(function*(){return yield this.request({method:"POST",url:t,body:e,params:i,config:n})}))}put(t,e,i,n){return s(this,void 0,void 0,(function*(){return yield this.request({method:"PUT",url:t,body:e,params:i,config:n})}))}patch(t,e,i,n){return s(this,void 0,void 0,(function*(){return yield this.request({method:"PATCH",url:t,body:e,params:i,config:n})}))}delete(t,e,i,n){return s(this,void 0,void 0,(function*(){return yield this.request({method:"DELETE",url:t,body:e,params:i,config:n})}))}}class y{constructor(t){this.taskUid=t.taskUid,this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.enqueuedAt=new Date(t.enqueuedAt)}}class g{constructor(t){this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.uid=t.uid,this.details=t.details,this.canceledBy=t.canceledBy,this.error=t.error,this.duration=t.duration,this.startedAt=new Date(t.startedAt),this.enqueuedAt=new Date(t.enqueuedAt),this.finishedAt=new Date(t.finishedAt)}}class w{constructor(t){this.httpRequest=new f(t)}getTask(t){return s(this,void 0,void 0,(function*(){const e=`tasks/${t}`,i=yield this.httpRequest.get(e);return new g(i)}))}getTasks(t={}){return s(this,void 0,void 0,(function*(){const e=yield this.httpRequest.get("tasks",v(t));return Object.assign(Object.assign({},e),{results:e.results.map((t=>new g(t)))})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return s(this,void 0,void 0,(function*(){const s=Date.now();for(;Date.now()-s<e;){const e=yield this.getTask(t);if(!["enqueued","processing"].includes(e.status))return e;yield l(i)}throw new a(`timeout of ${e}ms has exceeded on process ${t} when waiting a task to be resolved.`)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return s(this,void 0,void 0,(function*(){const s=[];for(const n of t){const t=yield this.waitForTask(n,{timeOutMs:e,intervalMs:i});s.push(t)}return s}))}cancelTasks(t={}){return s(this,void 0,void 0,(function*(){const e=yield this.httpRequest.post("tasks/cancel",{},v(t));return new y(e)}))}deleteTasks(t={}){return s(this,void 0,void 0,(function*(){const e=yield this.httpRequest.delete("tasks",{},v(t));return new y(e)}))}}class q{constructor(t,e,i){this.uid=e,this.primaryKey=i,this.httpRequest=new f(t),this.tasks=new w(t)}search(t,e,i){return s(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/search`;return yield this.httpRequest.post(s,c(Object.assign({q:t},e)),void 0,i)}))}searchGet(t,e,i){var n,r,o,u,a,h,l;return s(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/search`,v=Object.assign(Object.assign({q:t},e),{filter:(t=>{if("string"==typeof t)return t;if(Array.isArray(t))throw new d("The filter query parameter should be in string format when using searchGet")})(null==e?void 0:e.filter),sort:null===(n=null==e?void 0:e.sort)||void 0===n?void 0:n.join(","),facets:null===(r=null==e?void 0:e.facets)||void 0===r?void 0:r.join(","),attributesToRetrieve:null===(o=null==e?void 0:e.attributesToRetrieve)||void 0===o?void 0:o.join(","),attributesToCrop:null===(u=null==e?void 0:e.attributesToCrop)||void 0===u?void 0:u.join(","),attributesToHighlight:null===(a=null==e?void 0:e.attributesToHighlight)||void 0===a?void 0:a.join(","),vector:null===(h=null==e?void 0:e.vector)||void 0===h?void 0:h.join(","),attributesToSearchOn:null===(l=null==e?void 0:e.attributesToSearchOn)||void 0===l?void 0:l.join(",")});return yield this.httpRequest.get(s,c(v),i)}))}searchForFacetValues(t,e){return s(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/facet-search`;return yield this.httpRequest.post(i,c(t),void 0,e)}))}getRawInfo(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}`,e=yield this.httpRequest.get(t);return this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),e}))}fetchInfo(){return s(this,void 0,void 0,(function*(){return yield this.getRawInfo(),this}))}fetchPrimaryKey(){return s(this,void 0,void 0,(function*(){return this.primaryKey=(yield this.getRawInfo()).primaryKey,this.primaryKey}))}static create(t,e={},i){return s(this,void 0,void 0,(function*(){const s=new f(i),n=yield s.post("indexes",Object.assign(Object.assign({},e),{uid:t}));return new y(n)}))}update(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}`,i=yield this.httpRequest.patch(e,t);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}delete(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}`,e=yield this.httpRequest.delete(t);return new y(e)}))}getTasks(t={}){return s(this,void 0,void 0,(function*(){return yield this.tasks.getTasks(Object.assign(Object.assign({},t),{indexUids:[this.uid]}))}))}getTask(t){return s(this,void 0,void 0,(function*(){return yield this.tasks.getTask(t)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return s(this,void 0,void 0,(function*(){return yield this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:i})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return s(this,void 0,void 0,(function*(){return yield this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:i})}))}getStats(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/stats`;return yield this.httpRequest.get(t)}))}getDocuments(t={}){var e;return s(this,void 0,void 0,(function*(){if(void 0===(t=c(t)).filter){const i=`indexes/${this.uid}/documents`,s=Array.isArray(null==t?void 0:t.fields)?{fields:null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}:{};return yield this.httpRequest.get(i,Object.assign(Object.assign({},t),s))}try{const e=`indexes/${this.uid}/documents/fetch`;return yield this.httpRequest.post(e,t)}catch(t){throw(t instanceof n||t instanceof r)&&(t.message=h(t.message,"getDocuments")),t}}))}getDocument(t,e){return s(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents/${t}`,s=(()=>{var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")})();return yield this.httpRequest.get(i,c(Object.assign(Object.assign({},e),{fields:s})))}))}addDocuments(t,e){return s(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents`,s=yield this.httpRequest.post(i,t,e);return new y(s)}))}addDocumentsFromString(t,e,i){return s(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/documents`,n=yield this.httpRequest.post(s,t,i,{headers:{"Content-Type":e}});return new y(n)}))}addDocumentsInBatches(t,e=1e3,i){return s(this,void 0,void 0,(function*(){const s=[];for(let n=0;n<t.length;n+=e)s.push(yield this.addDocuments(t.slice(n,n+e),i));return s}))}updateDocuments(t,e){return s(this,void 0,void 0,(function*(){const i=`indexes/${this.uid}/documents`,s=yield this.httpRequest.put(i,t,e);return new y(s)}))}updateDocumentsInBatches(t,e=1e3,i){return s(this,void 0,void 0,(function*(){const s=[];for(let n=0;n<t.length;n+=e)s.push(yield this.updateDocuments(t.slice(n,n+e),i));return s}))}updateDocumentsFromString(t,e,i){return s(this,void 0,void 0,(function*(){const s=`indexes/${this.uid}/documents`,n=yield this.httpRequest.put(s,t,i,{headers:{"Content-Type":e}});return new y(n)}))}deleteDocument(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/documents/${t}`,i=yield this.httpRequest.delete(e);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}deleteDocuments(t){return s(this,void 0,void 0,(function*(){const e=!Array.isArray(t)&&"object"==typeof t,i=e?"documents/delete":"documents/delete-batch",s=`indexes/${this.uid}/${i}`;try{const e=yield this.httpRequest.post(s,t);return new y(e)}catch(t){throw(t instanceof n&&e||t instanceof r)&&(t.message=h(t.message,"deleteDocuments")),t}}))}deleteAllDocuments(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/documents`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSettings(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings`;return yield this.httpRequest.get(t)}))}updateSettings(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings`,i=yield this.httpRequest.patch(e,t);return i.enqueued=new Date(i.enqueuedAt),i}))}resetSettings(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getPagination(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/pagination`;return yield this.httpRequest.get(t)}))}updatePagination(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/pagination`,i=yield this.httpRequest.patch(e,t);return new y(i)}))}resetPagination(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/pagination`,e=yield this.httpRequest.delete(t);return new y(e)}))}getSynonyms(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/synonyms`;return yield this.httpRequest.get(t)}))}updateSynonyms(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/synonyms`,i=yield this.httpRequest.put(e,t);return new y(i)}))}resetSynonyms(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/synonyms`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getStopWords(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/stop-words`;return yield this.httpRequest.get(t)}))}updateStopWords(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/stop-words`,i=yield this.httpRequest.put(e,t);return new y(i)}))}resetStopWords(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/stop-words`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getRankingRules(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/ranking-rules`;return yield this.httpRequest.get(t)}))}updateRankingRules(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/ranking-rules`,i=yield this.httpRequest.put(e,t);return new y(i)}))}resetRankingRules(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/ranking-rules`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getDistinctAttribute(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/distinct-attribute`;return yield this.httpRequest.get(t)}))}updateDistinctAttribute(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/distinct-attribute`,i=yield this.httpRequest.put(e,t);return new y(i)}))}resetDistinctAttribute(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/distinct-attribute`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getFilterableAttributes(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/filterable-attributes`;return yield this.httpRequest.get(t)}))}updateFilterableAttributes(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/filterable-attributes`,i=yield this.httpRequest.put(e,t);return new y(i)}))}resetFilterableAttributes(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/filterable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSortableAttributes(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/sortable-attributes`;return yield this.httpRequest.get(t)}))}updateSortableAttributes(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/sortable-attributes`,i=yield this.httpRequest.put(e,t);return new y(i)}))}resetSortableAttributes(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/sortable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getSearchableAttributes(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/searchable-attributes`;return yield this.httpRequest.get(t)}))}updateSearchableAttributes(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/searchable-attributes`,i=yield this.httpRequest.put(e,t);return new y(i)}))}resetSearchableAttributes(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/searchable-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getDisplayedAttributes(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/displayed-attributes`;return yield this.httpRequest.get(t)}))}updateDisplayedAttributes(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/displayed-attributes`,i=yield this.httpRequest.put(e,t);return new y(i)}))}resetDisplayedAttributes(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/displayed-attributes`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getTypoTolerance(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/typo-tolerance`;return yield this.httpRequest.get(t)}))}updateTypoTolerance(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/typo-tolerance`,i=yield this.httpRequest.patch(e,t);return i.enqueuedAt=new Date(i.enqueuedAt),i}))}resetTypoTolerance(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/typo-tolerance`,e=yield this.httpRequest.delete(t);return e.enqueuedAt=new Date(e.enqueuedAt),e}))}getFaceting(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/faceting`;return yield this.httpRequest.get(t)}))}updateFaceting(t){return s(this,void 0,void 0,(function*(){const e=`indexes/${this.uid}/settings/faceting`,i=yield this.httpRequest.patch(e,t);return new y(i)}))}resetFaceting(){return s(this,void 0,void 0,(function*(){const t=`indexes/${this.uid}/settings/faceting`,e=yield this.httpRequest.delete(t);return new y(e)}))}}function b(t){return Buffer.from(JSON.stringify(t)).toString("base64")}class m{constructor(t){this.config=t}generateTenantToken(e,i,s){const n=(null==s?void 0:s.apiKey)||this.config.apiKey||"",r=e||"",o=null==s?void 0:s.expiresAt;!function(t){const{searchRules:e,uid:i,apiKey:s,expiresAt:n}=t;if(n){if(!(n instanceof Date))throw new d("Meilisearch: The expiredAt field must be an instance of Date.");if(n.getTime()<Date.now())throw new d("Meilisearch: The expiresAt field must be a date in the future.")}if(e&&"object"!=typeof e&&!Array.isArray(e))throw new d("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!s||"string"!=typeof s)throw new d("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!i||"string"!=typeof i)throw new d("Meilisearch: The uid of the api key used for the token generation must exist, be of type string and comply to the uuid4 format.");if(!/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi.test(i))throw new d("Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().")}({apiKey:n,uid:r,expiresAt:o,searchRules:i});const u=b({alg:"HS256",typ:"JWT"}).replace(/=/g,""),a=function(t){const{searchRules:e,uid:i,expiresAt:s}=t;return b({searchRules:e,apiKeyUid:i,exp:s?Math.floor(s.getTime()/1e3):void 0}).replace(/=/g,"")}({searchRules:i,uid:r,expiresAt:o}),h=function(e,i,s){return t.createHmac("sha256",e).update(`${i}.${s}`).digest("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}(n,u,a);return`${u}.${a}.${h}`}}class A extends class{constructor(t){this.config=t,this.httpRequest=new f(t),this.tasks=new w(t)}index(t){return new q(this.config,t)}getIndex(t){return s(this,void 0,void 0,(function*(){return new q(this.config,t).fetchInfo()}))}getRawIndex(t){return s(this,void 0,void 0,(function*(){return new q(this.config,t).getRawInfo()}))}getIndexes(t={}){return s(this,void 0,void 0,(function*(){const e=yield this.getRawIndexes(t),i=e.results.map((t=>new q(this.config,t.uid,t.primaryKey)));return Object.assign(Object.assign({},e),{results:i})}))}getRawIndexes(t={}){return s(this,void 0,void 0,(function*(){return yield this.httpRequest.get("indexes",t)}))}createIndex(t,e={}){return s(this,void 0,void 0,(function*(){return yield q.create(t,e,this.config)}))}updateIndex(t,e={}){return s(this,void 0,void 0,(function*(){return yield new q(this.config,t).update(e)}))}deleteIndex(t){return s(this,void 0,void 0,(function*(){return yield new q(this.config,t).delete()}))}deleteIndexIfExists(t){return s(this,void 0,void 0,(function*(){try{return yield this.deleteIndex(t),!0}catch(t){if("index_not_found"===t.code)return!1;throw t}}))}swapIndexes(t){return s(this,void 0,void 0,(function*(){return yield this.httpRequest.post("/swap-indexes",t)}))}multiSearch(t,e){return s(this,void 0,void 0,(function*(){return yield this.httpRequest.post("multi-search",t,void 0,e)}))}getTasks(t={}){return s(this,void 0,void 0,(function*(){return yield this.tasks.getTasks(t)}))}getTask(t){return s(this,void 0,void 0,(function*(){return yield this.tasks.getTask(t)}))}waitForTasks(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return s(this,void 0,void 0,(function*(){return yield this.tasks.waitForTasks(t,{timeOutMs:e,intervalMs:i})}))}waitForTask(t,{timeOutMs:e=5e3,intervalMs:i=50}={}){return s(this,void 0,void 0,(function*(){return yield this.tasks.waitForTask(t,{timeOutMs:e,intervalMs:i})}))}cancelTasks(t){return s(this,void 0,void 0,(function*(){return yield this.tasks.cancelTasks(t)}))}deleteTasks(t={}){return s(this,void 0,void 0,(function*(){return yield this.tasks.deleteTasks(t)}))}getKeys(t={}){return s(this,void 0,void 0,(function*(){const e=yield this.httpRequest.get("keys",t);return e.results=e.results.map((t=>Object.assign(Object.assign({},t),{createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)}))),e}))}getKey(t){return s(this,void 0,void 0,(function*(){const e=`keys/${t}`;return yield this.httpRequest.get(e)}))}createKey(t){return s(this,void 0,void 0,(function*(){return yield this.httpRequest.post("keys",t)}))}updateKey(t,e){return s(this,void 0,void 0,(function*(){const i=`keys/${t}`;return yield this.httpRequest.patch(i,e)}))}deleteKey(t){return s(this,void 0,void 0,(function*(){const e=`keys/${t}`;return yield this.httpRequest.delete(e)}))}health(){return s(this,void 0,void 0,(function*(){return yield this.httpRequest.get("health")}))}isHealthy(){return s(this,void 0,void 0,(function*(){try{const t="health";return yield this.httpRequest.get(t),!0}catch(t){return!1}}))}getStats(){return s(this,void 0,void 0,(function*(){return yield this.httpRequest.get("stats")}))}getVersion(){return s(this,void 0,void 0,(function*(){return yield this.httpRequest.get("version")}))}createDump(){return s(this,void 0,void 0,(function*(){const t=yield this.httpRequest.post("dumps");return new y(t)}))}generateTenantToken(t,e,i){const s=new Error;throw new Error(`Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ${s.stack}.`)}}{constructor(t){super(t),this.tokens=new m(t)}generateTenantToken(t,e,i){return"undefined"==typeof window?this.tokens.generateTenantToken(t,e,i):super.generateTenantToken(t,e,i)}}export{i as ContentTypeEnum,y as EnqueuedTask,q as Index,e as MatchingStrategies,A as MeiliSearch,r as MeiliSearchApiError,n as MeiliSearchCommunicationError,d as MeiliSearchError,a as MeiliSearchTimeOutError,g as Task,w as TaskClient,A as default,u as httpErrorHandler,o as httpResponseErrorHandler,h as versionErrorHintMessage}; | ||
//# sourceMappingURL=meilisearch.esm.min.js.map |
@@ -1,2 +0,4 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},e(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function 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},i.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,i,r,s){var o,u,c,a=this;return a=t.call(this,n)||this,Object.setPrototypeOf(a,e.prototype),a.name="MeiliSearchCommunicationError",i instanceof Response&&(a.message=i.statusText,a.statusCode=i.status),i instanceof Error&&(a.errno=i.errno,a.code=i.code),s?(a.stack=s,a.stack=null===(o=a.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,a.name),a.stack=null===(u=a.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(r," failed, reason: connect ECONNREFUSED")),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Not Found","Not Found: ".concat(r))):Error.captureStackTrace&&Error.captureStackTrace(a,e),a}return n(e,t),e}(Error),u=function(t){function e(e,n){var i=t.call(this,e.message)||this;return Object.setPrototypeOf(i,u.prototype),i.name="MeiliSearchApiError",i.code=e.code,i.type=e.type,i.link=e.link,i.message=e.message,i.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(i,u),i}return n(e,t),e}(Error);function c(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new o(t.statusText,t,t.url);case 4:throw new u(e,t.status);case 5:return[2,t]}}))}))}function a(t,e,n){if("MeiliSearchApiError"!==t.name)throw new o(t.message,t,n,e);throw t}var h=function(t){function e(n){var i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return n(e,t),e}(Error),d=function(t){function e(n){var i=t.call(this,n)||this;return Object.setPrototypeOf(i,e.prototype),i.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(i,e),i}return n(e,t),e}(Error);function l(t,e){return"".concat(t,"\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ").concat(e," call requires.")}function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function f(t){return Object.entries(t).reduce((function(t,e){var n=e[0],i=e[1];return void 0!==i&&(t[n]=i),t}),{})}function v(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()]}}))}))}function y(t){return Object.keys(t).reduce((function(e,n){var r,s,o,u=t[n];return void 0===u?e:Array.isArray(u)?i(i({},e),((r={})[n]=u.join(","),r)):u instanceof Date?i(i({},e),((s={})[n]=u.toISOString(),s)):i(i({},e),((o={})[n]=u,o))}),{})}function w(t){var e,n,i="X-Meilisearch-Client",r="Meilisearch JavaScript (v".concat("0.33.0",")"),s=function(t){if(Array.isArray(t))return t.reduce((function(t,e){return t[e[0]]=e[1],t}),{});if("has"in t){var e={};return t.forEach((function(t,n){return e[n]=t})),e}return Object.assign({},t)}(null!==(n=null===(e=t.requestConfig)||void 0===e?void 0:e.headers)&&void 0!==n?n:{});if(t.apiKey&&!s.Authorization&&(s.Authorization="Bearer ".concat(t.apiKey)),s["Content-Type"]||(s["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var o=t.clientAgents.concat(r);s[i]=o.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new h('Meilisearch: The header "'.concat(i,'" should be an array of string(s).\n'));s[i]=r}return s}var b=function(){function t(t){this.headers=w(t),this.requestConfig=t.requestConfig,this.httpClient=t.httpClient;try{var e=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new h("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e,n=t.method,o=t.url,u=t.params,h=t.body,d=t.config,l=void 0===d?{}:d;return r(this,void 0,void 0,(function(){var t,r,d,p,f,v,y;return s(this,(function(s){switch(s.label){case 0:"undefined"==typeof fetch&&require("cross-fetch/polyfill"),t=new URL(o,this.url),u&&(r=new URLSearchParams,Object.keys(u).filter((function(t){return null!==u[t]})).map((function(t){return r.set(t,u[t])})),t.search=r.toString()),(null===(e=l.headers)||void 0===e?void 0:e["Content-Type"])||(h=JSON.stringify(h)),d=i(i({},this.headers),l.headers),s.label=1;case 1:return s.trys.push([1,6,,7]),p=this.httpClient?this.httpClient:fetch,f=p(t.toString(),i(i(i({},l),this.requestConfig),{method:n,body:h,headers:d})),this.httpClient?[4,f]:[3,3];case 2:return[2,s.sent()];case 3:return[4,f.then((function(t){return c(t)}))];case 4:return[4,s.sent().json().catch((function(){}))];case 5:return[2,s.sent()];case 6:return v=s.sent(),y=v.stack,a(v,y,t.toString()),[3,7];case 7:return[2]}}))}))},t.prototype.get=function(t,e,n){return r(this,void 0,void 0,(function(){return s(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,i.sent()]}}))}))},t.prototype.post=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.put=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.patch=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t.prototype.delete=function(t,e,n,i){return r(this,void 0,void 0,(function(){return s(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:i})];case 1:return[2,r.sent()]}}))}))},t}(),g=function(t){this.taskUid=t.taskUid,this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.enqueuedAt=new Date(t.enqueuedAt)},q=function(t){this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.uid=t.uid,this.details=t.details,this.canceledBy=t.canceledBy,this.error=t.error,this.duration=t.duration,this.startedAt=new Date(t.startedAt),this.enqueuedAt=new Date(t.enqueuedAt),this.finishedAt=new Date(t.finishedAt)},m=function(){function t(t){this.httpRequest=new b(t)}return t.prototype.getTask=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return n=i.sent(),[2,new q(n)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return"tasks",[4,this.httpRequest.get("tasks",y(t))];case 1:return e=n.sent(),[2,i(i({},e),{results:e.results.map((function(t){return new q(t)}))})]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;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<o?[4,this.getTask(t)]:[3,4];case 2:return n=i.sent(),["enqueued","processing"].includes(n.status)?[4,v(c)]:[2,n];case 3:return i.sent(),[3,1];case 4:throw new d("timeout of ".concat(o,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){var e,n,i,r,u;return s(this,(function(s){switch(s.label){case 0:e=[],n=0,i=t,s.label=1;case 1:return n<i.length?(r=i[n],[4,this.waitForTask(r,{timeOutMs:o,intervalMs:c})]):[3,4];case 2:u=s.sent(),e.push(u),s.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},t.prototype.cancelTasks=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return"tasks/cancel",[4,this.httpRequest.post("tasks/cancel",{},y(t))];case 1:return e=n.sent(),[2,new g(e)]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return"tasks",[4,this.httpRequest.delete("tasks",{},y(t))];case 1:return e=n.sent(),[2,new g(e)]}}))}))},t}(),k=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new b(t),this.tasks=new m(t)}return t.prototype.search=function(t,e,n){return r(this,void 0,void 0,(function(){var r;return s(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(r,f(i({q:t},e)),void 0,n)];case 1:return[2,s.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var o,u,c,a,d;return r(this,void 0,void 0,(function(){var r,l,p;return s(this,(function(s){switch(s.label){case 0:return r="indexes/".concat(this.uid,"/search"),l=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},p=i(i({q:t},e),{filter:l(null==e?void 0:e.filter),sort:null===(o=null==e?void 0:e.sort)||void 0===o?void 0:o.join(","),facets:null===(u=null==e?void 0:e.facets)||void 0===u?void 0:u.join(","),attributesToRetrieve:null===(c=null==e?void 0:e.attributesToRetrieve)||void 0===c?void 0:c.join(","),attributesToCrop:null===(a=null==e?void 0:e.attributesToCrop)||void 0===a?void 0:a.join(","),attributesToHighlight:null===(d=null==e?void 0:e.attributesToHighlight)||void 0===d?void 0:d.join(",")}),[4,this.httpRequest.get(r,f(p),n)];case 1:return[2,s.sent()]}}))}))},t.prototype.getRawInfo=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){var r;return s(this,(function(s){switch(s.label){case 0:return"indexes",[4,new b(n).post("indexes",i(i({},e),{uid:t}))];case 1:return r=s.sent(),[2,new g(r)]}}))}))},t.prototype.update=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return(n=i.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.delete=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new g(e)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(i(i({},t),{indexUids:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.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/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){var e;return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var n,r,c;return s(this,(function(s){switch(s.label){case 0:if(void 0===(t=f(t)).filter)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),r="indexes/".concat(this.uid,"/documents/fetch"),[4,this.httpRequest.post(r,t)];case 2:return[2,s.sent()];case 3:throw((n=s.sent())instanceof o||n instanceof u)&&(n.message=l(n.message,"getDocuments")),n;case 4:return[3,7];case 5:return r="indexes/".concat(this.uid,"/documents"),c=Array.isArray(null==t?void 0:t.fields)?{fields:null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}:{},[4,this.httpRequest.get(r,i(i({},t),c))];case 6:return[2,s.sent()];case 7:return[2]}}))}))},t.prototype.getDocument=function(t,e){return r(this,void 0,void 0,(function(){var n,r;return s(this,(function(s){switch(s.label){case 0:return n="indexes/".concat(this.uid,"/documents/").concat(t),r=function(){var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")}(),[4,this.httpRequest.get(n,f(i(i({},e),{fields:r})))];case 1:return[2,s.sent()]}}))}))},t.prototype.addDocuments=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/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return i=r.sent(),[2,new g(i)]}}))}))},t.prototype.addDocumentsFromString=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:return i="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(i,t,n,{headers:{"Content-Type":e}})];case 1:return r=s.sent(),[2,new g(r)]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),r(this,void 0,void 0,(function(){var i,r,o,u;return s(this,(function(s){switch(s.label){case 0:i=[],r=0,s.label=1;case 1:return r<t.length?(u=(o=i).push,[4,this.addDocuments(t.slice(r,r+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return r+=e,[3,1];case 4:return[2,i]}}))}))},t.prototype.updateDocuments=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/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return i=r.sent(),[2,new g(i)]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),r(this,void 0,void 0,(function(){var i,r,o,u;return s(this,(function(s){switch(s.label){case 0:i=[],r=0,s.label=1;case 1:return r<t.length?(u=(o=i).push,[4,this.updateDocuments(t.slice(r,r+e),n)]):[3,4];case 2:u.apply(o,[s.sent()]),s.label=3;case 3:return r+=e,[3,1];case 4:return[2,i]}}))}))},t.prototype.updateDocumentsFromString=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:return i="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(i,t,n,{headers:{"Content-Type":e}})];case 1:return r=s.sent(),[2,new g(r)]}}))}))},t.prototype.deleteDocument=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return(n=i.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.deleteDocuments=function(t){return r(this,void 0,void 0,(function(){var e,n,i,r,c;return s(this,(function(s){switch(s.label){case 0:e=!Array.isArray(t)&&"object"===p(t),n=e?"documents/delete":"documents/delete-batch",i="indexes/".concat(this.uid,"/").concat(n),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this.httpRequest.post(i,t)];case 2:return r=s.sent(),[2,new g(r)];case 3:throw((c=s.sent())instanceof o&&e||c instanceof u)&&(c.message=l(c.message,"deleteDocuments")),c;case 4:return[2]}}))}))},t.prototype.deleteAllDocuments=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.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/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return(n=i.sent()).enqueued=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.resetSettings=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getPagination=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updatePagination=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.patch(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetPagination=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/pagination"),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new g(e)]}}))}))},t.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/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetSynonyms=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.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/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetStopWords=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.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/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetRankingRules=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.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/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetDistinctAttribute=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getFilterableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetFilterableAttributes=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getSortableAttributes=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetSortableAttributes=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.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/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetSearchableAttributes=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.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/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetDisplayedAttributes=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getTypoTolerance=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.patch(e,t)];case 1:return(n=i.sent()).enqueuedAt=new Date(n.enqueuedAt),[2,n]}}))}))},t.prototype.resetTypoTolerance=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return(e=n.sent()).enqueuedAt=new Date(e.enqueuedAt),[2,e]}}))}))},t.prototype.getFaceting=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFaceting=function(t){return r(this,void 0,void 0,(function(){var e,n;return s(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.patch(e,t)];case 1:return n=i.sent(),[2,new g(n)]}}))}))},t.prototype.resetFaceting=function(){return r(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid,"/settings/faceting"),[4,this.httpRequest.delete(t)];case 1:return e=n.sent(),[2,new g(e)]}}))}))},t}(),R=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new b(t),this.tasks=new m(t)}return t.prototype.index=function(t){return new k(this.config,t)},t.prototype.getIndex=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new k(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){return[2,new k(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e,n,r=this;return s(this,(function(s){switch(s.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=s.sent(),n=e.results.map((function(t){return new k(r.config,t.uid,t.primaryKey)})),[2,i(i({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"indexes",[4,this.httpRequest.get("indexes",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,k.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,new k(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,new k(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.swapIndexes=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"/swap-indexes",[4,this.httpRequest.post("/swap-indexes",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.multiSearch=function(t,e){return r(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return"multi-search",[4,this.httpRequest.post("multi-search",t,void 0,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,i=n.timeOutMs,o=void 0===i?5e3:i,u=n.intervalMs,c=void 0===u?50:u;return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:o,intervalMs:c})];case 1:return[2,e.sent()]}}))}))},t.prototype.cancelTasks=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.cancelTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,this.tasks.deleteTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return"keys",[4,this.httpRequest.get("keys",t)];case 1:return(e=n.sent()).results=e.results.map((function(t){return i(i({},t),{createdAt:new Date(t.createdAt),updateAt:new Date(t.updateAt)})})),[2,e]}}))}))},t.prototype.getKey=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return r(this,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return"keys",[4,this.httpRequest.post("keys",t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateKey=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="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.deleteKey=function(t){return r(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"health",[4,this.httpRequest.get("health")];case 1:return[2,t.sent()]}}))}))},t.prototype.isHealthy=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),"health",[4,this.httpRequest.get("health")];case 1:return t.sent(),[2,!0];case 2:return t.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"stats",[4,this.httpRequest.get("stats")];case 1:return[2,t.sent()]}}))}))},t.prototype.getVersion=function(){return r(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return"version",[4,this.httpRequest.get("version")];case 1:return[2,t.sent()]}}))}))},t.prototype.createDump=function(){return r(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return t=e.sent(),[2,new g(t)]}}))}))},t.prototype.generateTenantToken=function(t,e,n){var i=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(i.stack,"."))},t}());t.ContentTypeEnum={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},t.Index=k,t.MatchingStrategies={ALL:"all",LAST:"last"},t.MeiliSearch=R,t.MeiliSearchApiError=u,t.MeiliSearchCommunicationError=o,t.MeiliSearchError=h,t.MeiliSearchTimeOutError=d,t.default=R,t.httpErrorHandler=a,t.httpResponseErrorHandler=c,t.versionErrorHintMessage=l,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";function e(){ | ||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ | ||
e=function(){return t};var t={},r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",u=i.asyncIterator||"@@asyncIterator",a=i.toStringTag||"@@toStringTag";function o(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{o({},"")}catch(t){o=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var i=e&&e.prototype instanceof p?e:p,s=Object.create(i.prototype),u=new R(n||[]);return s._invoke=function(t,e,r){var n="suspendedStart";return function(i,s){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw s;return O()}for(r.method=i,r.arg=s;;){var u=r.delegate;if(u){var a=b(u,r);if(a){if(a===d)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var o=h(t,e,r);if("normal"===o.type){if(n=r.done?"completed":"suspendedYield",o.arg===d)continue;return{value:o.arg,done:r.done}}"throw"===o.type&&(n="completed",r.method="throw",r.arg=o.arg)}}}(t,r,u),s}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var d={};function p(){}function f(){}function v(){}var l={};o(l,s,(function(){return this}));var w=Object.getPrototypeOf,y=w&&w(w(A([])));y&&y!==r&&n.call(y,s)&&(l=y);var x=v.prototype=p.prototype=Object.create(l);function k(t){["next","throw","return"].forEach((function(e){o(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){function r(i,s,u,a){var o=h(t[i],t,s);if("throw"!==o.type){var c=o.arg,d=c.value;return d&&"object"==typeof d&&n.call(d,"__await")?e.resolve(d.__await).then((function(t){r("next",t,u,a)}),(function(t){r("throw",t,u,a)})):e.resolve(d).then((function(t){c.value=t,u(c)}),(function(t){return r("throw",t,u,a)}))}a(o.arg)}var i;this._invoke=function(t,n){function s(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(s,s):s()}}function b(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,b(t,e),"throw"===e.method))return d;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=h(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,d;var i=n.arg;return i?i.done?(e[t.resultName]=i.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,d):i:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,d)}function m(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function q(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(m,this),this.reset(!0)}function A(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,i=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:O}}function O(){return{value:void 0,done:!0}}return f.prototype=v,o(x,"constructor",v),o(v,"constructor",f),f.displayName=o(v,a,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===f||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,o(t,a,"GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},k(g.prototype),o(g.prototype,u,(function(){return this})),t.AsyncIterator=g,t.async=function(e,r,n,i,s){void 0===s&&(s=Promise);var u=new g(c(e,r,n,i),s);return t.isGeneratorFunction(r)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},k(x),o(x,a,"Generator"),o(x,s,(function(){return this})),o(x,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=A,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(q),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(r,n){return u.type="throw",u.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var s=this.tryEntries[i],u=s.completion;if("root"===s.tryLoc)return r("end");if(s.tryLoc<=this.prev){var a=n.call(s,"catchLoc"),o=n.call(s,"finallyLoc");if(a&&o){if(this.prev<s.catchLoc)return r(s.catchLoc,!0);if(this.prev<s.finallyLoc)return r(s.finallyLoc)}else if(a){if(this.prev<s.catchLoc)return r(s.catchLoc,!0)}else{if(!o)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return r(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var s=i;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var u=s?s.completion:{};return u.type=t,u.arg=e,s?(this.method="next",this.next=s.finallyLoc,d):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),q(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;q(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:A(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},t}function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function s(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function d(t,e,r){return d=h()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&c(i,r.prototype),i},d.apply(null,arguments)}function p(t){var e="function"==typeof Map?new Map:void 0;return p=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return d(t,arguments,o(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},p(t)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function v(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return f(t)}function l(t){var e=h();return function(){var r,n=o(t);if(e){var i=o(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return v(this,r)}}function w(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null==r)return;var n,i,s=[],u=!0,a=!1;try{for(r=r.call(t);!(u=(n=r.next()).done)&&(s.push(n.value),!e||s.length!==e);u=!0);}catch(t){a=!0,i=t}finally{try{u||null==r.return||r.return()}finally{if(a)throw i}}return s}(t,e)||y(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function y(t,e){if(t){if("string"==typeof t)return x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(t,e):void 0}}function x(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function k(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=y(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,u=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){a=!0,s=t},f:function(){try{u||null==r.return||r.return()}finally{if(a)throw s}}}}function g(t,e,r,n){return new(r||(r=Promise))((function(i,s){function u(t){try{o(n.next(t))}catch(t){s(t)}}function a(t){try{o(n.throw(t))}catch(t){s(t)}}function o(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(u,a)}o((n=n.apply(t,e||[])).next())}))}var b=function(t){a(r,t);var e=l(r);function r(t,i,s,u){var a,o,c,h;return n(this,r),a=e.call(this,t),Object.setPrototypeOf(f(a),r.prototype),a.name="MeiliSearchCommunicationError",i instanceof Response&&(a.message=i.statusText,a.statusCode=i.status),i instanceof Error&&(a.errno=i.errno,a.code=i.code),u?(a.stack=u,a.stack=null===(o=a.stack)||void 0===o?void 0:o.replace(/(TypeError|FetchError)/,a.name),a.stack=null===(c=a.stack)||void 0===c?void 0:c.replace("Failed to fetch","request to ".concat(s," failed, reason: connect ECONNREFUSED")),a.stack=null===(h=a.stack)||void 0===h?void 0:h.replace("Not Found","Not Found: ".concat(s))):Error.captureStackTrace&&Error.captureStackTrace(f(a),r),a}return s(r)}(p(Error)),m=function(t){a(r,t);var e=l(r);function r(t,i){var s;return n(this,r),s=e.call(this,t.message),Object.setPrototypeOf(f(s),r.prototype),s.name="MeiliSearchApiError",s.code=t.code,s.type=t.type,s.link=t.link,s.message=t.message,s.httpStatus=i,Error.captureStackTrace&&Error.captureStackTrace(f(s),r),s}return s(r)}(p(Error));function q(t){return g(this,void 0,void 0,e().mark((function r(){var n;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.ok){e.next=11;break}return e.prev=1,e.next=4,t.json();case 4:n=e.sent,e.next=10;break;case 7:throw e.prev=7,e.t0=e.catch(1),new b(t.statusText,t,t.url);case 10:throw new m(n,t.status);case 11:return e.abrupt("return",t);case 12:case"end":return e.stop()}}),r,null,[[1,7]])})))}function R(t,e,r){if("MeiliSearchApiError"!==t.name)throw new b(t.message,t,r,e);throw t}var A=function(t){a(r,t);var e=l(r);function r(t){var i;return n(this,r),i=e.call(this,t),Object.setPrototypeOf(f(i),r.prototype),i.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(f(i),r),i}return s(r)}(p(Error)),O=function(t){a(r,t);var e=l(r);function r(t){var i;return n(this,r),i=e.call(this,t),Object.setPrototypeOf(f(i),r.prototype),i.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(f(i),r),i}return s(r)}(p(Error));function T(t,e){return"".concat(t,"\nHint: It might not be working because maybe you're not up to date with the Meilisearch version that ").concat(e," call requires.")}function j(t){return Object.entries(t).reduce((function(t,e){var r=w(e,2),n=r[0],i=r[1];return void 0!==i&&(t[n]=i),t}),{})}function S(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new Promise((function(e){return setTimeout(e,t)}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r)})))}function E(t){return Object.keys(t).reduce((function(e,r){var n=t[r];return void 0===n?e:Array.isArray(n)?Object.assign(Object.assign({},e),u({},r,n.join(","))):n instanceof Date?Object.assign(Object.assign({},e),u({},r,n.toISOString())):Object.assign(Object.assign({},e),u({},r,n))}),{})}function D(t){var e,r,n="X-Meilisearch-Client",i="Meilisearch JavaScript (v".concat("0.35.0-v1.3.0-pre-release.0",")"),s=function(t){if(Array.isArray(t))return t.reduce((function(t,e){return t[e[0]]=e[1],t}),{});if("has"in t){var e={};return t.forEach((function(t,r){return e[r]=t})),e}return Object.assign({},t)}(null!==(r=null===(e=t.requestConfig)||void 0===e?void 0:e.headers)&&void 0!==r?r:{});if(t.apiKey&&!s.Authorization&&(s.Authorization="Bearer ".concat(t.apiKey)),s["Content-Type"]||(s["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var u=t.clientAgents.concat(i);s[n]=u.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new A('Meilisearch: The header "'.concat(n,'" should be an array of string(s).\n'));s[n]=i}return s}var M=function(){function t(e){n(this,t),this.headers=D(e),this.requestConfig=e.requestConfig,this.httpClient=e.httpClient;try{var r=function(t){try{return(e=t=function(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}(t)).endsWith("/")||(e+="/"),t=e}catch(t){throw new A("The provided host is not valid.")}var e}(e.host);this.url=new URL(r)}catch(t){throw new A("The provided host is not valid.")}}return s(t,[{key:"request",value:function(t){var r,n=t.method,i=t.url,s=t.params,u=t.body,a=t.config,o=void 0===a?{}:a;return g(this,void 0,void 0,e().mark((function t(){var a,c,h,d,p,f,v,l;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("undefined"==typeof fetch&&require("cross-fetch/polyfill"),a=new URL(i,this.url),s&&(c=new URLSearchParams,Object.keys(s).filter((function(t){return null!==s[t]})).map((function(t){return c.set(t,s[t])})),a.search=c.toString()),(null===(r=o.headers)||void 0===r?void 0:r["Content-Type"])||(u=JSON.stringify(u)),h=Object.assign(Object.assign({},this.headers),o.headers),t.prev=5,d=this.httpClient?this.httpClient:fetch,p=d(a.toString(),Object.assign(Object.assign(Object.assign({},o),this.requestConfig),{method:n,body:u,headers:h})),!this.httpClient){t.next=12;break}return t.next=11,p;case 11:return t.abrupt("return",t.sent);case 12:return t.next=14,p.then((function(t){return q(t)}));case 14:return f=t.sent,t.next=17,f.json().catch((function(){}));case 17:return v=t.sent,t.abrupt("return",v);case 21:t.prev=21,t.t0=t.catch(5),l=t.t0.stack,R(t.t0,l,a.toString());case 25:case"end":return t.stop()}}),t,this,[[5,21]])})))}},{key:"get",value:function(t,r,n){return g(this,void 0,void 0,e().mark((function i(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.request({method:"GET",url:t,params:r,config:n});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),i,this)})))}},{key:"post",value:function(t,r,n,i){return g(this,void 0,void 0,e().mark((function s(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.request({method:"POST",url:t,body:r,params:n,config:i});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),s,this)})))}},{key:"put",value:function(t,r,n,i){return g(this,void 0,void 0,e().mark((function s(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.request({method:"PUT",url:t,body:r,params:n,config:i});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),s,this)})))}},{key:"patch",value:function(t,r,n,i){return g(this,void 0,void 0,e().mark((function s(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.request({method:"PATCH",url:t,body:r,params:n,config:i});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),s,this)})))}},{key:"delete",value:function(t,r,n,i){return g(this,void 0,void 0,e().mark((function s(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.request({method:"DELETE",url:t,body:r,params:n,config:i});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),s,this)})))}}]),t}(),L=s((function t(e){n(this,t),this.taskUid=e.taskUid,this.indexUid=e.indexUid,this.status=e.status,this.type=e.type,this.enqueuedAt=new Date(e.enqueuedAt)})),F=s((function t(e){n(this,t),this.indexUid=e.indexUid,this.status=e.status,this.type=e.type,this.uid=e.uid,this.details=e.details,this.canceledBy=e.canceledBy,this.error=e.error,this.duration=e.duration,this.startedAt=new Date(e.startedAt),this.enqueuedAt=new Date(e.enqueuedAt),this.finishedAt=new Date(e.finishedAt)})),I=function(){function t(e){n(this,t),this.httpRequest=new M(e)}return s(t,[{key:"getTask",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="tasks/".concat(t),e.next=3,this.httpRequest.get(n);case 3:return i=e.sent,e.abrupt("return",new F(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"getTasks",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){var n;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"tasks",e.next=3,this.httpRequest.get("tasks",E(t));case 3:return n=e.sent,e.abrupt("return",Object.assign(Object.assign({},n),{results:n.results.map((function(t){return new F(t)}))}));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"waitForTask",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.timeOutMs,i=void 0===n?5e3:n,s=r.intervalMs,u=void 0===s?50:s;return g(this,void 0,void 0,e().mark((function r(){var n,s;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=Date.now();case 1:if(!(Date.now()-n<i)){e.next=11;break}return e.next=4,this.getTask(t);case 4:if(s=e.sent,["enqueued","processing"].includes(s.status)){e.next=7;break}return e.abrupt("return",s);case 7:return e.next=9,S(u);case 9:e.next=1;break;case 11:throw new O("timeout of ".concat(i,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."));case 12:case"end":return e.stop()}}),r,this)})))}},{key:"waitForTasks",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.timeOutMs,i=void 0===n?5e3:n,s=r.intervalMs,u=void 0===s?50:s;return g(this,void 0,void 0,e().mark((function r(){var n,s,a,o,c;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=[],s=k(t),e.prev=2,s.s();case 4:if((a=s.n()).done){e.next=12;break}return o=a.value,e.next=8,this.waitForTask(o,{timeOutMs:i,intervalMs:u});case 8:c=e.sent,n.push(c);case 10:e.next=4;break;case 12:e.next=17;break;case 14:e.prev=14,e.t0=e.catch(2),s.e(e.t0);case 17:return e.prev=17,s.f(),e.finish(17);case 20:return e.abrupt("return",n);case 21:case"end":return e.stop()}}),r,this,[[2,14,17,20]])})))}},{key:"cancelTasks",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){var n;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"tasks/cancel",e.next=3,this.httpRequest.post("tasks/cancel",{},E(t));case 3:return n=e.sent,e.abrupt("return",new L(n));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"deleteTasks",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){var n;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"tasks",e.next=3,this.httpRequest.delete("tasks",{},E(t));case 3:return n=e.sent,e.abrupt("return",new L(n));case 5:case"end":return e.stop()}}),r,this)})))}}]),t}(),P=function(){function t(e,r,i){n(this,t),this.uid=r,this.primaryKey=i,this.httpRequest=new M(e),this.tasks=new I(e)}return s(t,[{key:"search",value:function(t,r,n){return g(this,void 0,void 0,e().mark((function i(){var s;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s="indexes/".concat(this.uid,"/search"),e.next=3,this.httpRequest.post(s,j(Object.assign({q:t},r)),void 0,n);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),i,this)})))}},{key:"searchGet",value:function(t,r,n){var i,s,u,a,o,c,h;return g(this,void 0,void 0,e().mark((function d(){var p,f,v;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return p="indexes/".concat(this.uid,"/search"),f=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new A("The filter query parameter should be in string format when using searchGet")},v=Object.assign(Object.assign({q:t},r),{filter:f(null==r?void 0:r.filter),sort:null===(i=null==r?void 0:r.sort)||void 0===i?void 0:i.join(","),facets:null===(s=null==r?void 0:r.facets)||void 0===s?void 0:s.join(","),attributesToRetrieve:null===(u=null==r?void 0:r.attributesToRetrieve)||void 0===u?void 0:u.join(","),attributesToCrop:null===(a=null==r?void 0:r.attributesToCrop)||void 0===a?void 0:a.join(","),attributesToHighlight:null===(o=null==r?void 0:r.attributesToHighlight)||void 0===o?void 0:o.join(","),vector:null===(c=null==r?void 0:r.vector)||void 0===c?void 0:c.join(","),attributesToSearchOn:null===(h=null==r?void 0:r.attributesToSearchOn)||void 0===h?void 0:h.join(",")}),e.next=5,this.httpRequest.get(p,j(v),n);case 5:return e.abrupt("return",e.sent);case 6:case"end":return e.stop()}}),d,this)})))}},{key:"searchForFacetValues",value:function(t,r){return g(this,void 0,void 0,e().mark((function n(){var i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="indexes/".concat(this.uid,"/facet-search"),e.next=3,this.httpRequest.post(i,j(t),void 0,r);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),n,this)})))}},{key:"getRawInfo",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid),t.next=3,this.httpRequest.get(r);case 3:return n=t.sent,this.primaryKey=n.primaryKey,this.updatedAt=new Date(n.updatedAt),this.createdAt=new Date(n.createdAt),t.abrupt("return",n);case 8:case"end":return t.stop()}}),t,this)})))}},{key:"fetchInfo",value:function(){return g(this,void 0,void 0,e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getRawInfo();case 2:return t.abrupt("return",this);case 3:case"end":return t.stop()}}),t,this)})))}},{key:"fetchPrimaryKey",value:function(){return g(this,void 0,void 0,e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getRawInfo();case 2:return this.primaryKey=t.sent.primaryKey,t.abrupt("return",this.primaryKey);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"update",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid),e.next=3,this.httpRequest.patch(n,t);case 3:return(i=e.sent).enqueuedAt=new Date(i.enqueuedAt),e.abrupt("return",i);case 6:case"end":return e.stop()}}),r,this)})))}},{key:"delete",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid),t.next=3,this.httpRequest.delete(r);case 3:return n=t.sent,t.abrupt("return",new L(n));case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getTasks",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.getTasks(Object.assign(Object.assign({},t),{indexUids:[this.uid]}));case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"getTask",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.getTask(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"waitForTasks",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.timeOutMs,i=void 0===n?5e3:n,s=r.intervalMs,u=void 0===s?50:s;return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.waitForTasks(t,{timeOutMs:i,intervalMs:u});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"waitForTask",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.timeOutMs,i=void 0===n?5e3:n,s=r.intervalMs,u=void 0===s?50:s;return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.waitForTask(t,{timeOutMs:i,intervalMs:u});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"getStats",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/stats"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"getDocuments",value:function(){var t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function n(){var i,s,u;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===(r=j(r)).filter){e.next=15;break}return e.prev=2,i="indexes/".concat(this.uid,"/documents/fetch"),e.next=6,this.httpRequest.post(i,r);case 6:case 19:return e.abrupt("return",e.sent);case 9:throw e.prev=9,e.t0=e.catch(2),(e.t0 instanceof b||e.t0 instanceof m)&&(e.t0.message=T(e.t0.message,"getDocuments")),e.t0;case 13:e.next=20;break;case 15:return s="indexes/".concat(this.uid,"/documents"),u=Array.isArray(null==r?void 0:r.fields)?{fields:null===(t=null==r?void 0:r.fields)||void 0===t?void 0:t.join(",")}:{},e.next=19,this.httpRequest.get(s,Object.assign(Object.assign({},r),u));case 20:case"end":return e.stop()}}),n,this,[[2,9]])})))}},{key:"getDocument",value:function(t,r){return g(this,void 0,void 0,e().mark((function n(){var i,s;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="indexes/".concat(this.uid,"/documents/").concat(t),s=function(){var t;if(Array.isArray(null==r?void 0:r.fields))return null===(t=null==r?void 0:r.fields)||void 0===t?void 0:t.join(",")}(),e.next=4,this.httpRequest.get(i,j(Object.assign(Object.assign({},r),{fields:s})));case 4:return e.abrupt("return",e.sent);case 5:case"end":return e.stop()}}),n,this)})))}},{key:"addDocuments",value:function(t,r){return g(this,void 0,void 0,e().mark((function n(){var i,s;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="indexes/".concat(this.uid,"/documents"),e.next=3,this.httpRequest.post(i,t,r);case 3:return s=e.sent,e.abrupt("return",new L(s));case 5:case"end":return e.stop()}}),n,this)})))}},{key:"addDocumentsFromString",value:function(t,r,n){return g(this,void 0,void 0,e().mark((function i(){var s,u;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s="indexes/".concat(this.uid,"/documents"),e.next=3,this.httpRequest.post(s,t,n,{headers:{"Content-Type":r}});case 3:return u=e.sent,e.abrupt("return",new L(u));case 5:case"end":return e.stop()}}),i,this)})))}},{key:"addDocumentsInBatches",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,n=arguments.length>2?arguments[2]:void 0;return g(this,void 0,void 0,e().mark((function i(){var s,u;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=[],u=0;case 2:if(!(u<t.length)){e.next=11;break}return e.t0=s,e.next=6,this.addDocuments(t.slice(u,u+r),n);case 6:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 8:u+=r,e.next=2;break;case 11:return e.abrupt("return",s);case 12:case"end":return e.stop()}}),i,this)})))}},{key:"updateDocuments",value:function(t,r){return g(this,void 0,void 0,e().mark((function n(){var i,s;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="indexes/".concat(this.uid,"/documents"),e.next=3,this.httpRequest.put(i,t,r);case 3:return s=e.sent,e.abrupt("return",new L(s));case 5:case"end":return e.stop()}}),n,this)})))}},{key:"updateDocumentsInBatches",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3,n=arguments.length>2?arguments[2]:void 0;return g(this,void 0,void 0,e().mark((function i(){var s,u;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s=[],u=0;case 2:if(!(u<t.length)){e.next=11;break}return e.t0=s,e.next=6,this.updateDocuments(t.slice(u,u+r),n);case 6:e.t1=e.sent,e.t0.push.call(e.t0,e.t1);case 8:u+=r,e.next=2;break;case 11:return e.abrupt("return",s);case 12:case"end":return e.stop()}}),i,this)})))}},{key:"updateDocumentsFromString",value:function(t,r,n){return g(this,void 0,void 0,e().mark((function i(){var s,u;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s="indexes/".concat(this.uid,"/documents"),e.next=3,this.httpRequest.put(s,t,n,{headers:{"Content-Type":r}});case 3:return u=e.sent,e.abrupt("return",new L(u));case 5:case"end":return e.stop()}}),i,this)})))}},{key:"deleteDocument",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/documents/").concat(t),e.next=3,this.httpRequest.delete(n);case 3:return(i=e.sent).enqueuedAt=new Date(i.enqueuedAt),e.abrupt("return",i);case 6:case"end":return e.stop()}}),r,this)})))}},{key:"deleteDocuments",value:function(t){return g(this,void 0,void 0,e().mark((function n(){var i,s,u,a;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=!Array.isArray(t)&&"object"===r(t),s=i?"documents/delete":"documents/delete-batch",u="indexes/".concat(this.uid,"/").concat(s),e.prev=3,e.next=6,this.httpRequest.post(u,t);case 6:return a=e.sent,e.abrupt("return",new L(a));case 10:throw e.prev=10,e.t0=e.catch(3),(e.t0 instanceof b&&i||e.t0 instanceof m)&&(e.t0.message=T(e.t0.message,"deleteDocuments")),e.t0;case 14:case"end":return e.stop()}}),n,this,[[3,10]])})))}},{key:"deleteAllDocuments",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/documents"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getSettings",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateSettings",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings"),e.next=3,this.httpRequest.patch(n,t);case 3:return(i=e.sent).enqueued=new Date(i.enqueuedAt),e.abrupt("return",i);case 6:case"end":return e.stop()}}),r,this)})))}},{key:"resetSettings",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getPagination",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/pagination"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updatePagination",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/pagination"),e.next=3,this.httpRequest.patch(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetPagination",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/pagination"),t.next=3,this.httpRequest.delete(r);case 3:return n=t.sent,t.abrupt("return",new L(n));case 5:case"end":return t.stop()}}),t,this)})))}},{key:"getSynonyms",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/synonyms"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateSynonyms",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/synonyms"),e.next=3,this.httpRequest.put(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetSynonyms",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/synonyms"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getStopWords",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/stop-words"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateStopWords",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/stop-words"),e.next=3,this.httpRequest.put(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetStopWords",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/stop-words"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getRankingRules",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/ranking-rules"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateRankingRules",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/ranking-rules"),e.next=3,this.httpRequest.put(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetRankingRules",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/ranking-rules"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getDistinctAttribute",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/distinct-attribute"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateDistinctAttribute",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/distinct-attribute"),e.next=3,this.httpRequest.put(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetDistinctAttribute",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/distinct-attribute"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getFilterableAttributes",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/filterable-attributes"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateFilterableAttributes",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/filterable-attributes"),e.next=3,this.httpRequest.put(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetFilterableAttributes",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/filterable-attributes"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getSortableAttributes",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/sortable-attributes"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateSortableAttributes",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/sortable-attributes"),e.next=3,this.httpRequest.put(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetSortableAttributes",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/sortable-attributes"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getSearchableAttributes",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/searchable-attributes"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateSearchableAttributes",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/searchable-attributes"),e.next=3,this.httpRequest.put(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetSearchableAttributes",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/searchable-attributes"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getDisplayedAttributes",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/displayed-attributes"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateDisplayedAttributes",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/displayed-attributes"),e.next=3,this.httpRequest.put(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetDisplayedAttributes",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/displayed-attributes"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getTypoTolerance",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/typo-tolerance"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateTypoTolerance",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/typo-tolerance"),e.next=3,this.httpRequest.patch(n,t);case 3:return(i=e.sent).enqueuedAt=new Date(i.enqueuedAt),e.abrupt("return",i);case 6:case"end":return e.stop()}}),r,this)})))}},{key:"resetTypoTolerance",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/typo-tolerance"),t.next=3,this.httpRequest.delete(r);case 3:return(n=t.sent).enqueuedAt=new Date(n.enqueuedAt),t.abrupt("return",n);case 6:case"end":return t.stop()}}),t,this)})))}},{key:"getFaceting",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/faceting"),t.next=3,this.httpRequest.get(r);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"updateFaceting",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n,i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="indexes/".concat(this.uid,"/settings/faceting"),e.next=3,this.httpRequest.patch(n,t);case 3:return i=e.sent,e.abrupt("return",new L(i));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"resetFaceting",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r,n;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="indexes/".concat(this.uid,"/settings/faceting"),t.next=3,this.httpRequest.delete(r);case 3:return n=t.sent,t.abrupt("return",new L(n));case 5:case"end":return t.stop()}}),t,this)})))}}],[{key:"create",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return g(this,void 0,void 0,e().mark((function i(){var s,u;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"indexes",s=new M(n),e.next=4,s.post("indexes",Object.assign(Object.assign({},r),{uid:t}));case 4:return u=e.sent,e.abrupt("return",new L(u));case 6:case"end":return e.stop()}}),i)})))}}]),t}(),_=function(){function t(e){n(this,t),this.config=e,this.httpRequest=new M(e),this.tasks=new I(e)}return s(t,[{key:"index",value:function(t){return new P(this.config,t)}},{key:"getIndex",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new P(this.config,t).fetchInfo());case 1:case"end":return e.stop()}}),r,this)})))}},{key:"getRawIndex",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new P(this.config,t).getRawInfo());case 1:case"end":return e.stop()}}),r,this)})))}},{key:"getIndexes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){var n,i,s=this;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getRawIndexes(t);case 2:return n=e.sent,i=n.results.map((function(t){return new P(s.config,t.uid,t.primaryKey)})),e.abrupt("return",Object.assign(Object.assign({},n),{results:i}));case 5:case"end":return e.stop()}}),r,this)})))}},{key:"getRawIndexes",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"indexes",e.next=3,this.httpRequest.get("indexes",t);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),r,this)})))}},{key:"createIndex",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return g(this,void 0,void 0,e().mark((function n(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,P.create(t,r,this.config);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),n,this)})))}},{key:"updateIndex",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return g(this,void 0,void 0,e().mark((function n(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new P(this.config,t).update(r);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),n,this)})))}},{key:"deleteIndex",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,new P(this.config,t).delete();case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"deleteIndexIfExists",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,this.deleteIndex(t);case 3:return e.abrupt("return",!0);case 6:if(e.prev=6,e.t0=e.catch(0),"index_not_found"!==e.t0.code){e.next=10;break}return e.abrupt("return",!1);case 10:throw e.t0;case 11:case"end":return e.stop()}}),r,this,[[0,6]])})))}},{key:"swapIndexes",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"/swap-indexes",e.next=3,this.httpRequest.post("/swap-indexes",t);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),r,this)})))}},{key:"multiSearch",value:function(t,r){return g(this,void 0,void 0,e().mark((function n(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"multi-search",e.next=3,this.httpRequest.post("multi-search",t,void 0,r);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),n,this)})))}},{key:"getTasks",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.getTasks(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"getTask",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.getTask(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"waitForTasks",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.timeOutMs,i=void 0===n?5e3:n,s=r.intervalMs,u=void 0===s?50:s;return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.waitForTasks(t,{timeOutMs:i,intervalMs:u});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"waitForTask",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.timeOutMs,i=void 0===n?5e3:n,s=r.intervalMs,u=void 0===s?50:s;return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.waitForTask(t,{timeOutMs:i,intervalMs:u});case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"cancelTasks",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.cancelTasks(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"deleteTasks",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.tasks.deleteTasks(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),r,this)})))}},{key:"getKeys",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return g(this,void 0,void 0,e().mark((function r(){var n;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"keys",e.next=3,this.httpRequest.get("keys",t);case 3:return(n=e.sent).results=n.results.map((function(t){return Object.assign(Object.assign({},t),{createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)})})),e.abrupt("return",n);case 6:case"end":return e.stop()}}),r,this)})))}},{key:"getKey",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="keys/".concat(t),e.next=3,this.httpRequest.get(n);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),r,this)})))}},{key:"createKey",value:function(t){return g(this,void 0,void 0,e().mark((function r(){return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"keys",e.next=3,this.httpRequest.post("keys",t);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),r,this)})))}},{key:"updateKey",value:function(t,r){return g(this,void 0,void 0,e().mark((function n(){var i;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i="keys/".concat(t),e.next=3,this.httpRequest.patch(i,r);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),n,this)})))}},{key:"deleteKey",value:function(t){return g(this,void 0,void 0,e().mark((function r(){var n;return e().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n="keys/".concat(t),e.next=3,this.httpRequest.delete(n);case 3:return e.abrupt("return",e.sent);case 4:case"end":return e.stop()}}),r,this)})))}},{key:"health",value:function(){return g(this,void 0,void 0,e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"health",t.next=3,this.httpRequest.get("health");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"isHealthy",value:function(){return g(this,void 0,void 0,e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,"health",t.next=4,this.httpRequest.get("health");case 4:return t.abrupt("return",!0);case 7:return t.prev=7,t.t0=t.catch(0),t.abrupt("return",!1);case 10:case"end":return t.stop()}}),t,this,[[0,7]])})))}},{key:"getStats",value:function(){return g(this,void 0,void 0,e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"stats",t.next=3,this.httpRequest.get("stats");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"getVersion",value:function(){return g(this,void 0,void 0,e().mark((function t(){return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"version",t.next=3,this.httpRequest.get("version");case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t,this)})))}},{key:"createDump",value:function(){return g(this,void 0,void 0,e().mark((function t(){var r;return e().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return"dumps",t.next=3,this.httpRequest.post("dumps");case 3:return r=t.sent,t.abrupt("return",new L(r));case 5:case"end":return t.stop()}}),t,this)})))}},{key:"generateTenantToken",value:function(t,e,r){var n=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(n.stack,"."))}}]),t}(),C=function(t){a(r,t);var e=l(r);function r(t){return n(this,r),e.call(this,t)}return s(r)}(_);t.ContentTypeEnum={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},t.Index=P,t.MatchingStrategies={ALL:"all",LAST:"last"},t.MeiliSearch=C,t.MeiliSearchApiError=m,t.MeiliSearchCommunicationError=b,t.MeiliSearchError=A,t.MeiliSearchTimeOutError=O,t.default=C,t.httpErrorHandler=R,t.httpResponseErrorHandler=q,t.versionErrorHintMessage=T,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=meilisearch.umd.min.js.map |
@@ -1,2 +0,2 @@ | ||
// Type definitions for meilisearch 0.33.0 | ||
// Type definitions for meilisearch 0.35.0-v1.3.0-pre-release.0 | ||
// Project: https://github.com/meilisearch/meilisearch-js | ||
@@ -3,0 +3,0 @@ // Definitions by: cvermand <charlotte@meilisearch.com> <https://github.com/meilisearch> |
@@ -1,2 +0,2 @@ | ||
import { Config, SearchResponse, SearchParams, IndexObject, IndexOptions, IndexStats, DocumentsQuery, DocumentQuery, DocumentOptions, Settings, Synonyms, StopWords, RankingRules, DistinctAttribute, FilterableAttributes, SortableAttributes, SearchableAttributes, DisplayedAttributes, TypoTolerance, WaitOptions, TasksQuery, TasksResults, PaginationSettings, Faceting, ResourceResults, RawDocumentAdditionOptions, ContentType, DocumentsIds, DocumentsDeletionQuery } from './types'; | ||
import { Config, SearchResponse, SearchParams, IndexObject, IndexOptions, IndexStats, DocumentsQuery, DocumentQuery, DocumentOptions, Settings, Synonyms, StopWords, RankingRules, DistinctAttribute, FilterableAttributes, SortableAttributes, SearchableAttributes, DisplayedAttributes, TypoTolerance, WaitOptions, TasksQuery, TasksResults, PaginationSettings, Faceting, ResourceResults, RawDocumentAdditionOptions, ContentType, DocumentsIds, DocumentsDeletionQuery, SearchForFacetValuesParams, SearchForFacetValuesResponse } from './types'; | ||
import { HttpRequests } from './http-requests'; | ||
@@ -37,2 +37,10 @@ import { Task, TaskClient } from './task'; | ||
/** | ||
* Search for facet values | ||
* | ||
* @param params - Parameters used to search on the facets | ||
* @param config - Additional request configuration options | ||
* @returns Promise containing the search response | ||
*/ | ||
searchForFacetValues(params: SearchForFacetValuesParams, config?: Partial<Request>): Promise<SearchForFacetValuesResponse>; | ||
/** | ||
* Get index information. | ||
@@ -410,3 +418,3 @@ * | ||
*/ | ||
getTypoTolerance(): Promise<string[]>; | ||
getTypoTolerance(): Promise<TypoTolerance>; | ||
/** | ||
@@ -413,0 +421,0 @@ * Update the typo tolerance settings. |
@@ -1,2 +0,2 @@ | ||
export declare const PACKAGE_VERSION = "0.33.0"; | ||
export declare const PACKAGE_VERSION = "0.35.0-v1.3.0-pre-release.0"; | ||
//# sourceMappingURL=package-version.d.ts.map |
@@ -48,2 +48,14 @@ import { Task } from '../task'; | ||
}; | ||
export type SearchForFacetValuesParams = Omit<SearchParams, 'facetName'> & { | ||
facetName: string; | ||
}; | ||
export type FacetHit = { | ||
value: string; | ||
count: number; | ||
}; | ||
export type SearchForFacetValuesResponse = { | ||
facetHits: FacetHit[]; | ||
facetQuery: string | null; | ||
processingTimeMs: number; | ||
}; | ||
export type SearchParams = Query & Pagination & Highlight & Crop & { | ||
@@ -58,2 +70,8 @@ filter?: Filter; | ||
page?: number; | ||
facetName?: string; | ||
facetQuery?: string; | ||
vector?: number[] | null; | ||
showRankingScore?: boolean; | ||
showRankingScoreDetails?: boolean; | ||
attributesToSearchOn?: string[] | null; | ||
}; | ||
@@ -68,2 +86,4 @@ export type SearchRequestGET = Pagination & Query & Omit<Highlight, 'attributesToHighlight'> & Omit<Crop, 'attributesToCrop'> & { | ||
showMatchesPosition?: boolean; | ||
vector?: string | null; | ||
attributesToSearchOn?: string | null; | ||
}; | ||
@@ -88,3 +108,35 @@ export type MultiSearchQuery = SearchParams & { | ||
_matchesPosition?: MatchesPosition<T>; | ||
_rankingScore?: number; | ||
_rankingScoreDetails?: RakingScoreDetails; | ||
}; | ||
export type RakingScoreDetails = { | ||
words?: { | ||
order: number; | ||
matchingWords: number; | ||
maxMatchingWords: number; | ||
score: number; | ||
}; | ||
typo?: { | ||
order: number; | ||
typoCount: number; | ||
maxTypoCount: number; | ||
score: number; | ||
}; | ||
proximity?: { | ||
order: number; | ||
score: number; | ||
}; | ||
attribute?: { | ||
order: number; | ||
attributes_ranking_order: number; | ||
attributes_query_word_order: number; | ||
score: number; | ||
}; | ||
exactness?: { | ||
order: number; | ||
matchType: string; | ||
score: number; | ||
}; | ||
[key: string]: Record<string, any> | undefined; | ||
}; | ||
export type Hits<T = Record<string, any>> = Array<Hit<T>>; | ||
@@ -102,2 +154,3 @@ export type FacetStat = { | ||
facetStats?: FacetStats; | ||
vector: number[]; | ||
} & (undefined extends S ? Partial<FinitePagination & InfinitePagination> : true extends IsFinitePagination<NonNullable<S>> ? FinitePagination : InfinitePagination); | ||
@@ -167,4 +220,6 @@ type FinitePagination = { | ||
} | null; | ||
export type FacetOrder = 'alpha' | 'count'; | ||
export type Faceting = { | ||
maxValuesPerFacet?: number | null; | ||
sortFacetValuesBy?: Record<string, FacetOrder> | null; | ||
}; | ||
@@ -265,2 +320,3 @@ export type PaginationSettings = { | ||
next: number; | ||
total: number; | ||
}; | ||
@@ -297,3 +353,3 @@ export type TasksResults = CursorResults<Task>; | ||
createdAt: Date; | ||
updateAt: Date; | ||
updatedAt: Date; | ||
}; | ||
@@ -371,6 +427,8 @@ export type KeyCreation = { | ||
INVALID_DOCUMENT_OFFSET = "invalid_document_offset", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_offset */ | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_filter */ | ||
INVALID_DOCUMENT_FILTER = "invalid_document_filter", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_offset */ | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_document_filter */ | ||
MISSING_DOCUMENT_FILTER = "missing_document_filter", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_vectors_field */ | ||
INVALID_DOCUMENT_VECTORS_FIELD = "invalid_document_vectors_field", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#payload_too_large */ | ||
@@ -426,2 +484,6 @@ PAYLOAD_TOO_LARGE = "payload_too_large", | ||
INVALID_SEARCH_MATCHING_STRATEGY = "invalid_search_matching_strategy", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_vector */ | ||
INVALID_SEARCH_VECTOR = "invalid_search_vector", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_search_on */ | ||
INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON = "invalid_search_attributes_to_search_on", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#bad_request */ | ||
@@ -546,3 +608,9 @@ BAD_REQUEST = "bad_request", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_api_key_offset */ | ||
INVALID_API_KEY_OFFSET = "invalid_api_key_offset" | ||
INVALID_API_KEY_OFFSET = "invalid_api_key_offset", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_facet_name */ | ||
INVALID_FACET_SEARCH_FACET_NAME = "invalid_facet_search_facet_name", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_facet_search_facet_name */ | ||
MISSING_FACET_SEARCH_FACET_NAME = "missing_facet_search_facet_name", | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_facet_query */ | ||
INVALID_FACET_SEARCH_FACET_QUERY = "invalid_facet_search_facet_query" | ||
} | ||
@@ -549,0 +617,0 @@ export type TokenIndexRules = { |
{ | ||
"name": "meilisearch", | ||
"version": "0.33.0", | ||
"version": "0.35.0-v1.3.0-pre-release.0", | ||
"description": "The Meilisearch JS client for Node.js and the browser.", | ||
@@ -76,5 +76,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/preset-env": "^7.22.4", | ||
"@babel/preset-env": "^7.22.5", | ||
"@rollup/plugin-babel": "^6.0.3", | ||
"@rollup/plugin-commonjs": "25.0.0", | ||
"@rollup/plugin-commonjs": "25.0.2", | ||
"@rollup/plugin-json": "^6.0.0", | ||
@@ -110,3 +110,3 @@ "@rollup/plugin-node-resolve": "15.1.0", | ||
"rollup-plugin-terser": "^7.0.0", | ||
"rollup-plugin-typescript2": "^0.34.1", | ||
"rollup-plugin-typescript2": "^0.35.0", | ||
"shx": "^0.3.2", | ||
@@ -113,0 +113,0 @@ "ts-jest": "^26.5.6", |
@@ -9,2 +9,3 @@ <p align="center"> | ||
<a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> | | ||
<a href="https://www.meilisearch.com/pricing?utm_campaign=oss&utm_source=integration&utm_medium=meilisearch-js">Meilisearch Cloud</a> | | ||
<a href="https://www.meilisearch.com/docs">Documentation</a> | | ||
@@ -34,2 +35,3 @@ <a href="https://discord.meilisearch.com">Discord</a> | | ||
- [📖 Documentation](#-documentation) | ||
- [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience) | ||
- [🔧 Installation](#-installation) | ||
@@ -48,2 +50,6 @@ - [🎬 Getting started](#-getting-started) | ||
## ⚡ Supercharge your Meilisearch experience | ||
Say goodbye to server deployment and manual updates with [Meilisearch Cloud](https://www.meilisearch.com/pricing?utm_campaign=oss&utm_source=integration&utm_medium=meilisearch-js). Get started with a 14-day free trial! No credit card required. | ||
## 🔧 Installation | ||
@@ -381,5 +387,5 @@ | ||
- **Manipulate documents**: see the [API references](https://www.meilisearch.com/docs/reference/api/documents) or read more about [documents](https://www.meilisearch.com/docs/learn/core_concepts/documents.html). | ||
- **Manipulate documents**: see the [API references](https://www.meilisearch.com/docs/reference/api/documents) or read more about [documents](https://www.meilisearch.com/docs/learn/core_concepts/documents). | ||
- **Search**: see the [API references](https://www.meilisearch.com/docs/reference/api/search) or follow our guide on [search parameters](https://www.meilisearch.com/docs/reference/api/search#search-parameters). | ||
- **Manage the indexes**: see the [API references](https://www.meilisearch.com/docs/reference/api/indexes) or read more about [indexes](https://www.meilisearch.com/docs/learn/core_concepts/indexes.html). | ||
- **Manage the indexes**: see the [API references](https://www.meilisearch.com/docs/reference/api/indexes) or read more about [indexes](https://www.meilisearch.com/docs/learn/core_concepts/indexes). | ||
- **Configure the index settings**: see the [API references](https://www.meilisearch.com/docs/reference/api/settings) or follow our guide on [settings parameters](https://www.meilisearch.com/docs/reference/api/settings#settings_parameters). | ||
@@ -419,2 +425,10 @@ | ||
### Search For Facet Values | ||
#### [Search for facet values](#) | ||
```ts | ||
client.index<T>('myIndex').searchForFacetValues(params: SearchForFacetValuesParams, config?: Partial<Request>): Promise<SearchForFacetValuesResponse> | ||
``` | ||
### Documents <!-- omit in toc --> | ||
@@ -490,3 +504,3 @@ | ||
#### [Get all tasks](https://www.meilisearch.com/docs/reference/api/tasks.html#get-all-tasks) | ||
#### [Get all tasks](https://www.meilisearch.com/docs/reference/api/tasks#get-all-tasks) | ||
@@ -503,3 +517,3 @@ ```ts | ||
#### [Delete tasks](https://www.meilisearch.com/docs/reference/api/tasks.html#delete-task) | ||
#### [Delete tasks](https://www.meilisearch.com/docs/reference/api/tasks#delete-tasks) | ||
@@ -510,3 +524,3 @@ ```ts | ||
#### [Cancel tasks](https://www.meilisearch.com/docs/reference/api/tasks.html#cancel-task) | ||
#### [Cancel tasks](https://www.meilisearch.com/docs/reference/api/tasks#cancel-tasks) | ||
@@ -517,3 +531,3 @@ ```ts | ||
#### [Get all tasks of an index](https://www.meilisearch.com/docs/reference/api/tasks.html#get-all-tasks-by-index) | ||
#### [Get all tasks of an index](https://www.meilisearch.com/docs/reference/api/tasks#get-all-tasks-by-index) | ||
@@ -631,3 +645,3 @@ ```ts | ||
#### [Get specific index stats](https://www.meilisearch.com/docs/reference/api/stats.html#get-stat-of-an-index) | ||
#### [Get specific index stats](https://www.meilisearch.com/docs/reference/api/stats#get-stats-of-an-index) | ||
@@ -898,3 +912,3 @@ ```ts | ||
#### [Get keys](https://www.meilisearch.com/docs/reference/api/keys.html#get-all-keys) | ||
#### [Get keys](https://www.meilisearch.com/docs/reference/api/keys#get-all-keys) | ||
@@ -905,3 +919,3 @@ ```ts | ||
#### [Get one key](https://www.meilisearch.com/docs/reference/api/keys.html#get-one-key) | ||
#### [Get one key](https://www.meilisearch.com/docs/reference/api/keys#get-one-key) | ||
@@ -912,3 +926,3 @@ ```ts | ||
#### [Create a key](https://www.meilisearch.com/docs/reference/api/keys.html#create-a-key) | ||
#### [Create a key](https://www.meilisearch.com/docs/reference/api/keys#create-a-key) | ||
@@ -919,3 +933,3 @@ ```ts | ||
#### [Update a key](https://www.meilisearch.com/docs/reference/api/keys.html#update-a-key) | ||
#### [Update a key](https://www.meilisearch.com/docs/reference/api/keys#update-a-key) | ||
@@ -926,3 +940,3 @@ ```ts | ||
#### [Delete a key](https://www.meilisearch.com/docs/reference/api/keys.html#delete-a-key) | ||
#### [Delete a key](https://www.meilisearch.com/docs/reference/api/keys#delete-a-key) | ||
@@ -935,3 +949,3 @@ ```ts | ||
#### [Return `true` or `false` depending on the health of the server](https://www.meilisearch.com/docs/reference/api/health.html#get-health) | ||
#### [Return `true` or `false` depending on the health of the server](https://www.meilisearch.com/docs/reference/api/health#get-health) | ||
@@ -944,3 +958,3 @@ ```ts | ||
#### [Check if the server is healthy](https://www.meilisearch.com/docs/reference/api/health.html#get-health) | ||
#### [Check if the server is healthy](https://www.meilisearch.com/docs/reference/api/health#get-health) | ||
@@ -953,3 +967,3 @@ ```ts | ||
#### [Get database stats](https://www.meilisearch.com/docs/reference/api/stats.html#get-stats-of-all-indexes) | ||
#### [Get database stats](https://www.meilisearch.com/docs/reference/api/stats#get-stats-of-all-indexes) | ||
@@ -962,3 +976,3 @@ ```ts | ||
#### [Get binary version](https://www.meilisearch.com/docs/reference/api/version.html#get-version-of-meilisearch) | ||
#### [Get binary version](https://www.meilisearch.com/docs/reference/api/version#get-version-of-meilisearch) | ||
@@ -971,3 +985,3 @@ ```ts | ||
#### [Trigger a dump creation process](https://www.meilisearch.com/docs/reference/api/dump.html#create-a-dump) | ||
#### [Trigger a dump creation process](https://www.meilisearch.com/docs/reference/api/dump#create-a-dump) | ||
@@ -974,0 +988,0 @@ ```ts |
@@ -323,3 +323,3 @@ /* | ||
createdAt: new Date(key.createdAt), | ||
updateAt: new Date(key.updateAt), | ||
updatedAt: new Date(key.updatedAt), | ||
})) | ||
@@ -326,0 +326,0 @@ |
@@ -48,2 +48,4 @@ /* | ||
DocumentsDeletionQuery, | ||
SearchForFacetValuesParams, | ||
SearchForFacetValuesResponse, | ||
} from './types' | ||
@@ -141,2 +143,4 @@ import { removeUndefinedFromObject } from './utils' | ||
attributesToHighlight: options?.attributesToHighlight?.join(','), | ||
vector: options?.vector?.join(','), | ||
attributesToSearchOn: options?.attributesToSearchOn?.join(','), | ||
} | ||
@@ -151,2 +155,23 @@ | ||
/** | ||
* Search for facet values | ||
* | ||
* @param params - Parameters used to search on the facets | ||
* @param config - Additional request configuration options | ||
* @returns Promise containing the search response | ||
*/ | ||
async searchForFacetValues( | ||
params: SearchForFacetValuesParams, | ||
config?: Partial<Request> | ||
): Promise<SearchForFacetValuesResponse> { | ||
const url = `indexes/${this.uid}/facet-search` | ||
return await this.httpRequest.post( | ||
url, | ||
removeUndefinedFromObject(params), | ||
undefined, | ||
config | ||
) | ||
} | ||
/// | ||
@@ -1023,5 +1048,5 @@ /// INDEX | ||
*/ | ||
async getTypoTolerance(): Promise<string[]> { | ||
async getTypoTolerance(): Promise<TypoTolerance> { | ||
const url = `indexes/${this.uid}/settings/typo-tolerance` | ||
return await this.httpRequest.get<string[]>(url) | ||
return await this.httpRequest.get<TypoTolerance>(url) | ||
} | ||
@@ -1028,0 +1053,0 @@ |
@@ -1,1 +0,1 @@ | ||
export const PACKAGE_VERSION = '0.33.0' | ||
export const PACKAGE_VERSION = '0.35.0-v1.3.0-pre-release.0' |
@@ -81,2 +81,18 @@ // Type definitions for meilisearch | ||
// `facetName` becomes mandatory when using `searchForFacetValues` | ||
export type SearchForFacetValuesParams = Omit<SearchParams, 'facetName'> & { | ||
facetName: string | ||
} | ||
export type FacetHit = { | ||
value: string | ||
count: number | ||
} | ||
export type SearchForFacetValuesResponse = { | ||
facetHits: FacetHit[] | ||
facetQuery: string | null | ||
processingTimeMs: number | ||
} | ||
export type SearchParams = Query & | ||
@@ -94,2 +110,8 @@ Pagination & | ||
page?: number | ||
facetName?: string | ||
facetQuery?: string | ||
vector?: number[] | null | ||
showRankingScore?: boolean | ||
showRankingScoreDetails?: boolean | ||
attributesToSearchOn?: string[] | null | ||
} | ||
@@ -110,2 +132,4 @@ | ||
showMatchesPosition?: boolean | ||
vector?: string | null | ||
attributesToSearchOn?: string | null | ||
} | ||
@@ -132,4 +156,37 @@ | ||
_matchesPosition?: MatchesPosition<T> | ||
_rankingScore?: number | ||
_rankingScoreDetails?: RakingScoreDetails | ||
} | ||
export type RakingScoreDetails = { | ||
words?: { | ||
order: number | ||
matchingWords: number | ||
maxMatchingWords: number | ||
score: number | ||
} | ||
typo?: { | ||
order: number | ||
typoCount: number | ||
maxTypoCount: number | ||
score: number | ||
} | ||
proximity?: { | ||
order: number | ||
score: number | ||
} | ||
attribute?: { | ||
order: number | ||
attributes_ranking_order: number | ||
attributes_query_word_order: number | ||
score: number | ||
} | ||
exactness?: { | ||
order: number | ||
matchType: string | ||
score: number | ||
} | ||
[key: string]: Record<string, any> | undefined | ||
} | ||
export type Hits<T = Record<string, any>> = Array<Hit<T>> | ||
@@ -149,2 +206,3 @@ | ||
facetStats?: FacetStats | ||
vector: number[] | ||
} & (undefined extends S | ||
@@ -263,5 +321,9 @@ ? Partial<FinitePagination & InfinitePagination> | ||
export type FacetOrder = 'alpha' | 'count' | ||
export type Faceting = { | ||
maxValuesPerFacet?: number | null | ||
sortFacetValuesBy?: Record<string, FacetOrder> | null | ||
} | ||
export type PaginationSettings = { | ||
@@ -408,2 +470,3 @@ maxTotalHits?: number | null | ||
next: number | ||
total: number | ||
} | ||
@@ -458,3 +521,3 @@ | ||
createdAt: Date | ||
updateAt: Date | ||
updatedAt: Date | ||
} | ||
@@ -567,8 +630,11 @@ | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_offset */ | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_filter */ | ||
INVALID_DOCUMENT_FILTER = 'invalid_document_filter', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_offset */ | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_document_filter */ | ||
MISSING_DOCUMENT_FILTER = 'missing_document_filter', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_document_vectors_field */ | ||
INVALID_DOCUMENT_VECTORS_FIELD = 'invalid_document_vectors_field', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#payload_too_large */ | ||
@@ -649,2 +715,8 @@ PAYLOAD_TOO_LARGE = 'payload_too_large', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_vector */ | ||
INVALID_SEARCH_VECTOR = 'invalid_search_vector', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_search_attributes_to_search_on */ | ||
INVALID_SEARCH_ATTRIBUTES_TO_SEARCH_ON = 'invalid_search_attributes_to_search_on', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#bad_request */ | ||
@@ -829,2 +901,11 @@ BAD_REQUEST = 'bad_request', | ||
INVALID_API_KEY_OFFSET = 'invalid_api_key_offset', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_facet_name */ | ||
INVALID_FACET_SEARCH_FACET_NAME = 'invalid_facet_search_facet_name', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#missing_facet_search_facet_name */ | ||
MISSING_FACET_SEARCH_FACET_NAME = 'missing_facet_search_facet_name', | ||
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_facet_query */ | ||
INVALID_FACET_SEARCH_FACET_QUERY = 'invalid_facet_search_facet_query', | ||
} | ||
@@ -831,0 +912,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
975
688939
14473