@infrab4a/connect 4.0.0-beta.14 → 4.0.0-beta.15

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 (105) hide show
  1. package/domain/catalog/models/category-filter.d.ts +11 -0
  2. package/domain/catalog/models/category.d.ts +3 -2
  3. package/domain/catalog/models/filter-option.d.ts +10 -0
  4. package/domain/catalog/models/filter.d.ts +13 -0
  5. package/domain/catalog/models/index.d.ts +3 -0
  6. package/domain/catalog/models/product.d.ts +1 -0
  7. package/domain/catalog/models/types/index.d.ts +0 -1
  8. package/domain/catalog/repositories/category-filter.repository.d.ts +5 -0
  9. package/domain/catalog/repositories/category.repository.d.ts +3 -3
  10. package/domain/catalog/repositories/filter-option.repository.d.ts +4 -0
  11. package/domain/catalog/repositories/filter.repository.d.ts +4 -0
  12. package/domain/catalog/repositories/index.d.ts +3 -0
  13. package/domain/catalog/repositories/product.repository.d.ts +1 -0
  14. package/domain/generic/repository/find.repository.d.ts +3 -0
  15. package/domain/shop-settings/models/index.d.ts +1 -0
  16. package/domain/shop-settings/models/shop-settings.d.ts +9 -0
  17. package/domain/shop-settings/models/types/index.d.ts +6 -1
  18. package/domain/shop-settings/models/types/shop-banner.type.d.ts +12 -0
  19. package/domain/shop-settings/models/types/shop-brands.type.d.ts +10 -0
  20. package/domain/shop-settings/models/types/shop-carousel.type.d.ts +5 -0
  21. package/domain/shop-settings/models/types/shop-collection.type.d.ts +9 -0
  22. package/domain/shop-settings/models/types/shop-section.type.d.ts +9 -0
  23. package/domain/shop-settings/repositories/index.d.ts +1 -0
  24. package/domain/shop-settings/repositories/shop-settings.repository.d.ts +4 -0
  25. package/domain/shopping/models/buy-2-win.d.ts +3 -1
  26. package/domain/shopping/models/campaign-dashboard.d.ts +15 -0
  27. package/domain/shopping/models/campaign-hashtag.d.ts +18 -0
  28. package/domain/shopping/models/index.d.ts +5 -4
  29. package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +4 -0
  30. package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +4 -0
  31. package/domain/shopping/repositories/index.d.ts +4 -2
  32. package/esm2020/domain/catalog/models/category-filter.mjs +14 -0
  33. package/esm2020/domain/catalog/models/category.mjs +8 -1
  34. package/esm2020/domain/catalog/models/filter-option.mjs +10 -0
  35. package/esm2020/domain/catalog/models/filter.mjs +10 -0
  36. package/esm2020/domain/catalog/models/index.mjs +4 -1
  37. package/esm2020/domain/catalog/models/product.mjs +1 -1
  38. package/esm2020/domain/catalog/models/types/index.mjs +1 -2
  39. package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +2 -0
  40. package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
  41. package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +2 -0
  42. package/esm2020/domain/catalog/repositories/filter.repository.mjs +2 -0
  43. package/esm2020/domain/catalog/repositories/index.mjs +4 -1
  44. package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
  45. package/esm2020/domain/generic/repository/find.repository.mjs +1 -1
  46. package/esm2020/domain/shop-settings/models/index.mjs +2 -1
  47. package/esm2020/domain/shop-settings/models/shop-settings.mjs +7 -0
  48. package/esm2020/domain/shop-settings/models/types/index.mjs +7 -2
  49. package/esm2020/domain/shop-settings/models/types/shop-banner.type.mjs +2 -0
  50. package/esm2020/domain/shop-settings/models/types/shop-brands.type.mjs +2 -0
  51. package/esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs +2 -0
  52. package/esm2020/domain/shop-settings/models/types/shop-collection.type.mjs +2 -0
  53. package/esm2020/domain/shop-settings/models/types/shop-section.type.mjs +2 -0
  54. package/esm2020/domain/shop-settings/repositories/index.mjs +2 -1
  55. package/esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs +2 -0
  56. package/esm2020/domain/shopping/models/buy-2-win.mjs +2 -2
  57. package/esm2020/domain/shopping/models/campaign-dashboard.mjs +7 -0
  58. package/esm2020/domain/shopping/models/campaign-hashtag.mjs +7 -0
  59. package/esm2020/domain/shopping/models/index.mjs +6 -5
  60. package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +2 -0
  61. package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +2 -0
  62. package/esm2020/domain/shopping/repositories/index.mjs +5 -3
  63. package/esm2020/infra/elasticsearch/indexes/products-index.mjs +2 -1
  64. package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +3 -2
  65. package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +3 -1
  66. package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +5 -3
  67. package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +4 -1
  68. package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +2 -1
  69. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +14 -0
  70. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +14 -0
  71. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +14 -0
  72. package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +6 -4
  73. package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +2 -2
  74. package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +16 -12
  75. package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +5 -3
  76. package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +55 -0
  77. package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +94 -12
  78. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +104 -0
  79. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +21 -0
  80. package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +4 -1
  81. package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +21 -4
  82. package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +2 -2
  83. package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
  84. package/fesm2015/infrab4a-connect.mjs +472 -87
  85. package/fesm2015/infrab4a-connect.mjs.map +1 -1
  86. package/fesm2020/infrab4a-connect.mjs +450 -82
  87. package/fesm2020/infrab4a-connect.mjs.map +1 -1
  88. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -1
  89. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +1 -0
  90. package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +1 -0
  91. package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +7 -0
  92. package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +8 -0
  93. package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +8 -0
  94. package/infra/firebase/firestore/repositories/shopping/index.d.ts +5 -3
  95. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +4 -9
  96. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +11 -0
  97. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +6 -2
  98. package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +18 -0
  99. package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +10 -0
  100. package/infra/hasura-graphql/repositories/catalog/index.d.ts +3 -0
  101. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +1 -0
  102. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
  103. package/package.json +1 -1
  104. package/domain/catalog/models/types/category-filter.type.d.ts +0 -4
  105. package/esm2020/domain/catalog/models/types/category-filter.type.mjs +0 -2
