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

@meilisearch/instant-meilisearch

Package Overview
Dependencies
Maintainers
2
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@meilisearch/instant-meilisearch - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

6

dist/instant-meilisearch.cjs.js

@@ -129,9 +129,9 @@ 'use strict';

const searchInput = {
q: this.placeholderSearch && query === '' ? null : query,
q: query,
facetsDistribution: facets.length ? facets : undefined,
facetFilters: facetFilters,
facetFilters,
attributesToHighlight: this.attributesToHighlight,
attributesToCrop: attributesToSnippet,
filters,
limit,
limit: this.placeholderSearch === false && query === '' ? 0 : limit,
};

@@ -138,0 +138,0 @@ return removeUndefinedFromObject(searchInput)

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

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=t(require("meilisearch"));function i(t){return Object.keys(t).reduce((e,i)=>(void 0!==t[i]&&(e[i]=t[i]),e),{})}function s(t){return"string"==typeof t||t instanceof String}function a(t,e,i){let a=t||"";return e=e||"__ais-highlight__",i=i||"__/ais-highlight__",s(t)&&(a=t.replace(/<em>/g,e).replace(/<\/em>/g,i)),a.toString()}function r({formattedHit:t,highlightPreTag:e,highlightPostTag:i}){return Object.keys(t).reduce((s,r)=>(s[r]={value:a(t[r],e,i)},s),{})}function n(t,e,i,r){let n=t;return void 0!==e&&s(n)&&(n[0]===n[0].toLowerCase()&&!1===n.startsWith("<em>")&&(n=`${e}${n}`),!1==!!n.match(/[.!?]$/)&&(n=`${n}${e}`)),a(n,i,r)}function h({formattedHit:t,attributesToSnippet:e,snippetEllipsisText:i,highlightPreTag:s,highlightPostTag:a}){return void 0===e?null:(e=e.map(t=>t.split(":")[0]),Object.keys(t).reduce((r,h)=>(e.includes(h)&&(r[h]={value:n(t[h],i,s,a)}),r),{}))}module.exports=function(t,s,a={}){return{client:new e.default({host:t,apiKey:s}),attributesToHighlight:["*"],paginationTotalHits:a.paginationTotalHits||200,placeholderSearch:!1!==a.placeholderSearch,transformToMeiliSearchParams:function(t){const e=this.pagination?this.paginationTotalHits:this.hitsPerPage,{query:s,facets:a,facetFilters:r,attributesToSnippet:n,filters:h}=t;return i({q:this.placeholderSearch&&""===s?null:s,facetsDistribution:a.length?a:void 0,facetFilters:r,attributesToHighlight:this.attributesToHighlight,attributesToCrop:n,filters:h,limit:e})},parseHits:function(t,e){if(this.pagination){const i=e.page*this.hitsPerPage;t=t.splice(i,this.hitsPerPage)}return t.map(t=>{const i=t._formatted;return delete t._formatted,{...t,_highlightResult:r({formattedHit:i,...e}),_snippetResult:h({formattedHit:i,...e})}})},paginationParams:function(t,e){if(this.pagination){const i=t%this.hitsPerPage==0?0:1;return{nbPages:Math.floor(t/this.hitsPerPage)+i,page:e.page}}},parseMeiliSearchResponse:function(t,e,s){const{exhaustiveFacetsCount:a,exhaustiveNbHits:r,facetsDistribution:n,nbHits:h,processingTimeMs:o,query:u,hits:c}=e;return{results:[i({index:t,hitsPerPage:this.hitsPerPage,facets:n,exhaustiveFacetsCount:a,exhaustiveNbHits:r,nbHits:h,processingTimeMs:o,query:u,...this.paginationParams(c.length,s),hits:this.parseHits(c,s)})]}},search:async function(t){const e=t[0].params;this.pagination=void 0!==e.page,this.hitsPerPage=e.hitsPerPage||20;const i=this.transformToMeiliSearchParams(e),s=t[0].indexName,a=await this.client.getIndex(s).search(i.q,i);return this.parseMeiliSearchResponse(s,a,t[0].params)}}};
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var e=t(require("meilisearch"));function i(t){return Object.keys(t).reduce(((e,i)=>(void 0!==t[i]&&(e[i]=t[i]),e)),{})}function s(t){return"string"==typeof t||t instanceof String}function a(t,e,i){let a=t||"";return e=e||"__ais-highlight__",i=i||"__/ais-highlight__",s(t)&&(a=t.replace(/<em>/g,e).replace(/<\/em>/g,i)),a.toString()}function r({formattedHit:t,highlightPreTag:e,highlightPostTag:i}){return Object.keys(t).reduce(((s,r)=>(s[r]={value:a(t[r],e,i)},s)),{})}function n(t,e,i,r){let n=t;return void 0!==e&&s(n)&&(n[0]===n[0].toLowerCase()&&!1===n.startsWith("<em>")&&(n=`${e}${n}`),!1==!!n.match(/[.!?]$/)&&(n=`${n}${e}`)),a(n,i,r)}function h({formattedHit:t,attributesToSnippet:e,snippetEllipsisText:i,highlightPreTag:s,highlightPostTag:a}){return void 0===e?null:(e=e.map((t=>t.split(":")[0])),Object.keys(t).reduce(((r,h)=>(e.includes(h)&&(r[h]={value:n(t[h],i,s,a)}),r)),{}))}module.exports=function(t,s,a={}){return{client:new e.default({host:t,apiKey:s}),attributesToHighlight:["*"],paginationTotalHits:a.paginationTotalHits||200,placeholderSearch:!1!==a.placeholderSearch,transformToMeiliSearchParams:function(t){const e=this.pagination?this.paginationTotalHits:this.hitsPerPage,{query:s,facets:a,facetFilters:r,attributesToSnippet:n,filters:h}=t;return i({q:s,facetsDistribution:a.length?a:void 0,facetFilters:r,attributesToHighlight:this.attributesToHighlight,attributesToCrop:n,filters:h,limit:!1===this.placeholderSearch&&""===s?0:e})},parseHits:function(t,e){if(this.pagination){const i=e.page*this.hitsPerPage;t=t.splice(i,this.hitsPerPage)}return t.map((t=>{const i=t._formatted;return delete t._formatted,{...t,_highlightResult:r({formattedHit:i,...e}),_snippetResult:h({formattedHit:i,...e})}}))},paginationParams:function(t,e){if(this.pagination){const i=t%this.hitsPerPage==0?0:1;return{nbPages:Math.floor(t/this.hitsPerPage)+i,page:e.page}}},parseMeiliSearchResponse:function(t,e,s){const{exhaustiveFacetsCount:a,exhaustiveNbHits:r,facetsDistribution:n,nbHits:h,processingTimeMs:o,query:c,hits:u}=e;return{results:[i({index:t,hitsPerPage:this.hitsPerPage,facets:n,exhaustiveFacetsCount:a,exhaustiveNbHits:r,nbHits:h,processingTimeMs:o,query:c,...this.paginationParams(u.length,s),hits:this.parseHits(u,s)})]}},search:async function(t){const e=t[0].params;this.pagination=void 0!==e.page,this.hitsPerPage=e.hitsPerPage||20;const i=this.transformToMeiliSearchParams(e),s=t[0].indexName,a=await this.client.getIndex(s).search(i.q,i);return this.parseMeiliSearchResponse(s,a,t[0].params)}}};
//# sourceMappingURL=instant-meilisearch.cjs.min.js.map

@@ -123,9 +123,9 @@ import MeiliSearch from 'meilisearch';

const searchInput = {
q: this.placeholderSearch && query === '' ? null : query,
q: query,
facetsDistribution: facets.length ? facets : undefined,
facetFilters: facetFilters,
facetFilters,
attributesToHighlight: this.attributesToHighlight,
attributesToCrop: attributesToSnippet,
filters,
limit,
limit: this.placeholderSearch === false && query === '' ? 0 : limit,
};

@@ -132,0 +132,0 @@ return removeUndefinedFromObject(searchInput)

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

import t from"meilisearch";function e(t){return Object.keys(t).reduce((e,i)=>(void 0!==t[i]&&(e[i]=t[i]),e),{})}function i(t){return"string"==typeof t||t instanceof String}function s(t,e,s){let a=t||"";return e=e||"__ais-highlight__",s=s||"__/ais-highlight__",i(t)&&(a=t.replace(/<em>/g,e).replace(/<\/em>/g,s)),a.toString()}function a({formattedHit:t,highlightPreTag:e,highlightPostTag:i}){return Object.keys(t).reduce((a,r)=>(a[r]={value:s(t[r],e,i)},a),{})}function r(t,e,a,r){let n=t;return void 0!==e&&i(n)&&(n[0]===n[0].toLowerCase()&&!1===n.startsWith("<em>")&&(n=`${e}${n}`),!1==!!n.match(/[.!?]$/)&&(n=`${n}${e}`)),s(n,a,r)}function n({formattedHit:t,attributesToSnippet:e,snippetEllipsisText:i,highlightPreTag:s,highlightPostTag:a}){return void 0===e?null:(e=e.map(t=>t.split(":")[0]),Object.keys(t).reduce((n,h)=>(e.includes(h)&&(n[h]={value:r(t[h],i,s,a)}),n),{}))}export default function(i,s,r={}){return{client:new t({host:i,apiKey:s}),attributesToHighlight:["*"],paginationTotalHits:r.paginationTotalHits||200,placeholderSearch:!1!==r.placeholderSearch,transformToMeiliSearchParams:function(t){const i=this.pagination?this.paginationTotalHits:this.hitsPerPage,{query:s,facets:a,facetFilters:r,attributesToSnippet:n,filters:h}=t;return e({q:this.placeholderSearch&&""===s?null:s,facetsDistribution:a.length?a:void 0,facetFilters:r,attributesToHighlight:this.attributesToHighlight,attributesToCrop:n,filters:h,limit:i})},parseHits:function(t,e){if(this.pagination){const i=e.page*this.hitsPerPage;t=t.splice(i,this.hitsPerPage)}return t.map(t=>{const i=t._formatted;return delete t._formatted,{...t,_highlightResult:a({formattedHit:i,...e}),_snippetResult:n({formattedHit:i,...e})}})},paginationParams:function(t,e){if(this.pagination){const i=t%this.hitsPerPage==0?0:1;return{nbPages:Math.floor(t/this.hitsPerPage)+i,page:e.page}}},parseMeiliSearchResponse:function(t,i,s){const{exhaustiveFacetsCount:a,exhaustiveNbHits:r,facetsDistribution:n,nbHits:h,processingTimeMs:o,query:c,hits:g}=i;return{results:[e({index:t,hitsPerPage:this.hitsPerPage,facets:n,exhaustiveFacetsCount:a,exhaustiveNbHits:r,nbHits:h,processingTimeMs:o,query:c,...this.paginationParams(g.length,s),hits:this.parseHits(g,s)})]}},search:async function(t){const e=t[0].params;this.pagination=void 0!==e.page,this.hitsPerPage=e.hitsPerPage||20;const i=this.transformToMeiliSearchParams(e),s=t[0].indexName,a=await this.client.getIndex(s).search(i.q,i);return this.parseMeiliSearchResponse(s,a,t[0].params)}}}
import t from"meilisearch";function e(t){return Object.keys(t).reduce(((e,i)=>(void 0!==t[i]&&(e[i]=t[i]),e)),{})}function i(t){return"string"==typeof t||t instanceof String}function s(t,e,s){let a=t||"";return e=e||"__ais-highlight__",s=s||"__/ais-highlight__",i(t)&&(a=t.replace(/<em>/g,e).replace(/<\/em>/g,s)),a.toString()}function a({formattedHit:t,highlightPreTag:e,highlightPostTag:i}){return Object.keys(t).reduce(((a,r)=>(a[r]={value:s(t[r],e,i)},a)),{})}function r(t,e,a,r){let n=t;return void 0!==e&&i(n)&&(n[0]===n[0].toLowerCase()&&!1===n.startsWith("<em>")&&(n=`${e}${n}`),!1==!!n.match(/[.!?]$/)&&(n=`${n}${e}`)),s(n,a,r)}function n({formattedHit:t,attributesToSnippet:e,snippetEllipsisText:i,highlightPreTag:s,highlightPostTag:a}){return void 0===e?null:(e=e.map((t=>t.split(":")[0])),Object.keys(t).reduce(((n,h)=>(e.includes(h)&&(n[h]={value:r(t[h],i,s,a)}),n)),{}))}function h(i,s,r={}){return{client:new t({host:i,apiKey:s}),attributesToHighlight:["*"],paginationTotalHits:r.paginationTotalHits||200,placeholderSearch:!1!==r.placeholderSearch,transformToMeiliSearchParams:function(t){const i=this.pagination?this.paginationTotalHits:this.hitsPerPage,{query:s,facets:a,facetFilters:r,attributesToSnippet:n,filters:h}=t;return e({q:s,facetsDistribution:a.length?a:void 0,facetFilters:r,attributesToHighlight:this.attributesToHighlight,attributesToCrop:n,filters:h,limit:!1===this.placeholderSearch&&""===s?0:i})},parseHits:function(t,e){if(this.pagination){const i=e.page*this.hitsPerPage;t=t.splice(i,this.hitsPerPage)}return t.map((t=>{const i=t._formatted;return delete t._formatted,{...t,_highlightResult:a({formattedHit:i,...e}),_snippetResult:n({formattedHit:i,...e})}}))},paginationParams:function(t,e){if(this.pagination){const i=t%this.hitsPerPage==0?0:1;return{nbPages:Math.floor(t/this.hitsPerPage)+i,page:e.page}}},parseMeiliSearchResponse:function(t,i,s){const{exhaustiveFacetsCount:a,exhaustiveNbHits:r,facetsDistribution:n,nbHits:h,processingTimeMs:o,query:c,hits:g}=i;return{results:[e({index:t,hitsPerPage:this.hitsPerPage,facets:n,exhaustiveFacetsCount:a,exhaustiveNbHits:r,nbHits:h,processingTimeMs:o,query:c,...this.paginationParams(g.length,s),hits:this.parseHits(g,s)})]}},search:async function(t){const e=t[0].params;this.pagination=void 0!==e.page,this.hitsPerPage=e.hitsPerPage||20;const i=this.transformToMeiliSearchParams(e),s=t[0].indexName,a=await this.client.getIndex(s).search(i.q,i);return this.parseMeiliSearchResponse(s,a,t[0].params)}}}export default h;
//# sourceMappingURL=instant-meilisearch.esm.min.js.map

@@ -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 l(t){this.map={},t instanceof l?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 f(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=f(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=f(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}l.prototype.append=function(t,e){t=c(t),e=h(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},l.prototype.delete=function(t){delete this.map[c(t)]},l.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},l.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},l.prototype.set=function(t,e){this.map[c(t)]=h(e)},l.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},l.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},l.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},l.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},n&&(l.prototype[Symbol.iterator]=l.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 l(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 l(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 l(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 l(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 l,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=l,t.Request=w,t.Response=x),e.Headers=l,e.Request=w,e.Response=x,e.fetch=R}({})}("undefined"!=typeof self?self:t);var e=function(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.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}}(),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 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: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=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)},s&&(this.formData=function(){return this.text().then(m)}),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 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 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 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 p(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 p(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 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 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=p,t.Request=w,t.Response=x),e.Headers=p,e.Request=w,e.Response=x,e.fetch=R}({})}("undefined"!=typeof self?self:t);var e=function(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.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(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(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(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(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 l(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.baseUrl=t.host,this.url=new URL(this.baseUrl)}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(s,this.url),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 l(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}(),f=function(){function t(t,e){this.uid=e,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){return void 0===o&&(o="POST"),n(this,void 0,void 0,(function(){var n,a,c;return i(this,(function(i){switch(i.label){case 0:return n="/indexes/"+this.uid+"/search",a={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(a))];case 1:return[2,i.sent()];case 2:return"GET"!==o.toUpperCase()?[3,4]:(c=r(r({},a),{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(c))]);case 3:return[2,i.sent()];case 4:throw new s("method parameter should be either POST or GET")}}))}))},t.prototype.show=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.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateIndex=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,[4,this.httpRequest.put(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteIndex=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.getIndex=function(t){return new f(this.config,t)},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.createIndex(t,e)];case 1:return[2,n.sent()];case 2:if("index_already_exists"===(r=n.sent()).errorCode)return[2,this.getIndex(t)];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(){var n,s;return i(this,(function(i){switch(i.label){case 0:return n="/indexes",[4,this.httpRequest.post(n,r(r({},e),{uid:t}))];case 1:return s=i.sent(),[2,new f(this.config,s.uid)]}}))}))},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.setHealthy=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.put(t,{health:!0})];case 1:return[2,e.sent()]}}))}))},t.prototype.setUnhealthy=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.put(t,{health:!1})];case 1:return[2,e.sent()]}}))}))},t.prototype.changeHealthTo=function(t){return n(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return e="/health",[4,this.httpRequest.put(e,{health:t})];case 1:return[2,r.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}()}()}));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,filters:u}=t;return r({q:this.placeholderSearch&&""===n?null:n,facetsDistribution:i.length?i:void 0,facetFilters:s,attributesToHighlight:this.attributesToHighlight,attributesToCrop:o,filters:u,limit: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){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.getIndex(n).search(r.q,r);return this.parseMeiliSearchResponse(n,i,t[0].params)}}}}));
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 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=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 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,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){this.uid=e,this.httpRequest=new f(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.show=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.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateIndex=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,[4,this.httpRequest.put(e,t)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteIndex=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 f(t)}return t.prototype.getIndex=function(t){return new l(this.config,t)},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.createIndex(t,e)];case 1:return[2,n.sent()];case 2:if("index_already_exists"===(r=n.sent()).errorCode)return[2,this.getIndex(t)];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(){var n,s;return i(this,(function(i){switch(i.label){case 0:return n="/indexes",[4,this.httpRequest.post(n,r(r({},e),{uid:t}))];case 1:return s=i.sent(),[2,new l(this.config,s.uid)]}}))}))},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,filters:u}=t;return r({q:n,facetsDistribution:i.length?i:void 0,facetFilters:s,attributesToHighlight:this.attributesToHighlight,attributesToCrop:o,filters:u,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){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.getIndex(n).search(r.q,r);return this.parseMeiliSearchResponse(n,i,t[0].params)}}}}));
//# sourceMappingURL=instant-meilisearch.umd.min.js.map
{
"name": "@meilisearch/instant-meilisearch",
"version": "0.2.2",
"version": "0.2.3",
"private": false,

@@ -12,5 +12,7 @@ "description": "The search client to use MeiliSearch with InstantSearch.",

"test:demo:esm": "yarn --cwd examples/esm && yarn --cwd examples/esm start",
"build:playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue build",
"build:playground:react": "yarn --cwd ./playgrounds/react && yarn --cwd ./playgrounds/react build",
"test:all": "yarn test && yarn test:demo",
"lint": "eslint --ext .js,.ts,.tsx .",
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .",
"lint": "eslint --ext .js,.ts,.tsx,.vue .",
"lint:fix": "eslint --ext .js,.ts,.tsx,.vue --fix .",
"build": "rollup -c rollup.config.js && rollup --environment NODE_ENV:production -c rollup.config.js ",

@@ -35,28 +37,43 @@ "playground:vue": "yarn --cwd ./playgrounds/vue && yarn --cwd ./playgrounds/vue serve",

"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/meilisearch/instant-meilisearch.git"
},
"dependencies": {
"meilisearch": "^0.14.0"
"meilisearch": "^0.16.0"
},
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.10.4",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"babel-jest": "^26.1.0",
"eslint": "^7.5.0",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^4.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-standard": "^14.1.1",
"eslint-config-react-app": "^6.0.0",
"eslint-config-standard": "^16.0.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^24.0.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-vue": "^7.1.0",
"jest": "^26.1.0",
"jest-watch-typeahead": "^0.6.0",
"prettier": "2.1.1",
"prettier": "^2.0.0",
"regenerator-runtime": "^0.13.7",
"rollup": "^2.23.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-terser": "^7.0.0"
"rollup-plugin-terser": "^7.0.0",
"typescript": "^4.0.0"
}
}

