@meilisearch/instant-meilisearch
Advanced tools
Comparing version 0.2.6 to 0.2.7
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).instantMeiliSearch=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),s="FormData"in t,o="ArrayBuffer"in t;if(o)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function f(t){this.map={},t instanceof f?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function p(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function l(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=l(e);return e.readAsArrayBuffer(t),r}function v(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:s&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():o&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):o&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=p(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=p(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=l(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},s&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(t,e){t=c(t),e=h(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},f.prototype.delete=function(t){delete this.map[c(t)]},f.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},f.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},f.prototype.set=function(t,e){this.map[c(t)]=h(e)},f.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},f.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},f.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},f.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},n&&(f.prototype[Symbol.iterator]=f.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var r,n,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new f(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new f(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),g.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function x(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new f(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(x.prototype),x.prototype.clone=function(){return new x(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},x.error=function(){var t=new x(null,{status:0,statusText:""});return t.type="error",t};var T=[301,302,303,307,308];x.redirect=function(t,e){if(-1===T.indexOf(e))throw new RangeError("Invalid status code");return new x(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function R(t,r){return new Promise((function(n,s){var o=new w(t,r);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var u=new XMLHttpRequest;function a(){u.abort()}u.onload=function(){var t,e,r={status:u.status,statusText:u.statusText,headers:(t=u.getAllResponseHeaders()||"",e=new f,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in u?u.responseURL:r.headers.get("X-Request-URL");var i="response"in u?u.response:u.responseText;n(new x(i,r))},u.onerror=function(){s(new TypeError("Network request failed"))},u.ontimeout=function(){s(new TypeError("Network request failed"))},u.onabort=function(){s(new e.DOMException("Aborted","AbortError"))},u.open(o.method,o.url,!0),"include"===o.credentials?u.withCredentials=!0:"omit"===o.credentials&&(u.withCredentials=!1),"responseType"in u&&i&&(u.responseType="blob"),o.headers.forEach((function(t,e){u.setRequestHeader(e,t)})),o.signal&&(o.signal.addEventListener("abort",a),u.onreadystatechange=function(){4===u.readyState&&o.signal.removeEventListener("abort",a)}),u.send(void 0===o._bodyInit?null:o._bodyInit)}))}R.polyfill=!0,t.fetch||(t.fetch=R,t.Headers=f,t.Request=w,t.Response=x),e.Headers=f,e.Request=w,e.Response=x,e.fetch=R}({})}("undefined"!=typeof self?self:t);var e=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t,e){t.exports=function(){ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).instantMeiliSearch=e()}(this,(function(){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function l(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=l(e);return e.readAsArrayBuffer(t),r}function v(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=v(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=v(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=f(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=l(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(w)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(t,e){t=c(t),e=h(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},p.prototype.delete=function(t){delete this.map[c(t)]},p.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},p.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},p.prototype.set=function(t,e){this.map[c(t)]=h(e)},p.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},p.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},p.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},p.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},n&&(p.prototype[Symbol.iterator]=p.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function m(t,e){var r,n,i=(e=e||{}).body;if(t instanceof m){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new p(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new p(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),g.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function w(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}})),e}function R(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},b.call(m.prototype),b.call(R.prototype),R.prototype.clone=function(){return new R(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},R.error=function(){var t=new R(null,{status:0,statusText:""});return t.type="error",t};var S=[301,302,303,307,308];R.redirect=function(t,e){if(-1===S.indexOf(e))throw new RangeError("Invalid status code");return new R(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function C(t,r){return new Promise((function(n,o){var s=new m(t,r);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var u=new XMLHttpRequest;function a(){u.abort()}u.onload=function(){var t,e,r={status:u.status,statusText:u.statusText,headers:(t=u.getAllResponseHeaders()||"",e=new p,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}})),e)};r.url="responseURL"in u?u.responseURL:r.headers.get("X-Request-URL");var i="response"in u?u.response:u.responseText;n(new R(i,r))},u.onerror=function(){o(new TypeError("Network request failed"))},u.ontimeout=function(){o(new TypeError("Network request failed"))},u.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},u.open(s.method,s.url,!0),"include"===s.credentials?u.withCredentials=!0:"omit"===s.credentials&&(u.withCredentials=!1),"responseType"in u&&i&&(u.responseType="blob"),s.headers.forEach((function(t,e){u.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",a),u.onreadystatechange=function(){4===u.readyState&&s.signal.removeEventListener("abort",a)}),u.send(void 0===s._bodyInit?null:s._bodyInit)}))}C.polyfill=!0,t.fetch||(t.fetch=C,t.Headers=p,t.Request=m,t.Response=R),e.Headers=p,e.Request=m,e.Response=R,e.fetch=C}({})}("undefined"!=typeof self?self:t);var e=function(t){var e={exports:{}};return t(e,e.exports),e.exports}((function(t,e){t.exports=function(){ | ||
/*! ***************************************************************************** | ||
@@ -14,3 +14,3 @@ Copyright (c) Microsoft Corporation. | ||
***************************************************************************** */ | ||
var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};function e(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return(r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t,e,r,n){function i(t){return t instanceof r?t:new r((function(e){e(t)}))}return new(r||(r=Promise))((function(r,s){function o(t){try{a(n.next(t))}catch(t){s(t)}}function u(t){try{a(n.throw(t))}catch(t){s(t)}}function a(t){t.done?r(t.value):i(t.value).then(o,u)}a((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[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(t){return function(e){return a([t,e])}}function a(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}var s=function(t){function r(e){var n=t.call(this,e)||this;return n.name="MeiliSearchError",n.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(n,r),n}return e(r,t),r}(Error),o=function(t){function r(e){var n=t.call(this,e)||this;return n.name="MeiliSearchTimeOutError",n.type=n.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(n,r),n}return e(r,t),r}(Error);function u(t){return Object.entries(t).reduce((function(t,e){var r=e[0],n=e[1];return void 0!==n&&(t[r]=n),t}),{})}function a(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var c=function(t){function r(e,n){var i=t.call(this,e)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",n instanceof Response&&(i.message=n.statusText,i.statusCode=n.status),n instanceof Error&&(i.errno=n.errno,i.code=n.code),Error.captureStackTrace&&Error.captureStackTrace(i,r),i}return e(r,t),r}(Error),h=function(t){function r(e,r){var n=t.call(this,e.message)||this;return n.type="MeiliSearchApiError",n.name="MeiliSearchApiError",n.errorCode=e.errorCode,n.errorType=e.errorType,n.errorLink=e.errorLink,n.message=e.message,n.httpStatus=r,Error.captureStackTrace&&Error.captureStackTrace(n,h),n}return e(r,t),r}(Error);function d(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:if(t.ok)return[3,5];e=void 0,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,t.json()];case 2:return e=r.sent(),[3,4];case 3:throw r.sent(),new c(t.statusText,t);case 4:throw new h(e,t.status);case 5:return[2,t]}}))}))}function f(t){if("MeiliSearchApiError"!==t.type)throw new c(t.message,t);throw t}var p=function(){function t(t){this.headers=r(r(r({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=t.host}return t.prototype.request=function(t){var e=t.method,s=t.url,o=t.params,u=t.body,a=t.config;return n(this,void 0,void 0,(function(){var t,n,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),(t=new URL(this.url)).pathname=t.pathname+s,o&&(n=new URLSearchParams,Object.keys(o).filter((function(t){return null!==o[t]})).map((function(t){return n.set(t,o[t])})),t.search=n.toString()),[4,fetch(t.toString(),r(r({},a),{method:e,body:u?JSON.stringify(u):void 0,headers:this.headers})).then((function(t){return d(t)}))];case 1:return[4,i.sent().text()];case 2:c=i.sent();try{return[2,JSON.parse(c)]}catch(t){return[2]}return[3,4];case 3:return f(i.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,r){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:r})];case 1:return[2,n.sent()]}}))}))},t.prototype.post=function(t,e,r,s){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:r,config:s})];case 1:return[2,n.sent()]}}))}))},t.prototype.put=function(t,e,r,s){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:r,config:s})];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(t,e,r,s){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:r,config:s})];case 1:return[2,n.sent()]}}))}))},t}(),l=function(){function t(t,e,r){this.uid=e,this.primaryKey=r,this.httpRequest=new p(t)}return t.prototype.getUpdateStatus=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/updates/"+t,[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.waitForPendingUpdate=function(t,e){var r=void 0===e?{}:e,s=r.timeOutMs,u=void 0===s?5e3:s,c=r.intervalMs,h=void 0===c?50:c;return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:e=Date.now(),n.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(r=n.sent()).status?[2,r]:[4,a(h)];case 3:return n.sent(),[3,1];case 4:throw new o("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.getAllUpdateStatus=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/updates",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.search=function(t,e,o,a){return void 0===o&&(o="POST"),n(this,void 0,void 0,(function(){var n,c,h;return i(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/search",c={q:t,offset:null==e?void 0:e.offset,limit:null==e?void 0:e.limit,cropLength:null==e?void 0:e.cropLength,filters:null==e?void 0:e.filters,matches:null==e?void 0:e.matches,facetFilters:null==e?void 0:e.facetFilters,facetsDistribution:null==e?void 0:e.facetsDistribution,attributesToRetrieve:null==e?void 0:e.attributesToRetrieve,attributesToCrop:null==e?void 0:e.attributesToCrop,attributesToHighlight:null==e?void 0:e.attributesToHighlight},"POST"!==o.toUpperCase()?[3,2]:[4,this.httpRequest.post(n,u(c),void 0,a)];case 1:return[2,i.sent()];case 2:return"GET"!==o.toUpperCase()?[3,4]:(h=r(r({},c),{facetFilters:Array.isArray(null==e?void 0:e.facetFilters)&&(null==e?void 0:e.facetFilters)?JSON.stringify(e.facetFilters):void 0,facetsDistribution:(null==e?void 0:e.facetsDistribution)?JSON.stringify(e.facetsDistribution):void 0,attributesToRetrieve:(null==e?void 0:e.attributesToRetrieve)?e.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==e?void 0:e.attributesToCrop)?e.attributesToCrop.join(","):void 0,attributesToHighlight:(null==e?void 0:e.attributesToHighlight)?e.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(n,u(h),a)]);case 3:return[2,i.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},t.prototype.getRawInfo=function(){return n(this,void 0,void 0,(function(){var t,e;return i(this,(function(r){switch(r.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.get(t)];case 1:return e=r.sent(),this.primaryKey=e.primaryKey,[2,e]}}))}))},t.prototype.fetchInfo=function(){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(e,s,o){return void 0===o&&(o={}),n(this,void 0,void 0,(function(){var n,u;return i(this,(function(i){switch(i.label){case 0:return n="/indexes",[4,new p(e).post(n,r(r({},o),{uid:s}))];case 1:return u=i.sent(),[2,new t(e,s,u.primaryKey)]}}))}))},t.prototype.update=function(t){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return e="/indexes/"+this.uid,[4,this.httpRequest.put(e,t)];case 1:return r=n.sent(),this.primaryKey=r.primaryKey,[2,this]}}))}))},t.prototype.delete=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid,[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return n(this,void 0,void 0,(function(){var e,n;return i(this,(function(i){switch(i.label){case 0:return e="/indexes/"+this.uid+"/documents",void 0!==t&&Array.isArray(t.attributesToRetrieve)&&(n=t.attributesToRetrieve.join(",")),[4,this.httpRequest.get(e,r(r({},t),void 0!==n?{attributesToRetrieve:n}:{}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r="/indexes/"+this.uid+"/documents",[4,this.httpRequest.post(r,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateDocuments=function(t,e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r="/indexes/"+this.uid+"/documents",[4,this.httpRequest.put(r,t,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocument=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents/"+t,[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/documents/delete-batch",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteAllDocuments=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/documents",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSettings=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/settings",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.resetSettings=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.resetSynonyms=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/synonyms",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.resetStopWords=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/stop-words",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.resetRankingRules=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/ranking-rules",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/distinct-attribute",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getAttributesForFaceting=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateAttributesForFaceting=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.resetAttributesForFaceting=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/attributes-for-faceting",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/searchable-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.post(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/settings/displayed-attributes",[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}();return function(){function t(t){this.config=t,this.httpRequest=new p(t)}return t.prototype.index=function(t){return new l(this.config,t)},t.prototype.getIndex=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new l(this.config,t).fetchInfo()]}))}))},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getIndex(t)];case 1:return[2,n.sent()];case 2:if("index_not_found"===(r=n.sent()).errorCode)return[2,this.createIndex(t,e)];throw new h(r,r.status);case 3:return[2]}}))}))},t.prototype.listIndexes=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,l.create(this.config,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return i(this,(function(r){return[2,new l(this.config,t).update(e)]}))}))},t.prototype.deleteIndex=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new l(this.config,t).delete()]}))}))},t.prototype.getKeys=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/keys",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.isHealthy=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/health",[4,this.httpRequest.get(t).then((function(){return!0}))];case 1:return[2,e.sent()]}}))}))},t.prototype.stats=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.version=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/version",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createDump=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/dumps",[4,this.httpRequest.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDumpStatus=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/dumps/"+t+"/status",[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t}()}()}));function r(t){return Object.keys(t).reduce(((e,r)=>(void 0!==t[r]&&(e[r]=t[r]),e)),{})}function n(t){return"string"==typeof t||t instanceof String}function i(t,e,r){let i=t||"";return e=e||"__ais-highlight__",r=r||"__/ais-highlight__",n(t)&&(i=t.replace(/<em>/g,e).replace(/<\/em>/g,r)),i.toString()}function s({formattedHit:t,highlightPreTag:e,highlightPostTag:r}){return Object.keys(t).reduce(((n,s)=>(n[s]={value:i(t[s],e,r)},n)),{})}function o(t,e,r,s){let o=t;return void 0!==e&&n(o)&&(o[0]===o[0].toLowerCase()&&!1===o.startsWith("<em>")&&(o=`${e}${o}`),!1==!!o.match(/[.!?]$/)&&(o=`${o}${e}`)),i(o,r,s)}function u({formattedHit:t,attributesToSnippet:e,snippetEllipsisText:r,highlightPreTag:n,highlightPostTag:i}){return void 0===e?null:(e=e.map((t=>t.split(":")[0])),Object.keys(t).reduce(((s,u)=>(e.includes(u)&&(s[u]={value:o(t[u],r,n,i)}),s)),{}))}return function(t,n,i={}){return{client:new e({host:t,apiKey:n}),attributesToHighlight:["*"],paginationTotalHits:i.paginationTotalHits||200,placeholderSearch:!1!==i.placeholderSearch,transformToMeiliSearchParams:function(t){const e=this.pagination?this.paginationTotalHits:this.hitsPerPage,{query:n,facets:i,facetFilters:s,attributesToSnippet:o,attributesToRetrieve:u,filters:a}=t;return r({q:n,facetsDistribution:i.length?i:void 0,facetFilters:s,attributesToHighlight:this.attributesToHighlight,attributesToCrop:o,attributesToRetrieve:u,filters:a,limit:!1===this.placeholderSearch&&""===n?0:e})},parseHits:function(t,e){if(this.pagination){const r=e.page*this.hitsPerPage;t=t.splice(r,this.hitsPerPage)}return t.map((t=>{const r=t._formatted;return delete t._formatted,{...t,_highlightResult:s({formattedHit:r,...e}),_snippetResult:u({formattedHit:r,...e})}}))},paginationParams:function(t,e){if(this.pagination){const r=t%this.hitsPerPage==0?0:1;return{nbPages:Math.floor(t/this.hitsPerPage)+r,page:e.page}}},parseMeiliSearchResponse:function(t,e,n){const{exhaustiveFacetsCount:i,exhaustiveNbHits:s,facetsDistribution:o,nbHits:u,processingTimeMs:a,query:c,hits:h}=e;return{results:[r({index:t,hitsPerPage:this.hitsPerPage,facets:o,exhaustiveFacetsCount:i,exhaustiveNbHits:s,nbHits:u,processingTimeMs:a,query:c,...this.paginationParams(h.length,n),hits:this.parseHits(h,n)})]}},search:async function(t){try{const e=t[0].params;this.pagination=void 0!==e.page,this.hitsPerPage=e.hitsPerPage||20;const r=this.transformToMeiliSearchParams(e),n=t[0].indexName,i=await this.client.index(n).search(r.q,r);return await this.parseMeiliSearchResponse(n,i,t[0].params)}catch(t){throw console.error(t),new Error(t)}}}}})); | ||
var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(e,r)};function e(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}var r=function(){return(r=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function n(t,e,r,n){function i(t){return t instanceof r?t:new r((function(e){e(t)}))}return new(r||(r=Promise))((function(r,o){function s(t){try{a(n.next(t))}catch(t){o(t)}}function u(t){try{a(n.throw(t))}catch(t){o(t)}}function a(t){t.done?r(t.value):i(t.value).then(s,u)}a((n=n.apply(t,e||[])).next())}))}function i(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(t){return function(e){return a([t,e])}}function a(o){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}var o=function(t){function r(e){var n=t.call(this,e)||this;return n.name="MeiliSearchError",n.type="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(n,r),n}return e(r,t),r}(Error),s=function(t){function r(e){var n=t.call(this,e)||this;return n.name="MeiliSearchTimeOutError",n.type=n.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(n,r),n}return e(r,t),r}(Error);function u(t){return Object.entries(t).reduce((function(t,e){var r=e[0],n=e[1];return void 0!==n&&(t[r]=n),t}),{})}function a(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}var c=function(t){function r(e,n){var i=t.call(this,e)||this;return i.name="MeiliSearchCommunicationError",i.type="MeiliSearchCommunicationError",n instanceof Response&&(i.message=n.statusText,i.statusCode=n.status),n instanceof Error&&(i.errno=n.errno,i.code=n.code),Error.captureStackTrace&&Error.captureStackTrace(i,r),i}return e(r,t),r}(Error),h=function(t){function r(e,r){var n=t.call(this,e.message)||this;return n.type="MeiliSearchApiError",n.name="MeiliSearchApiError",n.errorCode=e.errorCode,n.errorType=e.errorType,n.errorLink=e.errorLink,n.message=e.message,n.httpStatus=r,Error.captureStackTrace&&Error.captureStackTrace(n,h),n}return e(r,t),r}(Error);function d(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:if(t.ok)return[3,5];e=void 0,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,t.json()];case 2:return e=r.sent(),[3,4];case 3:throw r.sent(),new c(t.statusText,t);case 4:throw new h(e,t.status);case 5:return[2,t]}}))}))}function p(t){if("MeiliSearchApiError"!==t.type)throw new c(t.message,t);throw t}var f=function(){function t(t){this.headers=r(r(r({},t.headers||{}),{"Content-Type":"application/json"}),t.apiKey?{"X-Meili-API-Key":t.apiKey}:{}),this.url=new URL(t.host)}return t.addTrailingSlash=function(t){return t.endsWith("/")||(t+="/"),t},t.prototype.request=function(t){var e=t.method,o=t.url,s=t.params,u=t.body,a=t.config;return n(this,void 0,void 0,(function(){var t,n,c;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),t=new URL(o,this.url),s&&(n=new URLSearchParams,Object.keys(s).filter((function(t){return null!==s[t]})).map((function(t){return n.set(t,s[t])})),t.search=n.toString()),[4,fetch(t.toString(),r(r({},a),{method:e,body:u?JSON.stringify(u):void 0,headers:this.headers})).then((function(t){return d(t)}))];case 1:return[4,i.sent().text()];case 2:c=i.sent();try{return[2,JSON.parse(c)]}catch(t){return[2]}return[3,4];case 3:return p(i.sent()),[3,4];case 4:return[2]}}))}))},t.prototype.get=function(t,e,r){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:r})];case 1:return[2,n.sent()]}}))}))},t.prototype.post=function(t,e,r,o){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:r,config:o})];case 1:return[2,n.sent()]}}))}))},t.prototype.put=function(t,e,r,o){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:r,config:o})];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(t,e,r,o){return n(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:r,config:o})];case 1:return[2,n.sent()]}}))}))},t}(),l=function(){function t(t,e,r){this.uid=e,this.primaryKey=r,this.httpRequest=new f(t)}return t.getApiRoutes=function(){return t.apiRoutes},t.getRouteConstructors=function(){return t.routeConstructors},t.prototype.getUpdateStatus=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.getUpdateStatus(this.uid,e),[4,this.httpRequest.get(r)];case 1:return[2,n.sent()]}}))}))},t.prototype.waitForPendingUpdate=function(t,e){var r=void 0===e?{}:e,o=r.timeOutMs,u=void 0===o?5e3:o,c=r.intervalMs,h=void 0===c?50:c;return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:e=Date.now(),n.label=1;case 1:return Date.now()-e<u?[4,this.getUpdateStatus(t)]:[3,4];case 2:return"enqueued"!==(r=n.sent()).status?[2,r]:[4,a(h)];case 3:return n.sent(),[3,1];case 4:throw new s("timeout of "+u+"ms has exceeded on process "+t+" when waiting for pending update to resolve.")}}))}))},t.prototype.getAllUpdateStatus=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getAllUpdateStatus(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.search=function(e,s,a,c){return void 0===a&&(a="POST"),n(this,void 0,void 0,(function(){var n,h,d;return i(this,(function(i){switch(i.label){case 0:return n=t.routeConstructors.search(this.uid),h={q:e,offset:null==s?void 0:s.offset,limit:null==s?void 0:s.limit,cropLength:null==s?void 0:s.cropLength,filters:null==s?void 0:s.filters,matches:null==s?void 0:s.matches,facetFilters:null==s?void 0:s.facetFilters,facetsDistribution:null==s?void 0:s.facetsDistribution,attributesToRetrieve:null==s?void 0:s.attributesToRetrieve,attributesToCrop:null==s?void 0:s.attributesToCrop,attributesToHighlight:null==s?void 0:s.attributesToHighlight},"POST"!==a.toUpperCase()?[3,2]:[4,this.httpRequest.post(n,u(h),void 0,c)];case 1:return[2,i.sent()];case 2:return"GET"!==a.toUpperCase()?[3,4]:(d=r(r({},h),{facetFilters:Array.isArray(null==s?void 0:s.facetFilters)&&(null==s?void 0:s.facetFilters)?JSON.stringify(s.facetFilters):void 0,facetsDistribution:(null==s?void 0:s.facetsDistribution)?JSON.stringify(s.facetsDistribution):void 0,attributesToRetrieve:(null==s?void 0:s.attributesToRetrieve)?s.attributesToRetrieve.join(","):void 0,attributesToCrop:(null==s?void 0:s.attributesToCrop)?s.attributesToCrop.join(","):void 0,attributesToHighlight:(null==s?void 0:s.attributesToHighlight)?s.attributesToHighlight.join(","):void 0}),[4,this.httpRequest.get(n,u(d),c)]);case 3:return[2,i.sent()];case 4:throw new o("method parameter should be either POST or GET")}}))}))},t.prototype.getRawInfo=function(){return n(this,void 0,void 0,(function(){var e,r;return i(this,(function(n){switch(n.label){case 0:return e=t.routeConstructors.indexRoute(this.uid),[4,this.httpRequest.get(e)];case 1:return r=n.sent(),this.primaryKey=r.primaryKey,[2,r]}}))}))},t.prototype.fetchInfo=function(){return n(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(e,o,s){return void 0===s&&(s={}),n(this,void 0,void 0,(function(){var n,u;return i(this,(function(i){switch(i.label){case 0:return n=t.apiRoutes.indexes,[4,new f(e).post(n,r(r({},s),{uid:o}))];case 1:return u=i.sent(),[2,new t(e,o,u.primaryKey)]}}))}))},t.prototype.update=function(e){return n(this,void 0,void 0,(function(){var r,n;return i(this,(function(i){switch(i.label){case 0:return r=t.routeConstructors.update(this.uid),[4,this.httpRequest.put(r,e)];case 1:return n=i.sent(),this.primaryKey=n.primaryKey,[2,this]}}))}))},t.prototype.delete=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.delete(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getStats=function(){return n(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t="/indexes/"+this.uid+"/stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(e){return n(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=t.routeConstructors.getDocuments(this.uid),void 0!==e&&Array.isArray(e.attributesToRetrieve)&&(o=e.attributesToRetrieve.join(",")),[4,this.httpRequest.get(n,r(r({},e),void 0!==o?{attributesToRetrieve:o}:{}))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.getDocument(this.uid,e),[4,this.httpRequest.get(r)];case 1:return[2,n.sent()]}}))}))},t.prototype.addDocuments=function(e,r){return n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return n=t.routeConstructors.addDocuments(this.uid),[4,this.httpRequest.post(n,e,r)];case 1:return[2,i.sent()]}}))}))},t.prototype.updateDocuments=function(e,r){return n(this,void 0,void 0,(function(){var n;return i(this,(function(i){switch(i.label){case 0:return n=t.routeConstructors.updateDocuments(this.uid),[4,this.httpRequest.put(n,e,r)];case 1:return[2,i.sent()]}}))}))},t.prototype.deleteDocument=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.deleteDocument(this.uid,e),[4,this.httpRequest.delete(r)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocuments=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.deleteDocuments(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteAllDocuments=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.deleteAllDocuments(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getSettings=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getSettings(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateSettings=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.updateSettings(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.resetSettings(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getSynonyms=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getSynonyms(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateSynonyms=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.updateSynonyms(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.resetSynonyms(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getStopWords=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getStopWords(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateStopWords=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.updateStopWords(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.resetStopWords(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getRankingRules=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getRankingRules(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateRankingRules=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.updateRankingRules(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.resetRankingRules(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getDistinctAttribute(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.updateDistinctAttribute(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.resetDistinctAttribute(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getAttributesForFaceting=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getAttributesForFaceting(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateAttributesForFaceting=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.updateAttributesForFaceting(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetAttributesForFaceting=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.resetAttributesForFaceting(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getSearchableAttributes(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.updateSearchableAttributes(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.resetSearchableAttributes(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.getDisplayedAttributes(this.uid),[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.updateDisplayedAttributes(this.uid),[4,this.httpRequest.post(r,e)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.routeConstructors.resetDisplayedAttributes(this.uid),[4,this.httpRequest.delete(e)];case 1:return[2,r.sent()]}}))}))},t.apiRoutes={indexes:"indexes"},t.routeConstructors={indexRoute:function(e){return t.apiRoutes.indexes+"/"+e},getUpdateStatus:function(e,r){return t.routeConstructors.indexRoute(e)+"/updates/"+r},getAllUpdateStatus:function(e){return t.routeConstructors.indexRoute(e)+"/updates"},search:function(e){return t.routeConstructors.indexRoute(e)+"/search"},getRawInfo:function(t){return"indexes/"+t},update:function(e){return t.routeConstructors.indexRoute(e)},delete:function(e){return t.routeConstructors.indexRoute(e)},getStats:function(e){return t.routeConstructors.indexRoute(e)+"/stats"},getDocument:function(e,r){return t.routeConstructors.indexRoute(e)+"/documents/"+r},getDocuments:function(e){return t.routeConstructors.indexRoute(e)+"/documents"},addDocuments:function(e){return t.routeConstructors.getDocuments(e)},updateDocuments:function(e){return t.routeConstructors.getDocuments(e)},deleteAllDocuments:function(e){return t.routeConstructors.getDocuments(e)},deleteDocument:function(e,r){return t.routeConstructors.indexRoute(e)+"/documents/"+r},deleteDocuments:function(e){return t.routeConstructors.indexRoute(e)+"/documents/delete-batch"},getSettings:function(e){return t.routeConstructors.indexRoute(e)+"/settings"},updateSettings:function(e){return t.routeConstructors.getSettings(e)},resetSettings:function(e){return t.routeConstructors.getSettings(e)},getSynonyms:function(e){return t.routeConstructors.indexRoute(e)+"/settings/synonyms"},updateSynonyms:function(e){return t.routeConstructors.getSynonyms(e)},resetSynonyms:function(e){return t.routeConstructors.getSynonyms(e)},getStopWords:function(e){return t.routeConstructors.indexRoute(e)+"/settings/stop-words"},updateStopWords:function(e){return t.routeConstructors.getStopWords(e)},resetStopWords:function(e){return t.routeConstructors.getStopWords(e)},getRankingRules:function(e){return t.routeConstructors.indexRoute(e)+"/settings/ranking-rules"},updateRankingRules:function(e){return t.routeConstructors.getRankingRules(e)},resetRankingRules:function(e){return t.routeConstructors.getRankingRules(e)},getDistinctAttribute:function(e){return t.routeConstructors.indexRoute(e)+"/settings/distinct-attribute"},updateDistinctAttribute:function(e){return t.routeConstructors.getDistinctAttribute(e)},resetDistinctAttribute:function(e){return t.routeConstructors.getDistinctAttribute(e)},getAttributesForFaceting:function(e){return t.routeConstructors.indexRoute(e)+"/settings/attributes-for-faceting"},updateAttributesForFaceting:function(e){return t.routeConstructors.getAttributesForFaceting(e)},resetAttributesForFaceting:function(e){return t.routeConstructors.getAttributesForFaceting(e)},getSearchableAttributes:function(e){return t.routeConstructors.indexRoute(e)+"/settings/searchable-attributes"},updateSearchableAttributes:function(e){return t.routeConstructors.getSearchableAttributes(e)},resetSearchableAttributes:function(e){return t.routeConstructors.getSearchableAttributes(e)},getDisplayedAttributes:function(e){return t.routeConstructors.indexRoute(e)+"/settings/displayed-attributes"},updateDisplayedAttributes:function(e){return t.routeConstructors.getDisplayedAttributes(e)},resetDisplayedAttributes:function(e){return t.routeConstructors.getDisplayedAttributes(e)}},t}();return function(){function t(t){t.host=f.addTrailingSlash(t.host),this.config=t,this.httpRequest=new f(t)}return t.getApiRoutes=function(){return t.apiRoutes},t.getRouteConstructors=function(){return t.routeConstructors},t.prototype.index=function(t){return new l(this.config,t)},t.prototype.getIndex=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new l(this.config,t).fetchInfo()]}))}))},t.prototype.getOrCreateIndex=function(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getIndex(t)];case 1:return[2,n.sent()];case 2:if("index_not_found"===(r=n.sent()).errorCode)return[2,this.createIndex(t,e)];throw new h(r,r.status);case 3:return[2]}}))}))},t.prototype.listIndexes=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.apiRoutes.listIndexes,[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,l.create(this.config,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),n(this,void 0,void 0,(function(){return i(this,(function(r){return[2,new l(this.config,t).update(e)]}))}))},t.prototype.deleteIndex=function(t){return n(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new l(this.config,t).delete()]}))}))},t.prototype.getKeys=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.apiRoutes.getKeys,[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.isHealthy=function(){return n(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.httpRequest.get(t.apiRoutes.isHealthy).then((function(){return!0}))];case 1:return[2,e.sent()]}}))}))},t.prototype.stats=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.apiRoutes.stats,[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.version=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.apiRoutes.version,[4,this.httpRequest.get(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.createDump=function(){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e=t.apiRoutes.createDump,[4,this.httpRequest.post(e)];case 1:return[2,r.sent()]}}))}))},t.prototype.getDumpStatus=function(e){return n(this,void 0,void 0,(function(){var r;return i(this,(function(n){switch(n.label){case 0:return r=t.routeConstructors.getDumpStatus(e),[4,this.httpRequest.get(r)];case 1:return[2,n.sent()]}}))}))},t.apiRoutes={listIndexes:"indexes",getkeys:"keys",isHealthy:"health",stats:"stats",version:"version",createDump:"dumps"},t.routeConstructors={getDumpStatus:function(t){return"dumps/"+t+"/status"}},t}()}()}));function r(t){return Object.keys(t).reduce(((e,r)=>(void 0!==t[r]&&(e[r]=t[r]),e)),{})}function n(t){return"string"==typeof t||t instanceof String}function i(t,e,r){let i=t||"";return e=e||"__ais-highlight__",r=r||"__/ais-highlight__",n(t)&&(i=t.replace(/<em>/g,e).replace(/<\/em>/g,r)),i.toString()}function o({formattedHit:t,highlightPreTag:e,highlightPostTag:r}){return Object.keys(t).reduce(((n,o)=>(n[o]={value:i(t[o],e,r)},n)),{})}function s(t,e,r,o){let s=t;return void 0!==e&&n(s)&&(s[0]===s[0].toLowerCase()&&!1===s.startsWith("<em>")&&(s=`${e}${s}`),!1==!!s.match(/[.!?]$/)&&(s=`${s}${e}`)),i(s,r,o)}function u({formattedHit:t,attributesToSnippet:e,snippetEllipsisText:r,highlightPreTag:n,highlightPostTag:i}){return void 0===e?null:(e=e.map((t=>t.split(":")[0])),Object.keys(t).reduce(((o,u)=>(e.includes(u)&&(o[u]={value:s(t[u],r,n,i)}),o)),{}))}return function(t,n,i={}){return{client:new e({host:t,apiKey:n}),attributesToHighlight:["*"],paginationTotalHits:i.paginationTotalHits||200,placeholderSearch:!1!==i.placeholderSearch,transformToMeiliSearchParams:function(t){const e=this.pagination?this.paginationTotalHits:this.hitsPerPage,{query:n,facets:i,facetFilters:o,attributesToSnippet:s,attributesToRetrieve:u,filters:a}=t;return r({q:n,facetsDistribution:i.length?i:void 0,facetFilters:o,attributesToHighlight:this.attributesToHighlight,attributesToCrop:s,attributesToRetrieve:u,filters:a,limit:!1===this.placeholderSearch&&""===n?0:e})},parseHits:function(t,e){if(this.pagination){const r=e.page*this.hitsPerPage;t=t.splice(r,this.hitsPerPage)}return t.map((t=>{const r=t._formatted;return delete t._formatted,{...t,_highlightResult:o({formattedHit:r,...e}),_snippetResult:u({formattedHit:r,...e})}}))},paginationParams:function(t,e){if(this.pagination){const r=t%this.hitsPerPage==0?0:1;return{nbPages:Math.floor(t/this.hitsPerPage)+r,page:e.page}}},parseMeiliSearchResponse:function(t,e,n){const{exhaustiveFacetsCount:i,exhaustiveNbHits:o,facetsDistribution:s,nbHits:u,processingTimeMs:a,query:c,hits:h}=e;return{results:[r({index:t,hitsPerPage:this.hitsPerPage,facets:s,exhaustiveFacetsCount:i,exhaustiveNbHits:o,nbHits:u,processingTimeMs:a,query:c,...this.paginationParams(h.length,n),hits:this.parseHits(h,n)})]}},search:async function(t){try{const e=t[0].params;this.pagination=void 0!==e.page,this.hitsPerPage=e.hitsPerPage||20;const r=this.transformToMeiliSearchParams(e),n=t[0].indexName,i=await this.client.index(n).search(r.q,r);return await this.parseMeiliSearchResponse(n,i,t[0].params)}catch(t){throw console.error(t),new Error(t)}}}}})); | ||
//# sourceMappingURL=instant-meilisearch.umd.min.js.map |
{ | ||
"name": "@meilisearch/instant-meilisearch", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"private": false, | ||
@@ -8,9 +8,11 @@ "description": "The search client to use MeiliSearch with InstantSearch.", | ||
"test": "jest", | ||
"test:demo": "yarn build && yarn test:demo:browser && yarn test:demo:nodejs && yarn test:demo:esm", | ||
"test:demo:browser": "yarn --cwd examples/express && yarn --cwd examples/express test", | ||
"test:demo:nodejs": "node examples/node/index.js", | ||
"test:demo:esm": "yarn --cwd examples/esm && yarn --cwd examples/esm start", | ||
"test:env": "yarn build && yarn test:env:browser && yarn test:env:nodejs && yarn test:env:esm", | ||
"test:env:browser": "yarn --cwd tests/env/express && yarn --cwd tests/env/express test", | ||
"test:env:nodejs": "node tests/env/node/index.js", | ||
"test:env:esm": "yarn --cwd tests/env/esm && yarn --cwd tests/env/esm start", | ||
"test:playgrounds": "yarn build:playground:vue && yarn build:playground:react && yarn build:playground:javascript && yarn build:playground:html", | ||
"build:playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue build", | ||
"build:playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react build", | ||
"build:playground:vanilla-js": "yarn --cwd ./playgrounds/vanilla-js && yarn --cwd ./playgrounds/vanilla-js build", | ||
"build:playground:javascript": "yarn --cwd ./playgrounds/javascript && yarn --cwd ./playgrounds/javascript build", | ||
"build:playground:html": "yarn --cwd ./playgrounds/html && yarn --cwd ./playgrounds/html build", | ||
"test:all": "yarn test && yarn test:demo", | ||
@@ -22,3 +24,4 @@ "lint": "eslint --ext .js,.ts,.tsx,.vue .", | ||
"playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react start", | ||
"playground:vanilla-js": "yarn --cwd ./playgrounds/vanilla-js && yarn --cwd ./playgrounds/vanilla-js start" | ||
"playground:javascript": "yarn --cwd ./playgrounds/javascript && yarn --cwd ./playgrounds/javascript start", | ||
"playground:html": "yarn --cwd ./playgrounds/html && yarn --cwd ./playgrounds/html start" | ||
}, | ||
@@ -31,3 +34,4 @@ "main": "./dist/instant-meilisearch.umd.js", | ||
"dist", | ||
"src" | ||
"src", | ||
"templates" | ||
], | ||
@@ -46,3 +50,3 @@ "keywords": [ | ||
"dependencies": { | ||
"meilisearch": "^0.17.0" | ||
"meilisearch": "^0.17.1" | ||
}, | ||
@@ -55,8 +59,9 @@ "devDependencies": { | ||
"@rollup/plugin-node-resolve": "^11.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.0.0", | ||
"@typescript-eslint/parser": "^4.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.14.0", | ||
"@typescript-eslint/parser": "^4.14.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-jest": "^26.1.0", | ||
"cssnano": "^4.1.10", | ||
"eslint": "^7.13.0", | ||
"eslint-config-prettier": "^7.0.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-config-react-app": "^6.0.0", | ||
@@ -74,3 +79,3 @@ "eslint-config-standard": "^16.0.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"eslint-plugin-vue": "^7.1.0", | ||
"eslint-plugin-vue": "^7.5.0", | ||
"jest": "^26.1.0", | ||
@@ -80,3 +85,3 @@ "jest-watch-typeahead": "^0.6.0", | ||
"regenerator-runtime": "^0.13.7", | ||
"rollup": "^2.23.0", | ||
"rollup": "^2.38.0", | ||
"rollup-plugin-babel": "^4.4.0", | ||
@@ -83,0 +88,0 @@ "rollup-plugin-terser": "^7.0.0", |
@@ -38,2 +38,14 @@ <p align="center"> | ||
## Installation | ||
Use `npm` or `yarn` to install `instant-meilisearch`: | ||
```bash | ||
$ npm install @meilisearch/instant-meilisearch | ||
``` | ||
```bash | ||
$ yarn add @meilisearch/instant-meilisearch | ||
``` | ||
## Usage | ||
@@ -44,2 +56,4 @@ | ||
```js | ||
import instantMeiliSearch from "@meilisearch/instant-meilisearch"; | ||
const searchClient = instantMeiliSearch( | ||
@@ -54,2 +68,4 @@ "https://demos.meilisearch.com", | ||
```js | ||
import instantMeiliSearch from "@meilisearch/instant-meilisearch"; | ||
const searchClient = instantMeiliSearch( | ||
@@ -56,0 +72,0 @@ "https://demos.meilisearch.com", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
324812
16
3666
171
33
Updatedmeilisearch@^0.17.1