@infrab4a/connect 2.0.0-beta.0 → 2.0.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.
@@ -289,7 +289,7 @@
289
289
  Status["CANCELLED"] = "Cancelado";
290
290
  })(exports.Status || (exports.Status = {}));
291
291
 
292
- /*! *****************************************************************************
292
+ /******************************************************************************
293
293
  Copyright (c) Microsoft Corporation.
294
294
 
295
295
  Permission to use, copy, modify, and/or distribute this software for any
@@ -387,7 +387,7 @@
387
387
  function step(op) {
388
388
  if (f)
389
389
  throw new TypeError("Generator is already executing.");
390
- while (_)
390
+ while (g && (g = 0, op[0] && (_ = 0)), _)
391
391
  try {
392
392
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
393
393
  return t;
@@ -451,7 +451,11 @@
451
451
  var __createBinding = Object.create ? (function (o, m, k, k2) {
452
452
  if (k2 === undefined)
453
453
  k2 = k;
454
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
454
+ var desc = Object.getOwnPropertyDescriptor(m, k);
455
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
456
+ desc = { enumerable: true, get: function () { return m[k]; } };
457
+ }
458
+ Object.defineProperty(o, k2, desc);
455
459
  }) : (function (o, m, k, k2) {
456
460
  if (k2 === undefined)
457
461
  k2 = k;
@@ -606,6 +610,11 @@
606
610
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
607
611
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
608
612
  }
613
+ function __classPrivateFieldIn(state, receiver) {
614
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
615
+ throw new TypeError("Cannot use 'in' operator on non-object");
616
+ return typeof state === "function" ? receiver === state : state.has(receiver);
617
+ }
609
618
 
610
619
  var Edition = /** @class */ (function (_super) {
611
620
  __extends(Edition, _super);
@@ -889,7 +898,7 @@
889
898
  Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
890
899
  })(exports.Exclusivities || (exports.Exclusivities = {}));
891
900
 
892
- var COUPON_EXPIRATION = 60 * 60 * 24 * 30;
901
+ var COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
893
902
  var Coupon = /** @class */ (function (_super) {
894
903
  __extends(Coupon, _super);
895
904
  function Coupon() {
@@ -1269,6 +1278,13 @@
1269
1278
  return Category;
1270
1279
  }(BaseModel));
1271
1280
 
1281
+ exports.GenderDestination = void 0;
1282
+ (function (GenderDestination) {
1283
+ GenderDestination["FEMALE"] = "female";
1284
+ GenderDestination["MALE"] = "male";
1285
+ GenderDestination["UNISEX"] = "unisex";
1286
+ })(exports.GenderDestination || (exports.GenderDestination = {}));
1287
+
1272
1288
  exports.Shops = void 0;
1273
1289
  (function (Shops) {
1274
1290
  Shops["MENSMARKET"] = "mensmarket";
@@ -1997,7 +2013,7 @@
1997
2013
  if (filtersKeysWithUnordered.length)
1998
2014
  filtersKeysWithUnordered.forEach(function (filterKey) {
1999
2015
  var _a;
2000
- return (orderBy = Object.assign((_a = {}, _a[filterKey] = 'asc', _a), orderBy));
2016
+ return (orderBy = Object.assign(Object.assign({}, (![exports.Where.EQUALS].includes(filters[filterKey].operator) ? (_a = {}, _a[filterKey] = 'asc', _a) : {})), orderBy));
2001
2017
  });
2002
2018
  Object.keys(orderBy).forEach(function (fieldName) { return (query = query.orderBy(fieldName, orderBy[fieldName])); });
2003
2019
  }
@@ -3082,7 +3098,9 @@
3082
3098
  return false;
3083
3099
  var converter = fieldOption.to
3084
3100
  ? fieldOption.to
3085
- : function (value) { return (filter.operator === exports.Where.LIKE && value.indexOf('%') < 0 ? "%" + value + "%" : value); };
3101
+ : function (value) { return filter.operator === exports.Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
3102
+ ? "%" + value + "%"
3103
+ : value; };
3086
3104
  return Array.isArray(filter.value) && !fieldOption.fields && [exports.Where.IN, exports.Where.NOTIN].includes(filter.operator)
3087
3105
  ? filter.value.map(function (fieldValue) { return converter(fieldValue); })
3088
3106
  : converter(filter.value);
@@ -3663,10 +3681,9 @@
3663
3681
  type: HasuraGraphQLColumnType.Jsonb,
3664
3682
  from: function (tags, row) { return ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }); },
3665
3683
  bindPersistData: function (value) {
3666
- var _a, _b;
3667
3684
  return {
3668
3685
  brand_condition: value.brand,
3669
- 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, '","')) || '') + "\"}",
3686
+ tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
3670
3687
  };
3671
3688
  },
3672
3689
  bindFindFilter: function (sentence) {
@@ -3698,34 +3715,34 @@
3698
3715
  });
3699
3716
  var _a;
