@infrab4a/connect 3.14.0-beta.5 → 3.14.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.
Files changed (35) hide show
  1. package/bundles/infrab4a-connect.umd.js +263 -145
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/models/category-filter.d.ts +2 -0
  4. package/domain/catalog/repositories/product.repository.d.ts +3 -1
  5. package/domain/generic/repository/find.repository.d.ts +3 -1
  6. package/domain/generic/repository/types/repository-find-result.type.d.ts +8 -1
  7. package/domain/shopping/models/order.d.ts +1 -0
  8. package/domain/shopping/models/shipping-method.d.ts +1 -0
  9. package/esm2015/domain/catalog/models/category-filter.js +9 -2
  10. package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
  11. package/esm2015/domain/generic/repository/find.repository.js +1 -1
  12. package/esm2015/domain/generic/repository/types/repository-find-result.type.js +1 -1
  13. package/esm2015/domain/shopping/models/order.js +1 -1
  14. package/esm2015/domain/shopping/models/shipping-method.js +1 -1
  15. package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +17 -2
  16. package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +5 -2
  17. package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +2 -2
  18. package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +51 -6
  19. package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +1 -1
  20. package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +1 -1
  21. package/esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js +1 -1
  22. package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +33 -2
  23. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +2 -2
  24. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +18 -6
  25. package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +2 -1
  26. package/esm2015/utils/index.js +3 -3
  27. package/fesm2015/infrab4a-connect.js +127 -17
  28. package/fesm2015/infrab4a-connect.js.map +1 -1
  29. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +2 -1
  30. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +12 -1
  31. package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +2 -0
  32. package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +1 -0
  33. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +2 -1
  34. package/package.json +1 -1
  35. package/utils/index.d.ts +2 -2
@@ -1872,13 +1872,17 @@
1872
1872
  }
1873
1873
  Object.defineProperty(CategoryFilter, "identifiersFields", {
1874
1874
  get: function () {
1875
- return ['id', 'filterId', 'categoryId'];
1875
+ return ['id'];
1876
1876
  },
1877
1877
  enumerable: false,
1878
1878
  configurable: true
1879
1879
  });
1880
1880
  return CategoryFilter;
1881
- }(BaseModel));
1881
+ }(BaseModel));
1882
+ __decorate([
1883
+ classTransformer.Type(function () { return Filter; }),
1884
+ __metadata("design:type", Filter)
1885
+ ], CategoryFilter.prototype, "filter", void 0);
1882
1886
 
1883
1887
  exports.GenderDestination = void 0;
1884
1888
  (function (GenderDestination) {
@@ -2639,6 +2643,17 @@
2639
2643
  : bindDate(data[key], key), _a)));
2640
2644
  }, {});
2641
2645
  };
