Socket
Socket
Sign inDemoInstall

@meilisearch/instant-meilisearch

Package Overview
Dependencies
Maintainers
5
Versions
74
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.14.0 to 0.15.0

31

dist/instant-meilisearch.cjs.js

@@ -243,4 +243,2 @@ 'use strict';

}
// Matches first occurrence of an operator
var numericSplitRegExp = /(?<!(?:[<!>]?=|<|>|:).*)([<!>]?=|<|>|:)/;
/**

@@ -261,5 +259,17 @@ * Transform InstantSearch [numeric filter](https://www.algolia.com/doc/api-reference/api-parameters/numericFilters/)

function transformNumericFilter(filter) {
// TODO: Warn users to not enable facet values escape for negative numbers.
// https://github.com/algolia/instantsearch/blob/da701529ed325bb7a1d782e80cb994711e20d94a/packages/instantsearch.js/src/lib/utils/escapeFacetValue.ts#L13-L21
var _a = filter.split(numericSplitRegExp), attribute = _a[0], operator = _a[1], value = _a[2];
var splitNumericFilter = function () {
var attributeMatch = filter.match(/^([^<!>:=]*)([<!>:=]+)(.*)$/);
if (attributeMatch) {
var _a = attributeMatch.slice(1), attribute_1 = _a[0], dirtyOperator = _a[1], valueEnd = _a[2];
var operatorMatch = dirtyOperator.match(/^([<!>]?=|<|>|:){1}(.*)/) || [
'',
'',
];
var _b = operatorMatch.slice(1), operator_1 = _b[0], valueStart = _b[1];
var cleanedValue = valueStart + valueEnd;
return [attribute_1, operator_1, cleanedValue];
}
return [filter, '', ''];
};
var _a = splitNumericFilter(), attribute = _a[0], operator = _a[1], value = _a[2];
var escapedAttribute = getValueWithEscapedBackslashesAndQuotes(attribute);

@@ -835,4 +845,9 @@ return "\"".concat(escapedAttribute.trim(), "\"").concat(operator === ':' ? ' ' : operator).concat(value.trim());

return [];
var sortRules = sortStr.split(/,(?=\w+:(?:asc|desc))/);
return sortRules;
var regex = /[^:]+:(?:asc|desc)/g;
var sortRules = [];
var match;
while ((match = regex.exec(sortStr)) !== null) {
sortRules.push(match[0]);
}
return sortRules.map(function (str) { return str.replace(/^,+|,+$/, ''); });
}

@@ -978,3 +993,3 @@

var PACKAGE_VERSION = '0.14.0';
var PACKAGE_VERSION = '0.15.0';

@@ -981,0 +996,0 @@ var constructClientAgents = function (clientAgents) {

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("meilisearch"),e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function i(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}"function"==typeof SuppressedError&&SuppressedError;var a=/([\\"])/g;function o(t){return t.replace(a,"\\$1")}function u(t){var e=o(t),n=e.indexOf(":"),r=e.slice(0,n),i=e.slice(n+1);return'"'.concat(r,'"="').concat(i,'"')}var c=/(?<!(?:[<!>]?=|<|>|:).*)([<!>]?=|<|>|:)/;function s(t){var e=t.split(c),n=e[0],r=e[1],i=e[2],a=o(n);return'"'.concat(a.trim(),'"').concat(":"===r?" ":r).concat(i.trim())}function l(t,e){return"string"==typeof e?t(e):e.map((function(e){return"string"==typeof e?t(e):e.map((function(e){return t(e)}))}))}function d(t){return"string"==typeof t?[t]:t}function f(t,e,n){return function(t,e,n){var r=d(e),i=d(n),a=[];return void 0!==t&&a.push(t),void 0!==r&&a.push.apply(a,r),void 0!==i&&a.push.apply(a,i),a}(t,void 0!==e?l(s,e):e,void 0!==n?l(u,n):n)}function h(t){var e=t.query,n=t.indexUid,r=t.facets,i=t.attributesToSnippet,a=t.snippetEllipsisText,o=t.filters,u=t.numericFilters,c=t.facetFilters,s=t.attributesToRetrieve,l=t.attributesToHighlight,d=t.highlightPreTag,h=t.highlightPostTag,g=t.placeholderSearch,p=t.pagination,v=t.sort,y=t.restrictSearchableAttributes,m=t.meiliSearchParams,b={indexUid:n},P=f(o,u,c);return{getParams:function(){return b},addQuery:function(){b.q=e},addFacets:function(){var t=r;void 0!==t&&(b.facets="string"==typeof t?[t]:t)},addAttributesToCrop:function(){var t,e=null!==(t=null==m?void 0:m.attributesToCrop)&&void 0!==t?t:i;void 0!==e&&(b.attributesToCrop=e)},addCropLength:function(){var t=null==m?void 0:m.cropLength;void 0!==t&&(b.cropLength=t)},addCropMarker:function(){var t,e=null!==(t=null==m?void 0:m.cropMarker)&&void 0!==t?t:a;void 0!==e&&(b.cropMarker=e)},addFilters:function(){P.length&&(b.filter=P)},addAttributesToRetrieve:function(){var t,e=null!==(t=null==m?void 0:m.attributesToRetrieve)&&void 0!==t?t:s;void 0!==e&&(b.attributesToRetrieve=e)},addAttributesToHighlight:function(){var t,e;b.attributesToHighlight=null!==(e=null!==(t=null==m?void 0:m.attributesToHighlight)&&void 0!==t?t:l)&&void 0!==e?e:["*"]},addPreTag:function(){var t,e;b.highlightPreTag=null!==(e=null!==(t=null==m?void 0:m.highlightPreTag)&&void 0!==t?t:d)&&void 0!==e?e:"__ais-highlight__"},addPostTag:function(){var t,e;b.highlightPostTag=null!==(e=null!==(t=null==m?void 0:m.highlightPostTag)&&void 0!==t?t:h)&&void 0!==e?e:"__/ais-highlight__"},addPagination:function(){var t=function(t,e,n){return!!(n||e||t&&0!==t.length)}(P,e,g);if(p.finite){var n=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{hitsPerPage:r,page:n+1}:{hitsPerPage:0,page:n+1}}(p,t),r=n.hitsPerPage,i=n.page;b.hitsPerPage=r,b.page=i}else{var a=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{limit:r+1,offset:n*r}:{limit:0,offset:0}}(p,t),o=a.limit,u=a.offset;b.limit=o,b.offset=u}},addSort:function(){(null==v?void 0:v.length)&&(b.sort=Array.isArray(v)?v:[v])},addGeoSearchFilter:function(){var e=function(t){var e,n,r,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var c=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[g=c[0],p=c[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):n=null!=o?o:u),i&&"string"==typeof i){var s=i.split(",").map((function(t){return parseFloat(t)})),l=s[0],d=s[1],f=s[2],h=s[3];r="_geoBoundingBox([".concat(l,", ").concat(d,"], [").concat(f,", ").concat(h,"])")}else if(null!=e&&null!=n){var g=e[0],p=e[1];r="_geoRadius(".concat(g,", ").concat(p,", ").concat(n,")")}return r}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});void 0!==e&&(Array.isArray(b.filter)?b.filter.unshift(e):b.filter=[e])},addShowMatchesPosition:function(){var t=null==m?void 0:m.showMatchesPosition;void 0!==t&&(b.showMatchesPosition=t)},addMatchingStrategy:function(){var t=null==m?void 0:m.matchingStrategy;void 0!==t&&(b.matchingStrategy=t)},addShowRankingScore:function(){var t=null==m?void 0:m.showRankingScore;void 0!==t&&(b.showRankingScore=t)},addAttributesToSearchOn:function(){var t=void 0!==(null==m?void 0:m.attributesToSearchOn)?m.attributesToSearchOn:y;void 0!==t&&(b.attributesToSearchOn=t)}}}function g(t){var e=h(t);return e.addQuery(),e.addFacets(),e.addAttributesToCrop(),e.addCropLength(),e.addCropMarker(),e.addFilters(),e.addAttributesToRetrieve(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addPagination(),e.addSort(),e.addGeoSearchFilter(),e.addShowMatchesPosition(),e.addMatchingStrategy(),e.addShowRankingScore(),e.addAttributesToSearchOn(),e.getParams()}function p(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function v(t){return Array.isArray(t)?t.map((function(t){return v(t)})):i(t)?Object.keys(t).reduce((function(e,n){return e[n]=v(t[n]),e}),{}):{value:p(t)}}function y(t){if(!t)return{};var e=v(t);return{_highlightResult:e,_snippetResult:e}}function m(t,e){var n=t.hits,r=t.pagination.hitsPerPage,i=e.finitePagination,a=e.primaryKey;!i&&n.length>r&&n.splice(n.length-1,1);var o=n.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesPosition"]),r=Object.assign(n,y(e));return a&&(r.objectID=t[a]),r}return t}));return o=function(t){for(var e,n=0;n<t.length;n++){var r="".concat(n+1e6*Math.random());t[n]._geo&&(t[n]._geoloc=t[n]._geo,t[n].objectID=r),(null===(e=t[n]._formatted)||void 0===e?void 0:e._geo)&&(t[n]._formatted._geoloc=t[n]._formatted._geo,t[n]._formatted.objectID=r)}return t}(o),o}function b(t){return Object.keys(t).reduce((function(n,r){return n[r]=e(e({},t[r]),{avg:0,sum:0}),n}),{})}function P(t,e,n){var r=t.map((function(t){return function(t,e,n){var r=t.processingTimeMs,i=t.query,a=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,c=t.facetStats,s=void 0===c?{}:c,l=Object.keys(u),d=function(t,e){var n=e.hitsPerPage,r=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var n=t.limit,r=void 0===n?20:n,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=r?1:0)}(t,n);return{page:r,nbPages:i,hitsPerPage:n}}(t,t.pagination),f=d.hitsPerPage,h=d.page,g=d.nbPages,p=m(t,n),v=function(t){var e=t.hitsPerPage,n=void 0===e?0:e,r=t.totalPages,i=void 0===r?0:r,a=t.estimatedTotalHits,o=t.totalHits;return null!=a?a:null!=o?o:n*i}(t),y=function(t,e,n,r){return t?function(t,e,n){for(var r=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},a=0,o=r;a<o.length;a++){var u=o[a];for(var c in e[u])i[u]||(i[u]=n[u]||{}),i[u][c]?i[u][c]=n[u][c]:i[u][c]=0}return i}(e,n,r=r||{}):r}(n.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:f,page:h,facets:y,nbPages:g,nbHits:v,processingTimeMS:r,query:i,hits:p,params:"",exhaustiveNbHits:!1,facets_stats:b(s)}}(t,e[t.indexUid],n)}));return{results:r}}function S(t){return t?t.split(/,(?=\w+:(?:asc|desc))/):[]}function x(t,e,n){return{hitsPerPage:void 0===e?20:e,page:n||0,finite:!!t}}function w(t){var e=t.indexOf(":");return-1===e?{indexUid:t,sortBy:""}:{indexUid:t.substring(0,e),sortBy:t.substring(e+1)}}function T(t,n){var r=t.query,i=t.indexName,a=t.params,o=w(i),u=o.indexUid,c=o.sortBy,s=x(n.finitePagination,null==a?void 0:a.hitsPerPage,null==a?void 0:a.page);return e(e(e(e({},n),{query:r}),a),{sort:S(c),indexUid:u,pagination:s,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}function O(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)},clearCache:function(){e={}}}}function _(t){var n=h(e(e({},t),{placeholderSearch:!0,query:""}));return n.addFacets(),n.addPagination(),n.getParams()}function k(t,e,i){return n(this,void 0,void 0,(function(){var n,a,o,u,c,s;return r(this,(function(r){switch(r.label){case 0:return l="indexUid",d=[],n=function(t){return!d.includes(t[l])&&(d.push(t[l]),!0)},a=e.filter(n).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===a.length?[2,i]:[4,t.multiSearch(a,[])];case 1:for(o=r.sent(),u=0,c=o;u<c.length;u++)s=c[u],i[s.indexUid]=s.facetDistribution||{};return[2,i]}var l,d}))}))}exports.instantMeiliSearch=function(a,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,n){var r=n.requestConfig,a=n.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==r&&!i(r))throw new TypeError("Provided requestConfig should be an object");if(a&&"function"!=typeof a)throw new TypeError("Provided custom httpClient should be a function")}(a,o,u);var c={host:a,apiKey:o=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(o),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.14.0",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,l,d,f=new t.MeiliSearch(c),h=O(),p=(s=f,l=h,{multiSearch:function(t,i){return n(this,void 0,void 0,(function(){var n,a,o,u;return r(this,(function(r){switch(r.label){case 0:return n=l.formatKey([t]),(a=l.getEntry(n))?[2,a]:[4,s.multiSearch({queries:t})];case 1:return o=r.sent(),u=o.results.map((function(t,n){return e(e({},t),{pagination:i[n]||{}})})),l.setEntry(n,u),[2,u]}}))}))}}),v={},y=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{setMeiliSearchParams:function(t){var n=u.meiliSearchParams;u.meiliSearchParams=void 0===n?t:e(e({},n),t)},searchClient:{clearCache:function(){return h.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,o,c,s,l,d,f,h,m;return r(this,(function(r){switch(r.label){case 0:for(r.trys.push([0,3,,4]),n=[],i=[],a=[],o=0,c=t;o<c.length;o++)s=c[o],l=T(s,u),d=g(l),n.push(d),f=_(l),a.push(f),i.push(l.pagination);return[4,k(p,a,v)];case 1:return v=r.sent(),[4,p.multiSearch(n,i)];case 2:return h=r.sent(),v=function(t,n){for(var r=0,i=n;r<i.length;r++){var a=i[r];t[a.indexUid]=e(e({},a.facetDistribution||{}),t[a.indexUid]||{})}return t}(v,h),[2,P(h,v,y)];case 3:throw m=r.sent(),console.error(m),new Error(m);case 4:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){var n,i,a,o,c,s,l,d,h,p;return r(this,(function(r){switch(r.label){case 0:n=[],i=0,a=t,r.label=1;case 1:return i<a.length?(o=a[i],c=function(t,n){var r=w(t.indexName),i=r.indexUid,a=r.sortBy,o=t.params,u=x(n.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page);return e(e(e({},n),o),{sort:S(a),indexUid:i,pagination:u,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}(o,u),s=g(c),delete(l=e(e({},s),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,f.index(c.indexUid).searchForFacetValues(l)]):[3,4];case 2:d=r.sent(),h=d.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),p={facetHits:h,exhaustiveFacetsCount:!1,processingTimeMS:d.processingTimeMs},n.push(p),r.label=3;case 3:return i++,[3,1];case 4:return[2,n]}}))}))}}}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("meilisearch"),e=function(){return e=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},e.apply(this,arguments)};function r(t,e,r,n){return new(r||(r=Promise))((function(i,a){function o(t){try{c(n.next(t))}catch(t){a(t)}}function u(t){try{c(n.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}c((n=n.apply(t,e||[])).next())}))}function n(t,e){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(r=1,n&&(i=2&u[0]?n.return:u[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,u[1])).done)return i;switch(n=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,n=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],n=0}finally{r=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function i(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}"function"==typeof SuppressedError&&SuppressedError;var a=/([\\"])/g;function o(t){return t.replace(a,"\\$1")}function u(t){var e=o(t),r=e.indexOf(":"),n=e.slice(0,r),i=e.slice(r+1);return'"'.concat(n,'"="').concat(i,'"')}function c(t){var e=function(){var e=t.match(/^([^<!>:=]*)([<!>:=]+)(.*)$/);if(e){var r=e.slice(1),n=r[0],i=r[1],a=r[2],o=(i.match(/^([<!>]?=|<|>|:){1}(.*)/)||["",""]).slice(1);return[n,o[0],o[1]+a]}return[t,"",""]}(),r=e[0],n=e[1],i=e[2],a=o(r);return'"'.concat(a.trim(),'"').concat(":"===n?" ":n).concat(i.trim())}function s(t,e){return"string"==typeof e?t(e):e.map((function(e){return"string"==typeof e?t(e):e.map((function(e){return t(e)}))}))}function l(t){return"string"==typeof t?[t]:t}function d(t,e,r){return function(t,e,r){var n=l(e),i=l(r),a=[];return void 0!==t&&a.push(t),void 0!==n&&a.push.apply(a,n),void 0!==i&&a.push.apply(a,i),a}(t,void 0!==e?s(c,e):e,void 0!==r?s(u,r):r)}function f(t){var e=t.query,r=t.indexUid,n=t.facets,i=t.attributesToSnippet,a=t.snippetEllipsisText,o=t.filters,u=t.numericFilters,c=t.facetFilters,s=t.attributesToRetrieve,l=t.attributesToHighlight,f=t.highlightPreTag,h=t.highlightPostTag,g=t.placeholderSearch,p=t.pagination,v=t.sort,y=t.restrictSearchableAttributes,m=t.meiliSearchParams,b={indexUid:r},P=d(o,u,c);return{getParams:function(){return b},addQuery:function(){b.q=e},addFacets:function(){var t=n;void 0!==t&&(b.facets="string"==typeof t?[t]:t)},addAttributesToCrop:function(){var t,e=null!==(t=null==m?void 0:m.attributesToCrop)&&void 0!==t?t:i;void 0!==e&&(b.attributesToCrop=e)},addCropLength:function(){var t=null==m?void 0:m.cropLength;void 0!==t&&(b.cropLength=t)},addCropMarker:function(){var t,e=null!==(t=null==m?void 0:m.cropMarker)&&void 0!==t?t:a;void 0!==e&&(b.cropMarker=e)},addFilters:function(){P.length&&(b.filter=P)},addAttributesToRetrieve:function(){var t,e=null!==(t=null==m?void 0:m.attributesToRetrieve)&&void 0!==t?t:s;void 0!==e&&(b.attributesToRetrieve=e)},addAttributesToHighlight:function(){var t,e;b.attributesToHighlight=null!==(e=null!==(t=null==m?void 0:m.attributesToHighlight)&&void 0!==t?t:l)&&void 0!==e?e:["*"]},addPreTag:function(){var t,e;b.highlightPreTag=null!==(e=null!==(t=null==m?void 0:m.highlightPreTag)&&void 0!==t?t:f)&&void 0!==e?e:"__ais-highlight__"},addPostTag:function(){var t,e;b.highlightPostTag=null!==(e=null!==(t=null==m?void 0:m.highlightPostTag)&&void 0!==t?t:h)&&void 0!==e?e:"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(P,e,g);if(p.finite){var r=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{hitsPerPage:n,page:r+1}:{hitsPerPage:0,page:r+1}}(p,t),n=r.hitsPerPage,i=r.page;b.hitsPerPage=n,b.page=i}else{var a=function(t,e){var r=t.page,n=t.hitsPerPage;return e?{limit:n+1,offset:r*n}:{limit:0,offset:0}}(p,t),o=a.limit,u=a.offset;b.limit=o,b.offset=u}},addSort:function(){(null==v?void 0:v.length)&&(b.sort=Array.isArray(v)?v:[v])},addGeoSearchFilter:function(){var e=function(t){var e,r,n,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var c=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[g=c[0],p=c[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):r=null!=o?o:u),i&&"string"==typeof i){var s=i.split(",").map((function(t){return parseFloat(t)})),l=s[0],d=s[1],f=s[2],h=s[3];n="_geoBoundingBox([".concat(l,", ").concat(d,"], [").concat(f,", ").concat(h,"])")}else if(null!=e&&null!=r){var g=e[0],p=e[1];n="_geoRadius(".concat(g,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});void 0!==e&&(Array.isArray(b.filter)?b.filter.unshift(e):b.filter=[e])},addShowMatchesPosition:function(){var t=null==m?void 0:m.showMatchesPosition;void 0!==t&&(b.showMatchesPosition=t)},addMatchingStrategy:function(){var t=null==m?void 0:m.matchingStrategy;void 0!==t&&(b.matchingStrategy=t)},addShowRankingScore:function(){var t=null==m?void 0:m.showRankingScore;void 0!==t&&(b.showRankingScore=t)},addAttributesToSearchOn:function(){var t=void 0!==(null==m?void 0:m.attributesToSearchOn)?m.attributesToSearchOn:y;void 0!==t&&(b.attributesToSearchOn=t)}}}function h(t){var e=f(t);return e.addQuery(),e.addFacets(),e.addAttributesToCrop(),e.addCropLength(),e.addCropMarker(),e.addFilters(),e.addAttributesToRetrieve(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addPagination(),e.addSort(),e.addGeoSearchFilter(),e.addShowMatchesPosition(),e.addMatchingStrategy(),e.addShowRankingScore(),e.addAttributesToSearchOn(),e.getParams()}function g(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function p(t){return Array.isArray(t)?t.map((function(t){return p(t)})):i(t)?Object.keys(t).reduce((function(e,r){return e[r]=p(t[r]),e}),{}):{value:g(t)}}function v(t){if(!t)return{};var e=p(t);return{_highlightResult:e,_snippetResult:e}}function y(t,e){var r=t.hits,n=t.pagination.hitsPerPage,i=e.finitePagination,a=e.primaryKey;!i&&r.length>n&&r.splice(r.length-1,1);var o=r.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var r=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]])}return r}(t,["_formatted","_matchesPosition"]),n=Object.assign(r,v(e));return a&&(n.objectID=t[a]),n}return t}));return o=function(t){for(var e,r=0;r<t.length;r++){var n="".concat(r+1e6*Math.random());t[r]._geo&&(t[r]._geoloc=t[r]._geo,t[r].objectID=n),(null===(e=t[r]._formatted)||void 0===e?void 0:e._geo)&&(t[r]._formatted._geoloc=t[r]._formatted._geo,t[r]._formatted.objectID=n)}return t}(o),o}function m(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function b(t,e,r){var n=t.map((function(t){return function(t,e,r){var n=t.processingTimeMs,i=t.query,a=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,c=t.facetStats,s=void 0===c?{}:c,l=Object.keys(u),d=function(t,e){var r=e.hitsPerPage,n=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var r=t.limit,n=void 0===r?20:r,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=n?1:0)}(t,r);return{page:n,nbPages:i,hitsPerPage:r}}(t,t.pagination),f=d.hitsPerPage,h=d.page,g=d.nbPages,p=y(t,r),v=function(t){var e=t.hitsPerPage,r=void 0===e?0:e,n=t.totalPages,i=void 0===n?0:n,a=t.estimatedTotalHits,o=t.totalHits;return null!=a?a:null!=o?o:r*i}(t),b=function(t,e,r,n){return t?function(t,e,r){for(var n=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},a=0,o=n;a<o.length;a++){var u=o[a];for(var c in e[u])i[u]||(i[u]=r[u]||{}),i[u][c]?i[u][c]=r[u][c]:i[u][c]=0}return i}(e,r,n=n||{}):n}(r.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:f,page:h,facets:b,nbPages:g,nbHits:v,processingTimeMS:n,query:i,hits:p,params:"",exhaustiveNbHits:!1,facets_stats:m(s)}}(t,e[t.indexUid],r)}));return{results:n}}function P(t){if(!t)return[];for(var e,r=/[^:]+:(?:asc|desc)/g,n=[];null!==(e=r.exec(t));)n.push(e[0]);return n.map((function(t){return t.replace(/^,+|,+$/,"")}))}function S(t,e,r){return{hitsPerPage:void 0===e?20:e,page:r||0,finite:!!t}}function x(t){var e=t.indexOf(":");return-1===e?{indexUid:t,sortBy:""}:{indexUid:t.substring(0,e),sortBy:t.substring(e+1)}}function T(t,r){var n=t.query,i=t.indexName,a=t.params,o=x(i),u=o.indexUid,c=o.sortBy,s=S(r.finitePagination,null==a?void 0:a.hitsPerPage,null==a?void 0:a.page);return e(e(e(e({},r),{query:n}),a),{sort:P(c),indexUid:u,pagination:s,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function w(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,r){e[t]=JSON.stringify(r)},clearCache:function(){e={}}}}function O(t){var r=f(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addPagination(),r.getParams()}function _(t,e,i){return r(this,void 0,void 0,(function(){var r,a,o,u,c,s;return n(this,(function(n){switch(n.label){case 0:return l="indexUid",d=[],r=function(t){return!d.includes(t[l])&&(d.push(t[l]),!0)},a=e.filter(r).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===a.length?[2,i]:[4,t.multiSearch(a,[])];case 1:for(o=n.sent(),u=0,c=o;u<c.length;u++)s=c[u],i[s.indexUid]=s.facetDistribution||{};return[2,i]}var l,d}))}))}exports.instantMeiliSearch=function(a,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,a=r.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==n&&!i(n))throw new TypeError("Provided requestConfig should be an object");if(a&&"function"!=typeof a)throw new TypeError("Provided custom httpClient should be a function")}(a,o,u);var c={host:a,apiKey:o=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(o),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.15.0",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,l,d,f=new t.MeiliSearch(c),g=w(),p=(s=f,l=g,{multiSearch:function(t,i){return r(this,void 0,void 0,(function(){var r,a,o,u;return n(this,(function(n){switch(n.label){case 0:return r=l.formatKey([t]),(a=l.getEntry(r))?[2,a]:[4,s.multiSearch({queries:t})];case 1:return o=n.sent(),u=o.results.map((function(t,r){return e(e({},t),{pagination:i[r]||{}})})),l.setEntry(r,u),[2,u]}}))}))}}),v={},y=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{setMeiliSearchParams:function(t){var r=u.meiliSearchParams;u.meiliSearchParams=void 0===r?t:e(e({},r),t)},searchClient:{clearCache:function(){return g.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var r,i,a,o,c,s,l,d,f,g,m;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),r=[],i=[],a=[],o=0,c=t;o<c.length;o++)s=c[o],l=T(s,u),d=h(l),r.push(d),f=O(l),a.push(f),i.push(l.pagination);return[4,_(p,a,v)];case 1:return v=n.sent(),[4,p.multiSearch(r,i)];case 2:return g=n.sent(),v=function(t,r){for(var n=0,i=r;n<i.length;n++){var a=i[n];t[a.indexUid]=e(e({},a.facetDistribution||{}),t[a.indexUid]||{})}return t}(v,g),[2,b(g,v,y)];case 3:throw m=n.sent(),console.error(m),new Error(m);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){var r,i,a,o,c,s,l,d,g,p;return n(this,(function(n){switch(n.label){case 0:r=[],i=0,a=t,n.label=1;case 1:return i<a.length?(o=a[i],c=function(t,r){var n=x(t.indexName),i=n.indexUid,a=n.sortBy,o=t.params,u=S(r.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page);return e(e(e({},r),o),{sort:P(a),indexUid:i,pagination:u,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}(o,u),s=h(c),delete(l=e(e({},s),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,f.index(c.indexUid).searchForFacetValues(l)]):[3,4];case 2:d=n.sent(),g=d.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),p={facetHits:g,exhaustiveFacetsCount:!1,processingTimeMS:d.processingTimeMs},r.push(p),n.label=3;case 3:return i++,[3,1];case 4:return[2,r]}}))}))}}}};
//# sourceMappingURL=instant-meilisearch.cjs.min.js.map

@@ -239,4 +239,2 @@ import { MeiliSearch } from 'meilisearch';

}
// Matches first occurrence of an operator
var numericSplitRegExp = /(?<!(?:[<!>]?=|<|>|:).*)([<!>]?=|<|>|:)/;
/**

@@ -257,5 +255,17 @@ * Transform InstantSearch [numeric filter](https://www.algolia.com/doc/api-reference/api-parameters/numericFilters/)

function transformNumericFilter(filter) {
// TODO: Warn users to not enable facet values escape for negative numbers.
// https://github.com/algolia/instantsearch/blob/da701529ed325bb7a1d782e80cb994711e20d94a/packages/instantsearch.js/src/lib/utils/escapeFacetValue.ts#L13-L21
var _a = filter.split(numericSplitRegExp), attribute = _a[0], operator = _a[1], value = _a[2];
var splitNumericFilter = function () {
var attributeMatch = filter.match(/^([^<!>:=]*)([<!>:=]+)(.*)$/);
if (attributeMatch) {
var _a = attributeMatch.slice(1), attribute_1 = _a[0], dirtyOperator = _a[1], valueEnd = _a[2];
var operatorMatch = dirtyOperator.match(/^([<!>]?=|<|>|:){1}(.*)/) || [
'',
'',
];
var _b = operatorMatch.slice(1), operator_1 = _b[0], valueStart = _b[1];
var cleanedValue = valueStart + valueEnd;
return [attribute_1, operator_1, cleanedValue];
}
return [filter, '', ''];
};
var _a = splitNumericFilter(), attribute = _a[0], operator = _a[1], value = _a[2];
var escapedAttribute = getValueWithEscapedBackslashesAndQuotes(attribute);

@@ -831,4 +841,9 @@ return "\"".concat(escapedAttribute.trim(), "\"").concat(operator === ':' ? ' ' : operator).concat(value.trim());

return [];
var sortRules = sortStr.split(/,(?=\w+:(?:asc|desc))/);
return sortRules;
var regex = /[^:]+:(?:asc|desc)/g;
var sortRules = [];
var match;
while ((match = regex.exec(sortStr)) !== null) {
sortRules.push(match[0]);
}
return sortRules.map(function (str) { return str.replace(/^,+|,+$/, ''); });
}

@@ -974,3 +989,3 @@

var PACKAGE_VERSION = '0.14.0';
var PACKAGE_VERSION = '0.15.0';

@@ -977,0 +992,0 @@ var constructClientAgents = function (clientAgents) {

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

import{MeiliSearch as t}from"meilisearch";var e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function i(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}"function"==typeof SuppressedError&&SuppressedError;var a=/([\\"])/g;function o(t){return t.replace(a,"\\$1")}function u(t){var e=o(t),n=e.indexOf(":"),r=e.slice(0,n),i=e.slice(n+1);return'"'.concat(r,'"="').concat(i,'"')}var c=/(?<!(?:[<!>]?=|<|>|:).*)([<!>]?=|<|>|:)/;function s(t){var e=t.split(c),n=e[0],r=e[1],i=e[2],a=o(n);return'"'.concat(a.trim(),'"').concat(":"===r?" ":r).concat(i.trim())}function l(t,e){return"string"==typeof e?t(e):e.map((function(e){return"string"==typeof e?t(e):e.map((function(e){return t(e)}))}))}function d(t){return"string"==typeof t?[t]:t}function f(t,e,n){return function(t,e,n){var r=d(e),i=d(n),a=[];return void 0!==t&&a.push(t),void 0!==r&&a.push.apply(a,r),void 0!==i&&a.push.apply(a,i),a}(t,void 0!==e?l(s,e):e,void 0!==n?l(u,n):n)}function h(t){var e=t.query,n=t.indexUid,r=t.facets,i=t.attributesToSnippet,a=t.snippetEllipsisText,o=t.filters,u=t.numericFilters,c=t.facetFilters,s=t.attributesToRetrieve,l=t.attributesToHighlight,d=t.highlightPreTag,h=t.highlightPostTag,g=t.placeholderSearch,p=t.pagination,v=t.sort,y=t.restrictSearchableAttributes,m=t.meiliSearchParams,b={indexUid:n},P=f(o,u,c);return{getParams:function(){return b},addQuery:function(){b.q=e},addFacets:function(){var t=r;void 0!==t&&(b.facets="string"==typeof t?[t]:t)},addAttributesToCrop:function(){var t,e=null!==(t=null==m?void 0:m.attributesToCrop)&&void 0!==t?t:i;void 0!==e&&(b.attributesToCrop=e)},addCropLength:function(){var t=null==m?void 0:m.cropLength;void 0!==t&&(b.cropLength=t)},addCropMarker:function(){var t,e=null!==(t=null==m?void 0:m.cropMarker)&&void 0!==t?t:a;void 0!==e&&(b.cropMarker=e)},addFilters:function(){P.length&&(b.filter=P)},addAttributesToRetrieve:function(){var t,e=null!==(t=null==m?void 0:m.attributesToRetrieve)&&void 0!==t?t:s;void 0!==e&&(b.attributesToRetrieve=e)},addAttributesToHighlight:function(){var t,e;b.attributesToHighlight=null!==(e=null!==(t=null==m?void 0:m.attributesToHighlight)&&void 0!==t?t:l)&&void 0!==e?e:["*"]},addPreTag:function(){var t,e;b.highlightPreTag=null!==(e=null!==(t=null==m?void 0:m.highlightPreTag)&&void 0!==t?t:d)&&void 0!==e?e:"__ais-highlight__"},addPostTag:function(){var t,e;b.highlightPostTag=null!==(e=null!==(t=null==m?void 0:m.highlightPostTag)&&void 0!==t?t:h)&&void 0!==e?e:"__/ais-highlight__"},addPagination:function(){var t=function(t,e,n){return!!(n||e||t&&0!==t.length)}(P,e,g);if(p.finite){var n=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{hitsPerPage:r,page:n+1}:{hitsPerPage:0,page:n+1}}(p,t),r=n.hitsPerPage,i=n.page;b.hitsPerPage=r,b.page=i}else{var a=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{limit:r+1,offset:n*r}:{limit:0,offset:0}}(p,t),o=a.limit,u=a.offset;b.limit=o,b.offset=u}},addSort:function(){(null==v?void 0:v.length)&&(b.sort=Array.isArray(v)?v:[v])},addGeoSearchFilter:function(){var e=function(t){var e,n,r,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var c=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[g=c[0],p=c[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):n=null!=o?o:u),i&&"string"==typeof i){var s=i.split(",").map((function(t){return parseFloat(t)})),l=s[0],d=s[1],f=s[2],h=s[3];r="_geoBoundingBox([".concat(l,", ").concat(d,"], [").concat(f,", ").concat(h,"])")}else if(null!=e&&null!=n){var g=e[0],p=e[1];r="_geoRadius(".concat(g,", ").concat(p,", ").concat(n,")")}return r}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});void 0!==e&&(Array.isArray(b.filter)?b.filter.unshift(e):b.filter=[e])},addShowMatchesPosition:function(){var t=null==m?void 0:m.showMatchesPosition;void 0!==t&&(b.showMatchesPosition=t)},addMatchingStrategy:function(){var t=null==m?void 0:m.matchingStrategy;void 0!==t&&(b.matchingStrategy=t)},addShowRankingScore:function(){var t=null==m?void 0:m.showRankingScore;void 0!==t&&(b.showRankingScore=t)},addAttributesToSearchOn:function(){var t=void 0!==(null==m?void 0:m.attributesToSearchOn)?m.attributesToSearchOn:y;void 0!==t&&(b.attributesToSearchOn=t)}}}function g(t){var e=h(t);return e.addQuery(),e.addFacets(),e.addAttributesToCrop(),e.addCropLength(),e.addCropMarker(),e.addFilters(),e.addAttributesToRetrieve(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addPagination(),e.addSort(),e.addGeoSearchFilter(),e.addShowMatchesPosition(),e.addMatchingStrategy(),e.addShowRankingScore(),e.addAttributesToSearchOn(),e.getParams()}function p(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function v(t){return Array.isArray(t)?t.map((function(t){return v(t)})):i(t)?Object.keys(t).reduce((function(e,n){return e[n]=v(t[n]),e}),{}):{value:p(t)}}function y(t){if(!t)return{};var e=v(t);return{_highlightResult:e,_snippetResult:e}}function m(t,e){var n=t.hits,r=t.pagination.hitsPerPage,i=e.finitePagination,a=e.primaryKey;!i&&n.length>r&&n.splice(n.length-1,1);var o=n.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesPosition"]),r=Object.assign(n,y(e));return a&&(r.objectID=t[a]),r}return t}));return o=function(t){for(var e,n=0;n<t.length;n++){var r="".concat(n+1e6*Math.random());t[n]._geo&&(t[n]._geoloc=t[n]._geo,t[n].objectID=r),(null===(e=t[n]._formatted)||void 0===e?void 0:e._geo)&&(t[n]._formatted._geoloc=t[n]._formatted._geo,t[n]._formatted.objectID=r)}return t}(o),o}function b(t){return Object.keys(t).reduce((function(n,r){return n[r]=e(e({},t[r]),{avg:0,sum:0}),n}),{})}function P(t,e,n){var r=t.map((function(t){return function(t,e,n){var r=t.processingTimeMs,i=t.query,a=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,c=t.facetStats,s=void 0===c?{}:c,l=Object.keys(u),d=function(t,e){var n=e.hitsPerPage,r=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var n=t.limit,r=void 0===n?20:n,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=r?1:0)}(t,n);return{page:r,nbPages:i,hitsPerPage:n}}(t,t.pagination),f=d.hitsPerPage,h=d.page,g=d.nbPages,p=m(t,n),v=function(t){var e=t.hitsPerPage,n=void 0===e?0:e,r=t.totalPages,i=void 0===r?0:r,a=t.estimatedTotalHits,o=t.totalHits;return null!=a?a:null!=o?o:n*i}(t),y=function(t,e,n,r){return t?function(t,e,n){for(var r=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},a=0,o=r;a<o.length;a++){var u=o[a];for(var c in e[u])i[u]||(i[u]=n[u]||{}),i[u][c]?i[u][c]=n[u][c]:i[u][c]=0}return i}(e,n,r=r||{}):r}(n.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:f,page:h,facets:y,nbPages:g,nbHits:v,processingTimeMS:r,query:i,hits:p,params:"",exhaustiveNbHits:!1,facets_stats:b(s)}}(t,e[t.indexUid],n)}));return{results:r}}function S(t){return t?t.split(/,(?=\w+:(?:asc|desc))/):[]}function w(t,e,n){return{hitsPerPage:void 0===e?20:e,page:n||0,finite:!!t}}function x(t){var e=t.indexOf(":");return-1===e?{indexUid:t,sortBy:""}:{indexUid:t.substring(0,e),sortBy:t.substring(e+1)}}function T(t,n){var r=t.query,i=t.indexName,a=t.params,o=x(i),u=o.indexUid,c=o.sortBy,s=w(n.finitePagination,null==a?void 0:a.hitsPerPage,null==a?void 0:a.page);return e(e(e(e({},n),{query:r}),a),{sort:S(c),indexUid:u,pagination:s,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}function O(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)},clearCache:function(){e={}}}}function _(t){var n=h(e(e({},t),{placeholderSearch:!0,query:""}));return n.addFacets(),n.addPagination(),n.getParams()}function k(t,e,i){return n(this,void 0,void 0,(function(){var n,a,o,u,c,s;return r(this,(function(r){switch(r.label){case 0:return l="indexUid",d=[],n=function(t){return!d.includes(t[l])&&(d.push(t[l]),!0)},a=e.filter(n).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===a.length?[2,i]:[4,t.multiSearch(a,[])];case 1:for(o=r.sent(),u=0,c=o;u<c.length;u++)s=c[u],i[s.indexUid]=s.facetDistribution||{};return[2,i]}var l,d}))}))}function A(a,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,n){var r=n.requestConfig,a=n.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==r&&!i(r))throw new TypeError("Provided requestConfig should be an object");if(a&&"function"!=typeof a)throw new TypeError("Provided custom httpClient should be a function")}(a,o,u);var c={host:a,apiKey:o=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(o),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.14.0",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,l,d,f=new t(c),h=O(),p=(s=f,l=h,{multiSearch:function(t,i){return n(this,void 0,void 0,(function(){var n,a,o,u;return r(this,(function(r){switch(r.label){case 0:return n=l.formatKey([t]),(a=l.getEntry(n))?[2,a]:[4,s.multiSearch({queries:t})];case 1:return o=r.sent(),u=o.results.map((function(t,n){return e(e({},t),{pagination:i[n]||{}})})),l.setEntry(n,u),[2,u]}}))}))}}),v={},y=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{setMeiliSearchParams:function(t){var n=u.meiliSearchParams;u.meiliSearchParams=void 0===n?t:e(e({},n),t)},searchClient:{clearCache:function(){return h.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,o,c,s,l,d,f,h,m;return r(this,(function(r){switch(r.label){case 0:for(r.trys.push([0,3,,4]),n=[],i=[],a=[],o=0,c=t;o<c.length;o++)s=c[o],l=T(s,u),d=g(l),n.push(d),f=_(l),a.push(f),i.push(l.pagination);return[4,k(p,a,v)];case 1:return v=r.sent(),[4,p.multiSearch(n,i)];case 2:return h=r.sent(),v=function(t,n){for(var r=0,i=n;r<i.length;r++){var a=i[r];t[a.indexUid]=e(e({},a.facetDistribution||{}),t[a.indexUid]||{})}return t}(v,h),[2,P(h,v,y)];case 3:throw m=r.sent(),console.error(m),new Error(m);case 4:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){var n,i,a,o,c,s,l,d,h,p;return r(this,(function(r){switch(r.label){case 0:n=[],i=0,a=t,r.label=1;case 1:return i<a.length?(o=a[i],c=function(t,n){var r=x(t.indexName),i=r.indexUid,a=r.sortBy,o=t.params,u=w(n.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page);return e(e(e({},n),o),{sort:S(a),indexUid:i,pagination:u,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}(o,u),s=g(c),delete(l=e(e({},s),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,f.index(c.indexUid).searchForFacetValues(l)]):[3,4];case 2:d=r.sent(),h=d.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),p={facetHits:h,exhaustiveFacetsCount:!1,processingTimeMS:d.processingTimeMs},n.push(p),r.label=3;case 3:return i++,[3,1];case 4:return[2,n]}}))}))}}}}export{A as instantMeiliSearch};
import{MeiliSearch as t}from"meilisearch";var e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{c(r.next(t))}catch(t){a(t)}}function u(t){try{c(r.throw(t))}catch(t){a(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}c((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(c){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=e.call(t,o)}catch(t){u=[6,t],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,c])}}}function i(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}"function"==typeof SuppressedError&&SuppressedError;var a=/([\\"])/g;function o(t){return t.replace(a,"\\$1")}function u(t){var e=o(t),n=e.indexOf(":"),r=e.slice(0,n),i=e.slice(n+1);return'"'.concat(r,'"="').concat(i,'"')}function c(t){var e=function(){var e=t.match(/^([^<!>:=]*)([<!>:=]+)(.*)$/);if(e){var n=e.slice(1),r=n[0],i=n[1],a=n[2],o=(i.match(/^([<!>]?=|<|>|:){1}(.*)/)||["",""]).slice(1);return[r,o[0],o[1]+a]}return[t,"",""]}(),n=e[0],r=e[1],i=e[2],a=o(n);return'"'.concat(a.trim(),'"').concat(":"===r?" ":r).concat(i.trim())}function s(t,e){return"string"==typeof e?t(e):e.map((function(e){return"string"==typeof e?t(e):e.map((function(e){return t(e)}))}))}function l(t){return"string"==typeof t?[t]:t}function d(t,e,n){return function(t,e,n){var r=l(e),i=l(n),a=[];return void 0!==t&&a.push(t),void 0!==r&&a.push.apply(a,r),void 0!==i&&a.push.apply(a,i),a}(t,void 0!==e?s(c,e):e,void 0!==n?s(u,n):n)}function f(t){var e=t.query,n=t.indexUid,r=t.facets,i=t.attributesToSnippet,a=t.snippetEllipsisText,o=t.filters,u=t.numericFilters,c=t.facetFilters,s=t.attributesToRetrieve,l=t.attributesToHighlight,f=t.highlightPreTag,h=t.highlightPostTag,g=t.placeholderSearch,p=t.pagination,v=t.sort,y=t.restrictSearchableAttributes,m=t.meiliSearchParams,b={indexUid:n},P=d(o,u,c);return{getParams:function(){return b},addQuery:function(){b.q=e},addFacets:function(){var t=r;void 0!==t&&(b.facets="string"==typeof t?[t]:t)},addAttributesToCrop:function(){var t,e=null!==(t=null==m?void 0:m.attributesToCrop)&&void 0!==t?t:i;void 0!==e&&(b.attributesToCrop=e)},addCropLength:function(){var t=null==m?void 0:m.cropLength;void 0!==t&&(b.cropLength=t)},addCropMarker:function(){var t,e=null!==(t=null==m?void 0:m.cropMarker)&&void 0!==t?t:a;void 0!==e&&(b.cropMarker=e)},addFilters:function(){P.length&&(b.filter=P)},addAttributesToRetrieve:function(){var t,e=null!==(t=null==m?void 0:m.attributesToRetrieve)&&void 0!==t?t:s;void 0!==e&&(b.attributesToRetrieve=e)},addAttributesToHighlight:function(){var t,e;b.attributesToHighlight=null!==(e=null!==(t=null==m?void 0:m.attributesToHighlight)&&void 0!==t?t:l)&&void 0!==e?e:["*"]},addPreTag:function(){var t,e;b.highlightPreTag=null!==(e=null!==(t=null==m?void 0:m.highlightPreTag)&&void 0!==t?t:f)&&void 0!==e?e:"__ais-highlight__"},addPostTag:function(){var t,e;b.highlightPostTag=null!==(e=null!==(t=null==m?void 0:m.highlightPostTag)&&void 0!==t?t:h)&&void 0!==e?e:"__/ais-highlight__"},addPagination:function(){var t=function(t,e,n){return!!(n||e||t&&0!==t.length)}(P,e,g);if(p.finite){var n=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{hitsPerPage:r,page:n+1}:{hitsPerPage:0,page:n+1}}(p,t),r=n.hitsPerPage,i=n.page;b.hitsPerPage=r,b.page=i}else{var a=function(t,e){var n=t.page,r=t.hitsPerPage;return e?{limit:r+1,offset:n*r}:{limit:0,offset:0}}(p,t),o=a.limit,u=a.offset;b.limit=o,b.offset=u}},addSort:function(){(null==v?void 0:v.length)&&(b.sort=Array.isArray(v)?v:[v])},addGeoSearchFilter:function(){var e=function(t){var e,n,r,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var c=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[g=c[0],p=c[1]]}if(null==o&&null==u||("all"===o?console.warn("instant-meilisearch is not compatible with the `all` value on the aroundRadius parameter"):n=null!=o?o:u),i&&"string"==typeof i){var s=i.split(",").map((function(t){return parseFloat(t)})),l=s[0],d=s[1],f=s[2],h=s[3];r="_geoBoundingBox([".concat(l,", ").concat(d,"], [").concat(f,", ").concat(h,"])")}else if(null!=e&&null!=n){var g=e[0],p=e[1];r="_geoRadius(".concat(g,", ").concat(p,", ").concat(n,")")}return r}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});void 0!==e&&(Array.isArray(b.filter)?b.filter.unshift(e):b.filter=[e])},addShowMatchesPosition:function(){var t=null==m?void 0:m.showMatchesPosition;void 0!==t&&(b.showMatchesPosition=t)},addMatchingStrategy:function(){var t=null==m?void 0:m.matchingStrategy;void 0!==t&&(b.matchingStrategy=t)},addShowRankingScore:function(){var t=null==m?void 0:m.showRankingScore;void 0!==t&&(b.showRankingScore=t)},addAttributesToSearchOn:function(){var t=void 0!==(null==m?void 0:m.attributesToSearchOn)?m.attributesToSearchOn:y;void 0!==t&&(b.attributesToSearchOn=t)}}}function h(t){var e=f(t);return e.addQuery(),e.addFacets(),e.addAttributesToCrop(),e.addCropLength(),e.addCropMarker(),e.addFilters(),e.addAttributesToRetrieve(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addPagination(),e.addSort(),e.addGeoSearchFilter(),e.addShowMatchesPosition(),e.addMatchingStrategy(),e.addShowRankingScore(),e.addAttributesToSearchOn(),e.getParams()}function g(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function p(t){return Array.isArray(t)?t.map((function(t){return p(t)})):i(t)?Object.keys(t).reduce((function(e,n){return e[n]=p(t[n]),e}),{}):{value:g(t)}}function v(t){if(!t)return{};var e=p(t);return{_highlightResult:e,_snippetResult:e}}function y(t,e){var n=t.hits,r=t.pagination.hitsPerPage,i=e.finitePagination,a=e.primaryKey;!i&&n.length>r&&n.splice(n.length-1,1);var o=n.map((function(t){if(Object.keys(t).length>0){var e=t._formatted;t._matchesPosition;var n=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(t,["_formatted","_matchesPosition"]),r=Object.assign(n,v(e));return a&&(r.objectID=t[a]),r}return t}));return o=function(t){for(var e,n=0;n<t.length;n++){var r="".concat(n+1e6*Math.random());t[n]._geo&&(t[n]._geoloc=t[n]._geo,t[n].objectID=r),(null===(e=t[n]._formatted)||void 0===e?void 0:e._geo)&&(t[n]._formatted._geoloc=t[n]._formatted._geo,t[n]._formatted.objectID=r)}return t}(o),o}function m(t){return Object.keys(t).reduce((function(n,r){return n[r]=e(e({},t[r]),{avg:0,sum:0}),n}),{})}function b(t,e,n){var r=t.map((function(t){return function(t,e,n){var r=t.processingTimeMs,i=t.query,a=t.indexUid,o=t.facetDistribution,u=void 0===o?{}:o,c=t.facetStats,s=void 0===c?{}:c,l=Object.keys(u),d=function(t,e){var n=e.hitsPerPage,r=e.page,i=function(t,e){if(null!=t.totalPages)return t.totalPages;if(0===e)return 0;var n=t.limit,r=void 0===n?20:n,i=t.offset;return(void 0===i?0:i)/e+1+(t.hits.length>=r?1:0)}(t,n);return{page:r,nbPages:i,hitsPerPage:n}}(t,t.pagination),f=d.hitsPerPage,h=d.page,g=d.nbPages,p=y(t,n),v=function(t){var e=t.hitsPerPage,n=void 0===e?0:e,r=t.totalPages,i=void 0===r?0:r,a=t.estimatedTotalHits,o=t.totalHits;return null!=a?a:null!=o?o:n*i}(t),b=function(t,e,n,r){return t?function(t,e,n){for(var r=function(t){return t?"string"==typeof t?[t]:t:[]}(t),i={},a=0,o=r;a<o.length;a++){var u=o[a];for(var c in e[u])i[u]||(i[u]=n[u]||{}),i[u][c]?i[u][c]=n[u][c]:i[u][c]=0}return i}(e,n,r=r||{}):r}(n.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:f,page:h,facets:b,nbPages:g,nbHits:v,processingTimeMS:r,query:i,hits:p,params:"",exhaustiveNbHits:!1,facets_stats:m(s)}}(t,e[t.indexUid],n)}));return{results:r}}function P(t){if(!t)return[];for(var e,n=/[^:]+:(?:asc|desc)/g,r=[];null!==(e=n.exec(t));)r.push(e[0]);return r.map((function(t){return t.replace(/^,+|,+$/,"")}))}function S(t,e,n){return{hitsPerPage:void 0===e?20:e,page:n||0,finite:!!t}}function x(t){var e=t.indexOf(":");return-1===e?{indexUid:t,sortBy:""}:{indexUid:t.substring(0,e),sortBy:t.substring(e+1)}}function T(t,n){var r=t.query,i=t.indexName,a=t.params,o=x(i),u=o.indexUid,c=o.sortBy,s=S(n.finitePagination,null==a?void 0:a.hitsPerPage,null==a?void 0:a.page);return e(e(e(e({},n),{query:r}),a),{sort:P(c),indexUid:u,pagination:s,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}function w(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(t){return}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)},clearCache:function(){e={}}}}function O(t){var n=f(e(e({},t),{placeholderSearch:!0,query:""}));return n.addFacets(),n.addPagination(),n.getParams()}function _(t,e,i){return n(this,void 0,void 0,(function(){var n,a,o,u,c,s;return r(this,(function(r){switch(r.label){case 0:return l="indexUid",d=[],n=function(t){return!d.includes(t[l])&&(d.push(t[l]),!0)},a=e.filter(n).filter((function(t){var e=t.indexUid;return!Object.keys(i).includes(e)})),0===a.length?[2,i]:[4,t.multiSearch(a,[])];case 1:for(o=r.sent(),u=0,c=o;u<c.length;u++)s=c[u],i[s.indexUid]=s.facetDistribution||{};return[2,i]}var l,d}))}))}function k(a,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,n){var r=n.requestConfig,a=n.httpClient;if("string"!=typeof t)throw new TypeError("Provided hostUrl value (1st parameter) is not a string, expected string");if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("Provided apiKey value (2nd parameter) is not a string or a function, expected string or function");if(void 0!==r&&!i(r))throw new TypeError("Provided requestConfig should be an object");if(a&&"function"!=typeof a)throw new TypeError("Provided custom httpClient should be a function")}(a,o,u);var c={host:a,apiKey:o=function(t){if("function"==typeof t){var e=t();if("string"!=typeof e)throw new TypeError("Provided apiKey function (2nd parameter) did not return a string, expected string");return e}return t}(o),clientAgents:function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.15.0",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,l,d,f=new t(c),g=w(),p=(s=f,l=g,{multiSearch:function(t,i){return n(this,void 0,void 0,(function(){var n,a,o,u;return r(this,(function(r){switch(r.label){case 0:return n=l.formatKey([t]),(a=l.getEntry(n))?[2,a]:[4,s.multiSearch({queries:t})];case 1:return o=r.sent(),u=o.results.map((function(t,n){return e(e({},t),{pagination:i[n]||{}})})),l.setEntry(n,u),[2,u]}}))}))}}),v={},y=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{setMeiliSearchParams:function(t){var n=u.meiliSearchParams;u.meiliSearchParams=void 0===n?t:e(e({},n),t)},searchClient:{clearCache:function(){return g.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,o,c,s,l,d,f,g,m;return r(this,(function(r){switch(r.label){case 0:for(r.trys.push([0,3,,4]),n=[],i=[],a=[],o=0,c=t;o<c.length;o++)s=c[o],l=T(s,u),d=h(l),n.push(d),f=O(l),a.push(f),i.push(l.pagination);return[4,_(p,a,v)];case 1:return v=r.sent(),[4,p.multiSearch(n,i)];case 2:return g=r.sent(),v=function(t,n){for(var r=0,i=n;r<i.length;r++){var a=i[r];t[a.indexUid]=e(e({},a.facetDistribution||{}),t[a.indexUid]||{})}return t}(v,g),[2,b(g,v,y)];case 3:throw m=r.sent(),console.error(m),new Error(m);case 4:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){var n,i,a,o,c,s,l,d,g,p;return r(this,(function(r){switch(r.label){case 0:n=[],i=0,a=t,r.label=1;case 1:return i<a.length?(o=a[i],c=function(t,n){var r=x(t.indexName),i=r.indexUid,a=r.sortBy,o=t.params,u=S(n.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page);return e(e(e({},n),o),{sort:P(a),indexUid:i,pagination:u,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets})}(o,u),s=h(c),delete(l=e(e({},s),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,f.index(c.indexUid).searchForFacetValues(l)]):[3,4];case 2:d=r.sent(),g=d.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),p={facetHits:g,exhaustiveFacetsCount:!1,processingTimeMS:d.processingTimeMs},n.push(p),r.label=3;case 3:return i++,[3,1];case 4:return[2,n]}}))}))}}}}export{k as instantMeiliSearch};
//# sourceMappingURL=instant-meilisearch.esm.min.js.map

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

export declare const PACKAGE_VERSION = "0.14.0";
export declare const PACKAGE_VERSION = "0.15.0";
//# sourceMappingURL=package-version.d.ts.map
{
"name": "@meilisearch/instant-meilisearch",
"version": "0.14.0",
"version": "0.15.0",
"private": false,

@@ -53,3 +53,3 @@ "description": "The search client to use Meilisearch with InstantSearch.",

"dependencies": {
"meilisearch": "^0.36.0"
"meilisearch": "^0.37.0"
},

@@ -56,0 +56,0 @@ "devDependencies": {

@@ -32,5 +32,2 @@ import type { Filter, SearchContext } from '../../types'

// Matches first occurrence of an operator
const numericSplitRegExp = /(?<!(?:[<!>]?=|<|>|:).*)([<!>]?=|<|>|:)/
/**

@@ -51,5 +48,21 @@ * Transform InstantSearch [numeric filter](https://www.algolia.com/doc/api-reference/api-parameters/numericFilters/)

function transformNumericFilter(filter: string): string {
// TODO: Warn users to not enable facet values escape for negative numbers.
// https://github.com/algolia/instantsearch/blob/da701529ed325bb7a1d782e80cb994711e20d94a/packages/instantsearch.js/src/lib/utils/escapeFacetValue.ts#L13-L21
const [attribute, operator, value] = filter.split(numericSplitRegExp)
const splitNumericFilter = (): [string, string, string] => {
const attributeMatch = filter.match(/^([^<!>:=]*)([<!>:=]+)(.*)$/)
if (attributeMatch) {
const [attribute, dirtyOperator, valueEnd] = attributeMatch.slice(1)
const operatorMatch = dirtyOperator.match(/^([<!>]?=|<|>|:){1}(.*)/) || [
'',
'',
]
const [operator, valueStart] = operatorMatch.slice(1)
const cleanedValue = valueStart + valueEnd
return [attribute, operator, cleanedValue]
}
return [filter, '', '']
}
const [attribute, operator, value] = splitNumericFilter()
const escapedAttribute = getValueWithEscapedBackslashesAndQuotes(attribute)

@@ -56,0 +69,0 @@ return `"${escapedAttribute.trim()}"${

@@ -19,5 +19,11 @@ /**

if (!sortStr) return []
const sortRules = sortStr.split(/,(?=\w+:(?:asc|desc))/)
const regex = /[^:]+:(?:asc|desc)/g
const sortRules: string[] = []
return sortRules
let match
while ((match = regex.exec(sortStr)) !== null) {
sortRules.push(match[0])
}
return sortRules.map((str) => str.replace(/^,+|,+$/, ''))
}

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

export const PACKAGE_VERSION = '0.14.0'
export const PACKAGE_VERSION = '0.15.0'

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc