@infrab4a/connect 1.0.2-beta.1 → 1.0.2

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.
@@ -3087,7 +3087,9 @@
3087
3087
  return false;
3088
3088
  var converter = fieldOption.to
3089
3089
  ? fieldOption.to
3090
- : function (value) { return (filter.operator === exports.Where.LIKE && value.indexOf('%') < 0 ? "%" + value + "%" : value); };
3090
+ : function (value) { return filter.operator === exports.Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
3091
+ ? "%" + value + "%"
3092
+ : value; };
3091
3093
  return Array.isArray(filter.value) && !fieldOption.fields && [exports.Where.IN, exports.Where.NOTIN].includes(filter.operator)
3092
3094
  ? filter.value.map(function (fieldValue) { return converter(fieldValue); })
3093
3095
  : converter(filter.value);
@@ -3668,10 +3670,9 @@
3668
3670
  type: HasuraGraphQLColumnType.Jsonb,
3669
3671
  from: function (tags, row) { return ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }); },
3670
3672
  bindPersistData: function (value) {
3671
- var _a, _b;
3672
3673
  return {
3673
3674
  brand_condition: value.brand,
3674
- tag_condition: "{\"" + (((_b = (_a = value === null || value === void 0 ? void 0 : value.tags) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '","')) || '') + "\"}",
3675
+ tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
3675
3676
  };
3676
3677
  },
3677
3678
  bindFindFilter: function (sentence) {
@@ -3703,34 +3704,34 @@
3703
3704
  });
3704
3705
  var _a;
3705
3706
  return __awaiter(this, void 0, void 0, function () {
3706
- var _c;
3707
- return __generator(this, function (_d) {
3708
- switch (_d.label) {
3707
+ var _b;
3708
+ return __generator(this, function (_c) {
3709
+ switch (_c.label) {
3709
3710
  case 0:
3710
3711
  if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
3711
3712
  return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
3712
3713
  case 1:
3713
- _c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
3714
+ _b = (_a = (_c.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
3714
3715
  return [3 /*break*/, 3];
3715
3716
  case 2:
3716
- _c = _super.get.call(this, identifiers);
3717
- _d.label = 3;
3718
- case 3: return [2 /*return*/, _c];
3717
+ _b = _super.get.call(this, identifiers);
3718
+ _c.label = 3;
3719
+ case 3: return [2 /*return*/, _b];
3719
3720
  }
3720
3721
  });
3721
3722
  });
3722
3723
  };
3723
3724
  CategoryHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, shop) {
3724
3725
  return __awaiter(this, void 0, void 0, function () {
3725
- var _c, data, count;
3726
- return __generator(this, function (_d) {
3727
- switch (_d.label) {
3726
+ var _b, data, count;
3727
+ return __generator(this, function (_c) {
3728
+ switch (_c.label) {
3728
3729
  case 0:
3729
3730
  if (!slug)
3730
3731
  return [2 /*return*/];
3731
3732
  return [4 /*yield*/, this.find({ filters: { slug: slug, shop: shop, published: true } })];
3732
3733
  case 1:
3733
- _c = _d.sent(), data = _c.data, count = _c.count;
3734
+ _b = _c.sent(), data = _b.data, count = _b.count;
3734
3735
  if (count > 1)
3735
3736
  throw new DuplicatedResultsError('Query returned duplicated values');
3736
3737
  if (!count)
@@ -3743,33 +3744,33 @@
3743
3744
  CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
3744
3745
  if (limit === void 0) { limit = 4; }
3745
3746
  return __awaiter(this, void 0, void 0, function () {
3746
- var _c, categories, count, homeSections;
3747
+ var _b, categories, count, homeSections;
3747
3748
  var _this = this;
3748
- return __generator(this, function (_d) {
3749
- switch (_d.label) {
3749
+ return __generator(this, function (_c) {
3750
+ switch (_c.label) {
3750
3751
  case 0: return [4 /*yield*/, this.find({
3751
3752
  filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
3752
3753
  })];
3753
3754
  case 1:
3754
- _c = _d.sent(), categories = _c.data, count = _c.count;
3755
+ _b = _c.sent(), categories = _b.data, count = _b.count;
3755
3756
  if (!count)
3756
3757
  throw new NotFoundError('Categories not found');
3757
3758
  return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
3758
- var _c;
3759
- return __generator(this, function (_d) {
3760
- switch (_d.label) {
3759
+ var _b;
3760
+ return __generator(this, function (_c) {
3761
+ switch (_c.label) {
3761
3762
  case 0:
3762
- _c = {
3763
+ _b = {
3763
3764
  category: category
3764
3765
  };
3765
3766
  return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
3766
- case 1: return [2 /*return*/, (_c.products = _d.sent(),
3767
- _c)];
3767
+ case 1: return [2 /*return*/, (_b.products = _c.sent(),
3768
+ _b)];
3768
3769
  }
3769
3770
  });
3770
3771
  }); }))];
3771
3772
  case 2:
3772
- homeSections = _d.sent();
3773
+ homeSections = _c.sent();
3773
3774
  return [2 /*return*/, homeSections];
3774
3775
  }
3775
3776
  });
@@ -3778,15 +3779,15 @@
3778
3779
  CategoryHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
3779
3780
  return __awaiter(this, void 0, void 0, function () {
3780
3781
  var products, publishedField, productsData;
3781
- var _c;
3782
- return __generator(this, function (_d) {
3783
- switch (_d.label) {
3782
+ var _b;
3783
+ return __generator(this, function (_c) {
3784
+ switch (_c.label) {
3784
3785
  case 0:
3785
3786
  if (!category.products)
3786
3787
  throw new RequiredArgumentError(['Category products is empty']);
3787
3788
  products = [];
3788
3789
  publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
3789
- return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_c = { id: { operator: exports.Where.IN, value: category.products } }, _c[publishedField] = true, _c), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
3790
+ return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_b = { id: { operator: exports.Where.IN, value: category.products } }, _b[publishedField] = true, _b), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
3790
3791
  'id',
3791
3792
  'name',
3792
3793
  'slug',
@@ -3811,7 +3812,7 @@
3811
3812
  'rate',
3812
3813
  ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
3813
3814
  case 1:
3814
- productsData = (_d.sent()).data;
3815
+ productsData = (_c.sent()).data;
3815
3816
  products.push.apply(products, __spreadArray([], __read(productsData)));
3816
3817
  return [2 /*return*/, products];
3817
3818
  }