2646
+ var omitByRecursivelyInPlace = function (value, iteratee) {
2647
+ lodash.each(value, function (v, k) {
2648
+ if (iteratee(v, k)) {
2649
+ lodash.unset(value, k);
2650
+ }
2651
+ else if (lodash.isObject(v)) {
2652
+ omitByRecursivelyInPlace(v, iteratee);
2653
+ }
2654
+ });
2655
+ return value;
2656
+ };
2642
2657
  return /** @class */ (function (_super) {
2643
2658
  __extends(class_1, _super);
2644
2659
  function class_1() {
@@ -2650,7 +2665,10 @@
2650
2665
  class_1.prototype.buildModelInstance = function () {
2651
2666
  var _this = this;
2652
2667
  return {
2653
- toFirestore: function (data) { return ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data); },
2668
+ toFirestore: function (data) {
2669
+ var plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
2670
+ return omitByRecursivelyInPlace(plain, function (value) { return value === undefined; });
2671
+ },
2654
2672
  fromFirestore: function (snap) {
2655
2673
  var data = snap.data();
2656
2674
  var bindedData;
@@ -3418,6 +3436,9 @@
3418
3436
  ProductFirestoreRepository.prototype.cleanShoppingCountFromIds = function (ids) {
3419
3437
  return;
3420
3438
  };
3439
+ ProductFirestoreRepository.prototype.findCatalog = function (params) {
3440
+ return this.find(params);
3441
+ };
3421
3442
  return ProductFirestoreRepository;
3422
3443
  }(withCrudFirestore(withHelpers(withFirestore(Base)))));
3423
3444
 
@@ -3817,7 +3838,7 @@
3817
3838
  return { columnName: attributeName.toString(), attributeName: attributeName, fields: fieldOption };
3818
3839
  return Object.assign({ attributeName: attributeName, columnName: attributeName.toString() }, fieldOption);
3819
3840
  };
3820
- AttributeOptionHelper.CheckIsColumnOption = function (fieldValue) { return !!fieldValue.columnName; };
3841
+ AttributeOptionHelper.CheckIsColumnOption = function (fieldValue) { return !!(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.columnName); };
3821
3842
  AttributeOptionHelper.FindColumnOptionFromList = function (columnName, fields) {
3822
3843
  if (fields.includes(columnName))
3823
3844
  return { columnName: columnName, attributeName: columnName };
@@ -4440,22 +4461,42 @@
4440
4461
  function FindHasuraGraphQLMixin() {
4441
4462
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
4442
4463
  _this.bindOrderByAttributes = function (orderBy, fields) { return Object.keys(orderBy).reduce(function (acc, current) {
4443
- var _b;
4444
- return (Object.assign(Object.assign({}, acc), (_b = {}, _b[AttributeOptionHelper.FindByAttribute(current, fields)
4445
- .columnName] = orderBy[current], _b)));
4464
+ var _d;
4465
+ return (Object.assign(Object.assign({}, acc), (_d = {}, _d[AttributeOptionHelper.FindByAttribute(current, fields)
4466
+ .columnName] = orderBy[current], _d)));
4446
4467
  }, {}); };
4468
+ _this.bindAggretageAttributes = function (aggregates, fields) {
4469
+ var _a, _b;
4470
+ return __spreadArray(__spreadArray([], __read((((_a = aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal) === null || _a === void 0 ? void 0 : _a.length)
4471
+ ? [
4472
+ {
4473
+ min: _this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal, fields),
4474
+ },
4475
+ ]
4476
+ : []))), __read((((_b = aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum) === null || _b === void 0 ? void 0 : _b.length)
4477
+ ? [
4478
+ {
4479
+ max: _this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum, fields),
4480
+ },
4481
+ ]
4482
+ : [])));
4483
+ };
4484
+ _this.bindAttributesToColumns = function (attributes, fields) { return attributes.map(function (attr) {
4485
+ var _a;
4486
+ return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr;
4487
+ }); };
4447
4488
  return _this;
4448
4489
  }
4449
4490
  FindHasuraGraphQLMixin.prototype.find = function (params) {
4450
- var _a;
4491
+ var _a, _b, _c;
4451
4492
  return __awaiter(this, void 0, void 0, function () {
4452
- var _b, filters, limits, orderBy, options, enableCount, variablesCount, variables, result, data;
4493
+ var _d, filters, limits, orderBy, options, enableCount, variablesCount, variables, aggregateFields, result, data;
4453
4494
  var _this = this;
4454
- return __generator(this, function (_c) {
4455
- switch (_c.label) {
4495
+ return __generator(this, function (_e) {
4496
+ switch (_e.label) {
4456
4497
  case 0:
4457
4498
  this.logger = DebugHelper.from(this, 'find');
4458
- _b = params || {}, filters = _b.filters, limits = _b.limits, orderBy = _b.orderBy, options = _b.options;
4499
+ _d = params || {}, filters = _d.filters, limits = _d.limits, orderBy = _d.orderBy, options = _d.options;
4459
4500
  enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
4460
4501
  variablesCount = Object.assign(Object.assign({}, (lodash.isNil(orderBy)
4461
4502
  ? {}
@@ -4475,6 +4516,7 @@
4475
4516
  },
4476
4517
  }));
4477
4518
  variables = Object.assign(Object.assign({}, (lodash.isNil(limits) ? {} : limits)), variablesCount);
4519
+ aggregateFields = __spreadArray(__spreadArray([], __read((enableCount ? ['count'] : []))), __read(this.bindAggretageAttributes(params.options, this.fields)));
4478
4520
  return [4 /*yield*/, this.query(__spreadArray([
4479
4521
  {
4480
4522
  operation: this.tableName,
@@ -4488,19 +4530,37 @@
4488
4530
  : this.fields,
4489
4531
  variables: variables,
4490
4532
  }
4491
- ], __read((enableCount
4533
+ ], __read((aggregateFields.length > 0
4492
4534
  ? [
4493
4535
  {
4494
4536
  operation: this.tableName + "_aggregate",
4495
- fields: [{ aggregate: ['count'] }],
4537
+ fields: [
4538
+ {
4539
+ aggregate: aggregateFields,
4540
+ },
4541
+ ],
4496
4542
  variables: variablesCount,
4497
4543
  },
4498
4544
  ]
4499
4545
  : []))))];
4500
4546
  case 1:
4501
- result = _c.sent();
4547
+ result = _e.sent();
4502
4548
  data = result[this.tableName].map(function (row) { return _this.convertDataFromHasura(row); });
4503
- return [2 /*return*/, { data: data, count: enableCount ? result[this.tableName + "_aggregate"].aggregate.count : Infinity }];
4549
+ return [2 /*return*/, Object.assign(Object.assign({ data: data, count: enableCount ? result[this.tableName + "_aggregate"].aggregate.count : Infinity }, (((_b = options === null || options === void 0 ? void 0 : options.minimal) === null || _b === void 0 ? void 0 : _b.length)
4550
+ ? {
4551
+ minimal: options.minimal.reduce(function (minimals, current) {
4552
+ var _a;
4553
+ return (Object.assign(Object.assign({}, minimals), lodash.set(minimals, current, result[_this.tableName + "_aggregate"].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), _this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
4554
+ }, {}),
4555
+ }
4556
+ : {})), (((_c = options === null || options === void 0 ? void 0 : options.maximum) === null || _c === void 0 ? void 0 : _c.length)
4557
+ ? {
4558
+ maximum: options.maximum.reduce(function (maximums, current) {
4559
+ var _a;
4560
+ return (Object.assign(Object.assign({}, maximums), lodash.set(maximums, current, result[_this.tableName + "_aggregate"].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), _this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
4561
+ }, {}),
4562
+ }
4563
+ : {}))];
4504
4564
  }
4505
4565
  });
4506
4566
  });
@@ -4611,7 +4671,38 @@
4611
4671
  model: CategoryFilter,
4612
4672
  endpoint: endpoint,
4613
4673
  authOptions: authOptions,
4614
- fields: ['id', { filterId: { columnName: 'filter_id' } }, { categoryId: { columnName: 'category_id' } }],
4674
+ fields: [
4675
+ 'id',
4676
+ { filterId: { columnName: 'filter_id' } },
4677
+ { categoryId: { columnName: 'category_id' } },
4678
+ {
4679
+ filter: {
4680
+ columnName: 'filter',
4681
+ foreignKeyColumn: { id: 'filterId' },
4682
+ fields: [
4683
+ 'id',
4684
+ 'description',
4685
+ 'slug',
4686
+ 'enabled',
4687
+ { createdAt: { columnName: 'created_at' } },
4688
+ { updatedAt: { columnName: 'updated_at' } },
4689
+ {
4690
+ options: {
4691
+ columnName: 'options',
4692
+ foreignKeyColumn: { filterId: 'id' },
4693
+ fields: [
4694
+ 'id',
4695
+ { filterId: { columnName: 'filter_id' } },
4696
+ 'description',
4697
+ { createdAt: { columnName: 'created_at' } },
4698
+ { updatedAt: { columnName: 'updated_at' } },
4699
+ ],
4700
+ },
4701
+ },
4702
+ ],
4703
+ },
4704
+ },
4705
+ ],
4615
4706
  }) || this;
4616
4707
  }
4617
4708
  CategoryFilterHasuraGraphQLRepository.prototype.deleteByCategoryAndFilter = function (categoryId, filterId) {
@@ -5171,7 +5262,7 @@
5171
5262
  })];
5172
5263
  case 1:
5173
5264
  category_tree = (_c.sent()).category_tree;
5174
- return [2 /*return*/, category_tree.map(function (c) { return Category.toInstance(c); })];
5265
+ return [2 /*return*/, category_tree.map(function (category) { return Category.toInstance(category); })];
5175
5266
  }
5176
5267
  });
5177
5268
  });
@@ -5444,8 +5535,7 @@
5444
5535
  brand: data.brand_description,
5445
5536
  ingredients: data.ingredients,
5446
5537
  }); },
5447
- bindFindFilter: function (sentence) {
5448
- var filters = Object.values(sentence).shift();
5538
+ bindFindFilter: function (filters) {
5449
5539
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
5450
5540
  who_must_use: filters.whoMustUse,
5451
5541
  })), (filters.howToUse && {
@@ -5489,8 +5579,7 @@
5489
5579
  subscriberDiscountPercentage: data.subscriber_discount_percentage,
5490
5580
  subscriberPrice: data.subscriber_price,
5491
5581
  }); },
5492
- bindFindFilter: function (sentence) {
5493
- var filters = Object.values(sentence).shift();
5582
+ bindFindFilter: function (filters) {
5494
5583
  return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
5495
5584
  subscriber_discount_percentage: filters.subscriberDiscountPercentage,
5496
5585
  })), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
@@ -5514,11 +5603,13 @@
5514
5603
  to: function (value) { return (lodash.isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity); },
5515
5604
  },
5516
5605
  },
5606
+ { hasStock: { columnName: 'has_stock' } },
5517
5607
  'slug',
5518
5608
  'type',
5519
5609
  'video',
5520
5610
  'weight',
5521
5611
  'gender',
5612
+ { intGender: { columnName: 'int_gender' } },
5522
5613
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
5523
5614
  { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
5524
5615
  { isKit: { columnName: 'is_kit' } },
@@ -5606,32 +5697,32 @@
5606
5697
  create: { get: function () { return _super_1.prototype.create; } }
5607
5698
  });
