@meilisearch/instant-meilisearch
Advanced tools
Comparing version 0.8.0 to 0.8.1-optional-words-beta.0
@@ -7,3 +7,3 @@ 'use strict'; | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -84,6 +84,10 @@ | ||
function __spreadArray(to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
function __spreadArray(to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
} | ||
@@ -176,3 +180,3 @@ | ||
var prevFields = cache[filterName] || []; | ||
cache = __assign(__assign({}, cache), (_a = {}, _a[filterName] = __spreadArray(__spreadArray([], prevFields, true), [value]), _a)); | ||
cache = __assign(__assign({}, cache), (_a = {}, _a[filterName] = __spreadArray(__spreadArray([], prevFields, true), [value], false), _a)); | ||
return cache; | ||
@@ -499,3 +503,3 @@ }, {}); | ||
adaptedFilters, | ||
]); | ||
], false); | ||
var cleanedFilters = adaptedFilter.filter(function (filter) { | ||
@@ -525,2 +529,108 @@ if (Array.isArray(filter)) { | ||
/** | ||
* Adapts instantsearch.js and instant-meilisearch options | ||
* to meilisearch search query parameters. | ||
* | ||
* @param {SearchContext} searchContext | ||
* | ||
* @returns {MeiliSearchParams} | ||
*/ | ||
function MeiliParamsCreator(searchContext) { | ||
var meiliSearchParams = {}; | ||
var facets = searchContext.facets, attributesToSnippet = searchContext.attributesToSnippet, snippetEllipsisText = searchContext.snippetEllipsisText, attributesToRetrieve = searchContext.attributesToRetrieve, filters = searchContext.filters, numericFilters = searchContext.numericFilters, facetFilters = searchContext.facetFilters, attributesToHighlight = searchContext.attributesToHighlight, highlightPreTag = searchContext.highlightPreTag, highlightPostTag = searchContext.highlightPostTag, placeholderSearch = searchContext.placeholderSearch, query = searchContext.query, finitePagination = searchContext.finitePagination, sort = searchContext.sort, pagination = searchContext.pagination, optionalWords = searchContext.optionalWords; | ||
return { | ||
getParams: function () { | ||
return meiliSearchParams; | ||
}, | ||
addFacets: function () { | ||
if (facets === null || facets === void 0 ? void 0 : facets.length) { | ||
meiliSearchParams.facets = facets; | ||
} | ||
}, | ||
addAttributesToCrop: function () { | ||
if (attributesToSnippet) { | ||
meiliSearchParams.attributesToCrop = attributesToSnippet; | ||
} | ||
}, | ||
addCropMarker: function () { | ||
// Attributes To Crop marker | ||
if (snippetEllipsisText != null) { | ||
meiliSearchParams.cropMarker = snippetEllipsisText; | ||
} | ||
}, | ||
addAttributesToRetrieve: function () { | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToRetrieve = attributesToRetrieve; | ||
} | ||
}, | ||
addFilters: function () { | ||
var filter = adaptFilters(filters, numericFilters, facetFilters); | ||
if (filter.length) { | ||
meiliSearchParams.filter = filter; | ||
} | ||
}, | ||
addAttributesToHighlight: function () { | ||
meiliSearchParams.attributesToHighlight = attributesToHighlight || ['*']; | ||
}, | ||
addPreTag: function () { | ||
if (highlightPreTag) { | ||
meiliSearchParams.highlightPreTag = highlightPreTag; | ||
} | ||
else { | ||
meiliSearchParams.highlightPreTag = '__ais-highlight__'; | ||
} | ||
}, | ||
addPostTag: function () { | ||
if (highlightPostTag) { | ||
meiliSearchParams.highlightPostTag = highlightPostTag; | ||
} | ||
else { | ||
meiliSearchParams.highlightPostTag = '__/ais-highlight__'; | ||
} | ||
}, | ||
addPagination: function () { | ||
// Limit based on pagination preferences | ||
if ((!placeholderSearch && query === '') || | ||
pagination.paginationTotalHits === 0) { | ||
meiliSearchParams.limit = 0; | ||
} | ||
else if (finitePagination) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits; | ||
} | ||
else { | ||
var limit = (pagination.page + 1) * pagination.hitsPerPage + 1; | ||
// If the limit is bigger than the total hits accepted | ||
// force the limit to that amount | ||
if (limit > pagination.paginationTotalHits) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits; | ||
} | ||
else { | ||
meiliSearchParams.limit = limit; | ||
} | ||
} | ||
}, | ||
addSort: function () { | ||
if (sort === null || sort === void 0 ? void 0 : sort.length) { | ||
meiliSearchParams.sort = [sort]; | ||
} | ||
}, | ||
addGeoSearchRules: function () { | ||
var geoSearchContext = createGeoSearchContext(searchContext); | ||
var geoRules = adaptGeoPointsRules(geoSearchContext); | ||
if (geoRules === null || geoRules === void 0 ? void 0 : geoRules.filter) { | ||
if (meiliSearchParams.filter) { | ||
meiliSearchParams.filter.unshift(geoRules.filter); | ||
} | ||
else { | ||
meiliSearchParams.filter = [geoRules.filter]; | ||
} | ||
} | ||
}, | ||
addOptionalWords: function () { | ||
if (optionalWords) { | ||
meiliSearchParams.optionalWords = optionalWords; | ||
} | ||
} | ||
}; | ||
} | ||
/** | ||
* Adapt search request from instantsearch.js | ||
@@ -533,92 +643,16 @@ * to search request compliant with Meilisearch | ||
function adaptSearchParams(searchContext) { | ||
// Creates search params object compliant with Meilisearch | ||
var meiliSearchParams = {}; | ||
// Facets | ||
var facets = searchContext === null || searchContext === void 0 ? void 0 : searchContext.facets; | ||
if (facets === null || facets === void 0 ? void 0 : facets.length) { | ||
meiliSearchParams.facets = facets; | ||
} | ||
// Attributes To Crop | ||
var attributesToCrop = searchContext === null || searchContext === void 0 ? void 0 : searchContext.attributesToSnippet; | ||
if (attributesToCrop) { | ||
meiliSearchParams.attributesToCrop = attributesToCrop; | ||
} | ||
// Attributes To Crop marker | ||
var cropMarker = searchContext === null || searchContext === void 0 ? void 0 : searchContext.snippetEllipsisText; | ||
if (cropMarker != null) { | ||
meiliSearchParams.cropMarker = cropMarker; | ||
} | ||
// Attributes To Retrieve | ||
var attributesToRetrieve = searchContext === null || searchContext === void 0 ? void 0 : searchContext.attributesToRetrieve; | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToRetrieve = attributesToRetrieve; | ||
} | ||
// Filter | ||
var filter = adaptFilters(searchContext === null || searchContext === void 0 ? void 0 : searchContext.filters, searchContext === null || searchContext === void 0 ? void 0 : searchContext.numericFilters, searchContext === null || searchContext === void 0 ? void 0 : searchContext.facetFilters); | ||
if (filter.length) { | ||
meiliSearchParams.filter = filter; | ||
} | ||
// Attributes To Retrieve | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToCrop = attributesToRetrieve; | ||
} | ||
// Attributes To Highlight | ||
meiliSearchParams.attributesToHighlight = (searchContext === null || searchContext === void 0 ? void 0 : searchContext.attributesToHighlight) || [ | ||
'*', | ||
]; | ||
// Highlight pre tag | ||
var highlightPreTag = searchContext === null || searchContext === void 0 ? void 0 : searchContext.highlightPreTag; | ||
if (highlightPreTag) { | ||
meiliSearchParams.highlightPreTag = highlightPreTag; | ||
} | ||
else { | ||
meiliSearchParams.highlightPreTag = '__ais-highlight__'; | ||
} | ||
// Highlight post tag | ||
var highlightPostTag = searchContext === null || searchContext === void 0 ? void 0 : searchContext.highlightPostTag; | ||
if (highlightPostTag) { | ||
meiliSearchParams.highlightPostTag = highlightPostTag; | ||
} | ||
else { | ||
meiliSearchParams.highlightPostTag = '__/ais-highlight__'; | ||
} | ||
var placeholderSearch = searchContext.placeholderSearch; | ||
var query = searchContext.query; | ||
// Pagination | ||
var pagination = searchContext.pagination; | ||
// Limit based on pagination preferences | ||
if ((!placeholderSearch && query === '') || | ||
pagination.paginationTotalHits === 0) { | ||
meiliSearchParams.limit = 0; | ||
} | ||
else if (searchContext.finitePagination) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits; | ||
} | ||
else { | ||
var limit = (pagination.page + 1) * pagination.hitsPerPage + 1; | ||
// If the limit is bigger than the total hits accepted | ||
// force the limit to that amount | ||
if (limit > pagination.paginationTotalHits) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits; | ||
} | ||
else { | ||
meiliSearchParams.limit = limit; | ||
} | ||
} | ||
var sort = searchContext.sort; | ||
// Sort | ||
if (sort === null || sort === void 0 ? void 0 : sort.length) { | ||
meiliSearchParams.sort = [sort]; | ||
} | ||
var geoSearchContext = createGeoSearchContext(searchContext); | ||
var geoRules = adaptGeoPointsRules(geoSearchContext); | ||
if (geoRules === null || geoRules === void 0 ? void 0 : geoRules.filter) { | ||
if (meiliSearchParams.filter) { | ||
meiliSearchParams.filter.unshift(geoRules.filter); | ||
} | ||
else { | ||
meiliSearchParams.filter = [geoRules.filter]; | ||
} | ||
} | ||
return meiliSearchParams; | ||
var meilisearchParams = MeiliParamsCreator(searchContext); | ||
meilisearchParams.addFacets(); | ||
meilisearchParams.addAttributesToHighlight(); | ||
meilisearchParams.addPreTag(); | ||
meilisearchParams.addPostTag(); | ||
meilisearchParams.addAttributesToRetrieve(); | ||
meilisearchParams.addAttributesToCrop(); | ||
meilisearchParams.addCropMarker(); | ||
meilisearchParams.addPagination(); | ||
meilisearchParams.addFilters(); | ||
meilisearchParams.addSort(); | ||
meilisearchParams.addGeoSearchRules(); | ||
meilisearchParams.addOptionalWords(); | ||
return meilisearchParams.getParams(); | ||
} | ||
@@ -810,3 +844,3 @@ | ||
}); | ||
var searchContext = __assign(__assign(__assign({}, options), instantSearchParams), { sort: sortByArray.join(':') || '', indexUid: indexUid, pagination: pagination, defaultFacetDistribution: defaultFacetDistribution, placeholderSearch: options.placeholderSearch !== false, keepZeroFacets: !!options.keepZeroFacets, finitePagination: !!options.finitePagination }); | ||
var searchContext = __assign(__assign(__assign({}, options), instantSearchParams), { sort: sortByArray.join(':') || '', indexUid: indexUid, pagination: pagination, defaultFacetDistribution: defaultFacetDistribution, placeholderSearch: options.placeholderSearch !== false, keepZeroFacets: !!options.keepZeroFacets, finitePagination: !!options.finitePagination, optionalWords: options.optionalWords || 'last' }); | ||
return searchContext; | ||
@@ -839,2 +873,5 @@ } | ||
searchCache[key] = JSON.stringify(searchResponse); | ||
}, | ||
clearCache: function () { | ||
searchCache = {}; | ||
} | ||
@@ -852,3 +889,3 @@ }; | ||
var PACKAGE_VERSION = '0.8.0'; | ||
var PACKAGE_VERSION = '0.8.1-optional-words-beta.0'; | ||
@@ -872,4 +909,5 @@ var constructClientAgents = function (clientAgents) { | ||
if (instantMeiliSearchOptions === void 0) { instantMeiliSearchOptions = {}; } | ||
var searchCache = SearchCache(); | ||
// create search resolver with included cache | ||
var searchResolver = SearchResolver(SearchCache()); | ||
var searchResolver = SearchResolver(searchCache); | ||
// paginationTotalHits can be 0 as it is a valid number | ||
@@ -884,2 +922,3 @@ var defaultFacetDistribution = {}; | ||
return { | ||
clearCache: function () { return searchCache.clearCache(); }, | ||
/** | ||
@@ -886,0 +925,0 @@ * @param {readonlyAlgoliaMultipleQueriesQuery[]} instantSearchRequests |
@@ -1,16 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("meilisearch"),n=function(){return(n=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t}).apply(this,arguments)}; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function e(t,n,e,r){return new(e||(e=Promise))((function(i,a){function o(t){try{s(r.next(t))}catch(t){a(t)}}function u(t){try{s(r.throw(t))}catch(t){a(t)}}function s(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(o,u)}s((r=r.apply(t,n||[])).next())}))}function r(t,n){var e,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(a){return function(u){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;o;)try{if(e=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=n.call(t,o)}catch(t){a=[6,t],r=0}finally{e=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t}function a(t){return t.replace(/:(.*)/i,'="$1"')}var o=function(t){var n=t.match(/([^=]*)="?([^\\"]*)"?$/);return n?(n[0],[{filterName:n[1],value:n[2]}]):[]};function u(t){var e=function(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)})):o(t)})).flat(2):[]}(t);return e.filter((function(t){return void 0!==t})).reduce((function(t,e){var r,a=e.filterName,o=e.value,u=t[a]||[];return t=n(n({},t),((r={})[a]=i(i([],u),[o]),r))}),{})}function s(t,e){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,e){var i,a=Object.keys(r[e]);return n(n({},t),((i={})[e]=a,i))}),{})):u(null==e?void 0:e.filter);var r}var c={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function l(t){return{searchResponse:function(n,i,a){return e(this,void 0,void 0,(function(){var e,o,u,l,f,h,p,g;return r(this,(function(r){switch(r.label){case 0:return e=n.placeholderSearch,o=n.query,e||o?(u=n.pagination,l=n.finitePagination?{}:u,f=t.formatKey([i,n.indexUid,n.query,l]),(h=t.getEntry(f))?[2,h]:(p=s(n,i),[4,a.index(n.indexUid).search(n.query,i)])):[2,c];case 1:return(g=r.sent()).facetDistribution=function(t,n){if(n=n||{},t&&Object.keys(t).length>0)for(var e in t){n[e]||(n[e]={});for(var r=0,i=t[e];r<i.length;r++){var a=i[r];Object.keys(n[e]).includes(a)||(n[e][a]=0)}}return n}(p,g.facetDistribution),t.setEntry(f,g),[2,g]}}))}))}}}function f(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function p(t){if(t){var n,e,r=t.insideBoundingBox,i=t.aroundLatLng,a=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(n=i),null==a&&null==o||(e=null!=a?a:o),r&&"string"==typeof r){var u=r.split(","),s=u[0],c=u[1],l=u[2],p=u[3],g=[parseFloat(s),parseFloat(c),parseFloat(l),parseFloat(p)],d=g[0],v=g[1],y=g[2],m=g[3];e=function(t,n,e,r){var i=t*Math.PI/180,a=e*Math.PI/180,o=(e-t)*Math.PI/180,u=(r-n)*Math.PI/180,s=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(a)*Math.sin(u/2)*Math.sin(u/2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6371e3}(d,v,y,m)/2,n=function(t,n,e,r){t=h(t),n=h(n);var i=Math.cos(t)*Math.cos(n),a=Math.cos(t)*Math.sin(n),o=Math.sin(t);e=h(e),r=h(r);var u=i+Math.cos(e)*Math.cos(r),s=a+Math.cos(e)*Math.sin(r),c=o+Math.sin(e),l=Math.sqrt(u*u+s*s),p=Math.atan2(s,u),g=Math.atan2(c,l);return n<r||n>r&&n>Math.PI&&r<-Math.PI?(g+=Math.PI,p+=Math.PI):(g=f(g),p=f(p)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(g=0,p=0),"".concat(g,",").concat(p)}(d,v,y,m)}if(null!=n&&null!=e){var b=n.split(","),P=b[0],M=b[1];return P=Number.parseFloat(P).toFixed(5),M=Number.parseFloat(M).toFixed(5),{filter:"_geoRadius(".concat(P,", ").concat(M,", ").concat(e,")")}}}}function g(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function d(t){return""===t?[]:"string"==typeof t?[t]:t}function v(t,n,e){return function(t,n,e){var r=e.trim(),a=d(t),o=d(n);return i(i(i([],a),o),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(g(e||[]),g(n||[]),t||"")}function y(t){var n={},e=null==t?void 0:t.facets;(null==e?void 0:e.length)&&(n.facets=e);var r=null==t?void 0:t.attributesToSnippet;r&&(n.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(n.cropMarker=i);var a=null==t?void 0:t.attributesToRetrieve;a&&(n.attributesToRetrieve=a);var o=v(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);o.length&&(n.filter=o),a&&(n.attributesToCrop=a),n.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var u=null==t?void 0:t.highlightPreTag;n.highlightPreTag=u||"__ais-highlight__";var s=null==t?void 0:t.highlightPostTag;n.highlightPostTag=s||"__/ais-highlight__";var c=t.placeholderSearch,l=t.query,f=t.pagination;if(!c&&""===l||0===f.paginationTotalHits)n.limit=0;else if(t.finitePagination)n.limit=f.paginationTotalHits;else{var h=(f.page+1)*f.hitsPerPage+1;h>f.paginationTotalHits?n.limit=f.paginationTotalHits:n.limit=h}var g=t.sort;(null==g?void 0:g.length)&&(n.sort=[g]);var d=p(function(t){var n={},e=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,u=t.insideBoundingBox,s=t.insidePolygon;return e&&(n.aroundLatLng=e),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(n.aroundRadius=i),a&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(n.minimumAroundRadius=o),u&&(n.insideBoundingBox=u),s&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),n}(t));return(null==d?void 0:d.filter)&&(n.filter?n.filter.unshift(d.filter):n.filter=[d.filter]),n}function m(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function b(t){return Array.isArray(t)?t.map((function(t){return b(t)})):"object"!=typeof(n=t)||Array.isArray(n)||null===n?{value:m(t)}:Object.keys(t).reduce((function(n,e){return n[e]=b(t[e]),n}),{});var n}function P(t,n,e){var r=n.primaryKey,i=e.hitsPerPage,a=function(t,n,e){if(e<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=n*e;return t.slice(r,r+e)}(t,e.page,i).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesPosition;var e=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]])}return e}(t,["_formatted","_matchesPosition"]),i=Object.assign(e,function(t){if(!t)return{};var n=b(t);return{_highlightResult:n,_snippetResult:n}}(n));return r&&(i.objectID=t[r]),i}return t}));return a=function(t){for(var n=0;n<t.length;n++)t[n]._geo&&(t[n]._geoloc={lat:t[n]._geo.lat,lng:t[n]._geo.lng},t[n].objectID="".concat(n+1e6*Math.random()),delete t[n]._geo);return t}(a)}function M(t,e){var r,i,a=t.facetDistribution,o=e.pagination,u=(r=t.hits.length,(i=o.hitsPerPage)>0?Math.ceil(r/i):0),s=P(t.hits,e,o),c=t.estimatedTotalHits,l=t.processingTimeMs,f=t.query,h=o.hitsPerPage,p=o.page;return{results:[n({index:e.indexUid,hitsPerPage:h,page:p,facets:a,nbPages:u,nbHits:c,processingTimeMS:l,query:f,hits:s,params:"",exhaustiveNbHits:!1},{})]}}function w(t){void 0===t&&(t={});var n=t;return{getEntry:function(t){if(n[t])try{return JSON.parse(n[t])}catch(e){return n[t]}},formatKey:function(t){return t.reduce((function(t,n){return t+JSON.stringify(n)}),"")},setEntry:function(t,e){n[t]=JSON.stringify(e)}}}exports.instantMeiliSearch=function(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u=l(w()),s={},c=function(t){void 0===t&&(t=[]);var n="Meilisearch instant-meilisearch (v".concat("0.8.0",")");return t.concat(n)}(o.clientAgents),f=new t.MeiliSearch({host:i,apiKey:a,clientAgents:c});return{search:function(t){return e(this,void 0,void 0,(function(){var e,i,a,c,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=t[0],i=function(t,e,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),u=t.params,s=function(t){var n=t.paginationTotalHits,e=t.hitsPerPage;return{paginationTotalHits:null!=n?n:200,hitsPerPage:void 0===e?20:e,page:t.page||0}}({paginationTotalHits:e.paginationTotalHits,hitsPerPage:null==u?void 0:u.hitsPerPage,page:null==u?void 0:u.page});return n(n(n({},e),u),{sort:o.join(":")||"",indexUid:a,pagination:s,defaultFacetDistribution:r,placeholderSearch:!1!==e.placeholderSearch,keepZeroFacets:!!e.keepZeroFacets,finitePagination:!!e.finitePagination})}(e,o,s),a=y(i),[4,u.searchResponse(i,a,f)];case 1:return c=r.sent(),s=function(t,n){return""===n.query&&0===Object.keys(t).length?n.facetDistribution:t}(s,c),[2,M(c,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return e(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){n(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,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{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,s)}u((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:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function i(t,e,n){if(n||2===arguments.length)for(var r,i=0,a=e.length;i<a;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function a(t){return t.replace(/:(.*)/i,'="$1"')}var o=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[]};function s(t){var n=function(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)})):o(t)})).flat(2):[]}(t);return n.filter((function(t){return void 0!==t})).reduce((function(t,n){var r,a=n.filterName,o=n.value,s=t[a]||[];return t=e(e({},t),((r={})[a]=i(i([],s,!0),[o],!1),r))}),{})}function u(t,n){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,n){var i,a=Object.keys(r[n]);return e(e({},t),((i={})[n]=a,i))}),{})):s(null==n?void 0:n.filter);var r}var c={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function l(t){return{searchResponse:function(e,i,a){return n(this,void 0,void 0,(function(){var n,o,s,l,f,h,d,p;return r(this,(function(r){switch(r.label){case 0:return n=e.placeholderSearch,o=e.query,n||o?(s=e.pagination,l=e.finitePagination?{}:s,f=t.formatKey([i,e.indexUid,e.query,l]),(h=t.getEntry(f))?[2,h]:(d=u(e,i),[4,a.index(e.indexUid).search(e.query,i)])):[2,c];case 1:return(p=r.sent()).facetDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var n in t){e[n]||(e[n]={});for(var r=0,i=t[n];r<i.length;r++){var a=i[r];Object.keys(e[n]).includes(a)||(e[n][a]=0)}}return e}(d,p.facetDistribution),t.setEntry(f,p),[2,p]}}))}))}}}function f(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function d(t){if(t){var e,n,r=t.insideBoundingBox,i=t.aroundLatLng,a=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(e=i),null==a&&null==o||(n=null!=a?a:o),r&&"string"==typeof r){var s=r.split(","),u=s[0],c=s[1],l=s[2],d=s[3],p=[parseFloat(u),parseFloat(c),parseFloat(l),parseFloat(d)],g=p[0],y=p[1],v=p[2],b=p[3];n=function(t,e,n,r){var i=t*Math.PI/180,a=n*Math.PI/180,o=(n-t)*Math.PI/180,s=(r-e)*Math.PI/180,u=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(a)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u))*6371e3}(g,y,v,b)/2,e=function(t,e,n,r){t=h(t),e=h(e);var i=Math.cos(t)*Math.cos(e),a=Math.cos(t)*Math.sin(e),o=Math.sin(t);n=h(n),r=h(r);var s=i+Math.cos(n)*Math.cos(r),u=a+Math.cos(n)*Math.sin(r),c=o+Math.sin(n),l=Math.sqrt(s*s+u*u),d=Math.atan2(u,s),p=Math.atan2(c,l);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(p+=Math.PI,d+=Math.PI):(p=f(p),d=f(d)),Math.abs(s)<Math.pow(10,-9)&&Math.abs(u)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(p=0,d=0),"".concat(p,",").concat(d)}(g,y,v,b)}if(null!=e&&null!=n){var m=e.split(","),P=m[0],M=m[1];return P=Number.parseFloat(P).toFixed(5),M=Number.parseFloat(M).toFixed(5),{filter:"_geoRadius(".concat(P,", ").concat(M,", ").concat(n,")")}}}}function p(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function g(t){return""===t?[]:"string"==typeof t?[t]:t}function y(t,e,n){return function(t,e,n){var r=n.trim(),a=g(t),o=g(e);return i(i(i([],a,!0),o,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(p(n||[]),p(e||[]),t||"")}function v(t){var e={},n=t.facets,r=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.filters,s=t.numericFilters,u=t.facetFilters,c=t.attributesToHighlight,l=t.highlightPreTag,f=t.highlightPostTag,h=t.placeholderSearch,p=t.query,g=t.finitePagination,v=t.sort,b=t.pagination,m=t.optionalWords;return{getParams:function(){return e},addFacets:function(){(null==n?void 0:n.length)&&(e.facets=n)},addAttributesToCrop:function(){r&&(e.attributesToCrop=r)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){a&&(e.attributesToRetrieve=a)},addFilters:function(){var t=y(o,s,u);t.length&&(e.filter=t)},addAttributesToHighlight:function(){e.attributesToHighlight=c||["*"]},addPreTag:function(){e.highlightPreTag=l||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=f||"__/ais-highlight__"},addPagination:function(){if(!h&&""===p||0===b.paginationTotalHits)e.limit=0;else if(g)e.limit=b.paginationTotalHits;else{var t=(b.page+1)*b.hitsPerPage+1;t>b.paginationTotalHits?e.limit=b.paginationTotalHits:e.limit=t}},addSort:function(){(null==v?void 0:v.length)&&(e.sort=[v])},addGeoSearchRules:function(){var n=function(t){var e={},n=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,s=t.insideBoundingBox,u=t.insidePolygon;return n&&(e.aroundLatLng=n),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(e.aroundRadius=i),a&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(e.minimumAroundRadius=o),s&&(e.insideBoundingBox=s),u&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),e}(t),r=d(n);(null==r?void 0:r.filter)&&(e.filter?e.filter.unshift(r.filter):e.filter=[r.filter])},addOptionalWords:function(){m&&(e.optionalWords=m)}}}function b(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function m(t){return Array.isArray(t)?t.map((function(t){return m(t)})):"object"!=typeof(e=t)||Array.isArray(e)||null===e?{value:b(t)}:Object.keys(t).reduce((function(e,n){return e[n]=m(t[n]),e}),{});var e}function P(t,e,n){var r=e.primaryKey,i=n.hitsPerPage,a=function(t,e,n){if(n<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=e*n;return t.slice(r,r+n)}(t,n.page,i),o=a.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"]),i=Object.assign(n,function(t){if(!t)return{};var e=m(t);return{_highlightResult:e,_snippetResult:e}}(e));return r&&(i.objectID=t[r]),i}return t}));return o=function(t){for(var e=0;e<t.length;e++)t[e]._geo&&(t[e]._geoloc={lat:t[e]._geo.lat,lng:t[e]._geo.lng},t[e].objectID="".concat(e+1e6*Math.random()),delete t[e]._geo);return t}(o),o}function M(t,n){var r,i,a=t.facetDistribution,o=n.pagination,s=(r=t.hits.length,(i=o.hitsPerPage)>0?Math.ceil(r/i):0),u=P(t.hits,n,o),c=t.estimatedTotalHits,l=t.processingTimeMs,f=t.query,h=o.hitsPerPage,d=o.page;return{results:[e({index:n.indexUid,hitsPerPage:h,page:d,facets:a,nbPages:s,nbHits:c,processingTimeMS:l,query:f,hits:u,params:"",exhaustiveNbHits:!1},{})]}}function T(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(n){return e[t]}},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={}}}}exports.instantMeiliSearch=function(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var s=T(),u=l(s),c={},f=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.8.1-optional-words-beta.0",")");return t.concat(e)}(o.clientAgents),h=new t.MeiliSearch({host:i,apiKey:a,clientAgents:f});return{clearCache:function(){return s.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,s,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=t[0],i=function(t,n,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),s=t.params,u=function(t){var e=t.paginationTotalHits,n=t.hitsPerPage;return{paginationTotalHits:null!=e?e:200,hitsPerPage:void 0===n?20:n,page:t.page||0}}({paginationTotalHits:n.paginationTotalHits,hitsPerPage:null==s?void 0:s.hitsPerPage,page:null==s?void 0:s.page});return e(e(e({},n),s),{sort:o.join(":")||"",indexUid:a,pagination:u,defaultFacetDistribution:r,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets,finitePagination:!!n.finitePagination,optionalWords:n.optionalWords||"last"})}(n,o,c),a=function(t){var e=v(t);return e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchRules(),e.addOptionalWords(),e.getParams()}(i),[4,u.searchResponse(i,a,h)];case 1:return s=r.sent(),c=function(t,e){return""===e.query&&0===Object.keys(t).length?e.facetDistribution:t}(c,s),[2,M(s,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){return r(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()]}}))}))}}}; | ||
//# sourceMappingURL=instant-meilisearch.cjs.min.js.map |
import { MeiliSearch } from 'meilisearch'; | ||
/*! ***************************************************************************** | ||
/****************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -79,6 +79,10 @@ | ||
function __spreadArray(to, from) { | ||
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) | ||
to[j] = from[i]; | ||
return to; | ||
function __spreadArray(to, from, pack) { | ||
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { | ||
if (ar || !(i in from)) { | ||
if (!ar) ar = Array.prototype.slice.call(from, 0, i); | ||
ar[i] = from[i]; | ||
} | ||
} | ||
return to.concat(ar || Array.prototype.slice.call(from)); | ||
} | ||
@@ -171,3 +175,3 @@ | ||
var prevFields = cache[filterName] || []; | ||
cache = __assign(__assign({}, cache), (_a = {}, _a[filterName] = __spreadArray(__spreadArray([], prevFields, true), [value]), _a)); | ||
cache = __assign(__assign({}, cache), (_a = {}, _a[filterName] = __spreadArray(__spreadArray([], prevFields, true), [value], false), _a)); | ||
return cache; | ||
@@ -494,3 +498,3 @@ }, {}); | ||
adaptedFilters, | ||
]); | ||
], false); | ||
var cleanedFilters = adaptedFilter.filter(function (filter) { | ||
@@ -520,2 +524,108 @@ if (Array.isArray(filter)) { | ||
/** | ||
* Adapts instantsearch.js and instant-meilisearch options | ||
* to meilisearch search query parameters. | ||
* | ||
* @param {SearchContext} searchContext | ||
* | ||
* @returns {MeiliSearchParams} | ||
*/ | ||
function MeiliParamsCreator(searchContext) { | ||
var meiliSearchParams = {}; | ||
var facets = searchContext.facets, attributesToSnippet = searchContext.attributesToSnippet, snippetEllipsisText = searchContext.snippetEllipsisText, attributesToRetrieve = searchContext.attributesToRetrieve, filters = searchContext.filters, numericFilters = searchContext.numericFilters, facetFilters = searchContext.facetFilters, attributesToHighlight = searchContext.attributesToHighlight, highlightPreTag = searchContext.highlightPreTag, highlightPostTag = searchContext.highlightPostTag, placeholderSearch = searchContext.placeholderSearch, query = searchContext.query, finitePagination = searchContext.finitePagination, sort = searchContext.sort, pagination = searchContext.pagination, optionalWords = searchContext.optionalWords; | ||
return { | ||
getParams: function () { | ||
return meiliSearchParams; | ||
}, | ||
addFacets: function () { | ||
if (facets === null || facets === void 0 ? void 0 : facets.length) { | ||
meiliSearchParams.facets = facets; | ||
} | ||
}, | ||
addAttributesToCrop: function () { | ||
if (attributesToSnippet) { | ||
meiliSearchParams.attributesToCrop = attributesToSnippet; | ||
} | ||
}, | ||
addCropMarker: function () { | ||
// Attributes To Crop marker | ||
if (snippetEllipsisText != null) { | ||
meiliSearchParams.cropMarker = snippetEllipsisText; | ||
} | ||
}, | ||
addAttributesToRetrieve: function () { | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToRetrieve = attributesToRetrieve; | ||
} | ||
}, | ||
addFilters: function () { | ||
var filter = adaptFilters(filters, numericFilters, facetFilters); | ||
if (filter.length) { | ||
meiliSearchParams.filter = filter; | ||
} | ||
}, | ||
addAttributesToHighlight: function () { | ||
meiliSearchParams.attributesToHighlight = attributesToHighlight || ['*']; | ||
}, | ||
addPreTag: function () { | ||
if (highlightPreTag) { | ||
meiliSearchParams.highlightPreTag = highlightPreTag; | ||
} | ||
else { | ||
meiliSearchParams.highlightPreTag = '__ais-highlight__'; | ||
} | ||
}, | ||
addPostTag: function () { | ||
if (highlightPostTag) { | ||
meiliSearchParams.highlightPostTag = highlightPostTag; | ||
} | ||
else { | ||
meiliSearchParams.highlightPostTag = '__/ais-highlight__'; | ||
} | ||
}, | ||
addPagination: function () { | ||
// Limit based on pagination preferences | ||
if ((!placeholderSearch && query === '') || | ||
pagination.paginationTotalHits === 0) { | ||
meiliSearchParams.limit = 0; | ||
} | ||
else if (finitePagination) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits; | ||
} | ||
else { | ||
var limit = (pagination.page + 1) * pagination.hitsPerPage + 1; | ||
// If the limit is bigger than the total hits accepted | ||
// force the limit to that amount | ||
if (limit > pagination.paginationTotalHits) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits; | ||
} | ||
else { | ||
meiliSearchParams.limit = limit; | ||
} | ||
} | ||
}, | ||
addSort: function () { | ||
if (sort === null || sort === void 0 ? void 0 : sort.length) { | ||
meiliSearchParams.sort = [sort]; | ||
} | ||
}, | ||
addGeoSearchRules: function () { | ||
var geoSearchContext = createGeoSearchContext(searchContext); | ||
var geoRules = adaptGeoPointsRules(geoSearchContext); | ||
if (geoRules === null || geoRules === void 0 ? void 0 : geoRules.filter) { | ||
if (meiliSearchParams.filter) { | ||
meiliSearchParams.filter.unshift(geoRules.filter); | ||
} | ||
else { | ||
meiliSearchParams.filter = [geoRules.filter]; | ||
} | ||
} | ||
}, | ||
addOptionalWords: function () { | ||
if (optionalWords) { | ||
meiliSearchParams.optionalWords = optionalWords; | ||
} | ||
} | ||
}; | ||
} | ||
/** | ||
* Adapt search request from instantsearch.js | ||
@@ -528,92 +638,16 @@ * to search request compliant with Meilisearch | ||
function adaptSearchParams(searchContext) { | ||
// Creates search params object compliant with Meilisearch | ||
var meiliSearchParams = {}; | ||
// Facets | ||
var facets = searchContext === null || searchContext === void 0 ? void 0 : searchContext.facets; | ||
if (facets === null || facets === void 0 ? void 0 : facets.length) { | ||
meiliSearchParams.facets = facets; | ||
} | ||
// Attributes To Crop | ||
var attributesToCrop = searchContext === null || searchContext === void 0 ? void 0 : searchContext.attributesToSnippet; | ||
if (attributesToCrop) { | ||
meiliSearchParams.attributesToCrop = attributesToCrop; | ||
} | ||
// Attributes To Crop marker | ||
var cropMarker = searchContext === null || searchContext === void 0 ? void 0 : searchContext.snippetEllipsisText; | ||
if (cropMarker != null) { | ||
meiliSearchParams.cropMarker = cropMarker; | ||
} | ||
// Attributes To Retrieve | ||
var attributesToRetrieve = searchContext === null || searchContext === void 0 ? void 0 : searchContext.attributesToRetrieve; | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToRetrieve = attributesToRetrieve; | ||
} | ||
// Filter | ||
var filter = adaptFilters(searchContext === null || searchContext === void 0 ? void 0 : searchContext.filters, searchContext === null || searchContext === void 0 ? void 0 : searchContext.numericFilters, searchContext === null || searchContext === void 0 ? void 0 : searchContext.facetFilters); | ||
if (filter.length) { | ||
meiliSearchParams.filter = filter; | ||
} | ||
// Attributes To Retrieve | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToCrop = attributesToRetrieve; | ||
} | ||
// Attributes To Highlight | ||
meiliSearchParams.attributesToHighlight = (searchContext === null || searchContext === void 0 ? void 0 : searchContext.attributesToHighlight) || [ | ||
'*', | ||
]; | ||
// Highlight pre tag | ||
var highlightPreTag = searchContext === null || searchContext === void 0 ? void 0 : searchContext.highlightPreTag; | ||
if (highlightPreTag) { | ||
meiliSearchParams.highlightPreTag = highlightPreTag; | ||
} | ||
else { | ||
meiliSearchParams.highlightPreTag = '__ais-highlight__'; | ||
} | ||
// Highlight post tag | ||
var highlightPostTag = searchContext === null || searchContext === void 0 ? void 0 : searchContext.highlightPostTag; | ||
if (highlightPostTag) { | ||
meiliSearchParams.highlightPostTag = highlightPostTag; | ||
} | ||
else { | ||
meiliSearchParams.highlightPostTag = '__/ais-highlight__'; | ||
} | ||
var placeholderSearch = searchContext.placeholderSearch; | ||
var query = searchContext.query; | ||
// Pagination | ||
var pagination = searchContext.pagination; | ||
// Limit based on pagination preferences | ||
if ((!placeholderSearch && query === '') || | ||
pagination.paginationTotalHits === 0) { | ||
meiliSearchParams.limit = 0; | ||
} | ||
else if (searchContext.finitePagination) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits; | ||
} | ||
else { | ||
var limit = (pagination.page + 1) * pagination.hitsPerPage + 1; | ||
// If the limit is bigger than the total hits accepted | ||
// force the limit to that amount | ||
if (limit > pagination.paginationTotalHits) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits; | ||
} | ||
else { | ||
meiliSearchParams.limit = limit; | ||
} | ||
} | ||
var sort = searchContext.sort; | ||
// Sort | ||
if (sort === null || sort === void 0 ? void 0 : sort.length) { | ||
meiliSearchParams.sort = [sort]; | ||
} | ||
var geoSearchContext = createGeoSearchContext(searchContext); | ||
var geoRules = adaptGeoPointsRules(geoSearchContext); | ||
if (geoRules === null || geoRules === void 0 ? void 0 : geoRules.filter) { | ||
if (meiliSearchParams.filter) { | ||
meiliSearchParams.filter.unshift(geoRules.filter); | ||
} | ||
else { | ||
meiliSearchParams.filter = [geoRules.filter]; | ||
} | ||
} | ||
return meiliSearchParams; | ||
var meilisearchParams = MeiliParamsCreator(searchContext); | ||
meilisearchParams.addFacets(); | ||
meilisearchParams.addAttributesToHighlight(); | ||
meilisearchParams.addPreTag(); | ||
meilisearchParams.addPostTag(); | ||
meilisearchParams.addAttributesToRetrieve(); | ||
meilisearchParams.addAttributesToCrop(); | ||
meilisearchParams.addCropMarker(); | ||
meilisearchParams.addPagination(); | ||
meilisearchParams.addFilters(); | ||
meilisearchParams.addSort(); | ||
meilisearchParams.addGeoSearchRules(); | ||
meilisearchParams.addOptionalWords(); | ||
return meilisearchParams.getParams(); | ||
} | ||
@@ -805,3 +839,3 @@ | ||
}); | ||
var searchContext = __assign(__assign(__assign({}, options), instantSearchParams), { sort: sortByArray.join(':') || '', indexUid: indexUid, pagination: pagination, defaultFacetDistribution: defaultFacetDistribution, placeholderSearch: options.placeholderSearch !== false, keepZeroFacets: !!options.keepZeroFacets, finitePagination: !!options.finitePagination }); | ||
var searchContext = __assign(__assign(__assign({}, options), instantSearchParams), { sort: sortByArray.join(':') || '', indexUid: indexUid, pagination: pagination, defaultFacetDistribution: defaultFacetDistribution, placeholderSearch: options.placeholderSearch !== false, keepZeroFacets: !!options.keepZeroFacets, finitePagination: !!options.finitePagination, optionalWords: options.optionalWords || 'last' }); | ||
return searchContext; | ||
@@ -834,2 +868,5 @@ } | ||
searchCache[key] = JSON.stringify(searchResponse); | ||
}, | ||
clearCache: function () { | ||
searchCache = {}; | ||
} | ||
@@ -847,3 +884,3 @@ }; | ||
var PACKAGE_VERSION = '0.8.0'; | ||
var PACKAGE_VERSION = '0.8.1-optional-words-beta.0'; | ||
@@ -867,4 +904,5 @@ var constructClientAgents = function (clientAgents) { | ||
if (instantMeiliSearchOptions === void 0) { instantMeiliSearchOptions = {}; } | ||
var searchCache = SearchCache(); | ||
// create search resolver with included cache | ||
var searchResolver = SearchResolver(SearchCache()); | ||
var searchResolver = SearchResolver(searchCache); | ||
// paginationTotalHits can be 0 as it is a valid number | ||
@@ -879,2 +917,3 @@ var defaultFacetDistribution = {}; | ||
return { | ||
clearCache: function () { return searchCache.clearCache(); }, | ||
/** | ||
@@ -881,0 +920,0 @@ * @param {readonlyAlgoliaMultipleQueriesQuery[]} instantSearchRequests |
@@ -1,16 +0,2 @@ | ||
import{MeiliSearch as t}from"meilisearch"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */var n=function(){return(n=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t}).apply(this,arguments)};function e(t,n,e,r){return new(e||(e=Promise))((function(i,a){function o(t){try{s(r.next(t))}catch(t){a(t)}}function u(t){try{s(r.throw(t))}catch(t){a(t)}}function s(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(o,u)}s((r=r.apply(t,n||[])).next())}))}function r(t,n){var e,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(a){return function(u){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;o;)try{if(e=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=n.call(t,o)}catch(t){a=[6,t],r=0}finally{e=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function i(t,n){for(var e=0,r=n.length,i=t.length;e<r;e++,i++)t[i]=n[e];return t}function a(t){return t.replace(/:(.*)/i,'="$1"')}var o=function(t){var n=t.match(/([^=]*)="?([^\\"]*)"?$/);return n?(n[0],[{filterName:n[1],value:n[2]}]):[]};function u(t){var e=function(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)})):o(t)})).flat(2):[]}(t);return e.filter((function(t){return void 0!==t})).reduce((function(t,e){var r,a=e.filterName,o=e.value,u=t[a]||[];return t=n(n({},t),((r={})[a]=i(i([],u),[o]),r))}),{})}function s(t,e){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,e){var i,a=Object.keys(r[e]);return n(n({},t),((i={})[e]=a,i))}),{})):u(null==e?void 0:e.filter);var r}var c={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function l(t){return{searchResponse:function(n,i,a){return e(this,void 0,void 0,(function(){var e,o,u,l,f,h,p,g;return r(this,(function(r){switch(r.label){case 0:return e=n.placeholderSearch,o=n.query,e||o?(u=n.pagination,l=n.finitePagination?{}:u,f=t.formatKey([i,n.indexUid,n.query,l]),(h=t.getEntry(f))?[2,h]:(p=s(n,i),[4,a.index(n.indexUid).search(n.query,i)])):[2,c];case 1:return(g=r.sent()).facetDistribution=function(t,n){if(n=n||{},t&&Object.keys(t).length>0)for(var e in t){n[e]||(n[e]={});for(var r=0,i=t[e];r<i.length;r++){var a=i[r];Object.keys(n[e]).includes(a)||(n[e][a]=0)}}return n}(p,g.facetDistribution),t.setEntry(f,g),[2,g]}}))}))}}}function f(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function p(t){if(t){var n,e,r=t.insideBoundingBox,i=t.aroundLatLng,a=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(n=i),null==a&&null==o||(e=null!=a?a:o),r&&"string"==typeof r){var u=r.split(","),s=u[0],c=u[1],l=u[2],p=u[3],g=[parseFloat(s),parseFloat(c),parseFloat(l),parseFloat(p)],d=g[0],v=g[1],y=g[2],m=g[3];e=function(t,n,e,r){var i=t*Math.PI/180,a=e*Math.PI/180,o=(e-t)*Math.PI/180,u=(r-n)*Math.PI/180,s=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(a)*Math.sin(u/2)*Math.sin(u/2);return 2*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))*6371e3}(d,v,y,m)/2,n=function(t,n,e,r){t=h(t),n=h(n);var i=Math.cos(t)*Math.cos(n),a=Math.cos(t)*Math.sin(n),o=Math.sin(t);e=h(e),r=h(r);var u=i+Math.cos(e)*Math.cos(r),s=a+Math.cos(e)*Math.sin(r),c=o+Math.sin(e),l=Math.sqrt(u*u+s*s),p=Math.atan2(s,u),g=Math.atan2(c,l);return n<r||n>r&&n>Math.PI&&r<-Math.PI?(g+=Math.PI,p+=Math.PI):(g=f(g),p=f(p)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(g=0,p=0),"".concat(g,",").concat(p)}(d,v,y,m)}if(null!=n&&null!=e){var b=n.split(","),P=b[0],M=b[1];return P=Number.parseFloat(P).toFixed(5),M=Number.parseFloat(M).toFixed(5),{filter:"_geoRadius(".concat(P,", ").concat(M,", ").concat(e,")")}}}}function g(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function d(t){return""===t?[]:"string"==typeof t?[t]:t}function v(t,n,e){return function(t,n,e){var r=e.trim(),a=d(t),o=d(n);return i(i(i([],a),o),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(g(e||[]),g(n||[]),t||"")}function y(t){var n={},e=null==t?void 0:t.facets;(null==e?void 0:e.length)&&(n.facets=e);var r=null==t?void 0:t.attributesToSnippet;r&&(n.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(n.cropMarker=i);var a=null==t?void 0:t.attributesToRetrieve;a&&(n.attributesToRetrieve=a);var o=v(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);o.length&&(n.filter=o),a&&(n.attributesToCrop=a),n.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var u=null==t?void 0:t.highlightPreTag;n.highlightPreTag=u||"__ais-highlight__";var s=null==t?void 0:t.highlightPostTag;n.highlightPostTag=s||"__/ais-highlight__";var c=t.placeholderSearch,l=t.query,f=t.pagination;if(!c&&""===l||0===f.paginationTotalHits)n.limit=0;else if(t.finitePagination)n.limit=f.paginationTotalHits;else{var h=(f.page+1)*f.hitsPerPage+1;h>f.paginationTotalHits?n.limit=f.paginationTotalHits:n.limit=h}var g=t.sort;(null==g?void 0:g.length)&&(n.sort=[g]);var d=p(function(t){var n={},e=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,u=t.insideBoundingBox,s=t.insidePolygon;return e&&(n.aroundLatLng=e),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(n.aroundRadius=i),a&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(n.minimumAroundRadius=o),u&&(n.insideBoundingBox=u),s&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),n}(t));return(null==d?void 0:d.filter)&&(n.filter?n.filter.unshift(d.filter):n.filter=[d.filter]),n}function m(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function b(t){return Array.isArray(t)?t.map((function(t){return b(t)})):"object"!=typeof(n=t)||Array.isArray(n)||null===n?{value:m(t)}:Object.keys(t).reduce((function(n,e){return n[e]=b(t[e]),n}),{});var n}function P(t,n,e){var r=n.primaryKey,i=e.hitsPerPage,a=function(t,n,e){if(e<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=n*e;return t.slice(r,r+e)}(t,e.page,i).map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesPosition;var e=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]])}return e}(t,["_formatted","_matchesPosition"]),i=Object.assign(e,function(t){if(!t)return{};var n=b(t);return{_highlightResult:n,_snippetResult:n}}(n));return r&&(i.objectID=t[r]),i}return t}));return a=function(t){for(var n=0;n<t.length;n++)t[n]._geo&&(t[n]._geoloc={lat:t[n]._geo.lat,lng:t[n]._geo.lng},t[n].objectID="".concat(n+1e6*Math.random()),delete t[n]._geo);return t}(a)}function M(t,e){var r,i,a=t.facetDistribution,o=e.pagination,u=(r=t.hits.length,(i=o.hitsPerPage)>0?Math.ceil(r/i):0),s=P(t.hits,e,o),c=t.estimatedTotalHits,l=t.processingTimeMs,f=t.query,h=o.hitsPerPage,p=o.page;return{results:[n({index:e.indexUid,hitsPerPage:h,page:p,facets:a,nbPages:u,nbHits:c,processingTimeMS:l,query:f,hits:s,params:"",exhaustiveNbHits:!1},{})]}}function w(t){void 0===t&&(t={});var n=t;return{getEntry:function(t){if(n[t])try{return JSON.parse(n[t])}catch(e){return n[t]}},formatKey:function(t){return t.reduce((function(t,n){return t+JSON.stringify(n)}),"")},setEntry:function(t,e){n[t]=JSON.stringify(e)}}}function T(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u=l(w()),s={},c=function(t){void 0===t&&(t=[]);var n="Meilisearch instant-meilisearch (v".concat("0.8.0",")");return t.concat(n)}(o.clientAgents),f=new t({host:i,apiKey:a,clientAgents:c});return{search:function(t){return e(this,void 0,void 0,(function(){var e,i,a,c,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=t[0],i=function(t,e,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),u=t.params,s=function(t){var n=t.paginationTotalHits,e=t.hitsPerPage;return{paginationTotalHits:null!=n?n:200,hitsPerPage:void 0===e?20:e,page:t.page||0}}({paginationTotalHits:e.paginationTotalHits,hitsPerPage:null==u?void 0:u.hitsPerPage,page:null==u?void 0:u.page});return n(n(n({},e),u),{sort:o.join(":")||"",indexUid:a,pagination:s,defaultFacetDistribution:r,placeholderSearch:!1!==e.placeholderSearch,keepZeroFacets:!!e.keepZeroFacets,finitePagination:!!e.finitePagination})}(e,o,s),a=y(i),[4,u.searchResponse(i,a,f)];case 1:return c=r.sent(),s=function(t,n){return""===n.query&&0===Object.keys(t).length?n.facetDistribution:t}(s,c),[2,M(c,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return e(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){n(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}}export{T as instantMeiliSearch}; | ||
import{MeiliSearch as t}from"meilisearch";var n=function(){return n=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t},n.apply(this,arguments)};function e(t,n,e,r){return new(e||(e=Promise))((function(i,a){function o(t){try{u(r.next(t))}catch(t){a(t)}}function s(t){try{u(r.throw(t))}catch(t){a(t)}}function u(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(o,s)}u((r=r.apply(t,n||[])).next())}))}function r(t,n){var e,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(e)throw new TypeError("Generator is already executing.");for(;o;)try{if(e=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=n.call(t,o)}catch(t){a=[6,t],r=0}finally{e=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function i(t,n,e){if(e||2===arguments.length)for(var r,i=0,a=n.length;i<a;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))}function a(t){return t.replace(/:(.*)/i,'="$1"')}var o=function(t){var n=t.match(/([^=]*)="?([^\\"]*)"?$/);return n?(n[0],[{filterName:n[1],value:n[2]}]):[]};function s(t){var e=function(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)})):o(t)})).flat(2):[]}(t);return e.filter((function(t){return void 0!==t})).reduce((function(t,e){var r,a=e.filterName,o=e.value,s=t[a]||[];return t=n(n({},t),((r={})[a]=i(i([],s,!0),[o],!1),r))}),{})}function u(t,e){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,e){var i,a=Object.keys(r[e]);return n(n({},t),((i={})[e]=a,i))}),{})):s(null==e?void 0:e.filter);var r}var c={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function l(t){return{searchResponse:function(n,i,a){return e(this,void 0,void 0,(function(){var e,o,s,l,f,h,d,p;return r(this,(function(r){switch(r.label){case 0:return e=n.placeholderSearch,o=n.query,e||o?(s=n.pagination,l=n.finitePagination?{}:s,f=t.formatKey([i,n.indexUid,n.query,l]),(h=t.getEntry(f))?[2,h]:(d=u(n,i),[4,a.index(n.indexUid).search(n.query,i)])):[2,c];case 1:return(p=r.sent()).facetDistribution=function(t,n){if(n=n||{},t&&Object.keys(t).length>0)for(var e in t){n[e]||(n[e]={});for(var r=0,i=t[e];r<i.length;r++){var a=i[r];Object.keys(n[e]).includes(a)||(n[e][a]=0)}}return n}(d,p.facetDistribution),t.setEntry(f,p),[2,p]}}))}))}}}function f(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function d(t){if(t){var n,e,r=t.insideBoundingBox,i=t.aroundLatLng,a=t.aroundRadius,o=t.minimumAroundRadius;if(i&&(n=i),null==a&&null==o||(e=null!=a?a:o),r&&"string"==typeof r){var s=r.split(","),u=s[0],c=s[1],l=s[2],d=s[3],p=[parseFloat(u),parseFloat(c),parseFloat(l),parseFloat(d)],g=p[0],y=p[1],v=p[2],b=p[3];e=function(t,n,e,r){var i=t*Math.PI/180,a=e*Math.PI/180,o=(e-t)*Math.PI/180,s=(r-n)*Math.PI/180,u=Math.sin(o/2)*Math.sin(o/2)+Math.cos(i)*Math.cos(a)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u))*6371e3}(g,y,v,b)/2,n=function(t,n,e,r){t=h(t),n=h(n);var i=Math.cos(t)*Math.cos(n),a=Math.cos(t)*Math.sin(n),o=Math.sin(t);e=h(e),r=h(r);var s=i+Math.cos(e)*Math.cos(r),u=a+Math.cos(e)*Math.sin(r),c=o+Math.sin(e),l=Math.sqrt(s*s+u*u),d=Math.atan2(u,s),p=Math.atan2(c,l);return n<r||n>r&&n>Math.PI&&r<-Math.PI?(p+=Math.PI,d+=Math.PI):(p=f(p),d=f(d)),Math.abs(s)<Math.pow(10,-9)&&Math.abs(u)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(p=0,d=0),"".concat(p,",").concat(d)}(g,y,v,b)}if(null!=n&&null!=e){var m=n.split(","),P=m[0],M=m[1];return P=Number.parseFloat(P).toFixed(5),M=Number.parseFloat(M).toFixed(5),{filter:"_geoRadius(".concat(P,", ").concat(M,", ").concat(e,")")}}}}function p(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function g(t){return""===t?[]:"string"==typeof t?[t]:t}function y(t,n,e){return function(t,n,e){var r=e.trim(),a=g(t),o=g(n);return i(i(i([],a,!0),o,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(p(e||[]),p(n||[]),t||"")}function v(t){var n={},e=t.facets,r=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.filters,s=t.numericFilters,u=t.facetFilters,c=t.attributesToHighlight,l=t.highlightPreTag,f=t.highlightPostTag,h=t.placeholderSearch,p=t.query,g=t.finitePagination,v=t.sort,b=t.pagination,m=t.optionalWords;return{getParams:function(){return n},addFacets:function(){(null==e?void 0:e.length)&&(n.facets=e)},addAttributesToCrop:function(){r&&(n.attributesToCrop=r)},addCropMarker:function(){null!=i&&(n.cropMarker=i)},addAttributesToRetrieve:function(){a&&(n.attributesToRetrieve=a)},addFilters:function(){var t=y(o,s,u);t.length&&(n.filter=t)},addAttributesToHighlight:function(){n.attributesToHighlight=c||["*"]},addPreTag:function(){n.highlightPreTag=l||"__ais-highlight__"},addPostTag:function(){n.highlightPostTag=f||"__/ais-highlight__"},addPagination:function(){if(!h&&""===p||0===b.paginationTotalHits)n.limit=0;else if(g)n.limit=b.paginationTotalHits;else{var t=(b.page+1)*b.hitsPerPage+1;t>b.paginationTotalHits?n.limit=b.paginationTotalHits:n.limit=t}},addSort:function(){(null==v?void 0:v.length)&&(n.sort=[v])},addGeoSearchRules:function(){var e=function(t){var n={},e=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,s=t.insideBoundingBox,u=t.insidePolygon;return e&&(n.aroundLatLng=e),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(n.aroundRadius=i),a&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),o&&(n.minimumAroundRadius=o),s&&(n.insideBoundingBox=s),u&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),n}(t),r=d(e);(null==r?void 0:r.filter)&&(n.filter?n.filter.unshift(r.filter):n.filter=[r.filter])},addOptionalWords:function(){m&&(n.optionalWords=m)}}}function b(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function m(t){return Array.isArray(t)?t.map((function(t){return m(t)})):"object"!=typeof(n=t)||Array.isArray(n)||null===n?{value:b(t)}:Object.keys(t).reduce((function(n,e){return n[e]=m(t[e]),n}),{});var n}function P(t,n,e){var r=n.primaryKey,i=e.hitsPerPage,a=function(t,n,e){if(e<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=n*e;return t.slice(r,r+e)}(t,e.page,i),o=a.map((function(t){if(Object.keys(t).length>0){var n=t._formatted;t._matchesPosition;var e=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)n.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(e[r[i]]=t[r[i]])}return e}(t,["_formatted","_matchesPosition"]),i=Object.assign(e,function(t){if(!t)return{};var n=m(t);return{_highlightResult:n,_snippetResult:n}}(n));return r&&(i.objectID=t[r]),i}return t}));return o=function(t){for(var n=0;n<t.length;n++)t[n]._geo&&(t[n]._geoloc={lat:t[n]._geo.lat,lng:t[n]._geo.lng},t[n].objectID="".concat(n+1e6*Math.random()),delete t[n]._geo);return t}(o),o}function M(t,e){var r,i,a=t.facetDistribution,o=e.pagination,s=(r=t.hits.length,(i=o.hitsPerPage)>0?Math.ceil(r/i):0),u=P(t.hits,e,o),c=t.estimatedTotalHits,l=t.processingTimeMs,f=t.query,h=o.hitsPerPage,d=o.page;return{results:[n({index:e.indexUid,hitsPerPage:h,page:d,facets:a,nbPages:s,nbHits:c,processingTimeMS:l,query:f,hits:u,params:"",exhaustiveNbHits:!1},{})]}}function T(t){void 0===t&&(t={});var n=t;return{getEntry:function(t){if(n[t])try{return JSON.parse(n[t])}catch(e){return n[t]}},formatKey:function(t){return t.reduce((function(t,n){return t+JSON.stringify(n)}),"")},setEntry:function(t,e){n[t]=JSON.stringify(e)},clearCache:function(){n={}}}}function w(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var s=T(),u=l(s),c={},f=function(t){void 0===t&&(t=[]);var n="Meilisearch instant-meilisearch (v".concat("0.8.1-optional-words-beta.0",")");return t.concat(n)}(o.clientAgents),h=new t({host:i,apiKey:a,clientAgents:f});return{clearCache:function(){return s.clearCache()},search:function(t){return e(this,void 0,void 0,(function(){var e,i,a,s,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=t[0],i=function(t,e,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),s=t.params,u=function(t){var n=t.paginationTotalHits,e=t.hitsPerPage;return{paginationTotalHits:null!=n?n:200,hitsPerPage:void 0===e?20:e,page:t.page||0}}({paginationTotalHits:e.paginationTotalHits,hitsPerPage:null==s?void 0:s.hitsPerPage,page:null==s?void 0:s.page});return n(n(n({},e),s),{sort:o.join(":")||"",indexUid:a,pagination:u,defaultFacetDistribution:r,placeholderSearch:!1!==e.placeholderSearch,keepZeroFacets:!!e.keepZeroFacets,finitePagination:!!e.finitePagination,optionalWords:e.optionalWords||"last"})}(e,o,c),a=function(t){var n=v(t);return n.addFacets(),n.addAttributesToHighlight(),n.addPreTag(),n.addPostTag(),n.addAttributesToRetrieve(),n.addAttributesToCrop(),n.addCropMarker(),n.addPagination(),n.addFilters(),n.addSort(),n.addGeoSearchRules(),n.addOptionalWords(),n.getParams()}(i),[4,u.searchResponse(i,a,h)];case 1:return s=r.sent(),c=function(t,n){return""===n.query&&0===Object.keys(t).length?n.facetDistribution:t}(c,s),[2,M(s,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return e(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return[4,new Promise((function(t,n){n(new Error("SearchForFacetValues is not compatible with Meilisearch")),t([])}))];case 1:return[2,t.sent()]}}))}))}}}export{w as instantMeiliSearch}; | ||
//# sourceMappingURL=instant-meilisearch.esm.min.js.map |
@@ -1,17 +0,3 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict"; | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).window=t.window||{})}(this,(function(t){"use strict";var e=function(){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,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}function i(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(t){var e={exports:{}};return t(e,e.exports),e.exports}s((function(t){!function(t){!function(e){var n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],u=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function v(t){var e=new FileReader,n=p(e);return e.readAsArrayBuffer(t),n}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||u(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var t,e,n,r=f(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=p(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(t,e){t=c(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},d.prototype.delete=function(t){delete this.map[c(t)]},d.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},d.prototype.set=function(t,e){this.map[c(t)]=h(e)},d.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,n){t.push(n)})),l(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),l(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,n){t.push([n,e])})),l(t)},r&&(d.prototype[Symbol.iterator]=d.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var n,r,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new d(e.headers)),this.method=(n=e.method||this.method||"GET",r=n.toUpperCase(),g.indexOf(r)>-1?r:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),e}function T(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(T.prototype),T.prototype.clone=function(){return new T(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},T.error=function(){var t=new T(null,{status:0,statusText:""});return t.type="error",t};var x=[301,302,303,307,308];T.redirect=function(t,e){if(-1===x.indexOf(e))throw new RangeError("Invalid status code");return new T(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function R(t,n){return new Promise((function(r,o){var s=new w(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t,e,n={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}})),e)};n.url="responseURL"in a?a.responseURL:n.headers.get("X-Request-URL");var i="response"in a?a.response:a.responseText;r(new T(i,n))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&i&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",u)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}R.polyfill=!0,t.fetch||(t.fetch=R,t.Headers=d,t.Request=w,t.Response=T),e.Headers=d,e.Request=w,e.Response=T,e.fetch=R,Object.defineProperty(e,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:o)}));var a=s((function(t,e){!function(t){ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */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}).apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function i(t,e){for(var n=0,r=e.length,i=t.length;n<r;n++,i++)t[i]=e[n];return t}var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function s(t){var e={exports:{}};return t(e,e.exports),e.exports}s((function(t){!function(t){!function(e){var n="URLSearchParams"in t,r="Symbol"in t&&"iterator"in Symbol,i="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),o="FormData"in t,s="ArrayBuffer"in t;if(s)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],a=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function h(t){return"string"!=typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}}))}function v(t){var e=new FileReader,n=p(e);return e.readAsArrayBuffer(t),n}function y(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:i&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:o&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:n&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&i&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=y(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||a(t))?this._bodyArrayBuffer=y(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(v)}),this.text=function(){var t,e,n,r=f(this);if(r)return r;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,n=p(e),e.readAsText(t),n;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r<e.length;r++)n[r]=String.fromCharCode(e[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},o&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}d.prototype.append=function(t,e){t=c(t),e=h(e);var n=this.map[t];this.map[t]=n?n+", "+e:e},d.prototype.delete=function(t){delete this.map[c(t)]},d.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},d.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},d.prototype.set=function(t,e){this.map[c(t)]=h(e)},d.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},d.prototype.keys=function(){var t=[];return this.forEach((function(e,n){t.push(n)})),l(t)},d.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),l(t)},d.prototype.entries=function(){var t=[];return this.forEach((function(e,n){t.push([n,e])})),l(t)},r&&(d.prototype[Symbol.iterator]=d.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function w(t,e){var n,r,i=(e=e||{}).body;if(t instanceof w){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,i||null==t._bodyInit||(i=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new d(e.headers)),this.method=(n=e.method||this.method||"GET",r=n.toUpperCase(),g.indexOf(r)>-1?r:n),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(i))}})),e}function x(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})},b.call(w.prototype),b.call(x.prototype),x.prototype.clone=function(){return new x(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},x.error=function(){var t=new x(null,{status:0,statusText:""});return t.type="error",t};var T=[301,302,303,307,308];x.redirect=function(t,e){if(-1===T.indexOf(e))throw new RangeError("Invalid status code");return new x(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var n=Error(t);this.stack=n.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function R(t,n){return new Promise((function(r,o){var s=new w(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var u=new XMLHttpRequest;function a(){u.abort()}u.onload=function(){var t,e,n={status:u.status,statusText:u.statusText,headers:(t=u.getAllResponseHeaders()||"",e=new d,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var n=t.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();e.append(r,i)}})),e)};n.url="responseURL"in u?u.responseURL:n.headers.get("X-Request-URL");var i="response"in u?u.response:u.responseText;r(new x(i,n))},u.onerror=function(){o(new TypeError("Network request failed"))},u.ontimeout=function(){o(new TypeError("Network request failed"))},u.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},u.open(s.method,s.url,!0),"include"===s.credentials?u.withCredentials=!0:"omit"===s.credentials&&(u.withCredentials=!1),"responseType"in u&&i&&(u.responseType="blob"),s.headers.forEach((function(t,e){u.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",a),u.onreadystatechange=function(){4===u.readyState&&s.signal.removeEventListener("abort",a)}),u.send(void 0===s._bodyInit?null:s._bodyInit)}))}R.polyfill=!0,t.fetch||(t.fetch=R,t.Headers=d,t.Request=w,t.Response=x),e.Headers=d,e.Request=w,e.Response=x,e.fetch=R,Object.defineProperty(e,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:o)}));var u=s((function(t,e){!function(t){ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. | ||
@@ -28,3 +14,3 @@ Permission to use, copy, modify, and/or distribute this software for any | ||
***************************************************************************** */ | ||
var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=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}).apply(this,arguments)};function i(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){t.done?n(t.value):i(t.value).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(t){return function(e){return a([t,e])}}function a(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}var s=function(t){function e(n,r,i,o){var s,u,a,c=this;return c=t.call(this,n)||this,Object.setPrototypeOf(c,e.prototype),c.name="MeiliSearchCommunicationError",r instanceof Response&&(c.message=r.statusText,c.statusCode=r.status),r instanceof Error&&(c.errno=r.errno,c.code=r.code),o?(c.stack=o,c.stack=null===(s=c.stack)||void 0===s?void 0:s.replace(/(TypeError|FetchError)/,c.name),c.stack=null===(u=c.stack)||void 0===u?void 0:u.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),c.stack=null===(a=c.stack)||void 0===a?void 0:a.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(c,e),c}return n(e,t),e}(Error),u=function(t){function e(e,n){var r=t.call(this,e.message)||this;return Object.setPrototypeOf(r,u.prototype),r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,u),r}return n(e,t),e}(Error);function a(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new s(t.statusText,t,t.url);case 4:throw new u(e,t.status);case 5:return[2,t]}}))}))}function c(t,e,n){if("MeiliSearchApiError"!==t.name)throw new s(t.message,t,n,e);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),l=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function d(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function f(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}function p(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}function v(t){return t.endsWith("/")||(t+="/"),t}var y="0.27.0";function b(t){try{return t=v(t=p(t))}catch(t){throw new h("The provided host is not valid.")}}function g(t){var e="X-Meilisearch-Client",n="Meilisearch JavaScript (v".concat(y,")"),r="Content-Type";t.headers=t.headers||{};var i=Object.assign({},t.headers);if(t.apiKey&&(i.Authorization="Bearer ".concat(t.apiKey)),t.headers[r]||(i["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var o=t.clientAgents.concat(n);i[e]=o.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new h('Meilisearch: The header "'.concat(e,'" should be an array of string(s).\n'));i[e]=n}return i}var w=function(){function t(t){this.headers=g(t);try{var e=b(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e=t.method,n=t.url,s=t.params,u=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,l,d;return o(this,(function(o){switch(o.label){case 0:t=new URL(n,this.url),s&&(i=new URLSearchParams,Object.keys(s).filter((function(t){return null!==s[t]})).map((function(t){return i.set(t,s[t])})),t.search=i.toString()),o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(u),headers:this.headers})).then((function(t){return a(t)}))];case 2:return[4,o.sent().json().catch((function(){}))];case 3:return[2,o.sent()];case 4:return l=o.sent(),d=l.stack,c(l,d,t.toString()),[3,5];case 5:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),m=function(){function t(t){this.httpRequest=new w(t)}return t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTasks=function(t){var e,n,r;return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var i,s;return o(this,(function(o){switch(o.label){case 0:return i="tasks",s={indexUid:null===(e=null==t?void 0:t.indexUid)||void 0===e?void 0:e.join(","),type:null===(n=null==t?void 0:t.type)||void 0===n?void 0:n.join(","),status:null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.join(","),from:t.from,limit:t.limit},[4,this.httpRequest.get(i,d(s))];case 1:return[2,o.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<s?[4,this.getTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,f(a)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new l("timeout of ".concat(s,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){var e,n,r,i,u;return o(this,(function(o){switch(o.label){case 0:e=[],n=0,r=t,o.label=1;case 1:return n<r.length?(i=r[n],[4,this.waitForTask(i,{timeOutMs:s,intervalMs:a})]):[3,4];case 2:u=o.sent(),e.push(u),o.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},t}(),x=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new w(t),this.tasks=new m(t)}return t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return o(this,(function(o){switch(o.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,d(r({q:t},e)),void 0,n)];case 1:return[2,o.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var s,u,a,c,l;return i(this,void 0,void 0,(function(){var i,f,p;return o(this,(function(o){switch(o.label){case 0:return i="indexes/".concat(this.uid,"/search"),f=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},p=r(r({q:t},e),{filter:f(null==e?void 0:e.filter),sort:null===(s=null==e?void 0:e.sort)||void 0===s?void 0:s.join(","),facets:null===(u=null==e?void 0:e.facets)||void 0===u?void 0:u.join(","),attributesToRetrieve:null===(a=null==e?void 0:e.attributesToRetrieve)||void 0===a?void 0:a.join(","),attributesToCrop:null===(c=null==e?void 0:e.attributesToCrop)||void 0===c?void 0:c.join(","),attributesToHighlight:null===(l=null==e?void 0:e.attributesToHighlight)||void 0===l?void 0:l.join(",")}),[4,this.httpRequest.get(i,d(p),n)];case 1:return[2,o.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return o(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var i;return o(this,(function(o){return i="indexes",[2,new w(n).post(i,r(r({},e),{uid:t}))]}))}))},t.prototype.update=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(r(r({},t),{indexUid:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:s,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:s,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n;return o(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/documents"),n=function(){var e;if(Array.isArray(null==t?void 0:t.fields))return null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}(),[4,this.httpRequest.get(e,d(r(r({},t),{fields:n})))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t,e){return i(this,void 0,void 0,(function(){var n,i;return o(this,(function(o){switch(o.label){case 0:return n="indexes/".concat(this.uid,"/documents/").concat(t),i=function(){var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")}(),[4,this.httpRequest.get(n,d(r(r({},e),{fields:i})))];case 1:return[2,o.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,s,u;return o(this,(function(o){switch(o.label){case 0:r=[],i=0,o.label=1;case 1:return i<t.length?(u=(s=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(s,[o.sent()]),o.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,s,u;return o(this,(function(o){switch(o.label){case 0:r=[],i=0,o.label=1;case 1:return i<t.length?(u=(s=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:u.apply(s,[o.sent()]),o.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteAllDocuments=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSettings=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),T=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new w(t),this.tasks=new m(t)}return t.prototype.index=function(t){return new x(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new x(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new x(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n,i=this;return o(this,(function(o){switch(o.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=o.sent(),n=e.results.map((function(t){return new x(i.config,t.uid,t.primaryKey)})),[2,r(r({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes",[4,this.httpRequest.get(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,x.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,new x(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new x(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:s,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,u=n.intervalMs,a=void 0===u?50:u;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:s,intervalMs:a})];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.get(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateKey=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="health",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="health",[4,this.httpRequest.get(t)];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getVersion=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="version",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="dumps",[4,this.httpRequest.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.generateTenantToken=function(t,e,n){var r=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(r.stack,"."))},t}());t.Index=x,t.MeiliSearch=T,t.MeiliSearchApiError=u,t.MeiliSearchCommunicationError=s,t.MeiliSearchError=h,t.MeiliSearchTimeOutError=l,t.default=T,t.httpErrorHandler=c,t.httpResponseErrorHandler=a,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));function a(t){return t.replace(/:(.*)/i,'="$1"')}var c=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[]};function h(t){var n=function(t){return"string"==typeof t?c(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return c(t)})):c(t)})).flat(2):[]}(t);return n.filter((function(t){return void 0!==t})).reduce((function(t,n){var r,o=n.filterName,s=n.value,u=t[o]||[];return t=e(e({},t),((r={})[o]=i(i([],u),[s]),r))}),{})}function l(t,n){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,n){var i,o=Object.keys(r[n]);return e(e({},t),((i={})[n]=o,i))}),{})):h(null==n?void 0:n.filter);var r}var d={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function f(t){return{searchResponse:function(e,i,o){return n(this,void 0,void 0,(function(){var n,s,u,a,c,h,f,p;return r(this,(function(r){switch(r.label){case 0:return n=e.placeholderSearch,s=e.query,n||s?(u=e.pagination,a=e.finitePagination?{}:u,c=t.formatKey([i,e.indexUid,e.query,a]),(h=t.getEntry(c))?[2,h]:(f=l(e,i),[4,o.index(e.indexUid).search(e.query,i)])):[2,d];case 1:return(p=r.sent()).facetDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var n in t){e[n]||(e[n]={});for(var r=0,i=t[n];r<i.length;r++){var o=i[r];Object.keys(e[n]).includes(o)||(e[n][o]=0)}}return e}(f,p.facetDistribution),t.setEntry(c,p),[2,p]}}))}))}}}function p(t){return 180*t/Math.PI}function v(t){return t*Math.PI/180}function y(t){if(t){var e,n,r=t.insideBoundingBox,i=t.aroundLatLng,o=t.aroundRadius,s=t.minimumAroundRadius;if(i&&(e=i),null==o&&null==s||(n=null!=o?o:s),r&&"string"==typeof r){var u=r.split(","),a=u[0],c=u[1],h=u[2],l=u[3],d=[parseFloat(a),parseFloat(c),parseFloat(h),parseFloat(l)],f=d[0],y=d[1],b=d[2],g=d[3];n=function(t,e,n,r){var i=t*Math.PI/180,o=n*Math.PI/180,s=(n-t)*Math.PI/180,u=(r-e)*Math.PI/180,a=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(o)*Math.sin(u/2)*Math.sin(u/2);return 2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))*6371e3}(f,y,b,g)/2,e=function(t,e,n,r){t=v(t),e=v(e);var i=Math.cos(t)*Math.cos(e),o=Math.cos(t)*Math.sin(e),s=Math.sin(t);n=v(n),r=v(r);var u=i+Math.cos(n)*Math.cos(r),a=o+Math.cos(n)*Math.sin(r),c=s+Math.sin(n),h=Math.sqrt(u*u+a*a),l=Math.atan2(a,u),d=Math.atan2(c,h);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(d+=Math.PI,l+=Math.PI):(d=p(d),l=p(l)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(a)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(d=0,l=0),"".concat(d,",").concat(l)}(f,y,b,g)}if(null!=e&&null!=n){var w=e.split(","),m=w[0],x=w[1];return m=Number.parseFloat(m).toFixed(5),x=Number.parseFloat(x).toFixed(5),{filter:"_geoRadius(".concat(m,", ").concat(x,", ").concat(n,")")}}}}function b(t){return"string"==typeof t?a(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return a(t)})).filter((function(t){return t})):a(t)})).filter((function(t){return t})):[]}function g(t){return""===t?[]:"string"==typeof t?[t]:t}function w(t,e,n){return function(t,e,n){var r=n.trim(),o=g(t),s=g(e);return i(i(i([],o),s),[r]).filter((function(t){return Array.isArray(t)?t.length:t}))}(b(n||[]),b(e||[]),t||"")}function m(t){var e={},n=null==t?void 0:t.facets;(null==n?void 0:n.length)&&(e.facets=n);var r=null==t?void 0:t.attributesToSnippet;r&&(e.attributesToCrop=r);var i=null==t?void 0:t.snippetEllipsisText;null!=i&&(e.cropMarker=i);var o=null==t?void 0:t.attributesToRetrieve;o&&(e.attributesToRetrieve=o);var s=w(null==t?void 0:t.filters,null==t?void 0:t.numericFilters,null==t?void 0:t.facetFilters);s.length&&(e.filter=s),o&&(e.attributesToCrop=o),e.attributesToHighlight=(null==t?void 0:t.attributesToHighlight)||["*"];var u=null==t?void 0:t.highlightPreTag;e.highlightPreTag=u||"__ais-highlight__";var a=null==t?void 0:t.highlightPostTag;e.highlightPostTag=a||"__/ais-highlight__";var c=t.placeholderSearch,h=t.query,l=t.pagination;if(!c&&""===h||0===l.paginationTotalHits)e.limit=0;else if(t.finitePagination)e.limit=l.paginationTotalHits;else{var d=(l.page+1)*l.hitsPerPage+1;d>l.paginationTotalHits?e.limit=l.paginationTotalHits:e.limit=d}var f=t.sort;(null==f?void 0:f.length)&&(e.sort=[f]);var p=y(function(t){var e={},n=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,o=t.aroundPrecision,s=t.minimumAroundRadius,u=t.insideBoundingBox,a=t.insidePolygon;return n&&(e.aroundLatLng=n),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(e.aroundRadius=i),o&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),s&&(e.minimumAroundRadius=s),u&&(e.insideBoundingBox=u),a&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),e}(t));return(null==p?void 0:p.filter)&&(e.filter?e.filter.unshift(p.filter):e.filter=[p.filter]),e}function x(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function T(t){return Array.isArray(t)?t.map((function(t){return T(t)})):"object"!=typeof(e=t)||Array.isArray(e)||null===e?{value:x(t)}:Object.keys(t).reduce((function(e,n){return e[n]=T(t[n]),e}),{});var e}function R(t,e,n){var r=e.primaryKey,i=n.hitsPerPage,o=function(t,e,n){if(n<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=e*n;return t.slice(r,r+n)}(t,n.page,i).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"]),i=Object.assign(n,function(t){if(!t)return{};var e=T(t);return{_highlightResult:e,_snippetResult:e}}(e));return r&&(i.objectID=t[r]),i}return t}));return o=function(t){for(var e=0;e<t.length;e++)t[e]._geo&&(t[e]._geoloc={lat:t[e]._geo.lat,lng:t[e]._geo.lng},t[e].objectID="".concat(e+1e6*Math.random()),delete t[e]._geo);return t}(o)}function A(t,n){var r,i,o=t.facetDistribution,s=n.pagination,u=(r=t.hits.length,(i=s.hitsPerPage)>0?Math.ceil(r/i):0),a=R(t.hits,n,s),c=t.estimatedTotalHits,h=t.processingTimeMs,l=t.query,d=s.hitsPerPage,f=s.page;return{results:[e({index:n.indexUid,hitsPerPage:d,page:f,facets:o,nbPages:u,nbHits:c,processingTimeMS:h,query:l,hits:a,params:"",exhaustiveNbHits:!1},{})]}}function k(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(n){return e[t]}},formatKey:function(t){return t.reduce((function(t,e){return t+JSON.stringify(e)}),"")},setEntry:function(t,n){e[t]=JSON.stringify(n)}}}t.instantMeiliSearch=function(t,i,o){void 0===i&&(i=""),void 0===o&&(o={});var s=f(k()),a={},c=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.8.0",")");return t.concat(e)}(o.clientAgents),h=new u.MeiliSearch({host:t,apiKey:i,clientAgents:c});return{search:function(t){return n(this,void 0,void 0,(function(){var n,i,u,c,l;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=t[0],i=function(t,n,r){var i=t.indexName.split(":"),o=i[0],s=i.slice(1),u=t.params,a=function(t){var e=t.paginationTotalHits,n=t.hitsPerPage;return{paginationTotalHits:null!=e?e:200,hitsPerPage:void 0===n?20:n,page:t.page||0}}({paginationTotalHits:n.paginationTotalHits,hitsPerPage:null==u?void 0:u.hitsPerPage,page:null==u?void 0:u.page});return e(e(e({},n),u),{sort:s.join(":")||"",indexUid:o,pagination:a,defaultFacetDistribution:r,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets,finitePagination:!!n.finitePagination})}(n,o,a),u=m(i),[4,s.searchResponse(i,u,h)];case 1:return c=r.sent(),a=function(t,e){return""===e.query&&0===Object.keys(t).length?e.facetDistribution:t}(a,c),[2,A(c,i)];case 2:throw l=r.sent(),console.error(l),new Error(l);case 3:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){return r(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()]}}))}))}}},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},e(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return r=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},r.apply(this,arguments)};function i(t,e,n,r){function i(t){return t instanceof n?t:new n((function(e){e(t)}))}return new(n||(n=Promise))((function(n,o){function s(t){try{u(r.next(t))}catch(t){o(t)}}function a(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?n(t.value):i(t.value).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function o(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(t){return function(e){return u([t,e])}}function u(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}}var s=function(t){function e(n,r,i,o){var s,a,u,c=this;return c=t.call(this,n)||this,Object.setPrototypeOf(c,e.prototype),c.name="MeiliSearchCommunicationError",r instanceof Response&&(c.message=r.statusText,c.statusCode=r.status),r instanceof Error&&(c.errno=r.errno,c.code=r.code),o?(c.stack=o,c.stack=null===(s=c.stack)||void 0===s?void 0:s.replace(/(TypeError|FetchError)/,c.name),c.stack=null===(a=c.stack)||void 0===a?void 0:a.replace("Failed to fetch","request to ".concat(i," failed, reason: connect ECONNREFUSED")),c.stack=null===(u=c.stack)||void 0===u?void 0:u.replace("Not Found","Not Found: ".concat(i))):Error.captureStackTrace&&Error.captureStackTrace(c,e),c}return n(e,t),e}(Error),a=function(t){function e(e,n){var r=t.call(this,e.message)||this;return Object.setPrototypeOf(r,a.prototype),r.name="MeiliSearchApiError",r.code=e.code,r.type=e.type,r.link=e.link,r.message=e.message,r.httpStatus=n,Error.captureStackTrace&&Error.captureStackTrace(r,a),r}return n(e,t),e}(Error);function u(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:if(t.ok)return[3,5];e=void 0,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,t.json()];case 2:return e=n.sent(),[3,4];case 3:throw n.sent(),new s(t.statusText,t,t.url);case 4:throw new a(e,t.status);case 5:return[2,t]}}))}))}function c(t,e,n){if("MeiliSearchApiError"!==t.name)throw new s(t.message,t,n,e);throw t}var h=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error),l=function(t){function e(n){var r=t.call(this,n)||this;return Object.setPrototypeOf(r,e.prototype),r.name="MeiliSearchTimeOutError",Error.captureStackTrace&&Error.captureStackTrace(r,e),r}return n(e,t),e}(Error);function d(t){return Object.entries(t).reduce((function(t,e){var n=e[0],r=e[1];return void 0!==r&&(t[n]=r),t}),{})}function f(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){return setTimeout(e,t)}))];case 1:return[2,e.sent()]}}))}))}function p(t){return t.startsWith("https://")||t.startsWith("http://")?t:"http://".concat(t)}function v(t){return t.endsWith("/")||(t+="/"),t}var y="0.27.0-optional-words-beta.0";function b(t){try{return t=v(t=p(t))}catch(t){throw new h("The provided host is not valid.")}}function g(t){var e="X-Meilisearch-Client",n="Meilisearch JavaScript (v".concat(y,")"),r="Content-Type";t.headers=t.headers||{};var i=Object.assign({},t.headers);if(t.apiKey&&(i.Authorization="Bearer ".concat(t.apiKey)),t.headers[r]||(i["Content-Type"]="application/json"),t.clientAgents&&Array.isArray(t.clientAgents)){var o=t.clientAgents.concat(n);i[e]=o.join(" ; ")}else{if(t.clientAgents&&!Array.isArray(t.clientAgents))throw new h('Meilisearch: The header "'.concat(e,'" should be an array of string(s).\n'));i[e]=n}return i}var w=function(){function t(t){this.headers=g(t);try{var e=b(t.host);this.url=new URL(e)}catch(t){throw new h("The provided host is not valid.")}}return t.prototype.request=function(t){var e=t.method,n=t.url,s=t.params,a=t.body,h=t.config;return i(this,void 0,void 0,(function(){var t,i,l,d;return o(this,(function(o){switch(o.label){case 0:t=new URL(n,this.url),s&&(i=new URLSearchParams,Object.keys(s).filter((function(t){return null!==s[t]})).map((function(t){return i.set(t,s[t])})),t.search=i.toString()),o.label=1;case 1:return o.trys.push([1,4,,5]),[4,fetch(t.toString(),r(r({},h),{method:e,body:JSON.stringify(a),headers:this.headers})).then((function(t){return u(t)}))];case 2:return[4,o.sent().json().catch((function(){}))];case 3:return[2,o.sent()];case 4:return l=o.sent(),d=l.stack,c(l,d,t.toString()),[3,5];case 5:return[2]}}))}))},t.prototype.get=function(t,e,n){return i(this,void 0,void 0,(function(){return o(this,(function(r){switch(r.label){case 0:return[4,this.request({method:"GET",url:t,params:e,config:n})];case 1:return[2,r.sent()]}}))}))},t.prototype.post=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"POST",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.put=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PUT",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.patch=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"PATCH",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t.prototype.delete=function(t,e,n,r){return i(this,void 0,void 0,(function(){return o(this,(function(i){switch(i.label){case 0:return[4,this.request({method:"DELETE",url:t,body:e,params:n,config:r})];case 1:return[2,i.sent()]}}))}))},t}(),m=function(){function t(t){this.httpRequest=new w(t)}return t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="tasks/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTasks=function(t){var e,n,r;return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var i,s;return o(this,(function(o){switch(o.label){case 0:return i="tasks",s={indexUid:null===(e=null==t?void 0:t.indexUid)||void 0===e?void 0:e.join(","),type:null===(n=null==t?void 0:t.type)||void 0===n?void 0:n.join(","),status:null===(r=null==t?void 0:t.status)||void 0===r?void 0:r.join(","),from:t.from,limit:t.limit},[4,this.httpRequest.get(i,d(s))];case 1:return[2,o.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){var e,n;return o(this,(function(r){switch(r.label){case 0:e=Date.now(),r.label=1;case 1:return Date.now()-e<s?[4,this.getTask(t)]:[3,4];case 2:return n=r.sent(),["enqueued","processing"].includes(n.status)?[4,f(u)]:[2,n];case 3:return r.sent(),[3,1];case 4:throw new l("timeout of ".concat(s,"ms has exceeded on process ").concat(t," when waiting a task to be resolved."))}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){var e,n,r,i,a;return o(this,(function(o){switch(o.label){case 0:e=[],n=0,r=t,o.label=1;case 1:return n<r.length?(i=r[n],[4,this.waitForTask(i,{timeOutMs:s,intervalMs:u})]):[3,4];case 2:a=o.sent(),e.push(a),o.label=3;case 3:return n++,[3,1];case 4:return[2,e]}}))}))},t}(),T=function(){function t(t,e,n){this.uid=e,this.primaryKey=n,this.httpRequest=new w(t),this.tasks=new m(t)}return t.prototype.search=function(t,e,n){return i(this,void 0,void 0,(function(){var i;return o(this,(function(o){switch(o.label){case 0:return i="indexes/".concat(this.uid,"/search"),[4,this.httpRequest.post(i,d(r({q:t},e)),void 0,n)];case 1:return[2,o.sent()]}}))}))},t.prototype.searchGet=function(t,e,n){var s,a,u,c,l;return i(this,void 0,void 0,(function(){var i,f,p;return o(this,(function(o){switch(o.label){case 0:return i="indexes/".concat(this.uid,"/search"),f=function(t){if("string"==typeof t)return t;if(Array.isArray(t))throw new h("The filter query parameter should be in string format when using searchGet")},p=r(r({q:t},e),{filter:f(null==e?void 0:e.filter),sort:null===(s=null==e?void 0:e.sort)||void 0===s?void 0:s.join(","),facets:null===(a=null==e?void 0:e.facets)||void 0===a?void 0:a.join(","),attributesToRetrieve:null===(u=null==e?void 0:e.attributesToRetrieve)||void 0===u?void 0:u.join(","),attributesToCrop:null===(c=null==e?void 0:e.attributesToCrop)||void 0===c?void 0:c.join(","),attributesToHighlight:null===(l=null==e?void 0:e.attributesToHighlight)||void 0===l?void 0:l.join(",")}),[4,this.httpRequest.get(i,d(p),n)];case 1:return[2,o.sent()]}}))}))},t.prototype.getRawInfo=function(){return i(this,void 0,void 0,(function(){var t,e;return o(this,(function(n){switch(n.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.get(t)];case 1:return e=n.sent(),this.primaryKey=e.primaryKey,this.updatedAt=new Date(e.updatedAt),this.createdAt=new Date(e.createdAt),[2,e]}}))}))},t.prototype.fetchInfo=function(){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.getRawInfo()];case 1:return t.sent(),[2,this]}}))}))},t.prototype.fetchPrimaryKey=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getRawInfo()];case 1:return t.primaryKey=e.sent().primaryKey,[2,this.primaryKey]}}))}))},t.create=function(t,e,n){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){var i;return o(this,(function(o){return i="indexes",[2,new w(n).post(i,r(r({},e),{uid:t}))]}))}))},t.prototype.update=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.delete=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(r(r({},t),{indexUid:[this.uid]}))];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:s,intervalMs:u})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:s,intervalMs:u})];case 1:return[2,e.sent()]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/stats"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDocuments=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n;return o(this,(function(i){switch(i.label){case 0:return e="indexes/".concat(this.uid,"/documents"),n=function(){var e;if(Array.isArray(null==t?void 0:t.fields))return null===(e=null==t?void 0:t.fields)||void 0===e?void 0:e.join(",")}(),[4,this.httpRequest.get(e,d(r(r({},t),{fields:n})))];case 1:return[2,i.sent()]}}))}))},t.prototype.getDocument=function(t,e){return i(this,void 0,void 0,(function(){var n,i;return o(this,(function(o){switch(o.label){case 0:return n="indexes/".concat(this.uid,"/documents/").concat(t),i=function(){var t;if(Array.isArray(null==e?void 0:e.fields))return null===(t=null==e?void 0:e.fields)||void 0===t?void 0:t.join(",")}(),[4,this.httpRequest.get(n,d(r(r({},e),{fields:i})))];case 1:return[2,o.sent()]}}))}))},t.prototype.addDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.post(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.addDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,s,a;return o(this,(function(o){switch(o.label){case 0:r=[],i=0,o.label=1;case 1:return i<t.length?(a=(s=r).push,[4,this.addDocuments(t.slice(i,i+e),n)]):[3,4];case 2:a.apply(s,[o.sent()]),o.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.updateDocuments=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.put(n,t,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.updateDocumentsInBatches=function(t,e,n){return void 0===e&&(e=1e3),i(this,void 0,void 0,(function(){var r,i,s,a;return o(this,(function(o){switch(o.label){case 0:r=[],i=0,o.label=1;case 1:return i<t.length?(a=(s=r).push,[4,this.updateDocuments(t.slice(i,i+e),n)]):[3,4];case 2:a.apply(s,[o.sent()]),o.label=3;case 3:return i+=e,[3,1];case 4:return[2,r]}}))}))},t.prototype.deleteDocument=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/").concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteDocuments=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/documents/delete-batch"),[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteAllDocuments=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/documents"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSettings=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSettings=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSettings=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSynonyms=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSynonyms=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/synonyms"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getStopWords=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateStopWords=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetStopWords=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/stop-words"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateRankingRules=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetRankingRules=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/ranking-rules"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDistinctAttribute=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDistinctAttribute=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/distinct-attribute"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateFilterableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetFilterableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/filterable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSortableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSortableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/sortable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateSearchableAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetSearchableAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/searchable-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateDisplayedAttributes=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.put(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetDisplayedAttributes=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/displayed-attributes"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.updateTypoTolerance=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.patch(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.resetTypoTolerance=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="indexes/".concat(this.uid,"/settings/typo-tolerance"),[4,this.httpRequest.delete(t)];case 1:return[2,e.sent()]}}))}))},t}(),x=function(t){function e(e){return t.call(this,e)||this}return n(e,t),e}(function(){function t(t){this.config=t,this.httpRequest=new w(t),this.tasks=new m(t)}return t.prototype.index=function(t){return new T(this.config,t)},t.prototype.getIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new T(this.config,t).fetchInfo()]}))}))},t.prototype.getRawIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){return[2,new T(this.config,t).getRawInfo()]}))}))},t.prototype.getIndexes=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e,n,i=this;return o(this,(function(o){switch(o.label){case 0:return[4,this.getRawIndexes(t)];case 1:return e=o.sent(),n=e.results.map((function(t){return new T(i.config,t.uid,t.primaryKey)})),[2,r(r({},e),{results:n})]}}))}))},t.prototype.getRawIndexes=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="indexes",[4,this.httpRequest.get(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.createIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,T.create(t,e,this.config)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateIndex=function(t,e){return void 0===e&&(e={}),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,new T(this.config,t).update(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteIndex=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,new T(this.config,t).delete()];case 1:return[2,e.sent()]}}))}))},t.prototype.deleteIndexIfExists=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.deleteIndex(t)];case 1:return n.sent(),[2,!0];case 2:if("index_not_found"===(e=n.sent()).code)return[2,!1];throw e;case 3:return[2]}}))}))},t.prototype.getTasks=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTasks(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getTask=function(t){return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.getTask(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTasks=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTasks(t,{timeOutMs:s,intervalMs:u})];case 1:return[2,e.sent()]}}))}))},t.prototype.waitForTask=function(t,e){var n=void 0===e?{}:e,r=n.timeOutMs,s=void 0===r?5e3:r,a=n.intervalMs,u=void 0===a?50:a;return i(this,void 0,void 0,(function(){return o(this,(function(e){switch(e.label){case 0:return[4,this.tasks.waitForTask(t,{timeOutMs:s,intervalMs:u})];case 1:return[2,e.sent()]}}))}))},t.prototype.getKeys=function(t){return void 0===t&&(t={}),i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.get(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.get(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.createKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys",[4,this.httpRequest.post(e,t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateKey=function(t,e){return i(this,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n="keys/".concat(t),[4,this.httpRequest.patch(n,e)];case 1:return[2,r.sent()]}}))}))},t.prototype.deleteKey=function(t){return i(this,void 0,void 0,(function(){var e;return o(this,(function(n){switch(n.label){case 0:return e="keys/".concat(t),[4,this.httpRequest.delete(e)];case 1:return[2,n.sent()]}}))}))},t.prototype.health=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="health",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.isHealthy=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t="health",[4,this.httpRequest.get(t)];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}}))}))},t.prototype.getStats=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="stats",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.getVersion=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="version",[4,this.httpRequest.get(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.createDump=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t="dumps",[4,this.httpRequest.post(t)];case 1:return[2,e.sent()]}}))}))},t.prototype.generateTenantToken=function(t,e,n){var r=new Error;throw new Error("Meilisearch: failed to generate a tenant token. Generation of a token only works in a node environment \n ".concat(r.stack,"."))},t}());t.Index=T,t.MeiliSearch=x,t.MeiliSearchApiError=a,t.MeiliSearchCommunicationError=s,t.MeiliSearchError=h,t.MeiliSearchTimeOutError=l,t.default=x,t.httpErrorHandler=c,t.httpResponseErrorHandler=u,Object.defineProperty(t,"__esModule",{value:!0})}(e)}));function u(t){return t.replace(/:(.*)/i,'="$1"')}var c=function(t){var e=t.match(/([^=]*)="?([^\\"]*)"?$/);return e?(e[0],[{filterName:e[1],value:e[2]}]):[]};function h(t){var n=function(t){return"string"==typeof t?c(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return c(t)})):c(t)})).flat(2):[]}(t);return n.filter((function(t){return void 0!==t})).reduce((function(t,n){var r,o=n.filterName,s=n.value,a=t[o]||[];return t=e(e({},t),((r={})[o]=i(i([],a,!0),[s],!1),r))}),{})}function l(t,n){return t.keepZeroFacets?(r=t.defaultFacetDistribution,Object.keys(r).reduce((function(t,n){var i,o=Object.keys(r[n]);return e(e({},t),((i={})[n]=o,i))}),{})):h(null==n?void 0:n.filter);var r}var d={hits:[],query:"",facetDistribution:{},limit:0,offset:0,estimatedTotalHits:0,processingTimeMs:0};function f(t){return{searchResponse:function(e,i,o){return n(this,void 0,void 0,(function(){var n,s,a,u,c,h,f,p;return r(this,(function(r){switch(r.label){case 0:return n=e.placeholderSearch,s=e.query,n||s?(a=e.pagination,u=e.finitePagination?{}:a,c=t.formatKey([i,e.indexUid,e.query,u]),(h=t.getEntry(c))?[2,h]:(f=l(e,i),[4,o.index(e.indexUid).search(e.query,i)])):[2,d];case 1:return(p=r.sent()).facetDistribution=function(t,e){if(e=e||{},t&&Object.keys(t).length>0)for(var n in t){e[n]||(e[n]={});for(var r=0,i=t[n];r<i.length;r++){var o=i[r];Object.keys(e[n]).includes(o)||(e[n][o]=0)}}return e}(f,p.facetDistribution),t.setEntry(c,p),[2,p]}}))}))}}}function p(t){return 180*t/Math.PI}function v(t){return t*Math.PI/180}function y(t){if(t){var e,n,r=t.insideBoundingBox,i=t.aroundLatLng,o=t.aroundRadius,s=t.minimumAroundRadius;if(i&&(e=i),null==o&&null==s||(n=null!=o?o:s),r&&"string"==typeof r){var a=r.split(","),u=a[0],c=a[1],h=a[2],l=a[3],d=[parseFloat(u),parseFloat(c),parseFloat(h),parseFloat(l)],f=d[0],y=d[1],b=d[2],g=d[3];n=function(t,e,n,r){var i=t*Math.PI/180,o=n*Math.PI/180,s=(n-t)*Math.PI/180,a=(r-e)*Math.PI/180,u=Math.sin(s/2)*Math.sin(s/2)+Math.cos(i)*Math.cos(o)*Math.sin(a/2)*Math.sin(a/2);return 2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u))*6371e3}(f,y,b,g)/2,e=function(t,e,n,r){t=v(t),e=v(e);var i=Math.cos(t)*Math.cos(e),o=Math.cos(t)*Math.sin(e),s=Math.sin(t);n=v(n),r=v(r);var a=i+Math.cos(n)*Math.cos(r),u=o+Math.cos(n)*Math.sin(r),c=s+Math.sin(n),h=Math.sqrt(a*a+u*u),l=Math.atan2(u,a),d=Math.atan2(c,h);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(d+=Math.PI,l+=Math.PI):(d=p(d),l=p(l)),Math.abs(a)<Math.pow(10,-9)&&Math.abs(u)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(d=0,l=0),"".concat(d,",").concat(l)}(f,y,b,g)}if(null!=e&&null!=n){var w=e.split(","),m=w[0],T=w[1];return m=Number.parseFloat(m).toFixed(5),T=Number.parseFloat(T).toFixed(5),{filter:"_geoRadius(".concat(m,", ").concat(T,", ").concat(n,")")}}}}function b(t){return"string"==typeof t?u(t):Array.isArray(t)?t.map((function(t){return Array.isArray(t)?t.map((function(t){return u(t)})).filter((function(t){return t})):u(t)})).filter((function(t){return t})):[]}function g(t){return""===t?[]:"string"==typeof t?[t]:t}function w(t,e,n){return function(t,e,n){var r=n.trim(),o=g(t),s=g(e);return i(i(i([],o,!0),s,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(b(n||[]),b(e||[]),t||"")}function m(t){var e={},n=t.facets,r=t.attributesToSnippet,i=t.snippetEllipsisText,o=t.attributesToRetrieve,s=t.filters,a=t.numericFilters,u=t.facetFilters,c=t.attributesToHighlight,h=t.highlightPreTag,l=t.highlightPostTag,d=t.placeholderSearch,f=t.query,p=t.finitePagination,v=t.sort,b=t.pagination,g=t.optionalWords;return{getParams:function(){return e},addFacets:function(){(null==n?void 0:n.length)&&(e.facets=n)},addAttributesToCrop:function(){r&&(e.attributesToCrop=r)},addCropMarker:function(){null!=i&&(e.cropMarker=i)},addAttributesToRetrieve:function(){o&&(e.attributesToRetrieve=o)},addFilters:function(){var t=w(s,a,u);t.length&&(e.filter=t)},addAttributesToHighlight:function(){e.attributesToHighlight=c||["*"]},addPreTag:function(){e.highlightPreTag=h||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=l||"__/ais-highlight__"},addPagination:function(){if(!d&&""===f||0===b.paginationTotalHits)e.limit=0;else if(p)e.limit=b.paginationTotalHits;else{var t=(b.page+1)*b.hitsPerPage+1;t>b.paginationTotalHits?e.limit=b.paginationTotalHits:e.limit=t}},addSort:function(){(null==v?void 0:v.length)&&(e.sort=[v])},addGeoSearchRules:function(){var n=function(t){var e={},n=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,o=t.aroundPrecision,s=t.minimumAroundRadius,a=t.insideBoundingBox,u=t.insidePolygon;return n&&(e.aroundLatLng=n),r&&console.warn("instant-meilisearch: `aroundLatLngViaIP` is not supported."),i&&(e.aroundRadius=i),o&&console.warn("instant-meilisearch: `aroundPrecision` is not supported.\n See this discussion to track its implementation https://github.com/meilisearch/product/discussions/264"),s&&(e.minimumAroundRadius=s),a&&(e.insideBoundingBox=a),u&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),e}(t),r=y(n);(null==r?void 0:r.filter)&&(e.filter?e.filter.unshift(r.filter):e.filter=[r.filter])},addOptionalWords:function(){g&&(e.optionalWords=g)}}}function T(t){return"string"==typeof t?t:void 0===t?JSON.stringify(null):JSON.stringify(t)}function x(t){return Array.isArray(t)?t.map((function(t){return x(t)})):"object"!=typeof(e=t)||Array.isArray(e)||null===e?{value:T(t)}:Object.keys(t).reduce((function(e,n){return e[n]=x(t[n]),e}),{});var e}function R(t,e,n){var r=e.primaryKey,i=n.hitsPerPage,o=function(t,e,n){if(n<0)throw new TypeError('Value too small for "hitsPerPage" parameter, expected integer between 0 and 9223372036854775807');var r=e*n;return t.slice(r,r+n)}(t,n.page,i),s=o.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"]),i=Object.assign(n,function(t){if(!t)return{};var e=x(t);return{_highlightResult:e,_snippetResult:e}}(e));return r&&(i.objectID=t[r]),i}return t}));return s=function(t){for(var e=0;e<t.length;e++)t[e]._geo&&(t[e]._geoloc={lat:t[e]._geo.lat,lng:t[e]._geo.lng},t[e].objectID="".concat(e+1e6*Math.random()),delete t[e]._geo);return t}(s),s}function A(t,n){var r,i,o=t.facetDistribution,s=n.pagination,a=(r=t.hits.length,(i=s.hitsPerPage)>0?Math.ceil(r/i):0),u=R(t.hits,n,s),c=t.estimatedTotalHits,h=t.processingTimeMs,l=t.query,d=s.hitsPerPage,f=s.page;return{results:[e({index:n.indexUid,hitsPerPage:d,page:f,facets:o,nbPages:a,nbHits:c,processingTimeMS:h,query:l,hits:u,params:"",exhaustiveNbHits:!1},{})]}}function P(t){void 0===t&&(t={});var e=t;return{getEntry:function(t){if(e[t])try{return JSON.parse(e[t])}catch(n){return e[t]}},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={}}}}t.instantMeiliSearch=function(t,i,o){void 0===i&&(i=""),void 0===o&&(o={});var s=P(),u=f(s),c={},h=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.8.1-optional-words-beta.0",")");return t.concat(e)}(o.clientAgents),l=new a.MeiliSearch({host:t,apiKey:i,clientAgents:h});return{clearCache:function(){return s.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,s,a,h;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),n=t[0],i=function(t,n,r){var i=t.indexName.split(":"),o=i[0],s=i.slice(1),a=t.params,u=function(t){var e=t.paginationTotalHits,n=t.hitsPerPage;return{paginationTotalHits:null!=e?e:200,hitsPerPage:void 0===n?20:n,page:t.page||0}}({paginationTotalHits:n.paginationTotalHits,hitsPerPage:null==a?void 0:a.hitsPerPage,page:null==a?void 0:a.page});return e(e(e({},n),a),{sort:s.join(":")||"",indexUid:o,pagination:u,defaultFacetDistribution:r,placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets,finitePagination:!!n.finitePagination,optionalWords:n.optionalWords||"last"})}(n,o,c),s=function(t){var e=m(t);return e.addFacets(),e.addAttributesToHighlight(),e.addPreTag(),e.addPostTag(),e.addAttributesToRetrieve(),e.addAttributesToCrop(),e.addCropMarker(),e.addPagination(),e.addFilters(),e.addSort(),e.addGeoSearchRules(),e.addOptionalWords(),e.getParams()}(i),[4,u.searchResponse(i,s,l)];case 1:return a=r.sent(),c=function(t,e){return""===e.query&&0===Object.keys(t).length?e.facetDistribution:t}(c,a),[2,A(a,i)];case 2:throw h=r.sent(),console.error(h),new Error(h);case 3:return[2]}}))}))},searchForFacetValues:function(t){return n(this,void 0,void 0,(function(){return r(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()]}}))}))}}},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=instant-meilisearch.umd.min.js.map |
@@ -1,2 +0,2 @@ | ||
// Type definitions for @meilisearch/instant-meilisearch 0.8.0 | ||
// Type definitions for @meilisearch/instant-meilisearch 0.8.1-optional-words-beta.0 | ||
// Project: https://github.com/meilisearch/instant-meilisearch.git | ||
@@ -3,0 +3,0 @@ // Definitions by: Clementine Urquizar <https://github.com/meilisearch> |
@@ -1,2 +0,2 @@ | ||
export declare const PACKAGE_VERSION = "0.8.0"; | ||
export declare const PACKAGE_VERSION = "0.8.1-optional-words-beta.0"; | ||
//# sourceMappingURL=package-version.d.ts.map |
@@ -22,2 +22,3 @@ import type { SearchResponse as MeiliSearchResponse, FacetDistribution } from 'meilisearch'; | ||
clientAgents?: string[]; | ||
optionalWords?: string; | ||
}; | ||
@@ -28,12 +29,5 @@ export declare type SearchCacheInterface = { | ||
setEntry: <T>(key: string, searchResponse: T) => void; | ||
clearCache: () => void; | ||
}; | ||
export declare type InsideBoundingBox = string | ReadonlyArray<readonly number[]>; | ||
declare type ClientParams = { | ||
primaryKey?: string; | ||
placeholderSearch?: boolean; | ||
sort?: string; | ||
indexUid: string; | ||
paginationTotalHits: number; | ||
finitePagination: boolean; | ||
}; | ||
export declare type GeoSearchContext = { | ||
@@ -58,3 +52,3 @@ aroundLatLng?: string; | ||
}; | ||
export declare type SearchContext = Omit<InstantSearchParams & ClientParams, 'insideBoundingBox' | 'paginationTotalHits'> & { | ||
export declare type SearchContext = Omit<InstantSearchParams, 'insideBoundingBox' | 'optionalWords'> & InstantSearchParams & { | ||
insideBoundingBox?: InsideBoundingBox; | ||
@@ -65,4 +59,12 @@ keepZeroFacets?: boolean; | ||
pagination: PaginationContext; | ||
finitePagination: boolean; | ||
sort?: string; | ||
indexUid: string; | ||
placeholderSearch?: boolean; | ||
primaryKey?: string; | ||
optionalWords?: string; | ||
}; | ||
export declare type InstantMeiliSearchInstance = SearchClient; | ||
export declare type InstantMeiliSearchInstance = SearchClient & { | ||
clearCache: () => void; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@meilisearch/instant-meilisearch", | ||
"version": "0.8.0", | ||
"version": "0.8.1-optional-words-beta.0", | ||
"private": false, | ||
@@ -60,8 +60,8 @@ "description": "The search client to use Meilisearch with InstantSearch.", | ||
"dependencies": { | ||
"meilisearch": "^0.27.0" | ||
"meilisearch": "0.27.0-optional-words-beta.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.18.6", | ||
"@babel/core": "^7.18.6", | ||
"@babel/preset-env": "^7.18.6", | ||
"@babel/cli": "^7.18.9", | ||
"@babel/core": "^7.18.9", | ||
"@babel/preset-env": "^7.18.9", | ||
"@rollup/plugin-commonjs": "^17.1.0", | ||
@@ -74,3 +74,3 @@ "@rollup/plugin-node-resolve": "^11.2.0", | ||
"@vue/eslint-plugin": "^4.2.0", | ||
"algoliasearch": "^4.13.1", | ||
"algoliasearch": "^4.14.1", | ||
"babel-eslint": "^10.1.0", | ||
@@ -96,3 +96,3 @@ "babel-jest": "^27.2.2", | ||
"eslint-plugin-vue": "^7.7.0", | ||
"instantsearch.js": "^4.43.0", | ||
"instantsearch.js": "^4.43.1", | ||
"jest": "^27.2.2", | ||
@@ -106,3 +106,3 @@ "jest-watch-typeahead": "^0.6.3", | ||
"rollup-plugin-terser": "^7.0.0", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"rollup-plugin-typescript2": "^0.32.1", | ||
"shx": "^0.3.3", | ||
@@ -109,0 +109,0 @@ "ts-jest": "^27.0.7", |
@@ -44,3 +44,3 @@ <p align="center"> | ||
- [💅 Customization](#-customization) | ||
- [⚡️ Example with InstantSearch](#-example-with-instantSearch) | ||
- [🪡 Example with InstantSearch](#-example-with-instantsearch) | ||
- [🤖 Compatibility with Meilisearch and InstantSearch](#-compatibility-with-meilisearch-and-instantsearch) | ||
@@ -74,3 +74,3 @@ - [📜 API Resources](#-api-resources) | ||
'https://integration-demos.meilisearch.com', // Host | ||
'q7QHwGiX841a509c8b05ef29e55f2d94c02c00635f729ccf097a734cbdf7961530f47c47' // API key | ||
'99d1e034ed32eb569f9edc27962cccf90b736e4c5a70f7f5e76b9fab54d6a185' // API key | ||
) | ||
@@ -88,2 +88,3 @@ ``` | ||
- [`keepZeroFacets`](#keep-zero-facets): Show the facets value even when they have 0 matches (default `false`). | ||
- [`optionalWords`](#optional-words): Determine the search strategy on words matching (default `last`). [See extented explaination](https://github.com/meilisearch/meilisearch/discussions/2639). | ||
@@ -97,3 +98,3 @@ The options are added as the third parameter of the `instantMeilisearch` function. | ||
'https://integration-demos.meilisearch.com', | ||
'q7QHwGiX841a509c8b05ef29e55f2d94c02c00635f729ccf097a734cbdf7961530f47c47', | ||
'99d1e034ed32eb569f9edc27962cccf90b736e4c5a70f7f5e76b9fab54d6a185', | ||
{ | ||
@@ -133,3 +134,3 @@ paginationTotalHits: 30, // default: 200. | ||
Finite pagination is used when you want to add a numbered pagination at the bottom of your hits (for example: `< << 1, 2, 3 > >>`). | ||
Finite pagination is used when you want to add a numbered pagination at the bottom of your hits (for example: `<< < 1, 2, 3 > >>`). | ||
To be able to know the amount of page numbers you have, a search is done requesting `paginationTotalHits` documents (default: `200`). | ||
@@ -178,4 +179,17 @@ With the amount of documents returned, instantsearch is able to render the correct amount of numbers in the pagination widget. | ||
## ⚡️ Example with InstantSearch | ||
### Optional words | ||
`optionalWords` gives you the possibility to chose how Meilisearch should handle the presence of multiple query words. | ||
For example, if your query is `Hello world` by default Meilisearch returns documents containing either both `Hello` and `world` or documents that only contain `hello`. This is the `last` strategy, where words are stripped from the right. | ||
The other strategy is `none`, where both `hello` and `worlds` **must** be present in a document for it to be returned. | ||
```js | ||
{ | ||
optionalWords: 'none' // default last | ||
} | ||
``` | ||
## 🪡 Example with InstantSearch | ||
The open-source [InstantSearch](https://www.algolia.com/doc/api-reference/widgets/js/) library powered by Algolia provides all the front-end tools you need to highly customize your search bar environment. | ||
@@ -214,3 +228,3 @@ | ||
'https://integration-demos.meilisearch.com', | ||
'q7QHwGiX841a509c8b05ef29e55f2d94c02c00635f729ccf097a734cbdf7961530f47c47' | ||
'99d1e034ed32eb569f9edc27962cccf90b736e4c5a70f7f5e76b9fab54d6a185' | ||
), | ||
@@ -267,3 +281,3 @@ }) | ||
- NodeJS >= 12.10 <= 14 | ||
- NodeJS >= 12.10 <= 18 | ||
- NPM >= 6.x | ||
@@ -323,3 +337,3 @@ | ||
- ✅ IndexName: [`uid` of your index](https://docs.meilisearch.com/learn/core_concepts/indexes.html#indexes). _required_ | ||
- ✅ SearchClient: Search client, in our case instant-meilisearch. See [customization](#customization) for details on options. _required_ | ||
- ✅ SearchClient: Search client, in our case instant-meilisearch. See [customization](#-customization) for details on options. _required_ | ||
- ❌ numberLocale: Does not work with both Algoliasearch and instant-meilisearch. | ||
@@ -331,3 +345,3 @@ - ✅ searchFunction: Surcharge the search function provided by the search client. | ||
- ✅ routing: browser URL synchronization, search parameters appear in current URL ([guide](https://www.algolia.com/doc/guides/building-search-ui/going-further/routing-urls/js/)). | ||
- ✅ insightsClient: Hook analytics to search actions ([see insight section](#insight)). | ||
- ✅ insightsClient: Hook analytics to search actions ([see insight section](#-insight)). | ||
@@ -339,3 +353,3 @@ ```js | ||
'https://integration-demos.meilisearch.com', | ||
'q7QHwGiX841a509c8b05ef29e55f2d94c02c00635f729ccf097a734cbdf7961530f47c47', | ||
'99d1e034ed32eb569f9edc27962cccf90b736e4c5a70f7f5e76b9fab54d6a185', | ||
{ | ||
@@ -527,3 +541,3 @@ // ... InstantMeiliSearch options | ||
See [Hits](#hits) for an example. | ||
See [Hits](#-hits) for an example. | ||
@@ -540,3 +554,3 @@ ### ✅ Snippet | ||
Note that the attribute has to be added to `attributesToSnippet` in [configuration](#configuration). Highlight is applied on snippeted fields. | ||
Note that the attribute has to be added to `attributesToSnippet` in [configuration](#-configure). Highlight is applied on snippeted fields. | ||
@@ -922,3 +936,3 @@ Snippeting is called `cropping` in Meilisearch, [more about it here](https://docs.meilisearch.com/reference/features/search_parameters.html#attributes-to-retrieve). It is possible to change the size of the snippeting by adding its character size in the attributesToSnippet parameter. <br> | ||
We do not recommend using this widget as pagination slows the search responses. Instead, the [InfiniteHits](#InfiniteHits) component is recommended. | ||
We do not recommend using this widget as pagination slows the search responses. Instead, the [InfiniteHits](#-infinitehits) component is recommended. | ||
@@ -987,3 +1001,3 @@ - ✅ container: The CSS Selector or HTMLElement to insert the widget into. _required_ | ||
Deprecated. See [Insight](#Insight). | ||
Deprecated. See [Insight](#-insight). | ||
@@ -990,0 +1004,0 @@ ### ❌ QueryRuleCustomData |
@@ -8,2 +8,3 @@ import { addMissingFacets } from '../filters' | ||
) | ||
expect(returnedDistribution).toMatchObject({ genre: { comedy: 1 } }) | ||
@@ -14,2 +15,3 @@ }) | ||
const returnedDistribution = addMissingFacets({ genre: ['comedy'] }, {}) | ||
expect(returnedDistribution).toMatchObject({ genre: { comedy: 0 } }) | ||
@@ -23,2 +25,3 @@ }) | ||
) | ||
expect(returnedDistribution).toMatchObject({ | ||
@@ -35,2 +38,3 @@ genre: { comedy: 12 }, | ||
) | ||
expect(returnedDistribution).toMatchObject({ | ||
@@ -47,2 +51,3 @@ genre: { comedy: 0 }, | ||
) | ||
expect(returnedDistribution).toMatchObject({ | ||
@@ -59,2 +64,3 @@ genre: { comedy: 12 }, | ||
) | ||
expect(returnedDistribution).toMatchObject({ | ||
@@ -70,2 +76,3 @@ genre: { comedy: 12, horror: 0 }, | ||
}) | ||
expect(returnedDistribution).toMatchObject({ genre: { comedy: 12 } }) | ||
@@ -76,2 +83,3 @@ }) | ||
const returnedDistribution = addMissingFacets({}, { genre: { comedy: 12 } }) | ||
expect(returnedDistribution).toMatchObject({ genre: { comedy: 12 } }) | ||
@@ -82,2 +90,3 @@ }) | ||
const returnedDistribution = addMissingFacets({}, {}) | ||
expect(returnedDistribution).toMatchObject({}) | ||
@@ -88,2 +97,3 @@ }) | ||
const returnedDistribution = addMissingFacets(undefined, {}) | ||
expect(returnedDistribution).toMatchObject({}) | ||
@@ -94,3 +104,4 @@ }) | ||
const returnedDistribution = addMissingFacets(undefined, undefined) | ||
expect(returnedDistribution).toMatchObject({}) | ||
}) |
@@ -67,2 +67,3 @@ import { extractFacets } from '../filters' | ||
) | ||
expect(cache).toEqual(expectedCache) | ||
@@ -69,0 +70,0 @@ }) |
@@ -20,2 +20,3 @@ import { adaptGeoPointsRules } from '../geo-rules-adapter' | ||
}) | ||
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)') | ||
@@ -28,2 +29,3 @@ }) | ||
}) | ||
expect(rules).toBeUndefined() | ||
@@ -36,2 +38,3 @@ }) | ||
}) | ||
expect(rules?.filter).toBeUndefined() | ||
@@ -45,2 +48,3 @@ }) | ||
}) | ||
expect(rules?.filter).toBe('_geoRadius(51.12420, 9.66250, 1)') | ||
@@ -54,2 +58,3 @@ }) | ||
}) | ||
expect(rules?.filter).toBe('_geoRadius(51.12420, 9.66250, 0)') | ||
@@ -64,2 +69,3 @@ }) | ||
}) | ||
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)') | ||
@@ -72,2 +78,3 @@ }) | ||
}) | ||
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)') | ||
@@ -80,3 +87,4 @@ }) | ||
}) | ||
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)') | ||
}) |
import { adaptSearchParams } from '../search-params-adapter' | ||
test('Adapt basic SearchContext ', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
const DEFAULT_CONTEXT = { | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
defaultFacetDistribution: {}, | ||
} | ||
describe('Parameters adapter', () => { | ||
test('adapting a basic searchContext ', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
finitePagination: false, | ||
}) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
test('Adapt SearchContext with filters, sort and no geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
facetFilters: [['genres:Drama', 'genres:Thriller'], ['title:Ariel']], | ||
sort: 'id < 1', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
test('adapting a searchContext with filters and sort', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
facetFilters: [['genres:Drama', 'genres:Thriller'], ['title:Ariel']], | ||
sort: 'id < 1', | ||
finitePagination: false, | ||
}) | ||
expect(searchParams.filter).toStrictEqual([ | ||
['genres="Drama"', 'genres="Thriller"'], | ||
['title="Ariel"'], | ||
]) | ||
expect(searchParams.sort).toStrictEqual(['id < 1']) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
expect(searchParams.filter).toStrictEqual([ | ||
['genres="Drama"', 'genres="Thriller"'], | ||
['title="Ariel"'], | ||
]) | ||
expect(searchParams.sort).toStrictEqual(['id < 1']) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
test('Adapt SearchContext with filters, sort and geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
facetFilters: [['genres:Drama', 'genres:Thriller'], ['title:Ariel']], | ||
insideBoundingBox: '0,0,0,0', | ||
sort: 'id < 1', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
describe('Geo rules adapter', () => { | ||
test('adapting a searchContext with filters, sort and geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
facetFilters: [['genres:Drama', 'genres:Thriller'], ['title:Ariel']], | ||
insideBoundingBox: '0,0,0,0', | ||
sort: 'id < 1', | ||
finitePagination: false, | ||
}) | ||
expect(searchParams.filter).toStrictEqual([ | ||
'_geoRadius(0.00000, 0.00000, 0)', | ||
['genres="Drama"', 'genres="Thriller"'], | ||
['title="Ariel"'], | ||
]) | ||
expect(searchParams.sort).toStrictEqual(['id < 1']) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
expect(searchParams.filter).toStrictEqual([ | ||
'_geoRadius(0.00000, 0.00000, 0)', | ||
['genres="Drama"', 'genres="Thriller"'], | ||
['title="Ariel"'], | ||
]) | ||
expect(searchParams.sort).toStrictEqual(['id < 1']) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
test('adapting a searchContext with only facetFilters and geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
facetFilters: [['genres:Drama', 'genres:Thriller'], ['title:Ariel']], | ||
insideBoundingBox: '0,0,0,0', | ||
finitePagination: false, | ||
}) | ||
test('Adapt SearchContext with only facetFilters and geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
facetFilters: [['genres:Drama', 'genres:Thriller'], ['title:Ariel']], | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
expect(searchParams.filter).toEqual([ | ||
'_geoRadius(0.00000, 0.00000, 0)', | ||
['genres="Drama"', 'genres="Thriller"'], | ||
['title="Ariel"'], | ||
]) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
expect(searchParams.filter).toEqual([ | ||
'_geoRadius(0.00000, 0.00000, 0)', | ||
['genres="Drama"', 'genres="Thriller"'], | ||
['title="Ariel"'], | ||
]) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
test('adapting a searchContext with only sort and geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
insideBoundingBox: '0,0,0,0', | ||
sort: 'id < 1', | ||
finitePagination: false, | ||
}) | ||
test('Adapt SearchContext with only sort and geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
sort: 'id < 1', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
expect(searchParams.filter).toEqual(['_geoRadius(0.00000, 0.00000, 0)']) | ||
expect(searchParams.sort).toStrictEqual(['id < 1']) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
expect(searchParams.filter).toEqual(['_geoRadius(0.00000, 0.00000, 0)']) | ||
expect(searchParams.sort).toStrictEqual(['id < 1']) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
test('adapting a searchContext with no sort and no filters and geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
insideBoundingBox: '0,0,0,0', | ||
finitePagination: false, | ||
}) | ||
test('Adapt SearchContext with no sort and no filters and geo rules ', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
expect(searchParams.filter).toEqual(['_geoRadius(0.00000, 0.00000, 0)']) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
expect(searchParams.filter).toEqual(['_geoRadius(0.00000, 0.00000, 0)']) | ||
expect(searchParams.attributesToHighlight).toContain('*') | ||
expect(searchParams.attributesToHighlight?.length).toBe(1) | ||
}) | ||
test('Adapt SearchContext with finite pagination', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: true, | ||
describe('Pagination adapter', () => { | ||
test('adapting a searchContext with finite pagination', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
finitePagination: true, | ||
}) | ||
expect(searchParams.limit).toBe(20) | ||
}) | ||
expect(searchParams.limit).toBe(20) | ||
}) | ||
test('adapting a searchContext with finite pagination on a later page', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
pagination: { paginationTotalHits: 20, page: 10, hitsPerPage: 6 }, | ||
finitePagination: true, | ||
}) | ||
test('Adapt SearchContext with finite pagination on a later page', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 10, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: true, | ||
expect(searchParams.limit).toBe(20) | ||
}) | ||
expect(searchParams.limit).toBe(20) | ||
}) | ||
test('adapting a searchContext with finite pagination and pagination total hits lower than hitsPerPage', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
pagination: { paginationTotalHits: 4, page: 0, hitsPerPage: 6 }, | ||
finitePagination: true, | ||
}) | ||
test('Adapt SearchContext with finite pagination and pagination total hits lower than hitsPerPage', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 4, page: 0, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: true, | ||
expect(searchParams.limit).toBe(4) | ||
}) | ||
expect(searchParams.limit).toBe(4) | ||
}) | ||
test('adapting a searchContext with no finite pagination', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
finitePagination: false, | ||
}) | ||
test('Adapt SearchContext with no finite pagination', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 0, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
expect(searchParams.limit).toBe(7) | ||
}) | ||
expect(searchParams.limit).toBe(7) | ||
}) | ||
test('adapting a searchContext with no finite pagination on page 2', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
pagination: { paginationTotalHits: 20, page: 1, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
}) | ||
test('Adapt SearchContext with no finite pagination on page 2', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 1, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
expect(searchParams.limit).toBe(13) | ||
}) | ||
expect(searchParams.limit).toBe(13) | ||
}) | ||
test('adapting a searchContext with no finite pagination on page higher than paginationTotalHits', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
pagination: { paginationTotalHits: 20, page: 40, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
}) | ||
test('Adapt SearchContext with no finite pagination on page higher than paginationTotalHits', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 20, page: 40, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
expect(searchParams.limit).toBe(20) | ||
}) | ||
expect(searchParams.limit).toBe(20) | ||
}) | ||
test('adapting a searchContext with no finite pagination and pagination total hits lower than hitsPerPage', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
pagination: { paginationTotalHits: 4, page: 0, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
}) | ||
test('Adapt SearchContext with no finite pagination and pagination total hits lower than hitsPerPage', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
pagination: { paginationTotalHits: 4, page: 0, hitsPerPage: 6 }, | ||
insideBoundingBox: '0,0,0,0', | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
expect(searchParams.limit).toBe(4) | ||
}) | ||
expect(searchParams.limit).toBe(4) | ||
}) | ||
test('adapting a searchContext placeholderSearch set to false', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
query: '', | ||
pagination: { paginationTotalHits: 4, page: 0, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
placeholderSearch: false, | ||
}) | ||
test('Adapt SearchContext placeholderSearch set to false', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
query: '', | ||
pagination: { paginationTotalHits: 4, page: 0, hitsPerPage: 6 }, | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
placeholderSearch: false, | ||
expect(searchParams.limit).toBe(0) | ||
}) | ||
expect(searchParams.limit).toBe(0) | ||
}) | ||
test('adapting a searchContext placeholderSearch set to false', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
query: '', | ||
pagination: { paginationTotalHits: 200, page: 0, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
placeholderSearch: true, | ||
}) | ||
test('Adapt SearchContext placeholderSearch set to false', () => { | ||
const searchParams = adaptSearchParams({ | ||
indexUid: 'test', | ||
query: '', | ||
pagination: { paginationTotalHits: 200, page: 0, hitsPerPage: 6 }, | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
placeholderSearch: true, | ||
expect(searchParams.limit).toBe(7) | ||
}) | ||
expect(searchParams.limit).toBe(7) | ||
}) |
@@ -10,2 +10,124 @@ import type { MeiliSearchParams, SearchContext } from '../../types' | ||
/** | ||
* Adapts instantsearch.js and instant-meilisearch options | ||
* to meilisearch search query parameters. | ||
* | ||
* @param {SearchContext} searchContext | ||
* | ||
* @returns {MeiliSearchParams} | ||
*/ | ||
function MeiliParamsCreator(searchContext: SearchContext) { | ||
const meiliSearchParams: Record<string, any> = {} | ||
const { | ||
facets, | ||
attributesToSnippet, | ||
snippetEllipsisText, | ||
attributesToRetrieve, | ||
filters, | ||
numericFilters, | ||
facetFilters, | ||
attributesToHighlight, | ||
highlightPreTag, | ||
highlightPostTag, | ||
placeholderSearch, | ||
query, | ||
finitePagination, | ||
sort, | ||
pagination, | ||
optionalWords, | ||
} = searchContext | ||
return { | ||
getParams() { | ||
return meiliSearchParams | ||
}, | ||
addFacets() { | ||
if (facets?.length) { | ||
meiliSearchParams.facets = facets | ||
} | ||
}, | ||
addAttributesToCrop() { | ||
if (attributesToSnippet) { | ||
meiliSearchParams.attributesToCrop = attributesToSnippet | ||
} | ||
}, | ||
addCropMarker() { | ||
// Attributes To Crop marker | ||
if (snippetEllipsisText != null) { | ||
meiliSearchParams.cropMarker = snippetEllipsisText | ||
} | ||
}, | ||
addAttributesToRetrieve() { | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToRetrieve = attributesToRetrieve | ||
} | ||
}, | ||
addFilters() { | ||
const filter = adaptFilters(filters, numericFilters, facetFilters) | ||
if (filter.length) { | ||
meiliSearchParams.filter = filter | ||
} | ||
}, | ||
addAttributesToHighlight() { | ||
meiliSearchParams.attributesToHighlight = attributesToHighlight || ['*'] | ||
}, | ||
addPreTag() { | ||
if (highlightPreTag) { | ||
meiliSearchParams.highlightPreTag = highlightPreTag | ||
} else { | ||
meiliSearchParams.highlightPreTag = '__ais-highlight__' | ||
} | ||
}, | ||
addPostTag() { | ||
if (highlightPostTag) { | ||
meiliSearchParams.highlightPostTag = highlightPostTag | ||
} else { | ||
meiliSearchParams.highlightPostTag = '__/ais-highlight__' | ||
} | ||
}, | ||
addPagination() { | ||
// Limit based on pagination preferences | ||
if ( | ||
(!placeholderSearch && query === '') || | ||
pagination.paginationTotalHits === 0 | ||
) { | ||
meiliSearchParams.limit = 0 | ||
} else if (finitePagination) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits | ||
} else { | ||
const limit = (pagination.page + 1) * pagination.hitsPerPage + 1 | ||
// If the limit is bigger than the total hits accepted | ||
// force the limit to that amount | ||
if (limit > pagination.paginationTotalHits) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits | ||
} else { | ||
meiliSearchParams.limit = limit | ||
} | ||
} | ||
}, | ||
addSort() { | ||
if (sort?.length) { | ||
meiliSearchParams.sort = [sort] | ||
} | ||
}, | ||
addGeoSearchRules() { | ||
const geoSearchContext = createGeoSearchContext(searchContext) | ||
const geoRules = adaptGeoPointsRules(geoSearchContext) | ||
if (geoRules?.filter) { | ||
if (meiliSearchParams.filter) { | ||
meiliSearchParams.filter.unshift(geoRules.filter) | ||
} else { | ||
meiliSearchParams.filter = [geoRules.filter] | ||
} | ||
} | ||
}, | ||
addOptionalWords() { | ||
if (optionalWords) { | ||
meiliSearchParams.optionalWords = optionalWords | ||
} | ||
}, | ||
} | ||
} | ||
/** | ||
* Adapt search request from instantsearch.js | ||
@@ -20,109 +142,17 @@ * to search request compliant with Meilisearch | ||
): MeiliSearchParams { | ||
// Creates search params object compliant with Meilisearch | ||
const meiliSearchParams: Record<string, any> = {} | ||
const meilisearchParams = MeiliParamsCreator(searchContext) | ||
meilisearchParams.addFacets() | ||
meilisearchParams.addAttributesToHighlight() | ||
meilisearchParams.addPreTag() | ||
meilisearchParams.addPostTag() | ||
meilisearchParams.addAttributesToRetrieve() | ||
meilisearchParams.addAttributesToCrop() | ||
meilisearchParams.addCropMarker() | ||
meilisearchParams.addPagination() | ||
meilisearchParams.addFilters() | ||
meilisearchParams.addSort() | ||
meilisearchParams.addGeoSearchRules() | ||
meilisearchParams.addOptionalWords() | ||
// Facets | ||
const facets = searchContext?.facets | ||
if (facets?.length) { | ||
meiliSearchParams.facets = facets | ||
} | ||
// Attributes To Crop | ||
const attributesToCrop = searchContext?.attributesToSnippet | ||
if (attributesToCrop) { | ||
meiliSearchParams.attributesToCrop = attributesToCrop | ||
} | ||
// Attributes To Crop marker | ||
const cropMarker = searchContext?.snippetEllipsisText | ||
if (cropMarker != null) { | ||
meiliSearchParams.cropMarker = cropMarker | ||
} | ||
// Attributes To Retrieve | ||
const attributesToRetrieve = searchContext?.attributesToRetrieve | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToRetrieve = attributesToRetrieve | ||
} | ||
// Filter | ||
const filter = adaptFilters( | ||
searchContext?.filters, | ||
searchContext?.numericFilters, | ||
searchContext?.facetFilters | ||
) | ||
if (filter.length) { | ||
meiliSearchParams.filter = filter | ||
} | ||
// Attributes To Retrieve | ||
if (attributesToRetrieve) { | ||
meiliSearchParams.attributesToCrop = attributesToRetrieve | ||
} | ||
// Attributes To Highlight | ||
meiliSearchParams.attributesToHighlight = searchContext?.attributesToHighlight || [ | ||
'*', | ||
] | ||
// Highlight pre tag | ||
const highlightPreTag = searchContext?.highlightPreTag | ||
if (highlightPreTag) { | ||
meiliSearchParams.highlightPreTag = highlightPreTag | ||
} else { | ||
meiliSearchParams.highlightPreTag = '__ais-highlight__' | ||
} | ||
// Highlight post tag | ||
const highlightPostTag = searchContext?.highlightPostTag | ||
if (highlightPostTag) { | ||
meiliSearchParams.highlightPostTag = highlightPostTag | ||
} else { | ||
meiliSearchParams.highlightPostTag = '__/ais-highlight__' | ||
} | ||
const placeholderSearch = searchContext.placeholderSearch | ||
const query = searchContext.query | ||
// Pagination | ||
const { pagination } = searchContext | ||
// Limit based on pagination preferences | ||
if ( | ||
(!placeholderSearch && query === '') || | ||
pagination.paginationTotalHits === 0 | ||
) { | ||
meiliSearchParams.limit = 0 | ||
} else if (searchContext.finitePagination) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits | ||
} else { | ||
const limit = (pagination.page + 1) * pagination.hitsPerPage + 1 | ||
// If the limit is bigger than the total hits accepted | ||
// force the limit to that amount | ||
if (limit > pagination.paginationTotalHits) { | ||
meiliSearchParams.limit = pagination.paginationTotalHits | ||
} else { | ||
meiliSearchParams.limit = limit | ||
} | ||
} | ||
const sort = searchContext.sort | ||
// Sort | ||
if (sort?.length) { | ||
meiliSearchParams.sort = [sort] | ||
} | ||
const geoSearchContext = createGeoSearchContext(searchContext) | ||
const geoRules = adaptGeoPointsRules(geoSearchContext) | ||
if (geoRules?.filter) { | ||
if (meiliSearchParams.filter) { | ||
meiliSearchParams.filter.unshift(geoRules.filter) | ||
} else { | ||
meiliSearchParams.filter = [geoRules.filter] | ||
} | ||
} | ||
return meiliSearchParams | ||
return meilisearchParams.getParams() | ||
} |
@@ -132,2 +132,3 @@ import { adaptPagination } from '../pagination-adapter' | ||
const response = ceiledDivision(hitsLength, hitsPerPage) | ||
expect(response).toBe(numberPages) | ||
@@ -147,2 +148,3 @@ }) | ||
const response = adaptPagination(hits, page, hitsPerPage) | ||
expect(response).toEqual(returnedHits) | ||
@@ -158,2 +160,3 @@ }) | ||
const page = 0 | ||
adaptPagination(hits, page, hitsPerPage) | ||
@@ -160,0 +163,0 @@ } catch (e: any) { |
@@ -5,3 +5,3 @@ import { SearchCache } from '../search-cache' | ||
describe('Tests on entries in cache', () => { | ||
test('Test to getEntry on empty cache', () => { | ||
test('to getEntry on empty cache', () => { | ||
const cache = SearchCache() | ||
@@ -13,3 +13,3 @@ const key = cache.getEntry('') | ||
test('Test to getEntry on invalid json', () => { | ||
test('to getEntry on invalid json', () => { | ||
const cache = SearchCache({ myKey: 'myValue' }) | ||
@@ -21,3 +21,3 @@ const key = cache.getEntry('myKey') | ||
test('Test to getEntry on valid json string', () => { | ||
test('to getEntry on valid json string', () => { | ||
const cache = SearchCache({ myKey: '"myValue"' }) | ||
@@ -29,3 +29,3 @@ const key = cache.getEntry('myKey') | ||
test('Test to getEntry on valid json object', () => { | ||
test('to getEntry on valid json object', () => { | ||
const cache = SearchCache({ myKey: '{ "id": 1 }' }) | ||
@@ -37,3 +37,3 @@ const key = cache.getEntry('myKey') | ||
test('Test to getEntry on invalid json object', () => { | ||
test('to getEntry on invalid json object', () => { | ||
const cache = SearchCache({ myKey: '{ id: 1 }' }) | ||
@@ -47,28 +47,33 @@ const key = cache.getEntry('myKey') | ||
describe('Tests on key format', () => { | ||
test('Test to format an empty string', () => { | ||
test('to format an empty string', () => { | ||
const cache = SearchCache() | ||
const key = cache.formatKey(['']) | ||
expect(key).toEqual('""') | ||
}) | ||
test('Test to format a number', () => { | ||
test('to format a number', () => { | ||
const cache = SearchCache() | ||
const key = cache.formatKey([1]) | ||
expect(key).toEqual('1') | ||
}) | ||
test('Test to format multiple empty strings', () => { | ||
test('to format multiple empty strings', () => { | ||
const cache = SearchCache() | ||
const key = cache.formatKey(['', '', '']) | ||
expect(key).toEqual('""""""') | ||
}) | ||
test('Test to format empty string', () => { | ||
test('to format empty string', () => { | ||
const cache = SearchCache() | ||
const key = cache.formatKey([]) | ||
expect(key).toEqual('') | ||
}) | ||
test('Test to format undefined', () => { | ||
test('to format undefined', () => { | ||
const cache = SearchCache() | ||
const key = cache.formatKey([undefined]) | ||
expect(key).toEqual('undefined') | ||
@@ -75,0 +80,0 @@ }) |
@@ -10,3 +10,3 @@ import { SearchCacheInterface } from '../types' | ||
): SearchCacheInterface { | ||
const searchCache = cache | ||
let searchCache = cache | ||
return { | ||
@@ -29,3 +29,6 @@ getEntry: function (key: string) { | ||
}, | ||
clearCache: function () { | ||
searchCache = {} | ||
}, | ||
} | ||
} |
@@ -31,4 +31,5 @@ import { MeiliSearch } from 'meilisearch' | ||
): InstantMeiliSearchInstance { | ||
const searchCache = SearchCache() | ||
// create search resolver with included cache | ||
const searchResolver = SearchResolver(SearchCache()) | ||
const searchResolver = SearchResolver(searchCache) | ||
// paginationTotalHits can be 0 as it is a valid number | ||
@@ -47,2 +48,3 @@ let defaultFacetDistribution: any = {} | ||
return { | ||
clearCache: () => searchCache.clearCache(), | ||
/** | ||
@@ -49,0 +51,0 @@ * @param {readonlyAlgoliaMultipleQueriesQuery[]} instantSearchRequests |
@@ -40,4 +40,5 @@ import { | ||
finitePagination: !!options.finitePagination, // false by default | ||
optionalWords: options.optionalWords || 'last', | ||
} | ||
return searchContext | ||
} |
@@ -1,1 +0,1 @@ | ||
export const PACKAGE_VERSION = '0.8.0' | ||
export const PACKAGE_VERSION = '0.8.1-optional-words-beta.0' |
@@ -37,2 +37,3 @@ import type { | ||
clientAgents?: string[] | ||
optionalWords?: string | ||
} | ||
@@ -44,2 +45,3 @@ | ||
setEntry: <T>(key: string, searchResponse: T) => void | ||
clearCache: () => void | ||
} | ||
@@ -49,11 +51,2 @@ | ||
type ClientParams = { | ||
primaryKey?: string | ||
placeholderSearch?: boolean | ||
sort?: string | ||
indexUid: string | ||
paginationTotalHits: number | ||
finitePagination: boolean | ||
} | ||
export type GeoSearchContext = { | ||
@@ -82,12 +75,21 @@ aroundLatLng?: string | ||
export type SearchContext = Omit< | ||
InstantSearchParams & ClientParams, | ||
'insideBoundingBox' | 'paginationTotalHits' | ||
> & { | ||
insideBoundingBox?: InsideBoundingBox | ||
keepZeroFacets?: boolean | ||
cropMarker?: string | ||
defaultFacetDistribution: FacetDistribution | ||
pagination: PaginationContext | ||
InstantSearchParams, | ||
'insideBoundingBox' | 'optionalWords' | ||
> & | ||
InstantSearchParams & { | ||
insideBoundingBox?: InsideBoundingBox | ||
keepZeroFacets?: boolean | ||
cropMarker?: string | ||
defaultFacetDistribution: FacetDistribution | ||
pagination: PaginationContext | ||
finitePagination: boolean | ||
sort?: string | ||
indexUid: string | ||
placeholderSearch?: boolean | ||
primaryKey?: string | ||
optionalWords?: string | ||
} | ||
export type InstantMeiliSearchInstance = SearchClient & { | ||
clearCache: () => void | ||
} | ||
export type InstantMeiliSearchInstance = SearchClient |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
619039
8693
1091
+ Addedmeilisearch@0.27.0-optional-words-beta.0(transitive)
- Removedmeilisearch@0.27.0(transitive)