@infrab4a/connect 3.2.5 → 3.2.6-beta.1

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.
@@ -3816,33 +3816,55 @@
3816
3816
  CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
3817
3817
  if (limit === void 0) { limit = 4; }
3818
3818
  return __awaiter(this, void 0, void 0, function () {
3819
- var _c, categories, count, homeSections;
3819
+ var categoriesFirestore, categoriesHasura, categories, _c, _d, _e, _f, homeSections;
3820
3820
  var _this = this;
3821
- return __generator(this, function (_d) {
3822
- switch (_d.label) {
3823
- case 0: return [4 /*yield*/, this.find({
3824
- filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
3825
- })];
3821
+ return __generator(this, function (_g) {
3822
+ switch (_g.label) {
3823
+ case 0:
3824
+ if (!categoryIds)
3825
+ return [2 /*return*/, []];
3826
+ categoriesFirestore = categoryIds.filter(function (categoryId) { return Number.isNaN(+categoryId); });
3827
+ categoriesHasura = categoryIds.filter(function (categoryId) { return +categoryId > 0; });
3828
+ categories = [];
3829
+ if (!categoriesFirestore.length) return [3 /*break*/, 2];
3830
+ _d = (_c = categories).push;
3831
+ return [4 /*yield*/, this.find({
3832
+ filters: { firestoreId: { operator: exports.Where.IN, value: categoriesFirestore.filter(Boolean) }, published: true },
3833
+ }).then(function (_c) {
3834
+ var data = _c.data;
3835
+ return data;
3836
+ })];
3826
3837
  case 1:
3827
- _c = _d.sent(), categories = _c.data, count = _c.count;
3828
- if (!count)
3829
- throw new NotFoundError('Categories not found');
3830
- return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
3831
- var _c;
3832
- return __generator(this, function (_d) {
3833
- switch (_d.label) {
3834
- case 0:
3835
- _c = {
3836
- category: category
3837
- };
3838
- return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
3839
- case 1: return [2 /*return*/, (_c.products = _d.sent(),
3840
- _c)];
3841
- }
3842
- });
3843
- }); }))];
3838
+ _d.apply(_c, [_g.sent()]);
3839
+ _g.label = 2;
3844
3840
  case 2:
3845
- homeSections = _d.sent();
3841
+ if (!categoriesHasura.length) return [3 /*break*/, 4];
3842
+ _f = (_e = categories).push;
3843
+ return [4 /*yield*/, this.find({
3844
+ filters: { id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
3845
+ }).then(function (_c) {
3846
+ var data = _c.data;
3847
+ return data;
3848
+ })];
3849
+ case 3:
3850
+ _f.apply(_e, [_g.sent()]);
3851
+ _g.label = 4;
3852
+ case 4: return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
3853
+ var _c;
3854
+ return __generator(this, function (_d) {
3855
+ switch (_d.label) {
3856
+ case 0:
3857
+ _c = {
3858
+ category: category
3859
+ };
3860
+ return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
3861
+ case 1: return [2 /*return*/, (_c.products = _d.sent(),
3862
+ _c)];
3863
+ }
3864
+ });
3865
+ }); }))];
3866
+ case 5:
3867
+ homeSections = _g.sent();
3846
3868
  return [2 /*return*/, homeSections];
3847
3869
  }
3848
3870
  });