@@ -754,6 +754,15 @@ class RecoveryPassword {
754
754
  }
755
755
  }
756
756
 
757
+ class Filter extends BaseModel {
758
+ identifierFields() {
759
+ return ['id'];
760
+ }
761
+ static get identifiersFields() {
762
+ return ['id'];
763
+ }
764
+ }
765
+
757
766
  class Category extends BaseModel {
758
767
  identifierFields() {
759
768
  return ['id'];
@@ -762,6 +771,20 @@ class Category extends BaseModel {
762
771
  return ['id'];
763
772
  }
764
773
  }
774
+ __decorate([
775
+ Type(() => Filter),
776
+ __metadata("design:type", Array)
777
+ ], Category.prototype, "filters", void 0);
778
+
779
+ class CategoryFilter extends BaseModel {
780
+ static get identifiersFields() {
781
+ return ['id'];
782
+ }
783
+ }
784
+ __decorate([
785
+ Type(() => Filter),
786
+ __metadata("design:type", Filter)
787
+ ], CategoryFilter.prototype, "filter", void 0);
765
788
 
766
789
  var GenderDestination;
767
790
  (function (GenderDestination) {
@@ -778,6 +801,15 @@ var Shops;
778
801
  Shops["ALL"] = "ALL";
779
802
  })(Shops || (Shops = {}));
780
803
 
804
+ class FilterOption extends BaseModel {
805
+ identifierFields() {
806
+ return ['id'];
807
+ }
808
+ static get identifiersFields() {
809
+ return ['id'];
810
+ }
811
+ }
812
+
781
813
  class Product extends BaseModel {
782
814
  identifierFields() {
783
815
  return ['id'];
@@ -814,17 +846,27 @@ class Variant extends BaseModel {
814
846
  }
815
847
  }
816
848
 
817
- var OrderStatus;
818
- (function (OrderStatus) {
819
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
820
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
821
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
822
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
823
- OrderStatus["ENVIADO"] = "Enviado";
824
- OrderStatus["ENTREGUE"] = "Entregue";
825
- OrderStatus["CANCELADO"] = "Cancelado";
826
- OrderStatus["CREDIT_CARD"] = "credit_card";
827
- })(OrderStatus || (OrderStatus = {}));
849
+ class Buy2Win extends BaseModel {
850
+ static get identifiersFields() {
851
+ return ['id'];
852
+ }
853
+ }
854
+ __decorate([
855
+ Type(() => Category),
856
+ __metadata("design:type", Array)
857
+ ], Buy2Win.prototype, "categories", void 0);
858
+
859
+ class CampaignDashboard extends BaseModel {
860
+ static get identifiersFields() {
861
+ return ['id'];
862
+ }
863
+ }
864
+
865
+ class CampaignHashtag extends BaseModel {
866
+ static get identifiersFields() {
867
+ return ['id'];
868
+ }
869
+ }
828
870
 
829
871
  class LineItem extends Product {
830
872
  }
@@ -865,6 +907,18 @@ __decorate([
865
907
  __metadata("design:type", Coupon)
866
908
  ], Checkout.prototype, "coupon", void 0);
867
909
 
910
+ var OrderStatus;
911
+ (function (OrderStatus) {
912
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
913
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
914
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
915
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
916
+ OrderStatus["ENVIADO"] = "Enviado";
917
+ OrderStatus["ENTREGUE"] = "Entregue";
918
+ OrderStatus["CANCELADO"] = "Cancelado";
919
+ OrderStatus["CREDIT_CARD"] = "credit_card";
920
+ })(OrderStatus || (OrderStatus = {}));
921
+
868
922
  class Order extends Checkout {
869
923
  }
870
924
  __decorate([
@@ -894,16 +948,6 @@ __decorate([
894
948
  __metadata("design:type", Coupon)
895
949
  ], CheckoutSubscription.prototype, "coupon", void 0);
896
950
 
897
- class Buy2Win extends BaseModel {
898
- static get identifiersFields() {
899
- return ['id'];
900
- }
901
- }
902
- __decorate([
903
- Type(() => Category),
904
- __metadata("design:type", Array)
905
- ], Buy2Win.prototype, "categories", void 0);
906
-
907
951
  var FilterType;
908
952
  (function (FilterType) {
909
953
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -1003,6 +1047,12 @@ class ShopMenu extends BaseModel {
1003
1047
  }
1004
1048
  }
1005
1049
 
1050
+ class ShopSettings extends BaseModel {
1051
+ static get identifiersFields() {
1052
+ return ['id'];
1053
+ }
1054
+ }
1055
+
1006
1056
  class InvalidArgumentError extends CustomError {
1007
1057
  constructor(message) {
1008
1058
  super(message);
@@ -1113,6 +1163,7 @@ class ProductsIndex {
1113
1163
  'stock',
1114
1164
  'weight',
1115
1165
  'tags',
1166
+ 'filters',
1116
1167
  'hasVariants',
1117
1168
  'type',
1118
1169
  ];
@@ -1206,6 +1257,8 @@ const withFirestore = (MixinBase) => {
1206
1257
  constructor(...params) {
1207
1258
  const options = params[0];
1208
1259
  super(...params);
1260
+ this.fields = {};
1261
+ this.interceptors = {};
1209
1262
  this.collectionName = '';
1210
1263
  this.firestore = options.firestore;
1211
1264
  this.collectionName = options.collectionName;
@@ -1347,10 +1400,11 @@ const withFindFirestore = (MixinBase) => {
1347
1400
  };
1348
1401
  }
1349
1402
  find(find = {}) {
1350
- var _a, _b, _c, _d;
1403
+ var _a, _b, _c, _d, _e, _f;
1351
1404
  return __awaiter(this, void 0, void 0, function* () {
1352
1405
  const collection = this.collection(this.buildCollectionPathForFind(find.filters));
1353
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { find }));
1406
+ const enableCount = (_b = (_a = find === null || find === void 0 ? void 0 : find.options) === null || _a === void 0 ? void 0 : _a.enableCount) !== null && _b !== void 0 ? _b : true;
1407
+ const intercepted = yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { find }));
1354
1408
  const { filters, limits, orderBy } = intercepted.find || find;
1355
1409
  const queries = this.makeFirestoreWhere(filters || {});
1356
1410
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
@@ -1359,8 +1413,8 @@ const withFindFirestore = (MixinBase) => {
1359
1413
  const docs = yield getDocs(query(collection, ...queryArgumments));
1360
1414
  const data = docs.docs.map((doc) => doc.data());
1361
1415
  return {
1362
- data: (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, data, intercepted))) || data,
1363
- count: this.calculateCount(data, limits),
1416
+ data: (yield ((_f = (_e = this.interceptors) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.call(_e, data, intercepted))) || data,
1417
+ count: enableCount ? this.calculateCount(data, limits) : Infinity,
1364
1418
  };
1365
1419
  });
1366
1420
  }
@@ -1683,7 +1737,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1683
1737
  return categoryDocs.docs[0].data();
1684
1738
  });
1685
1739
  }
1686
- getCategoriesForHome(categoryIds, limit = 4) {
1740
+ getCategoriesForHome(categoryIds, limit = 4, gender) {
1687
1741
  return __awaiter(this, void 0, void 0, function* () {
1688
1742
  const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
1689
1743
  if (categorySnap.empty)
@@ -1692,7 +1746,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1692
1746
  const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
1693
1747
  return ({
1694
1748
  category,
1695
- products: yield this.mountCategory(category, { limit, hasStock: true }),
1749
+ products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
1696
1750
  });
1697
1751
  })));
1698
1752
  return homeSections;
@@ -1711,6 +1765,8 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1711
1765
  wheres.push(where('published', '==', true), where('id', 'in', productIds));
1712
1766
  if (options === null || options === void 0 ? void 0 : options.hasStock)
1713
1767
  wheres.push(where('stock.quantity', '>', 0));
1768
+ if (options === null || options === void 0 ? void 0 : options.gender)
1769
+ wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
1714
1770
  if (options === null || options === void 0 ? void 0 : options.limit)
1715
1771
  wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
1716
1772
  const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
@@ -1772,6 +1828,9 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
1772
1828
  return this.reviews[status];
1773
1829
  });
1774
1830
  }
1831
+ cleanShoppingCountFromIds() {
1832
+ return;
1833
+ }
1775
1834
  }
1776
1835
 
1777
1836
  class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
@@ -1798,6 +1857,39 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
1798
1857
  }
1799
1858
  }
1800
1859
 
1860
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1861
+ constructor({ firestore, interceptors }) {
1862
+ super({
1863
+ firestore,
1864
+ collectionName: 'buy2win',
1865
+ model: Buy2Win,
1866
+ interceptors,
1867
+ });
1868
+ }
1869
+ }
1870
+
1871
+ class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1872
+ constructor({ firestore, interceptors, }) {
1873
+ super({
1874
+ firestore,
1875
+ collectionName: 'dashboardCampaignsAuto',
1876
+ model: CampaignDashboard,
1877
+ interceptors,
1878
+ });
1879
+ }
1880
+ }
1881
+
1882
+ class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1883
+ constructor({ firestore, interceptors, }) {
1884
+ super({
1885
+ firestore,
1886
+ collectionName: 'hashtagCampaignsAuto',
1887
+ model: CampaignHashtag,
1888
+ interceptors,
1889
+ });
1890
+ }
1891
+ }
1892
+
1801
1893
  class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1802
1894
  constructor({ firestore, interceptors }) {
1803
1895
  super({
@@ -1809,6 +1901,17 @@ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1809
1901
  }
1810
1902
  }
1811
1903
 
1904
+ class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1905
+ constructor({ firestore, interceptors, }) {
1906
+ super({
1907
+ firestore,
1908
+ collectionName: 'checkoutsSubscription',
1909
+ model: CheckoutSubscription,
1910
+ interceptors,
1911
+ });
1912
+ }
1913
+ }
1914
+
1812
1915
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1813
1916
  constructor({ firestore, interceptors }) {
1814
1917
  super({
@@ -1874,23 +1977,22 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1874
1977
  }
1875
1978
  }
1876
1979
 
1877
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1980
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1878
1981
  constructor({ firestore, interceptors }) {
1879
1982
  super({
1880
1983
  firestore,
1881
- collectionName: 'payments',
1882
- model: Payment,
1883
1984
  interceptors,
1884
1985
  });
1986
+ this.collectionName = 'legacyOrders';
1885
1987
  }
1886
1988
  }
1887
1989
 
1888
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1889
- constructor({ firestore, interceptors, }) {
1990
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1991
+ constructor({ firestore, interceptors }) {
1890
1992
  super({
1891
1993
  firestore,
1892
- collectionName: 'checkoutsSubscription',
1893
- model: CheckoutSubscription,
1994
+ collectionName: 'payments',
1995
+ model: Payment,
1894
1996
  interceptors,
1895
1997
  });
1896
1998
  }
@@ -1907,27 +2009,6 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
1907
2009
  }
1908
2010
  }
1909
2011
 
1910
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1911
- constructor({ firestore, interceptors }) {
1912
- super({
1913
- firestore,
1914
- collectionName: 'buy2win',
1915
- model: Buy2Win,
1916
- interceptors,
1917
- });
1918
- }
1919
- }
1920
-
1921
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1922
- constructor({ firestore, interceptors }) {
1923
- super({
1924
- firestore,
1925
- interceptors,
1926
- });
1927
- this.collectionName = 'legacyOrders';
1928
- }
1929
- }
1930
-
1931
2012
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1932
2013
  constructor({ firestore, interceptors }) {
1933
2014
  super({
@@ -1993,6 +2074,17 @@ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1993
2074
  }
1994
2075
  }
1995
2076
 
2077
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2078
+ constructor({ firestore, interceptors, }) {
2079
+ super({
2080
+ firestore,
2081
+ collectionName: 'shopSettings',
2082
+ model: ShopSettings,
2083
+ interceptors,
2084
+ });
2085
+ }
2086
+ }
2087
+
1996
2088
  class AuthenticationFirebaseAuthService {
1997
2089
  constructor(firebaseAuth) {
1998
2090
  this.firebaseAuth = firebaseAuth;
@@ -2079,7 +2171,7 @@ class AttributeOptionHelper {
2079
2171
  AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2080
2172
  var _a;
2081
2173
  if (fields.includes(attributeName))
2082
- return { columnName: attributeName.toString(), attributeName };
2174
+ return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
2083
2175
  const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
2084
2176
  const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
2085
2177
  if (isNil(fieldOption))
@@ -2407,10 +2499,12 @@ const withHasuraGraphQL = (MixinBase) => {
2407
2499
  fetch(params) {
2408
2500
  return __awaiter(this, void 0, void 0, function* () {
2409
2501
  const headers = this.headers;
2410
- const response = yield axios.post(`${this.endpoint}`, params, {
2502
+ const { data: result } = yield axios({
2503
+ url: `${this.endpoint}`,
2504
+ method: 'POST',
2505
+ data: params,
2411
2506
  headers,
2412
2507
  });
2413
- const result = yield response.data;
2414
2508
  if (!isNil(result.errors))
2415
2509
  throw new Error(JSON.stringify(result.errors));
2416
2510
  return result.data;
@@ -2550,9 +2644,11 @@ const withGetHasuraGraphQL = (MixinBase) => {
2550
2644
 
2551
2645
  const withFindHasuraGraphQL = (MixinBase) => {
2552
2646
  return class FindHasuraGraphQLMixin extends MixinBase {
2553
- find(options) {
2647
+ find(params) {
2648
+ var _a;
2554
2649
  return __awaiter(this, void 0, void 0, function* () {
2555
- const { filters, limits, orderBy } = options || {};
2650
+ const { filters, limits, orderBy, options } = params || {};
2651
+ const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
2556
2652
  const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
2557
2653
  ? {}
2558
2654
  : {
@@ -2566,8 +2662,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
2566
2662
  const result = yield this.query([
2567
2663
  {
2568
2664
  operation: this.tableName,
2569
- fields: options.fields
2570
- ? options.fields
2665
+ fields: params.fields
2666
+ ? params.fields
2571
2667
  .map((fieldName) => {
2572
2668
  var _a;
2573
2669
  return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
@@ -2576,15 +2672,18 @@ const withFindHasuraGraphQL = (MixinBase) => {
2576
2672
  : this.fields,
2577
2673
  variables,
2578
2674
  },
2579
- {
2580
- operation: `${this.tableName}_aggregate`,
2581
- fields: [{ aggregate: ['count'] }],
2582
- variables: variablesCount,
2583
- },
2675
+ ...(enableCount
2676
+ ? [
2677
+ {
2678
+ operation: `${this.tableName}_aggregate`,
2679
+ fields: [{ aggregate: ['count'] }],
2680
+ variables: variablesCount,
2681
+ },
2682
+ ]
2683
+ : []),
2584
2684
  ]);
2585
2685
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
2586
- const count = result[`${this.tableName}_aggregate`].aggregate.count;
2587
- return { count, data };
2686
+ return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
2588
2687
  });
2589
2688
  }
2590
2689
  };
@@ -2624,8 +2723,60 @@ class VariantHasuraGraphQL extends Variant {
2624
2723
  }
2625
2724
  }
2626
2725
 
2726
+ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2727
+ constructor(endpoint, authOptions) {
2728
+ super({
2729
+ tableName: 'category_filter',
2730
+ model: CategoryFilter,
2731
+ endpoint,
2732
+ authOptions,
2733
+ fields: [
2734
+ 'id',
2735
+ { filterId: { columnName: 'filter_id' } },
2736
+ { categoryId: { columnName: 'category_id' } },
2737
+ {
2738
+ filter: {
2739
+ columnName: 'filter',
2740
+ foreignKeyColumn: { id: 'filterId' },
2741
+ fields: [
2742
+ 'id',
2743
+ 'description',
2744
+ 'slug',
2745
+ 'enabled',
2746
+ { createdAt: { columnName: 'created_at' } },
2747
+ { updatedAt: { columnName: 'updated_at' } },
2748
+ {
2749
+ options: {
2750
+ columnName: 'options',
2751
+ foreignKeyColumn: { filterId: 'id' },
2752
+ fields: [
2753
+ 'id',
2754
+ { filterId: { columnName: 'filter_id' } },
2755
+ 'description',
2756
+ { createdAt: { columnName: 'created_at' } },
2757
+ { updatedAt: { columnName: 'updated_at' } },
2758
+ ],
2759
+ },
2760
+ },
2761
+ ],
2762
+ },
2763
+ },
2764
+ ],
2765
+ });
2766
+ }
2767
+ deleteByCategoryAndFilter(categoryId, filterId) {
2768
+ return this.mutation('delete_category_filter', ['affected_rows'], {
2769
+ where: {
2770
+ type: 'category_filter_bool_exp',
2771
+ required: true,
2772
+ value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
2773
+ },
2774
+ });
2775
+ }
2776
+ }
2777
+
2627
2778
  class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2628
- constructor({ endpoint, authOptions, interceptors, }, productRepository) {
2779
+ constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
2629
2780
  super({
2630
2781
  tableName: 'category',
2631
2782
  model: Category,
@@ -2665,7 +2816,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2665
2816
  },
2666
2817
  },
2667
2818
  },
2668
- 'filters',
2819
+ {
2820
+ filters: {
2821
+ columnName: 'filters',
2822
+ foreignKeyColumn: { filter_id: 'id' },
2823
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
2824
+ bindPersistData: (value) => ({
2825
+ filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
2826
+ }),
2827
+ from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
2828
+ },
2829
+ },
2669
2830
  { createdAt: { columnName: 'created_at' } },
2670
2831
  { updatedAt: { columnName: 'updated_at' } },
2671
2832
  {
@@ -2690,6 +2851,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2690
2851
  ],
2691
2852
  });
2692
2853
  this.productRepository = productRepository;
2854
+ this.categoryFilterRepository = categoryFilterRepository;
2693
2855
  }
2694
2856
  create(params) {
2695
2857
  const _super = Object.create(null, {
@@ -2707,7 +2869,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2707
2869
  var _a;
2708
2870
  return __awaiter(this, void 0, void 0, function* () {
2709
2871
  return Number.isNaN(+identifiers.id)
2710
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
2872
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
2711
2873
  : _super.get.call(this, identifiers);
2712
2874
  });
2713
2875
  }
@@ -2716,12 +2878,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2716
2878
  update: { get: () => super.update }
2717
2879
  });
2718
2880
  return __awaiter(this, void 0, void 0, function* () {
2719
- const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
2881
+ const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
2720
2882
  const plainData = this.paramsToPlain({ id: checkId });
2721
2883
  const id = yield this.getId(plainData.id);
2722
2884
  const category = yield _super.update.call(this, Object.assign({ id }, data));
2723
2885
  category.products = products && (yield this.updateProducts(+id, { products }));
2724
2886
  category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
2887
+ category.filters = filters && (yield this.updateFilters(+id, { filters }));
2725
2888
  return category;
2726
2889
  });
2727
2890
  }
@@ -2729,15 +2892,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2729
2892
  return __awaiter(this, void 0, void 0, function* () {
2730
2893
  if (!slug)
2731
2894
  return null;
2732
- const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
2733
- if (count > 1)
2734
- throw new DuplicatedResultsError('Query returned duplicated values');
2735
- if (!count)
2895
+ const { data } = yield this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
2896
+ if (!data.length)
2736
2897
  throw new NotFoundError(`Category with slug ${slug} not found`);
2898
+ if (data.length > 1)
2899
+ throw new DuplicatedResultsError('Query returned duplicated values');
2737
2900
  return data.shift();
2738
2901
  });
2739
2902
  }
2740
- getCategoriesForHome(categoryIds, limit = 4) {
2903
+ getCategoriesForHome(categoryIds, limit = 4, gender) {
2741
2904
  return __awaiter(this, void 0, void 0, function* () {
2742
2905
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
2743
2906
  return [];
@@ -2757,7 +2920,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2757
2920
  const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
2758
2921
  return ({
2759
2922
  category,
2760
- products: yield this.mountCategory(category, { limit, hasStock: true }),
2923
+ products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
2761
2924
  });
2762
2925
  })));
2763
2926
  return homeSections;
@@ -2769,7 +2932,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2769
2932
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
2770
2933
  return [];
2771
2934
  const products = [];
2772
- const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
2935
+ const { data: productsData } = yield this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
2773
2936
  'id',
2774
2937
  'name',
2775
2938
  'slug',
@@ -2793,7 +2956,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2793
2956
  'tags',
2794
2957
  'type',
2795
2958
  'shoppingCount',
2796
- ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
2959
+ 'gender',
2960
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
2797
2961
  products.push(...productsData);
2798
2962
  return products;
2799
2963
  });
@@ -2803,7 +2967,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2803
2967
  return __awaiter(this, void 0, void 0, function* () {
2804
2968
  if (!Number.isNaN(+id))
2805
2969
  return id;
2806
- const { data } = yield this.find({ filters: { firestoreId: id } });
2970
+ const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
2807
2971
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
2808
2972
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
2809
2973
  throw new NotFoundError(`Category with id ${id} not found`);
@@ -2861,6 +3025,208 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2861
3025
  return plainData.metadata;
2862
3026
  });
2863
3027
  }
3028
+ updateFilters(categoryId, { filters }) {
3029
+ return __awaiter(this, void 0, void 0, function* () {
3030
+ if ('action' in filters && filters.action === 'remove' && filters.value.length) {
3031
+ for (let i = 0; i < filters.value.length; i++) {
3032
+ yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
3033
+ }
3034
+ return [];
3035
+ }
3036
+ if ('action' in filters && filters.action === 'merge' && filters.value.length) {
3037
+ let filtersList = [];
3038
+ for (let i = 0; i < filters.value.length; i++) {
3039
+ try {
3040
+ const hasFilter = yield this.categoryFilterRepository
3041
+ .find({
3042
+ filters: {
3043
+ categoryId,
3044
+ filterId: filters.value[i].id,
3045
+ },
3046
+ })
3047
+ .then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
3048
+ if (hasFilter) {
3049
+ filtersList.push(hasFilter);
3050
+ }
3051
+ else {
3052
+ yield this.categoryFilterRepository.create({
3053
+ filterId: filters.value[i].id,
3054
+ categoryId,
3055
+ });
3056
+ filtersList.push(filters.value[i]);
3057
+ }
3058
+ }
3059
+ catch (error) {
3060
+ console.log('catch error: ', error);
3061
+ }
3062
+ }
3063
+ return filtersList;
3064
+ }
3065
+ if (Array.isArray(filters) && filters.length) {
3066
+ let filtersList = [];
3067
+ for (let i = 0; i < filters.length; i++) {
3068
+ try {
3069
+ const hasFilter = yield this.categoryFilterRepository
3070
+ .find({
3071
+ filters: {
3072
+ categoryId,
3073
+ filterId: filters[i].id,
3074
+ },
3075
+ })
3076
+ .then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
3077
+ if (hasFilter) {
3078
+ filtersList.push(hasFilter);
3079
+ }
3080
+ else {
3081
+ yield this.categoryFilterRepository.create({
3082
+ filterId: filters[i].id,
3083
+ categoryId,
3084
+ });
3085
+ filtersList.push(filters[i]);
3086
+ }
3087
+ }
3088
+ catch (error) {
3089
+ console.log('catch error: ', error);
3090
+ }
3091
+ }
3092
+ return filtersList;
3093
+ }
3094
+ return [];
3095
+ });
3096
+ }
3097
+ }
3098
+
3099
+ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3100
+ constructor(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
3101
+ super({
3102
+ tableName: 'filter',
3103
+ model: Filter,
3104
+ endpoint,
3105
+ authOptions,
3106
+ fields: [
3107
+ 'id',
3108
+ 'description',
3109
+ 'slug',
3110
+ 'enabled',
3111
+ { createdAt: { columnName: 'created_at' } },
3112
+ { updatedAt: { columnName: 'updated_at' } },
3113
+ {
3114
+ options: {
3115
+ columnName: 'options',
3116
+ foreignKeyColumn: { filterId: 'id' },
3117
+ fields: [
3118
+ 'id',
3119
+ { filterId: { columnName: 'filter_id' } },
3120
+ 'description',
3121
+ { createdAt: { columnName: 'created_at' } },
3122
+ { updatedAt: { columnName: 'updated_at' } },
3123
+ ],
3124
+ },
3125
+ },
3126
+ ],
3127
+ });
3128
+ this.filterOptionRepository = filterOptionRepository;
3129
+ this.categoryFilterRepository = categoryFilterRepository;
3130
+ }
3131
+ update(params) {
3132
+ const _super = Object.create(null, {
3133
+ update: { get: () => super.update }
3134
+ });
3135
+ return __awaiter(this, void 0, void 0, function* () {
3136
+ const { options } = params, data = __rest(params, ["options"]);
3137
+ const filter = yield _super.update.call(this, data);
3138
+ filter.options = yield this.updateOptions(+data.id, { options });
3139
+ return filter;
3140
+ });
3141
+ }
3142
+ updateOptions(filterId, { options }) {
3143
+ return __awaiter(this, void 0, void 0, function* () {
3144
+ if (!options)
3145
+ return [];
3146
+ if ('action' in options && options.action === 'remove' && options.value.length) {
3147
+ for (let i = 0; i < options.value.length; i++) {
3148
+ yield this.filterOptionRepository.delete({ id: options.value[i].id });
3149
+ }
3150
+ return [];
3151
+ }
3152
+ if ('action' in options && options.action === 'merge' && options.value.length) {
3153
+ let filterOptions = [];
3154
+ for (let i = 0; i < options.value.length; i++) {
3155
+ try {
3156
+ const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
3157
+ if (hasFilter)
3158
+ filterOptions.push(hasFilter);
3159
+ }
3160
+ catch (error) {
3161
+ const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
3162
+ filterOptions.push(newOption);
3163
+ }
3164
+ }
3165
+ return filterOptions;
3166
+ }
3167
+ if (Array.isArray(options) && options.length) {
3168
+ let filterOptions = [];
3169
+ for (let i = 0; i < options.length; i++) {
3170
+ try {
3171
+ const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
3172
+ if (hasFilter)
3173
+ filterOptions.push(hasFilter);
3174
+ }
3175
+ catch (error) {
3176
+ const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
3177
+ filterOptions.push(newOption);
3178
+ }
3179
+ }
3180
+ }
3181
+ return [];
3182
+ });
3183
+ }
3184
+ delete(params) {
3185
+ const _super = Object.create(null, {
3186
+ delete: { get: () => super.delete }
3187
+ });
3188
+ return __awaiter(this, void 0, void 0, function* () {
3189
+ const { data: categoryFilters } = yield this.categoryFilterRepository.find({
3190
+ filters: {
3191
+ filterId: params.id,
3192
+ },
3193
+ });
3194
+ if (categoryFilters.length)
3195
+ throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
3196
+ yield this.deleteOptions(+params.id);
3197
+ yield _super.delete.call(this, { id: +params.id });
3198
+ return;
3199
+ });
3200
+ }
3201
+ deleteOptions(filterId) {
3202
+ return __awaiter(this, void 0, void 0, function* () {
3203
+ yield this.mutation('delete_filter_option', ['affected_rows'], {
3204
+ where: {
3205
+ type: 'filter_option_bool_exp',
3206
+ required: true,
3207
+ value: { filter_id: { _eq: filterId } },
3208
+ },
3209
+ });
3210
+ });
3211
+ }
3212
+ }
3213
+
3214
+ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3215
+ constructor(endpoint, authOptions) {
3216
+ super({
3217
+ tableName: 'filter_option',
3218
+ model: FilterOption,
3219
+ endpoint,
3220
+ authOptions,
3221
+ fields: [
3222
+ 'id',
3223
+ 'description',
3224
+ { filterId: { columnName: 'filter_id' } },
3225
+ { createdAt: { columnName: 'created_at' } },
3226
+ { updatedAt: { columnName: 'updated_at' } },
3227
+ ],
3228
+ });
3229
+ }
2864
3230
  }
2865
3231
 
2866
3232
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -2967,6 +3333,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2967
3333
  'weight',
2968
3334
  'gender',
2969
3335
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
3336
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
2970
3337
  { isKit: { columnName: 'is_kit' } },
2971
3338
  { createdAt: { columnName: 'created_at' } },
2972
3339
  { updatedAt: { columnName: 'updated_at' } },
@@ -3068,7 +3435,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3068
3435
  var _a;
3069
3436
  return __awaiter(this, void 0, void 0, function* () {
3070
3437
  const product = Number.isNaN(+identifiers.id)
3071
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
3438
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
3072
3439
  : yield _super.get.call(this, identifiers);
3073
3440
  if (product.productId)
3074
3441
  throw new NotFoundError('Product not found, it is a variant');
@@ -3096,9 +3463,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3096
3463
  filters: {
3097
3464
  slug,
3098
3465
  },
3466
+ fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
3467
+ options: {
3468
+ enableCount: false,
3469
+ },
3099
3470
  });
3100
3471
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3101
- product.reviews = yield this.findReviewsByProduct(+product.id);
3102
3472
  return product;
3103
3473
  });
3104
3474
  }
@@ -3261,7 +3631,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3261
3631
  return __awaiter(this, void 0, void 0, function* () {
3262
3632
  if (!Number.isNaN(+id))
3263
3633
  return id;
3264
- const { data } = yield this.find({ filters: { firestoreId: id } });
3634
+ const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3265
3635
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3266
3636
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
3267
3637
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3317,6 +3687,21 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3317
3687
  return data && data[0] && this.bindReviewToModel(data[0]);
3318
3688
  });
3319
3689
  }
3690
+ cleanShoppingCountFromIds(ids) {
3691
+ return __awaiter(this, void 0, void 0, function* () {
3692
+ return yield this.mutation('update_product', ['affected_rows'], {
3693
+ where: {
3694
+ value: { id: { _nin: ids } },
3695
+ type: 'product_bool_exp',
3696
+ required: true,
3697
+ },
3698
+ _set: {
3699
+ value: { shopping_count: 0 },
3700
+ type: 'product_set_input',
3701
+ },
3702
+ });
3703
+ });
3704
+ }
3320
3705
  }
3321
3706
 
3322
3707
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -3427,7 +3812,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3427
3812
  return __awaiter(this, void 0, void 0, function* () {
3428
3813
  if (!Number.isNaN(+id))
3429
3814
  return id;
3430
- const { data } = yield this.find({ filters: { firestoreId: id } });
3815
+ const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3431
3816
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3432
3817
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
3433
3818
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3439,5 +3824,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3439
3824
  * Generated bundle index. Do not edit.
3440
3825
  */
3441
3826
 
3442
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3827
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3443
3828
  //# sourceMappingURL=infrab4a-connect.mjs.map