Socket
Socket
Sign inDemoInstall

@meilisearch/instant-meilisearch

Package Overview
Dependencies
Maintainers
6
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.13.3 to 0.13.4

templates/basic_search.css

60

dist/instant-meilisearch.cjs.js

@@ -93,2 +93,7 @@ 'use strict';

typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
function isPureObject(data) {

@@ -836,2 +841,16 @@ return typeof data === 'object' && !Array.isArray(data) && data !== null;

}
/**
* @param {AlgoliaMultipleQueriesQuery} searchRequest
* @param {Context} options
* @returns {SearchContext}
*/
function createFacetSearchContext(searchRequest, options) {
// Split index name and possible sorting rules
var _a = searchRequest.indexName.split(':'), indexUid = _a[0], sortByArray = _a.slice(1);
var instantSearchParams = searchRequest.params;
var paginationState = createPaginationState(options.finitePagination, instantSearchParams === null || instantSearchParams === void 0 ? void 0 : instantSearchParams.hitsPerPage, instantSearchParams === null || instantSearchParams === void 0 ? void 0 : instantSearchParams.page);
var sortState = splitSortString(sortByArray.join(':'));
var searchContext = __assign(__assign(__assign({}, options), instantSearchParams), { sort: sortState, indexUid: indexUid, pagination: paginationState, placeholderSearch: options.placeholderSearch !== false, keepZeroFacets: !!options.keepZeroFacets });
return searchContext;
}

@@ -914,3 +933,3 @@ /**

var PACKAGE_VERSION = '0.13.3';
var PACKAGE_VERSION = '0.13.4';

@@ -1002,11 +1021,38 @@ var constructClientAgents = function (clientAgents) {

},
searchForFacetValues: function (_) {
searchForFacetValues: function (requests) {
return __awaiter(this, void 0, void 0, function () {
var results, _i, requests_1, request, searchContext, meilisearchSearchQuery, index, meilisearchRequest, meilisearchResponse, facetHits, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
reject(new Error('SearchForFacetValues is not compatible with Meilisearch'));
resolve([]); // added here to avoid compilation error
})];
case 1: return [2 /*return*/, _a.sent()];
case 0:
results = [];
_i = 0, requests_1 = requests;
_a.label = 1;
case 1:
if (!(_i < requests_1.length)) return [3 /*break*/, 4];
request = requests_1[_i];
searchContext = createFacetSearchContext(request, instantMeiliSearchOptions);
meilisearchSearchQuery = adaptSearchParams(searchContext);
index = request.indexName;
meilisearchRequest = __assign(__assign({}, meilisearchSearchQuery), { facetQuery: request.params.facetQuery, facetName: request.params.facetName });
delete meilisearchRequest.indexUid;
return [4 /*yield*/, meilisearchClient
.index(index)
.searchForFacetValues(meilisearchRequest)];
case 2:
meilisearchResponse = _a.sent();
facetHits = meilisearchResponse.facetHits.map(function (facetHit) { return (__assign(__assign({}, facetHit), {
// not currently supported
highlighted: facetHit.value })); });
result = {
facetHits: facetHits,
exhaustiveFacetsCount: false,
processingTimeMS: meilisearchResponse.processingTimeMs
};
results.push(result);
_a.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/, results];
}

@@ -1013,0 +1059,0 @@ });

2

dist/instant-meilisearch.cjs.min.js

@@ -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,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{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}s((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(s){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,s])}}}function i(t,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;i<a;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function a(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function o(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function u(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})).filter((function(t){return t})):o(t)})).filter((function(t){return t})):[]}function s(t){return""===t?[]:"string"==typeof t?[t]:t}function c(t,e,r){return function(t,e,r){var n=r.trim(),a=s(t),o=s(e);return i(i(i([],a,!0),o,!0),[n],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(u(r||[]),u(e||[]),t||"")}function l(t){var e={},r=t.facets,n=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,s=t.highlightPostTag,l=t.placeholderSearch,f=t.query,d=t.sort,g=t.pagination,h=t.matchingStrategy,p=t.filters,v=t.numericFilters,y=t.facetFilters,m=t.indexUid,b=c(p,v,y);return{getParams:function(){return e},addQuery:function(){e.q=f},addIndexUid:function(){e.indexUid=m},addFacets:function(){Array.isArray(r)?e.facets=r:"string"==typeof r&&(e.facets=[r])},addAttributesToCrop:function(){n&&(e.attributesToCrop=n)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){b.length&&(e.filter=b)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=s||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(b,f,l);if(g.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}}(g,t),n=r.hitsPerPage,i=r.page;e.hitsPerPage=n,e.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}}(g,t),o=a.limit,u=a.offset;e.limit=o,e.offset=u}},addSort:function(){(null==d?void 0:d.length)&&(e.sort=Array.isArray(d)?d:[d])},addGeoSearchFilter:function(){var r=function(t){var e,r,n,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var s=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[h=s[0],p=s[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 c=i.split(",").map((function(t){return parseFloat(t)})),l=c[0],f=c[1],d=c[2],g=c[3];n="_geoBoundingBox([".concat(l,", ").concat(f,"], [").concat(d,", ").concat(g,"])")}else if(null!=e&&null!=r){var h=e[0],p=e[1];n="_geoRadius(".concat(h,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});r&&(e.filter?e.filter.unshift(r):e.filter=[r])},addMatchingStrategy:function(){h&&(e.matchingStrategy=h)}}}function f(t){var e=l(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function d(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function g(t){return Array.isArray(t)?t.map((function(t){return g(t)})):a(t)?Object.keys(t).reduce((function(e,r){return e[r]=g(t[r]),e}),{}):{value:d(t)}}function h(t){if(!t)return{};var e=g(t);return{_highlightResult:e,_snippetResult:e}}function p(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,h(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 v(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function y(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,s=t.facetStats,c=void 0===s?{}:s,l=Object.keys(u),f=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),d=f.hitsPerPage,g=f.page,h=f.nbPages,y=p(t,r),m=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 s in e[u])i[u]||(i[u]=r[u]||{}),i[u][s]?i[u][s]=r[u][s]:i[u][s]=0}return i}(e,r,n=n||{}):n}(r.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:d,page:g,facets:b,nbPages:h,nbHits:m,processingTimeMS:n,query:i,hits:y,params:"",exhaustiveNbHits:!1,facets_stats:v(c)}}(t,e[t.indexUid],r)}));return{results:n}}function m(t,r){var n,i,a,o,u=t.query,s=t.indexName,c=t.params,l=function(t){var e=t.indexOf(":");return-1===e?{indexUid:t,sortBy:""}:{indexUid:t.substring(0,e),sortBy:t.substring(e+1)}}(s),f=l.indexUid,d=l.sortBy,g=(n=r.finitePagination,i=null==c?void 0:c.hitsPerPage,a=null==c?void 0:c.page,{hitsPerPage:void 0===i?20:i,page:a||0,finite:!!n});return e(e(e(e({},r),{query:u}),c),{sort:(o=d,o?o.split(/,(?=\w+:(?:asc|desc))/):[]),indexUid:f,pagination:g,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function b(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 P(t){var r=l(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addIndexUid(),r.addPagination(),r.getParams()}function x(t,e,i){return r(this,void 0,void 0,(function(){var r,a,o,u,s,c;return n(this,(function(n){switch(n.label){case 0:return l="indexUid",f=[],r=function(t){return!f.includes(t[l])&&(f.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,s=o;u<s.length;u++)c=s[u],i[c.indexUid]=c.facetDistribution||{};return[2,i]}var l,f}))}))}var w;exports.MatchingStrategies=void 0,(w=exports.MatchingStrategies||(exports.MatchingStrategies={})).ALL="all",w.LAST="last",exports.instantMeiliSearch=function(i,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,i=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&&!a(n))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(i,o,u);var s={host:i,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.13.3",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(s.httpClient=u.httpClient),void 0!==u.requestConfig&&(s.requestConfig=u.requestConfig);var c,l,d,g=new t.MeiliSearch(s),h=b(),p=(c=g,l=h,{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,c.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={},w=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return h.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,a,o,s,c,l,d,g,h;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),e=[],r=[],i=[],a=0,o=t;a<o.length;a++)s=o[a],c=m(s,u),l=f(c),e.push(l),d=P(c),i.push(d),r.push(c.pagination);return[4,x(p,i,v)];case 1:return v=n.sent(),[4,p.multiSearch(e,r)];case 2:return g=n.sent(),[2,y(g,v,w)];case 3:throw h=n.sent(),console.error(h),new Error(h);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}};
"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{s(n.next(t))}catch(t){a(t)}}function u(t){try{s(n.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(o,u)}s((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(s){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,s])}}}function i(t,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;i<a;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function a(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function o(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function u(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})).filter((function(t){return t})):o(t)})).filter((function(t){return t})):[]}function s(t){return""===t?[]:"string"==typeof t?[t]:t}function c(t,e,r){return function(t,e,r){var n=r.trim(),a=s(t),o=s(e);return i(i(i([],a,!0),o,!0),[n],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(u(r||[]),u(e||[]),t||"")}function l(t){var e={},r=t.facets,n=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,s=t.highlightPostTag,l=t.placeholderSearch,f=t.query,d=t.sort,g=t.pagination,h=t.matchingStrategy,p=t.filters,v=t.numericFilters,y=t.facetFilters,m=t.indexUid,P=c(p,v,y);return{getParams:function(){return e},addQuery:function(){e.q=f},addIndexUid:function(){e.indexUid=m},addFacets:function(){Array.isArray(r)?e.facets=r:"string"==typeof r&&(e.facets=[r])},addAttributesToCrop:function(){n&&(e.attributesToCrop=n)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){P.length&&(e.filter=P)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=s||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(P,f,l);if(g.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}}(g,t),n=r.hitsPerPage,i=r.page;e.hitsPerPage=n,e.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}}(g,t),o=a.limit,u=a.offset;e.limit=o,e.offset=u}},addSort:function(){(null==d?void 0:d.length)&&(e.sort=Array.isArray(d)?d:[d])},addGeoSearchFilter:function(){var r=function(t){var e,r,n,i=t.insideBoundingBox,a=t.aroundLatLng,o=t.aroundRadius,u=t.minimumAroundRadius;if(a){var s=a.split(",").map((function(t){return Number.parseFloat(t).toFixed(5)}));e=[h=s[0],p=s[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 c=i.split(",").map((function(t){return parseFloat(t)})),l=c[0],f=c[1],d=c[2],g=c[3];n="_geoBoundingBox([".concat(l,", ").concat(f,"], [").concat(d,", ").concat(g,"])")}else if(null!=e&&null!=r){var h=e[0],p=e[1];n="_geoRadius(".concat(h,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});r&&(e.filter?e.filter.unshift(r):e.filter=[r])},addMatchingStrategy:function(){h&&(e.matchingStrategy=h)}}}function f(t){var e=l(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function d(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function g(t){return Array.isArray(t)?t.map((function(t){return g(t)})):a(t)?Object.keys(t).reduce((function(e,r){return e[r]=g(t[r]),e}),{}):{value:d(t)}}function h(t){if(!t)return{};var e=g(t);return{_highlightResult:e,_snippetResult:e}}function p(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,h(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 v(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function y(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,s=t.facetStats,c=void 0===s?{}:s,l=Object.keys(u),f=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),d=f.hitsPerPage,g=f.page,h=f.nbPages,y=p(t,r),m=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),P=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 s in e[u])i[u]||(i[u]=r[u]||{}),i[u][s]?i[u][s]=r[u][s]:i[u][s]=0}return i}(e,r,n=n||{}):n}(r.keepZeroFacets,l,e,u);return{index:a,hitsPerPage:d,page:g,facets:P,nbPages:h,nbHits:m,processingTimeMS:n,query:i,hits:y,params:"",exhaustiveNbHits:!1,facets_stats:v(c)}}(t,e[t.indexUid],r)}));return{results:n}}function m(t){return t?t.split(/,(?=\w+:(?:asc|desc))/):[]}function P(t,e,r){return{hitsPerPage:void 0===e?20:e,page:r||0,finite:!!t}}function b(t,r){var n=t.query,i=t.indexName,a=t.params,o=function(t){var e=t.indexOf(":");return-1===e?{indexUid:t,sortBy:""}:{indexUid:t.substring(0,e),sortBy:t.substring(e+1)}}(i),u=o.indexUid,s=o.sortBy,c=P(r.finitePagination,null==a?void 0:a.hitsPerPage,null==a?void 0:a.page);return e(e(e(e({},r),{query:n}),a),{sort:m(s),indexUid:u,pagination:c,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function x(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 S(t){var r=l(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addIndexUid(),r.addPagination(),r.getParams()}function w(t,e,i){return r(this,void 0,void 0,(function(){var r,a,o,u,s,c;return n(this,(function(n){switch(n.label){case 0:return l="indexUid",f=[],r=function(t){return!f.includes(t[l])&&(f.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,s=o;u<s.length;u++)c=s[u],i[c.indexUid]=c.facetDistribution||{};return[2,i]}var l,f}))}))}"function"==typeof SuppressedError&&SuppressedError;var T;exports.MatchingStrategies=void 0,(T=exports.MatchingStrategies||(exports.MatchingStrategies={})).ALL="all",T.LAST="last",exports.instantMeiliSearch=function(i,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,i=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&&!a(n))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(i,o,u);var s={host:i,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.13.4",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(s.httpClient=u.httpClient),void 0!==u.requestConfig&&(s.requestConfig=u.requestConfig);var c,l,d,g=new t.MeiliSearch(s),h=x(),p=(c=g,l=h,{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,c.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={},T=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return h.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,a,o,s,c,l,d,g,h;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),e=[],r=[],i=[],a=0,o=t;a<o.length;a++)s=o[a],c=b(s,u),l=f(c),e.push(l),d=S(c),i.push(d),r.push(c.pagination);return[4,w(p,i,v)];case 1:return v=n.sent(),[4,p.multiSearch(e,r)];case 2:return g=n.sent(),[2,y(g,v,T)];case 3:throw h=n.sent(),console.error(h),new Error(h);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){var r,i,a,o,s,c,l,d,h,p,v;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],s=function(t,r){var n=t.indexName.split(":"),i=n[0],a=n.slice(1),o=t.params,u=P(r.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page),s=m(a.join(":"));return e(e(e({},r),o),{sort:s,indexUid:i,pagination:u,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}(o,u),c=f(s),l=o.indexName,delete(d=e(e({},c),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,g.index(l).searchForFacetValues(d)]):[3,4];case 2:h=n.sent(),p=h.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),v={facetHits:p,exhaustiveFacetsCount:!1,processingTimeMS:h.processingTimeMs},r.push(v),n.label=3;case 3:return i++,[3,1];case 4:return[2,r]}}))}))}}};
//# sourceMappingURL=instant-meilisearch.cjs.min.js.map

