@infrab4a/connect 5.3.0-beta.3 → 5.3.0-beta.30

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 (155) hide show
  1. package/index.cjs.js +2985 -447
  2. package/index.esm.js +2950 -450
  3. package/package.json +3 -2
  4. package/src/domain/catalog/models/category-brand.d.ts +17 -0
  5. package/src/domain/catalog/models/category.d.ts +12 -0
  6. package/src/domain/catalog/models/enums/shops.enum.d.ts +2 -0
  7. package/src/domain/catalog/models/index.d.ts +4 -0
  8. package/src/domain/catalog/models/product-base.d.ts +10 -0
  9. package/src/domain/catalog/models/product-group.d.ts +12 -0
  10. package/src/domain/catalog/models/product-price-log.d.ts +25 -0
  11. package/src/domain/catalog/models/product-review.d.ts +2 -0
  12. package/src/domain/catalog/models/product-stock-entry.d.ts +16 -0
  13. package/src/domain/catalog/models/product.d.ts +1 -0
  14. package/src/domain/catalog/models/types/brands-shop-menu.type.d.ts +13 -0
  15. package/src/domain/catalog/models/types/index.d.ts +2 -0
  16. package/src/domain/catalog/models/types/product-competitors-price.d.ts +6 -0
  17. package/src/domain/catalog/repositories/category-brand.repository.d.ts +4 -0
  18. package/src/domain/catalog/repositories/category-product.repository.d.ts +2 -0
  19. package/src/domain/catalog/repositories/category.repository.d.ts +1 -0
  20. package/src/domain/catalog/repositories/index.d.ts +5 -0
  21. package/src/domain/catalog/repositories/product-catalog.repository.d.ts +17 -0
  22. package/src/domain/catalog/repositories/product-group.repository.d.ts +4 -0
  23. package/src/domain/catalog/repositories/product-price-log.repository.d.ts +4 -0
  24. package/src/domain/catalog/repositories/product-stock-entry.repository.d.ts +4 -0
  25. package/src/domain/shop-settings/enums/shop-page-name.enum.d.ts +2 -1
  26. package/src/domain/shop-settings/models/home.d.ts +2 -1
  27. package/src/domain/shop-settings/models/index.d.ts +2 -1
  28. package/src/domain/shop-settings/models/shop-configs.d.ts +18 -0
  29. package/src/domain/shop-settings/models/{shop-settings.d.ts → shop-page-settings.d.ts} +4 -1
  30. package/src/domain/shop-settings/models/types/index.d.ts +3 -0
  31. package/src/domain/shop-settings/models/types/limit-orders.type.d.ts +7 -0
  32. package/src/domain/shop-settings/models/types/shipping-thresholds.type.d.ts +17 -0
  33. package/src/domain/shop-settings/models/types/shop-error-messages.type.d.ts +10 -0
  34. package/src/domain/shop-settings/models/types/shop-page-section.type.d.ts +140 -0
  35. package/src/domain/shop-settings/repositories/index.d.ts +1 -0
  36. package/src/domain/shop-settings/repositories/shop-configs.repository.d.ts +4 -0
  37. package/src/domain/shop-settings/repositories/shop-settings.repository.d.ts +1 -1
  38. package/src/domain/shopping/enums/index.d.ts +3 -0
  39. package/src/domain/shopping/enums/order-payment-status.enum.d.ts +10 -0
  40. package/src/domain/shopping/enums/pagarme-v5-payment-status.enum.d.ts +24 -0
  41. package/src/domain/shopping/enums/payment-providers.enum.d.ts +2 -1
  42. package/src/domain/shopping/enums/transaction-payment-methods.enum.d.ts +5 -0
  43. package/src/domain/shopping/factories/index.d.ts +1 -0
  44. package/src/domain/shopping/factories/mercado-pago-payment-method.factory.d.ts +11 -0
  45. package/src/domain/shopping/factories/payment-provider.factory.d.ts +2 -0
  46. package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +10 -2
  47. package/src/domain/shopping/models/enums/index.d.ts +3 -0
  48. package/src/domain/shopping/models/enums/order-status.enum.d.ts +2 -1
  49. package/src/domain/shopping/models/enums/shopping-recurrence-cycle.enum.d.ts +5 -0
  50. package/src/domain/shopping/models/enums/shopping-recurrence-edition-status.enum.d.ts +11 -0
  51. package/src/domain/shopping/models/enums/shopping-recurrence-status.enum.d.ts +7 -0
  52. package/src/domain/shopping/models/index.d.ts +1 -0
  53. package/src/domain/shopping/models/line-item.d.ts +1 -0
  54. package/src/domain/shopping/models/order-blocked.d.ts +5 -0
  55. package/src/domain/shopping/models/order.d.ts +19 -0
  56. package/src/domain/shopping/models/payment-transaction.d.ts +19 -2
  57. package/src/domain/shopping/models/payment.d.ts +3 -1
  58. package/src/domain/shopping/models/recurrence/index.d.ts +3 -0
  59. package/src/domain/shopping/models/recurrence/shopping-recurrence-edition.d.ts +18 -0
  60. package/src/domain/shopping/models/recurrence/shopping-recurrence-error-log.d.ts +9 -0
  61. package/src/domain/shopping/models/recurrence/shopping-recurrence.d.ts +45 -0
  62. package/src/domain/shopping/models/shipping-method.d.ts +2 -0
  63. package/src/domain/shopping/models/types/index.d.ts +1 -0
  64. package/src/domain/shopping/models/types/line-item-recurrence.type.d.ts +2 -0
  65. package/src/domain/shopping/repositories/index.d.ts +1 -0
  66. package/src/domain/shopping/repositories/order-blocked.repository.d.ts +5 -0
  67. package/src/domain/shopping/repositories/recurrence/index.d.ts +3 -0
  68. package/src/domain/shopping/repositories/recurrence/shopping-recurrence-edition.repository.d.ts +4 -0
  69. package/src/domain/shopping/repositories/recurrence/shopping-recurrence-error-log.repository.d.ts +4 -0
  70. package/src/domain/shopping/repositories/recurrence/shopping-recurrence.repository.d.ts +9 -0
  71. package/src/domain/shopping/services/antifraud-card.service.d.ts +2 -0
  72. package/src/domain/shopping/types/card-info.type.d.ts +1 -0
  73. package/src/domain/shopping/types/checkout-paylod-request.type.d.ts +2 -7
  74. package/src/domain/shopping/types/create-recurrency-payload.type.d.ts +8 -0
  75. package/src/domain/shopping/types/index.d.ts +4 -0
  76. package/src/domain/shopping/types/mercado-pago-card.type.d.ts +14 -0
  77. package/src/domain/shopping/types/mercado-pago-credentials.type.d.ts +5 -0
  78. package/src/domain/shopping/types/pagarme-card.type.d.ts +9 -3
  79. package/src/domain/shopping/types/pagarme-credentials-v5.type.d.ts +4 -0
  80. package/src/domain/shopping/types/pagarme-credentials.type.d.ts +9 -3
  81. package/src/domain/shopping/types/payment-card-info.type.d.ts +6 -1
  82. package/src/domain/users/models/user-payment-method.d.ts +2 -0
  83. package/src/domain/users/models/user.d.ts +1 -0
  84. package/src/errors/enum/error.enum.d.ts +14 -0
  85. package/src/errors/enum/index.d.ts +1 -0
  86. package/src/errors/fraud-validation.error.d.ts +1 -1
  87. package/src/errors/index.d.ts +2 -0
  88. package/src/errors/invalid-checkout.error.d.ts +7 -0
  89. package/src/errors/not-found.error.d.ts +1 -0
  90. package/src/errors/payment.error.d.ts +1 -1
  91. package/src/infra/firebase/firestore/repositories/catalog/category-brand-firestore.repository.d.ts +7 -0
  92. package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -0
  93. package/src/infra/firebase/firestore/repositories/catalog/index.d.ts +1 -0
  94. package/src/infra/firebase/firestore/repositories/shop-settings/index.d.ts +1 -0
  95. package/src/infra/firebase/firestore/repositories/shop-settings/shop-configs-firestore.repository.d.ts +7 -0
  96. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +3 -0
  97. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.d.ts +1 -0
  98. package/src/infra/firebase/firestore/repositories/shopping/shopping-recurrence-edition-firestore.repository.d.ts +7 -0
  99. package/src/infra/firebase/firestore/repositories/shopping/shopping-recurrence-error-log-firestore.repository.d.ts +7 -0
  100. package/src/infra/firebase/firestore/repositories/shopping/shopping-recurrence-firestore.repository.d.ts +10 -0
  101. package/src/infra/hasura-graphql/models/index.d.ts +2 -0
  102. package/src/infra/hasura-graphql/models/product-catalog-hasura-graphql.d.ts +16 -0
  103. package/src/infra/hasura-graphql/models/product-stock-entry-hasura-graphql.d.ts +3 -0
  104. package/src/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +7 -0
  105. package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -0
  106. package/src/infra/hasura-graphql/repositories/catalog/category-product-hasura-graphql.repository.d.ts +2 -0
  107. package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +4 -0
  108. package/src/infra/hasura-graphql/repositories/catalog/product-catalog-hasura-graphql.repository.d.ts +22 -0
  109. package/src/infra/hasura-graphql/repositories/catalog/product-group-hasura-graphql.repository.d.ts +7 -0
  110. package/src/infra/hasura-graphql/repositories/catalog/product-price-log-hasura-graphql.repository.d.ts +7 -0
  111. package/src/infra/hasura-graphql/repositories/catalog/product-stock-entry-hasura-graphql.repository.d.ts +8 -0
  112. package/src/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +1 -0
  113. package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +1 -0
  114. package/src/infra/index.d.ts +1 -0
  115. package/src/infra/mercado-pago/adapters/index.d.ts +3 -0
  116. package/src/infra/mercado-pago/adapters/mercado-pago-base-axios.d.ts +11 -0
  117. package/src/infra/mercado-pago/adapters/mercado-pago-boleto-payment-axios.adapter.d.ts +8 -0
  118. package/src/infra/mercado-pago/adapters/mercado-pago-card-payment-axios.adapter.d.ts +22 -0
  119. package/src/infra/mercado-pago/adapters/mercado-pago-pix-payment-axios.adapter.d.ts +8 -0
  120. package/src/infra/mercado-pago/enums/index.d.ts +2 -0
  121. package/src/infra/mercado-pago/enums/mercado-pago-status-detail.enum.d.ts +33 -0
  122. package/src/infra/mercado-pago/enums/mercado-pago-status.enum.d.ts +10 -0
  123. package/src/infra/mercado-pago/helpers/index.d.ts +3 -0
  124. package/src/infra/mercado-pago/helpers/mercado-pago-errors.helper.d.ts +3 -0
  125. package/src/infra/mercado-pago/helpers/mercado-pago-request.helper.d.ts +60 -0
  126. package/src/infra/mercado-pago/helpers/mercado-pago-response.helper.d.ts +10 -0
  127. package/src/infra/mercado-pago/index.d.ts +4 -0
  128. package/src/infra/mercado-pago/types/index.d.ts +3 -0
  129. package/src/infra/mercado-pago/types/mercado-pago-request.type.d.ts +1 -0
  130. package/src/infra/mercado-pago/types/mercado-pago-response.type.d.ts +211 -0
  131. package/src/infra/mercado-pago/types/mercado-pago-status-detail.type.d.ts +2 -0
  132. package/src/infra/mercado-pago/types/mercado-pago-status.type.d.ts +2 -0
  133. package/src/infra/pagarme/adapters/helpers/index.d.ts +3 -0
  134. package/src/infra/pagarme/adapters/helpers/pagarme-blocked-order.helper.d.ts +7 -2
  135. package/src/infra/pagarme/adapters/helpers/pagarme-errors.helper.d.ts +3 -0
  136. package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +13 -0
  137. package/src/infra/pagarme/adapters/helpers/pagarme-v5-response.helper.d.ts +10 -0
  138. package/src/infra/pagarme/adapters/index.d.ts +2 -3
  139. package/src/infra/pagarme/adapters/v4/index.d.ts +3 -0
  140. package/src/infra/pagarme/adapters/{pagarme-bank-slip-payment-axios.adapter.d.ts → v4/pagarme-bank-slip-payment-axios.adapter.d.ts} +4 -4
  141. package/src/infra/pagarme/adapters/{pagarme-card-payment-axios.adapter.d.ts → v4/pagarme-card-payment-axios.adapter.d.ts} +7 -6
  142. package/src/infra/pagarme/adapters/{pagarme-pix-payment-axios.adapter.d.ts → v4/pagarme-pix-payment-axios.adapter.d.ts} +4 -4
  143. package/src/infra/pagarme/adapters/v5/index.d.ts +4 -0
  144. package/src/infra/pagarme/adapters/v5/pagarmev5-bank-slip-payment-axios.adapter.d.ts +11 -0
  145. package/src/infra/pagarme/adapters/v5/pagarmev5-base-axios.d.ts +11 -0
  146. package/src/infra/pagarme/adapters/v5/pagarmev5-card-payment-axios.adapter.d.ts +25 -0
  147. package/src/infra/pagarme/adapters/v5/pagarmev5-pix-payment-axios.adapter.d.ts +11 -0
  148. package/src/infra/pagarme/index.d.ts +1 -0
  149. package/src/infra/pagarme/types/index.d.ts +1 -0
  150. package/src/infra/pagarme/types/v5/index.d.ts +4 -0
  151. package/src/infra/pagarme/types/v5/pagarmev5-customer.type.d.ts +19 -0
  152. package/src/infra/pagarme/types/v5/pagarmev5-order-request-payload.type.d.ts +91 -0
  153. package/src/infra/pagarme/types/v5/pagarmev5-order-response.type.d.ts +241 -0
  154. package/src/infra/pagarme/types/v5/pagarmev5-postback-response.type.d.ts +11 -0
  155. package/src/utils/index.d.ts +3 -2
package/index.esm.js CHANGED
@@ -1,8 +1,10 @@
1
1
  import 'reflect-metadata';
2
2
  import { __decorate, __metadata } from 'tslib';
3
3
  import { plainToInstance, instanceToPlain, Type } from 'class-transformer';
4
- import { parseISO, format, startOfDay, endOfDay, subDays, addDays } from 'date-fns';
5
- export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
4
+ import { parseISO, startOfDay, endOfDay, addHours, subDays, format, addDays } from 'date-fns';
5
+ export { add, addBusinessDays, addDays, addHours, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
6
+ import { utcToZonedTime } from 'date-fns-tz';
7
+ export { formatInTimeZone } from 'date-fns-tz';
6
8
  import { compact, get, isNil, isArray, first, last, flatten, isString, omit, each, unset, isObject, isEmpty, isDate, isBoolean, isInteger, isNumber, isNaN as isNaN$1, set, chunk, sortBy } from 'lodash';
7
9
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
8
10
  import { debug } from 'debug';
@@ -36,6 +38,18 @@ var OrderBlockedType;
36
38
  OrderBlockedType["Boleto"] = "Boleto";
37
39
  })(OrderBlockedType || (OrderBlockedType = {}));
38
40
 
41
+ var OrderPaymentStatus;
42
+ (function (OrderPaymentStatus) {
43
+ OrderPaymentStatus["Em processamento"] = "processing";
44
+ OrderPaymentStatus["Autorizada"] = "authorized";
45
+ OrderPaymentStatus["Pago"] = "paid";
46
+ OrderPaymentStatus["Estornada"] = "refunded";
47
+ OrderPaymentStatus["Aguardando pagamento"] = "waiting_payment";
48
+ OrderPaymentStatus["Aguardando estorno"] = "pending_refund";
49
+ OrderPaymentStatus["Recusada/N\u00E3o autorizada"] = "refused";
50
+ OrderPaymentStatus["Chargedback"] = "chargedback";
51
+ })(OrderPaymentStatus || (OrderPaymentStatus = {}));
52
+
39
53
  var PagarmePaymentStatus;
40
54
  (function (PagarmePaymentStatus) {
41
55
  PagarmePaymentStatus["Em processamento"] = "processing";
@@ -48,6 +62,33 @@ var PagarmePaymentStatus;
48
62
  PagarmePaymentStatus["Chargedback"] = "chargedback";
49
63
  })(PagarmePaymentStatus || (PagarmePaymentStatus = {}));
50
64
 
65
+ var PagarMeV5PaymentStatus;
66
+ (function (PagarMeV5PaymentStatus) {
67
+ PagarMeV5PaymentStatus["Em processamento"] = "processing";
68
+ PagarMeV5PaymentStatus["Gerado"] = "generated";
69
+ PagarMeV5PaymentStatus["Visualizado"] = "viewed";
70
+ PagarMeV5PaymentStatus["Pago a menor"] = "underpaid";
71
+ PagarMeV5PaymentStatus["Pago a maior"] = "overpaid";
72
+ PagarMeV5PaymentStatus["Aguardando pagamento"] = "waiting_payment";
73
+ PagarMeV5PaymentStatus["Pago"] = "paid";
74
+ PagarMeV5PaymentStatus["Aguardando estorno"] = "pending_refund";
75
+ PagarMeV5PaymentStatus["Autorizada pendente de captura"] = "authorized_pending_capture";
76
+ PagarMeV5PaymentStatus["N\u00E3o autorizada"] = "not_authorized";
77
+ PagarMeV5PaymentStatus["Capturada"] = "captured";
78
+ PagarMeV5PaymentStatus["Aguardando captura"] = "waiting_capture";
79
+ PagarMeV5PaymentStatus["Com erro"] = "with_error";
80
+ PagarMeV5PaymentStatus["Estornado"] = "refunded";
81
+ PagarMeV5PaymentStatus["Cancelado"] = "voided";
82
+ PagarMeV5PaymentStatus["Falha"] = "failed";
83
+ })(PagarMeV5PaymentStatus || (PagarMeV5PaymentStatus = {}));
84
+ var PagarMeV5OrderStatus;
85
+ (function (PagarMeV5OrderStatus) {
86
+ PagarMeV5OrderStatus["Pendente"] = "pending";
87
+ PagarMeV5OrderStatus["Pago"] = "paid";
88
+ PagarMeV5OrderStatus["Cancelado"] = "canceled";
89
+ PagarMeV5OrderStatus["Falha"] = "failed";
90
+ })(PagarMeV5OrderStatus || (PagarMeV5OrderStatus = {}));
91
+
51
92
  var PaymentMethods;
52
93
  (function (PaymentMethods) {
53
94
  PaymentMethods["CARD"] = "card";
@@ -61,8 +102,16 @@ var PaymentProviders;
61
102
  PaymentProviders["PAGARME"] = "pagarMe";
62
103
  PaymentProviders["ADYEN"] = "adyen";
63
104
  PaymentProviders["GLAMPOINTS"] = "glampoints";
105
+ PaymentProviders["MERCADOPAGO"] = "mercadoPago";
64
106
  })(PaymentProviders || (PaymentProviders = {}));
65
107
 
108
+ var TransactionPaymentMethods;
109
+ (function (TransactionPaymentMethods) {
110
+ TransactionPaymentMethods["CARD"] = "credit_card";
111
+ TransactionPaymentMethods["BANKSLIP"] = "boleto";
112
+ TransactionPaymentMethods["PIX"] = "pix";
113
+ })(TransactionPaymentMethods || (TransactionPaymentMethods = {}));
114
+
66
115
  class BasePaymentMethodFactory {
67
116
  constructor(methods) {
68
117
  this.methods = methods;
@@ -87,6 +136,9 @@ class AntifraudProviderFactory {
87
136
  class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
88
137
  }
89
138
 
139
+ class MercadoPagoPaymentMethodFactory extends BasePaymentMethodFactory {
140
+ }
141
+
90
142
  class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
91
143
  }
92
144
 
@@ -639,6 +691,8 @@ var Shops;
639
691
  Shops["MENSMARKET"] = "mensmarket";
640
692
  Shops["GLAMSHOP"] = "Glamshop";
641
693
  Shops["GLAMPOINTS"] = "Glampoints";
694
+ Shops["GLAMBEAUTY"] = "Glambeauty";
695
+ Shops["ELLA"] = "ella";
642
696
  Shops["ALL"] = "ALL";
643
697
  })(Shops || (Shops = {}));
644
698
 
@@ -673,12 +727,36 @@ class Category extends BaseModel {
673
727
  image: null,
674
728
  };
675
729
  }
730
+ get glamBeautyImages() {
731
+ return this.images?.[Shops.GLAMBEAUTY]
732
+ ? this.images[Shops.GLAMBEAUTY]
733
+ : {
734
+ brandBanner: null,
735
+ brandBannerMobile: null,
736
+ image: null,
737
+ };
738
+ }
739
+ get ellaImages() {
740
+ return this.images?.[Shops.ELLA]
741
+ ? this.images[Shops.ELLA]
742
+ : {
743
+ brandBanner: null,
744
+ brandBannerMobile: null,
745
+ image: null,
746
+ };
747
+ }
676
748
  get glamMetadata() {
677
749
  return this.metadatas.find((metadata) => metadata.shop === Shops.GLAMSHOP);
678
750
  }
679
751
  get mensMetadata() {
680
752
  return this.metadatas.find((metadata) => metadata.shop === Shops.MENSMARKET);
681
753
  }
754
+ get glamBeautyMetadata() {
755
+ return this.metadatas.find((metadata) => metadata.shop === Shops.GLAMBEAUTY);
756
+ }
757
+ get ellaMetadata() {
758
+ return this.metadatas.find((metadata) => metadata.shop === Shops.ELLA);
759
+ }
682
760
  getMostRelevantByShop(shop) {
683
761
  return this.mostRelevants?.[shop] || [];
684
762
  }