@@ -9,6 +9,6 @@ <p align="center">

<a href="https://github.com/meilisearch/MeiliSearch">MeiliSearch</a> |
<a href="https://docs.meilisearch.com">Documentation</a> |
<a href="https://www.meilisearch.com">Website</a> |
<a href="https://blog.meilisearch.com">Blog</a> |
<a href="https://twitter.com/meilisearch">Twitter</a> |
<a href="https://docs.meilisearch.com">Documentation</a> |
<a href="https://docs.meilisearch.com/faq">FAQ</a>

@@ -23,2 +23,3 @@ </h4>

<a href="https://github.com/meilisearch/MeiliSearch/discussions" alt="Discussions"><img src="https://img.shields.io/badge/github-discussions-red" /></a>
<a href="https://app.bors.tech/repositories/28908"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
</p>

@@ -28,3 +29,3 @@

**MeiliSearch** is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, and synonyms are provided out-of-the-box.
**MeiliSearch** is a powerful, fast, open-source, easy to use and deploy search engine. Both searching and indexing are highly customizable. Features such as typo-tolerance, filters, facets, and synonyms are provided out-of-the-box.

@@ -65,9 +66,10 @@ This library is a plugin to establish the communication between your [MeiliSearch](https://github.com/meilisearch/MeiliSearch) instance and the open-source [InstantSearch](https://github.com/algolia/instantsearch.js) tools (powered by Algolia) for your front-end application.<br>

- `paginationTotalHits` (`200` by default): The total (and finite) number of hits you can browse during pagination.<br>
It means, by default, you can browse `paginationTotalHits / hitsPerPage = 200 / 20 = 10` pages during pagination.<br>
By default, `hitsPerPage` is set to `20` but it can be changed with [`InsantSearch.configure`](https://www.algolia.com/doc/api-reference/widgets/configure/js/#examples)<br>
If the pagination widget is not set, this parameter is ignored.
- `placeholderSearch` (`true` by default). Displays documents even when the query is empty.
- `paginationTotalHits` (`200` by default): The total (and finite) number of hits you can browse during pagination when using the [pagination widget](https://www.algolia.com/doc/api-reference/widgets/pagination/js/). If the pagination widget is not used, `paginationTotalHits` is ignored.<br>
Which means that, with a `paginationTotalHits` default value of 200, and `hitsPerPage` default value of 20, you can browse `paginationTotalHits / hitsPerPage` => `200 / 20 = 10` pages during pagination. Each of the 10 pages containing 20 results.<br>
The default value of `hitsPerPage` is set to `20` but it can be changed with [`InsantSearch.configure`](https://www.algolia.com/doc/api-reference/widgets/configure/js/#examples).<br>
āš ļø MeiliSearch is not designed for pagination and this can lead to performances issues, so the usage of the pagination widget is not encouraged. However, the `paginationTotalHits` parameter lets you implement this pagination with less performance issue as possible: depending on your dataset (the size of each document and the number of documents) you might decrease the value of `paginationTotalHits`.<br>
More information about MeiliSearch and the pagination [here](https://github.com/meilisearch/documentation/issues/561).
## Example with InstantSearch

@@ -147,6 +149,4 @@

This package is compatible with the following MeiliSearch versions:
This package only guarantees the compatibility with the [version v0.16.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.16.0).
- `v0.13.X`
## Development Workflow and Contributing

@@ -153,0 +153,0 @@

@@ -24,9 +24,9 @@ import MeiliSearch from 'meilisearch'

const searchInput = {
q: this.placeholderSearch && query === '' ? null : query,
q: query,
facetsDistribution: facets.length ? facets : undefined,
facetFilters: facetFilters,
facetFilters,
attributesToHighlight: this.attributesToHighlight,
attributesToCrop: attributesToSnippet,
filters,
limit,
limit: this.placeholderSearch === false && query === '' ? 0 : limit,
}

@@ -33,0 +33,0 @@ return removeUndefinedFromObject(searchInput)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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