@@ -89,2 +89,7 @@ import { MeiliSearch } from 'meilisearch';

typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
function isPureObject(data) {

@@ -832,2 +837,16 @@ return typeof data === 'object' && !Array.isArray(data) && data !== null;

}
/**
* @param {AlgoliaMultipleQueriesQuery} searchRequest
* @param {Context} options
* @returns {SearchContext}
*/
function createFacetSearchContext(searchRequest, options) {
// Split index name and possible sorting rules
var _a = searchRequest.indexName.split(':'), indexUid = _a[0], sortByArray = _a.slice(1);
var instantSearchParams = searchRequest.params;
var paginationState = createPaginationState(options.finitePagination, instantSearchParams === null || instantSearchParams === void 0 ? void 0 : instantSearchParams.hitsPerPage, instantSearchParams === null || instantSearchParams === void 0 ? void 0 : instantSearchParams.page);
var sortState = splitSortString(sortByArray.join(':'));
var searchContext = __assign(__assign(__assign({}, options), instantSearchParams), { sort: sortState, indexUid: indexUid, pagination: paginationState, placeholderSearch: options.placeholderSearch !== false, keepZeroFacets: !!options.keepZeroFacets });
return searchContext;
}

@@ -910,3 +929,3 @@ /**

var PACKAGE_VERSION = '0.13.3';
var PACKAGE_VERSION = '0.13.4';

@@ -998,11 +1017,38 @@ var constructClientAgents = function (clientAgents) {

},
searchForFacetValues: function (_) {
searchForFacetValues: function (requests) {
return __awaiter(this, void 0, void 0, function () {
var results, _i, requests_1, request, searchContext, meilisearchSearchQuery, index, meilisearchRequest, meilisearchResponse, facetHits, result;
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) {
reject(new Error('SearchForFacetValues is not compatible with Meilisearch'));
resolve([]); // added here to avoid compilation error
})];
case 1: return [2 /*return*/, _a.sent()];
case 0:
results = [];
_i = 0, requests_1 = requests;
_a.label = 1;
case 1:
if (!(_i < requests_1.length)) return [3 /*break*/, 4];
request = requests_1[_i];
searchContext = createFacetSearchContext(request, instantMeiliSearchOptions);
meilisearchSearchQuery = adaptSearchParams(searchContext);
index = request.indexName;
meilisearchRequest = __assign(__assign({}, meilisearchSearchQuery), { facetQuery: request.params.facetQuery, facetName: request.params.facetName });
delete meilisearchRequest.indexUid;
return [4 /*yield*/, meilisearchClient
.index(index)
.searchForFacetValues(meilisearchRequest)];
case 2:
meilisearchResponse = _a.sent();
facetHits = meilisearchResponse.facetHits.map(function (facetHit) { return (__assign(__assign({}, facetHit), {
// not currently supported
highlighted: facetHit.value })); });
result = {
facetHits: facetHits,
exhaustiveFacetsCount: false,
processingTimeMS: meilisearchResponse.processingTimeMs
};
results.push(result);
_a.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/, results];
}