3700
3717
  return __awaiter(this, void 0, void 0, function () {
3701
- var _c;
3702
- return __generator(this, function (_d) {
3703
- switch (_d.label) {
3718
+ var _b;
3719
+ return __generator(this, function (_c) {
3720
+ switch (_c.label) {
3704
3721
  case 0:
3705
3722
  if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
3706
3723
  return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
3707
3724
  case 1:
3708
- _c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
3725
+ _b = (_a = (_c.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
3709
3726
  return [3 /*break*/, 3];
3710
3727
  case 2:
3711
- _c = _super.get.call(this, identifiers);
3712
- _d.label = 3;
3713
- case 3: return [2 /*return*/, _c];
3728
+ _b = _super.get.call(this, identifiers);
3729
+ _c.label = 3;
3730
+ case 3: return [2 /*return*/, _b];
3714
3731
  }
3715
3732
  });
3716
3733
  });
3717
3734
  };
3718
3735
  CategoryHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, shop) {
3719
3736
  return __awaiter(this, void 0, void 0, function () {
3720
- var _c, data, count;
3721
- return __generator(this, function (_d) {
3722
- switch (_d.label) {
3737
+ var _b, data, count;
3738
+ return __generator(this, function (_c) {
3739
+ switch (_c.label) {
3723
3740
  case 0:
3724
3741
  if (!slug)
3725
3742
  return [2 /*return*/];
3726
3743
  return [4 /*yield*/, this.find({ filters: { slug: slug, shop: shop, published: true } })];
3727
3744
  case 1:
3728
- _c = _d.sent(), data = _c.data, count = _c.count;
3745
+ _b = _c.sent(), data = _b.data, count = _b.count;
3729
3746
  if (count > 1)
3730
3747
  throw new DuplicatedResultsError('Query returned duplicated values');
3731
3748
  if (!count)
@@ -3738,33 +3755,33 @@
3738
3755
  CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
3739
3756
  if (limit === void 0) { limit = 4; }
3740
3757
  return __awaiter(this, void 0, void 0, function () {
3741
- var _c, categories, count, homeSections;
3758
+ var _b, categories, count, homeSections;
3742
3759
  var _this = this;
3743
- return __generator(this, function (_d) {
3744
- switch (_d.label) {
3760
+ return __generator(this, function (_c) {
3761
+ switch (_c.label) {
3745
3762
  case 0: return [4 /*yield*/, this.find({
3746
3763
  filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
3747
3764
  })];
3748
3765
  case 1:
3749
- _c = _d.sent(), categories = _c.data, count = _c.count;
3766
+ _b = _c.sent(), categories = _b.data, count = _b.count;
3750
3767
  if (!count)
3751
3768
  throw new NotFoundError('Categories not found');
3752
3769
  return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
3753
- var _c;
3754
- return __generator(this, function (_d) {
3755
- switch (_d.label) {
3770
+ var _b;
3771
+ return __generator(this, function (_c) {
3772
+ switch (_c.label) {
3756
3773
  case 0:
3757
- _c = {
3774
+ _b = {
3758
3775
  category: category
3759
3776
  };
3760
3777
  return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
3761
- case 1: return [2 /*return*/, (_c.products = _d.sent(),
3762
- _c)];
3778
+ case 1: return [2 /*return*/, (_b.products = _c.sent(),
3779
+ _b)];
3763
3780
  }
3764
3781
  });
3765
3782
  }); }))];
3766
3783
  case 2:
3767
- homeSections = _d.sent();
3784
+ homeSections = _c.sent();
3768
3785
  return [2 /*return*/, homeSections];
3769
3786
  }
3770
3787
  });
@@ -3773,15 +3790,15 @@
3773
3790
  CategoryHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
3774
3791
  return __awaiter(this, void 0, void 0, function () {
3775
3792
  var products, publishedField, productsData;
3776
- var _c;
3777
- return __generator(this, function (_d) {
3778
- switch (_d.label) {
3793
+ var _b;
3794
+ return __generator(this, function (_c) {
3795
+ switch (_c.label) {
3779
3796
  case 0:
3780
3797
  if (!category.products)
3781
3798
  throw new RequiredArgumentError(['Category products is empty']);
3782
3799
  products = [];
3783
3800
  publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
3784
- 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: [
3801
+ 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: [
3785
3802
  'id',
3786
3803
  'name',
3787
3804
  'slug',
@@ -3806,7 +3823,7 @@
3806
3823
  'rate',
3807
3824
  ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
3808
3825
  case 1:
3809
- productsData = (_d.sent()).data;
3826
+ productsData = (_c.sent()).data;
3810
3827
  products.push.apply(products, __spreadArray([], __read(productsData)));
3811
3828
  return [2 /*return*/, products];
3812
3829
  }
@@ -3896,6 +3913,7 @@
3896
3913
  'type',
3897
3914
  'video',
3898
3915
  'weight',
3916
+ 'gender',
3899
3917
  {
3900
3918
  shopAvailability: {
3901
3919
  columnName: 'shop_availabilities',
@@ -4016,6 +4034,8 @@
4016
4034
  _e.label = 4;
4017
4035
  case 4:
4018
4036
  product = _c;
4037
+ if (product.productId)
4038
+ throw new NotFoundError('Product not found, it is a variant');
4019
4039
  _d = product;
4020
4040
  return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
4021
4041
  case 5:
@@ -4458,7 +4478,7 @@
4458
4478
  });
4459
4479
  var _a;
4460
4480
  return __awaiter(this, void 0, void 0, function () {
4461
- var _c;
4481
+ var variant, _c;
4462
4482
  return __generator(this, function (_d) {
4463
4483
  switch (_d.label) {
4464
4484
  case 0:
@@ -4466,11 +4486,16 @@
4466
4486
  return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
4467
4487
  case 1:
4468
4488
  _c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
4469
- return [3 /*break*/, 3];
4470
- case 2:
4471
- _c = _super.get.call(this, identifiers);
4472
- _d.label = 3;
4473
- case 3: return [2 /*return*/, _c];
4489
+ return [3 /*break*/, 4];
4490
+ case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
4491
+ case 3:
4492
+ _c = _d.sent();
4493
+ _d.label = 4;
4494
+ case 4:
4495
+ variant = _c;
4496
+ if (!variant.productId)
4497
+ throw new NotFoundError("Variant not found, it is a product");
4498
+ return [2 /*return*/, variant];
4474
4499
  }
4475
4500
  });
4476
4501
  });