@infrab4a/connect 5.4.0-beta.9 → 5.4.0

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 (53) hide show
  1. package/index.cjs.js +665 -641
  2. package/index.esm.js +664 -638
  3. package/package.json +3 -3
  4. package/src/domain/catalog/models/category-brand.d.ts +17 -0
  5. package/src/domain/catalog/models/index.d.ts +1 -0
  6. package/src/domain/catalog/models/product-base.d.ts +0 -1
  7. package/src/domain/catalog/models/product.d.ts +0 -1
  8. package/src/domain/catalog/repositories/category-brand.repository.d.ts +4 -0
  9. package/src/domain/catalog/repositories/index.d.ts +1 -1
  10. package/src/domain/shopping/enums/index.d.ts +1 -0
  11. package/src/domain/shopping/enums/order-payment-status.enum.d.ts +10 -0
  12. package/src/domain/shopping/enums/payment-providers.enum.d.ts +2 -1
  13. package/src/domain/shopping/factories/index.d.ts +1 -0
  14. package/src/domain/shopping/factories/mercado-pago-payment-method.factory.d.ts +11 -0
  15. package/src/domain/shopping/factories/payment-provider.factory.d.ts +2 -0
  16. package/src/domain/shopping/models/order.d.ts +7 -1
  17. package/src/domain/shopping/models/payment-transaction.d.ts +2 -0
  18. package/src/domain/shopping/models/payment.d.ts +1 -0
  19. package/src/domain/shopping/services/antifraud-card.service.d.ts +2 -0
  20. package/src/domain/shopping/types/checkout-paylod-request.type.d.ts +2 -7
  21. package/src/domain/shopping/types/index.d.ts +2 -0
  22. package/src/domain/shopping/types/mercado-pago-card.type.d.ts +14 -0
  23. package/src/domain/shopping/types/mercado-pago-credentials.type.d.ts +5 -0
  24. package/src/domain/shopping/types/payment-card-info.type.d.ts +3 -0
  25. package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
  26. package/src/infra/firebase/firestore/repositories/catalog/category-brand-firestore.repository.d.ts +7 -0
  27. package/src/infra/firebase/firestore/repositories/catalog/index.d.ts +1 -0
  28. package/src/infra/hasura-graphql/models/index.d.ts +0 -1
  29. package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -1
  30. package/src/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +0 -1
  31. package/src/infra/index.d.ts +1 -0
  32. package/src/infra/mercado-pago/adapters/index.d.ts +3 -0
  33. package/src/infra/mercado-pago/adapters/mercado-pago-boleto-payment-axios.adapter.d.ts +8 -0
  34. package/src/infra/mercado-pago/adapters/mercado-pago-card-payment-axios.adapter.d.ts +20 -0
  35. package/src/infra/mercado-pago/adapters/mercado-pago-pix-payment-axios.adapter.d.ts +7 -0
  36. package/src/infra/mercado-pago/enums/index.d.ts +2 -0
  37. package/src/infra/mercado-pago/enums/mercado-pago-status-detail.enum.d.ts +33 -0
  38. package/src/infra/mercado-pago/enums/mercado-pago-status.enum.d.ts +10 -0
  39. package/src/infra/mercado-pago/helpers/index.d.ts +2 -0
  40. package/src/infra/mercado-pago/helpers/mercado-pago-request.helper.d.ts +60 -0
  41. package/src/infra/mercado-pago/helpers/mercado-pago-response.helper.d.ts +10 -0
  42. package/src/infra/mercado-pago/index.d.ts +4 -0
  43. package/src/infra/mercado-pago/types/index.d.ts +3 -0
  44. package/src/infra/mercado-pago/types/mercado-pago-request.type.d.ts +1 -0
  45. package/src/infra/mercado-pago/types/mercado-pago-response.type.d.ts +188 -0
  46. package/src/infra/mercado-pago/types/mercado-pago-status-detail.type.d.ts +2 -0
  47. package/src/infra/mercado-pago/types/mercado-pago-status.type.d.ts +2 -0
  48. package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +1 -0
  49. package/src/infra/pagarme/types/v5/pagarmev5-order-request-payload.type.d.ts +1 -0
  50. package/src/utils/index.d.ts +2 -2
  51. package/src/domain/catalog/repositories/product-catalog.repository.d.ts +0 -17
  52. package/src/infra/hasura-graphql/models/product-catalog-hasura-graphql.d.ts +0 -16
  53. package/src/infra/hasura-graphql/repositories/catalog/product-catalog-hasura-graphql.repository.d.ts +0 -22
package/index.cjs.js CHANGED
@@ -62,6 +62,18 @@ exports.OrderBlockedType = void 0;
62
62
  OrderBlockedType["Boleto"] = "Boleto";
63
63
  })(exports.OrderBlockedType || (exports.OrderBlockedType = {}));
64
64
 
65
+ exports.OrderPaymentStatus = void 0;
66
+ (function (OrderPaymentStatus) {
67
+ OrderPaymentStatus["Em processamento"] = "processing";
68
+ OrderPaymentStatus["Autorizada"] = "authorized";
69
+ OrderPaymentStatus["Pago"] = "paid";
70
+ OrderPaymentStatus["Estornada"] = "refunded";
71
+ OrderPaymentStatus["Aguardando pagamento"] = "waiting_payment";
72
+ OrderPaymentStatus["Aguardando estorno"] = "pending_refund";
73
+ OrderPaymentStatus["Recusada/N\u00E3o autorizada"] = "refused";
74
+ OrderPaymentStatus["Chargedback"] = "chargedback";
75
+ })(exports.OrderPaymentStatus || (exports.OrderPaymentStatus = {}));
76
+
65
77
  exports.PagarmePaymentStatus = void 0;
66
78
  (function (PagarmePaymentStatus) {
67
79
  PagarmePaymentStatus["Em processamento"] = "processing";
@@ -114,6 +126,7 @@ exports.PaymentProviders = void 0;
114
126
  PaymentProviders["PAGARME"] = "pagarMe";
115
127
  PaymentProviders["ADYEN"] = "adyen";
116
128
  PaymentProviders["GLAMPOINTS"] = "glampoints";
129
+ PaymentProviders["MERCADOPAGO"] = "mercadoPago";
117
130
  })(exports.PaymentProviders || (exports.PaymentProviders = {}));
118
131
 
119
132
  exports.TransactionPaymentMethods = void 0;
@@ -147,6 +160,9 @@ class AntifraudProviderFactory {
147
160
  class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
148
161
  }
149
162
 
163
+ class MercadoPagoPaymentMethodFactory extends BasePaymentMethodFactory {
164
+ }
165
+
150
166
  class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
151
167
  }
152
168
 
@@ -757,6 +773,30 @@ tslib.__decorate([
757
773
  ], Category.prototype, "filters", void 0);
758
774
  registerClass('Category', Category);
759
775
 