@@ -1009,0 +1055,0 @@ });

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

import{MeiliSearch as t}from"meilisearch";var 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,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;i<a;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function a(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function o(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function u(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})).filter((function(t){return t})):o(t)})).filter((function(t){return t})):[]}function c(t){return""===t?[]:"string"==typeof t?[t]:t}function s(t,e,r){return function(t,e,r){var n=r.trim(),a=c(t),o=c(e);return i(i(i([],a,!0),o,!0),[n],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(u(r||[]),u(e||[]),t||"")}function f(t){var e={},r=t.facets,n=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,c=t.highlightPostTag,f=t.placeholderSearch,l=t.query,d=t.sort,g=t.pagination,h=t.matchingStrategy,p=t.filters,v=t.numericFilters,y=t.facetFilters,m=t.indexUid,b=s(p,v,y);return{getParams:function(){return e},addQuery:function(){e.q=l},addIndexUid:function(){e.indexUid=m},addFacets:function(){Array.isArray(r)?e.facets=r:"string"==typeof r&&(e.facets=[r])},addAttributesToCrop:function(){n&&(e.attributesToCrop=n)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){b.length&&(e.filter=b)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=c||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(b,l,f);if(g.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}}(g,t),n=r.hitsPerPage,i=r.page;e.hitsPerPage=n,e.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}}(g,t),o=a.limit,u=a.offset;e.limit=o,e.offset=u}},addSort:function(){(null==d?void 0:d.length)&&(e.sort=Array.isArray(d)?d:[d])},addGeoSearchFilter:function(){var r=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=[h=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)})),f=s[0],l=s[1],d=s[2],g=s[3];n="_geoBoundingBox([".concat(f,", ").concat(l,"], [").concat(d,", ").concat(g,"])")}else if(null!=e&&null!=r){var h=e[0],p=e[1];n="_geoRadius(".concat(h,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});r&&(e.filter?e.filter.unshift(r):e.filter=[r])},addMatchingStrategy:function(){h&&(e.matchingStrategy=h)}}}function l(t){var e=f(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function d(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function g(t){return Array.isArray(t)?t.map((function(t){return g(t)})):a(t)?Object.keys(t).reduce((function(e,r){return e[r]=g(t[r]),e}),{}):{value:d(t)}}function h(t){if(!t)return{};var e=g(t);return{_highlightResult:e,_snippetResult:e}}function p(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,h(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 v(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function y(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,f=Object.keys(u),l=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),d=l.hitsPerPage,g=l.page,h=l.nbPages,y=p(t,r),m=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,f,e,u);return{index:a,hitsPerPage:d,page:g,facets:b,nbPages:h,nbHits:m,processingTimeMS:n,query:i,hits:y,params:"",exhaustiveNbHits:!1,facets_stats:v(s)}}(t,e[t.indexUid],r)}));return{results:n}}function m(t,r){var n,i,a,o,u=t.query,c=t.indexName,s=t.params,f=function(t){var e=t.indexOf(":");return-1===e?{indexUid:t,sortBy:""}:{indexUid:t.substring(0,e),sortBy:t.substring(e+1)}}(c),l=f.indexUid,d=f.sortBy,g=(n=r.finitePagination,i=null==s?void 0:s.hitsPerPage,a=null==s?void 0:s.page,{hitsPerPage:void 0===i?20:i,page:a||0,finite:!!n});return e(e(e(e({},r),{query:u}),s),{sort:(o=d,o?o.split(/,(?=\w+:(?:asc|desc))/):[]),indexUid:l,pagination:g,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function b(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 P(t){var r=f(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addIndexUid(),r.addPagination(),r.getParams()}function w(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 f="indexUid",l=[],r=function(t){return!l.includes(t[f])&&(l.push(t[f]),!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 f,l}))}))}var x;function S(i,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,i=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&&!a(n))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(i,o,u);var c={host:i,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.13.3",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,f,d,g=new t(c),h=b(),p=(s=g,f=h,{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=f.formatKey([t]),(a=f.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]||{}})})),f.setEntry(r,u),[2,u]}}))}))}}),v={},x=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return h.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,a,o,c,s,f,d,g,h;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),e=[],r=[],i=[],a=0,o=t;a<o.length;a++)c=o[a],s=m(c,u),f=l(s),e.push(f),d=P(s),i.push(d),r.push(s.pagination);return[4,w(p,i,v)];case 1:return v=n.sent(),[4,p.multiSearch(e,r)];case 2:return g=n.sent(),[2,y(g,v,x)];case 3:throw h=n.sent(),console.error(h),new Error(h);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){return n(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,e){e(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}}!function(t){t.ALL="all",t.LAST="last"}(x||(x={}));export{x as MatchingStrategies,S as instantMeiliSearch};
import{MeiliSearch as t}from"meilisearch";var 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,e,r){if(r||2===arguments.length)for(var n,i=0,a=e.length;i<a;i++)!n&&i in e||(n||(n=Array.prototype.slice.call(e,0,i)),n[i]=e[i]);return t.concat(n||Array.prototype.slice.call(e))}function a(t){return"object"==typeof t&&!Array.isArray(t)&&null!==t}function o(t){return t.replace(/(.*):(.*)/i,'"$1"="$2"')}function u(t){return"string"==typeof t?o(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return o(t)})).filter((function(t){return t})):o(t)})).filter((function(t){return t})):[]}function c(t){return""===t?[]:"string"==typeof t?[t]:t}function s(t,e,r){return function(t,e,r){var n=r.trim(),a=c(t),o=c(e);return i(i(i([],a,!0),o,!0),[n],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(u(r||[]),u(e||[]),t||"")}function f(t){var e={},r=t.facets,n=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.attributesToHighlight,u=t.highlightPreTag,c=t.highlightPostTag,f=t.placeholderSearch,l=t.query,d=t.sort,g=t.pagination,h=t.matchingStrategy,p=t.filters,v=t.numericFilters,y=t.facetFilters,m=t.indexUid,P=s(p,v,y);return{getParams:function(){return e},addQuery:function(){e.q=l},addIndexUid:function(){e.indexUid=m},addFacets:function(){Array.isArray(r)?e.facets=r:"string"==typeof r&&(e.facets=[r])},addAttributesToCrop:function(){n&&(e.attributesToCrop=n)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){P.length&&(e.filter=P)},addAttributesToHighlight:function(){e.attributesToHighlight=o||["*"]},addPreTag:function(){e.highlightPreTag=u||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=c||"__/ais-highlight__"},addPagination:function(){var t=function(t,e,r){return!!(r||e||t&&0!==t.length)}(P,l,f);if(g.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}}(g,t),n=r.hitsPerPage,i=r.page;e.hitsPerPage=n,e.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}}(g,t),o=a.limit,u=a.offset;e.limit=o,e.offset=u}},addSort:function(){(null==d?void 0:d.length)&&(e.sort=Array.isArray(d)?d:[d])},addGeoSearchFilter:function(){var r=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=[h=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)})),f=s[0],l=s[1],d=s[2],g=s[3];n="_geoBoundingBox([".concat(f,", ").concat(l,"], [").concat(d,", ").concat(g,"])")}else if(null!=e&&null!=r){var h=e[0],p=e[1];n="_geoRadius(".concat(h,", ").concat(p,", ").concat(r,")")}return n}({insideBoundingBox:t.insideBoundingBox,aroundLatLng:t.aroundLatLng,aroundRadius:t.aroundRadius,minimumAroundRadius:t.minimumAroundRadius});r&&(e.filter?e.filter.unshift(r):e.filter=[r])},addMatchingStrategy:function(){h&&(e.matchingStrategy=h)}}}function l(t){var e=f(t);return e.addQuery(),e.addIndexUid(),e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchFilter(),e.addMatchingStrategy(),e.getParams()}function d(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function g(t){return Array.isArray(t)?t.map((function(t){return g(t)})):a(t)?Object.keys(t).reduce((function(e,r){return e[r]=g(t[r]),e}),{}):{value:d(t)}}function h(t){if(!t)return{};var e=g(t);return{_highlightResult:e,_snippetResult:e}}function p(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,h(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 v(t){return Object.keys(t).reduce((function(r,n){return r[n]=e(e({},t[n]),{avg:0,sum:0}),r}),{})}function y(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,f=Object.keys(u),l=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),d=l.hitsPerPage,g=l.page,h=l.nbPages,y=p(t,r),m=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),P=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,f,e,u);return{index:a,hitsPerPage:d,page:g,facets:P,nbPages:h,nbHits:m,processingTimeMS:n,query:i,hits:y,params:"",exhaustiveNbHits:!1,facets_stats:v(s)}}(t,e[t.indexUid],r)}));return{results:n}}function m(t){return t?t.split(/,(?=\w+:(?:asc|desc))/):[]}function P(t,e,r){return{hitsPerPage:void 0===e?20:e,page:r||0,finite:!!t}}function b(t,r){var n=t.query,i=t.indexName,a=t.params,o=function(t){var e=t.indexOf(":");return-1===e?{indexUid:t,sortBy:""}:{indexUid:t.substring(0,e),sortBy:t.substring(e+1)}}(i),u=o.indexUid,c=o.sortBy,s=P(r.finitePagination,null==a?void 0:a.hitsPerPage,null==a?void 0:a.page);return e(e(e(e({},r),{query:n}),a),{sort:m(c),indexUid:u,pagination:s,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}function x(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 S(t){var r=f(e(e({},t),{placeholderSearch:!0,query:""}));return r.addFacets(),r.addIndexUid(),r.addPagination(),r.getParams()}function w(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 f="indexUid",l=[],r=function(t){return!l.includes(t[f])&&(l.push(t[f]),!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 f,l}))}))}"function"==typeof SuppressedError&&SuppressedError;var T;function A(i,o,u){void 0===o&&(o=""),void 0===u&&(u={}),function(t,e,r){var n=r.requestConfig,i=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&&!a(n))throw new TypeError("Provided requestConfig should be an object");if(i&&"function"!=typeof i)throw new TypeError("Provided custom httpClient should be a function")}(i,o,u);var c={host:i,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.13.4",")");return t.concat(e)}(u.clientAgents)};void 0!==u.httpClient&&(c.httpClient=u.httpClient),void 0!==u.requestConfig&&(c.requestConfig=u.requestConfig);var s,f,d,g=new t(c),h=x(),p=(s=g,f=h,{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=f.formatKey([t]),(a=f.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]||{}})})),f.setEntry(r,u),[2,u]}}))}))}}),v={},T=(d=u,e(e({},{placeholderSearch:!0,keepZeroFacets:!1,clientAgents:[],finitePagination:!1}),d));return{clearCache:function(){return h.clearCache()},search:function(t){return r(this,void 0,void 0,(function(){var e,r,i,a,o,c,s,f,d,g,h;return n(this,(function(n){switch(n.label){case 0:for(n.trys.push([0,3,,4]),e=[],r=[],i=[],a=0,o=t;a<o.length;a++)c=o[a],s=b(c,u),f=l(s),e.push(f),d=S(s),i.push(d),r.push(s.pagination);return[4,w(p,i,v)];case 1:return v=n.sent(),[4,p.multiSearch(e,r)];case 2:return g=n.sent(),[2,y(g,v,T)];case 3:throw h=n.sent(),console.error(h),new Error(h);case 4:return[2]}}))}))},searchForFacetValues:function(t){return r(this,void 0,void 0,(function(){var r,i,a,o,c,s,f,d,h,p,v;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=t.indexName.split(":"),i=n[0],a=n.slice(1),o=t.params,u=P(r.finitePagination,null==o?void 0:o.hitsPerPage,null==o?void 0:o.page),c=m(a.join(":"));return e(e(e({},r),o),{sort:c,indexUid:i,pagination:u,placeholderSearch:!1!==r.placeholderSearch,keepZeroFacets:!!r.keepZeroFacets})}(o,u),s=l(c),f=o.indexName,delete(d=e(e({},s),{facetQuery:o.params.facetQuery,facetName:o.params.facetName})).indexUid,[4,g.index(f).searchForFacetValues(d)]):[3,4];case 2:h=n.sent(),p=h.facetHits.map((function(t){return e(e({},t),{highlighted:t.value})})),v={facetHits:p,exhaustiveFacetsCount:!1,processingTimeMS:h.processingTimeMs},r.push(v),n.label=3;case 3:return i++,[3,1];case 4:return[2,r]}}))}))}}}!function(t){t.ALL="all",t.LAST="last"}(T||(T={}));export{T as MatchingStrategies,A as instantMeiliSearch};
//# sourceMappingURL=instant-meilisearch.esm.min.js.map

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

export { createSearchContext } from './search-context';
export { createSearchContext, createFacetSearchContext } from './search-context';
//# sourceMappingURL=index.d.ts.map

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

import { InstantMeiliSearchOptions, AlgoliaMultipleQueriesQuery, SearchContext } from '../types';
import { InstantMeiliSearchOptions, AlgoliaMultipleQueriesQuery, SearchContext, AlgoliaSearchForFacetValuesRequest } from '../types';
/**

@@ -8,2 +8,8 @@ * @param {AlgoliaMultipleQueriesQuery} searchRequest

export declare function createSearchContext(searchRequest: AlgoliaMultipleQueriesQuery, options: InstantMeiliSearchOptions): SearchContext;
/**
* @param {AlgoliaMultipleQueriesQuery} searchRequest
* @param {Context} options
* @returns {SearchContext}
*/
export declare function createFacetSearchContext(searchRequest: AlgoliaSearchForFacetValuesRequest, options: InstantMeiliSearchOptions): SearchContext;
//# sourceMappingURL=search-context.d.ts.map

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

export declare const PACKAGE_VERSION = "0.13.3";
export declare const PACKAGE_VERSION = "0.13.4";
//# sourceMappingURL=package-version.d.ts.map
import type { SearchClient } from 'instantsearch.js';
import type { MultipleQueriesQuery as AlgoliaMultipleQueriesQuery } from '@algolia/client-search';
import type { MultipleQueriesQuery as AlgoliaMultipleQueriesQuery, multipleSearchForFacetValues } from '@algolia/client-search';
import type { MultiSearchQuery as MeiliSearchMultiSearchParams, MultiSearchResult, Config as MeilisearchConfig } from 'meilisearch';
export type { AlgoliaMultipleQueriesQuery, MultiSearchResult };
export type { SearchResponse as AlgoliaSearchResponse, SearchForFacetValuesResponse as AlgoliaSearchForFacetValuesResponse, } from '@algolia/client-search';
export type AlgoliaSearchForFacetValuesRequests = Parameters<ReturnType<typeof multipleSearchForFacetValues>>[0];
export type AlgoliaSearchForFacetValuesRequest = AlgoliaSearchForFacetValuesRequests[0];
export type { Filter, FacetDistribution, MeiliSearch, FacetStats as MeiliFacetStats, MultiSearchQuery as MeiliSearchMultiSearchParams, Config as MeilisearchConfig, } from 'meilisearch';

@@ -7,0 +9,0 @@ export type InstantSearchParams = AlgoliaMultipleQueriesQuery['params'];

{
"name": "@meilisearch/instant-meilisearch",
"version": "0.13.3",
"version": "0.13.4",
"private": false,

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

"dependencies": {
"meilisearch": "^0.33.0"
"meilisearch": "^0.34.0"
},
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/cli": "^7.22.9",
"@babel/core": "^7.20.12",

@@ -79,5 +79,5 @@ "@babel/preset-env": "^7.21.4",

"ts-jest": "^27.0.7",
"tslib": "^2.4.1",
"tslib": "^2.6.1",
"typescript": "^4.9.5"
}
}

@@ -710,7 +710,7 @@ <p align="center">

- ✅ showMoreLimit: The maximum number of displayed items. Does not work when showMoreLimit > limit.
- ❌ searchable: Whether to add a search input to let the user search for more facet values. Not supported by Meilisearch. If you'd like to see it implemented [please vote](https://roadmap.meilisearch.com/c/64-search-for-facet-values?utm_medium=social&utm_source=portal_share).
- ❌ searchablePlaceholder: The value of the search input’s placeholder. Not supported, see `searchable`.
- ❌ searchableIsAlwaysActive: When false, disables the facet search input. Not supported, see `searchable`.
- ❌ searchableEscapeFacetValues: When true, escapes the facet values. Not supported, see `searchable`.
- ❌ sortBy: Not supported natively but can be implemented manually using `transformItems` options.
- ✅ searchable: Whether to add a search input to let the user search for more facet values. Not supported by Meilisearch. If you'd like to see it implemented [please vote](https://roadmap.meilisearch.com/c/64-search-for-facet-values?utm_medium=social&utm_source=portal_share).
- ✅ searchablePlaceholder: The value of the search input’s placeholder. Not supported, see `searchable`.
- ✅ searchableIsAlwaysActive: When false, disables the facet search input. Not supported, see `searchable`.
- ❌ searchableEscapeFacetValues: When true, escapes the facet values.
- ❌ sortBy: Not supported but can be implemented manually using `transformItems` options.
- ✅ transformItems: A function to transform the items passed to the templates.

@@ -717,0 +717,0 @@ - ✅ templates: The templates to use for the widget.

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

MeilisearchConfig,
AlgoliaSearchForFacetValuesRequests,
AlgoliaSearchForFacetValuesResponse,
} from '../types'

@@ -23,3 +25,3 @@ import {

} from '../adapter'
import { createSearchContext } from '../contexts'
import { createSearchContext, createFacetSearchContext } from '../contexts'
import {

@@ -137,11 +139,46 @@ SearchCache,

},
searchForFacetValues: async function (_: any) {
return await new Promise((resolve, reject) => {
reject(
new Error('SearchForFacetValues is not compatible with Meilisearch')
searchForFacetValues: async function (
requests: AlgoliaSearchForFacetValuesRequests
): Promise<AlgoliaSearchForFacetValuesResponse[]> {
const results = []
for (const request of requests) {
const searchContext: SearchContext = createFacetSearchContext(
request,
instantMeiliSearchOptions
)
resolve([]) // added here to avoid compilation error
})
const meilisearchSearchQuery = adaptSearchParams(searchContext)
const index = request.indexName
const meilisearchRequest: any = {
...meilisearchSearchQuery,
facetQuery: request.params.facetQuery,
facetName: request.params.facetName,
}
delete meilisearchRequest.indexUid
const meilisearchResponse = await meilisearchClient
.index(index)
.searchForFacetValues(meilisearchRequest)
const facetHits = meilisearchResponse.facetHits.map((facetHit) => ({
...facetHit,
// not currently supported
highlighted: facetHit.value,
}))
const result = {
facetHits,
exhaustiveFacetsCount: false,
processingTimeMS: meilisearchResponse.processingTimeMs,
}
results.push(result)
}
return results
},
}
}

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

export { createSearchContext } from './search-context'
export { createSearchContext, createFacetSearchContext } from './search-context'

@@ -5,2 +5,3 @@ import {

SearchContext,
AlgoliaSearchForFacetValuesRequest,
} from '../types'

@@ -58,1 +59,34 @@ import { splitSortString } from './sort-context'

}
/**
* @param {AlgoliaMultipleQueriesQuery} searchRequest
* @param {Context} options
* @returns {SearchContext}
*/
export function createFacetSearchContext(
searchRequest: AlgoliaSearchForFacetValuesRequest,
options: InstantMeiliSearchOptions
): SearchContext {
// Split index name and possible sorting rules
const [indexUid, ...sortByArray] = searchRequest.indexName.split(':')
const { params: instantSearchParams } = searchRequest
const paginationState = createPaginationState(
options.finitePagination,
instantSearchParams?.hitsPerPage,
instantSearchParams?.page
)
const sortState = splitSortString(sortByArray.join(':'))
const searchContext: SearchContext = {
...options,
...instantSearchParams,
sort: sortState,
indexUid,
pagination: paginationState,
placeholderSearch: options.placeholderSearch !== false, // true by default
keepZeroFacets: !!options.keepZeroFacets, // false by default
}
return searchContext
}

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

export const PACKAGE_VERSION = '0.13.3'
export const PACKAGE_VERSION = '0.13.4'
import type { SearchClient } from 'instantsearch.js'
import type { MultipleQueriesQuery as AlgoliaMultipleQueriesQuery } from '@algolia/client-search'
import type {
MultipleQueriesQuery as AlgoliaMultipleQueriesQuery,
multipleSearchForFacetValues,
} from '@algolia/client-search'
import type {
MultiSearchQuery as MeiliSearchMultiSearchParams,

@@ -15,2 +18,9 @@ MultiSearchResult,

export type AlgoliaSearchForFacetValuesRequests = Parameters<
ReturnType<typeof multipleSearchForFacetValues>
>[0]
export type AlgoliaSearchForFacetValuesRequest =
AlgoliaSearchForFacetValuesRequests[0]
export type {

@@ -17,0 +27,0 @@ Filter,

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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