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

meilisearch

Package Overview
Dependencies
Maintainers
4
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meilisearch - npm Package Compare versions

Comparing version 0.33.0-prototype-search-for-facet-values.0 to 0.33.0-prototype-search-for-facet-values.1

2

dist/bundles/meilisearch.esm.min.js

@@ -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-prototype-search-for-facet-values.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.searchForFacetValue=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="indexes/".concat(this.uid,"/facet-search"),[4,this.httpRequest.post(n,v(t),void 0,e)];case 1:return[2,i.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";var e={ALL:"all",LAST:"last"},n={COUNT:"error",ALPHA:"alpha"},i={JSON:"application/json",CSV:"text/csv",NDJSON:"application/x-ndjson"},r=function(t,e){return r=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])},r(t,e)};function s(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}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return o=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},o.apply(this,arguments)};function u(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 c(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 a=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 s(e,t),e}(Error),h=function(t){function e(e,n){var i=t.call(this,e.message)||this;return Object.setPrototypeOf(i,h.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,h),i}return s(e,t),e}(Error);function d(t){return u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new a(t.statusText,t,t.url);case 4:throw new h(e,t.status);case 5:return[2,t]}}))}))}function l(t,e,n){if("MeiliSearchApiError"!==t.name)throw new a(t.message,t,n,e);throw t}var f=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 s(e,t),e}(Error),p=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 s(e,t),e}(Error);function v(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 y(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 w(t){return u(this,void 0,void 0,(function(){return c(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 b(t){return Object.keys(t).reduce((function(e,n){var i,r,s,u=t[n];return void 0===u?e:Array.isArray(u)?o(o({},e),((i={})[n]=u.join(","),i)):u instanceof Date?o(o({},e),((r={})[n]=u.toISOString(),r)):o(o({},e),((s={})[n]=u,s))}),{})}function g(t){var e,n,i="X-Meilisearch-Client",r="Meilisearch JavaScript (v".concat("0.33.0-prototype-search-for-facet-values.1",")"),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 f('Meilisearch: The header "'.concat(i,'" should be an array of string(s).\n'));s[i]=r}return s}var q=function(){function t(t){this.headers=g(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 f("The provided host is not valid.")}var e}(t.host);this.url=new URL(e)}catch(t){throw new f("The provided host is not valid.")}}return t.prototype.request=function(t){var e,n=t.method,i=t.url,r=t.params,s=t.body,a=t.config,h=void 0===a?{}:a;return u(this,void 0,void 0,(function(){var t,u,a,f,p,v,y;return c(this,(function(c){switch(c.label){case 0:"undefined"==typeof fetch&&require("cross-fetch/polyfill"),t=new URL(i,this.url),r&&(u=new URLSearchParams,Object.keys(r).filter((function(t){return null!==r[t]})).map((function(t){return u.set(t,r[t])})),t.search=u.toString()),(null===(e=h.headers)||void 0===e?void 0:e["Content-Type"])||(s=JSON.stringify(s)),a=o(o({},this.headers),h.headers),c.label=1;case 1:return c.trys.push([1,6,,7]),f=this.httpClient?this.httpClient:fetch,p=f(t.toString(),o(o(o({},h),this.requestConfig),{method:n,body:s,headers:a})),this.httpClient?[4,p]:[3,3];case 2:return[2,c.sent()];case 3:return[4,p.then((function(t){return d(t)}))];case 4:return[4,c.sent().json().catch((function(){}))];case 5:return[2,c.sent()];case 6:return v=c.sent(),y=v.stack,l(v,y,t.toString()),[3,7];case 7:return[2]}}))}))},t.prototype.get=function(t,e,n){return u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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}(),m=function(t){this.taskUid=t.taskUid,this.indexUid=t.indexUid,this.status=t.status,this.type=t.type,this.enqueuedAt=new Date(t.enqueuedAt)},k=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)},A=function(){function t(t){this.httpRequest=new q(t)}return t.prototype.getTask=function(t){return u(this,void 0,void 0,(function(){var e,n;return c(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 k(n)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return"tasks",[4,this.httpRequest.get("tasks",b(t))];case 1:return e=n.sent(),[2,o(o({},e),{results:e.results.map((function(t){return new k(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,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){var e,n;return c(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,w(o)]:[2,n];case 3:return i.sent(),[3,1];case 4:throw new p("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,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){var e,n,i,s,u;return c(this,(function(c){switch(c.label){case 0:e=[],n=0,i=t,c.label=1;case 1:return n<i.length?(s=i[n],[4,this.waitForTask(s,{timeOutMs:r,intervalMs:o})]):[3,4];case 2:u=c.sent(),e.push(u),c.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},t.prototype.cancelTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return"tasks/cancel",[4,this.httpRequest.post("tasks/cancel",{},b(t))];case 1:return e=n.sent(),[2,new m(e)]}}))}))},t.prototype.deleteTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return"tasks",[4,this.httpRequest.delete("tasks",{},b(t))];case 1:return e=n.sent(),[2,new m(e)]}}))}))},t}(),x=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new q(t),this.tasks=new A(t)}return t.prototype.search=function(t,e,n){return u(this,void 0,void 0,(function(){var i;return c(this,(function(r){switch(r.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,y(o({q:t},e)),void 0,n)];case 1:return[2,r.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var i,r,s,a,h;return u(this,void 0,void 0,(function(){var u,d,l;return c(this,(function(c){switch(c.label){case 0:return u="indexes/".concat(this.uid,"/search"),d=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new f("The filter query parameter should be in string format when using searchGet")},l=o(o({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===(s=null==e?void 0:e.attributesToRetrieve)||void 0===s?void 0:s.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(u,y(l),n)];case 1:return[2,c.sent()]}}))}))},t.prototype.searchForFacetValues=function(t,e){return u(this,void 0,void 0,(function(){var n;return c(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/facet-search"),[4,this.httpRequest.post(n,y(t),void 0,e)];case 1:return[2,i.sent()]}}))}))},t.prototype.getRawInfo=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return u(this,void 0,void 0,(function(){var t;return c(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={}),u(this,void 0,void 0,(function(){var i;return c(this,(function(r){switch(r.label){case 0:return"indexes",[4,new q(n).post("indexes",o(o({},e),{uid:t}))];case 1:return i=r.sent(),[2,new m(i)]}}))}))},t.prototype.update=function(t){return u(this,void 0,void 0,(function(){var e,n;return c(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 u(this,void 0,void 0,(function(){var t,e;return c(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 m(e)]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(o(o({},t),{indexUids:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return u(this,void 0,void 0,(function(){return c(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,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:r,intervalMs:o})];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,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:r,intervalMs:o})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return u(this,void 0,void 0,(function(){var t;return c(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={}),u(this,void 0,void 0,(function(){var n,i,r;return c(this,(function(s){switch(s.label){case 0:if(void 0===(t=y(t)).filter)return[3,5];s.label=1;case 1:return s.trys.push([1,3,,4]),i="indexes/".concat(this.uid,"/documents/fetch"),[4,this.httpRequest.post(i,t)];case 2:return[2,s.sent()];case 3:throw((n=s.sent())instanceof a||n instanceof h)&&(n.message=v(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,o(o({},t),r))];case 6:return[2,s.sent()];case 7:return[2]}}))}))},t.prototype.getDocument=function(t,e){return u(this,void 0,void 0,(function(){var n,i;return c(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,y(o(o({},e),{fields:i})))];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return u(this,void 0,void 0,(function(){var n,i;return c(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 m(i)]}}))}))},t.prototype.addDocumentsFromString=function(t,e,n){return u(this,void 0,void 0,(function(){var i,r;return c(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 m(r)]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),u(this,void 0,void 0,(function(){var i,r,s,o;return c(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 u(this,void 0,void 0,(function(){var n,i;return c(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 m(i)]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),u(this,void 0,void 0,(function(){var i,r,s,o;return c(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 u(this,void 0,void 0,(function(){var i,r;return c(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 m(r)]}}))}))},t.prototype.deleteDocument=function(t){return u(this,void 0,void 0,(function(){var e,n;return c(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 u(this,void 0,void 0,(function(){var e,n,i,r,s;return c(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 m(r)];case 3:throw((s=o.sent())instanceof a&&e||s instanceof h)&&(s.message=v(s.message,"deleteDocuments")),s;case 4:return[2]}}))}))},t.prototype.deleteAllDocuments=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetPagination=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 m(e)]}}))}))},t.prototype.getSynonyms=function(){return u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetSynonyms=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetStopWords=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetRankingRules=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetDistinctAttribute=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetFilterableAttributes=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetSortableAttributes=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetSearchableAttributes=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetDisplayedAttributes=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 u(this,void 0,void 0,(function(){var t,e;return c(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 u(this,void 0,void 0,(function(){var t;return c(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 u(this,void 0,void 0,(function(){var e,n;return c(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 m(n)]}}))}))},t.prototype.resetFaceting=function(){return u(this,void 0,void 0,(function(){var t,e;return c(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 m(e)]}}))}))},t}(),R=function(){function t(t){this.config=t,this.httpRequest=new q(t),this.tasks=new A(t)}return t.prototype.index=function(t){return new x(this.config,t)},t.prototype.getIndex=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,new x(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){return[2,new x(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){var e,n,i=this;return c(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 x(i.config,t.uid,t.primaryKey)})),[2,o(o({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),u(this,void 0,void 0,(function(){return c(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={}),u(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,x.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),u(this,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,new x(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,new x(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return u(this,void 0,void 0,(function(){var e;return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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={}),u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:r,intervalMs:o})];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,o=void 0===s?50:s;return u(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:r,intervalMs:o})];case 1:return[2,e.sent()]}}))}))},t.prototype.cancelTasks=function(t){return u(this,void 0,void 0,(function(){return c(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={}),u(this,void 0,void 0,(function(){return c(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={}),u(this,void 0,void 0,(function(){var e;return c(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 o(o({},t),{createdAt:new Date(t.createdAt),updateAt:new Date(t.updateAt)})})),[2,e]}}))}))},t.prototype.getKey=function(t){return u(this,void 0,void 0,(function(){var e;return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){var n;return c(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 u(this,void 0,void 0,(function(){var e;return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){return c(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 u(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return"dumps",[4,this.httpRequest.post("dumps")];case 1:return t=e.sent(),[2,new m(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 T(t){return Buffer.from(JSON.stringify(t)).toString("base64")}var D=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 f("Meilisearch: The expiredAt field must be an instance of Date.");if(r.getTime()<Date.now())throw new f("Meilisearch: The expiresAt field must be a date in the future.")}if(e&&"object"!=typeof e&&!Array.isArray(e))throw new f("Meilisearch: The search rules added in the token generation must be of type array or object.");if(!i||"string"!=typeof i)throw new f("Meilisearch: The API key used for the token generation must exist and be of type string.");if(!n||"string"!=typeof n)throw new f("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 f("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=T({alg:"HS256",typ:"JWT"}).replace(/=/g,""),c=function(t){var e=t.searchRules,n=t.uid,i=t.expiresAt;return T({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}(),S=function(t){function e(e){var n=t.call(this,e)||this;return n.tokens=new D(e),n}return s(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}(R);export{i as ContentTypeEnum,m as EnqueuedTask,x as Index,e as MatchingStrategies,S as MeiliSearch,h as MeiliSearchApiError,a as MeiliSearchCommunicationError,f as MeiliSearchError,p as MeiliSearchTimeOutError,n as SortFacetValuesBy,k as Task,A as TaskClient,S as default,l as httpErrorHandler,d as httpResponseErrorHandler,v as versionErrorHintMessage};
//# sourceMappingURL=meilisearch.esm.min.js.map

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

!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-prototype-search-for-facet-values.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.searchForFacetValue=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/facet-search"),[4,this.httpRequest.post(n,f(t),void 0,e)];case 1:return[2,i.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";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-prototype-search-for-facet-values.1",")"),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.searchForFacetValues=function(t,e){return r(this,void 0,void 0,(function(){var n;return s(this,(function(i){switch(i.label){case 0:return n="indexes/".concat(this.uid,"/facet-search"),[4,this.httpRequest.post(n,f(t),void 0,e)];case 1:return[2,i.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.SortFacetValuesBy={COUNT:"error",ALPHA:"alpha"},t.default=R,t.httpErrorHandler=a,t.httpResponseErrorHandler=c,t.versionErrorHintMessage=l,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=meilisearch.umd.min.js.map

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

// Type definitions for meilisearch 0.33.0-prototype-search-for-facet-values.0
// Type definitions for meilisearch 0.33.0-prototype-search-for-facet-values.1
// Project: https://github.com/meilisearch/meilisearch-js

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

@@ -43,3 +43,3 @@ 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';

*/
searchForFacetValue(params: SearchForFacetValuesParams, config?: Partial<Request>): Promise<SearchForFacetValuesResponse>;
searchForFacetValues(params: SearchForFacetValuesParams, config?: Partial<Request>): Promise<SearchForFacetValuesResponse>;
/**

@@ -46,0 +46,0 @@ * Get index information.

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

export declare const PACKAGE_VERSION = "0.33.0-prototype-search-for-facet-values.0";
export declare const PACKAGE_VERSION = "0.33.0-prototype-search-for-facet-values.1";
//# sourceMappingURL=package-version.d.ts.map

@@ -48,2 +48,19 @@ import { Task } from '../task';

};
export declare const SortFacetValuesBy: {
COUNT: string;
ALPHA: string;
};
export type SortFacetValuesBy = typeof SortFacetValuesBy[keyof typeof SortFacetValuesBy];
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 +75,5 @@ filter?: Filter;

page?: number;
sortFacetValuesBy?: SortFacetValuesBy;
facetName?: string;
facetQuery?: string;
};

@@ -125,18 +145,2 @@ export type SearchRequestGET = Pagination & Query & Omit<Highlight, 'attributesToHighlight'> & Omit<Crop, 'attributesToCrop'> & {

};
export type SearchForFacetValuesParams = SearchParams & {
facetName: string;
facetQuery?: string;
q?: string;
filter?: Filter;
matchingStrategy?: MatchingStrategies;
};
export type FacetHit = {
value: string;
count: number;
};
export type SearchForFacetValuesResponse = {
hits: FacetHit[];
query: string | null;
processingTimeMs: number;
};
type Fields<T = Record<string, any>> = Array<Extract<keyof T, string>> | Extract<keyof T, string>;

@@ -555,3 +559,11 @@ export type DocumentOptions = {

/** @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#invalid_facet_search_query */
INVALID_FACET_SEARCH_QUERY = "invalid_facet_search_query",
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_name */
INVALID_FACET_SEARCH_NAME = "invalid_facet_search_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"
}

@@ -558,0 +570,0 @@ export type TokenIndexRules = {

{
"name": "meilisearch",
"version": "0.33.0-prototype-search-for-facet-values.0",
"version": "0.33.0-prototype-search-for-facet-values.1",
"description": "The Meilisearch JS client for Node.js and the browser.",

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

@@ -415,8 +415,8 @@ <p align="center">

### Search For Facet Value
### Search For Facet Values
#### [Search for facet value](#)
#### [Search for facet values](#)
```ts
client.index<T>('xxx').searchForFacetValue(params: SearchForFacetValuesParams, config?: Partial<Request>): Promise<SearchForFacetValuesResponse>
client.index<T>('xxx').searchForFacetValues(params: SearchForFacetValuesParams, config?: Partial<Request>): Promise<SearchForFacetValuesResponse>
```

@@ -423,0 +423,0 @@

@@ -158,3 +158,3 @@ /*

*/
async searchForFacetValue(
async searchForFacetValues(
params: SearchForFacetValuesParams,

@@ -161,0 +161,0 @@ config?: Partial<Request>

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

export const PACKAGE_VERSION = '0.33.0-prototype-search-for-facet-values.0'
export const PACKAGE_VERSION = '0.33.0-prototype-search-for-facet-values.1'

@@ -81,2 +81,24 @@ // Type definitions for meilisearch

export const SortFacetValuesBy = {
COUNT: 'error',
ALPHA: 'alpha',
}
export type SortFacetValuesBy = typeof SortFacetValuesBy[keyof typeof SortFacetValuesBy]
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 +116,5 @@ Pagination &

page?: number
sortFacetValuesBy?: SortFacetValuesBy
facetName?: string
facetQuery?: string
}

@@ -195,25 +220,2 @@

/*
* Facet search
*/
export type SearchForFacetValuesParams = SearchParams & {
facetName: string
facetQuery?: string
q?: string
filter?: Filter
matchingStrategy?: MatchingStrategies
}
export type FacetHit = {
value: string
count: number
}
export type SearchForFacetValuesResponse = {
hits: FacetHit[]
query: string | null
processingTimeMs: number
}
/*
** Documents

@@ -845,2 +847,14 @@ */

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#invalid_facet_search_query */
INVALID_FACET_SEARCH_QUERY = 'invalid_facet_search_query',
/** @see https://www.meilisearch.com/docs/reference/errors/error_codes#invalid_facet_search_name */
INVALID_FACET_SEARCH_NAME = 'invalid_facet_search_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',
}

@@ -847,0 +861,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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc