@meilisearch/instant-meilisearch
Advanced tools
Comparing version 0.8.2 to 0.9.0
@@ -525,3 +525,3 @@ 'use strict'; | ||
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; | ||
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, matchingStrategy = searchContext.matchingStrategy; | ||
return { | ||
@@ -614,2 +614,7 @@ getParams: function () { | ||
} | ||
}, | ||
addMatchingStrategy: function () { | ||
if (matchingStrategy) { | ||
meiliSearchParams.matchingStrategy = matchingStrategy; | ||
} | ||
} | ||
@@ -638,2 +643,3 @@ }; | ||
meilisearchParams.addGeoSearchRules(); | ||
meilisearchParams.addMatchingStrategy(); | ||
return meilisearchParams.getParams(); | ||
@@ -887,3 +893,3 @@ } | ||
var PACKAGE_VERSION = '0.8.2'; | ||
var PACKAGE_VERSION = '0.9.0'; | ||
@@ -971,2 +977,8 @@ var constructClientAgents = function (clientAgents) { | ||
exports.MatchingStrategies = void 0; | ||
(function (MatchingStrategies) { | ||
MatchingStrategies["ALL"] = "all"; | ||
MatchingStrategies["LAST"] = "last"; | ||
})(exports.MatchingStrategies || (exports.MatchingStrategies = {})); | ||
exports.instantMeiliSearch = instantMeiliSearch; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("meilisearch"),e=function(){return e=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},e.apply(this,arguments)};function n(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(t){try{s(r.next(t))}catch(t){a(t)}}function u(t){try{s(r.throw(t))}catch(t){a(t)}}function s(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,u)}s((r=r.apply(t,e||[])).next())}))}function r(t,e){var n,r,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){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,u])}}}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 u(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,u=t[a]||[];return t=e(e({},t),((r={})[a]=i(i([],u,!0),[o],!1),r))}),{})}function s(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))}),{})):u(null==n?void 0:n.filter);var r}function c(t,e){return{searchResponse:function(i,a){return n(this,void 0,void 0,(function(){var n,o,u,c,l,f,h,d;return r(this,(function(r){switch(r.label){case 0:return n=i.placeholderSearch,o=i.query,u=i.pagination,c=i.finitePagination?{}:u,l=e.formatKey([a,i.indexUid,i.query,c]),(f=e.getEntry(l))?[2,f]:(h=s(i,a),[4,t.index(i.indexUid).search(i.query,a)]);case 1:return(d=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}(h,d.facetDistribution),n||o||(d.hits=[]),e.setEntry(l,d),[2,d]}}))}))}}}function l(t){return 180*t/Math.PI}function f(t){return t*Math.PI/180}function h(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 u=r.split(","),s=u[0],c=u[1],h=u[2],d=u[3],p=[parseFloat(s),parseFloat(c),parseFloat(h),parseFloat(d)],g=p[0],v=p[1],y=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,u=(r-e)*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}(g,v,y,b)/2,e=function(t,e,n,r){t=f(t),e=f(e);var i=Math.cos(t)*Math.cos(e),a=Math.cos(t)*Math.sin(e),o=Math.sin(t);n=f(n),r=f(r);var u=i+Math.cos(n)*Math.cos(r),s=a+Math.cos(n)*Math.sin(r),c=o+Math.sin(n),h=Math.sqrt(u*u+s*s),d=Math.atan2(s,u),p=Math.atan2(c,h);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(p+=Math.PI,d+=Math.PI):(p=l(p),d=l(d)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(p=0,d=0),"".concat(p,",").concat(d)}(g,v,y,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 d(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 p(t){return""===t?[]:"string"==typeof t?[t]:t}function g(t,e,n){return function(t,e,n){var r=n.trim(),a=p(t),o=p(e);return i(i(i([],a,!0),o,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(d(n||[]),d(e||[]),t||"")}function v(t){var e={},n=t.facets,r=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.filters,u=t.numericFilters,s=t.facetFilters,c=t.attributesToHighlight,l=t.highlightPreTag,f=t.highlightPostTag,d=t.placeholderSearch,p=t.query,v=t.finitePagination,y=t.sort,b=t.pagination;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=g(o,u,s);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(!d&&""===p||0===b.paginationTotalHits)e.limit=0;else if(v)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==y?void 0:y.length)&&(e.sort=[y])},addGeoSearchRules:function(){var n=function(t){var e={},n=t.aroundLatLng,r=t.aroundLatLngViaIP,i=t.aroundRadius,a=t.aroundPrecision,o=t.minimumAroundRadius,u=t.insideBoundingBox,s=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),u&&(e.insideBoundingBox=u),s&&console.warn("instant-meilisearch: `insidePolygon` is not implented in instant-meilisearch."),e}(t),r=h(n);(null==r?void 0:r.filter)&&(e.filter?e.filter.unshift(r.filter):e.filter=[r.filter])}}}function y(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(e=t)||Array.isArray(e)||null===e?{value:y(t)}:Object.keys(t).reduce((function(e,n){return e[n]=b(t[n]),e}),{});var e}function m(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=b(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 P(t,n){var r,i,a=t.facetDistribution,o=n.pagination,u=(r=t.hits.length,(i=o.hitsPerPage)>0?Math.ceil(r/i):0),s=m(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:u,nbHits:c,processingTimeMS:l,query:f,hits:s,params:"",exhaustiveNbHits:!1},{})]}}function M(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={}}}}function T(t,i){return n(this,void 0,void 0,(function(){var n,a;return r(this,(function(r){switch(r.label){case 0:return n=e(e({},i),{placeholderSearch:!0,pagination:e(e({},i.pagination),{paginationTotalHits:0}),query:""}),(a=v(n)).addFacets(),a.addPagination(),[4,t.searchResponse(n,a.getParams())];case 1:return[2,r.sent().facetDistribution||{}]}}))}))}exports.instantMeiliSearch=function(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u,s=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.8.2",")");return t.concat(e)}(o.clientAgents),l=new t.MeiliSearch({host:i,apiKey:a,clientAgents:s}),f=M(),h=c(l,f);return{clearCache:function(){return f.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,s,c;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),n=t[0],i=function(t,n,r){var i=t.indexName.split(":"),a=i[0],o=i.slice(1),u=t.params,s=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:o.join(":")||"",indexUid:a,pagination:s,defaultFacetDistribution:r||{},placeholderSearch:!1!==n.placeholderSearch,keepZeroFacets:!!n.keepZeroFacets,finitePagination:!!n.finitePagination})}(n,o,u),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.getParams()}(i),void 0!==u?[3,2]:[4,T(h,i)];case 1:u=r.sent(),i.defaultFacetDistribution=u,r.label=2;case 2:return[4,h.searchResponse(i,a)];case 3:return s=r.sent(),[2,P(s,i)];case 4:throw c=r.sent(),console.error(c),new Error(c);case 5: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()]}}))}))}}}; | ||
"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}function c(t,e){return{searchResponse:function(i,a){return n(this,void 0,void 0,(function(){var n,o,s,c,l,h,f,d;return r(this,(function(r){switch(r.label){case 0:return n=i.placeholderSearch,o=i.query,s=i.pagination,c=i.finitePagination?{}:s,l=e.formatKey([a,i.indexUid,i.query,c]),(h=e.getEntry(l))?[2,h]:(f=u(i,a),[4,t.index(i.indexUid).search(i.query,a)]);case 1:return(d=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}(f,d.facetDistribution),n||o||(d.hits=[]),e.setEntry(l,d),[2,d]}}))}))}}}function l(t){return 180*t/Math.PI}function h(t){return t*Math.PI/180}function f(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],f=s[2],d=s[3],g=[parseFloat(u),parseFloat(c),parseFloat(f),parseFloat(d)],p=g[0],v=g[1],y=g[2],b=g[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}(p,v,y,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),f=Math.sqrt(s*s+u*u),d=Math.atan2(u,s),g=Math.atan2(c,f);return e<r||e>r&&e>Math.PI&&r<-Math.PI?(g+=Math.PI,d+=Math.PI):(g=l(g),d=l(d)),Math.abs(s)<Math.pow(10,-9)&&Math.abs(u)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(g=0,d=0),"".concat(g,",").concat(d)}(p,v,y,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 d(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 p(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}))}(d(n||[]),d(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,h=t.highlightPostTag,d=t.placeholderSearch,g=t.query,v=t.finitePagination,y=t.sort,b=t.pagination,m=t.matchingStrategy;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=p(o,s,u);t.length&&(e.filter=t)},addAttributesToHighlight:function(){e.attributesToHighlight=c||["*"]},addPreTag:function(){e.highlightPreTag=l||"__ais-highlight__"},addPostTag:function(){e.highlightPostTag=h||"__/ais-highlight__"},addPagination:function(){if(!d&&""===g||0===b.paginationTotalHits)e.limit=0;else if(v)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==y?void 0:y.length)&&(e.sort=[y])},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=f(n);(null==r?void 0:r.filter)&&(e.filter?e.filter.unshift(r.filter):e.filter=[r.filter])},addMatchingStrategy:function(){m&&(e.matchingStrategy=m)}}}function y(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(e=t)||Array.isArray(e)||null===e?{value:y(t)}:Object.keys(t).reduce((function(e,n){return e[n]=b(t[n]),e}),{});var e}function m(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=b(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 P(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=m(t.hits,n,o),c=t.estimatedTotalHits,l=t.processingTimeMs,h=t.query,f=o.hitsPerPage,d=o.page;return{results:[e({index:n.indexUid,hitsPerPage:f,page:d,facets:a,nbPages:s,nbHits:c,processingTimeMS:l,query:h,hits:u,params:"",exhaustiveNbHits:!1},{})]}}function M(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={}}}}function T(t,i){return n(this,void 0,void 0,(function(){var n,a;return r(this,(function(r){switch(r.label){case 0:return n=e(e({},i),{placeholderSearch:!0,pagination:e(e({},i.pagination),{paginationTotalHits:0}),query:""}),(a=v(n)).addFacets(),a.addPagination(),[4,t.searchResponse(n,a.getParams())];case 1:return[2,r.sent().facetDistribution||{}]}}))}))}var w;exports.MatchingStrategies=void 0,(w=exports.MatchingStrategies||(exports.MatchingStrategies={})).ALL="all",w.LAST="last",exports.instantMeiliSearch=function(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var s,u=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.9.0",")");return t.concat(e)}(o.clientAgents),l=new t.MeiliSearch({host:i,apiKey:a,clientAgents:u}),h=M(),f=c(l,h);return{clearCache:function(){return h.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,u,c;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),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})}(n,o,s),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.addMatchingStrategy(),e.getParams()}(i),void 0!==s?[3,2]:[4,T(f,i)];case 1:s=r.sent(),i.defaultFacetDistribution=s,r.label=2;case 2:return[4,f.searchResponse(i,a)];case 3:return u=r.sent(),[2,P(u,i)];case 4:throw c=r.sent(),console.error(c),new Error(c);case 5: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 |
@@ -521,3 +521,3 @@ import { MeiliSearch } from 'meilisearch'; | ||
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; | ||
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, matchingStrategy = searchContext.matchingStrategy; | ||
return { | ||
@@ -610,2 +610,7 @@ getParams: function () { | ||
} | ||
}, | ||
addMatchingStrategy: function () { | ||
if (matchingStrategy) { | ||
meiliSearchParams.matchingStrategy = matchingStrategy; | ||
} | ||
} | ||
@@ -634,2 +639,3 @@ }; | ||
meilisearchParams.addGeoSearchRules(); | ||
meilisearchParams.addMatchingStrategy(); | ||
return meilisearchParams.getParams(); | ||
@@ -883,3 +889,3 @@ } | ||
var PACKAGE_VERSION = '0.8.2'; | ||
var PACKAGE_VERSION = '0.9.0'; | ||
@@ -967,2 +973,8 @@ var constructClientAgents = function (clientAgents) { | ||
export { instantMeiliSearch }; | ||
var MatchingStrategies; | ||
(function (MatchingStrategies) { | ||
MatchingStrategies["ALL"] = "all"; | ||
MatchingStrategies["LAST"] = "last"; | ||
})(MatchingStrategies || (MatchingStrategies = {})); | ||
export { MatchingStrategies, instantMeiliSearch }; |
@@ -1,2 +0,2 @@ | ||
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{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,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 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,!0),[o],!1),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}function c(t,n){return{searchResponse:function(i,a){return e(this,void 0,void 0,(function(){var e,o,u,c,l,f,h,d;return r(this,(function(r){switch(r.label){case 0:return e=i.placeholderSearch,o=i.query,u=i.pagination,c=i.finitePagination?{}:u,l=n.formatKey([a,i.indexUid,i.query,c]),(f=n.getEntry(l))?[2,f]:(h=s(i,a),[4,t.index(i.indexUid).search(i.query,a)]);case 1:return(d=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}(h,d.facetDistribution),e||o||(d.hits=[]),n.setEntry(l,d),[2,d]}}))}))}}}function l(t){return 180*t/Math.PI}function f(t){return t*Math.PI/180}function h(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],h=u[2],d=u[3],p=[parseFloat(s),parseFloat(c),parseFloat(h),parseFloat(d)],g=p[0],v=p[1],y=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,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}(g,v,y,b)/2,n=function(t,n,e,r){t=f(t),n=f(n);var i=Math.cos(t)*Math.cos(n),a=Math.cos(t)*Math.sin(n),o=Math.sin(t);e=f(e),r=f(r);var u=i+Math.cos(e)*Math.cos(r),s=a+Math.cos(e)*Math.sin(r),c=o+Math.sin(e),h=Math.sqrt(u*u+s*s),d=Math.atan2(s,u),p=Math.atan2(c,h);return n<r||n>r&&n>Math.PI&&r<-Math.PI?(p+=Math.PI,d+=Math.PI):(p=l(p),d=l(d)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(p=0,d=0),"".concat(p,",").concat(d)}(g,v,y,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 d(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 p(t){return""===t?[]:"string"==typeof t?[t]:t}function g(t,n,e){return function(t,n,e){var r=e.trim(),a=p(t),o=p(n);return i(i(i([],a,!0),o,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(d(e||[]),d(n||[]),t||"")}function v(t){var n={},e=t.facets,r=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.filters,u=t.numericFilters,s=t.facetFilters,c=t.attributesToHighlight,l=t.highlightPreTag,f=t.highlightPostTag,d=t.placeholderSearch,p=t.query,v=t.finitePagination,y=t.sort,b=t.pagination;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=g(o,u,s);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(!d&&""===p||0===b.paginationTotalHits)n.limit=0;else if(v)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==y?void 0:y.length)&&(n.sort=[y])},addGeoSearchRules:function(){var e=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),r=h(e);(null==r?void 0:r.filter)&&(n.filter?n.filter.unshift(r.filter):n.filter=[r.filter])}}}function y(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:y(t)}:Object.keys(t).reduce((function(n,e){return n[e]=b(t[e]),n}),{});var n}function m(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=b(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 P(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=m(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:u,nbHits:c,processingTimeMS:l,query:f,hits:s,params:"",exhaustiveNbHits:!1},{})]}}function M(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 T(t,i){return e(this,void 0,void 0,(function(){var e,a;return r(this,(function(r){switch(r.label){case 0:return e=n(n({},i),{placeholderSearch:!0,pagination:n(n({},i.pagination),{paginationTotalHits:0}),query:""}),(a=v(e)).addFacets(),a.addPagination(),[4,t.searchResponse(e,a.getParams())];case 1:return[2,r.sent().facetDistribution||{}]}}))}))}function w(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u,s=function(t){void 0===t&&(t=[]);var n="Meilisearch instant-meilisearch (v".concat("0.8.2",")");return t.concat(n)}(o.clientAgents),l=new t({host:i,apiKey:a,clientAgents:s}),f=M(),h=c(l,f);return{clearCache:function(){return f.clearCache()},search:function(t){return e(this,void 0,void 0,(function(){var e,i,a,s,c;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),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,u),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.getParams()}(i),void 0!==u?[3,2]:[4,T(h,i)];case 1:u=r.sent(),i.defaultFacetDistribution=u,r.label=2;case 2:return[4,h.searchResponse(i,a)];case 3:return s=r.sent(),[2,P(s,i)];case 4:throw c=r.sent(),console.error(c),new Error(c);case 5: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}; | ||
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{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,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 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,!0),[o],!1),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}function c(t,n){return{searchResponse:function(i,a){return e(this,void 0,void 0,(function(){var e,o,u,c,l,f,h,d;return r(this,(function(r){switch(r.label){case 0:return e=i.placeholderSearch,o=i.query,u=i.pagination,c=i.finitePagination?{}:u,l=n.formatKey([a,i.indexUid,i.query,c]),(f=n.getEntry(l))?[2,f]:(h=s(i,a),[4,t.index(i.indexUid).search(i.query,a)]);case 1:return(d=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}(h,d.facetDistribution),e||o||(d.hits=[]),n.setEntry(l,d),[2,d]}}))}))}}}function l(t){return 180*t/Math.PI}function f(t){return t*Math.PI/180}function h(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],h=u[2],d=u[3],g=[parseFloat(s),parseFloat(c),parseFloat(h),parseFloat(d)],p=g[0],v=g[1],y=g[2],b=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}(p,v,y,b)/2,n=function(t,n,e,r){t=f(t),n=f(n);var i=Math.cos(t)*Math.cos(n),a=Math.cos(t)*Math.sin(n),o=Math.sin(t);e=f(e),r=f(r);var u=i+Math.cos(e)*Math.cos(r),s=a+Math.cos(e)*Math.sin(r),c=o+Math.sin(e),h=Math.sqrt(u*u+s*s),d=Math.atan2(s,u),g=Math.atan2(c,h);return n<r||n>r&&n>Math.PI&&r<-Math.PI?(g+=Math.PI,d+=Math.PI):(g=l(g),d=l(d)),Math.abs(u)<Math.pow(10,-9)&&Math.abs(s)<Math.pow(10,-9)&&Math.abs(c)<Math.pow(10,-9)&&(g=0,d=0),"".concat(g,",").concat(d)}(p,v,y,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 d(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 p(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}))}(d(e||[]),d(n||[]),t||"")}function v(t){var n={},e=t.facets,r=t.attributesToSnippet,i=t.snippetEllipsisText,a=t.attributesToRetrieve,o=t.filters,u=t.numericFilters,s=t.facetFilters,c=t.attributesToHighlight,l=t.highlightPreTag,f=t.highlightPostTag,d=t.placeholderSearch,g=t.query,v=t.finitePagination,y=t.sort,b=t.pagination,m=t.matchingStrategy;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=p(o,u,s);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(!d&&""===g||0===b.paginationTotalHits)n.limit=0;else if(v)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==y?void 0:y.length)&&(n.sort=[y])},addGeoSearchRules:function(){var e=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),r=h(e);(null==r?void 0:r.filter)&&(n.filter?n.filter.unshift(r.filter):n.filter=[r.filter])},addMatchingStrategy:function(){m&&(n.matchingStrategy=m)}}}function y(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:y(t)}:Object.keys(t).reduce((function(n,e){return n[e]=b(t[e]),n}),{});var n}function m(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=b(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 P(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=m(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:u,nbHits:c,processingTimeMS:l,query:f,hits:s,params:"",exhaustiveNbHits:!1},{})]}}function M(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 T(t,i){return e(this,void 0,void 0,(function(){var e,a;return r(this,(function(r){switch(r.label){case 0:return e=n(n({},i),{placeholderSearch:!0,pagination:n(n({},i.pagination),{paginationTotalHits:0}),query:""}),(a=v(e)).addFacets(),a.addPagination(),[4,t.searchResponse(e,a.getParams())];case 1:return[2,r.sent().facetDistribution||{}]}}))}))}var w;function A(i,a,o){void 0===a&&(a=""),void 0===o&&(o={});var u,s=function(t){void 0===t&&(t=[]);var n="Meilisearch instant-meilisearch (v".concat("0.9.0",")");return t.concat(n)}(o.clientAgents),l=new t({host:i,apiKey:a,clientAgents:s}),f=M(),h=c(l,f);return{clearCache:function(){return f.clearCache()},search:function(t){return e(this,void 0,void 0,(function(){var e,i,a,s,c;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),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,u),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.addMatchingStrategy(),n.getParams()}(i),void 0!==u?[3,2]:[4,T(h,i)];case 1:u=r.sent(),i.defaultFacetDistribution=u,r.label=2;case 2:return[4,h.searchResponse(i,a)];case 3:return s=r.sent(),[2,P(s,i)];case 4:throw c=r.sent(),console.error(c),new Error(c);case 5: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()]}}))}))}}}!function(t){t.ALL="all",t.LAST="last"}(w||(w={}));export{w as MatchingStrategies,A as instantMeiliSearch}; | ||
//# sourceMappingURL=instant-meilisearch.esm.min.js.map |
@@ -14,3 +14,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";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){ | ||
***************************************************************************** */ | ||
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";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}function d(t,e){return{searchResponse:function(i,o){return n(this,void 0,void 0,(function(){var n,s,a,u,c,h,d,f;return r(this,(function(r){switch(r.label){case 0:return n=i.placeholderSearch,s=i.query,a=i.pagination,u=i.finitePagination?{}:a,c=e.formatKey([o,i.indexUid,i.query,u]),(h=e.getEntry(c))?[2,h]:(d=l(i,o),[4,t.index(i.indexUid).search(i.query,o)]);case 1:return(f=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}(d,f.facetDistribution),n||s||(f.hits=[]),e.setEntry(c,f),[2,f]}}))}))}}}function f(t){return 180*t/Math.PI}function p(t){return t*Math.PI/180}function v(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)],v=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}(v,y,b,g)/2,e=function(t,e,n,r){t=p(t),e=p(e);var i=Math.cos(t)*Math.cos(e),o=Math.cos(t)*Math.sin(e),s=Math.sin(t);n=p(n),r=p(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=f(d),l=f(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)}(v,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 y(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 b(t){return""===t?[]:"string"==typeof t?[t]:t}function g(t,e,n){return function(t,e,n){var r=n.trim(),o=b(t),s=b(e);return i(i(i([],o,!0),s,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(y(n||[]),y(e||[]),t||"")}function w(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,y=t.sort,b=t.pagination;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=g(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==y?void 0:y.length)&&(e.sort=[y])},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=v(n);(null==r?void 0:r.filter)&&(e.filter?e.filter.unshift(r.filter):e.filter=[r.filter])}}}function m(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:m(t)}:Object.keys(t).reduce((function(e,n){return e[n]=T(t[n]),e}),{});var e}function x(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=T(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 R(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=x(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 A(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={}}}}function P(t,i){return n(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return n=e(e({},i),{placeholderSearch:!0,pagination:e(e({},i.pagination),{paginationTotalHits:0}),query:""}),(o=w(n)).addFacets(),o.addPagination(),[4,t.searchResponse(n,o.getParams())];case 1:return[2,r.sent().facetDistribution||{}]}}))}))}t.instantMeiliSearch=function(t,i,o){void 0===i&&(i=""),void 0===o&&(o={});var s,u=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.8.2",")");return t.concat(e)}(o.clientAgents),c=new a.MeiliSearch({host:t,apiKey:i,clientAgents:u}),h=A(),l=d(c,h);return{clearCache:function(){return h.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,u,c;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),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})}(n,o,s),a=function(t){var e=w(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.getParams()}(i),void 0!==s?[3,2]:[4,P(l,i)];case 1:s=r.sent(),i.defaultFacetDistribution=s,r.label=2;case 2:return[4,l.searchResponse(i,a)];case 3:return u=r.sent(),[2,R(u,i)];case 4:throw c=r.sent(),console.error(c),new Error(c);case 5: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.28.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}function d(t,e){return{searchResponse:function(i,o){return n(this,void 0,void 0,(function(){var n,s,a,u,c,h,d,f;return r(this,(function(r){switch(r.label){case 0:return n=i.placeholderSearch,s=i.query,a=i.pagination,u=i.finitePagination?{}:a,c=e.formatKey([o,i.indexUid,i.query,u]),(h=e.getEntry(c))?[2,h]:(d=l(i,o),[4,t.index(i.indexUid).search(i.query,o)]);case 1:return(f=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}(d,f.facetDistribution),n||s||(f.hits=[]),e.setEntry(c,f),[2,f]}}))}))}}}function f(t){return 180*t/Math.PI}function p(t){return t*Math.PI/180}function v(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)],v=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}(v,y,b,g)/2,e=function(t,e,n,r){t=p(t),e=p(e);var i=Math.cos(t)*Math.cos(e),o=Math.cos(t)*Math.sin(e),s=Math.sin(t);n=p(n),r=p(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=f(d),l=f(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)}(v,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 y(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 b(t){return""===t?[]:"string"==typeof t?[t]:t}function g(t,e,n){return function(t,e,n){var r=n.trim(),o=b(t),s=b(e);return i(i(i([],o,!0),s,!0),[r],!1).filter((function(t){return Array.isArray(t)?t.length:t}))}(y(n||[]),y(e||[]),t||"")}function w(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,y=t.sort,b=t.pagination,w=t.matchingStrategy;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=g(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==y?void 0:y.length)&&(e.sort=[y])},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=v(n);(null==r?void 0:r.filter)&&(e.filter?e.filter.unshift(r.filter):e.filter=[r.filter])},addMatchingStrategy:function(){w&&(e.matchingStrategy=w)}}}function m(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:m(t)}:Object.keys(t).reduce((function(e,n){return e[n]=T(t[n]),e}),{});var e}function x(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=T(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 R(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=x(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 A(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={}}}}function P(t,i){return n(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return n=e(e({},i),{placeholderSearch:!0,pagination:e(e({},i.pagination),{paginationTotalHits:0}),query:""}),(o=w(n)).addFacets(),o.addPagination(),[4,t.searchResponse(n,o.getParams())];case 1:return[2,r.sent().facetDistribution||{}]}}))}))}var M;t.MatchingStrategies=void 0,(M=t.MatchingStrategies||(t.MatchingStrategies={})).ALL="all",M.LAST="last",t.instantMeiliSearch=function(t,i,o){void 0===i&&(i=""),void 0===o&&(o={});var s,u=function(t){void 0===t&&(t=[]);var e="Meilisearch instant-meilisearch (v".concat("0.9.0",")");return t.concat(e)}(o.clientAgents),c=new a.MeiliSearch({host:t,apiKey:i,clientAgents:u}),h=A(),l=d(c,h);return{clearCache:function(){return h.clearCache()},search:function(t){return n(this,void 0,void 0,(function(){var n,i,a,u,c;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),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})}(n,o,s),a=function(t){var e=w(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.addMatchingStrategy(),e.getParams()}(i),void 0!==s?[3,2]:[4,P(l,i)];case 1:s=r.sent(),i.defaultFacetDistribution=s,r.label=2;case 2:return[4,l.searchResponse(i,a)];case 3:return u=r.sent(),[2,R(u,i)];case 4:throw c=r.sent(),console.error(c),new Error(c);case 5: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 |
@@ -23,2 +23,3 @@ import type { MeiliSearchParams, SearchContext } from '../../types'; | ||
addGeoSearchRules(): void; | ||
addMatchingStrategy(): void; | ||
}; | ||
@@ -25,0 +26,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
// Type definitions for @meilisearch/instant-meilisearch 0.8.2 | ||
// Type definitions for @meilisearch/instant-meilisearch 0.9.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.2"; | ||
export declare const PACKAGE_VERSION = "0.9.0"; | ||
//# sourceMappingURL=package-version.d.ts.map |
@@ -15,2 +15,6 @@ import type { SearchResponse as MeiliSearchResponse, FacetDistribution } from 'meilisearch'; | ||
}; | ||
export declare const enum MatchingStrategies { | ||
ALL = "all", | ||
LAST = "last" | ||
} | ||
export declare type InstantMeiliSearchOptions = { | ||
@@ -23,2 +27,3 @@ paginationTotalHits?: number; | ||
clientAgents?: string[]; | ||
matchingStrategy?: MatchingStrategies; | ||
}; | ||
@@ -62,2 +67,3 @@ export declare type SearchCacheInterface = { | ||
primaryKey?: string; | ||
matchingStrategy?: MatchingStrategies; | ||
}; | ||
@@ -64,0 +70,0 @@ export declare type InstantMeiliSearchInstance = SearchClient & { |
{ | ||
"name": "@meilisearch/instant-meilisearch", | ||
"version": "0.8.2", | ||
"version": "0.9.0", | ||
"private": false, | ||
@@ -60,3 +60,3 @@ "description": "The search client to use Meilisearch with InstantSearch.", | ||
"dependencies": { | ||
"meilisearch": "^0.27.0" | ||
"meilisearch": "^0.28.0" | ||
}, | ||
@@ -66,3 +66,3 @@ "devDependencies": { | ||
"@babel/core": "^7.18.13", | ||
"@babel/preset-env": "^7.18.10", | ||
"@babel/preset-env": "^7.19.3", | ||
"@rollup/plugin-commonjs": "^17.1.0", | ||
@@ -69,0 +69,0 @@ "@rollup/plugin-node-resolve": "^11.2.0", |
@@ -86,2 +86,3 @@ <p align="center"> | ||
- [`keepZeroFacets`](#keep-zero-facets): Show the facets value even when they have 0 matches (default `false`). | ||
- [`matchingStrategy`](#matching-strategy): Determine the search strategy on words matching (default `last`). | ||
@@ -174,2 +175,16 @@ The options are added as the third parameter of the `instantMeilisearch` function. | ||
### Matching strategy | ||
`matchingStrategy` gives you the possibility to choose how Meilisearch should handle the presence of multiple query words, see [documentation](https://docs.meilisearch.com/reference/api/search.html#matching-strategy). | ||
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 `all`, where both `hello` and `world` **must** be present in a document for it to be returned. | ||
```js | ||
{ | ||
matchingStrategy: 'all' // default last | ||
} | ||
``` | ||
## 🪡 Example with InstantSearch | ||
@@ -258,3 +273,3 @@ | ||
This package only guarantees the compatibility with the [version v0.28.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0). | ||
This package only guarantees the compatibility with the [version v0.29.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.29.0). | ||
@@ -261,0 +276,0 @@ **Node / NPM versions**: |
import { adaptSearchParams } from '../search-params-adapter' | ||
import { MatchingStrategies } from '../../../types' | ||
@@ -7,2 +8,3 @@ const DEFAULT_CONTEXT = { | ||
defaultFacetDistribution: {}, | ||
finitePagination: false, | ||
} | ||
@@ -14,3 +16,2 @@ | ||
...DEFAULT_CONTEXT, | ||
finitePagination: false, | ||
}) | ||
@@ -27,3 +28,2 @@ | ||
sort: 'id < 1', | ||
finitePagination: false, | ||
}) | ||
@@ -39,2 +39,11 @@ | ||
}) | ||
test('adapting a searchContext with matching strategy', () => { | ||
const searchParams = adaptSearchParams({ | ||
...DEFAULT_CONTEXT, | ||
matchingStrategy: MatchingStrategies.ALL, | ||
}) | ||
expect(searchParams.matchingStrategy).toEqual('all') | ||
}) | ||
}) | ||
@@ -49,3 +58,2 @@ | ||
sort: 'id < 1', | ||
finitePagination: false, | ||
}) | ||
@@ -68,3 +76,2 @@ | ||
insideBoundingBox: '0,0,0,0', | ||
finitePagination: false, | ||
}) | ||
@@ -86,3 +93,2 @@ | ||
sort: 'id < 1', | ||
finitePagination: false, | ||
}) | ||
@@ -100,3 +106,2 @@ | ||
insideBoundingBox: '0,0,0,0', | ||
finitePagination: false, | ||
}) | ||
@@ -143,3 +148,2 @@ | ||
...DEFAULT_CONTEXT, | ||
finitePagination: false, | ||
}) | ||
@@ -154,3 +158,2 @@ | ||
pagination: { paginationTotalHits: 20, page: 1, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
}) | ||
@@ -165,3 +168,2 @@ | ||
pagination: { paginationTotalHits: 20, page: 40, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
}) | ||
@@ -176,3 +178,2 @@ | ||
pagination: { paginationTotalHits: 4, page: 0, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
}) | ||
@@ -188,3 +189,2 @@ | ||
pagination: { paginationTotalHits: 4, page: 0, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
placeholderSearch: false, | ||
@@ -201,3 +201,2 @@ }) | ||
pagination: { paginationTotalHits: 200, page: 0, hitsPerPage: 6 }, | ||
finitePagination: false, | ||
placeholderSearch: true, | ||
@@ -204,0 +203,0 @@ }) |
@@ -35,2 +35,3 @@ import type { MeiliSearchParams, SearchContext } from '../../types' | ||
pagination, | ||
matchingStrategy, | ||
} = searchContext | ||
@@ -123,2 +124,7 @@ | ||
}, | ||
addMatchingStrategy() { | ||
if (matchingStrategy) { | ||
meiliSearchParams.matchingStrategy = matchingStrategy | ||
} | ||
}, | ||
} | ||
@@ -149,4 +155,5 @@ } | ||
meilisearchParams.addGeoSearchRules() | ||
meilisearchParams.addMatchingStrategy() | ||
return meilisearchParams.getParams() | ||
} |
@@ -6,2 +6,3 @@ import { | ||
FacetDistribution, | ||
MatchingStrategies, | ||
} from '../types' | ||
@@ -8,0 +9,0 @@ |
@@ -1,1 +0,1 @@ | ||
export const PACKAGE_VERSION = '0.8.2' | ||
export const PACKAGE_VERSION = '0.9.0' |
@@ -30,2 +30,7 @@ import type { | ||
export const enum MatchingStrategies { | ||
ALL = 'all', | ||
LAST = 'last', | ||
} | ||
export type InstantMeiliSearchOptions = { | ||
@@ -38,2 +43,3 @@ paginationTotalHits?: number | ||
clientAgents?: string[] | ||
matchingStrategy?: MatchingStrategies | ||
} | ||
@@ -84,2 +90,3 @@ | ||
primaryKey?: string | ||
matchingStrategy?: MatchingStrategies | ||
} | ||
@@ -86,0 +93,0 @@ |
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
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
624429
8769
1092
+ Addedmeilisearch@0.28.0(transitive)
- Removedmeilisearch@0.27.0(transitive)
Updatedmeilisearch@^0.28.0