@infrab4a/connect 3.2.5 → 3.2.6-beta.0

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,16 +3816,41 @@
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)
3838
+ _d.apply(_c, [_g.sent()]);
3839
+ _g.label = 2;
3840
+ case 2:
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:
3853
+ if (!categoriesHasura.length)
3829
3854
  throw new NotFoundError('Categories not found');
3830
3855
  return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
3831
3856
  var _c;
@@ -3841,8 +3866,8 @@
3841
3866
  }
3842
3867
  });
3843
3868
  }); }))];
3844
- case 2:
3845
- homeSections = _d.sent();
3869
+ case 5:
3870
+ homeSections = _g.sent();
3846
3871
  return [2 /*return*/, homeSections];
3847
3872
  }
3848
3873
  });