typesense-instantsearch-adapter 2.7.1-3 → 2.7.1-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/typesense-instantsearch-adapter.js +16 -3
- package/dist/typesense-instantsearch-adapter.js.map +1 -1
- package/dist/typesense-instantsearch-adapter.min.js +1 -1
- package/dist/typesense-instantsearch-adapter.min.js.map +1 -1
- package/index.d.ts +1 -0
- package/lib/Configuration.js +3 -1
- package/lib/Configuration.js.map +1 -1
- package/lib/SearchResponseAdapter.js +13 -2
- package/lib/SearchResponseAdapter.js.map +1 -1
- package/package.json +1 -1
- package/src/Configuration.js +1 -0
- package/src/SearchResponseAdapter.js +14 -2
|
@@ -2216,7 +2216,8 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
2216
2216
|
_options$geoLocationF,
|
|
2217
2217
|
_options$facetableFie,
|
|
2218
2218
|
_options$collectionSp,
|
|
2219
|
-
_this = this
|
|
2219
|
+
_this = this,
|
|
2220
|
+
_options$flattenGroup;
|
|
2220
2221
|
|
|
2221
2222
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2222
2223
|
|
|
@@ -2253,6 +2254,7 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
2253
2254
|
});
|
|
2254
2255
|
});
|
|
2255
2256
|
this.renderingContent = options.renderingContent;
|
|
2257
|
+
this.flattenGroupedHits = (_options$flattenGroup = options.flattenGroupedHits) !== null && _options$flattenGroup !== void 0 ? _options$flattenGroup : true;
|
|
2256
2258
|
}
|
|
2257
2259
|
|
|
2258
2260
|
(0,_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__["default"])(Configuration, [{
|
|
@@ -2951,9 +2953,20 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
2951
2953
|
return adaptedHits;
|
|
2952
2954
|
}); // adaptedResult is now in the form of [[{}, {}], [{}, {}], ...]
|
|
2953
2955
|
// where each element in the outermost array corresponds to a group.
|
|
2954
|
-
// We now flatten it to [{}, {}, {}]
|
|
2955
2956
|
|
|
2956
|
-
|
|
2957
|
+
if (this.configuration.flattenGroupedHits) {
|
|
2958
|
+
// We flatten it to [{}, {}, {}]
|
|
2959
|
+
adaptedResult = adaptedResult.flat();
|
|
2960
|
+
} else {
|
|
2961
|
+
// We flatten it to [{ ..., grouped_hits: [{}, {}] }, {}, {}]
|
|
2962
|
+
// We set the first element in the group as the hit, and then add a new key called grouped_hits with the other hits
|
|
2963
|
+
adaptedResult = adaptedResult.map(function (adaptedGroupedHit) {
|
|
2964
|
+
return _objectSpread(_objectSpread({}, adaptedGroupedHit[0]), {}, {
|
|
2965
|
+
_grouped_hits: adaptedGroupedHit
|
|
2966
|
+
});
|
|
2967
|
+
});
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2957
2970
|
return adaptedResult;
|
|
2958
2971
|
}
|
|
2959
2972
|
}, {
|