5608
5699
  return __awaiter(this, void 0, void 0, function () {
5609
- var metadata, data, product, _c, _d, error_1;
5610
- return __generator(this, function (_e) {
5611
- switch (_e.label) {
5700
+ var metadata, data, product, _p, _q, error_1;
5701
+ return __generator(this, function (_r) {
5702
+ switch (_r.label) {
5612
5703
  case 0:
5613
5704
  metadata = params.metadata, data = __rest(params, ["metadata"]);
5614
5705
  return [4 /*yield*/, _super.create.call(this, lodash.omit(Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }), ['reviews']))];
5615
5706
  case 1:
5616
- product = _e.sent();
5617
- _e.label = 2;
5707
+ product = _r.sent();
5708
+ _r.label = 2;
5618
5709
  case 2:
5619
- _e.trys.push([2, 5, , 7]);
5620
- _c = product;
5621
- _d = data.reviews;
5622
- if (!_d) return [3 /*break*/, 4];
5710
+ _r.trys.push([2, 5, , 7]);
5711
+ _p = product;
5712
+ _q = data.reviews;
5713
+ if (!_q) return [3 /*break*/, 4];
5623
5714
  return [4 /*yield*/, this.updateReviews(+product.id, data)];
5624
5715
  case 3:
5625
- _d = (_e.sent());
5626
- _e.label = 4;
5716
+ _q = (_r.sent());
5717
+ _r.label = 4;
5627
5718
  case 4:
5628
- _c.reviews = _d;
5719
+ _p.reviews = _q;
5629
5720
  return [3 /*break*/, 7];
5630
5721
  case 5:
5631
- error_1 = _e.sent();
5722
+ error_1 = _r.sent();
5632
5723
  return [4 /*yield*/, this.delete({ id: product.id })];
5633
5724
  case 6:
5634
- _e.sent();
5725
+ _r.sent();
5635
5726
  throw error_1;
5636
5727
  case 7: return [2 /*return*/, product];
5637
5728
  }
@@ -5644,32 +5735,32 @@
5644
5735
  });
5645
5736
  var _a;
5646
5737
  return __awaiter(this, void 0, void 0, function () {
5647
- var product, _c, _d, _e;
5648
- return __generator(this, function (_f) {
5649
- switch (_f.label) {
5738
+ var product, _p, _q, _r;
5739
+ return __generator(this, function (_s) {
5740
+ switch (_s.label) {
5650
5741
  case 0:
5651
5742
  if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
5652
5743
  return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })];
5653
5744
  case 1:
5654
- _c = (_a = (_f.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
5745
+ _p = (_a = (_s.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
5655
5746
  return [3 /*break*/, 4];
5656
5747
  case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
5657
5748
  case 3:
5658
- _c = _f.sent();
5659
- _f.label = 4;
5749
+ _p = _s.sent();
5750
+ _s.label = 4;
5660
5751
  case 4:
5661
- product = _c;
5752
+ product = _p;
5662
5753
  if (product.productId)
5663
5754
  throw new NotFoundError('Product not found, it is a variant');
5664
- _d = product;
5665
- _e = product.reviews;
5666
- if (_e) return [3 /*break*/, 6];
5755
+ _q = product;
5756
+ _r = product.reviews;
5757
+ if (_r) return [3 /*break*/, 6];
5667
5758
  return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
5668
5759
  case 5:
5669
- _e = (_f.sent());
5670
- _f.label = 6;
5760
+ _r = (_s.sent());
5761
+ _s.label = 6;
5671
5762
  case 6:
5672
- _d.reviews = _e;
5763
+ _q.reviews = _r;
5673
5764
  return [2 /*return*/, product];
5674
5765
  }
5675
5766
  });
@@ -5679,14 +5770,21 @@
5679
5770
  var _super = Object.create(null, {
5680
5771
  find: { get: function () { return _super_1.prototype.find; } }
5681
5772
  });
5773
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
5682
5774
  return __awaiter(this, void 0, void 0, function () {
5683
- var _a, filters, fields, options, bindFields;
5684
- return __generator(this, function (_c) {
5685
- _a = params || {}, filters = _a.filters, fields = _a.fields, options = __rest(_a, ["filters", "fields"]);
5775
+ var _o, filters, fields, options, bindFields;
5776
+ return __generator(this, function (_p) {
5777
+ _o = params || {}, filters = _o.filters, fields = _o.fields, options = __rest(_o, ["filters", "fields"]);
5686
5778
  bindFields = fields ||
5687
5779
  this.fields
5688
5780
  .map(function (field) { return (typeof field === 'string' ? field : Object.keys(field).shift()); })
5689
5781
  .filter(function (field) { return field !== 'reviews'; });
5782
+ if ((_b = (_a = options.options) === null || _a === void 0 ? void 0 : _a.minimal) === null || _b === void 0 ? void 0 : _b.includes('price'))
5783
+ (_c = options.options) === null || _c === void 0 ? void 0 : _c.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
5784
+ if ((_e = (_d = options.options) === null || _d === void 0 ? void 0 : _d.maximum) === null || _e === void 0 ? void 0 : _e.includes('price'))
5785
+ (_f = options.options) === null || _f === void 0 ? void 0 : _f.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
5786
+ (_h = (_g = options.options) === null || _g === void 0 ? void 0 : _g.minimal) === null || _h === void 0 ? void 0 : _h.splice((_j = options.options) === null || _j === void 0 ? void 0 : _j.minimal.indexOf('price'), 1);
5787
+ (_l = (_k = options.options) === null || _k === void 0 ? void 0 : _k.maximum) === null || _l === void 0 ? void 0 : _l.splice((_m = options.options) === null || _m === void 0 ? void 0 : _m.maximum.indexOf('price'), 1);
5690
5788
  return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }), fields: __spreadArray(__spreadArray([], __read(bindFields)), __read((bindFields.includes('price')
5691
5789
  ? [
5692
5790
  'subscriberPrice',
@@ -5701,8 +5799,8 @@
5701
5799
  var _a;
5702
5800
  return __awaiter(this, void 0, void 0, function () {
5703
5801
  var result, product;
5704
- return __generator(this, function (_c) {
5705
- switch (_c.label) {
5802
+ return __generator(this, function (_p) {
5803
+ switch (_p.label) {
5706
5804
  case 0: return [4 /*yield*/, this.find({
5707
5805
  filters: {
5708
5806
  slug: slug,
@@ -5713,7 +5811,7 @@
5713
5811
  },
5714
5812
  })];
5715
5813
  case 1:
5716
- result = _c.sent();
5814
+ result = _p.sent();
5717
5815
  product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
5718
5816
  RoundProductPricesHelper.roundProductPrices(product);
5719
5817
  return [2 /*return*/, product];
@@ -5726,54 +5824,54 @@
5726
5824
  update: { get: function () { return _super_1.prototype.update; } }
5727
5825
  });
5728
5826
  return __awaiter(this, void 0, void 0, function () {
5729
- var categories, kitProducts, reviews, checkId, rate, metadata, data, plainData, id, product, _c, _d, _e, _f, _g, _h, _j, _k;
5730
- return __generator(this, function (_l) {
5731
- switch (_l.label) {
5827
+ var categories, kitProducts, reviews, checkId, rate, metadata, data, plainData, id, product, _p, _q, _r, _s, _t, _u, _v, _w;
5828
+ return __generator(this, function (_x) {
5829
+ switch (_x.label) {
5732
5830
  case 0:
5733
5831
  categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id, rate = params.rate, metadata = params.metadata, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "rate", "metadata"]);
5734
5832
  plainData = this.paramsToPlain({ id: checkId });
5735
5833
  return [4 /*yield*/, this.getId(plainData.id)];
5736
5834
  case 1:
5737
- id = _l.sent();
5835
+ id = _x.sent();
5738
5836
  return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
5739
5837
  case 2:
5740
- product = _l.sent();
5741
- _c = product;
5742
- _d = categories;
5743
- if (!_d) return [3 /*break*/, 4];
5838
+ product = _x.sent();
5839
+ _p = product;
5840
+ _q = categories;
5841
+ if (!_q) return [3 /*break*/, 4];
5744
5842
  return [4 /*yield*/, this.updateCategories(+id, { categories: categories })];
5745
5843
  case 3:
5746
- _d = (_l.sent());
5747
- _l.label = 4;
5844
+ _q = (_x.sent());
5845
+ _x.label = 4;
5748
5846
  case 4:
5749
- _c.categories = _d;
5750
- _e = product;
5751
- _f = kitProducts;
5752
- if (!_f) return [3 /*break*/, 6];
5847
+ _p.categories = _q;
5848
+ _r = product;
5849
+ _s = kitProducts;
5850
+ if (!_s) return [3 /*break*/, 6];
5753
5851
  return [4 /*yield*/, this.updateKitProducts(+id, { kitProducts: kitProducts })];
5754
5852
  case 5:
5755
- _f = (_l.sent());
5756
- _l.label = 6;
5853
+ _s = (_x.sent());
5854
+ _x.label = 6;
5757
5855
  case 6:
5758
- _e.kitProducts = _f;
5759
- _g = product;
5760
- _h = reviews;
5761
- if (!_h) return [3 /*break*/, 8];
5856
+ _r.kitProducts = _s;
5857
+ _t = product;
5858
+ _u = reviews;
5859
+ if (!_u) return [3 /*break*/, 8];
5762
5860
  return [4 /*yield*/, this.updateReviews(+id, { reviews: reviews })];
5763
5861
  case 7:
5764
- _h = (_l.sent());
5765
- _l.label = 8;
5862
+ _u = (_x.sent());
5863
+ _x.label = 8;
5766
5864
  case 8:
5767
- _g.reviews = _h;
5768
- _j = product;
5769
- _k = metadata;
5770
- if (!_k) return [3 /*break*/, 10];
5865
+ _t.reviews = _u;
5866
+ _v = product;
5867
+ _w = metadata;
5868
+ if (!_w) return [3 /*break*/, 10];
5771
5869
  return [4 /*yield*/, this.updateMetadata(+id, { metadata: metadata })];
5772
5870
  case 9:
5773
- _k = (_l.sent());
5774
- _l.label = 10;
5871
+ _w = (_x.sent());
5872
+ _x.label = 10;
5775
5873
  case 10:
5776
- _j.metadata = _k;
5874
+ _v.metadata = _w;
5777
5875
  return [2 /*return*/, product];
5778
5876
  }
5779
5877
  });
@@ -5782,20 +5880,20 @@
5782
5880
  ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
5783
5881
  return __awaiter(this, void 0, void 0, function () {
5784
5882
  var reviewsExpression, data;
5785
- var _c, _d;
5883
+ var _p, _q;
5786
5884
  var _this = this;
5787
- return __generator(this, function (_e) {
5788
- switch (_e.label) {
5885
+ return __generator(this, function (_r) {
5886
+ switch (_r.label) {
5789
5887
  case 0:
5790
5888
  reviewsExpression = {
5791
5889
  status: status === 'pending'
5792
- ? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
5890
+ ? (_p = {}, _p[HasuraGraphQLWhere.ISNULL] = true, _p) : (_q = {}, _q[HasuraGraphQLWhere.EQUALS] = status === 'approved', _q),
5793
5891
  };
5794
5892
  return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
5795
5893
  where: { value: { reviews: reviewsExpression }, type: 'product_bool_exp', required: true },
5796
5894
  })];
5797
5895
  case 1:
5798
- data = (_e.sent()).product;
5896
+ data = (_r.sent()).product;
5799
5897
  return [2 /*return*/, data.reduce(function (reviews, product) { return __spreadArray(__spreadArray([], __read(reviews)), __read(product.reviews
5800
5898
  .filter(function (review) { return (status === 'pending' && [undefined, null].includes(review.status)) ||
5801
5899
  (status === 'approved' && review.status === true) ||
@@ -5805,12 +5903,19 @@
5805
5903
  });
5806
5904
  });
5807
5905
  };
5808
- ProductHasuraGraphQLRepository.prototype.updateCategories = function (productId, _c) {
5809
- var categories = _c.categories;
5906
+ ProductHasuraGraphQLRepository.prototype.findCatalog = function (params, mainGender) {
5907
+ return __awaiter(this, void 0, void 0, function () {
5908
+ return __generator(this, function (_p) {
5909
+ return [2 /*return*/, this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign({ hasStock: 'desc', intGender: mainGender === 'female' ? 'desc' : 'asc' }, lodash.omit(params.orderBy, ['hasStock', 'intGender'])) }))];
5910
+ });
5911
+ });
5912
+ };
5913
+ ProductHasuraGraphQLRepository.prototype.updateCategories = function (productId, _p) {
5914
+ var categories = _p.categories;
5810
5915
  return __awaiter(this, void 0, void 0, function () {
5811
5916
  var plainData;
5812
- return __generator(this, function (_c) {
5813
- switch (_c.label) {
5917
+ return __generator(this, function (_p) {
5918
+ switch (_p.label) {
5814
5919
  case 0:
5815
5920
  if (!('action' in categories && categories.action === 'remove')) return [3 /*break*/, 2];
5816
5921
  return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
@@ -5821,7 +5926,7 @@
5821
5926
  },
5822
5927
  })];
5823
5928
  case 1:
5824
- _c.sent();
5929
+ _p.sent();
5825
5930
  return [2 /*return*/, []];
5826
5931
  case 2:
5827
5932
  plainData = this.paramsToPlain({ categories: categories });
@@ -5835,7 +5940,7 @@
5835
5940
  },
5836
5941
  })];
5837
5942
  case 3:
5838
- _c.sent();
5943
+ _p.sent();
5839
5944
  return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
5840
5945
  objects: {
5841
5946
  type: '[category_product_insert_input!]',
@@ -5844,18 +5949,18 @@
5844
5949
  },
5845
5950
  })];
5846
5951
  case 4:
5847
- _c.sent();
5952
+ _p.sent();
5848
5953
  return [2 /*return*/, plainData.categories];
5849
5954
  }
5850
5955
  });
5851
5956
  });
5852
5957
  };
5853
- ProductHasuraGraphQLRepository.prototype.updateKitProducts = function (productId, _c) {
5854
- var kitProducts = _c.kitProducts;
5958
+ ProductHasuraGraphQLRepository.prototype.updateKitProducts = function (productId, _p) {
5959
+ var kitProducts = _p.kitProducts;
5855
5960
  return __awaiter(this, void 0, void 0, function () {
5856
5961
  var plainData;
5857
- return __generator(this, function (_c) {
5858
- switch (_c.label) {
5962
+ return __generator(this, function (_p) {
5963
+ switch (_p.label) {
5859
5964
  case 0:
5860
5965
  plainData = this.paramsToPlain({ kitProducts: kitProducts });
5861
5966
  return [4 /*yield*/, this.mutation('delete_product_kit', ['affected_rows'], {
@@ -5866,7 +5971,7 @@
5866
5971
  },
5867
5972
  })];
5868
5973
  case 1:
5869
- _c.sent();
5974
+ _p.sent();
5870
5975
  return [4 /*yield*/, this.mutation('insert_product_kit', ['affected_rows'], {
5871
5976
  objects: {
5872
5977
  type: '[product_kit_insert_input!]',
@@ -5879,55 +5984,55 @@
5879
5984
  },
5880
5985
  })];
5881
5986
  case 2:
5882
- _c.sent();
5987
+ _p.sent();
5883
5988
  return [2 /*return*/, plainData.kitProducts];
5884
5989
  }
5885
5990
  });
5886
5991
  });
5887
5992
  };
5888
- ProductHasuraGraphQLRepository.prototype.updateReviews = function (productId, _c) {
5889
- var reviews = _c.reviews;
5993
+ ProductHasuraGraphQLRepository.prototype.updateReviews = function (productId, _p) {
5994
+ var reviews = _p.reviews;
5890
5995
  return __awaiter(this, void 0, void 0, function () {
5891
5996
  var reviewIds_1, plainData;
5892
5997
  var _this = this;
5893
- return __generator(this, function (_c) {
5894
- switch (_c.label) {
5998
+ return __generator(this, function (_p) {
5999
+ switch (_p.label) {
5895
6000
  case 0:
5896
6001
  if (!reviews)
5897
6002
  return [2 /*return*/, []];
5898
6003
  if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
5899
6004
  return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
5900
6005
  var review;
5901
- return __generator(this, function (_c) {
5902
- switch (_c.label) {
6006
+ return __generator(this, function (_p) {
6007
+ switch (_p.label) {
5903
6008
  case 0: return [4 /*yield*/, this.findReview(reviewData, productId)];
5904
6009
  case 1:
5905
- review = _c.sent();
6010
+ review = _p.sent();
5906
6011
  return [2 /*return*/, review === null || review === void 0 ? void 0 : review.id];
5907
6012
  }
5908
6013
  });
5909
6014
  }); }))];
5910
6015
  case 1:
5911
- reviewIds_1 = _c.sent();
6016
+ reviewIds_1 = _p.sent();
5912
6017
  return [4 /*yield*/, this.mutation('delete_product_review', ['affected_rows'], {
5913
6018
  where: { value: { id: { _in: reviewIds_1.filter(Boolean) } }, type: 'product_review_bool_exp', required: true },
5914
6019
  })];
5915
6020
  case 2:
5916
- _c.sent();
6021
+ _p.sent();
5917
6022
  return [2 /*return*/, reviews.value.map(function (review, index) { return !reviewIds_1[index] && review; }).filter(Boolean)];
5918
6023
  case 3:
5919
6024
  plainData = this.paramsToPlain({ reviews: reviews });
5920
6025
  if (!plainData.reviews || plainData.reviews.length <= 0)
5921
6026
  return [2 /*return*/, []];
5922
6027
  return [2 /*return*/, Promise.all(plainData.reviews.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
5923
- var review, _c, _d;
5924
- return __generator(this, function (_e) {
5925
- switch (_e.label) {
6028
+ var review, _p, _q;
6029
+ return __generator(this, function (_r) {
6030
+ switch (_r.label) {
5926
6031
  case 0: return [4 /*yield*/, this.findReview(reviewData, productId)];
5927
6032
  case 1:
5928
- review = _e.sent();
6033
+ review = _r.sent();
5929
6034
  if (!review.id) return [3 /*break*/, 3];
5930
- _c = this.bindReviewToModel;
6035
+ _p = this.bindReviewToModel;
5931
6036
  return [4 /*yield*/, this.mutation('update_product_review_by_pk', this.reviewsFields, {
5932
6037
  pk_columns: {
5933
6038
  value: { id: review.id },
@@ -5940,9 +6045,9 @@
5940
6045
  required: true,
5941
6046
  },
5942
6047
  })];
5943
- case 2: return [2 /*return*/, _c.apply(this, [(_e.sent()).update_product_review_by_pk])];
6048
+ case 2: return [2 /*return*/, _p.apply(this, [(_r.sent()).update_product_review_by_pk])];
5944
6049
  case 3:
5945
- _d = this.bindReviewToModel;
6050
+ _q = this.bindReviewToModel;
5946
6051
  return [4 /*yield*/, this.mutation('insert_product_review_one', this.reviewsFields, {
5947
6052
  object: {
5948
6053
  value: lodash.omit(Object.assign(Object.assign({}, this.bindReviewToHasura(reviewData)), { product_id: productId }), ['id']),
@@ -5950,7 +6055,7 @@
5950
6055
  required: true,
5951
6056
  },
5952
6057
  })];
5953
- case 4: return [2 /*return*/, _d.apply(this, [(_e.sent()).insert_product_review_one])];
6058
+ case 4: return [2 /*return*/, _q.apply(this, [(_r.sent()).insert_product_review_one])];
5954
6059
  }
5955
6060
  });
5956
6061
  }); }))];
@@ -5958,12 +6063,12 @@
5958
6063
  });
5959
6064
  });
5960
6065
  };
5961
- ProductHasuraGraphQLRepository.prototype.updateMetadata = function (productId, _c) {
5962
- var metadata = _c.metadata;
6066
+ ProductHasuraGraphQLRepository.prototype.updateMetadata = function (productId, _p) {
6067
+ var metadata = _p.metadata;
5963
6068
  return __awaiter(this, void 0, void 0, function () {
5964
6069
  var plainData;
5965
- return __generator(this, function (_c) {
5966
- switch (_c.label) {
6070
+ return __generator(this, function (_p) {
6071
+ switch (_p.label) {
5967
6072
  case 0:
5968
6073
  plainData = this.paramsToPlain({ metadata: metadata });
5969
6074
  if (!plainData.metadata)
@@ -5981,7 +6086,7 @@
5981
6086
  },
5982
6087
  })];
5983
6088
  case 1:
5984
- _c.sent();
6089
+ _p.sent();
5985
6090
  return [2 /*return*/, plainData.metadata];
5986
6091
  }
5987
6092
  });
@@ -5991,14 +6096,14 @@
5991
6096
  var _a, _b;
5992
6097
  return __awaiter(this, void 0, void 0, function () {
5993
6098
  var data;
5994
- return __generator(this, function (_c) {
5995
- switch (_c.label) {
6099
+ return __generator(this, function (_p) {
6100
+ switch (_p.label) {
5996
6101
  case 0:
5997
6102
  if (!Number.isNaN(+id))
5998
6103
  return [2 /*return*/, id];
5999
6104
  return [4 /*yield*/, this.find({ filters: { firestoreId: id }, options: { enableCount: false } })];
6000
6105
  case 1:
6001
- data = (_c.sent()).data;
6106
+ data = (_p.sent()).data;
6002
6107
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
6003
6108
  return [2 /*return*/, (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id];
6004
6109
  throw new NotFoundError("Product with id " + id + " not found");
@@ -6010,8 +6115,8 @@
6010
6115
  return __awaiter(this, void 0, void 0, function () {
6011
6116
  var data;
6012
6117
  var _this = this;
6013
- return __generator(this, function (_c) {
6014
- switch (_c.label) {
6118
+ return __generator(this, function (_p) {
6119
+ switch (_p.label) {
6015
6120
  case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
6016
6121
  where: {
6017
6122
  value: {
@@ -6022,7 +6127,7 @@
6022
6127
  },
6023
6128
  })];
6024
6129
  case 1:
6025
- data = (_c.sent()).product_review;
6130
+ data = (_p.sent()).product_review;
6026
6131
  return [2 /*return*/, data && data.map(function (review) { return _this.bindReviewToModel(review); })];
6027
6132
  }
6028
6133
  });
@@ -6031,22 +6136,22 @@
6031
6136
  ProductHasuraGraphQLRepository.prototype.findReview = function (review, productId) {
6032
6137
  return __awaiter(this, void 0, void 0, function () {
6033
6138
  var loadedReview;
6034
- return __generator(this, function (_c) {
6035
- switch (_c.label) {
6139
+ return __generator(this, function (_p) {
6140
+ switch (_p.label) {
6036
6141
  case 0:
6037
6142
  if (review.id)
6038
6143
  return [2 /*return*/, review];
6039
6144
  if (!review.personId) return [3 /*break*/, 2];
6040
6145
  return [4 /*yield*/, this.getReviewByPersonId(review.personId, productId, review.orderId)];
6041
6146
  case 1:
6042
- loadedReview = _c.sent();
6043
- _c.label = 2;
6147
+ loadedReview = _p.sent();
6148
+ _p.label = 2;
6044
6149
  case 2:
6045
6150
  if (!(!loadedReview && review.author && review.email)) return [3 /*break*/, 4];
6046
6151
  return [4 /*yield*/, this.getReviewByAuthorAndEmail(review.author, review.email, productId, review.orderId)];
6047
6152
  case 3:
6048
- loadedReview = _c.sent();
6049
- _c.label = 4;
6153
+ loadedReview = _p.sent();
6154
+ _p.label = 4;
6050
6155
  case 4: return [2 /*return*/, loadedReview || review];
6051
6156
  }
6052
6157
  });
@@ -6055,8 +6160,8 @@
6055
6160
  ProductHasuraGraphQLRepository.prototype.getReviewByPersonId = function (personId, productId, orderId) {
6056
6161
  return __awaiter(this, void 0, void 0, function () {
6057
6162
  var data;
6058
- return __generator(this, function (_c) {
6059
- switch (_c.label) {
6163
+ return __generator(this, function (_p) {
6164
+ switch (_p.label) {
6060
6165
  case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
6061
6166
  where: {
6062
6167
  value: Object.assign({ product_id: { _eq: productId }, person_id: { _eq: personId } }, (orderId && { order_id: { _eq: orderId } })),
@@ -6065,7 +6170,7 @@
6065
6170
  },
6066
6171
  })];
6067
6172
  case 1:
6068
- data = (_c.sent()).product_review;
6173
+ data = (_p.sent()).product_review;
6069
6174
  return [2 /*return*/, data && data[0] && this.bindReviewToModel(data[0])];
6070
6175
  }
6071
6176
  });
@@ -6074,8 +6179,8 @@
6074
6179
  ProductHasuraGraphQLRepository.prototype.getReviewByAuthorAndEmail = function (author, email, productId, orderId) {
6075
6180
  return __awaiter(this, void 0, void 0, function () {
6076
6181
  var data;
6077
- return __generator(this, function (_c) {
6078
- switch (_c.label) {
6182
+ return __generator(this, function (_p) {
6183
+ switch (_p.label) {
6079
6184
  case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
6080
6185
  where: {
6081
6186
  value: Object.assign({ product_id: { _eq: productId }, author: { _eq: author }, email: { _eq: email } }, (orderId && { order_id: { _eq: orderId } })),
@@ -6084,7 +6189,7 @@
6084
6189
  },
6085
6190
  })];
6086
6191
  case 1:
6087
- data = (_c.sent()).product_review;
6192
+ data = (_p.sent()).product_review;
6088
6193
  return [2 /*return*/, data && data[0] && this.bindReviewToModel(data[0])];
6089
6194
  }
6090
6195
  });
@@ -6092,8 +6197,8 @@
6092
6197
  };
6093
6198
  ProductHasuraGraphQLRepository.prototype.cleanShoppingCountFromIds = function (ids) {
6094
6199
  return __awaiter(this, void 0, void 0, function () {
6095
- return __generator(this, function (_c) {
6096
- switch (_c.label) {
6200
+ return __generator(this, function (_p) {
6201
+ switch (_p.label) {
6097
6202
  case 0: return [4 /*yield*/, this.mutation('update_product', ['affected_rows'], {
6098
6203
  where: {
6099
6204
  value: { id: { _nin: ids } },
@@ -6105,7 +6210,7 @@
6105
6210
  type: 'product_set_input',
6106
6211
  },
6107
6212
  })];
6108
- case 1: return [2 /*return*/, _c.sent()];
6213
+ case 1: return [2 /*return*/, _p.sent()];
6109
6214
  }
6110
6215
  });
6111
6216
  });
@@ -6160,6 +6265,7 @@
6160
6265
  to: function (value) { return (lodash.isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity); },
6161
6266
  },
6162
6267
  },
6268
+ { hasStock: { columnName: 'has_stock' } },
6163
6269
  'weight',
6164
6270
  { name: { to: function () { return ''; }, from: function () { return undefined; } } },
6165
6271
  { hasVariants: { columnName: 'has_variants', to: function () { return false; }, from: function () { return undefined; } } },
@@ -6311,6 +6417,14 @@
6311
6417
  enumerable: true,
6312
6418
  get: function () { return lodash.chunk; }
6313
6419
  });
6420
+ Object.defineProperty(exports, 'each', {
6421
+ enumerable: true,
6422
+ get: function () { return lodash.each; }
6423
+ });
6424
+ Object.defineProperty(exports, 'get', {
6425
+ enumerable: true,
6426
+ get: function () { return lodash.get; }
6427
+ });
6314
6428
  Object.defineProperty(exports, 'isBoolean', {
6315
6429
  enumerable: true,
6316
6430
  get: function () { return lodash.isBoolean; }
@@ -6363,6 +6477,10 @@
6363
6477
  enumerable: true,
6364
6478
  get: function () { return lodash.set; }
6365
6479
  });
6480
+ Object.defineProperty(exports, 'unset', {
6481
+ enumerable: true,
6482
+ get: function () { return lodash.unset; }
6483
+ });
6366
6484
  exports.Address = Address;
6367
6485
  exports.Authentication = Authentication;
6368
6486
  exports.AuthenticationFirebaseAuthService = AuthenticationFirebaseAuthService;