776
+ class BrandCategory extends BaseModel {
777
+ get glamImages() {
778
+ return this.images?.[exports.Shops.GLAMSHOP]
779
+ ? this.images[exports.Shops.GLAMSHOP]
780
+ : {
781
+ brandBanner: null,
782
+ brandBannerMobile: null,
783
+ image: null,
784
+ };
785
+ }
786
+ get mensImages() {
787
+ return this.images?.[exports.Shops.MENSMARKET]
788
+ ? this.images[exports.Shops.MENSMARKET]
789
+ : {
790
+ brandBanner: null,
791
+ brandBannerMobile: null,
792
+ image: null,
793
+ };
794
+ }
795
+ static get identifiersFields() {
796
+ return ['id'];
797
+ }
798
+ }
799
+
760
800
  class CategoryCollectionChildren extends BaseModel {
761
801
  static get identifiersFields() {
762
802
  return ['collectionId', 'categoryId'];
@@ -1760,19 +1800,58 @@ class AntifraudCardService {
1760
1800
  constructor(orderRepository, orderBlockedRepository) {
1761
1801
  this.orderRepository = orderRepository;
1762
1802
  this.orderBlockedRepository = orderBlockedRepository;
1763
- this.LIMIT_ORDERS_DAY = 2;
1764
- this.LIMIT_ORDERS_WEEK = 7;
1765
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
1803
+ this.LIMIT_ORDERS_DAY = null;
1804
+ this.LIMIT_ORDERS_WEEK = null;
1766
1805
  }
1767
1806
  async validate(checkout, card) {
1807
+ this.setLimitsByUserType(checkout.user.isSubscriber);
1768
1808
  await this.validateBlockedOrderAttempts(checkout, card);
1769
1809
  await this.validateDayAndWeekOrderLimits(checkout, card);
1770
1810
  return true;
1771
1811
  }
1812
+ setLimitsByUserType(isSubscriber) {
1813
+ this.LIMIT_ORDERS_DAY = {
1814
+ subscriber: {
1815
+ cpf: 4,
1816
+ email: 4,
1817
+ phone: 4,
1818
+ card: 4,
1819
+ zip: 4,
1820
+ },
1821
+ nonSubscriber: {
1822
+ cpf: 2,
1823
+ email: 2,
1824
+ phone: 2,
1825
+ card: 2,
1826
+ zip: 2,
1827
+ },
1828
+ };
1829
+ this.LIMIT_ORDERS_WEEK = {
1830
+ subscriber: {
1831
+ cpf: 12,
1832
+ email: 12,
1833
+ phone: 12,
1834
+ card: 12,
1835
+ zip: Infinity,
1836
+ },
1837
+ nonSubscriber: {
1838
+ cpf: 7,
1839
+ email: 7,
1840
+ phone: 7,
1841
+ card: 7,
1842
+ zip: Infinity,
1843
+ },
1844
+ };
1845
+ this.LIMIT_BLOCKED_ORDERS_DAY = isSubscriber ? 7 : 5;
1846
+ }
1847
+ getLimitsByUserType(type, isSubscriber) {
1848
+ const limits = type === 'day' ? this.LIMIT_ORDERS_DAY : this.LIMIT_ORDERS_WEEK;
1849
+ return isSubscriber ? limits['subscriber'] : limits['nonSubscriber'];
1850
+ }
1772
1851
  async validateBlockedOrderAttempts(checkout, card) {
1773
1852
  const isValid = await this.verifyBlockedOrderAttempts(checkout, card);
1774
1853
  if (!isValid) {
1775
- throw new FraudValidationError('Cliente com mais de 5 compras negadas/bloqueadas no dia', {
1854
+ throw new FraudValidationError(`Cliente com mais de ${this.LIMIT_BLOCKED_ORDERS_DAY} compras negadas/bloqueadas no dia`, {
1776
1855
  checkoutId: checkout.id,
1777
1856
  userEmail: checkout.user.email,
1778
1857
  info: {
@@ -1786,7 +1865,7 @@ class AntifraudCardService {
1786
1865
  async validateDayAndWeekOrderLimits(checkout, card) {
1787
1866
  const isValid = await this.verifyDayAndWeekOrders(checkout, card);
1788
1867
  if (!isValid) {
1789
- throw new FraudValidationError('Cliente tentando comprar mais de 2 vezes no dia ou 7 vezes na semana', {
1868
+ throw new FraudValidationError('Cliente tentando comprar mais do que o permitido no dia/semana', {
1790
1869
  checkoutId: checkout.id,
1791
1870
  userEmail: checkout.user.email,
1792
1871
  info: {
@@ -1805,7 +1884,7 @@ class AntifraudCardService {
1805
1884
  await this.createBlockedOrderRecord({
1806
1885
  checkout,
1807
1886
  card,
1808
- reason: 'More than 5 attempts have failed',
1887
+ reason: `More than ${this.LIMIT_BLOCKED_ORDERS_DAY} attempts have failed`,
1809
1888
  key: 'Failed attempts',
1810
1889
  period: 'day',
1811
1890
  });
@@ -1815,7 +1894,7 @@ class AntifraudCardService {
1815
1894
  }
1816
1895
  getTodayDateRange() {
1817
1896
  const timeZone = 'America/Sao_Paulo';
1818
- const today = dateFnsTz.toZonedTime(new Date(), timeZone);
1897
+ const today = dateFnsTz.utcToZonedTime(new Date(), timeZone);
1819
1898
  const day = dateFns.startOfDay(today);
1820
1899
  const endOfDay = dateFns.endOfDay(today);
1821
1900
  return { day: dateFns.addHours(day, 3), endOfDay: dateFns.addHours(endOfDay, 3) };
@@ -1926,26 +2005,28 @@ class AntifraudCardService {
1926
2005
  }
1927
2006
  async validateDayOrderLimits(checkout, params) {
1928
2007
  const ordersPerDay = await this.validateOrdersByRange(params, this.getDateRange('day'));
2008
+ const limits = this.getLimitsByUserType('day', checkout.user.isSubscriber);
1929
2009
  return this.checkOrderLimitsAndBlock({
1930
2010
  checkout,
1931
2011
  orderCounts: ordersPerDay,
1932
- limit: this.LIMIT_ORDERS_DAY,
2012
+ limit: limits,
1933
2013
  period: 'day',
1934
2014
  });
1935
2015
  }
1936
2016
  async validateWeekOrderLimits(checkout, params) {
1937
2017
  const ordersPerWeek = await this.validateOrdersByRange(params, this.getDateRange('week'));
2018
+ const limits = this.getLimitsByUserType('week', checkout.user.isSubscriber);
1938
2019
  return this.checkOrderLimitsAndBlock({
1939
2020
  checkout,
1940
2021
  orderCounts: ordersPerWeek,
1941
- limit: this.LIMIT_ORDERS_WEEK,
2022
+ limit: limits,
1942
2023
  period: 'week',
1943
2024
  });
1944
2025
  }
1945
2026
  async checkOrderLimitsAndBlock(params) {
1946
2027
  const { checkout, orderCounts, limit, period } = params;
1947
2028
  for (const key in orderCounts) {
1948
- if (orderCounts[key] >= limit) {
2029
+ if (orderCounts[key] >= limit[key]) {
1949
2030
  await this.createBlockedOrderRecord({
1950
2031
  checkout,
1951
2032
  card: null,
@@ -4763,6 +4844,17 @@ const withCrudFirestore = (MixinBase) => {
4763
4844
  };
4764
4845
  };
4765
4846
 
4847
+ class BrandCategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4848
+ constructor({ firestore, interceptors, }) {
4849
+ super({
4850
+ firestore,
4851
+ collectionName: 'brandsCategory',
4852
+ model: BrandCategory,
4853
+ interceptors,
4854
+ });
4855
+ }
4856
+ }
4857
+
4766
4858
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4767
4859
  constructor({ firestore, interceptors }) {
4768
4860
  super({
@@ -5851,9 +5943,6 @@ tslib.__decorate([
5851
5943
  tslib.__metadata("design:type", Product)
5852
5944
  ], KitProductHasuraGraphQL.prototype, "product", void 0);
5853
5945
 
5854
- class ProductCatalogHasuraGraphQL extends Product {
5855
- }
5856
-
5857
5946
  class ProductHasuraGraphQL extends Product {
5858
5947
  }
5859
5948
  tslib.__decorate([
@@ -7219,7 +7308,83 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7219
7308
  }
7220
7309
  }
7221
7310
 
7222
- const commonFields$1 = [
7311
+ class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7312
+ constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7313
+ super({
7314
+ tableName: 'product_errors',
7315
+ model: ProductErrorsHasuraGraphQL,
7316
+ endpoint,
7317
+ authOptions,
7318
+ interceptors,
7319
+ cache,
7320
+ fields: [
7321
+ {
7322
+ productId: {
7323
+ columnName: 'product_id',
7324
+ to: (value) => +value,
7325
+ from: (value) => value.toString(),
7326
+ },
7327
+ },
7328
+ 'source',
7329
+ 'error',
7330
+ { createdAt: { columnName: 'created_at' } },
7331
+ { updatedAt: { columnName: 'updated_at' } },
7332
+ {
7333
+ product: {
7334
+ columnName: 'product',
7335
+ foreignKeyColumn: { id: 'productId' },
7336
+ fields: [
7337
+ { id: { columnName: 'id', from: (value) => value.toString() } },
7338
+ { productId: { columnName: 'main_product_id' } },
7339
+ 'name',
7340
+ 'published',
7341
+ 'group',
7342
+ 'validity',
7343
+ { createdAt: { columnName: 'created_at' } },
7344
+ { updatedAt: { columnName: 'updated_at' } },
7345
+ ],
7346
+ },
7347
+ },
7348
+ ],
7349
+ });
7350
+ this.productRepository = productRepository;
7351
+ }
7352
+ async get(params) {
7353
+ const result = await super.get(params);
7354
+ if (result instanceof VariantHasuraGraphQL) {
7355
+ const product = await this.productRepository.get({ id: result.productId.toString() });
7356
+ result.product.name = product.name;
7357
+ result.product.group = product.group;
7358
+ }
7359
+ return result;
7360
+ }
7361
+ async find(params) {
7362
+ const result = await super.find(params);
7363
+ const variantsWithNoData = result.data.filter((item) => item.product instanceof VariantHasuraGraphQL &&
7364
+ (lodash.isEmpty(item.product.name) || lodash.isEmpty(item.product.group) || lodash.isEmpty(item.product)));
7365
+ if (variantsWithNoData.length > 0) {
7366
+ const { data: products } = await this.productRepository.find({
7367
+ filters: {
7368
+ id: {
7369
+ operator: exports.Where.IN,
7370
+ value: Array.from(new Set(variantsWithNoData.map((item) => item.product.productId?.toString()))),
7371
+ },
7372
+ },
7373
+ });
7374
+ products.forEach((product) => {
7375
+ result.data
7376
+ .filter((variant) => variant.product.productId?.toString() === product.id.toString())
7377
+ .forEach((variant) => {
7378
+ variant.product.name = product.name;
7379
+ variant.product.group = product.group;
7380
+ });
7381
+ });
7382
+ }
7383
+ return result;
7384
+ }
7385
+ }
7386
+
7387
+ const commonFields = [
7223
7388
  {
7224
7389
  id: {
7225
7390
  columnName: 'id',
@@ -7386,401 +7551,29 @@ const commonFields$1 = [
7386
7551
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7387
7552
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7388
7553
  { daysOfUse: { columnName: 'days_of_use' } },
7389
- { showVariants: { columnName: 'show_variants' } },
7390
- { variantSlug: { columnName: 'variant_slug' } },
7391
7554
  ];
7392
- class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
7393
- constructor({ endpoint, authOptions, interceptors, cache, }) {
7394
- super({
7395
- tableName: 'product_catalog',
7396
- model: ProductCatalogHasuraGraphQL,
7397
- endpoint,
7398
- authOptions,
7399
- interceptors,
7400
- fields: commonFields$1,
7401
- cache,
7402
- });
7403
- }
7404
- async get({ id }, options) {
7405
- if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7406
- const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
7407
- const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7408
- if (cachedData) {
7409
- this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7410
- return this.model.toInstance(deserialize(cachedData));
7411
- }
7412
- }
7413
- const product = await super
7414
- .find({
7415
- filters: {
7416
- id,
7417
- },
7418
- limits: {
7419
- limit: 1,
7420
- },
7421
- })
7422
- .then((res) => res.data.at(0));
7423
- if (!product)
7424
- throw new NotFoundError(`Product not found`);
7425
- if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7426
- const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
7427
- await this.cache.cacheAdapter.set({
7428
- key: cacheKey,
7429
- data: serialize(product),
7430
- expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7431
- });
7432
- this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7433
- }
7434
- return product;
7435
- }
7436
- async getByEAN(EAN, options) {
7437
- if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7438
- const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7439
- const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7440
- if (cachedData) {
7441
- this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7442
- return this.model.toInstance(deserialize(cachedData));
7443
- }
7444
- }
7445
- const product = await super
7446
- .find({
7447
- filters: {
7448
- EAN,
7449
- },
7450
- limits: {
7451
- limit: 1,
7452
- },
7453
- })
7454
- .then((res) => res.data.at(0));
7455
- if (!product)
7456
- return null;
7457
- RoundProductPricesHelper.roundProductPrices(product);
7458
- if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7459
- const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7460
- await this.cache.cacheAdapter.set({
7461
- key: cacheKey,
7462
- data: serialize(product),
7463
- expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7464
- });
7465
- this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7466
- }
7467
- return product;
7468
- }
7469
- async find(params, optionsParams) {
7470
- const { filters, fields, ...options } = params || {};
7471
- const bindFields = fields ||
7472
- this.fields
7473
- .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7474
- .filter((field) => field !== 'reviews' && field !== 'categories');
7475
- if (options.options?.minimal?.includes('price'))
7476
- options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7477
- if (options.options?.maximum?.includes('price'))
7478
- options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7479
- options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7480
- options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7481
- return super.find({
7482
- ...options,
7483
- filters: { ...filters },
7555
+ const fieldsConfiguration$2 = [
7556
+ ...commonFields,
7557
+ {
7558
+ categories: {
7559
+ columnName: 'categories',
7560
+ fields: ['category_id'],
7561
+ bindPersistData: (value) => ({
7562
+ categories: { data: value.map((category) => ({ category_id: +category })) },
7563
+ }),
7564
+ to: (categories) => categories.map((categoryId) => +categoryId),
7565
+ from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
7566
+ },
7567
+ },
7568
+ {
7569
+ kitProducts: {
7570
+ columnName: 'kit_products',
7571
+ foreignKeyColumn: { productId: 'id' },
7484
7572
  fields: [
7485
- ...bindFields,
7486
- ...(bindFields.includes('price')
7487
- ? [
7488
- 'subscriberPrice',
7489
- 'subscriberDiscountPercentage',
7490
- 'fullPrice',
7491
- ]
7492
- : []),
7493
- ],
7494
- }, optionsParams);
7495
- }
7496
- async findCatalog(params, mainGender, options) {
7497
- const result = await this.find({
7498
- ...params,
7499
- filters: { ...params.filters, published: true },
7500
- orderBy: {
7501
- hasStock: 'desc',
7502
- ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
7503
- ...lodash.omit(params.orderBy, ['hasStock', 'intGender']),
7504
- },
7505
- }, options);
7506
- return result;
7507
- }
7508
- }
7509
- tslib.__decorate([
7510
- Log(),
7511
- tslib.__metadata("design:type", Function),
7512
- tslib.__metadata("design:paramtypes", [Object, Object, Object]),
7513
- tslib.__metadata("design:returntype", Promise)
7514
- ], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
7515
-
7516
- class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7517
- constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7518
- super({
7519
- tableName: 'product_errors',
7520
- model: ProductErrorsHasuraGraphQL,
7521
- endpoint,
7522
- authOptions,
7523
- interceptors,
7524
- cache,
7525
- fields: [
7526
- {
7527
- productId: {
7528
- columnName: 'product_id',
7529
- to: (value) => +value,
7530
- from: (value) => value.toString(),
7531
- },
7532
- },
7533
- 'source',
7534
- 'error',
7535
- { createdAt: { columnName: 'created_at' } },
7536
- { updatedAt: { columnName: 'updated_at' } },
7537
- {
7538
- product: {
7539
- columnName: 'product',
7540
- foreignKeyColumn: { id: 'productId' },
7541
- fields: [
7542
- { id: { columnName: 'id', from: (value) => value.toString() } },
7543
- { productId: { columnName: 'main_product_id' } },
7544
- 'name',
7545
- 'published',
7546
- 'group',
7547
- 'validity',
7548
- { createdAt: { columnName: 'created_at' } },
7549
- { updatedAt: { columnName: 'updated_at' } },
7550
- ],
7551
- },
7552
- },
7553
- ],
7554
- });
7555
- this.productRepository = productRepository;
7556
- }
7557
- async get(params) {
7558
- const result = await super.get(params);
7559
- if (result instanceof VariantHasuraGraphQL) {
7560
- const product = await this.productRepository.get({ id: result.productId.toString() });
7561
- result.product.name = product.name;
7562
- result.product.group = product.group;
7563
- }
7564
- return result;
7565
- }
7566
- async find(params) {
7567
- const result = await super.find(params);
7568
- const variantsWithNoData = result.data.filter((item) => item.product instanceof VariantHasuraGraphQL &&
7569
- (lodash.isEmpty(item.product.name) || lodash.isEmpty(item.product.group) || lodash.isEmpty(item.product)));
7570
- if (variantsWithNoData.length > 0) {
7571
- const { data: products } = await this.productRepository.find({
7572
- filters: {
7573
- id: {
7574
- operator: exports.Where.IN,
7575
- value: Array.from(new Set(variantsWithNoData.map((item) => item.product.productId?.toString()))),
7576
- },
7577
- },
7578
- });
7579
- products.forEach((product) => {
7580
- result.data
7581
- .filter((variant) => variant.product.productId?.toString() === product.id.toString())
7582
- .forEach((variant) => {
7583
- variant.product.name = product.name;
7584
- variant.product.group = product.group;
7585
- });
7586
- });
7587
- }
7588
- return result;
7589
- }
7590
- }
7591
-
7592
- const commonFields = [
7593
- {
7594
- id: {
7595
- columnName: 'id',
7596
- to: (value) => +value,
7597
- from: (value) => value.toString(),
7598
- },
7599
- },
7600
- { firestoreId: { columnName: 'firestore_id' } },
7601
- { productId: { columnName: 'main_product_id' } },
7602
- { CEST: { columnName: 'cest' } },
7603
- { EAN: { columnName: 'ean' } },
7604
- { NCM: { columnName: 'ncm' } },
7605
- 'brand',
7606
- { costPrice: { columnName: 'cost_price' } },
7607
- {
7608
- description: {
7609
- columnName: 'description',
7610
- from: (description, data) => ({
7611
- description,
7612
- differentials: data.differentials,
7613
- whoMustUse: data.who_must_use,
7614
- howToUse: data.how_to_use,
7615
- brand: data.brand_description,
7616
- ingredients: data.ingredients,
7617
- purpose: data.purpose,
7618
- }),
7619
- bindFindFilter: (filters) => {
7620
- return {
7621
- ...(filters?.description && { description: filters.description }),
7622
- ...(filters.differentials && { differentials: filters.differentials }),
7623
- ...(filters.whoMustUse && {
7624
- who_must_use: filters.whoMustUse,
7625
- }),
7626
- ...(filters.howToUse && {
7627
- how_to_use: filters.howToUse,
7628
- }),
7629
- ...(filters.brand && {
7630
- brand_description: filters.brand,
7631
- }),
7632
- ...(filters.ingredients && {
7633
- ingredients: filters.ingredients,
7634
- }),
7635
- ...(filters.purpose && {
7636
- purpose: filters.purpose,
7637
- }),
7638
- };
7639
- },
7640
- bindPersistData: (descriptionData) => ({
7641
- ...(descriptionData?.description && { description: descriptionData.description }),
7642
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7643
- ...(descriptionData.whoMustUse && {
7644
- who_must_use: descriptionData.whoMustUse,
7645
- }),
7646
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7647
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7648
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7649
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7650
- }),
7651
- },
7652
- },
7653
- { differentials: { columnName: 'differentials' } },
7654
- { whoMustUse: { columnName: 'who_must_use' } },
7655
- { howToUse: { columnName: 'how_to_use' } },
7656
- { brandDescription: { columnName: 'brand_description' } },
7657
- { ingredients: { columnName: 'ingredients' } },
7658
- { purpose: { columnName: 'purpose' } },
7659
- { hasVariants: { columnName: 'has_variants' } },
7660
- {
7661
- images: {
7662
- columnName: 'images',
7663
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7664
- },
7665
- },
7666
- {
7667
- miniatures: {
7668
- columnName: 'miniatures',
7669
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7670
- },
7671
- },
7672
- {
7673
- imagesCard: {
7674
- columnName: 'images_card',
7675
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7676
- },
7677
- },
7678
- 'name',
7679
- {
7680
- price: {
7681
- columnName: 'price',
7682
- from: (price, data) => ({
7683
- price,
7684
- fullPrice: data.full_price,
7685
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
7686
- fullPriceDiscountPercentage: data.full_price_discount_percentage,
7687
- subscriberPrice: data.subscriber_price,
7688
- }),
7689
- bindFindFilter: (filters) => {
7690
- return {
7691
- ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7692
- ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7693
- ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7694
- subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7695
- }),
7696
- ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7697
- subscriber_price: filters.subscriberPrice,
7698
- }),
7699
- ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7700
- full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7701
- }),
7702
- };
7703
- },
7704
- bindPersistData: (priceData) => ({
7705
- ...(priceData?.price >= 0 && { price: priceData.price }),
7706
- ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
7707
- ...(priceData.subscriberDiscountPercentage >= 0 && {
7708
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7709
- }),
7710
- ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
7711
- ...(priceData.fullPriceDiscountPercentage >= 0 && {
7712
- full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7713
- }),
7714
- }),
7715
- },
7716
- },
7717
- { fullPrice: { columnName: 'full_price' } },
7718
- { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7719
- { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7720
- { subscriberPrice: { columnName: 'subscriber_price' } },
7721
- 'published',
7722
- 'outlet',
7723
- 'label',
7724
- 'sku',
7725
- {
7726
- stock: {
7727
- columnName: 'stock',
7728
- from: (quantity) => ({ quantity }),
7729
- to: (value) => (lodash.isNil(value?.quantity) ? value : value?.quantity),
7730
- },
7731
- },
7732
- { hasStock: { columnName: 'has_stock' } },
7733
- 'slug',
7734
- 'type',
7735
- 'video',
7736
- 'weight',
7737
- 'gender',
7738
- { intGender: { columnName: 'int_gender' } },
7739
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7740
- { isKit: { columnName: 'is_kit' } },
7741
- { createdAt: { columnName: 'created_at' } },
7742
- { updatedAt: { columnName: 'updated_at' } },
7743
- { rate: { columnName: 'rating' } },
7744
- { reviewsTotal: { columnName: 'reviews_total' } },
7745
- { shoppingCount: { columnName: 'shopping_count' } },
7746
- { categoryId: { columnName: 'category_id' } },
7747
- {
7748
- category: {
7749
- columnName: 'category',
7750
- foreignKeyColumn: { id: 'categoryId' },
7751
- fields: ['id', 'name', 'reference', 'slug'],
7752
- },
7753
- },
7754
- 'group',
7755
- 'validity',
7756
- { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7757
- { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7758
- { daysOfUse: { columnName: 'days_of_use' } },
7759
- { showVariants: { columnName: 'show_variants' } },
7760
- { variantSlug: { columnName: 'variant_slug' } },
7761
- ];
7762
- const fieldsConfiguration$2 = [
7763
- ...commonFields,
7764
- {
7765
- categories: {
7766
- columnName: 'categories',
7767
- fields: ['category_id'],
7768
- bindPersistData: (value) => ({
7769
- categories: { data: value.map((category) => ({ category_id: +category })) },
7770
- }),
7771
- to: (categories) => categories.map((categoryId) => +categoryId),
7772
- from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
7773
- },
7774
- },
7775
- {
7776
- kitProducts: {
7777
- columnName: 'kit_products',
7778
- foreignKeyColumn: { productId: 'id' },
7779
- fields: [
7780
- { productId: { columnName: 'product_id' } },
7781
- { kitProductId: { columnName: 'kit_product_id' } },
7782
- 'quantity',
7783
- { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
7573
+ { productId: { columnName: 'product_id' } },
7574
+ { kitProductId: { columnName: 'kit_product_id' } },
7575
+ 'quantity',
7576
+ { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
7784
7577
  ],
7785
7578
  },
7786
7579
  },
@@ -7821,61 +7614,9 @@ const fieldsConfiguration$2 = [
7821
7614
  foreignKeyColumn: { product_id: 'id' },
7822
7615
  fields: [
7823
7616
  'id',
7824
- 'name',
7825
7617
  'ean',
7826
7618
  'sku',
7827
- {
7828
- description: {
7829
- columnName: 'description',
7830
- from: (description, data) => ({
7831
- description,
7832
- differentials: data.differentials,
7833
- whoMustUse: data.who_must_use,
7834
- howToUse: data.how_to_use,
7835
- brand: data.brand_description,
7836
- ingredients: data.ingredients,
7837
- purpose: data.purpose,
7838
- }),
7839
- bindFindFilter: (filters) => {
7840
- return {
7841
- ...(filters?.description && { description: filters.description }),
7842
- ...(filters.differentials && { differentials: filters.differentials }),
7843
- ...(filters.whoMustUse && {
7844
- who_must_use: filters.whoMustUse,
7845
- }),
7846
- ...(filters.howToUse && {
7847
- how_to_use: filters.howToUse,
7848
- }),
7849
- ...(filters.brand && {
7850
- brand_description: filters.brand,
7851
- }),
7852
- ...(filters.ingredients && {
7853
- ingredients: filters.ingredients,
7854
- }),
7855
- ...(filters.purpose && {
7856
- purpose: filters.purpose,
7857
- }),
7858
- };
7859
- },
7860
- bindPersistData: (descriptionData) => ({
7861
- ...(descriptionData?.description && { description: descriptionData.description }),
7862
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7863
- ...(descriptionData.whoMustUse && {
7864
- who_must_use: descriptionData.whoMustUse,
7865
- }),
7866
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7867
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7868
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7869
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7870
- }),
7871
- },
7872
- },
7873
- { differentials: { columnName: 'differentials' } },
7874
- { whoMustUse: { columnName: 'who_must_use' } },
7875
- { howToUse: { columnName: 'how_to_use' } },
7876
- { brandDescription: { columnName: 'brand_description' } },
7877
- { ingredients: { columnName: 'ingredients' } },
7878
- { purpose: { columnName: 'purpose' } },
7619
+ 'description',
7879
7620
  {
7880
7621
  grade: {
7881
7622
  columnName: 'grade',
@@ -7921,6 +7662,10 @@ const fieldsConfiguration$2 = [
7921
7662
  }),
7922
7663
  },
7923
7664
  },
7665
+ { fullPrice: { columnName: 'full_price' } },
7666
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7667
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7668
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7924
7669
  'published',
7925
7670
  {
7926
7671
  stock: {
@@ -7949,29 +7694,6 @@ const fieldsConfiguration$2 = [
7949
7694
  },
7950
7695
  { tagsProfile: { columnName: 'tags_profile' } },
7951
7696
  { tagsCollection: { columnName: 'tags_collection' } },
7952
- { variantSlug: { columnName: 'variant_slug' } },
7953
- {
7954
- reviews: {
7955
- columnName: 'reviews',
7956
- foreignKeyColumn: { product_id: 'id' },
7957
- fields: [
7958
- 'id',
7959
- 'shop',
7960
- 'rate',
7961
- 'author',
7962
- 'email',
7963
- 'location',
7964
- 'review',
7965
- 'status',
7966
- 'title',
7967
- { personId: { columnName: 'person_id' } },
7968
- 'points',
7969
- { orderId: { columnName: 'order_id' } },
7970
- { createdAt: { columnName: 'created_at' } },
7971
- { updatedAt: { columnName: 'updated_at' } },
7972
- ],
7973
- },
7974
- },
7975
7697
  ],
7976
7698
  },
7977
7699
  },
@@ -8037,12 +7759,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8037
7759
  : await super.get(identifiers, options);
8038
7760
  if (product.productId)
8039
7761
  throw new NotFoundError('Product not found, it is a variant');
8040
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
8041
- if (!product.variants?.length) {
8042
- for (const [index, variant] of product.variants.entries()) {
8043
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8044
- }
8045
- }
7762
+ product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
8046
7763
  return product;
8047
7764
  }
8048
7765
  async find(params, optionsParams) {
@@ -8059,7 +7776,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8059
7776
  options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
8060
7777
  return super.find({
8061
7778
  ...options,
8062
- filters: { ...filters },
7779
+ filters: { ...filters, productId: { operator: exports.Where.ISNULL } },
8063
7780
  fields: [
8064
7781
  ...bindFields,
8065
7782
  ...(bindFields.includes('price')
@@ -8084,9 +7801,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8084
7801
  const result = await this.find({
8085
7802
  filters: {
8086
7803
  slug,
8087
- productId: {
8088
- operator: exports.Where.ISNULL,
8089
- },
8090
7804
  },
8091
7805
  fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
8092
7806
  options: {
@@ -8096,11 +7810,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8096
7810
  if (!result.data.length)
8097
7811
  return null;
8098
7812
  const product = result?.data?.shift();
8099
- if (!product.variants?.length) {
8100
- for (const [index, variant] of product.variants.entries()) {
8101
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8102
- }
8103
- }
8104
7813
  RoundProductPricesHelper.roundProductPrices(product);
8105
7814
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
8106
7815
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -8302,7 +8011,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8302
8011
  return data?.[0]?.id;
8303
8012
  throw new NotFoundError(`Product with id ${id} not found`);
8304
8013
  }
8305
- async findReviewsByProduct(productId, onlyApproved, options) {
8014
+ async findReviewsByProduct(productId, options) {
8306
8015
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
8307
8016
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
8308
8017
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -8315,16 +8024,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8315
8024
  where: {
8316
8025
  value: {
8317
8026
  product_id: { _eq: productId },
8318
- ...(onlyApproved && { status: { _eq: true } }),
8319
8027
  },
8320
8028
  type: 'product_review_bool_exp',
8321
8029
  required: true,
8322
8030
  },
8323
- order_by: {
8324
- type: '[product_review_order_by]',
8325
- value: [{ createdAt: 'desc' }],
8326
- required: true,
8327
- },
8328
8031
  });
8329
8032
  const reviews = data?.map((review) => this.bindReviewToModel(review));
8330
8033
  if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
@@ -8429,7 +8132,7 @@ tslib.__decorate([
8429
8132
  tslib.__decorate([
8430
8133
  Log(),
8431
8134
  tslib.__metadata("design:type", Function),
8432
- tslib.__metadata("design:paramtypes", [Number, Boolean, Object]),
8135
+ tslib.__metadata("design:paramtypes", [Number, Object]),
8433
8136
  tslib.__metadata("design:returntype", Promise)
8434
8137
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
8435
8138
 
@@ -8668,115 +8371,15 @@ const fieldsConfiguration$1 = [
8668
8371
  {
8669
8372
  miniatures: {
8670
8373
  columnName: 'miniatures',
8671
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8672
- },
8673
- },
8674
- {
8675
- imagesCard: {
8676
- columnName: 'images_card',
8677
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8678
- },
8679
- },
8680
- 'slug',
8681
- 'brand',
8682
- 'name',
8683
- 'sku',
8684
- { NCM: { columnName: 'ncm' } },
8685
- { CEST: { columnName: 'cest' } },
8686
- {
8687
- description: {
8688
- columnName: 'description',
8689
- from: (description, data) => ({
8690
- description,
8691
- differentials: data.differentials,
8692
- whoMustUse: data.who_must_use,
8693
- howToUse: data.how_to_use,
8694
- brand: data.brand_description,
8695
- ingredients: data.ingredients,
8696
- purpose: data.purpose,
8697
- }),
8698
- bindFindFilter: (filters) => {
8699
- return {
8700
- ...(filters?.description && { description: filters.description }),
8701
- ...(filters.differentials && { differentials: filters.differentials }),
8702
- ...(filters.whoMustUse && {
8703
- who_must_use: filters.whoMustUse,
8704
- }),
8705
- ...(filters.howToUse && {
8706
- how_to_use: filters.howToUse,
8707
- }),
8708
- ...(filters.brand && {
8709
- brand_description: filters.brand,
8710
- }),
8711
- ...(filters.ingredients && {
8712
- ingredients: filters.ingredients,
8713
- }),
8714
- ...(filters.purpose && {
8715
- purpose: filters.purpose,
8716
- }),
8717
- };
8718
- },
8719
- bindPersistData: (descriptionData) => ({
8720
- ...(descriptionData?.description && { description: descriptionData.description }),
8721
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8722
- ...(descriptionData.whoMustUse && {
8723
- who_must_use: descriptionData.whoMustUse,
8724
- }),
8725
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8726
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8727
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8728
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8729
- }),
8730
- },
8731
- },
8732
- { differentials: { columnName: 'differentials' } },
8733
- { whoMustUse: { columnName: 'who_must_use' } },
8734
- { howToUse: { columnName: 'how_to_use' } },
8735
- { brandDescription: { columnName: 'brand_description' } },
8736
- { ingredients: { columnName: 'ingredients' } },
8737
- { purpose: { columnName: 'purpose' } },
8738
- 'gender',
8739
- { intGender: { columnName: 'int_gender' } },
8740
- 'label',
8741
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8742
- { rate: { columnName: 'rating' } },
8743
- { reviewsTotal: { columnName: 'reviews_total' } },
8744
- { shoppingCount: { columnName: 'shopping_count' } },
8745
- { categoryId: { columnName: 'category_id' } },
8746
- {
8747
- metadata: {
8748
- columnName: 'metadata',
8749
- fields: ['title', 'description'],
8750
- bindPersistData: (value) => ({
8751
- metadata: { data: value },
8752
- }),
8374
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8753
8375
  },
8754
8376
  },
8755
8377
  {
8756
- reviews: {
8757
- columnName: 'reviews',
8758
- foreignKeyColumn: { product_id: 'id' },
8759
- fields: [
8760
- 'id',
8761
- 'shop',
8762
- 'rate',
8763
- 'author',
8764
- 'email',
8765
- 'location',
8766
- 'review',
8767
- 'status',
8768
- 'title',
8769
- { personId: { columnName: 'person_id' } },
8770
- 'points',
8771
- { orderId: { columnName: 'order_id' } },
8772
- { createdAt: { columnName: 'created_at' } },
8773
- { updatedAt: { columnName: 'updated_at' } },
8774
- ],
8378
+ imagesCard: {
8379
+ columnName: 'images_card',
8380
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8775
8381
  },
8776
8382
  },
8777
- { variantSlug: { columnName: 'variant_slug' } },
8778
- { createdAt: { columnName: 'created_at' } },
8779
- { updatedAt: { columnName: 'updated_at' } },
8780
8383
  ];
8781
8384
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8782
8385
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8817,37 +8420,18 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8817
8420
  return data.at(0);
8818
8421
  }
8819
8422
  async update(params) {
8820
- const { productId, id: checkId, metadata, ...data } = params;
8423
+ const { productId, id: checkId, ...data } = params;
8821
8424
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8822
8425
  if (!dataWithProductId.id) {
8823
8426
  throw new NotFoundError('Variant ID is required for update');
8824
8427
  }
8825
8428
  const id = await this.getId(dataWithProductId.id);
8826
8429
  const product = await super.update({ id, ...data });
8827
- product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8828
8430
  if (dataWithProductId.productId) {
8829
8431
  product.productId = dataWithProductId.productId;
8830
8432
  }
8831
8433
  return product;
8832
8434
  }
8833
- async updateMetadata(productId, { metadata }) {
8834
- const plainData = this.paramsToPlain({ metadata });
8835
- if (!plainData.metadata)
8836
- return null;
8837
- await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8838
- pk_columns: {
8839
- value: { product_id: productId },
8840
- type: 'product_metadata_pk_columns_input',
8841
- required: true,
8842
- },
8843
- _set: {
8844
- value: lodash.omit(metadata, ['product_id']),
8845
- type: 'product_metadata_set_input',
8846
- required: true,
8847
- },
8848
- });
8849
- return plainData.metadata;
8850
- }
8851
8435
  async getId(id) {
8852
8436
  if (!Number.isNaN(+id))
8853
8437
  return id;
@@ -9191,6 +8775,438 @@ tslib.__decorate([
9191
8775
  tslib.__metadata("design:returntype", Promise)
9192
8776
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
9193
8777
 
8778
+ class MercadoPagoRequestHelper {
8779
+ static build(data) {
8780
+ const { checkout, method, postback, card } = data;
8781
+ return {
8782
+ transaction_amount: +checkout.totalPrice.toFixed(2),
8783
+ notification_url: postback,
8784
+ metadata: {
8785
+ checkoutId: checkout.id,
8786
+ },
8787
+ payer: this.buildPayer(checkout, card),
8788
+ statement_descriptor: checkout.shop === exports.Shops.GLAMSHOP ? 'Glam' : 'Mens Market',
8789
+ additional_info: {
8790
+ items: this.buildItems(checkout),
8791
+ },
8792
+ ...(method === 'credit_card' && this.buildCardPayment(card)),
8793
+ ...(method === 'pix' && this.buildPixPayment()),
8794
+ ...(method === 'boleto' && this.buildBoletoPayment(checkout)),
8795
+ };
8796
+ }
8797
+ static buildItems(checkout) {
8798
+ return checkout.lineItems
8799
+ .filter((item) => !item.isGift)
8800
+ .map((item) => {
8801
+ return {
8802
+ id: item.EAN,
8803
+ title: item.name,
8804
+ description: item.name,
8805
+ picture_url: item.image ?? null,
8806
+ category_id: item.category?.id ?? null,
8807
+ quantity: item.quantity,
8808
+ unit_price: +item.pricePaid.toFixed(2),
8809
+ };
8810
+ });
8811
+ }
8812
+ static buildPayer(checkout, card) {
8813
+ return {
8814
+ ...(card && { id: card.customerId }),
8815
+ first_name: checkout.user.firstName,
8816
+ last_name: checkout.user.lastName,
8817
+ email: checkout.user.email,
8818
+ identification: {
8819
+ type: 'CPF',
8820
+ number: checkout.user.cpf.replace(/\D/g, ''),
8821
+ },
8822
+ };
8823
+ }
8824
+ static buildFullPayer(checkout) {
8825
+ return {
8826
+ first_name: checkout.user.firstName,
8827
+ last_name: checkout.user.lastName,
8828
+ phone: {
8829
+ area_code: checkout.user.phone.substring(0, 2),
8830
+ number: checkout.user.phone.substring(2),
8831
+ },
8832
+ address: {
8833
+ zip_code: checkout.shippingAddress.zip,
8834
+ street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
8835
+ street_number: checkout.shippingAddress.number,
8836
+ neighborhood: checkout.shippingAddress.district,
8837
+ city: checkout.shippingAddress.city,
8838
+ federal_unit: checkout.shippingAddress.state,
8839
+ },
8840
+ };
8841
+ }
8842
+ static buildCardPayment(card) {
8843
+ return {
8844
+ installments: card.installments,
8845
+ token: card.cardId,
8846
+ binary_mode: true,
8847
+ capture: true,
8848
+ };
8849
+ }
8850
+ static buildPixPayment() {
8851
+ return {
8852
+ payment_method_id: 'pix',
8853
+ date_of_expiration: dateFns.format(dateFns.addDays(new Date(), 1), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
8854
+ };
8855
+ }
8856
+ static buildBoletoPayment(checkout) {
8857
+ return {
8858
+ payment_method_id: 'bolbradesco',
8859
+ date_of_expiration: dateFns.format(dateFns.addDays(new Date(), 3), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
8860
+ payer: {
8861
+ first_name: checkout.user.firstName,
8862
+ last_name: checkout.user.lastName,
8863
+ email: checkout.user.email,
8864
+ identification: {
8865
+ type: 'CPF',
8866
+ number: checkout.user.cpf.replace(/\D/g, ''),
8867
+ },
8868
+ phone: {
8869
+ area_code: checkout.user.phone.substring(0, 2),
8870
+ number: checkout.user.phone.substring(2),
8871
+ },
8872
+ address: {
8873
+ zip_code: checkout.shippingAddress.zip.replace(/\D/g, ''),
8874
+ street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
8875
+ street_number: checkout.shippingAddress.number,
8876
+ neighborhood: checkout.shippingAddress.district,
8877
+ city: checkout.shippingAddress.city,
8878
+ federal_unit: checkout.shippingAddress.state,
8879
+ },
8880
+ },
8881
+ };
8882
+ }
8883
+ }
8884
+
8885
+ class MercadoPagoResponseHelper {
8886
+ static build(method, checkout, response) {
8887
+ return Payment.toInstance({
8888
+ createdAt: new Date(),
8889
+ updatedAt: new Date(),
8890
+ userId: checkout.user.id,
8891
+ checkoutId: checkout.id,
8892
+ totalPrice: checkout.totalPrice,
8893
+ paymentProvider: exports.PaymentProviders.MERCADOPAGO,
8894
+ mercadoPagoId: response.id,
8895
+ transaction: this.buildPaymentTransaction(method, response),
8896
+ });
8897
+ }
8898
+ static buildPaymentTransaction(method, response) {
8899
+ return PaymentTransaction.toInstance({
8900
+ id: response.id.toString(),
8901
+ acquirer_name: exports.PaymentProviders.MERCADOPAGO,
8902
+ amount: response.transaction_amount,
8903
+ status: this.statusMapping(response.status),
8904
+ status_reason: response.status_detail?.toString(),
8905
+ payment_method: method,
8906
+ currency: response.currency_id?.toString(),
8907
+ paid_amount: response.transaction_details?.total_paid_amount ?? null,
8908
+ paid_at: response.date_approved ?? null,
8909
+ charger_id: response.charges_details?.at(0)?.id?.toString() ?? null,
8910
+ ...(method == exports.TransactionPaymentMethods.PIX && this.getPixReponse(response)),
8911
+ ...(method == exports.TransactionPaymentMethods.CARD && this.getCardReponse(response)),
8912
+ ...(method == exports.TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(response)),
8913
+ });
8914
+ }
8915
+ static getBoletoReponse(response) {
8916
+ return {
8917
+ boleto_url: response.transaction_details?.external_resource_url?.toString(),
8918
+ boleto_barcode: response.transaction_details?.barcode?.content?.toString(),
8919
+ boleto_line: response.transaction_details?.digitable_line?.toString(),
8920
+ boleto_expiration_date: response.date_of_expiration?.toString(),
8921
+ boleto_document_number: response.transaction_details?.verification_code?.toString(),
8922
+ };
8923
+ }
8924
+ static getPixReponse(response) {
8925
+ return {
8926
+ pix_qr_code: response.point_of_interaction?.transaction_data?.qr_code,
8927
+ pix_expiration_date: response.date_of_expiration?.toString(),
8928
+ };
8929
+ }
8930
+ static getCardReponse(response) {
8931
+ return {
8932
+ soft_descriptor: response.statement_descriptor?.toString(),
8933
+ installments: response.installments,
8934
+ card_brand: response.payment_method_id?.toString(),
8935
+ card_first_digits: response.card?.first_six_digits?.toString(),
8936
+ card_last_digits: response.card?.last_four_digits?.toString(),
8937
+ card_id: response.card?.id?.toString(),
8938
+ card_holder_name: response.card?.cardholder?.name?.toString(),
8939
+ card_expiration_month: response.card?.expiration_month?.toString(),
8940
+ card_expiration_year: response.card?.expiration_year?.toString(),
8941
+ capture_method: response.payment_type_id?.toString(),
8942
+ authorization_code: response.authorization_code?.toString(),
8943
+ paid_amount: this.statusMapping(response.status) == 'paid' ? response.transaction_details?.total_paid_amount : null,
8944
+ paid_at: this.statusMapping(response.status) == 'paid' ? response.date_approved : null,
8945
+ };
8946
+ }
8947
+ static statusMapping(status) {
8948
+ const statusMap = {
8949
+ approved: 'paid',
8950
+ pending: 'waiting_payment',
8951
+ in_process: 'processing',
8952
+ rejected: 'refused',
8953
+ cancelled: 'refused',
8954
+ refunded: 'refunded',
8955
+ charged_back: 'chargedback',
8956
+ };
8957
+ return statusMap[status] || status;
8958
+ }
8959
+ }
8960
+
8961
+ class MercadoPagoBankSlipAxiosAdapter {
8962
+ constructor(credentials, paymentRepository) {
8963
+ this.credentials = credentials;
8964
+ this.paymentRepository = paymentRepository;
8965
+ }
8966
+ async pay(checkout) {
8967
+ try {
8968
+ const payload = MercadoPagoRequestHelper.build({
8969
+ checkout,
8970
+ method: 'boleto',
8971
+ postback: this.credentials.postback,
8972
+ });
8973
+ console.warn('[MERCADO PAGO BOLETO DATA TO SEND]', JSON.stringify(payload));
8974
+ const { data } = await axios__default["default"]({
8975
+ method: 'POST',
8976
+ url: `${this.credentials.url}/v1/payments`,
8977
+ headers: {
8978
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
8979
+ Authorization: `Bearer ${this.credentials.api_key}`,
8980
+ 'Content-Type': 'application/json',
8981
+ },
8982
+ data: payload,
8983
+ });
8984
+ console.warn('[MERCADO PAGO RESPONSE BOLETO DATA]', JSON.stringify(data));
8985
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(exports.TransactionPaymentMethods.BANKSLIP, checkout, data));
8986
+ return payment;
8987
+ }
8988
+ catch (error) {
8989
+ if (error instanceof axios.AxiosError) {
8990
+ console.warn(JSON.stringify(error.response.data.message));
8991
+ }
8992
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
8993
+ checkoutId: checkout.id,
8994
+ userEmail: checkout.user.email,
8995
+ info: error.response.data?.message || error.message?.toString(),
8996
+ });
8997
+ }
8998
+ }
8999
+ getBoletoTransaction(paymentId) {
9000
+ throw new Error('Method not implemented.');
9001
+ }
9002
+ }
9003
+
9004
+ class MercadoPagoCardAxiosAdapter {
9005
+ constructor(credentials, paymentRepository, orderBlockedRepository) {
9006
+ this.credentials = credentials;
9007
+ this.paymentRepository = paymentRepository;
9008
+ this.orderBlockedRepository = orderBlockedRepository;
9009
+ }
9010
+ async pay(checkout, card) {
9011
+ try {
9012
+ const payload = await this.getPaymentPayload(checkout, card);
9013
+ console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
9014
+ const { data } = await axios__default["default"]({
9015
+ method: 'POST',
9016
+ url: `${this.credentials.url}/v1/payments`,
9017
+ headers: {
9018
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
9019
+ Authorization: `Bearer ${this.credentials.api_key}`,
9020
+ 'Content-Type': 'application/json',
9021
+ },
9022
+ data: payload,
9023
+ });
9024
+ console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
9025
+ if (data.status == exports.MercadoPagoStatusEnum.rejected) {
9026
+ await this.orderBlockedRepository.createBlockedOrderOrPayment({
9027
+ checkout,
9028
+ blockType: 'Card not authorized',
9029
+ type: 'Card',
9030
+ limiteRange: 'day',
9031
+ card,
9032
+ });
9033
+ 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', {
9034
+ checkoutId: checkout.id,
9035
+ userEmail: checkout.user.email,
9036
+ info: data,
9037
+ });
9038
+ }
9039
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(exports.TransactionPaymentMethods.CARD, checkout, data));
9040
+ return payment;
9041
+ }
9042
+ catch (error) {
9043
+ if (error instanceof axios.AxiosError) {
9044
+ console.warn(JSON.stringify(error.response.data.message));
9045
+ }
9046
+ 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', {
9047
+ checkoutId: checkout.id,
9048
+ userEmail: checkout.user.email,
9049
+ info: error.response.data?.message || error.message?.toString(),
9050
+ });
9051
+ }
9052
+ }
9053
+ async getPaymentPayload(checkout, card) {
9054
+ const cardResponse = await this.getCardByToken(card.customerId, card.cardId, card.cardCvv);
9055
+ const payload = MercadoPagoRequestHelper.build({
9056
+ checkout,
9057
+ method: 'credit_card',
9058
+ postback: this.credentials.postback,
9059
+ card: {
9060
+ ...card,
9061
+ cardId: cardResponse.id,
9062
+ },
9063
+ });
9064
+ return payload;
9065
+ }
9066
+ async addCard(card, customer) {
9067
+ return;
9068
+ }
9069
+ async getCardByToken(customerId, token, cardCvv) {
9070
+ try {
9071
+ const payload = { cardId: token, customerId: customerId, securityCode: cardCvv };
9072
+ console.warn('payload getCardByToken', payload);
9073
+ const { data } = await axios__default["default"]({
9074
+ method: 'POST',
9075
+ url: `${this.credentials.url}/v1/card_tokens`,
9076
+ headers: {
9077
+ Authorization: `Bearer ${this.credentials.api_key}`,
9078
+ 'Content-Type': 'application/json',
9079
+ },
9080
+ data: payload,
9081
+ });
9082
+ return data;
9083
+ }
9084
+ catch (error) {
9085
+ if (error instanceof axios.AxiosError) {
9086
+ console.warn(JSON.stringify(error.response.data.cause));
9087
+ }
9088
+ throw error;
9089
+ }
9090
+ }
9091
+ createCardHash(bu, shop, card) {
9092
+ return;
9093
+ }
9094
+ createTransaction(info) {
9095
+ return;
9096
+ }
9097
+ async createOrUpdateCustomer(customer) {
9098
+ const { data } = await axios__default["default"]({
9099
+ method: 'POST',
9100
+ url: `${this.credentials.url}/v1/customers`,
9101
+ headers: {
9102
+ Authorization: `Bearer ${this.credentials.api_key}`,
9103
+ 'Content-Type': 'application/json',
9104
+ },
9105
+ data: {
9106
+ email: customer.email,
9107
+ first_name: customer.firstName,
9108
+ last_name: customer.lastName,
9109
+ phone: {
9110
+ area_code: customer.phone.substring(0, 2),
9111
+ number: customer.phone.substring(2),
9112
+ },
9113
+ identification: {
9114
+ type: 'CPF',
9115
+ number: customer.cpf.replace(/\D/g, ''),
9116
+ },
9117
+ },
9118
+ });
9119
+ return data;
9120
+ }
9121
+ }
9122
+
9123
+ class MercadoPagoPixAxiosAdapter {
9124
+ constructor(credentials, paymentRepository) {
9125
+ this.credentials = credentials;
9126
+ this.paymentRepository = paymentRepository;
9127
+ }
9128
+ async pay(checkout) {
9129
+ try {
9130
+ const payload = MercadoPagoRequestHelper.build({
9131
+ checkout,
9132
+ method: 'pix',
9133
+ postback: this.credentials.postback,
9134
+ });
9135
+ console.warn('[MERCADO PAGO PIX DATA TO SEND]', JSON.stringify(payload));
9136
+ const { data } = await axios__default["default"]({
9137
+ method: 'POST',
9138
+ url: `${this.credentials.url}/v1/payments`,
9139
+ headers: {
9140
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
9141
+ Authorization: `Bearer ${this.credentials.api_key}`,
9142
+ 'Content-Type': 'application/json',
9143
+ },
9144
+ data: payload,
9145
+ });
9146
+ console.warn('[MERCADO PAGO RESPONSE PIX DATA]', JSON.stringify(data));
9147
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(exports.TransactionPaymentMethods.PIX, checkout, data));
9148
+ return payment;
9149
+ }
9150
+ catch (error) {
9151
+ if (error instanceof axios.AxiosError) {
9152
+ console.warn(JSON.stringify(error.response.data.message));
9153
+ }
9154
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
9155
+ checkoutId: checkout.id,
9156
+ userEmail: checkout.user.email,
9157
+ info: error.response.data?.message || error.message?.toString(),
9158
+ });
9159
+ }
9160
+ }
9161
+ }
9162
+
9163
+ exports.MercadoPagoStatusDetailEnum = void 0;
9164
+ (function (MercadoPagoStatusDetailEnum) {
9165
+ MercadoPagoStatusDetailEnum["accredited"] = "accredited";
9166
+ MercadoPagoStatusDetailEnum["partially_refunded"] = "partially_refunded";
9167
+ MercadoPagoStatusDetailEnum["pending_capture"] = "pending_capture";
9168
+ MercadoPagoStatusDetailEnum["offline_process"] = "offline_process";
9169
+ MercadoPagoStatusDetailEnum["pending_contingency"] = "pending_contingency";
9170
+ MercadoPagoStatusDetailEnum["pending_review_manual"] = "pending_review_manual";
9171
+ MercadoPagoStatusDetailEnum["pending_waiting_transfer"] = "pending_waiting_transfer";
9172
+ MercadoPagoStatusDetailEnum["pending_waiting_payment"] = "pending_waiting_payment";
9173
+ MercadoPagoStatusDetailEnum["pending_challenge"] = "pending_challenge";
9174
+ MercadoPagoStatusDetailEnum["bank_error"] = "bank_error";
9175
+ MercadoPagoStatusDetailEnum["cc_rejected_3ds_mandatory"] = "cc_rejected_3ds_mandatory";
9176
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_card_number"] = "cc_rejected_bad_filled_card_number";
9177
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_date"] = "cc_rejected_bad_filled_date";
9178
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_other"] = "cc_rejected_bad_filled_other";
9179
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_security_code"] = "cc_rejected_bad_filled_security_code";
9180
+ MercadoPagoStatusDetailEnum["cc_rejected_blacklist"] = "cc_rejected_blacklist";
9181
+ MercadoPagoStatusDetailEnum["cc_rejected_call_for_authorize"] = "cc_rejected_call_for_authorize";
9182
+ MercadoPagoStatusDetailEnum["cc_rejected_card_disabled"] = "cc_rejected_card_disabled";
9183
+ MercadoPagoStatusDetailEnum["cc_rejected_card_error"] = "cc_rejected_card_error";
9184
+ MercadoPagoStatusDetailEnum["cc_rejected_duplicated_payment"] = "cc_rejected_duplicated_payment";
9185
+ MercadoPagoStatusDetailEnum["cc_rejected_high_risk"] = "cc_rejected_high_risk";
9186
+ MercadoPagoStatusDetailEnum["cc_rejected_insufficient_amount"] = "cc_rejected_insufficient_amount";
9187
+ MercadoPagoStatusDetailEnum["cc_rejected_invalid_installments"] = "cc_rejected_invalid_installments";
9188
+ MercadoPagoStatusDetailEnum["cc_rejected_max_attempts"] = "cc_rejected_max_attempts";
9189
+ MercadoPagoStatusDetailEnum["cc_rejected_other_reason"] = "cc_rejected_other_reason";
9190
+ MercadoPagoStatusDetailEnum["cc_amount_rate_limit_exceeded"] = "cc_amount_rate_limit_exceeded";
9191
+ MercadoPagoStatusDetailEnum["rejected_insufficient_data"] = "rejected_insufficient_data";
9192
+ MercadoPagoStatusDetailEnum["rejected_by_bank"] = "rejected_by_bank";
9193
+ MercadoPagoStatusDetailEnum["rejected_by_regulations"] = "rejected_by_regulations";
9194
+ MercadoPagoStatusDetailEnum["insufficient_amount"] = "insufficient_amount";
9195
+ MercadoPagoStatusDetailEnum["cc_rejected_card_type_not_allowed"] = "cc_rejected_card_type_not_allowed";
9196
+ })(exports.MercadoPagoStatusDetailEnum || (exports.MercadoPagoStatusDetailEnum = {}));
9197
+
9198
+ exports.MercadoPagoStatusEnum = void 0;
9199
+ (function (MercadoPagoStatusEnum) {
9200
+ MercadoPagoStatusEnum["approved"] = "approved";
9201
+ MercadoPagoStatusEnum["authorized"] = "authorized";
9202
+ MercadoPagoStatusEnum["pending"] = "pending";
9203
+ MercadoPagoStatusEnum["in_process"] = "in_process";
9204
+ MercadoPagoStatusEnum["rejected"] = "rejected";
9205
+ MercadoPagoStatusEnum["cancelled"] = "cancelled";
9206
+ MercadoPagoStatusEnum["refunded"] = "refunded";
9207
+ MercadoPagoStatusEnum["charged_back"] = "charged_back";
9208
+ })(exports.MercadoPagoStatusEnum || (exports.MercadoPagoStatusEnum = {}));
9209
+
9194
9210
  class PagarmeBankSlipAxiosAdapter {
9195
9211
  constructor(credentials, paymentRepository) {
9196
9212
  this.credentials = credentials;
@@ -9338,15 +9354,17 @@ class PagarMeV5RequestHelper {
9338
9354
  customer: this.buildCustomer(checkout),
9339
9355
  shipping: this.buildShipping(checkout),
9340
9356
  payments: this.buildPayment(checkout, method, card),
9357
+ ...this.buildAdditionalInfo(checkout),
9341
9358
  };
9342
9359
  }
9343
9360
  static buildItems(checkout) {
9361
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
9344
9362
  return checkout.lineItems
9345
9363
  .filter((item) => !item.isGift)
9346
9364
  .map((item) => {
9347
9365
  return {
9348
9366
  amount: Math.floor(item.pricePaid * 100),
9349
- description: item.name,
9367
+ description: isSubscriber ? `${item.name} - ASSINANTE` : item.name,
9350
9368
  quantity: item.quantity,
9351
9369
  code: item.EAN,
9352
9370
  };
@@ -9443,6 +9461,14 @@ class PagarMeV5RequestHelper {
9443
9461
  },
9444
9462
  };
9445
9463
  }
9464
+ static buildAdditionalInfo(checkout) {
9465
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
9466
+ if (isSubscriber)
9467
+ return {
9468
+ antifraude_enabled: false,
9469
+ };
9470
+ return {};
9471
+ }
9446
9472
  }
9447
9473
 
9448
9474
  class PagarMeV5ResponseHelper {
@@ -10227,14 +10253,6 @@ Object.defineProperty(exports, 'formatInTimeZone', {
10227
10253
  enumerable: true,
10228
10254
  get: function () { return dateFnsTz.formatInTimeZone; }
10229
10255
  });
10230
- Object.defineProperty(exports, 'fromZonedTime', {
10231
- enumerable: true,
10232
- get: function () { return dateFnsTz.fromZonedTime; }
10233
- });
10234
- Object.defineProperty(exports, 'toZonedTime', {
10235
- enumerable: true,
10236
- get: function () { return dateFnsTz.toZonedTime; }
10237
- });
10238
10256
  Object.defineProperty(exports, 'chunk', {
10239
10257
  enumerable: true,
10240
10258
  get: function () { return lodash.chunk; }
@@ -10322,6 +10340,8 @@ exports.Base = Base;
10322
10340
  exports.BaseModel = BaseModel;
10323
10341
  exports.BeautyProfile = BeautyProfile;
10324
10342
  exports.BeautyQuestionsHelper = BeautyQuestionsHelper;
10343
+ exports.BrandCategory = BrandCategory;
10344
+ exports.BrandCategoryFirestoreRepository = BrandCategoryFirestoreRepository;
10325
10345
  exports.BusinessError = BusinessError;
10326
10346
  exports.Buy2Win = Buy2Win;
10327
10347
  exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
@@ -10380,6 +10400,12 @@ exports.Log = Log;
10380
10400
  exports.LogDocument = LogDocument;
10381
10401
  exports.LogFirestoreRepository = LogFirestoreRepository;
10382
10402
  exports.Logger = Logger;
10403
+ exports.MercadoPagoBankSlipAxiosAdapter = MercadoPagoBankSlipAxiosAdapter;
10404
+ exports.MercadoPagoCardAxiosAdapter = MercadoPagoCardAxiosAdapter;
10405
+ exports.MercadoPagoPaymentMethodFactory = MercadoPagoPaymentMethodFactory;
10406
+ exports.MercadoPagoPixAxiosAdapter = MercadoPagoPixAxiosAdapter;
10407
+ exports.MercadoPagoRequestHelper = MercadoPagoRequestHelper;
10408
+ exports.MercadoPagoResponseHelper = MercadoPagoResponseHelper;
10383
10409
  exports.NotFoundError = NotFoundError;
10384
10410
  exports.ObsEmitter = ObsEmitter;
10385
10411
  exports.Order = Order;
@@ -10399,8 +10425,6 @@ exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
10399
10425
  exports.PaymentProviderFactory = PaymentProviderFactory;
10400
10426
  exports.PaymentTransaction = PaymentTransaction;
10401
10427
  exports.Product = Product;
10402
- exports.ProductCatalogHasuraGraphQL = ProductCatalogHasuraGraphQL;
10403
- exports.ProductCatalogHasuraGraphQLRepository = ProductCatalogHasuraGraphQLRepository;
10404
10428
  exports.ProductErrors = ProductErrors;
10405
10429
  exports.ProductErrorsHasuraGraphQL = ProductErrorsHasuraGraphQL;
10406
10430
  exports.ProductErrorsHasuraGraphQLRepository = ProductErrorsHasuraGraphQLRepository;