@@ -697,6 +775,30 @@ __decorate([
697
775
  ], Category.prototype, "filters", void 0);
698
776
  registerClass('Category', Category);
699
777
 
778
+ class BrandCategory extends BaseModel {
779
+ get glamImages() {
780
+ return this.images?.[Shops.GLAMSHOP]
781
+ ? this.images[Shops.GLAMSHOP]
782
+ : {
783
+ brandBanner: null,
784
+ brandBannerMobile: null,
785
+ image: null,
786
+ };
787
+ }
788
+ get mensImages() {
789
+ return this.images?.[Shops.MENSMARKET]
790
+ ? this.images[Shops.MENSMARKET]
791
+ : {
792
+ brandBanner: null,
793
+ brandBannerMobile: null,
794
+ image: null,
795
+ };
796
+ }
797
+ static get identifiersFields() {
798
+ return ['id'];
799
+ }
800
+ }
801
+
700
802
  class CategoryCollectionChildren extends BaseModel {
701
803
  static get identifiersFields() {
702
804
  return ['collectionId', 'categoryId'];
@@ -770,6 +872,11 @@ class ProductReview extends BaseModel {
770
872
  return ['id'];
771
873
  }
772
874
  }
875
+ __decorate([
876
+ Type(resolveClass('Product')),
877
+ __metadata("design:type", Function)
878
+ ], ProductReview.prototype, "product", void 0);
879
+ registerClass('ProductReview', ProductReview);
773
880
 
774
881
  class ProductBase extends BaseModel {
775
882
  get evaluation() {
@@ -834,28 +941,6 @@ __decorate([
834
941
  __metadata("design:type", Object)
835
942
  ], ProductErrors.prototype, "product", void 0);
836
943
 
837
- class ProductStockNotification extends BaseModel {
838
- static get identifiersFields() {
839
- return ['id'];
840
- }
841
- }
842
-
843
- class Wishlist extends Category {
844
- static get identifiersFields() {
845
- return ['id'];
846
- }
847
- }
848
-
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
944
  var Where;
860
945
  (function (Where) {
861
946
  Where["EQUALS"] = "==";
@@ -882,6 +967,46 @@ var UpdateOptionActions;
882
967
  UpdateOptionActions["NULL"] = "null";
883
968
  })(UpdateOptionActions || (UpdateOptionActions = {}));
884
969
 
970
+ class ProductGroup extends BaseModel {
971
+ static get identifiersFields() {
972
+ return ['id'];
973
+ }
974
+ }
975
+
976
+ class ProductPriceLog extends BaseModel {
977
+ static get identifiersFields() {
978
+ return ['id'];
979
+ }
980
+ }
981
+
982
+ class ProductStockEntry extends BaseModel {
983
+ static get identifiersFields() {
984
+ return ['id'];
985
+ }
986
+ }
987
+
988
+ class ProductStockNotification extends BaseModel {
989
+ static get identifiersFields() {
990
+ return ['id'];
991
+ }
992
+ }
993
+
994
+ class Wishlist extends Category {
995
+ static get identifiersFields() {
996
+ return ['id'];
997
+ }
998
+ }
999
+
1000
+ class Buy2Win extends BaseModel {
1001
+ static get identifiersFields() {
1002
+ return ['id'];
1003
+ }
1004
+ }
1005
+ __decorate([
1006
+ Type(() => Category),
1007
+ __metadata("design:type", Array)
1008
+ ], Buy2Win.prototype, "categories", void 0);
1009
+
885
1010
  class CampaignDashboard extends BaseModel {
886
1011
  static get identifiersFields() {
887
1012
  return ['id'];
@@ -1568,8 +1693,38 @@ var OrderStatus;
1568
1693
  OrderStatus["ENTREGUE"] = "Entregue";
1569
1694
  OrderStatus["CANCELADO"] = "Cancelado";
1570
1695
  OrderStatus["PENDENTE_REENVIO"] = "Pendente reenvio";
1696
+ OrderStatus["AGUARDANDO_STOCK_REENVIO"] = "Aguardando stock para reenvio";
1571
1697
  })(OrderStatus || (OrderStatus = {}));
1572
1698
 
1699
+ var ShoppingRecurrenceCycle;
1700
+ (function (ShoppingRecurrenceCycle) {
1701
+ ShoppingRecurrenceCycle[ShoppingRecurrenceCycle["MONTHLY"] = 1] = "MONTHLY";
1702
+ ShoppingRecurrenceCycle[ShoppingRecurrenceCycle["BIMONTHLY"] = 2] = "BIMONTHLY";
1703
+ ShoppingRecurrenceCycle[ShoppingRecurrenceCycle["QUARTERLY"] = 3] = "QUARTERLY";
1704
+ })(ShoppingRecurrenceCycle || (ShoppingRecurrenceCycle = {}));
1705
+
1706
+ var ShoppingRecurrenceEditionStatus;
1707
+ (function (ShoppingRecurrenceEditionStatus) {
1708
+ ShoppingRecurrenceEditionStatus["SCHEDULED"] = "scheduled";
1709
+ ShoppingRecurrenceEditionStatus["PAUSED"] = "paused";
1710
+ ShoppingRecurrenceEditionStatus["SKIPPED"] = "skipped";
1711
+ ShoppingRecurrenceEditionStatus["PROCESSING"] = "processing";
1712
+ ShoppingRecurrenceEditionStatus["FINISHED"] = "finished";
1713
+ ShoppingRecurrenceEditionStatus["PAYMENT_FAIL"] = "payment_fail";
1714
+ ShoppingRecurrenceEditionStatus["AWAITING_PAYMENT"] = "awaiting_payment";
1715
+ ShoppingRecurrenceEditionStatus["STOCK_VALIDATION"] = "stock_validation";
1716
+ ShoppingRecurrenceEditionStatus["CANCELLED"] = "cancelled";
1717
+ })(ShoppingRecurrenceEditionStatus || (ShoppingRecurrenceEditionStatus = {}));
1718
+
1719
+ var ShoppingRecurrenceStatus;
1720
+ (function (ShoppingRecurrenceStatus) {
1721
+ ShoppingRecurrenceStatus["ACTIVE"] = "active";
1722
+ ShoppingRecurrenceStatus["PAUSED"] = "paused";
1723
+ ShoppingRecurrenceStatus["CANCELLED"] = "cancelled";
1724
+ ShoppingRecurrenceStatus["PAYMENT_FAILED"] = "payment_failed";
1725
+ ShoppingRecurrenceStatus["WAITING_STOCK"] = "waiting_stock";
1726
+ })(ShoppingRecurrenceStatus || (ShoppingRecurrenceStatus = {}));
1727
+
1573
1728
  class Order extends Checkout {
1574
1729
  }
1575
1730
  __decorate([
@@ -1583,6 +1738,44 @@ class OrderBlocked extends BaseModel {
1583
1738
  }
1584
1739
  }
1585
1740
 
1741
+ class ShoppingRecurrence extends BaseModel {
1742
+ static get identifiersFields() {
1743
+ return ['id'];
1744
+ }
1745
+ }
1746
+ __decorate([
1747
+ Type(() => User),
1748
+ __metadata("design:type", User)
1749
+ ], ShoppingRecurrence.prototype, "user", void 0);
1750
+ __decorate([
1751
+ Type(() => UserAddress),
1752
+ __metadata("design:type", UserAddress)
1753
+ ], ShoppingRecurrence.prototype, "shippingAddress", void 0);
1754
+ __decorate([
1755
+ Type(() => UserAddress),
1756
+ __metadata("design:type", UserAddress)
1757
+ ], ShoppingRecurrence.prototype, "billingAddress", void 0);
1758
+ __decorate([
1759
+ Type(() => ShippingMethod),
1760
+ __metadata("design:type", ShippingMethod)
1761
+ ], ShoppingRecurrence.prototype, "shipping", void 0);
1762
+ __decorate([
1763
+ Type(() => Coupon),
1764
+ __metadata("design:type", Coupon)
1765
+ ], ShoppingRecurrence.prototype, "coupon", void 0);
1766
+
1767
+ class ShoppingRecurrenceEdition extends BaseModel {
1768
+ static get identifiersFields() {
1769
+ return ['id'];
1770
+ }
1771
+ }
1772
+
1773
+ class ShoppingRecurrenceErrorLog extends BaseModel {
1774
+ static get identifiersFields() {
1775
+ return ['id'];
1776
+ }
1777
+ }
1778
+
1586
1779
  class CheckoutSubscription extends BaseModel {
1587
1780
  static get identifiersFields() {
1588
1781
  return ['id'];
@@ -1605,11 +1798,27 @@ __decorate([
1605
1798
  __metadata("design:type", Coupon)
1606
1799
  ], CheckoutSubscription.prototype, "coupon", void 0);
1607
1800
 
1801
+ var ErrorsCode;
1802
+ (function (ErrorsCode) {
1803
+ ErrorsCode["genericError"] = "generic-error";
1804
+ ErrorsCode["businessError"] = "business-error";
1805
+ ErrorsCode["invalidCheckoutError"] = "invalid-checkout";
1806
+ ErrorsCode["stockLimit"] = "stock-limit";
1807
+ ErrorsCode["stockOut"] = "stock-out";
1808
+ ErrorsCode["notFound"] = "not-found";
1809
+ ErrorsCode["fraudPreventionInternal"] = "fraud-prevention-internal";
1810
+ ErrorsCode["fraudPreventionExternal"] = "fraud-prevention-external";
1811
+ ErrorsCode["invalidCardError"] = "invalid-card-error";
1812
+ ErrorsCode["insufficientFundsError"] = "insufficient-funds-error";
1813
+ ErrorsCode["paymentNotAuthorizedError"] = "payment-not-authorized-error";
1814
+ ErrorsCode["paymentError"] = "payment-error";
1815
+ })(ErrorsCode || (ErrorsCode = {}));
1816
+
1608
1817
  class BusinessError extends CustomError {
1609
- constructor(message, additionalData, type = '') {
1818
+ constructor(message, additionalData, type) {
1610
1819
  super(message);
1611
1820
  this.additionalData = additionalData;
1612
- this.type = type;
1821
+ this.type = type || ErrorsCode.businessError;
1613
1822
  }
1614
1823
  }
1615
1824
 
@@ -1620,10 +1829,10 @@ class DuplicatedResultsError extends CustomError {
1620
1829
  }
1621
1830
 
1622
1831
  class FraudValidationError extends CustomError {
1623
- constructor(message, additionalData) {
1832
+ constructor(message, type, additionalData) {
1624
1833
  super(message);
1625
1834
  this.additionalData = additionalData;
1626
- this.type = 'antifraud';
1835
+ this.type = type;
1627
1836
  }
1628
1837
  }
1629
1838
 
@@ -1633,17 +1842,26 @@ class InvalidArgumentError extends CustomError {
1633
1842
  }
1634
1843
  }
1635
1844
 
1845
+ class InvalidCheckoutError extends CustomError {
1846
+ constructor(message, additionalData) {
1847
+ super(message);
1848
+ this.additionalData = additionalData;
1849
+ this.type = ErrorsCode.invalidCheckoutError;
1850
+ }
1851
+ }
1852
+
1636
1853
  class NotFoundError extends CustomError {
1637
1854
  constructor(message) {
1638
1855
  super(message);
1856
+ this.type = ErrorsCode.notFound;
1639
1857
  }
1640
1858
  }
1641
1859
 
1642
1860
  class PaymentError extends CustomError {
1643
- constructor(message, additionalData) {
1861
+ constructor(message, type, additionalData) {
1644
1862
  super(message);
1645
1863
  this.additionalData = additionalData;
1646
- this.type = 'payment';
1864
+ this.type = type;
1647
1865
  }
1648
1866
  }
1649
1867
 
@@ -1658,14 +1876,14 @@ class RequiredArgumentError extends CustomError {
1658
1876
  class StockLimitError extends BusinessError {
1659
1877
  constructor(message, additionalData) {
1660
1878
  super(message, additionalData);
1661
- this.type = 'stock-limit';
1879
+ this.type = ErrorsCode.stockLimit;
1662
1880
  }
1663
1881
  }
1664
1882
 
1665
1883
  class StockOutError extends BusinessError {
1666
1884
  constructor(message, additionalData) {
1667
1885
  super(message, additionalData);
1668
- this.type = 'stock-out';
1886
+ this.type = ErrorsCode.stockOut;
1669
1887
  }
1670
1888
  }
1671
1889
 
@@ -1682,7 +1900,7 @@ class AntifraudBankSlipService {
1682
1900
  type: 'Boleto',
1683
1901
  limiteRange: 'day',
1684
1902
  });
1685
- throw new FraudValidationError('Boleto não autorizado para cliente não assinante', {
1903
+ throw new FraudValidationError('Boleto não autorizado para cliente não assinante', ErrorsCode.fraudPreventionInternal, {
1686
1904
  checkoutId: checkout.id,
1687
1905
  userEmail: checkout.user.email,
1688
1906
  info: {
@@ -1700,19 +1918,58 @@ class AntifraudCardService {
1700
1918
  constructor(orderRepository, orderBlockedRepository) {
1701
1919
  this.orderRepository = orderRepository;
1702
1920
  this.orderBlockedRepository = orderBlockedRepository;
1703
- this.LIMIT_ORDERS_DAY = 2;
1704
- this.LIMIT_ORDERS_WEEK = 7;
1705
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
1921
+ this.LIMIT_ORDERS_DAY = null;
1922
+ this.LIMIT_ORDERS_WEEK = null;
1706
1923
  }
1707
1924
  async validate(checkout, card) {
1925
+ this.setLimitsByUserType(checkout.user.isSubscriber);
1708
1926
  await this.validateBlockedOrderAttempts(checkout, card);
1709
1927
  await this.validateDayAndWeekOrderLimits(checkout, card);
1710
1928
  return true;
1711
1929
  }
1930
+ setLimitsByUserType(isSubscriber) {
1931
+ this.LIMIT_ORDERS_DAY = {
1932
+ subscriber: {
1933
+ cpf: 4,
1934
+ email: 4,
1935
+ phone: 4,
1936
+ card: 4,
1937
+ zip: 4,
1938
+ },
1939
+ nonSubscriber: {
1940
+ cpf: 2,
1941
+ email: 2,
1942
+ phone: 2,
1943
+ card: 2,
1944
+ zip: 2,
1945
+ },
1946
+ };
1947
+ this.LIMIT_ORDERS_WEEK = {
1948
+ subscriber: {
1949
+ cpf: 12,
1950
+ email: 12,
1951
+ phone: 12,
1952
+ card: 12,
1953
+ zip: Infinity,
1954
+ },
1955
+ nonSubscriber: {
1956
+ cpf: 7,
1957
+ email: 7,
1958
+ phone: 7,
1959
+ card: 7,
1960
+ zip: Infinity,
1961
+ },
1962
+ };
1963
+ this.LIMIT_BLOCKED_ORDERS_DAY = isSubscriber ? 7 : 5;
1964
+ }
1965
+ getLimitsByUserType(type, isSubscriber) {
1966
+ const limits = type === 'day' ? this.LIMIT_ORDERS_DAY : this.LIMIT_ORDERS_WEEK;
1967
+ return isSubscriber ? limits['subscriber'] : limits['nonSubscriber'];
1968
+ }
1712
1969
  async validateBlockedOrderAttempts(checkout, card) {
1713
1970
  const isValid = await this.verifyBlockedOrderAttempts(checkout, card);
1714
1971
  if (!isValid) {
1715
- throw new FraudValidationError('Cliente com mais de 5 compras negadas/bloqueadas no dia', {
1972
+ throw new FraudValidationError(`Cliente com mais de ${this.LIMIT_BLOCKED_ORDERS_DAY} compras negadas/bloqueadas no dia`, ErrorsCode.fraudPreventionInternal, {
1716
1973
  checkoutId: checkout.id,
1717
1974
  userEmail: checkout.user.email,
1718
1975
  info: {
@@ -1726,7 +1983,7 @@ class AntifraudCardService {
1726
1983
  async validateDayAndWeekOrderLimits(checkout, card) {
1727
1984
  const isValid = await this.verifyDayAndWeekOrders(checkout, card);
1728
1985
  if (!isValid) {
1729
- throw new FraudValidationError('Cliente tentando comprar mais de 2 vezes no dia ou 7 vezes na semana', {
1986
+ throw new FraudValidationError('Cliente tentando comprar mais do que o permitido no dia/semana', ErrorsCode.fraudPreventionInternal, {
1730
1987
  checkoutId: checkout.id,
1731
1988
  userEmail: checkout.user.email,
1732
1989
  info: {
@@ -1745,7 +2002,7 @@ class AntifraudCardService {
1745
2002
  await this.createBlockedOrderRecord({
1746
2003
  checkout,
1747
2004
  card,
1748
- reason: 'More than 5 attempts have failed',
2005
+ reason: `More than ${this.LIMIT_BLOCKED_ORDERS_DAY} attempts have failed`,
1749
2006
  key: 'Failed attempts',
1750
2007
  period: 'day',
1751
2008
  });
@@ -1754,15 +2011,17 @@ class AntifraudCardService {
1754
2011
  return true;
1755
2012
  }
1756
2013
  getTodayDateRange() {
1757
- const day = `${format(new Date(), 'yyyy-MM-dd')}T00:00:00`;
1758
- const endOfDay = `${format(new Date(), 'yyyy-MM-dd')}T23:59:59`;
1759
- return { day, endOfDay };
2014
+ const timeZone = 'America/Sao_Paulo';
2015
+ const today = utcToZonedTime(new Date(), timeZone);
2016
+ const day = startOfDay(today);
2017
+ const endOfDay$1 = endOfDay(today);
2018
+ return { day: addHours(day, 3), endOfDay: addHours(endOfDay$1, 3) };
1760
2019
  }
1761
2020
  async getBlockedOrdersByMultipleCriteria(checkout, dateRange) {
1762
2021
  const { day, endOfDay } = dateRange;
1763
2022
  const dateFilter = [
1764
- { operator: Where.GTE, value: new Date(day) },
1765
- { operator: Where.LTE, value: new Date(endOfDay) },
2023
+ { operator: Where.GTE, value: day },
2024
+ { operator: Where.LTE, value: endOfDay },
1766
2025
  ];
1767
2026
  const [ordersBlockedWithCpf, ordersBlockedWithEmail, ordersBlockedWithCep, ordersBlockedWithPhone] = await Promise.all([
1768
2027
  this.getBlockedOrdersByCpf(checkout.user?.cpf, dateFilter),
@@ -1864,26 +2123,28 @@ class AntifraudCardService {
1864
2123
  }
1865
2124
  async validateDayOrderLimits(checkout, params) {
1866
2125
  const ordersPerDay = await this.validateOrdersByRange(params, this.getDateRange('day'));
2126
+ const limits = this.getLimitsByUserType('day', checkout.user.isSubscriber);
1867
2127
  return this.checkOrderLimitsAndBlock({
1868
2128
  checkout,
1869
2129
  orderCounts: ordersPerDay,
1870
- limit: this.LIMIT_ORDERS_DAY,
2130
+ limit: limits,
1871
2131
  period: 'day',
1872
2132
  });
1873
2133
  }
1874
2134
  async validateWeekOrderLimits(checkout, params) {
1875
2135
  const ordersPerWeek = await this.validateOrdersByRange(params, this.getDateRange('week'));
2136
+ const limits = this.getLimitsByUserType('week', checkout.user.isSubscriber);
1876
2137
  return this.checkOrderLimitsAndBlock({
1877
2138
  checkout,
1878
2139
  orderCounts: ordersPerWeek,
1879
- limit: this.LIMIT_ORDERS_WEEK,
2140
+ limit: limits,
1880
2141
  period: 'week',
1881
2142
  });
1882
2143
  }
1883
2144
  async checkOrderLimitsAndBlock(params) {
1884
2145
  const { checkout, orderCounts, limit, period } = params;
1885
2146
  for (const key in orderCounts) {
1886
- if (orderCounts[key] >= limit) {
2147
+ if (orderCounts[key] >= limit[key]) {
1887
2148
  await this.createBlockedOrderRecord({
1888
2149
  checkout,
1889
2150
  card: null,
@@ -2149,6 +2410,7 @@ var ShopPageName;
2149
2410
  ShopPageName["LP_GLAMQUEENS"] = "LP_GLAMQUEENS";
2150
2411
  ShopPageName["LP_INVITE"] = "LP_INVITE";
2151
2412
  ShopPageName["LP_LIVELO"] = "LP_LIVELO";
2413
+ ShopPageName["GLAM_NEW_HOME"] = "GLAM_NEW_HOME";
2152
2414
  })(ShopPageName || (ShopPageName = {}));
2153
2415
 
2154
2416
  class BeautyQuestionsHelper {
@@ -2214,16 +2476,100 @@ class Home extends BaseModel {
2214
2476
  }
2215
2477
  }
2216
2478
 
2479
+ class ShopConfigs extends BaseModel {
2480
+ static get identifiersFields() {
2481
+ return ['id'];
2482
+ }
2483
+ }
2484
+
2217
2485
  class ShopMenu extends BaseModel {
2218
2486
  static get identifiersFields() {
2219
2487
  return ['id'];
2220
2488
  }
2221
2489
  }
2222
2490
 
2491
+ var ShopPageSectionType;
2492
+ (function (ShopPageSectionType) {
2493
+ ShopPageSectionType["LIVE"] = "LIVE";
2494
+ ShopPageSectionType["CAROUSEL"] = "CAROUSEL";
2495
+ ShopPageSectionType["BANNER"] = "BANNER";
2496
+ ShopPageSectionType["INFOBARS"] = "INFOBARS";
2497
+ ShopPageSectionType["HIGHLIGHTS"] = "HIGHLIGHTS";
2498
+ ShopPageSectionType["SUBSCRIBER_INFO"] = "SUBSCRIBER_INFO";
2499
+ ShopPageSectionType["COLLECTION"] = "COLLECTION";
2500
+ ShopPageSectionType["BEAUTY_PROFILE_COLLECTION"] = "BEAUTY_PROFILE_COLLECTION";
2501
+ ShopPageSectionType["PLANS"] = "PLANS";
2502
+ ShopPageSectionType["SINGLE_PLAN"] = "SINGLE_PLAN";
2503
+ ShopPageSectionType["BRANDS"] = "BRANDS";
2504
+ ShopPageSectionType["NEWSLETTER"] = "NEWSLETTER";
2505
+ })(ShopPageSectionType || (ShopPageSectionType = {}));
2506
+
2507
+ /* eslint-disable max-lines-per-function */
2223
2508
  class ShopSettings extends BaseModel {
2224
2509
  static get identifiersFields() {
2225
2510
  return ['id'];
2226
2511
  }
2512
+ getPageSections(displayRules) {
2513
+ const now = new Date();
2514
+ return (Array.isArray(this.sections) ? this.sections : [])
2515
+ .map((section) => {
2516
+ // Filtra banners dentro de carrousel
2517
+ if (section.type === ShopPageSectionType.CAROUSEL && Array.isArray(section.banners)) {
2518
+ const filteredBanners = section.banners.filter((banner) => {
2519
+ // Filtra por displayRules
2520
+ const rulesMatch = banner.displayRules.length
2521
+ ? banner.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2522
+ : true;
2523
+ // Filtra por publishDate e expirationDate
2524
+ const publishOk = !banner.publishDate || now >= new Date(banner.publishDate);
2525
+ const expireOk = !banner.expirationDate || now <= new Date(banner.expirationDate);
2526
+ return rulesMatch && publishOk && expireOk;
2527
+ });
2528
+ return { ...section, banners: filteredBanners };
2529
+ }
2530
+ // Filtra highlights
2531
+ if (section.type === ShopPageSectionType.HIGHLIGHTS && Array.isArray(section.highlights)) {
2532
+ const filteredHighlights = section.highlights.filter((highlight) => {
2533
+ // Filtra por displayRules
2534
+ const rulesMatch = highlight.displayRules.length
2535
+ ? highlight.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2536
+ : true;
2537
+ return rulesMatch;
2538
+ });
2539
+ const sortedHighlights = !displayRules.beautyProfile
2540
+ ? filteredHighlights.sort((a, b) => (a.starred === b.starred ? 0 : a.starred ? -1 : 1))
2541
+ : filteredHighlights;
2542
+ return { ...section, highlights: sortedHighlights };
2543
+ }
2544
+ // Filtra collections
2545
+ if (section.type === ShopPageSectionType.COLLECTION) {
2546
+ const rulesMatch = section.displayRules.length
2547
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2548
+ : true;
2549
+ const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2550
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2551
+ return rulesMatch && publishOk && expireOk ? section : null;
2552
+ }
2553
+ // Filtra banners
2554
+ if (section.type === ShopPageSectionType.BANNER) {
2555
+ const rulesMatch = section.displayRules.length
2556
+ ? section.displayRules.some((rule) => Object.keys(rule).every((key) => rule[key] === displayRules[key]))
2557
+ : true;
2558
+ const publishOk = !section.publishDate || now >= new Date(section.publishDate);
2559
+ const expireOk = !section.expirationDate || now <= new Date(section.expirationDate);
2560
+ return rulesMatch && publishOk && expireOk ? section : null;
2561
+ }
2562
+ if (section.type === ShopPageSectionType.LIVE) {
2563
+ return section.active ? section : null;
2564
+ }
2565
+ if (section.type === ShopPageSectionType.PLANS || section.type === ShopPageSectionType.SINGLE_PLAN) {
2566
+ return displayRules.notSubscriber ? section : null;
2567
+ }
2568
+ // Demais seções retornam normalmente
2569
+ return section;
2570
+ })
2571
+ .filter(Boolean);
2572
+ }
2227
2573
  }
2228
2574
 
2229
2575
  class AdyenBlockedOrderHelper {
@@ -2235,14 +2581,14 @@ class AdyenBlockedOrderHelper {
2235
2581
  limiteRange: 'day',
2236
2582
  card: params.card,
2237
2583
  });
2238
- throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
2584
+ throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', ErrorsCode.paymentError, {
2239
2585
  checkoutId: params.checkout.id,
2240
2586
  userEmail: params.checkout.user.email,
2241
2587
  info: params.adyenResponse,
2242
2588
  });
2243
2589
  }
2244
2590
  static createPaymentError(checkout, errorInfo) {
2245
- return new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
2591
+ return new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', ErrorsCode.paymentError, {
2246
2592
  checkoutId: checkout.id,
2247
2593
  userEmail: checkout.user.email,
2248
2594
  info: errorInfo,
@@ -4701,6 +5047,17 @@ const withCrudFirestore = (MixinBase) => {
4701
5047
  };
4702
5048
  };
4703
5049
 
5050
+ class BrandCategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5051
+ constructor({ firestore, interceptors, }) {
5052
+ super({
5053
+ firestore,
5054
+ collectionName: 'brandsCategory',
5055
+ model: BrandCategory,
5056
+ interceptors,
5057
+ });
5058
+ }
5059
+ }
5060
+
4704
5061
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4705
5062
  constructor({ firestore, interceptors }) {
4706
5063
  super({
@@ -4776,6 +5133,9 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
4776
5133
  isChild(_id, _parentId) {
4777
5134
  return;
4778
5135
  }
5136
+ async getBrandsWithProducts() {
5137
+ return;
5138
+ }
4779
5139
  }
4780
5140
  __decorate([
4781
5141
  Log(),
@@ -4989,6 +5349,18 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
4989
5349
  }
4990
5350
  }
4991
5351
 
5352
+ class ShopConfigsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5353
+ constructor({ firestore, interceptors, cache, }) {
5354
+ super({
5355
+ firestore,
5356
+ collectionName: 'shopConfigs',
5357
+ model: ShopConfigs,
5358
+ interceptors,
5359
+ cache,
5360
+ });
5361
+ }
5362
+ }
5363
+
4992
5364
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4993
5365
  constructor({ firestore, interceptors, cache, }) {
4994
5366
  super({
@@ -5182,6 +5554,7 @@ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(with
5182
5554
  card,
5183
5555
  checkout,
5184
5556
  date: new Date(),
5557
+ gatewayInfo: params.gatewayInfo || {},
5185
5558
  }));
5186
5559
  }
5187
5560
  formatZip(zip) {
@@ -5203,6 +5576,74 @@ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFires
5203
5576
  }
5204
5577
  }
5205
5578
 
5579
+ class ShoppingRecurrenceEditionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5580
+ constructor({ firestore, interceptors, cache, }) {
5581
+ super({
5582
+ firestore,
5583
+ collectionName: 'shoppingRecurrenceEditions',
5584
+ model: ShoppingRecurrenceEdition,
5585
+ interceptors,
5586
+ cache,
5587
+ });
5588
+ }
5589
+ }
5590
+
5591
+ class ShoppingRecurrenceErrorLogFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5592
+ constructor({ firestore, interceptors, cache, }) {
5593
+ super({
5594
+ firestore,
5595
+ collectionName: 'shoppingRecurrenceErrorLogs',
5596
+ model: ShoppingRecurrenceErrorLog,
5597
+ interceptors,
5598
+ cache,
5599
+ });
5600
+ }
5601
+ }
5602
+
5603
+ class ShoppingRecurrenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5604
+ constructor({ firestore, interceptors, cache, }) {
5605
+ super({
5606
+ firestore,
5607
+ collectionName: 'shoppingRecurrences',
5608
+ model: ShoppingRecurrence,
5609
+ interceptors,
5610
+ cache,
5611
+ });
5612
+ }
5613
+ async findByUserId(userId) {
5614
+ const result = await this.find({
5615
+ filters: {
5616
+ user: {
5617
+ id: userId,
5618
+ },
5619
+ },
5620
+ });
5621
+ return result.data;
5622
+ }
5623
+ async findByUserIdAndStatus(userId, status) {
5624
+ const result = await this.find({
5625
+ filters: {
5626
+ user: {
5627
+ id: userId,
5628
+ },
5629
+ status,
5630
+ },
5631
+ });
5632
+ return result.data;
5633
+ }
5634
+ async findByUserAndShop(userId, shop) {
5635
+ const result = await this.find({
5636
+ filters: {
5637
+ user: {
5638
+ id: userId,
5639
+ },
5640
+ shop,
5641
+ },
5642
+ });
5643
+ return result.data;
5644
+ }
5645
+ }
5646
+
5206
5647
  class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
5207
5648
  constructor({ firestore, interceptors, cache, }) {
5208
5649
  super({
@@ -5786,6 +6227,9 @@ __decorate([
5786
6227
  __metadata("design:type", Product)
5787
6228
  ], KitProductHasuraGraphQL.prototype, "product", void 0);
5788
6229
 
6230
+ class ProductCatalogHasuraGraphQL extends Product {
6231
+ }
6232
+
5789
6233
  class ProductHasuraGraphQL extends Product {
5790
6234
  }
5791
6235
  __decorate([
@@ -5803,6 +6247,9 @@ __decorate([
5803
6247
  __metadata("design:type", Object)
5804
6248
  ], ProductErrorsHasuraGraphQL.prototype, "product", void 0);
5805
6249
 
6250
+ class ProductStockEntryHasuraGraphQL extends ProductStockEntry {
6251
+ }
6252
+
5806
6253
  class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5807
6254
  constructor({ endpoint, authOptions, interceptors, cache, }) {
5808
6255
  super({
@@ -6689,6 +7136,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6689
7136
  mostRelevants: mostRelevants || {
6690
7137
  [Shops.GLAMSHOP]: null,
6691
7138
  [Shops.MENSMARKET]: null,
7139
+ [Shops.GLAMBEAUTY]: null,
7140
+ [Shops.ELLA]: null,
6692
7141
  },
6693
7142
  images: images || {
6694
7143
  [Shops.GLAMSHOP]: {
@@ -6701,6 +7150,16 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6701
7150
  brandBannerMobile: null,
6702
7151
  image: null,
6703
7152
  },
7153
+ [Shops.GLAMBEAUTY]: {
7154
+ brandBanner: null,
7155
+ brandBannerMobile: null,
7156
+ image: null,
7157
+ },
7158
+ [Shops.ELLA]: {
7159
+ brandBanner: null,
7160
+ brandBannerMobile: null,
7161
+ image: null,
7162
+ },
6704
7163
  },
6705
7164
  });
6706
7165
  }
@@ -6874,6 +7333,19 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6874
7333
  categoryFilterRepository: this.categoryFilterRepository,
6875
7334
  });
6876
7335
  }
7336
+ async getBrandsWithProducts() {
7337
+ const fields = ['id', 'name', 'slug', 'brand_category', 'published', 'images'];
7338
+ const { brands_with_products_query: data, } = await this.query('brands_with_products_query', fields);
7339
+ return data.map((brand) => Category.toInstance({
7340
+ id: brand.id,
7341
+ name: brand.name,
7342
+ slug: brand.slug,
7343
+ brandCategory: brand.brand_category,
7344
+ shops: brand.shops,
7345
+ published: brand.published,
7346
+ images: brand.images,
7347
+ }));
7348
+ }
6877
7349
  }
6878
7350
  __decorate([
6879
7351
  Log(),
@@ -6988,10 +7460,30 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
6988
7460
  },
6989
7461
  });
6990
7462
  }
6991
- }
6992
-
6993
- const fieldsConfiguration$3 = [
6994
- 'id',
7463
+ async removeProductFromAllCategories(productId) {
7464
+ this.logger = DebugHelper.from(this, 'removeProductFromAllCategories');
7465
+ await this.mutation('delete_category_product', ['affected_rows'], {
7466
+ where: {
7467
+ type: 'category_product_bool_exp',
7468
+ required: true,
7469
+ value: { product_id: { _eq: productId } },
7470
+ },
7471
+ });
7472
+ }
7473
+ async removeCategoryFromAllProducts(categoryId) {
7474
+ this.logger = DebugHelper.from(this, 'removeCategoryFromAllProducts');
7475
+ await this.mutation('delete_category_product', ['affected_rows'], {
7476
+ where: {
7477
+ type: 'category_product_bool_exp',
7478
+ required: true,
7479
+ value: { category_id: { _eq: categoryId } },
7480
+ },
7481
+ });
7482
+ }
7483
+ }
7484
+
7485
+ const fieldsConfiguration$3 = [
7486
+ 'id',
6995
7487
  'title',
6996
7488
  'description',
6997
7489
  'slug',
@@ -7138,83 +7630,7 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7138
7630
  }
7139
7631
  }
7140
7632
 
7141
- class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7142
- constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7143
- super({
7144
- tableName: 'product_errors',
7145
- model: ProductErrorsHasuraGraphQL,
7146
- endpoint,
7147
- authOptions,
7148
- interceptors,
7149
- cache,
7150
- fields: [
7151
- {
7152
- productId: {
7153
- columnName: 'product_id',
7154
- to: (value) => +value,
7155
- from: (value) => value.toString(),
7156
- },
7157
- },
7158
- 'source',
7159
- 'error',
7160
- { createdAt: { columnName: 'created_at' } },
7161
- { updatedAt: { columnName: 'updated_at' } },
7162
- {
7163
- product: {
7164
- columnName: 'product',
7165
- foreignKeyColumn: { id: 'productId' },
7166
- fields: [
7167
- { id: { columnName: 'id', from: (value) => value.toString() } },
7168
- { productId: { columnName: 'main_product_id' } },
7169
- 'name',
7170
- 'published',
7171
- 'group',
7172
- 'validity',
7173
- { createdAt: { columnName: 'created_at' } },
7174
- { updatedAt: { columnName: 'updated_at' } },
7175
- ],
7176
- },
7177
- },
7178
- ],
7179
- });
7180
- this.productRepository = productRepository;
7181
- }
7182
- async get(params) {
7183
- const result = await super.get(params);
7184
- if (result instanceof VariantHasuraGraphQL) {
7185
- const product = await this.productRepository.get({ id: result.productId.toString() });
7186
- result.product.name = product.name;
7187
- result.product.group = product.group;
7188
- }
7189
- return result;
7190
- }
7191
- async find(params) {
7192
- const result = await super.find(params);
7193
- const variantsWithNoData = result.data.filter((item) => item.product instanceof VariantHasuraGraphQL &&
7194
- (isEmpty(item.product.name) || isEmpty(item.product.group) || isEmpty(item.product)));
7195
- if (variantsWithNoData.length > 0) {
7196
- const { data: products } = await this.productRepository.find({
7197
- filters: {
7198
- id: {
7199
- operator: Where.IN,
7200
- value: Array.from(new Set(variantsWithNoData.map((item) => item.product.productId?.toString()))),
7201
- },
7202
- },
7203
- });
7204
- products.forEach((product) => {
7205
- result.data
7206
- .filter((variant) => variant.product.productId?.toString() === product.id.toString())
7207
- .forEach((variant) => {
7208
- variant.product.name = product.name;
7209
- variant.product.group = product.group;
7210
- });
7211
- });
7212
- }
7213
- return result;
7214
- }
7215
- }
7216
-
7217
- const commonFields = [
7633
+ const commonFields$1 = [
7218
7634
  {
7219
7635
  id: {
7220
7636
  columnName: 'id',
@@ -7294,6 +7710,12 @@ const commonFields = [
7294
7710
  to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7295
7711
  },
7296
7712
  },
7713
+ {
7714
+ imagesCard: {
7715
+ columnName: 'images_card',
7716
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7717
+ },
7718
+ },
7297
7719
  'name',
7298
7720
  {
7299
7721
  price: {
@@ -7355,7 +7777,6 @@ const commonFields = [
7355
7777
  'weight',
7356
7778
  'gender',
7357
7779
  { intGender: { columnName: 'int_gender' } },
7358
- // { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
7359
7780
  { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7360
7781
  { isKit: { columnName: 'is_kit' } },
7361
7782
  { createdAt: { columnName: 'created_at' } },
@@ -7372,187 +7793,746 @@ const commonFields = [
7372
7793
  },
7373
7794
  },
7374
7795
  'group',
7796
+ { groupId: { columnName: 'group_id' } },
7375
7797
  'validity',
7376
7798
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7377
7799
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7378
7800
  { daysOfUse: { columnName: 'days_of_use' } },
7801
+ { showVariants: { columnName: 'show_variants' } },
7802
+ { variantSlug: { columnName: 'variant_slug' } },
7379
7803
  ];
7380
- const fieldsConfiguration$2 = [
7381
- ...commonFields,
7382
- {
7383
- categories: {
7384
- columnName: 'categories',
7385
- fields: ['category_id'],
7386
- bindPersistData: (value) => ({
7387
- categories: { data: value.map((category) => ({ category_id: +category })) },
7388
- }),
7389
- to: (categories) => categories.map((categoryId) => +categoryId),
7390
- from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
7391
- },
7392
- },
7393
- {
7394
- kitProducts: {
7395
- columnName: 'kit_products',
7396
- foreignKeyColumn: { productId: 'id' },
7397
- fields: [
7398
- { productId: { columnName: 'product_id' } },
7399
- { kitProductId: { columnName: 'kit_product_id' } },
7400
- 'quantity',
7401
- { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
7402
- ],
7403
- },
7404
- },
7405
- {
7406
- reviews: {
7407
- columnName: 'reviews',
7408
- foreignKeyColumn: { product_id: 'id' },
7409
- fields: [
7410
- 'id',
7411
- 'shop',
7412
- 'rate',
7413
- 'author',
7414
- 'email',
7415
- 'location',
7416
- 'review',
7417
- 'status',
7418
- 'title',
7419
- { personId: { columnName: 'person_id' } },
7420
- 'points',
7421
- { orderId: { columnName: 'order_id' } },
7422
- { createdAt: { columnName: 'created_at' } },
7423
- { updatedAt: { columnName: 'updated_at' } },
7424
- ],
7425
- },
7426
- },
7427
- {
7428
- metadata: {
7429
- columnName: 'metadata',
7430
- fields: ['title', 'description'],
7431
- bindPersistData: (value) => ({
7432
- metadata: { data: value },
7433
- }),
7434
- },
7435
- },
7436
- {
7437
- variants: {
7438
- columnName: 'variants',
7439
- foreignKeyColumn: { product_id: 'id' },
7440
- fields: [
7441
- 'id',
7442
- 'ean',
7443
- 'grade',
7444
- 'price',
7445
- 'published',
7446
- 'stock',
7447
- { tagsCollection: { columnName: 'tags_collection' } },
7448
- { tagsProfile: { columnName: 'tags_profile' } },
7449
- ],
7450
- },
7451
- },
7452
- ];
7453
- class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7454
- get reviewsFields() {
7455
- return [
7456
- 'id',
7457
- 'shop',
7458
- 'rate',
7459
- 'author',
7460
- 'email',
7461
- 'location',
7462
- 'review',
7463
- 'status',
7464
- 'title',
7465
- { personId: { columnName: 'person_id' } },
7466
- 'points',
7467
- { orderId: { columnName: 'order_id' } },
7468
- { createdAt: { columnName: 'created_at' } },
7469
- { updatedAt: { columnName: 'updated_at' } },
7470
- ];
7471
- }
7804
+ class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
7472
7805
  constructor({ endpoint, authOptions, interceptors, cache, }) {
7473
7806
  super({
7474
- tableName: 'product',
7475
- model: ProductHasuraGraphQL,
7807
+ tableName: 'product_catalog',
7808
+ model: ProductCatalogHasuraGraphQL,
7476
7809
  endpoint,
7477
7810
  authOptions,
7478
7811
  interceptors,
7479
- fields: fieldsConfiguration$2,
7812
+ fields: commonFields$1,
7480
7813
  cache,
7481
7814
  });
7482
- this.bindReviewToModel = (plain) => ProductReview.toInstance({
7483
- ...is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])),
7484
- createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at,
7485
- updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at,
7486
- personId: plain.person_id,
7487
- orderId: plain.order_id,
7488
- });
7489
- this.bindReviewToHasura = (review) => ({
7490
- ...is(omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])),
7491
- person_id: review.personId,
7492
- order_id: review.orderId,
7493
- });
7494
- }
7495
- async create(params) {
7496
- const { metadata, ...data } = params;
7497
- const product = await super.create(omit({ ...data, metadata: metadata || { description: null, title: null } }, ['reviews']));
7498
- try {
7499
- product.reviews = data.reviews && (await this.updateReviews(+product.id, data));
7500
- }
7501
- catch (error) {
7502
- await this.delete({ id: product.id });
7503
- throw error;
7504
- }
7505
- return product;
7506
- }
7507
- async get(identifiers, options) {
7508
- const product = Number.isNaN(+identifiers.id)
7509
- ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, options))
7510
- .data?.[0]
7511
- : await super.get(identifiers, options);
7512
- if (product.productId)
7513
- throw new NotFoundError('Product not found, it is a variant');
7514
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
7515
- return product;
7516
- }
7517
- async find(params, optionsParams) {
7518
- const { filters, fields, ...options } = params || {};
7519
- const bindFields = fields ||
7520
- this.fields
7521
- .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7522
- .filter((field) => field !== 'reviews' && field !== 'categories');
7523
- if (options.options?.minimal?.includes('price'))
7524
- options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7525
- if (options.options?.maximum?.includes('price'))
7526
- options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7527
- options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7528
- options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7529
- return super.find({
7530
- ...options,
7531
- filters: { ...filters, productId: { operator: Where.ISNULL } },
7532
- fields: [
7533
- ...bindFields,
7534
- ...(bindFields.includes('price')
7535
- ? [
7536
- 'subscriberPrice',
7537
- 'subscriberDiscountPercentage',
7538
- 'fullPrice',
7539
- ]
7540
- : []),
7541
- ],
7542
- }, optionsParams);
7543
7815
  }
7544
- async getBySlug(slug, options) {
7816
+ async get({ id }, options) {
7545
7817
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7546
- const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
7818
+ const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
7547
7819
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7548
7820
  if (cachedData) {
7549
7821
  this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7550
7822
  return this.model.toInstance(deserialize(cachedData));
7551
7823
  }
7552
7824
  }
7553
- const result = await this.find({
7825
+ const product = await super
7826
+ .find({
7827
+ filters: {
7828
+ id,
7829
+ },
7830
+ limits: {
7831
+ limit: 1,
7832
+ },
7833
+ })
7834
+ .then((res) => res.data.at(0));
7835
+ if (!product)
7836
+ throw new NotFoundError(`Product not found`);
7837
+ if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7838
+ const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
7839
+ await this.cache.cacheAdapter.set({
7840
+ key: cacheKey,
7841
+ data: serialize(product),
7842
+ expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7843
+ });
7844
+ this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7845
+ }
7846
+ return product;
7847
+ }
7848
+ async getByEAN(EAN, options) {
7849
+ if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7850
+ const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7851
+ const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7852
+ if (cachedData) {
7853
+ this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7854
+ return this.model.toInstance(deserialize(cachedData));
7855
+ }
7856
+ }
7857
+ const product = await super
7858
+ .find({
7859
+ filters: {
7860
+ EAN,
7861
+ },
7862
+ limits: {
7863
+ limit: 1,
7864
+ },
7865
+ })
7866
+ .then((res) => res.data.at(0));
7867
+ if (!product)
7868
+ return null;
7869
+ RoundProductPricesHelper.roundProductPrices(product);
7870
+ if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7871
+ const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7872
+ await this.cache.cacheAdapter.set({
7873
+ key: cacheKey,
7874
+ data: serialize(product),
7875
+ expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7876
+ });
7877
+ this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7878
+ }
7879
+ return product;
7880
+ }
7881
+ async find(params, optionsParams) {
7882
+ const { filters, fields, ...options } = params || {};
7883
+ const bindFields = fields ||
7884
+ this.fields
7885
+ .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7886
+ .filter((field) => field !== 'reviews' && field !== 'categories');
7887
+ if (options.options?.minimal?.includes('price'))
7888
+ options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7889
+ if (options.options?.maximum?.includes('price'))
7890
+ options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7891
+ options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7892
+ options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7893
+ return super.find({
7894
+ ...options,
7895
+ filters: { ...filters },
7896
+ fields: [
7897
+ ...bindFields,
7898
+ ...(bindFields.includes('price')
7899
+ ? [
7900
+ 'subscriberPrice',
7901
+ 'subscriberDiscountPercentage',
7902
+ 'fullPrice',
7903
+ ]
7904
+ : []),
7905
+ ],
7906
+ }, optionsParams);
7907
+ }
7908
+ async findCatalog(params, mainGender, options) {
7909
+ const result = await this.find({
7910
+ ...params,
7911
+ filters: { ...params.filters, published: true },
7912
+ orderBy: {
7913
+ hasStock: 'desc',
7914
+ ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
7915
+ ...omit(params.orderBy, ['hasStock', 'intGender']),
7916
+ },
7917
+ }, options);
7918
+ return result;
7919
+ }
7920
+ }
7921
+ __decorate([
7922
+ Log(),
7923
+ __metadata("design:type", Function),
7924
+ __metadata("design:paramtypes", [Object, Object, Object]),
7925
+ __metadata("design:returntype", Promise)
7926
+ ], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
7927
+
7928
+ class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7929
+ constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7930
+ super({
7931
+ tableName: 'product_errors',
7932
+ model: ProductErrorsHasuraGraphQL,
7933
+ endpoint,
7934
+ authOptions,
7935
+ interceptors,
7936
+ cache,
7937
+ fields: [
7938
+ {
7939
+ productId: {
7940
+ columnName: 'product_id',
7941
+ to: (value) => +value,
7942
+ from: (value) => value.toString(),
7943
+ },
7944
+ },
7945
+ 'source',
7946
+ 'error',
7947
+ { createdAt: { columnName: 'created_at' } },
7948
+ { updatedAt: { columnName: 'updated_at' } },
7949
+ {
7950
+ product: {
7951
+ columnName: 'product',
7952
+ foreignKeyColumn: { id: 'productId' },
7953
+ fields: [
7954
+ { id: { columnName: 'id', from: (value) => value.toString() } },
7955
+ { productId: { columnName: 'main_product_id' } },
7956
+ 'name',
7957
+ 'published',
7958
+ 'group',
7959
+ 'validity',
7960
+ { createdAt: { columnName: 'created_at' } },
7961
+ { updatedAt: { columnName: 'updated_at' } },
7962
+ ],
7963
+ },
7964
+ },
7965
+ ],
7966
+ });
7967
+ this.productRepository = productRepository;
7968
+ }
7969
+ async get(params) {
7970
+ const result = await super.get(params);
7971
+ if (result instanceof VariantHasuraGraphQL) {
7972
+ const product = await this.productRepository.get({ id: result.productId.toString() });
7973
+ result.product.name = product.name;
7974
+ result.product.group = product.group;
7975
+ }
7976
+ return result;
7977
+ }
7978
+ async find(params) {
7979
+ const result = await super.find(params);
7980
+ const variantsWithNoData = result.data.filter((item) => item.product instanceof VariantHasuraGraphQL &&
7981
+ (isEmpty(item.product.name) || isEmpty(item.product.group) || isEmpty(item.product)));
7982
+ if (variantsWithNoData.length > 0) {
7983
+ const { data: products } = await this.productRepository.find({
7984
+ filters: {
7985
+ id: {
7986
+ operator: Where.IN,
7987
+ value: Array.from(new Set(variantsWithNoData.map((item) => item.product.productId?.toString()))),
7988
+ },
7989
+ },
7990
+ });
7991
+ products.forEach((product) => {
7992
+ result.data
7993
+ .filter((variant) => variant.product.productId?.toString() === product.id.toString())
7994
+ .forEach((variant) => {
7995
+ variant.product.name = product.name;
7996
+ variant.product.group = product.group;
7997
+ });
7998
+ });
7999
+ }
8000
+ return result;
8001
+ }
8002
+ }
8003
+
8004
+ class ProductGroupHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8005
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
8006
+ super({
8007
+ tableName: 'group',
8008
+ model: ProductGroup,
8009
+ endpoint,
8010
+ authOptions,
8011
+ interceptors,
8012
+ fields: [
8013
+ {
8014
+ id: {
8015
+ columnName: 'id',
8016
+ to: (value) => +value,
8017
+ from: (value) => value.toString(),
8018
+ },
8019
+ },
8020
+ 'name',
8021
+ 'description',
8022
+ { markupMin: { columnName: 'markup_min' } },
8023
+ { markupWithoutCompetitor: { columnName: 'markup_without_competitor' } },
8024
+ { discountCompetitor: { columnName: 'discount_competitor' } },
8025
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
8026
+ { dynamicPrecification: { columnName: 'dynamic_precification' } },
8027
+ { createdAt: { columnName: 'created_at' } },
8028
+ { updatedAt: { columnName: 'updated_at' } },
8029
+ ],
8030
+ cache,
8031
+ });
8032
+ }
8033
+ }
8034
+
8035
+ const commonFields = [
8036
+ {
8037
+ id: {
8038
+ columnName: 'id',
8039
+ to: (value) => +value,
8040
+ from: (value) => value.toString(),
8041
+ },
8042
+ },
8043
+ { firestoreId: { columnName: 'firestore_id' } },
8044
+ { productId: { columnName: 'main_product_id' } },
8045
+ { CEST: { columnName: 'cest' } },
8046
+ { EAN: { columnName: 'ean' } },
8047
+ { NCM: { columnName: 'ncm' } },
8048
+ 'brand',
8049
+ { costPrice: { columnName: 'cost_price' } },
8050
+ {
8051
+ description: {
8052
+ columnName: 'description',
8053
+ from: (description, data) => ({
8054
+ description,
8055
+ differentials: data.differentials,
8056
+ whoMustUse: data.who_must_use,
8057
+ howToUse: data.how_to_use,
8058
+ brand: data.brand_description,
8059
+ ingredients: data.ingredients,
8060
+ purpose: data.purpose,
8061
+ }),
8062
+ bindFindFilter: (filters) => {
8063
+ return {
8064
+ ...(filters?.description && { description: filters.description }),
8065
+ ...(filters.differentials && { differentials: filters.differentials }),
8066
+ ...(filters.whoMustUse && {
8067
+ who_must_use: filters.whoMustUse,
8068
+ }),
8069
+ ...(filters.howToUse && {
8070
+ how_to_use: filters.howToUse,
8071
+ }),
8072
+ ...(filters.brand && {
8073
+ brand_description: filters.brand,
8074
+ }),
8075
+ ...(filters.ingredients && {
8076
+ ingredients: filters.ingredients,
8077
+ }),
8078
+ ...(filters.purpose && {
8079
+ purpose: filters.purpose,
8080
+ }),
8081
+ };
8082
+ },
8083
+ bindPersistData: (descriptionData) => ({
8084
+ ...(descriptionData?.description && { description: descriptionData.description }),
8085
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8086
+ ...(descriptionData.whoMustUse && {
8087
+ who_must_use: descriptionData.whoMustUse,
8088
+ }),
8089
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8090
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8091
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8092
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8093
+ }),
8094
+ },
8095
+ },
8096
+ { differentials: { columnName: 'differentials' } },
8097
+ { whoMustUse: { columnName: 'who_must_use' } },
8098
+ { howToUse: { columnName: 'how_to_use' } },
8099
+ { brandDescription: { columnName: 'brand_description' } },
8100
+ { ingredients: { columnName: 'ingredients' } },
8101
+ { purpose: { columnName: 'purpose' } },
8102
+ { hasVariants: { columnName: 'has_variants' } },
8103
+ {
8104
+ images: {
8105
+ columnName: 'images',
8106
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8107
+ },
8108
+ },
8109
+ {
8110
+ miniatures: {
8111
+ columnName: 'miniatures',
8112
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8113
+ },
8114
+ },
8115
+ {
8116
+ imagesCard: {
8117
+ columnName: 'images_card',
8118
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8119
+ },
8120
+ },
8121
+ 'name',
8122
+ {
8123
+ price: {
8124
+ columnName: 'price',
8125
+ from: (price, data) => ({
8126
+ price,
8127
+ fullPrice: data.full_price,
8128
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
8129
+ fullPriceDiscountPercentage: data.full_price_discount_percentage,
8130
+ subscriberPrice: data.subscriber_price,
8131
+ }),
8132
+ bindFindFilter: (filters) => {
8133
+ return {
8134
+ ...((filters?.price || filters?.price === 0) && { price: filters.price }),
8135
+ ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
8136
+ ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
8137
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
8138
+ }),
8139
+ ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
8140
+ subscriber_price: filters.subscriberPrice,
8141
+ }),
8142
+ ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
8143
+ full_price_discount_percentage: filters.fullPriceDiscountPercentage,
8144
+ }),
8145
+ };
8146
+ },
8147
+ bindPersistData: (priceData) => ({
8148
+ ...(priceData?.price >= 0 && { price: priceData.price }),
8149
+ ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
8150
+ ...(priceData.subscriberDiscountPercentage >= 0 && {
8151
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
8152
+ }),
8153
+ ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
8154
+ ...(priceData.fullPriceDiscountPercentage >= 0 && {
8155
+ full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
8156
+ }),
8157
+ }),
8158
+ },
8159
+ },
8160
+ { fullPrice: { columnName: 'full_price' } },
8161
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
8162
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
8163
+ { subscriberPrice: { columnName: 'subscriber_price' } },
8164
+ 'published',
8165
+ 'outlet',
8166
+ 'label',
8167
+ 'sku',
8168
+ {
8169
+ stock: {
8170
+ columnName: 'stock',
8171
+ from: (quantity) => ({ quantity }),
8172
+ to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
8173
+ },
8174
+ },
8175
+ { hasStock: { columnName: 'has_stock' } },
8176
+ 'slug',
8177
+ 'type',
8178
+ 'video',
8179
+ 'weight',
8180
+ 'gender',
8181
+ { intGender: { columnName: 'int_gender' } },
8182
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8183
+ { isKit: { columnName: 'is_kit' } },
8184
+ { createdAt: { columnName: 'created_at' } },
8185
+ { updatedAt: { columnName: 'updated_at' } },
8186
+ { rate: { columnName: 'rating' } },
8187
+ { reviewsTotal: { columnName: 'reviews_total' } },
8188
+ { shoppingCount: { columnName: 'shopping_count' } },
8189
+ { categoryId: { columnName: 'category_id' } },
8190
+ {
8191
+ category: {
8192
+ columnName: 'category',
8193
+ foreignKeyColumn: { id: 'categoryId' },
8194
+ fields: ['id', 'name', 'reference', 'slug'],
8195
+ },
8196
+ },
8197
+ 'group',
8198
+ { groupId: { columnName: 'group_id' } },
8199
+ 'validity',
8200
+ { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
8201
+ { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
8202
+ { tagsSupply: { columnName: 'tags_supply', type: HasuraGraphQLColumnType.Jsonb } },
8203
+ { daysOfUse: { columnName: 'days_of_use' } },
8204
+ { showVariants: { columnName: 'show_variants' } },
8205
+ { variantSlug: { columnName: 'variant_slug' } },
8206
+ { caixariaMinima: { columnName: 'caixaria_minima', type: HasuraGraphQLColumnType.Jsonb } },
8207
+ 'suppliers',
8208
+ 'curve',
8209
+ ];
8210
+ const fieldsConfiguration$2 = [
8211
+ ...commonFields,
8212
+ {
8213
+ categories: {
8214
+ columnName: 'categories',
8215
+ fields: ['category_id'],
8216
+ bindPersistData: (value) => ({
8217
+ categories: { data: value.map((category) => ({ category_id: +category })) },
8218
+ }),
8219
+ to: (categories) => categories.map((categoryId) => +categoryId),
8220
+ from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
8221
+ },
8222
+ },
8223
+ {
8224
+ kitProducts: {
8225
+ columnName: 'kit_products',
8226
+ foreignKeyColumn: { productId: 'id' },
8227
+ fields: [
8228
+ { productId: { columnName: 'product_id' } },
8229
+ { kitProductId: { columnName: 'kit_product_id' } },
8230
+ 'quantity',
8231
+ { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
8232
+ ],
8233
+ },
8234
+ },
8235
+ {
8236
+ reviews: {
8237
+ columnName: 'reviews',
8238
+ foreignKeyColumn: { product_id: 'id' },
8239
+ fields: [
8240
+ 'id',
8241
+ 'shop',
8242
+ 'rate',
8243
+ 'author',
8244
+ 'email',
8245
+ 'location',
8246
+ 'review',
8247
+ 'status',
8248
+ 'title',
8249
+ { personId: { columnName: 'person_id' } },
8250
+ 'points',
8251
+ { orderId: { columnName: 'order_id' } },
8252
+ { createdAt: { columnName: 'created_at' } },
8253
+ { updatedAt: { columnName: 'updated_at' } },
8254
+ ],
8255
+ },
8256
+ },
8257
+ {
8258
+ metadata: {
8259
+ columnName: 'metadata',
8260
+ fields: ['title', 'description'],
8261
+ bindPersistData: (value) => ({
8262
+ metadata: { data: value },
8263
+ }),
8264
+ },
8265
+ },
8266
+ {
8267
+ variants: {
8268
+ columnName: 'variants',
8269
+ foreignKeyColumn: { product_id: 'id' },
8270
+ fields: [
8271
+ 'id',
8272
+ 'name',
8273
+ 'ean',
8274
+ 'sku',
8275
+ {
8276
+ description: {
8277
+ columnName: 'description',
8278
+ from: (description, data) => ({
8279
+ description,
8280
+ differentials: data.differentials,
8281
+ whoMustUse: data.who_must_use,
8282
+ howToUse: data.how_to_use,
8283
+ brand: data.brand_description,
8284
+ ingredients: data.ingredients,
8285
+ purpose: data.purpose,
8286
+ }),
8287
+ bindFindFilter: (filters) => {
8288
+ return {
8289
+ ...(filters?.description && { description: filters.description }),
8290
+ ...(filters.differentials && { differentials: filters.differentials }),
8291
+ ...(filters.whoMustUse && {
8292
+ who_must_use: filters.whoMustUse,
8293
+ }),
8294
+ ...(filters.howToUse && {
8295
+ how_to_use: filters.howToUse,
8296
+ }),
8297
+ ...(filters.brand && {
8298
+ brand_description: filters.brand,
8299
+ }),
8300
+ ...(filters.ingredients && {
8301
+ ingredients: filters.ingredients,
8302
+ }),
8303
+ ...(filters.purpose && {
8304
+ purpose: filters.purpose,
8305
+ }),
8306
+ };
8307
+ },
8308
+ bindPersistData: (descriptionData) => ({
8309
+ ...(descriptionData?.description && { description: descriptionData.description }),
8310
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8311
+ ...(descriptionData.whoMustUse && {
8312
+ who_must_use: descriptionData.whoMustUse,
8313
+ }),
8314
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8315
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8316
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8317
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8318
+ }),
8319
+ },
8320
+ },
8321
+ { differentials: { columnName: 'differentials' } },
8322
+ { whoMustUse: { columnName: 'who_must_use' } },
8323
+ { howToUse: { columnName: 'how_to_use' } },
8324
+ { brandDescription: { columnName: 'brand_description' } },
8325
+ { ingredients: { columnName: 'ingredients' } },
8326
+ { purpose: { columnName: 'purpose' } },
8327
+ {
8328
+ grade: {
8329
+ columnName: 'grade',
8330
+ type: HasuraGraphQLColumnType.Jsonb,
8331
+ },
8332
+ },
8333
+ {
8334
+ price: {
8335
+ columnName: 'price',
8336
+ from: (price, data) => ({
8337
+ price,
8338
+ fullPrice: data.full_price,
8339
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
8340
+ subscriberPrice: data.subscriber_price,
8341
+ fullPriceDiscountPercentage: data.full_price_discount_percentage,
8342
+ }),
8343
+ bindPersistData: (priceData) => ({
8344
+ ...((priceData?.price || 0) >= 0 && { price: priceData.price }),
8345
+ ...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
8346
+ ...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
8347
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
8348
+ }),
8349
+ ...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
8350
+ ...(priceData.fullPriceDiscountPercentage >= 0 && {
8351
+ full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
8352
+ }),
8353
+ }),
8354
+ },
8355
+ },
8356
+ { fullPrice: { columnName: 'full_price' } },
8357
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
8358
+ { subscriberPrice: { columnName: 'subscriber_price' } },
8359
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
8360
+ 'published',
8361
+ {
8362
+ stock: {
8363
+ columnName: 'stock',
8364
+ from: (quantity) => ({ quantity }),
8365
+ to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
8366
+ },
8367
+ },
8368
+ {
8369
+ images: {
8370
+ columnName: 'images',
8371
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8372
+ },
8373
+ },
8374
+ {
8375
+ miniatures: {
8376
+ columnName: 'miniatures',
8377
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8378
+ },
8379
+ },
8380
+ {
8381
+ imagesCard: {
8382
+ columnName: 'images_card',
8383
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8384
+ },
8385
+ },
8386
+ { tagsProfile: { columnName: 'tags_profile' } },
8387
+ { tagsCollection: { columnName: 'tags_collection' } },
8388
+ { variantSlug: { columnName: 'variant_slug' } },
8389
+ {
8390
+ reviews: {
8391
+ columnName: 'reviews',
8392
+ foreignKeyColumn: { product_id: 'id' },
8393
+ fields: [
8394
+ 'id',
8395
+ 'shop',
8396
+ 'rate',
8397
+ 'author',
8398
+ 'email',
8399
+ 'location',
8400
+ 'review',
8401
+ 'status',
8402
+ 'title',
8403
+ { personId: { columnName: 'person_id' } },
8404
+ 'points',
8405
+ { orderId: { columnName: 'order_id' } },
8406
+ { createdAt: { columnName: 'created_at' } },
8407
+ { updatedAt: { columnName: 'updated_at' } },
8408
+ ],
8409
+ },
8410
+ },
8411
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8412
+ {
8413
+ metadata: {
8414
+ columnName: 'metadata',
8415
+ fields: ['title', 'description'],
8416
+ bindPersistData: (value) => ({
8417
+ metadata: { data: value },
8418
+ }),
8419
+ },
8420
+ },
8421
+ ],
8422
+ },
8423
+ },
8424
+ ];
8425
+ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8426
+ get reviewsFields() {
8427
+ return [
8428
+ 'id',
8429
+ 'shop',
8430
+ 'rate',
8431
+ 'author',
8432
+ 'email',
8433
+ 'location',
8434
+ 'review',
8435
+ 'status',
8436
+ 'title',
8437
+ { personId: { columnName: 'person_id' } },
8438
+ 'points',
8439
+ { orderId: { columnName: 'order_id' } },
8440
+ { createdAt: { columnName: 'created_at' } },
8441
+ { updatedAt: { columnName: 'updated_at' } },
8442
+ ];
8443
+ }
8444
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
8445
+ super({
8446
+ tableName: 'product',
8447
+ model: ProductHasuraGraphQL,
8448
+ endpoint,
8449
+ authOptions,
8450
+ interceptors,
8451
+ fields: fieldsConfiguration$2,
8452
+ cache,
8453
+ });
8454
+ this.bindReviewToModel = (plain) => ProductReview.toInstance({
8455
+ ...is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])),
8456
+ createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at,
8457
+ updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at,
8458
+ personId: plain.person_id,
8459
+ orderId: plain.order_id,
8460
+ });
8461
+ this.bindReviewToHasura = (review) => ({
8462
+ ...is(omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])),
8463
+ person_id: review.personId,
8464
+ order_id: review.orderId,
8465
+ });
8466
+ }
8467
+ async create(params) {
8468
+ const { metadata, ...data } = params;
8469
+ const product = await super.create(omit({ ...data, metadata: metadata || { description: null, title: null } }, ['reviews']));
8470
+ try {
8471
+ product.reviews = data.reviews && (await this.updateReviews(+product.id, data));
8472
+ }
8473
+ catch (error) {
8474
+ await this.delete({ id: product.id });
8475
+ throw error;
8476
+ }
8477
+ return product;
8478
+ }
8479
+ async get(identifiers, options) {
8480
+ const product = Number.isNaN(+identifiers.id)
8481
+ ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, options))
8482
+ .data?.[0]
8483
+ : await super.get(identifiers, options);
8484
+ if (product.productId)
8485
+ throw new NotFoundError('Product not found, it is a variant');
8486
+ product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
8487
+ if (!product.variants?.length) {
8488
+ for (const [index, variant] of product.variants.entries()) {
8489
+ product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8490
+ }
8491
+ }
8492
+ return product;
8493
+ }
8494
+ async find(params, optionsParams) {
8495
+ const { filters, fields, ...options } = params || {};
8496
+ const bindFields = fields ||
8497
+ this.fields
8498
+ .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
8499
+ .filter((field) => field !== 'reviews' && field !== 'categories');
8500
+ if (options.options?.minimal?.includes('price'))
8501
+ options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
8502
+ if (options.options?.maximum?.includes('price'))
8503
+ options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
8504
+ options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
8505
+ options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
8506
+ return super.find({
8507
+ ...options,
8508
+ filters: { ...filters, productId: { operator: Where.ISNULL } },
8509
+ fields: [
8510
+ ...bindFields,
8511
+ ...(bindFields.includes('price')
8512
+ ? [
8513
+ 'subscriberPrice',
8514
+ 'subscriberDiscountPercentage',
8515
+ 'fullPrice',
8516
+ ]
8517
+ : []),
8518
+ ],
8519
+ }, optionsParams);
8520
+ }
8521
+ async getBySlug(slug, options) {
8522
+ if (this.cache?.cacheAdapter && options?.cache?.enabled) {
8523
+ const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
8524
+ const cachedData = await this.cache.cacheAdapter.get(cacheKey);
8525
+ if (cachedData) {
8526
+ this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
8527
+ return this.model.toInstance(deserialize(cachedData));
8528
+ }
8529
+ }
8530
+ const result = await this.find({
7554
8531
  filters: {
7555
8532
  slug,
8533
+ productId: {
8534
+ operator: Where.ISNULL,
8535
+ },
7556
8536
  },
7557
8537
  fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
7558
8538
  options: {
@@ -7562,6 +8542,11 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7562
8542
  if (!result.data.length)
7563
8543
  return null;
7564
8544
  const product = result?.data?.shift();
8545
+ if (!product.variants?.length) {
8546
+ for (const [index, variant] of product.variants.entries()) {
8547
+ product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8548
+ }
8549
+ }
7565
8550
  RoundProductPricesHelper.roundProductPrices(product);
7566
8551
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7567
8552
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -7741,7 +8726,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7741
8726
  const plainData = this.paramsToPlain({ metadata });
7742
8727
  if (!plainData.metadata)
7743
8728
  return null;
7744
- await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8729
+ // eslint-disable-next-line @typescript-eslint/naming-convention
8730
+ const { update_product_metadata_by_pk } = await this.mutation('update_product_metadata_by_pk', ['product_id'], {
7745
8731
  pk_columns: {
7746
8732
  value: { product_id: productId },
7747
8733
  type: 'product_metadata_pk_columns_input',
@@ -7753,6 +8739,14 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7753
8739
  required: true,
7754
8740
  },
7755
8741
  });
8742
+ if (!update_product_metadata_by_pk) {
8743
+ await this.mutation('insert_product_metadata', ['affected_rows'], {
8744
+ objects: {
8745
+ type: '[product_metadata_insert_input!]!',
8746
+ value: [{ product_id: productId, ...metadata }],
8747
+ },
8748
+ });
8749
+ }
7756
8750
  return plainData.metadata;
7757
8751
  }
7758
8752
  async getId(id) {
@@ -7763,7 +8757,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7763
8757
  return data?.[0]?.id;
7764
8758
  throw new NotFoundError(`Product with id ${id} not found`);
7765
8759
  }
7766
- async findReviewsByProduct(productId, options) {
8760
+ async findReviewsByProduct(productId, onlyApproved, options) {
7767
8761
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7768
8762
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
7769
8763
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -7776,10 +8770,16 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7776
8770
  where: {
7777
8771
  value: {
7778
8772
  product_id: { _eq: productId },
8773
+ ...(onlyApproved && { status: { _eq: true } }),
7779
8774
  },
7780
8775
  type: 'product_review_bool_exp',
7781
8776
  required: true,
7782
8777
  },
8778
+ order_by: {
8779
+ type: '[product_review_order_by]',
8780
+ value: [{ createdAt: 'desc' }],
8781
+ required: true,
8782
+ },
7783
8783
  });
7784
8784
  const reviews = data?.map((review) => this.bindReviewToModel(review));
7785
8785
  if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
@@ -7884,10 +8884,53 @@ __decorate([
7884
8884
  __decorate([
7885
8885
  Log(),
7886
8886
  __metadata("design:type", Function),
7887
- __metadata("design:paramtypes", [Number, Object]),
8887
+ __metadata("design:paramtypes", [Number, Boolean, Object]),
7888
8888
  __metadata("design:returntype", Promise)
7889
8889
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
7890
8890
 
8891
+ class ProductPriceLogHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8892
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
8893
+ super({
8894
+ tableName: 'product_price_log',
8895
+ model: ProductPriceLog,
8896
+ endpoint,
8897
+ authOptions,
8898
+ interceptors,
8899
+ fields: [
8900
+ {
8901
+ id: {
8902
+ columnName: 'id',
8903
+ to: (value) => +value,
8904
+ from: (value) => value.toString(),
8905
+ },
8906
+ },
8907
+ { productId: { columnName: 'product_id' } },
8908
+ { productEAN: { columnName: 'product_ean' } },
8909
+ { productSKU: { columnName: 'product_sku' } },
8910
+ { productName: { columnName: 'product_name' } },
8911
+ { productCostPrice: { columnName: 'product_cost_price' } },
8912
+ { productPrice: { columnName: 'product_price' } },
8913
+ { productSubscriberPrice: { columnName: 'product_subscriber_price' } },
8914
+ { productSubscriberDiscountPercentage: { columnName: 'product_subscriber_discount_percentage' } },
8915
+ { markupMin: { columnName: 'markup_min' } },
8916
+ { markupWithoutCompetitor: { columnName: 'markup_without_competitor' } },
8917
+ { discountCompetitor: { columnName: 'discount_competitor' } },
8918
+ { minViablePrice: { columnName: 'min_viable_price' } },
8919
+ { targetPrice: { columnName: 'target_price' } },
8920
+ { groupId: { columnName: 'group_id' } },
8921
+ { competitorsAndPrices: { columnName: 'competitors_and_prices', type: HasuraGraphQLColumnType.Jsonb } },
8922
+ { competitorsPrices: { columnName: 'competitors_prices', type: HasuraGraphQLColumnType.Jsonb } },
8923
+ { competitorsMinPrice: { columnName: 'competitors_min_price' } },
8924
+ { competitorsSellerMinPrice: { columnName: 'competitors_seller_min_price' } },
8925
+ { statusPrecificacao: { columnName: 'status_precificacao' } },
8926
+ { createdAt: { columnName: 'created_at' } },
8927
+ { updatedAt: { columnName: 'updated_at' } },
8928
+ ],
8929
+ cache,
8930
+ });
8931
+ }
8932
+ }
8933
+
7891
8934
  class ProductReviewHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7892
8935
  constructor({ endpoint, authOptions, interceptors, cache, }) {
7893
8936
  super({
@@ -7916,7 +8959,25 @@ class ProductReviewHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHas
7916
8959
  product: {
7917
8960
  columnName: 'product',
7918
8961
  foreignKeyColumn: { id: 'productId' },
7919
- fields: ['id', 'ean', 'sku', 'name', 'brand', 'slug', 'images', 'grade', 'gender'],
8962
+ fields: [
8963
+ 'id',
8964
+ {
8965
+ productId: {
8966
+ columnName: 'main_product_id',
8967
+ to: (value) => +value,
8968
+ from: (value) => value?.toString(),
8969
+ },
8970
+ },
8971
+ 'ean',
8972
+ 'sku',
8973
+ 'name',
8974
+ 'brand',
8975
+ 'slug',
8976
+ 'images',
8977
+ 'grade',
8978
+ 'gender',
8979
+ '',
8980
+ ],
7920
8981
  },
7921
8982
  },
7922
8983
  ],
@@ -7961,6 +9022,33 @@ __decorate([
7961
9022
  __metadata("design:returntype", void 0)
7962
9023
  ], ProductReviewHasuraGraphQLRepository.prototype, "disaproveReview", null);
7963
9024
 
9025
+ class ProductStockEntryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
9026
+ constructor({ endpoint, authOptions, interceptors, cache, }) {
9027
+ super({
9028
+ tableName: 'product_millenium_stock_entry',
9029
+ model: ProductStockEntry,
9030
+ endpoint,
9031
+ authOptions,
9032
+ interceptors,
9033
+ cache,
9034
+ fields: [
9035
+ 'id',
9036
+ { productId: { columnName: 'product_id' } },
9037
+ { codProduct: { columnName: 'cod_product' } },
9038
+ { productDescription: { columnName: 'product_description' } },
9039
+ { eventDescription: { columnName: 'event_description' } },
9040
+ { invoiceValue: { columnName: 'invoice_value' } },
9041
+ 'price',
9042
+ 'quantity',
9043
+ { invoiceId: { columnName: 'invoice_id' } },
9044
+ { nfeKey: { columnName: 'nfe_key' } },
9045
+ 'batch',
9046
+ { createdAt: { columnName: 'created_at' } },
9047
+ ],
9048
+ });
9049
+ }
9050
+ }
9051
+
7964
9052
  class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7965
9053
  constructor({ endpoint, authOptions, interceptors, cache, }) {
7966
9054
  super({
@@ -8109,12 +9197,153 @@ const fieldsConfiguration$1 = [
8109
9197
  },
8110
9198
  },
8111
9199
  'group',
9200
+ { groupId: { columnName: 'group_id' } },
9201
+ 'type',
8112
9202
  'validity',
8113
- // { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
8114
9203
  'published',
8115
9204
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
8116
9205
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
9206
+ { tagsSupply: { columnName: 'tags_supply', type: HasuraGraphQLColumnType.Jsonb } },
8117
9207
  { daysOfUse: { columnName: 'days_of_use' } },
9208
+ {
9209
+ images: {
9210
+ columnName: 'images',
9211
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
9212
+ },
9213
+ },
9214
+ {
9215
+ miniatures: {
9216
+ columnName: 'miniatures',
9217
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
9218
+ },
9219
+ },
9220
+ {
9221
+ imagesCard: {
9222
+ columnName: 'images_card',
9223
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
9224
+ },
9225
+ },
9226
+ 'slug',
9227
+ 'brand',
9228
+ 'name',
9229
+ 'sku',
9230
+ { NCM: { columnName: 'ncm' } },
9231
+ { CEST: { columnName: 'cest' } },
9232
+ {
9233
+ description: {
9234
+ columnName: 'description',
9235
+ from: (description, data) => ({
9236
+ description,
9237
+ differentials: data.differentials,
9238
+ whoMustUse: data.who_must_use,
9239
+ howToUse: data.how_to_use,
9240
+ brand: data.brand_description,
9241
+ ingredients: data.ingredients,
9242
+ purpose: data.purpose,
9243
+ }),
9244
+ bindFindFilter: (filters) => {
9245
+ return {
9246
+ ...(filters?.description && { description: filters.description }),
9247
+ ...(filters.differentials && { differentials: filters.differentials }),
9248
+ ...(filters.whoMustUse && {
9249
+ who_must_use: filters.whoMustUse,
9250
+ }),
9251
+ ...(filters.howToUse && {
9252
+ how_to_use: filters.howToUse,
9253
+ }),
9254
+ ...(filters.brand && {
9255
+ brand_description: filters.brand,
9256
+ }),
9257
+ ...(filters.ingredients && {
9258
+ ingredients: filters.ingredients,
9259
+ }),
9260
+ ...(filters.purpose && {
9261
+ purpose: filters.purpose,
9262
+ }),
9263
+ };
9264
+ },
9265
+ bindPersistData: (descriptionData) => ({
9266
+ ...(descriptionData?.description && { description: descriptionData.description }),
9267
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
9268
+ ...(descriptionData.whoMustUse && {
9269
+ who_must_use: descriptionData.whoMustUse,
9270
+ }),
9271
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
9272
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
9273
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
9274
+ ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
9275
+ }),
9276
+ },
9277
+ },
9278
+ { differentials: { columnName: 'differentials' } },
9279
+ { whoMustUse: { columnName: 'who_must_use' } },
9280
+ { howToUse: { columnName: 'how_to_use' } },
9281
+ { brandDescription: { columnName: 'brand_description' } },
9282
+ { ingredients: { columnName: 'ingredients' } },
9283
+ { purpose: { columnName: 'purpose' } },
9284
+ 'gender',
9285
+ { intGender: { columnName: 'int_gender' } },
9286
+ 'label',
9287
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
9288
+ { rate: { columnName: 'rating' } },
9289
+ { reviewsTotal: { columnName: 'reviews_total' } },
9290
+ { shoppingCount: { columnName: 'shopping_count' } },
9291
+ { categoryId: { columnName: 'category_id' } },
9292
+ {
9293
+ category: {
9294
+ columnName: 'category',
9295
+ foreignKeyColumn: { id: 'categoryId' },
9296
+ fields: ['id', 'name', 'reference', 'slug'],
9297
+ },
9298
+ },
9299
+ {
9300
+ categories: {
9301
+ columnName: 'categories',
9302
+ fields: ['category_id'],
9303
+ bindPersistData: (value) => ({
9304
+ categories: { data: value.map((category) => ({ category_id: +category })) },
9305
+ }),
9306
+ to: (categories) => categories.map((categoryId) => +categoryId),
9307
+ from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
9308
+ },
9309
+ },
9310
+ {
9311
+ metadata: {
9312
+ columnName: 'metadata',
9313
+ fields: ['title', 'description'],
9314
+ bindPersistData: (value) => ({
9315
+ metadata: { data: value },
9316
+ }),
9317
+ },
9318
+ },
9319
+ {
9320
+ reviews: {
9321
+ columnName: 'reviews',
9322
+ foreignKeyColumn: { product_id: 'id' },
9323
+ fields: [
9324
+ 'id',
9325
+ 'shop',
9326
+ 'rate',
9327
+ 'author',
9328
+ 'email',
9329
+ 'location',
9330
+ 'review',
9331
+ 'status',
9332
+ 'title',
9333
+ { personId: { columnName: 'person_id' } },
9334
+ 'points',
9335
+ { orderId: { columnName: 'order_id' } },
9336
+ { createdAt: { columnName: 'created_at' } },
9337
+ { updatedAt: { columnName: 'updated_at' } },
9338
+ ],
9339
+ },
9340
+ },
9341
+ { variantSlug: { columnName: 'variant_slug' } },
9342
+ { caixariaMinima: { columnName: 'caixaria_minima', type: HasuraGraphQLColumnType.Jsonb } },
9343
+ 'suppliers',
9344
+ 'curve',
9345
+ { createdAt: { columnName: 'created_at' } },
9346
+ { updatedAt: { columnName: 'updated_at' } },
8118
9347
  ];
8119
9348
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8120
9349
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8155,17 +9384,45 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8155
9384
  return data.at(0);
8156
9385
  }
8157
9386
  async update(params) {
8158
- const { productId, id: checkId, ...data } = params;
9387
+ const { productId, id: checkId, metadata, ...data } = params;
8159
9388
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8160
9389
  if (!dataWithProductId.id) {
8161
9390
  throw new NotFoundError('Variant ID is required for update');
8162
9391
  }
8163
9392
  const id = await this.getId(dataWithProductId.id);
8164
9393
  const product = await super.update({ id, ...data });
9394
+ product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8165
9395
  if (dataWithProductId.productId) {
8166
9396
  product.productId = dataWithProductId.productId;
8167
9397
  }
8168
- return product;
9398
+ return product;
9399
+ }
9400
+ async updateMetadata(productId, { metadata }) {
9401
+ const plainData = this.paramsToPlain({ metadata });
9402
+ if (!plainData.metadata)
9403
+ return null;
9404
+ // eslint-disable-next-line @typescript-eslint/naming-convention
9405
+ const { update_product_metadata_by_pk } = await this.mutation('update_product_metadata_by_pk', ['product_id'], {
9406
+ pk_columns: {
9407
+ value: { product_id: productId },
9408
+ type: 'product_metadata_pk_columns_input',
9409
+ required: true,
9410
+ },
9411
+ _set: {
9412
+ value: omit(metadata, ['product_id']),
9413
+ type: 'product_metadata_set_input',
9414
+ required: true,
9415
+ },
9416
+ });
9417
+ if (!update_product_metadata_by_pk) {
9418
+ await this.mutation('insert_product_metadata', ['affected_rows'], {
9419
+ objects: {
9420
+ type: '[product_metadata_insert_input!]!',
9421
+ value: [{ product_id: productId, ...metadata }],
9422
+ },
9423
+ });
9424
+ }
9425
+ return plainData.metadata;
8169
9426
  }
8170
9427
  async getId(id) {
8171
9428
  if (!Number.isNaN(+id))
@@ -8388,124 +9645,670 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
8388
9645
  async getCategoryBySlug(slug, _shop) {
8389
9646
  return this.getWishlistBySlug(slug);
8390
9647
  }
8391
- async getCategoryByShop(shop) {
8392
- if (!shop)
8393
- return;
8394
- const { data } = await this.find({
8395
- filters: {
8396
- shops: { operator: Where.IN, value: [shop] },
8397
- published: { operator: Where.EQUALS, value: true },
8398
- isWishlist: { operator: Where.EQUALS, value: true },
8399
- },
8400
- options: {
8401
- enableCount: false,
9648
+ async getCategoryByShop(shop) {
9649
+ if (!shop)
9650
+ return;
9651
+ const { data } = await this.find({
9652
+ filters: {
9653
+ shops: { operator: Where.IN, value: [shop] },
9654
+ published: { operator: Where.EQUALS, value: true },
9655
+ isWishlist: { operator: Where.EQUALS, value: true },
9656
+ },
9657
+ options: {
9658
+ enableCount: false,
9659
+ },
9660
+ });
9661
+ return data;
9662
+ }
9663
+ async findBfluOrGlamgirlWishlists(params, shops) {
9664
+ return this.find({
9665
+ ...params,
9666
+ filters: {
9667
+ ...params.filters,
9668
+ published: true,
9669
+ shops: { operator: Where.LIKE, value: shops },
9670
+ personType: params.filters?.personType ?? {
9671
+ operator: Where.IN,
9672
+ value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
9673
+ },
9674
+ },
9675
+ orderBy: {
9676
+ personHasPhoto: 'desc',
9677
+ ...omit(params.orderBy, ['personHasPhoto']),
9678
+ },
9679
+ });
9680
+ }
9681
+ getCategoriesForHome() {
9682
+ return;
9683
+ }
9684
+ mountCategory() {
9685
+ return;
9686
+ }
9687
+ getChildren(_parentId) {
9688
+ return;
9689
+ }
9690
+ isChild(_id, _parentId) {
9691
+ return;
9692
+ }
9693
+ async updateMetadata(categoryId, { metadatas }) {
9694
+ if (Array.isArray(metadatas) && !metadatas.length)
9695
+ return [];
9696
+ if (Array.isArray(metadatas) && metadatas.length) {
9697
+ const metadataUpdated = [];
9698
+ for (const data of metadatas) {
9699
+ const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
9700
+ pk_columns: {
9701
+ value: { category_id: categoryId, shop: data.shop },
9702
+ type: 'category_metadata_pk_columns_input',
9703
+ required: true,
9704
+ },
9705
+ _set: {
9706
+ value: omit(data, ['category_id', 'shop']),
9707
+ type: 'category_metadata_set_input',
9708
+ required: true,
9709
+ },
9710
+ });
9711
+ metadataUpdated.push(update);
9712
+ }
9713
+ return metadataUpdated;
9714
+ }
9715
+ if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
9716
+ for (let i = 0; i < metadatas.value.length; i++) {
9717
+ await this.mutation('delete_category_metadata', ['affected_rows'], {
9718
+ where: {
9719
+ type: 'category_metadata_bool_exp',
9720
+ required: true,
9721
+ value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
9722
+ },
9723
+ });
9724
+ }
9725
+ return [];
9726
+ }
9727
+ }
9728
+ async addProduct(wishlistId, productId) {
9729
+ await this.categoryProductRepository.create({
9730
+ categoryId: +wishlistId,
9731
+ productId: +productId,
9732
+ order: 0,
9733
+ });
9734
+ }
9735
+ async removeProduct(wishlistId, productId) {
9736
+ return this.categoryProductRepository.delete({
9737
+ categoryId: +wishlistId,
9738
+ productId: +productId,
9739
+ });
9740
+ }
9741
+ async getBrandsWithProducts() {
9742
+ return;
9743
+ }
9744
+ }
9745
+ __decorate([
9746
+ Log(),
9747
+ __metadata("design:type", Function),
9748
+ __metadata("design:paramtypes", [String]),
9749
+ __metadata("design:returntype", Promise)
9750
+ ], WishlistHasuraGraphQLRepository.prototype, "getWishlistBySlug", null);
9751
+ __decorate([
9752
+ Log(),
9753
+ __metadata("design:type", Function),
9754
+ __metadata("design:paramtypes", [String]),
9755
+ __metadata("design:returntype", Promise)
9756
+ ], WishlistHasuraGraphQLRepository.prototype, "getWishlistByPerson", null);
9757
+ __decorate([
9758
+ Log(),
9759
+ __metadata("design:type", Function),
9760
+ __metadata("design:paramtypes", [String]),
9761
+ __metadata("design:returntype", Promise)
9762
+ ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
9763
+ __decorate([
9764
+ Log(),
9765
+ __metadata("design:type", Function),
9766
+ __metadata("design:paramtypes", [Object, Array]),
9767
+ __metadata("design:returntype", Promise)
9768
+ ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
9769
+
9770
+ class MercadoPagoErrorHelper {
9771
+ static getErrorTypeFromResponse(errorCode) {
9772
+ switch (errorCode) {
9773
+ case 'bad_filled_card_data':
9774
+ case 'invalid_card_token':
9775
+ case 'card_disabled':
9776
+ case 'cc_rejected_card_disabled':
9777
+ case 'cc_rejected_bad_filled_card_number':
9778
+ case 'cc_rejected_bad_filled_date':
9779
+ case 'cc_rejected_bad_filled_other':
9780
+ case 'cc_rejected_bad_filled_security_code':
9781
+ return ErrorsCode.invalidCardError;
9782
+ case 'high_risk':
9783
+ case 'rejected_high_risk':
9784
+ case 'cc_rejected_blacklist':
9785
+ case 'cc_rejected_call_for_authorize':
9786
+ case 'cc_rejected_high_risk':
9787
+ return ErrorsCode.fraudPreventionExternal;
9788
+ case 'rejected_by_issuer':
9789
+ case 'rejected_by_bank':
9790
+ case 'cc_rejected_max_attempts':
9791
+ case 'required_call_for_authorize':
9792
+ case 'max_attempts_exceeded':
9793
+ return ErrorsCode.paymentNotAuthorizedError;
9794
+ case 'insufficient_amount':
9795
+ case 'amount_limit_exceeded':
9796
+ case 'cc_rejected_insufficient_amount':
9797
+ return ErrorsCode.insufficientFundsError;
9798
+ case 'processing_error':
9799
+ return ErrorsCode.paymentError;
9800
+ case 'invalid_installments':
9801
+ case 'cc_rejected_invalid_installments':
9802
+ case 'cc_rejected_other_reason':
9803
+ case 'rejected_insufficient_data':
9804
+ return ErrorsCode.businessError;
9805
+ default:
9806
+ return ErrorsCode.paymentError;
9807
+ }
9808
+ }
9809
+ }
9810
+
9811
+ class MercadoPagoRequestHelper {
9812
+ static build(data) {
9813
+ const { checkout, method, postback, card } = data;
9814
+ return {
9815
+ transaction_amount: +checkout.totalPrice.toFixed(2),
9816
+ notification_url: postback,
9817
+ metadata: {
9818
+ checkoutId: checkout.id,
9819
+ },
9820
+ payer: this.buildPayer(checkout, card),
9821
+ statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'loja glam' : 'mens market',
9822
+ additional_info: {
9823
+ items: this.buildItems(checkout),
9824
+ },
9825
+ ...(method === 'credit_card' && this.buildCardPayment(card)),
9826
+ ...(method === 'pix' && this.buildPixPayment()),
9827
+ ...(method === 'boleto' && this.buildBoletoPayment(checkout)),
9828
+ };
9829
+ }
9830
+ static buildItems(checkout) {
9831
+ return checkout.lineItems
9832
+ .filter((item) => !item.isGift)
9833
+ .map((item) => {
9834
+ return {
9835
+ id: item.EAN,
9836
+ title: item.name,
9837
+ description: item.name,
9838
+ picture_url: item.image ?? null,
9839
+ category_id: item.category?.id ?? null,
9840
+ quantity: item.quantity,
9841
+ unit_price: +item.pricePaid.toFixed(2),
9842
+ };
9843
+ });
9844
+ }
9845
+ static buildPayer(checkout, card) {
9846
+ return {
9847
+ ...(card && { id: card.customerId }),
9848
+ first_name: checkout.user.firstName,
9849
+ last_name: checkout.user.lastName,
9850
+ email: checkout.user.email,
9851
+ identification: {
9852
+ type: 'CPF',
9853
+ number: checkout.user.cpf.replace(/\D/g, ''),
9854
+ },
9855
+ };
9856
+ }
9857
+ static buildFullPayer(checkout) {
9858
+ return {
9859
+ first_name: checkout.user.firstName,
9860
+ last_name: checkout.user.lastName,
9861
+ phone: {
9862
+ area_code: checkout.user.phone.substring(0, 2),
9863
+ number: checkout.user.phone.substring(2),
9864
+ },
9865
+ address: {
9866
+ zip_code: checkout.shippingAddress.zip,
9867
+ street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
9868
+ street_number: checkout.shippingAddress.number,
9869
+ neighborhood: checkout.shippingAddress.district,
9870
+ city: checkout.shippingAddress.city,
9871
+ federal_unit: checkout.shippingAddress.state,
9872
+ },
9873
+ };
9874
+ }
9875
+ static buildCardPayment(card) {
9876
+ return {
9877
+ installments: card.installments,
9878
+ token: card.cardId,
9879
+ binary_mode: true,
9880
+ capture: true,
9881
+ };
9882
+ }
9883
+ static buildPixPayment() {
9884
+ return {
9885
+ payment_method_id: 'pix',
9886
+ date_of_expiration: format(addHours(new Date(), 24), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx"),
9887
+ };
9888
+ }
9889
+ static buildBoletoPayment(checkout) {
9890
+ return {
9891
+ payment_method_id: 'bolbradesco',
9892
+ date_of_expiration: format(addDays(new Date(), 3), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
9893
+ payer: {
9894
+ first_name: checkout.user.firstName,
9895
+ last_name: checkout.user.lastName,
9896
+ email: checkout.user.email,
9897
+ identification: {
9898
+ type: 'CPF',
9899
+ number: checkout.user.cpf.replace(/\D/g, ''),
9900
+ },
9901
+ phone: {
9902
+ area_code: checkout.user.phone.substring(0, 2),
9903
+ number: checkout.user.phone.substring(2),
9904
+ },
9905
+ address: {
9906
+ zip_code: checkout.shippingAddress.zip.replace(/\D/g, ''),
9907
+ street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
9908
+ street_number: checkout.shippingAddress.number,
9909
+ neighborhood: checkout.shippingAddress.district,
9910
+ city: checkout.shippingAddress.city,
9911
+ federal_unit: checkout.shippingAddress.state,
9912
+ },
9913
+ },
9914
+ };
9915
+ }
9916
+ }
9917
+
9918
+ class MercadoPagoResponseHelper {
9919
+ static build(method, checkout, response) {
9920
+ return Payment.toInstance({
9921
+ createdAt: new Date(),
9922
+ updatedAt: new Date(),
9923
+ userId: checkout.user.id,
9924
+ checkoutId: checkout.id,
9925
+ totalPrice: checkout.totalPrice,
9926
+ paymentProvider: PaymentProviders.MERCADOPAGO,
9927
+ mercadoPagoId: response.id,
9928
+ transaction: this.buildPaymentTransaction(method, response),
9929
+ });
9930
+ }
9931
+ static buildPaymentTransaction(method, response) {
9932
+ return PaymentTransaction.toInstance({
9933
+ id: response.id.toString(),
9934
+ acquirer_name: PaymentProviders.MERCADOPAGO,
9935
+ amount: response.transaction_amount,
9936
+ status: this.statusMapping(response.status),
9937
+ status_reason: response.status_detail?.toString(),
9938
+ payment_method: method,
9939
+ currency: response.currency_id?.toString(),
9940
+ paid_amount: response.transaction_details?.total_paid_amount ?? null,
9941
+ paid_at: response.date_approved ?? null,
9942
+ charger_id: response.charges_details?.at(0)?.id?.toString() ?? null,
9943
+ ...(method == TransactionPaymentMethods.PIX && this.getPixReponse(response)),
9944
+ ...(method == TransactionPaymentMethods.CARD && this.getCardReponse(response)),
9945
+ ...(method == TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(response)),
9946
+ });
9947
+ }
9948
+ static getBoletoReponse(response) {
9949
+ return {
9950
+ boleto_url: response.transaction_details?.external_resource_url?.toString(),
9951
+ boleto_barcode: response.transaction_details?.barcode?.content?.toString(),
9952
+ boleto_line: response.transaction_details?.digitable_line?.toString(),
9953
+ boleto_expiration_date: response.date_of_expiration?.toString(),
9954
+ boleto_document_number: response.transaction_details?.verification_code?.toString(),
9955
+ };
9956
+ }
9957
+ static getPixReponse(response) {
9958
+ return {
9959
+ pix_qr_code: response.point_of_interaction?.transaction_data?.qr_code,
9960
+ pix_expiration_date: response.date_of_expiration?.toString(),
9961
+ };
9962
+ }
9963
+ static getCardReponse(response) {
9964
+ return {
9965
+ soft_descriptor: response.statement_descriptor?.toString(),
9966
+ installments: response.installments,
9967
+ card_brand: response.payment_method_id?.toString(),
9968
+ card_first_digits: response.card?.first_six_digits?.toString(),
9969
+ card_last_digits: response.card?.last_four_digits?.toString(),
9970
+ card_id: response.card?.id?.toString(),
9971
+ card_holder_name: response.card?.cardholder?.name?.toString(),
9972
+ card_expiration_month: response.card?.expiration_month?.toString(),
9973
+ card_expiration_year: response.card?.expiration_year?.toString(),
9974
+ capture_method: response.payment_type_id?.toString(),
9975
+ authorization_code: response.authorization_code?.toString(),
9976
+ paid_amount: this.statusMapping(response.status) == 'paid' ? response.transaction_details?.total_paid_amount : null,
9977
+ paid_at: this.statusMapping(response.status) == 'paid' ? response.date_approved : null,
9978
+ };
9979
+ }
9980
+ static statusMapping(status) {
9981
+ const statusMap = {
9982
+ approved: 'paid',
9983
+ pending: 'waiting_payment',
9984
+ in_process: 'processing',
9985
+ rejected: 'refused',
9986
+ cancelled: 'refused',
9987
+ refunded: 'refunded',
9988
+ charged_back: 'chargedback',
9989
+ };
9990
+ return statusMap[status] || status;
9991
+ }
9992
+ }
9993
+
9994
+ class MercadoPagoBankSlipAxiosAdapter {
9995
+ constructor(credentials, paymentRepository) {
9996
+ this.credentials = credentials;
9997
+ this.paymentRepository = paymentRepository;
9998
+ }
9999
+ async pay(checkout) {
10000
+ try {
10001
+ const payload = MercadoPagoRequestHelper.build({
10002
+ checkout,
10003
+ method: 'boleto',
10004
+ postback: this.credentials.postback,
10005
+ });
10006
+ console.warn('[MERCADO PAGO BOLETO DATA TO SEND]', JSON.stringify(payload));
10007
+ const { data } = await axios({
10008
+ method: 'POST',
10009
+ url: `${this.credentials.url}/v1/payments`,
10010
+ headers: {
10011
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
10012
+ Authorization: `Bearer ${this.credentials.api_key}`,
10013
+ 'Content-Type': 'application/json',
10014
+ },
10015
+ data: payload,
10016
+ });
10017
+ console.warn('[MERCADO PAGO RESPONSE BOLETO DATA]', JSON.stringify(data));
10018
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.BANKSLIP, checkout, data));
10019
+ return payment;
10020
+ }
10021
+ catch (error) {
10022
+ if (error instanceof AxiosError) {
10023
+ console.warn(JSON.stringify(error.response.data.message));
10024
+ }
10025
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
10026
+ checkoutId: checkout.id,
10027
+ userEmail: checkout.user.email,
10028
+ info: error.response.data?.message || error.message?.toString(),
10029
+ });
10030
+ }
10031
+ }
10032
+ getBoletoTransaction(paymentId) {
10033
+ throw new Error('Method not implemented.');
10034
+ }
10035
+ }
10036
+
10037
+ var MercadoPagoStatusDetailEnum;
10038
+ (function (MercadoPagoStatusDetailEnum) {
10039
+ MercadoPagoStatusDetailEnum["accredited"] = "accredited";
10040
+ MercadoPagoStatusDetailEnum["partially_refunded"] = "partially_refunded";
10041
+ MercadoPagoStatusDetailEnum["pending_capture"] = "pending_capture";
10042
+ MercadoPagoStatusDetailEnum["offline_process"] = "offline_process";
10043
+ MercadoPagoStatusDetailEnum["pending_contingency"] = "pending_contingency";
10044
+ MercadoPagoStatusDetailEnum["pending_review_manual"] = "pending_review_manual";
10045
+ MercadoPagoStatusDetailEnum["pending_waiting_transfer"] = "pending_waiting_transfer";
10046
+ MercadoPagoStatusDetailEnum["pending_waiting_payment"] = "pending_waiting_payment";
10047
+ MercadoPagoStatusDetailEnum["pending_challenge"] = "pending_challenge";
10048
+ MercadoPagoStatusDetailEnum["bank_error"] = "bank_error";
10049
+ MercadoPagoStatusDetailEnum["cc_rejected_3ds_mandatory"] = "cc_rejected_3ds_mandatory";
10050
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_card_number"] = "cc_rejected_bad_filled_card_number";
10051
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_date"] = "cc_rejected_bad_filled_date";
10052
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_other"] = "cc_rejected_bad_filled_other";
10053
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_security_code"] = "cc_rejected_bad_filled_security_code";
10054
+ MercadoPagoStatusDetailEnum["cc_rejected_blacklist"] = "cc_rejected_blacklist";
10055
+ MercadoPagoStatusDetailEnum["cc_rejected_call_for_authorize"] = "cc_rejected_call_for_authorize";
10056
+ MercadoPagoStatusDetailEnum["cc_rejected_card_disabled"] = "cc_rejected_card_disabled";
10057
+ MercadoPagoStatusDetailEnum["cc_rejected_card_error"] = "cc_rejected_card_error";
10058
+ MercadoPagoStatusDetailEnum["cc_rejected_duplicated_payment"] = "cc_rejected_duplicated_payment";
10059
+ MercadoPagoStatusDetailEnum["cc_rejected_high_risk"] = "cc_rejected_high_risk";
10060
+ MercadoPagoStatusDetailEnum["cc_rejected_insufficient_amount"] = "cc_rejected_insufficient_amount";
10061
+ MercadoPagoStatusDetailEnum["cc_rejected_invalid_installments"] = "cc_rejected_invalid_installments";
10062
+ MercadoPagoStatusDetailEnum["cc_rejected_max_attempts"] = "cc_rejected_max_attempts";
10063
+ MercadoPagoStatusDetailEnum["cc_rejected_other_reason"] = "cc_rejected_other_reason";
10064
+ MercadoPagoStatusDetailEnum["cc_amount_rate_limit_exceeded"] = "cc_amount_rate_limit_exceeded";
10065
+ MercadoPagoStatusDetailEnum["rejected_insufficient_data"] = "rejected_insufficient_data";
10066
+ MercadoPagoStatusDetailEnum["rejected_by_bank"] = "rejected_by_bank";
10067
+ MercadoPagoStatusDetailEnum["rejected_by_regulations"] = "rejected_by_regulations";
10068
+ MercadoPagoStatusDetailEnum["insufficient_amount"] = "insufficient_amount";
10069
+ MercadoPagoStatusDetailEnum["cc_rejected_card_type_not_allowed"] = "cc_rejected_card_type_not_allowed";
10070
+ })(MercadoPagoStatusDetailEnum || (MercadoPagoStatusDetailEnum = {}));
10071
+
10072
+ var MercadoPagoStatusEnum;
10073
+ (function (MercadoPagoStatusEnum) {
10074
+ MercadoPagoStatusEnum["approved"] = "approved";
10075
+ MercadoPagoStatusEnum["authorized"] = "authorized";
10076
+ MercadoPagoStatusEnum["pending"] = "pending";
10077
+ MercadoPagoStatusEnum["in_process"] = "in_process";
10078
+ MercadoPagoStatusEnum["rejected"] = "rejected";
10079
+ MercadoPagoStatusEnum["cancelled"] = "cancelled";
10080
+ MercadoPagoStatusEnum["refunded"] = "refunded";
10081
+ MercadoPagoStatusEnum["charged_back"] = "charged_back";
10082
+ })(MercadoPagoStatusEnum || (MercadoPagoStatusEnum = {}));
10083
+
10084
+ class MercadoPagoBaseAxiosAdapter {
10085
+ constructor(credentials, paymentRepository) {
10086
+ this.credentials = credentials;
10087
+ this.paymentRepository = paymentRepository;
10088
+ }
10089
+ async refund(order, amount) {
10090
+ const { data } = await axios({
10091
+ method: 'POST',
10092
+ url: `${this.credentials.url}/v1/payments/${order.payment.id}/refunds`,
10093
+ headers: {
10094
+ 'X-Idempotency-Key': `${order.payment.charger_id}-${new Date().getTime()}`,
10095
+ Authorization: `Bearer ${this.credentials.api_key}`,
10096
+ 'Content-Type': 'application/json',
10097
+ },
10098
+ data: {
10099
+ amount: +amount.toFixed(2),
10100
+ },
10101
+ });
10102
+ await this.paymentRepository.create({
10103
+ createdAt: new Date(),
10104
+ updatedAt: new Date(),
10105
+ userId: order.user.id,
10106
+ orderId: order.id,
10107
+ totalPrice: amount,
10108
+ paymentProvider: PaymentProviders.MERCADOPAGO,
10109
+ mercadoPagoId: data.id,
10110
+ transaction: data,
10111
+ });
10112
+ console.warn('[RESPONSE MERCADO PAGO REFUND]', JSON.stringify(data));
10113
+ return {
10114
+ status: this.getRefundStatus(data.status),
10115
+ success: [
10116
+ MercadoPagoStatusEnum.approved,
10117
+ MercadoPagoStatusEnum.refunded,
10118
+ MercadoPagoStatusEnum.cancelled,
10119
+ MercadoPagoStatusEnum.authorized,
10120
+ ].includes(data.status)
10121
+ ? true
10122
+ : false,
10123
+ };
10124
+ }
10125
+ getRefundStatus(status) {
10126
+ if ([MercadoPagoStatusEnum.in_process, MercadoPagoStatusEnum.pending].includes(status)) {
10127
+ return 'processing';
10128
+ }
10129
+ if ([
10130
+ MercadoPagoStatusEnum.approved,
10131
+ MercadoPagoStatusEnum.refunded,
10132
+ MercadoPagoStatusEnum.cancelled,
10133
+ MercadoPagoStatusEnum.authorized,
10134
+ ].includes(status)) {
10135
+ return 'success';
10136
+ }
10137
+ return 'unknown';
10138
+ }
10139
+ }
10140
+
10141
+ class MercadoPagoCardAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
10142
+ constructor(credentials, paymentRepository, orderBlockedRepository) {
10143
+ super(credentials, paymentRepository);
10144
+ this.credentials = credentials;
10145
+ this.paymentRepository = paymentRepository;
10146
+ this.orderBlockedRepository = orderBlockedRepository;
10147
+ }
10148
+ async pay(checkout, card) {
10149
+ try {
10150
+ const payload = await this.getPaymentPayload(checkout, card);
10151
+ console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
10152
+ const data = await this.requestPayment(checkout, payload);
10153
+ console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
10154
+ if (data.status == MercadoPagoStatusEnum.rejected) {
10155
+ await this.orderBlockedRepository.createBlockedOrderOrPayment({
10156
+ checkout,
10157
+ blockType: 'Card not authorized',
10158
+ type: 'Card',
10159
+ limiteRange: 'day',
10160
+ card,
10161
+ gatewayInfo: {
10162
+ gateway: PaymentProviders.MERCADOPAGO,
10163
+ status: data.status,
10164
+ statusDetail: data.status_detail,
10165
+ },
10166
+ });
10167
+ const errorCode = MercadoPagoErrorHelper.getErrorTypeFromResponse(data.status_detail);
10168
+ throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', errorCode, {
10169
+ checkoutId: checkout.id,
10170
+ userEmail: checkout.user.email,
10171
+ info: data,
10172
+ });
10173
+ }
10174
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
10175
+ return payment;
10176
+ }
10177
+ catch (error) {
10178
+ if (error instanceof AxiosError) {
10179
+ console.warn(JSON.stringify(error.response?.data?.message));
10180
+ throw new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', ErrorsCode.paymentError, {
10181
+ checkoutId: checkout.id,
10182
+ userEmail: checkout.user.email,
10183
+ info: error.response?.data?.message || error.message?.toString(),
10184
+ });
10185
+ }
10186
+ throw error;
10187
+ }
10188
+ }
10189
+ async requestPayment(checkout, payload) {
10190
+ const { data } = await axios({
10191
+ method: 'POST',
10192
+ url: `${this.credentials.url}/v1/payments`,
10193
+ headers: {
10194
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
10195
+ Authorization: `Bearer ${this.credentials.api_key}`,
10196
+ 'Content-Type': 'application/json',
8402
10197
  },
10198
+ data: payload,
8403
10199
  });
8404
10200
  return data;
8405
10201
  }
8406
- async findBfluOrGlamgirlWishlists(params, shops) {
8407
- return this.find({
8408
- ...params,
8409
- filters: {
8410
- ...params.filters,
8411
- published: true,
8412
- shops: { operator: Where.LIKE, value: shops },
8413
- personType: params.filters?.personType ?? {
8414
- operator: Where.IN,
8415
- value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
8416
- },
8417
- },
8418
- orderBy: {
8419
- personHasPhoto: 'desc',
8420
- ...omit(params.orderBy, ['personHasPhoto']),
10202
+ async getPaymentPayload(checkout, card) {
10203
+ const cardResponse = await this.getCardByToken(card.customerId, card.cardId, card.cardCvv);
10204
+ const payload = MercadoPagoRequestHelper.build({
10205
+ checkout,
10206
+ method: 'credit_card',
10207
+ postback: this.credentials.postback,
10208
+ card: {
10209
+ ...card,
10210
+ cardId: cardResponse.id,
8421
10211
  },
8422
10212
  });
10213
+ return payload;
8423
10214
  }
8424
- getCategoriesForHome() {
10215
+ async addCard(card, customer) {
8425
10216
  return;
8426
10217
  }
8427
- mountCategory() {
8428
- return;
10218
+ async getCardByToken(customerId, token, cardCvv) {
10219
+ try {
10220
+ const payload = { cardId: token, customerId: customerId, securityCode: cardCvv };
10221
+ console.warn('payload getCardByToken', payload);
10222
+ const { data } = await axios({
10223
+ method: 'POST',
10224
+ url: `${this.credentials.url}/v1/card_tokens`,
10225
+ headers: {
10226
+ Authorization: `Bearer ${this.credentials.api_key}`,
10227
+ 'Content-Type': 'application/json',
10228
+ },
10229
+ data: payload,
10230
+ });
10231
+ return data;
10232
+ }
10233
+ catch (error) {
10234
+ if (error instanceof AxiosError) {
10235
+ console.warn(JSON.stringify(error.response.data.cause));
10236
+ }
10237
+ throw error;
10238
+ }
8429
10239
  }
8430
- getChildren(_parentId) {
10240
+ createCardHash(bu, shop, card) {
8431
10241
  return;
8432
10242
  }
8433
- isChild(_id, _parentId) {
10243
+ createTransaction(info) {
8434
10244
  return;
8435
10245
  }
8436
- async updateMetadata(categoryId, { metadatas }) {
8437
- if (Array.isArray(metadatas) && !metadatas.length)
8438
- return [];
8439
- if (Array.isArray(metadatas) && metadatas.length) {
8440
- const metadataUpdated = [];
8441
- for (const data of metadatas) {
8442
- const update = await this.mutation('update_category_metadata_by_pk', ['category_id', 'shop'], {
8443
- pk_columns: {
8444
- value: { category_id: categoryId, shop: data.shop },
8445
- type: 'category_metadata_pk_columns_input',
8446
- required: true,
8447
- },
8448
- _set: {
8449
- value: omit(data, ['category_id', 'shop']),
8450
- type: 'category_metadata_set_input',
8451
- required: true,
8452
- },
8453
- });
8454
- metadataUpdated.push(update);
8455
- }
8456
- return metadataUpdated;
10246
+ async createOrUpdateCustomer(customer) {
10247
+ const { data } = await axios({
10248
+ method: 'POST',
10249
+ url: `${this.credentials.url}/v1/customers`,
10250
+ headers: {
10251
+ Authorization: `Bearer ${this.credentials.api_key}`,
10252
+ 'Content-Type': 'application/json',
10253
+ },
10254
+ data: {
10255
+ email: customer.email,
10256
+ first_name: customer.firstName,
10257
+ last_name: customer.lastName,
10258
+ phone: {
10259
+ area_code: customer.phone.substring(0, 2),
10260
+ number: customer.phone.substring(2),
10261
+ },
10262
+ identification: {
10263
+ type: 'CPF',
10264
+ number: customer.cpf.replace(/\D/g, ''),
10265
+ },
10266
+ },
10267
+ });
10268
+ return data;
10269
+ }
10270
+ }
10271
+
10272
+ class MercadoPagoPixAxiosAdapter extends MercadoPagoBaseAxiosAdapter {
10273
+ constructor(credentials, paymentRepository) {
10274
+ super(credentials, paymentRepository);
10275
+ this.credentials = credentials;
10276
+ this.paymentRepository = paymentRepository;
10277
+ }
10278
+ async pay(checkout) {
10279
+ try {
10280
+ const payload = MercadoPagoRequestHelper.build({
10281
+ checkout,
10282
+ method: 'pix',
10283
+ postback: this.credentials.postback,
10284
+ });
10285
+ console.warn('[MERCADO PAGO PIX DATA TO SEND]', JSON.stringify(payload));
10286
+ const { data } = await axios({
10287
+ method: 'POST',
10288
+ url: `${this.credentials.url}/v1/payments`,
10289
+ headers: {
10290
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
10291
+ Authorization: `Bearer ${this.credentials.api_key}`,
10292
+ 'Content-Type': 'application/json',
10293
+ },
10294
+ data: payload,
10295
+ });
10296
+ console.warn('[MERCADO PAGO RESPONSE PIX DATA]', JSON.stringify(data));
10297
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.PIX, checkout, data));
10298
+ return payment;
8457
10299
  }
8458
- if ('action' in metadatas && metadatas.action === 'remove' && metadatas.value.length) {
8459
- for (let i = 0; i < metadatas.value.length; i++) {
8460
- await this.mutation('delete_category_metadata', ['affected_rows'], {
8461
- where: {
8462
- type: 'category_metadata_bool_exp',
8463
- required: true,
8464
- value: { category_id: { _eq: categoryId }, shop: metadatas.value[i].shop },
8465
- },
8466
- });
10300
+ catch (error) {
10301
+ if (error instanceof AxiosError) {
10302
+ console.warn(JSON.stringify(error.response.data.message));
8467
10303
  }
8468
- return [];
10304
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', ErrorsCode.paymentError, {
10305
+ checkoutId: checkout.id,
10306
+ userEmail: checkout.user.email,
10307
+ info: error.response.data?.message || error.message?.toString(),
10308
+ });
8469
10309
  }
8470
10310
  }
8471
- async addProduct(wishlistId, productId) {
8472
- await this.categoryProductRepository.create({
8473
- categoryId: +wishlistId,
8474
- productId: +productId,
8475
- order: 0,
8476
- });
8477
- }
8478
- async removeProduct(wishlistId, productId) {
8479
- return this.categoryProductRepository.delete({
8480
- categoryId: +wishlistId,
8481
- productId: +productId,
8482
- });
8483
- }
8484
10311
  }
8485
- __decorate([
8486
- Log(),
8487
- __metadata("design:type", Function),
8488
- __metadata("design:paramtypes", [String]),
8489
- __metadata("design:returntype", Promise)
8490
- ], WishlistHasuraGraphQLRepository.prototype, "getWishlistBySlug", null);
8491
- __decorate([
8492
- Log(),
8493
- __metadata("design:type", Function),
8494
- __metadata("design:paramtypes", [String]),
8495
- __metadata("design:returntype", Promise)
8496
- ], WishlistHasuraGraphQLRepository.prototype, "getWishlistByPerson", null);
8497
- __decorate([
8498
- Log(),
8499
- __metadata("design:type", Function),
8500
- __metadata("design:paramtypes", [String]),
8501
- __metadata("design:returntype", Promise)
8502
- ], WishlistHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
8503
- __decorate([
8504
- Log(),
8505
- __metadata("design:type", Function),
8506
- __metadata("design:paramtypes", [Object, Array]),
8507
- __metadata("design:returntype", Promise)
8508
- ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
8509
10312
 
8510
10313
  class PagarmeBankSlipAxiosAdapter {
8511
10314
  constructor(credentials, paymentRepository) {
@@ -8522,7 +10325,7 @@ class PagarmeBankSlipAxiosAdapter {
8522
10325
  });
8523
10326
  console.warn('[PAGARME BOLETO DATA TO SEND]', payload);
8524
10327
  if (result.data.status !== PagarmePaymentStatus['Em processamento']) {
8525
- return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
10328
+ return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
8526
10329
  checkoutId: checkout.id,
8527
10330
  userEmail: checkout.user.email,
8528
10331
  info: result.data,
@@ -8540,7 +10343,7 @@ class PagarmeBankSlipAxiosAdapter {
8540
10343
  return payment;
8541
10344
  }
8542
10345
  catch (error) {
8543
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
10346
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
8544
10347
  checkoutId: checkout.id,
8545
10348
  userEmail: checkout.user.email,
8546
10349
  info: error.response.data,
@@ -8588,62 +10391,423 @@ class PagarmeBankSlipAxiosAdapter {
8588
10391
  },
8589
10392
  };
8590
10393
  }
8591
- }
8592
-
8593
- class PagarmeBlockedOrderHelper {
8594
- static async createBlockedOrderForUnauthorizedCard(params) {
8595
- const { checkout, card, orderBlockedRepository } = params;
8596
- await orderBlockedRepository.createBlockedOrderOrPayment({
8597
- checkout,
8598
- blockType: 'Card not authorized',
8599
- type: 'Card',
8600
- limiteRange: 'day',
8601
- card,
8602
- });
8603
- }
8604
- static createPaymentError(checkout, resultData) {
8605
- return new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
8606
- checkoutId: checkout.id,
8607
- userEmail: checkout.user.email,
8608
- info: resultData,
8609
- });
8610
- }
8611
- static createGenericPaymentError(checkout, errorResponseData) {
8612
- return new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', {
8613
- checkoutId: checkout.id,
8614
- userEmail: checkout.user.email,
8615
- info: errorResponseData,
8616
- });
10394
+ }
10395
+
10396
+ class PagarmeBlockedOrderHelper {
10397
+ static async createBlockedOrderForUnauthorizedCard(params) {
10398
+ const { checkout, card, orderBlockedRepository, gatewayInfo } = params;
10399
+ await orderBlockedRepository.createBlockedOrderOrPayment({
10400
+ checkout,
10401
+ blockType: 'Card not authorized',
10402
+ type: 'Card',
10403
+ limiteRange: 'day',
10404
+ card,
10405
+ gatewayInfo,
10406
+ });
10407
+ }
10408
+ static createPaymentError(checkout, errorType, resultData) {
10409
+ return new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', errorType, {
10410
+ checkoutId: checkout.id,
10411
+ userEmail: checkout.user.email,
10412
+ info: resultData,
10413
+ });
10414
+ }
10415
+ static createGenericPaymentError(checkout, errorType, errorResponseData) {
10416
+ return new PaymentError('Seu pagamento com cartão não foi autorizado. Para não perder seus produtos, pague com PIX ou outro cartão de crédito', errorType, {
10417
+ checkoutId: checkout.id,
10418
+ userEmail: checkout.user.email,
10419
+ info: errorResponseData,
10420
+ });
10421
+ }
10422
+ }
10423
+
10424
+ /* eslint-disable complexity */
10425
+ class PagarMeErrorHelper {
10426
+ static getErrorTypeFromResponse(errorCode) {
10427
+ switch (errorCode) {
10428
+ // Cartão inválido, vencido, bloqueado
10429
+ case '1000':
10430
+ case '1001':
10431
+ case '1011':
10432
+ case '1025':
10433
+ case '1032':
10434
+ case '1045':
10435
+ case '1068':
10436
+ case '1069':
10437
+ case '1070':
10438
+ case '2001':
10439
+ case '2004':
10440
+ case '5025':
10441
+ case '9124':
10442
+ return ErrorsCode.invalidCardError;
10443
+ // Dados obrigatórios ausentes
10444
+ case '1044':
10445
+ case '5034':
10446
+ case '5047':
10447
+ case '5061':
10448
+ return ErrorsCode.invalidCardError;
10449
+ // Suspeita de fraude, prevenção do banco
10450
+ case '1002':
10451
+ case '1004':
10452
+ case '1019':
10453
+ case '2002':
10454
+ case '2005':
10455
+ case '2007':
10456
+ case '2008':
10457
+ case '2009':
10458
+ case '2010':
10459
+ case '9201':
10460
+ return ErrorsCode.fraudPreventionExternal;
10461
+ // Recusado pelo banco/emissor
10462
+ case '1007':
10463
+ case '1008':
10464
+ case '2000':
10465
+ case '5093':
10466
+ return ErrorsCode.paymentNotAuthorizedError;
10467
+ // Saldo/limite insuficiente ou excedido
10468
+ case '1016':
10469
+ case '1021':
10470
+ case '1023':
10471
+ case '2011':
10472
+ case '2012':
10473
+ case '5051':
10474
+ case '5087':
10475
+ return ErrorsCode.insufficientFundsError;
10476
+ // Valor solicitado inválido
10477
+ case '5094':
10478
+ case '5016':
10479
+ case '5092':
10480
+ return ErrorsCode.paymentError;
10481
+ // Erros internos ou genéricos
10482
+ case '5000':
10483
+ case '5001':
10484
+ case '5003':
10485
+ case '5004':
10486
+ case '5006':
10487
+ case '5008':
10488
+ case '5009':
10489
+ case '5010':
10490
+ case '5011':
10491
+ case '5012':
10492
+ case '5013':
10493
+ case '5014':
10494
+ case '5015':
10495
+ case '5017':
10496
+ case '5018':
10497
+ case '5019':
10498
+ case '5020':
10499
+ case '5021':
10500
+ case '5022':
10501
+ case '5023':
10502
+ case '5024':
10503
+ case '5026':
10504
+ case '5027':
10505
+ case '5028':
10506
+ case '5029':
10507
+ case '5030':
10508
+ case '5031':
10509
+ case '5032':
10510
+ case '5033':
10511
+ case '5035':
10512
+ case '5036':
10513
+ case '5037':
10514
+ case '5038':
10515
+ case '5039':
10516
+ case '5040':
10517
+ case '5041':
10518
+ case '5042':
10519
+ case '5043':
10520
+ case '5044':
10521
+ case '5045':
10522
+ case '5049':
10523
+ case '5050':
10524
+ case '5052':
10525
+ case '5053':
10526
+ case '5054':
10527
+ case '5055':
10528
+ case '5056':
10529
+ case '5057':
10530
+ case '5058':
10531
+ case '5059':
10532
+ case '5060':
10533
+ case '5062':
10534
+ case '5063':
10535
+ case '5064':
10536
+ case '5065':
10537
+ case '5066':
10538
+ case '5067':
10539
+ case '5068':
10540
+ case '5069':
10541
+ case '5070':
10542
+ case '5071':
10543
+ case '5072':
10544
+ case '5073':
10545
+ case '5074':
10546
+ case '5075':
10547
+ case '5076':
10548
+ case '5077':
10549
+ case '5078':
10550
+ case '5079':
10551
+ case '5080':
10552
+ case '5081':
10553
+ case '5082':
10554
+ case '5083':
10555
+ case '5084':
10556
+ case '5085':
10557
+ case '5089':
10558
+ case '5090':
10559
+ case '5095':
10560
+ case '5096':
10561
+ case '5097':
10562
+ return ErrorsCode.paymentError;
10563
+ // Banco/emissor inválido ou não operante
10564
+ case '1049':
10565
+ case '1050':
10566
+ return ErrorsCode.paymentError;
10567
+ // Transação não suportada para o banco/emissor
10568
+ case '1061':
10569
+ return ErrorsCode.paymentError;
10570
+ case '1010':
10571
+ case '1046':
10572
+ return ErrorsCode.invalidCheckoutError;
10573
+ default:
10574
+ return ErrorsCode.paymentError;
10575
+ }
10576
+ }
10577
+ }
10578
+
10579
+ class PagarmePaymentFactoryHelper {
10580
+ static async createSuccessfulPayment(params) {
10581
+ const { checkout, resultData, paymentRepository } = params;
10582
+ const payment = await paymentRepository.create({
10583
+ createdAt: new Date(),
10584
+ updatedAt: new Date(),
10585
+ userId: checkout.user.id,
10586
+ checkoutId: checkout.id,
10587
+ totalPrice: checkout.totalPrice,
10588
+ paymentProvider: PaymentProviders.PAGARME,
10589
+ transaction: { ...resultData, paidAt: new Date() },
10590
+ });
10591
+ return payment;
10592
+ }
10593
+ }
10594
+
10595
+ class PagarmePaymentOperationsHelper {
10596
+ static async executePaymentRequest(params) {
10597
+ const { checkout, card, credentials, createPayloadFunction } = params;
10598
+ const payload = createPayloadFunction(checkout, card);
10599
+ console.warn('[PAGARME CARD DATA TO SEND]', payload);
10600
+ const result = await axios({
10601
+ method: 'POST',
10602
+ url: `${credentials.URL}/transactions`,
10603
+ data: payload,
10604
+ });
10605
+ return result;
10606
+ }
10607
+ }
10608
+
10609
+ class PagarMeV5RequestHelper {
10610
+ static build(checkout, method, card) {
10611
+ return {
10612
+ items: this.buildItems(checkout),
10613
+ customer: this.buildCustomer(checkout),
10614
+ shipping: this.buildShipping(checkout),
10615
+ payments: this.buildPayment(checkout, method, card),
10616
+ ...this.buildAdditionalInfo(checkout),
10617
+ };
10618
+ }
10619
+ static buildItems(checkout) {
10620
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
10621
+ return checkout.lineItems
10622
+ .filter((item) => !item.isGift)
10623
+ .map((item) => {
10624
+ return {
10625
+ amount: Math.floor(item.pricePaid * 100),
10626
+ description: isSubscriber ? `${item.name} - ASSINANTE` : item.name,
10627
+ quantity: item.quantity,
10628
+ code: item.EAN,
10629
+ };
10630
+ });
10631
+ }
10632
+ static buildCustomer(checkout) {
10633
+ return {
10634
+ name: checkout.user.displayName,
10635
+ email: checkout.user.email,
10636
+ type: 'individual',
10637
+ document: checkout.user.cpf,
10638
+ phones: {
10639
+ home_phone: {
10640
+ country_code: '55',
10641
+ number: checkout.user.phone.slice(2),
10642
+ area_code: checkout.user.phone.slice(0, 2),
10643
+ },
10644
+ mobile_phone: {
10645
+ country_code: '55',
10646
+ number: checkout.user.phone.slice(2),
10647
+ area_code: checkout.user.phone.slice(0, 2),
10648
+ },
10649
+ },
10650
+ address: {
10651
+ line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
10652
+ line_2: `${checkout.billingAddress.extension}`,
10653
+ zip_code: checkout.shippingAddress.zip,
10654
+ city: checkout.billingAddress.city,
10655
+ state: checkout.billingAddress.state,
10656
+ country: 'BR',
10657
+ },
10658
+ };
10659
+ }
10660
+ static buildShipping(checkout) {
10661
+ return {
10662
+ amount: Math.floor(checkout.shipping.ShippingPrice * 100),
10663
+ description: `${checkout.shipping.ShippingCompanyName} - ${checkout.shipping.description}`,
10664
+ recipient_name: checkout.shippingAddress.recipient,
10665
+ recipient_phone: checkout.user.phone,
10666
+ address: {
10667
+ line_1: `${checkout.shippingAddress.number}, ${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
10668
+ line_2: `${checkout.shippingAddress.extension}`,
10669
+ zip_code: checkout.shippingAddress.zip,
10670
+ city: checkout.shippingAddress.city,
10671
+ state: checkout.shippingAddress.state,
10672
+ country: 'BR',
10673
+ },
10674
+ };
10675
+ }
10676
+ static buildPayment(checkout, method, card) {
10677
+ return [
10678
+ {
10679
+ payment_method: method,
10680
+ amount: Math.floor(checkout.totalPrice * 100),
10681
+ ...(method === 'pix' && {
10682
+ pix: this.getPixOrder(),
10683
+ }),
10684
+ ...(method === 'boleto' && {
10685
+ boleto: this.getBoletoOrder(),
10686
+ }),
10687
+ ...(method === 'credit_card' && {
10688
+ credit_card: this.getCardOrder(checkout, card),
10689
+ }),
10690
+ },
10691
+ ];
10692
+ }
10693
+ static getPixOrder() {
10694
+ return {
10695
+ expires_at: format(addHours(new Date(), 24), "yyyy-MM-dd'T'HH:mm:ss.SSSxxx"),
10696
+ };
10697
+ }
10698
+ static getBoletoOrder() {
10699
+ return {
10700
+ due_at: format(addDays(new Date(), 3), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
10701
+ instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
10702
+ type: 'DM',
10703
+ document_number: new Date().getTime().toString(),
10704
+ };
10705
+ }
10706
+ static getCardOrder(checkout, card) {
10707
+ return {
10708
+ installments: card.installments,
10709
+ statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'loja glam' : 'mens market',
10710
+ card_id: card.cardId,
10711
+ card: {
10712
+ cvv: card.cardCvv,
10713
+ billing_address: {
10714
+ line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
10715
+ zip_code: checkout.billingAddress.zip,
10716
+ city: checkout.billingAddress.city,
10717
+ state: checkout.billingAddress.state,
10718
+ country: 'BR',
10719
+ },
10720
+ },
10721
+ };
10722
+ }
10723
+ static buildAdditionalInfo(checkout) {
10724
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
10725
+ if (isSubscriber)
10726
+ return {
10727
+ antifraude_enabled: false,
10728
+ };
10729
+ return {};
8617
10730
  }
8618
10731
  }
8619
10732
 
8620
- class PagarmePaymentFactoryHelper {
8621
- static async createSuccessfulPayment(params) {
8622
- const { checkout, resultData, paymentRepository } = params;
8623
- const payment = await paymentRepository.create({
10733
+ class PagarMeV5ResponseHelper {
10734
+ static build(method, checkout, response) {
10735
+ return Payment.toInstance({
8624
10736
  createdAt: new Date(),
8625
10737
  updatedAt: new Date(),
8626
10738
  userId: checkout.user.id,
8627
10739
  checkoutId: checkout.id,
8628
10740
  totalPrice: checkout.totalPrice,
8629
10741
  paymentProvider: PaymentProviders.PAGARME,
8630
- transaction: { ...resultData, paidAt: new Date() },
8631
- });
8632
- return payment;
10742
+ pagarMeOrderId: response.id,
10743
+ transaction: this.buildPaymentTransaction(method, response),
10744
+ });
10745
+ }
10746
+ static buildPaymentTransaction(method, response) {
10747
+ const charger = response.charges.at(0);
10748
+ const transaction = charger.last_transaction;
10749
+ return PaymentTransaction.toInstance({
10750
+ acquirer_name: PaymentProviders.PAGARME,
10751
+ amount: charger.amount,
10752
+ currency: charger.currency,
10753
+ gateway_id: charger.gateway_id,
10754
+ status: this.getPaymentStatus(transaction.status),
10755
+ payment_method: charger.payment_method,
10756
+ date_created: charger.created_at,
10757
+ date_updated: charger.updated_at,
10758
+ paid_amount: charger.paid_amount,
10759
+ paid_at: charger.paid_at,
10760
+ order_id: response.id,
10761
+ charger_id: charger.id,
10762
+ tid: charger.id,
10763
+ id: charger.id,
10764
+ ...(method == TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(transaction)),
10765
+ ...(method == TransactionPaymentMethods.PIX && this.getPixReponse(transaction)),
10766
+ ...(method == TransactionPaymentMethods.CARD && this.getCardReponse(transaction)),
10767
+ });
10768
+ }
10769
+ static getPaymentStatus(status) {
10770
+ if (status == PagarMeV5PaymentStatus.Gerado)
10771
+ return PagarMeV5PaymentStatus['Aguardando pagamento'];
10772
+ if (status == PagarMeV5PaymentStatus.Capturada)
10773
+ return PagarMeV5PaymentStatus.Pago;
10774
+ return status;
10775
+ }
10776
+ static getBoletoReponse(transaction) {
10777
+ return {
10778
+ boleto_url: transaction.url?.toString(),
10779
+ boleto_barcode: transaction.line?.toString(),
10780
+ boleto_qr_code: transaction.qr_code?.toString(),
10781
+ boleto_expiration_date: transaction.due_at?.toString(),
10782
+ boleto_instructions: transaction.instructions?.toString(),
10783
+ boleto_nosso_numero: transaction.nosso_numero?.toString(),
10784
+ boleto_type: transaction.type?.toString(),
10785
+ boleto_document_number: transaction.document_number?.toString(),
10786
+ };
8633
10787
  }
8634
- }
8635
-
8636
- class PagarmePaymentOperationsHelper {
8637
- static async executePaymentRequest(params) {
8638
- const { checkout, card, credentials, createPayloadFunction } = params;
8639
- const payload = createPayloadFunction(checkout, card);
8640
- console.warn('[PAGARME CARD DATA TO SEND]', payload);
8641
- const result = await axios({
8642
- method: 'POST',
8643
- url: `${credentials.URL}/transactions`,
8644
- data: payload,
8645
- });
8646
- return result;
10788
+ static getPixReponse(transaction) {
10789
+ return {
10790
+ pix_qr_code: transaction.qr_code?.toString(),
10791
+ pix_qr_code_url: transaction.qr_code_url?.toString(),
10792
+ pix_expiration_date: transaction.expires_at?.toString(),
10793
+ };
10794
+ }
10795
+ static getCardReponse(transaction) {
10796
+ return {
10797
+ soft_descriptor: transaction.statement_descriptor?.toString(),
10798
+ acquirer_name: transaction.acquirer_name?.toString(),
10799
+ acquirer_id: transaction.acquirer_tid?.toString(),
10800
+ acquirer_nsu: transaction.acquirer_nsu?.toString(),
10801
+ acquirer_auth_code: transaction.acquirer_auth_code?.toString(),
10802
+ acquirer_message: transaction.acquirer_message?.toString(),
10803
+ acquirer_return_code: transaction.acquirer_return_code?.toString(),
10804
+ installments: transaction.installments ?? null,
10805
+ card_holder_name: transaction.card?.holder_name?.toString(),
10806
+ card_last_digits: transaction.card?.last_four_digits?.toString(),
10807
+ card_first_digits: transaction.card?.first_six_digits?.toString(),
10808
+ card_brand: transaction.card?.brand?.toString(),
10809
+ card_id: transaction.card?.id?.toString(),
10810
+ };
8647
10811
  }
8648
10812
  }
8649
10813
 
@@ -8667,7 +10831,7 @@ class PagarmeCardAxiosAdapter {
8667
10831
  card,
8668
10832
  orderBlockedRepository: this.orderBlockedRepository,
8669
10833
  });
8670
- throw PagarmeBlockedOrderHelper.createPaymentError(checkout, result.data);
10834
+ throw PagarmeBlockedOrderHelper.createPaymentError(checkout, ErrorsCode.paymentError, result.data);
8671
10835
  }
8672
10836
  return PagarmePaymentFactoryHelper.createSuccessfulPayment({
8673
10837
  checkout,
@@ -8679,7 +10843,7 @@ class PagarmeCardAxiosAdapter {
8679
10843
  if (error instanceof PaymentError) {
8680
10844
  throw error;
8681
10845
  }
8682
- throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
10846
+ throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, ErrorsCode.paymentError, error.response?.data);
8683
10847
  }
8684
10848
  }
8685
10849
  async addCard(card) {
@@ -8703,8 +10867,9 @@ class PagarmeCardAxiosAdapter {
8703
10867
  });
8704
10868
  }
8705
10869
  }
8706
- async createCardHash(bu) {
8707
- const key = bu === BusinessUnitEnum.SHOP ? this.credentials.SHOP_API_KEY : this.credentials.SUBSCRIPTION_API_KEY;
10870
+ async createCardHash(bu, shop) {
10871
+ const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
10872
+ const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
8708
10873
  try {
8709
10874
  const { data } = await axios({
8710
10875
  method: 'GET',
@@ -8835,7 +11000,7 @@ class PagarmePixAxiosAdapter {
8835
11000
  return payment;
8836
11001
  }
8837
11002
  catch (error) {
8838
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
11003
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', ErrorsCode.paymentError, {
8839
11004
  checkoutId: checkout.id,
8840
11005
  userEmail: checkout.user.email,
8841
11006
  info: error.response?.data,
@@ -8867,6 +11032,341 @@ class PagarmePixAxiosAdapter {
8867
11032
  }
8868
11033
  }
8869
11034
 
11035
+ class PagarmeV5BankSlipAxiosAdapter {
11036
+ constructor(credentials, paymentRepository) {
11037
+ this.credentials = credentials;
11038
+ this.paymentRepository = paymentRepository;
11039
+ }
11040
+ async pay(checkout) {
11041
+ try {
11042
+ const payload = PagarMeV5RequestHelper.build(checkout, 'boleto');
11043
+ console.warn('[PAGARME BOLETO DATA TO SEND]', JSON.stringify(payload));
11044
+ const { data } = await axios({
11045
+ method: 'POST',
11046
+ url: `${this.credentials.URL}/orders`,
11047
+ headers: {
11048
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
11049
+ 'Content-Type': 'application/json',
11050
+ },
11051
+ data: payload,
11052
+ });
11053
+ console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
11054
+ if (data.status === PagarMeV5OrderStatus.Falha ||
11055
+ data.charges.at(0).status === PagarMeV5OrderStatus.Falha ||
11056
+ (data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus.Gerado &&
11057
+ data.charges.at(0).last_transaction.status !== PagarMeV5PaymentStatus['Em processamento'])) {
11058
+ return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
11059
+ checkoutId: checkout.id,
11060
+ userEmail: checkout.user.email,
11061
+ info: data.charges.at(0).last_transaction?.gateway_response,
11062
+ }));
11063
+ }
11064
+ const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.BANKSLIP, checkout, data));
11065
+ return payment;
11066
+ }
11067
+ catch (error) {
11068
+ if (error instanceof AxiosError) {
11069
+ console.error('error data: ', JSON.stringify(error.response?.data));
11070
+ }
11071
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', ErrorsCode.paymentError, {
11072
+ checkoutId: checkout.id,
11073
+ userEmail: checkout.user.email,
11074
+ info: error.response?.data,
11075
+ });
11076
+ }
11077
+ }
11078
+ async getBoletoTransaction(paymentId) {
11079
+ try {
11080
+ const { data } = await axios({
11081
+ method: 'GET',
11082
+ url: `${this.credentials.URL}/charges/${paymentId}`,
11083
+ headers: {
11084
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
11085
+ 'Content-Type': 'application/json',
11086
+ },
11087
+ });
11088
+ const payment = await this.paymentRepository.get({
11089
+ id: data.id,
11090
+ });
11091
+ return payment.transaction;
11092
+ }
11093
+ catch (error) {
11094
+ throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
11095
+ paymentId,
11096
+ info: error.response.data,
11097
+ });
11098
+ }
11099
+ }
11100
+ }
11101
+
11102
+ class PagarmeV5BaseAxiosAdapter {
11103
+ constructor(credentials, paymentRepository) {
11104
+ this.credentials = credentials;
11105
+ this.paymentRepository = paymentRepository;
11106
+ }
11107
+ async refund(order, amount) {
11108
+ try {
11109
+ console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment, 'with amount', amount);
11110
+ const amountToSend = +amount.toFixed(2) * 100;
11111
+ console.warn('[PAGARME REFUND] Amount to send in cents', amountToSend);
11112
+ const { data } = await axios({
11113
+ method: 'DELETE',
11114
+ url: `${this.credentials.URL}/charges/${order.payment.charger_id}`,
11115
+ headers: {
11116
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
11117
+ 'Content-Type': 'application/json',
11118
+ },
11119
+ data: {
11120
+ amount: amountToSend,
11121
+ },
11122
+ });
11123
+ console.warn('[RESPONSE PAGARME REFUND]', JSON.stringify(data));
11124
+ await this.paymentRepository.create({
11125
+ createdAt: new Date(),
11126
+ updatedAt: new Date(),
11127
+ userId: order.user.id,
11128
+ orderId: order.id,
11129
+ totalPrice: amount,
11130
+ paymentProvider: PaymentProviders.PAGARME,
11131
+ pagarMeOrderId: data.id,
11132
+ transaction: data,
11133
+ });
11134
+ return {
11135
+ status: this.getRefundStatus(data.status),
11136
+ success: [PagarMeV5OrderStatus.Pago, PagarMeV5OrderStatus.Cancelado].includes(data.status) ? true : false,
11137
+ };
11138
+ }
11139
+ catch (error) {
11140
+ console.error('Error during refund process for order', order.id, 'with error', error);
11141
+ throw error;
11142
+ }
11143
+ }
11144
+ getRefundStatus(status) {
11145
+ if ([PagarMeV5PaymentStatus['Em processamento']].includes(status)) {
11146
+ return 'processing';
11147
+ }
11148
+ if ([PagarMeV5OrderStatus.Pago, PagarMeV5OrderStatus.Cancelado].includes(status)) {
11149
+ return 'success';
11150
+ }
11151
+ return 'unknown';
11152
+ }
11153
+ }
11154
+
11155
+ class PagarmeV5CardAxiosAdapter extends PagarmeV5BaseAxiosAdapter {
11156
+ constructor(credentials, paymentRepository, orderBlockedRepository) {
11157
+ super(credentials, paymentRepository);
11158
+ this.credentials = credentials;
11159
+ this.paymentRepository = paymentRepository;
11160
+ this.orderBlockedRepository = orderBlockedRepository;
11161
+ }
11162
+ async pay(checkout, card) {
11163
+ try {
11164
+ const payload = PagarMeV5RequestHelper.build(checkout, 'credit_card', card);
11165
+ console.warn('[PAGARME CARD DATA TO SEND]', JSON.stringify(payload));
11166
+ const { data } = await axios({
11167
+ method: 'POST',
11168
+ url: `${this.credentials.URL}/orders`,
11169
+ headers: {
11170
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
11171
+ 'Content-Type': 'application/json',
11172
+ },
11173
+ data: payload,
11174
+ });
11175
+ console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
11176
+ const charge = data.charges.at(0);
11177
+ if (data.status == PagarMeV5OrderStatus.Falha ||
11178
+ charge.status !== PagarMeV5OrderStatus.Pago ||
11179
+ charge.last_transaction.status !== PagarMeV5PaymentStatus.Capturada) {
11180
+ await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
11181
+ checkout,
11182
+ card,
11183
+ orderBlockedRepository: this.orderBlockedRepository,
11184
+ gatewayInfo: {
11185
+ gateway: PaymentProviders.PAGARME,
11186
+ status: charge.status,
11187
+ statusDetail: charge.last_transaction?.status,
11188
+ },
11189
+ });
11190
+ const errorCode = PagarMeErrorHelper.getErrorTypeFromResponse(charge.last_transaction.acquirer_return_code);
11191
+ throw PagarmeBlockedOrderHelper.createPaymentError(checkout, errorCode, data);
11192
+ }
11193
+ const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
11194
+ return payment;
11195
+ }
11196
+ catch (error) {
11197
+ if (error instanceof AxiosError) {
11198
+ console.error('error data: ', JSON.stringify(error.response?.data));
11199
+ throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, ErrorsCode.paymentError, error.response?.data);
11200
+ }
11201
+ throw error;
11202
+ }
11203
+ }
11204
+ async addCard(card, customer) {
11205
+ try {
11206
+ const { id } = await this.createOrUpdateCustomer(customer);
11207
+ const { data } = await axios({
11208
+ method: 'POST',
11209
+ url: `${this.credentials.URL}/customers/${id}/cards`,
11210
+ headers: {
11211
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
11212
+ 'Content-Type': 'application/json',
11213
+ },
11214
+ data: {
11215
+ number: card.number,
11216
+ holder_name: card.name,
11217
+ holder_document: card.cpf,
11218
+ exp_month: card.expirationDate.split('/').at(0),
11219
+ exp_year: card.expirationDate.split('/').at(1),
11220
+ cvv: card.cvv,
11221
+ billing_address: {
11222
+ line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
11223
+ line_2: `${customer.billingAddress.extension}`,
11224
+ zip_code: customer.billingAddress.zip,
11225
+ city: customer.billingAddress.city,
11226
+ state: customer.billingAddress.state,
11227
+ country: 'BR',
11228
+ },
11229
+ },
11230
+ });
11231
+ return data;
11232
+ }
11233
+ catch (error) {
11234
+ console.warn(JSON.stringify(error));
11235
+ throw error;
11236
+ }
11237
+ }
11238
+ async createCardHash(bu, shop) {
11239
+ const credentials = shop && shop == Shops.MENSMARKET ? this.credentials[Shops.MENSMARKET] : this.credentials[Shops.GLAMSHOP];
11240
+ const key = bu === BusinessUnitEnum.SHOP ? credentials.SHOP_API_KEY : credentials.SUBSCRIPTION_API_KEY;
11241
+ try {
11242
+ const { data } = await axios({
11243
+ method: 'GET',
11244
+ headers: {
11245
+ 'content-type': 'application/json',
11246
+ },
11247
+ url: `${this.credentials.URL}/transactions/card_hash_key`,
11248
+ data: JSON.stringify({
11249
+ api_key: key,
11250
+ }),
11251
+ });
11252
+ return data;
11253
+ }
11254
+ catch (error) {
11255
+ throw new BusinessError('Houve uma falha gerar o hash', {
11256
+ info: error.response.data,
11257
+ });
11258
+ }
11259
+ }
11260
+ async getCardByToken(customerId, token) {
11261
+ try {
11262
+ const { data } = await axios({
11263
+ method: 'GET',
11264
+ url: `${this.credentials.URL}/cards/${token}`,
11265
+ data: {
11266
+ api_key: this.credentials.API_KEY,
11267
+ },
11268
+ });
11269
+ return data;
11270
+ }
11271
+ catch (error) {
11272
+ throw new BusinessError('Houve uma falha buscar o cartão com id: ' + token, {
11273
+ info: error.response.data,
11274
+ });
11275
+ }
11276
+ }
11277
+ async createTransaction(info) {
11278
+ return info;
11279
+ }
11280
+ async createOrUpdateCustomer(customer) {
11281
+ try {
11282
+ const { data } = await axios({
11283
+ method: 'POST',
11284
+ url: `${this.credentials.URL}/customers`,
11285
+ headers: {
11286
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
11287
+ 'Content-Type': 'application/json',
11288
+ },
11289
+ data: {
11290
+ name: customer.displayName,
11291
+ email: customer.email,
11292
+ document: customer.cpf,
11293
+ type: 'individual',
11294
+ document_type: 'CPF',
11295
+ address: {
11296
+ line_1: `${customer.billingAddress.number}, ${customer.billingAddress.street}, ${customer.billingAddress.district}`,
11297
+ line_2: `${customer.billingAddress.extension}`,
11298
+ zip_code: customer.billingAddress.zip,
11299
+ city: customer.billingAddress.city,
11300
+ state: customer.billingAddress.state,
11301
+ country: 'BR',
11302
+ },
11303
+ birthdate: format(new Date(customer.birthday), 'MM/dd/yyyy'),
11304
+ phones: {
11305
+ home_phone: {
11306
+ country_code: '55',
11307
+ number: customer.phone.slice(2),
11308
+ area_code: customer.phone.slice(0, 2),
11309
+ },
11310
+ mobile_phone: {
11311
+ country_code: '55',
11312
+ number: customer.phone.slice(2),
11313
+ area_code: customer.phone.slice(0, 2),
11314
+ },
11315
+ },
11316
+ },
11317
+ });
11318
+ return data;
11319
+ }
11320
+ catch (error) {
11321
+ console.warn(error);
11322
+ throw error;
11323
+ }
11324
+ }
11325
+ }
11326
+
11327
+ class PagarmeV5PixAxiosAdapter extends PagarmeV5BaseAxiosAdapter {
11328
+ constructor(credentials, paymentRepository) {
11329
+ super(credentials, paymentRepository);
11330
+ this.credentials = credentials;
11331
+ this.paymentRepository = paymentRepository;
11332
+ }
11333
+ async pay(checkout) {
11334
+ try {
11335
+ const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
11336
+ console.warn('[PAGARME PIX DATA TO SEND]', JSON.stringify(payload));
11337
+ const { data } = await axios({
11338
+ method: 'POST',
11339
+ url: `${this.credentials.URL}/orders`,
11340
+ headers: {
11341
+ Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
11342
+ 'Content-Type': 'application/json',
11343
+ },
11344
+ data: payload,
11345
+ });
11346
+ console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
11347
+ if (data.status == PagarMeV5OrderStatus.Falha || data.status == PagarMeV5OrderStatus.Cancelado) {
11348
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', ErrorsCode.paymentError, {
11349
+ checkoutId: checkout.id,
11350
+ userEmail: checkout.user.email,
11351
+ info: data.charges.at(0).last_transaction?.gateway_response,
11352
+ });
11353
+ }
11354
+ const payment = await this.paymentRepository.create(PagarMeV5ResponseHelper.build(TransactionPaymentMethods.PIX, checkout, data));
11355
+ return payment;
11356
+ }
11357
+ catch (error) {
11358
+ if (error instanceof AxiosError) {
11359
+ console.error('error data: ', JSON.stringify(error.response?.data));
11360
+ }
11361
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', ErrorsCode.paymentError, {
11362
+ checkoutId: checkout.id,
11363
+ userEmail: checkout.user.email,
11364
+ info: error.response?.data,
11365
+ });
11366
+ }
11367
+ }
11368
+ }
11369
+
8870
11370
  class VertexAxiosAdapter {
8871
11371
  constructor(config) {
8872
11372
  this.config = config;
@@ -9020,4 +11520,4 @@ class ProductsVertexSearch {
9020
11520
  }
9021
11521
  }
9022
11522
 
9023
- export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
11523
+ export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandCategory, BrandCategoryFirestoreRepository, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, ErrorsCode, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, InvalidCheckoutError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, MercadoPagoBankSlipAxiosAdapter, MercadoPagoCardAxiosAdapter, MercadoPagoErrorHelper, MercadoPagoPaymentMethodFactory, MercadoPagoPixAxiosAdapter, MercadoPagoRequestHelper, MercadoPagoResponseHelper, MercadoPagoStatusDetailEnum, MercadoPagoStatusEnum, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderPaymentStatus, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5BaseAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQL, ProductCatalogHasuraGraphQLRepository, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductGroup, ProductGroupHasuraGraphQLRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductPriceLog, ProductPriceLogHasuraGraphQLRepository, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockEntry, ProductStockEntryHasuraGraphQL, ProductStockEntryHasuraGraphQLRepository, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopConfigs, ShopConfigsFirestoreRepository, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, ShoppingRecurrence, ShoppingRecurrenceCycle, ShoppingRecurrenceEdition, ShoppingRecurrenceEditionFirestoreRepository, ShoppingRecurrenceEditionStatus, ShoppingRecurrenceErrorLog, ShoppingRecurrenceErrorLogFirestoreRepository, ShoppingRecurrenceFirestoreRepository, ShoppingRecurrenceStatus, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };