@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.esm.js CHANGED
@@ -3,8 +3,8 @@ import { __decorate, __metadata } from 'tslib';
3
3
  import { plainToInstance, instanceToPlain, Type } from 'class-transformer';
4
4
  import { parseISO, startOfDay, endOfDay, addHours, subDays, format, addDays } from 'date-fns';
5
5
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
6
- import { toZonedTime } from 'date-fns-tz';
7
- export { formatInTimeZone, fromZonedTime, toZonedTime } from 'date-fns-tz';
6
+ import { utcToZonedTime } from 'date-fns-tz';
7
+ export { formatInTimeZone } from 'date-fns-tz';
8
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';
9
9
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
10
10
  import { debug } from 'debug';
@@ -38,6 +38,18 @@ var OrderBlockedType;
38
38
  OrderBlockedType["Boleto"] = "Boleto";
39
39
  })(OrderBlockedType || (OrderBlockedType = {}));
40
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
+
41
53
  var PagarmePaymentStatus;
42
54
  (function (PagarmePaymentStatus) {
43
55
  PagarmePaymentStatus["Em processamento"] = "processing";
@@ -90,6 +102,7 @@ var PaymentProviders;
90
102
  PaymentProviders["PAGARME"] = "pagarMe";
91
103
  PaymentProviders["ADYEN"] = "adyen";
92
104
  PaymentProviders["GLAMPOINTS"] = "glampoints";
105
+ PaymentProviders["MERCADOPAGO"] = "mercadoPago";
93
106
  })(PaymentProviders || (PaymentProviders = {}));
94
107
 
95
108
  var TransactionPaymentMethods;
@@ -123,6 +136,9 @@ class AntifraudProviderFactory {
123
136
  class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
124
137
  }
125
138
 
139
+ class MercadoPagoPaymentMethodFactory extends BasePaymentMethodFactory {
140
+ }
141
+
126
142
  class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
127
143
  }
128
144
 
@@ -733,6 +749,30 @@ __decorate([
733
749
  ], Category.prototype, "filters", void 0);
734
750
  registerClass('Category', Category);
735
751
 
752
+ class BrandCategory extends BaseModel {
753
+ get glamImages() {
754
+ return this.images?.[Shops.GLAMSHOP]
755
+ ? this.images[Shops.GLAMSHOP]
756
+ : {
757
+ brandBanner: null,
758
+ brandBannerMobile: null,
759
+ image: null,
760
+ };
761
+ }
762
+ get mensImages() {
763
+ return this.images?.[Shops.MENSMARKET]
764
+ ? this.images[Shops.MENSMARKET]
765
+ : {
766
+ brandBanner: null,
767
+ brandBannerMobile: null,
768
+ image: null,
769
+ };
770
+ }
771
+ static get identifiersFields() {
772
+ return ['id'];
773
+ }
774
+ }
775
+
736
776
  class CategoryCollectionChildren extends BaseModel {
737
777
  static get identifiersFields() {
738
778
  return ['collectionId', 'categoryId'];
@@ -1736,19 +1776,58 @@ class AntifraudCardService {
1736
1776
  constructor(orderRepository, orderBlockedRepository) {
1737
1777
  this.orderRepository = orderRepository;
1738
1778
  this.orderBlockedRepository = orderBlockedRepository;
1739
- this.LIMIT_ORDERS_DAY = 2;
1740
- this.LIMIT_ORDERS_WEEK = 7;
1741
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
1779
+ this.LIMIT_ORDERS_DAY = null;
1780
+ this.LIMIT_ORDERS_WEEK = null;
1742
1781
  }
1743
1782
  async validate(checkout, card) {
1783
+ this.setLimitsByUserType(checkout.user.isSubscriber);
1744
1784
  await this.validateBlockedOrderAttempts(checkout, card);
1745
1785
  await this.validateDayAndWeekOrderLimits(checkout, card);
1746
1786
  return true;
1747
1787
  }
1788
+ setLimitsByUserType(isSubscriber) {
1789
+ this.LIMIT_ORDERS_DAY = {
1790
+ subscriber: {
1791
+ cpf: 4,
1792
+ email: 4,
1793
+ phone: 4,
1794
+ card: 4,
1795
+ zip: 4,
1796
+ },
1797
+ nonSubscriber: {
1798
+ cpf: 2,
1799
+ email: 2,
1800
+ phone: 2,
1801
+ card: 2,
1802
+ zip: 2,
1803
+ },
1804
+ };
1805
+ this.LIMIT_ORDERS_WEEK = {
1806
+ subscriber: {
1807
+ cpf: 12,
1808
+ email: 12,
1809
+ phone: 12,
1810
+ card: 12,
1811
+ zip: Infinity,
1812
+ },
1813
+ nonSubscriber: {
1814
+ cpf: 7,
1815
+ email: 7,
1816
+ phone: 7,
1817
+ card: 7,
1818
+ zip: Infinity,
1819
+ },
1820
+ };
1821
+ this.LIMIT_BLOCKED_ORDERS_DAY = isSubscriber ? 7 : 5;
1822
+ }
1823
+ getLimitsByUserType(type, isSubscriber) {
1824
+ const limits = type === 'day' ? this.LIMIT_ORDERS_DAY : this.LIMIT_ORDERS_WEEK;
1825
+ return isSubscriber ? limits['subscriber'] : limits['nonSubscriber'];
1826
+ }
1748
1827
  async validateBlockedOrderAttempts(checkout, card) {
1749
1828
  const isValid = await this.verifyBlockedOrderAttempts(checkout, card);
1750
1829
  if (!isValid) {
1751
- throw new FraudValidationError('Cliente com mais de 5 compras negadas/bloqueadas no dia', {
1830
+ throw new FraudValidationError(`Cliente com mais de ${this.LIMIT_BLOCKED_ORDERS_DAY} compras negadas/bloqueadas no dia`, {
1752
1831
  checkoutId: checkout.id,
1753
1832
  userEmail: checkout.user.email,
1754
1833
  info: {
@@ -1762,7 +1841,7 @@ class AntifraudCardService {
1762
1841
  async validateDayAndWeekOrderLimits(checkout, card) {
1763
1842
  const isValid = await this.verifyDayAndWeekOrders(checkout, card);
1764
1843
  if (!isValid) {
1765
- throw new FraudValidationError('Cliente tentando comprar mais de 2 vezes no dia ou 7 vezes na semana', {
1844
+ throw new FraudValidationError('Cliente tentando comprar mais do que o permitido no dia/semana', {
1766
1845
  checkoutId: checkout.id,
1767
1846
  userEmail: checkout.user.email,
1768
1847
  info: {
@@ -1781,7 +1860,7 @@ class AntifraudCardService {
1781
1860
  await this.createBlockedOrderRecord({
1782
1861
  checkout,
1783
1862
  card,
1784
- reason: 'More than 5 attempts have failed',
1863
+ reason: `More than ${this.LIMIT_BLOCKED_ORDERS_DAY} attempts have failed`,
1785
1864
  key: 'Failed attempts',
1786
1865
  period: 'day',
1787
1866
  });
@@ -1791,7 +1870,7 @@ class AntifraudCardService {
1791
1870
  }
1792
1871
  getTodayDateRange() {
1793
1872
  const timeZone = 'America/Sao_Paulo';
1794
- const today = toZonedTime(new Date(), timeZone);
1873
+ const today = utcToZonedTime(new Date(), timeZone);
1795
1874
  const day = startOfDay(today);
1796
1875
  const endOfDay$1 = endOfDay(today);
1797
1876
  return { day: addHours(day, 3), endOfDay: addHours(endOfDay$1, 3) };
@@ -1902,26 +1981,28 @@ class AntifraudCardService {
1902
1981
  }
1903
1982
  async validateDayOrderLimits(checkout, params) {
1904
1983
  const ordersPerDay = await this.validateOrdersByRange(params, this.getDateRange('day'));
1984
+ const limits = this.getLimitsByUserType('day', checkout.user.isSubscriber);
1905
1985
  return this.checkOrderLimitsAndBlock({
1906
1986
  checkout,
1907
1987
  orderCounts: ordersPerDay,
1908
- limit: this.LIMIT_ORDERS_DAY,
1988
+ limit: limits,
1909
1989
  period: 'day',
1910
1990
  });
1911
1991
  }
1912
1992
  async validateWeekOrderLimits(checkout, params) {
1913
1993
  const ordersPerWeek = await this.validateOrdersByRange(params, this.getDateRange('week'));
1994
+ const limits = this.getLimitsByUserType('week', checkout.user.isSubscriber);
1914
1995
  return this.checkOrderLimitsAndBlock({
1915
1996
  checkout,
1916
1997
  orderCounts: ordersPerWeek,
1917
- limit: this.LIMIT_ORDERS_WEEK,
1998
+ limit: limits,
1918
1999
  period: 'week',
1919
2000
  });
1920
2001
  }
1921
2002
  async checkOrderLimitsAndBlock(params) {
1922
2003
  const { checkout, orderCounts, limit, period } = params;
1923
2004
  for (const key in orderCounts) {
1924
- if (orderCounts[key] >= limit) {
2005
+ if (orderCounts[key] >= limit[key]) {
1925
2006
  await this.createBlockedOrderRecord({
1926
2007
  checkout,
1927
2008
  card: null,
@@ -4739,6 +4820,17 @@ const withCrudFirestore = (MixinBase) => {
4739
4820
  };
4740
4821
  };
4741
4822
 
4823
+ class BrandCategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4824
+ constructor({ firestore, interceptors, }) {
4825
+ super({
4826
+ firestore,
4827
+ collectionName: 'brandsCategory',
4828
+ model: BrandCategory,
4829
+ interceptors,
4830
+ });
4831
+ }
4832
+ }
4833
+
4742
4834
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4743
4835
  constructor({ firestore, interceptors }) {
4744
4836
  super({
@@ -5827,9 +5919,6 @@ __decorate([
5827
5919
  __metadata("design:type", Product)
5828
5920
  ], KitProductHasuraGraphQL.prototype, "product", void 0);
5829
5921
 
5830
- class ProductCatalogHasuraGraphQL extends Product {
5831
- }
5832
-
5833
5922
  class ProductHasuraGraphQL extends Product {
5834
5923
  }
5835
5924
  __decorate([
@@ -7195,7 +7284,83 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7195
7284
  }
7196
7285
  }
7197
7286
 
7198
- const commonFields$1 = [
7287
+ class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7288
+ constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7289
+ super({
7290
+ tableName: 'product_errors',
7291
+ model: ProductErrorsHasuraGraphQL,
7292
+ endpoint,
7293
+ authOptions,
7294
+ interceptors,
7295
+ cache,
7296
+ fields: [
7297
+ {
7298
+ productId: {
7299
+ columnName: 'product_id',
7300
+ to: (value) => +value,
7301
+ from: (value) => value.toString(),
7302
+ },
7303
+ },
7304
+ 'source',
7305
+ 'error',
7306
+ { createdAt: { columnName: 'created_at' } },
7307
+ { updatedAt: { columnName: 'updated_at' } },
7308
+ {
7309
+ product: {
7310
+ columnName: 'product',
7311
+ foreignKeyColumn: { id: 'productId' },
7312
+ fields: [
7313
+ { id: { columnName: 'id', from: (value) => value.toString() } },
7314
+ { productId: { columnName: 'main_product_id' } },
7315
+ 'name',
7316
+ 'published',
7317
+ 'group',
7318
+ 'validity',
7319
+ { createdAt: { columnName: 'created_at' } },
7320
+ { updatedAt: { columnName: 'updated_at' } },
7321
+ ],
7322
+ },
7323
+ },
7324
+ ],
7325
+ });
7326
+ this.productRepository = productRepository;
7327
+ }
7328
+ async get(params) {
7329
+ const result = await super.get(params);
7330
+ if (result instanceof VariantHasuraGraphQL) {
7331
+ const product = await this.productRepository.get({ id: result.productId.toString() });
7332
+ result.product.name = product.name;
7333
+ result.product.group = product.group;
7334
+ }
7335
+ return result;
7336
+ }
7337
+ async find(params) {
7338
+ const result = await super.find(params);
7339
+ const variantsWithNoData = result.data.filter((item) => item.product instanceof VariantHasuraGraphQL &&
7340
+ (isEmpty(item.product.name) || isEmpty(item.product.group) || isEmpty(item.product)));
7341
+ if (variantsWithNoData.length > 0) {
7342
+ const { data: products } = await this.productRepository.find({
7343
+ filters: {
7344
+ id: {
7345
+ operator: Where.IN,
7346
+ value: Array.from(new Set(variantsWithNoData.map((item) => item.product.productId?.toString()))),
7347
+ },
7348
+ },
7349
+ });
7350
+ products.forEach((product) => {
7351
+ result.data
7352
+ .filter((variant) => variant.product.productId?.toString() === product.id.toString())
7353
+ .forEach((variant) => {
7354
+ variant.product.name = product.name;
7355
+ variant.product.group = product.group;
7356
+ });
7357
+ });
7358
+ }
7359
+ return result;
7360
+ }
7361
+ }
7362
+
7363
+ const commonFields = [
7199
7364
  {
7200
7365
  id: {
7201
7366
  columnName: 'id',
@@ -7362,401 +7527,29 @@ const commonFields$1 = [
7362
7527
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7363
7528
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7364
7529
  { daysOfUse: { columnName: 'days_of_use' } },
7365
- { showVariants: { columnName: 'show_variants' } },
7366
- { variantSlug: { columnName: 'variant_slug' } },
7367
7530
  ];
7368
- class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
7369
- constructor({ endpoint, authOptions, interceptors, cache, }) {
7370
- super({
7371
- tableName: 'product_catalog',
7372
- model: ProductCatalogHasuraGraphQL,
7373
- endpoint,
7374
- authOptions,
7375
- interceptors,
7376
- fields: commonFields$1,
7377
- cache,
7378
- });
7379
- }
7380
- async get({ id }, options) {
7381
- if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7382
- const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
7383
- const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7384
- if (cachedData) {
7385
- this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7386
- return this.model.toInstance(deserialize(cachedData));
7387
- }
7388
- }
7389
- const product = await super
7390
- .find({
7391
- filters: {
7392
- id,
7393
- },
7394
- limits: {
7395
- limit: 1,
7396
- },
7397
- })
7398
- .then((res) => res.data.at(0));
7399
- if (!product)
7400
- throw new NotFoundError(`Product not found`);
7401
- if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7402
- const cacheKey = `${this.model.name.toLowerCase()}:id:${id}`;
7403
- await this.cache.cacheAdapter.set({
7404
- key: cacheKey,
7405
- data: serialize(product),
7406
- expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7407
- });
7408
- this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7409
- }
7410
- return product;
7411
- }
7412
- async getByEAN(EAN, options) {
7413
- if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7414
- const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7415
- const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7416
- if (cachedData) {
7417
- this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7418
- return this.model.toInstance(deserialize(cachedData));
7419
- }
7420
- }
7421
- const product = await super
7422
- .find({
7423
- filters: {
7424
- EAN,
7425
- },
7426
- limits: {
7427
- limit: 1,
7428
- },
7429
- })
7430
- .then((res) => res.data.at(0));
7431
- if (!product)
7432
- return null;
7433
- RoundProductPricesHelper.roundProductPrices(product);
7434
- if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7435
- const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7436
- await this.cache.cacheAdapter.set({
7437
- key: cacheKey,
7438
- data: serialize(product),
7439
- expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7440
- });
7441
- this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7442
- }
7443
- return product;
7444
- }
7445
- async find(params, optionsParams) {
7446
- const { filters, fields, ...options } = params || {};
7447
- const bindFields = fields ||
7448
- this.fields
7449
- .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7450
- .filter((field) => field !== 'reviews' && field !== 'categories');
7451
- if (options.options?.minimal?.includes('price'))
7452
- options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7453
- if (options.options?.maximum?.includes('price'))
7454
- options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7455
- options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7456
- options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7457
- return super.find({
7458
- ...options,
7459
- filters: { ...filters },
7531
+ const fieldsConfiguration$2 = [
7532
+ ...commonFields,
7533
+ {
7534
+ categories: {
7535
+ columnName: 'categories',
7536
+ fields: ['category_id'],
7537
+ bindPersistData: (value) => ({
7538
+ categories: { data: value.map((category) => ({ category_id: +category })) },
7539
+ }),
7540
+ to: (categories) => categories.map((categoryId) => +categoryId),
7541
+ from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
7542
+ },
7543
+ },
7544
+ {
7545
+ kitProducts: {
7546
+ columnName: 'kit_products',
7547
+ foreignKeyColumn: { productId: 'id' },
7460
7548
  fields: [
7461
- ...bindFields,
7462
- ...(bindFields.includes('price')
7463
- ? [
7464
- 'subscriberPrice',
7465
- 'subscriberDiscountPercentage',
7466
- 'fullPrice',
7467
- ]
7468
- : []),
7469
- ],
7470
- }, optionsParams);
7471
- }
7472
- async findCatalog(params, mainGender, options) {
7473
- const result = await this.find({
7474
- ...params,
7475
- filters: { ...params.filters, published: true },
7476
- orderBy: {
7477
- hasStock: 'desc',
7478
- ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
7479
- ...omit(params.orderBy, ['hasStock', 'intGender']),
7480
- },
7481
- }, options);
7482
- return result;
7483
- }
7484
- }
7485
- __decorate([
7486
- Log(),
7487
- __metadata("design:type", Function),
7488
- __metadata("design:paramtypes", [Object, Object, Object]),
7489
- __metadata("design:returntype", Promise)
7490
- ], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
7491
-
7492
- class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7493
- constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7494
- super({
7495
- tableName: 'product_errors',
7496
- model: ProductErrorsHasuraGraphQL,
7497
- endpoint,
7498
- authOptions,
7499
- interceptors,
7500
- cache,
7501
- fields: [
7502
- {
7503
- productId: {
7504
- columnName: 'product_id',
7505
- to: (value) => +value,
7506
- from: (value) => value.toString(),
7507
- },
7508
- },
7509
- 'source',
7510
- 'error',
7511
- { createdAt: { columnName: 'created_at' } },
7512
- { updatedAt: { columnName: 'updated_at' } },
7513
- {
7514
- product: {
7515
- columnName: 'product',
7516
- foreignKeyColumn: { id: 'productId' },
7517
- fields: [
7518
- { id: { columnName: 'id', from: (value) => value.toString() } },
7519
- { productId: { columnName: 'main_product_id' } },
7520
- 'name',
7521
- 'published',
7522
- 'group',
7523
- 'validity',
7524
- { createdAt: { columnName: 'created_at' } },
7525
- { updatedAt: { columnName: 'updated_at' } },
7526
- ],
7527
- },
7528
- },
7529
- ],
7530
- });
7531
- this.productRepository = productRepository;
7532
- }
7533
- async get(params) {
7534
- const result = await super.get(params);
7535
- if (result instanceof VariantHasuraGraphQL) {
7536
- const product = await this.productRepository.get({ id: result.productId.toString() });
7537
- result.product.name = product.name;
7538
- result.product.group = product.group;
7539
- }
7540
- return result;
7541
- }
7542
- async find(params) {
7543
- const result = await super.find(params);
7544
- const variantsWithNoData = result.data.filter((item) => item.product instanceof VariantHasuraGraphQL &&
7545
- (isEmpty(item.product.name) || isEmpty(item.product.group) || isEmpty(item.product)));
7546
- if (variantsWithNoData.length > 0) {
7547
- const { data: products } = await this.productRepository.find({
7548
- filters: {
7549
- id: {
7550
- operator: Where.IN,
7551
- value: Array.from(new Set(variantsWithNoData.map((item) => item.product.productId?.toString()))),
7552
- },
7553
- },
7554
- });
7555
- products.forEach((product) => {
7556
- result.data
7557
- .filter((variant) => variant.product.productId?.toString() === product.id.toString())
7558
- .forEach((variant) => {
7559
- variant.product.name = product.name;
7560
- variant.product.group = product.group;
7561
- });
7562
- });
7563
- }
7564
- return result;
7565
- }
7566
- }
7567
-
7568
- const commonFields = [
7569
- {
7570
- id: {
7571
- columnName: 'id',
7572
- to: (value) => +value,
7573
- from: (value) => value.toString(),
7574
- },
7575
- },
7576
- { firestoreId: { columnName: 'firestore_id' } },
7577
- { productId: { columnName: 'main_product_id' } },
7578
- { CEST: { columnName: 'cest' } },
7579
- { EAN: { columnName: 'ean' } },
7580
- { NCM: { columnName: 'ncm' } },
7581
- 'brand',
7582
- { costPrice: { columnName: 'cost_price' } },
7583
- {
7584
- description: {
7585
- columnName: 'description',
7586
- from: (description, data) => ({
7587
- description,
7588
- differentials: data.differentials,
7589
- whoMustUse: data.who_must_use,
7590
- howToUse: data.how_to_use,
7591
- brand: data.brand_description,
7592
- ingredients: data.ingredients,
7593
- purpose: data.purpose,
7594
- }),
7595
- bindFindFilter: (filters) => {
7596
- return {
7597
- ...(filters?.description && { description: filters.description }),
7598
- ...(filters.differentials && { differentials: filters.differentials }),
7599
- ...(filters.whoMustUse && {
7600
- who_must_use: filters.whoMustUse,
7601
- }),
7602
- ...(filters.howToUse && {
7603
- how_to_use: filters.howToUse,
7604
- }),
7605
- ...(filters.brand && {
7606
- brand_description: filters.brand,
7607
- }),
7608
- ...(filters.ingredients && {
7609
- ingredients: filters.ingredients,
7610
- }),
7611
- ...(filters.purpose && {
7612
- purpose: filters.purpose,
7613
- }),
7614
- };
7615
- },
7616
- bindPersistData: (descriptionData) => ({
7617
- ...(descriptionData?.description && { description: descriptionData.description }),
7618
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7619
- ...(descriptionData.whoMustUse && {
7620
- who_must_use: descriptionData.whoMustUse,
7621
- }),
7622
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7623
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7624
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7625
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7626
- }),
7627
- },
7628
- },
7629
- { differentials: { columnName: 'differentials' } },
7630
- { whoMustUse: { columnName: 'who_must_use' } },
7631
- { howToUse: { columnName: 'how_to_use' } },
7632
- { brandDescription: { columnName: 'brand_description' } },
7633
- { ingredients: { columnName: 'ingredients' } },
7634
- { purpose: { columnName: 'purpose' } },
7635
- { hasVariants: { columnName: 'has_variants' } },
7636
- {
7637
- images: {
7638
- columnName: 'images',
7639
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7640
- },
7641
- },
7642
- {
7643
- miniatures: {
7644
- columnName: 'miniatures',
7645
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7646
- },
7647
- },
7648
- {
7649
- imagesCard: {
7650
- columnName: 'images_card',
7651
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7652
- },
7653
- },
7654
- 'name',
7655
- {
7656
- price: {
7657
- columnName: 'price',
7658
- from: (price, data) => ({
7659
- price,
7660
- fullPrice: data.full_price,
7661
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
7662
- fullPriceDiscountPercentage: data.full_price_discount_percentage,
7663
- subscriberPrice: data.subscriber_price,
7664
- }),
7665
- bindFindFilter: (filters) => {
7666
- return {
7667
- ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7668
- ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7669
- ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7670
- subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7671
- }),
7672
- ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7673
- subscriber_price: filters.subscriberPrice,
7674
- }),
7675
- ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7676
- full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7677
- }),
7678
- };
7679
- },
7680
- bindPersistData: (priceData) => ({
7681
- ...(priceData?.price >= 0 && { price: priceData.price }),
7682
- ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
7683
- ...(priceData.subscriberDiscountPercentage >= 0 && {
7684
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7685
- }),
7686
- ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
7687
- ...(priceData.fullPriceDiscountPercentage >= 0 && {
7688
- full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7689
- }),
7690
- }),
7691
- },
7692
- },
7693
- { fullPrice: { columnName: 'full_price' } },
7694
- { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7695
- { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7696
- { subscriberPrice: { columnName: 'subscriber_price' } },
7697
- 'published',
7698
- 'outlet',
7699
- 'label',
7700
- 'sku',
7701
- {
7702
- stock: {
7703
- columnName: 'stock',
7704
- from: (quantity) => ({ quantity }),
7705
- to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
7706
- },
7707
- },
7708
- { hasStock: { columnName: 'has_stock' } },
7709
- 'slug',
7710
- 'type',
7711
- 'video',
7712
- 'weight',
7713
- 'gender',
7714
- { intGender: { columnName: 'int_gender' } },
7715
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7716
- { isKit: { columnName: 'is_kit' } },
7717
- { createdAt: { columnName: 'created_at' } },
7718
- { updatedAt: { columnName: 'updated_at' } },
7719
- { rate: { columnName: 'rating' } },
7720
- { reviewsTotal: { columnName: 'reviews_total' } },
7721
- { shoppingCount: { columnName: 'shopping_count' } },
7722
- { categoryId: { columnName: 'category_id' } },
7723
- {
7724
- category: {
7725
- columnName: 'category',
7726
- foreignKeyColumn: { id: 'categoryId' },
7727
- fields: ['id', 'name', 'reference', 'slug'],
7728
- },
7729
- },
7730
- 'group',
7731
- 'validity',
7732
- { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7733
- { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7734
- { daysOfUse: { columnName: 'days_of_use' } },
7735
- { showVariants: { columnName: 'show_variants' } },
7736
- { variantSlug: { columnName: 'variant_slug' } },
7737
- ];
7738
- const fieldsConfiguration$2 = [
7739
- ...commonFields,
7740
- {
7741
- categories: {
7742
- columnName: 'categories',
7743
- fields: ['category_id'],
7744
- bindPersistData: (value) => ({
7745
- categories: { data: value.map((category) => ({ category_id: +category })) },
7746
- }),
7747
- to: (categories) => categories.map((categoryId) => +categoryId),
7748
- from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
7749
- },
7750
- },
7751
- {
7752
- kitProducts: {
7753
- columnName: 'kit_products',
7754
- foreignKeyColumn: { productId: 'id' },
7755
- fields: [
7756
- { productId: { columnName: 'product_id' } },
7757
- { kitProductId: { columnName: 'kit_product_id' } },
7758
- 'quantity',
7759
- { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
7549
+ { productId: { columnName: 'product_id' } },
7550
+ { kitProductId: { columnName: 'kit_product_id' } },
7551
+ 'quantity',
7552
+ { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
7760
7553
  ],
7761
7554
  },
7762
7555
  },
@@ -7797,61 +7590,9 @@ const fieldsConfiguration$2 = [
7797
7590
  foreignKeyColumn: { product_id: 'id' },
7798
7591
  fields: [
7799
7592
  'id',
7800
- 'name',
7801
7593
  'ean',
7802
7594
  'sku',
7803
- {
7804
- description: {
7805
- columnName: 'description',
7806
- from: (description, data) => ({
7807
- description,
7808
- differentials: data.differentials,
7809
- whoMustUse: data.who_must_use,
7810
- howToUse: data.how_to_use,
7811
- brand: data.brand_description,
7812
- ingredients: data.ingredients,
7813
- purpose: data.purpose,
7814
- }),
7815
- bindFindFilter: (filters) => {
7816
- return {
7817
- ...(filters?.description && { description: filters.description }),
7818
- ...(filters.differentials && { differentials: filters.differentials }),
7819
- ...(filters.whoMustUse && {
7820
- who_must_use: filters.whoMustUse,
7821
- }),
7822
- ...(filters.howToUse && {
7823
- how_to_use: filters.howToUse,
7824
- }),
7825
- ...(filters.brand && {
7826
- brand_description: filters.brand,
7827
- }),
7828
- ...(filters.ingredients && {
7829
- ingredients: filters.ingredients,
7830
- }),
7831
- ...(filters.purpose && {
7832
- purpose: filters.purpose,
7833
- }),
7834
- };
7835
- },
7836
- bindPersistData: (descriptionData) => ({
7837
- ...(descriptionData?.description && { description: descriptionData.description }),
7838
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7839
- ...(descriptionData.whoMustUse && {
7840
- who_must_use: descriptionData.whoMustUse,
7841
- }),
7842
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7843
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7844
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7845
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7846
- }),
7847
- },
7848
- },
7849
- { differentials: { columnName: 'differentials' } },
7850
- { whoMustUse: { columnName: 'who_must_use' } },
7851
- { howToUse: { columnName: 'how_to_use' } },
7852
- { brandDescription: { columnName: 'brand_description' } },
7853
- { ingredients: { columnName: 'ingredients' } },
7854
- { purpose: { columnName: 'purpose' } },
7595
+ 'description',
7855
7596
  {
7856
7597
  grade: {
7857
7598
  columnName: 'grade',
@@ -7897,6 +7638,10 @@ const fieldsConfiguration$2 = [
7897
7638
  }),
7898
7639
  },
7899
7640
  },
7641
+ { fullPrice: { columnName: 'full_price' } },
7642
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7643
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7644
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7900
7645
  'published',
7901
7646
  {
7902
7647
  stock: {
@@ -7925,29 +7670,6 @@ const fieldsConfiguration$2 = [
7925
7670
  },
7926
7671
  { tagsProfile: { columnName: 'tags_profile' } },
7927
7672
  { tagsCollection: { columnName: 'tags_collection' } },
7928
- { variantSlug: { columnName: 'variant_slug' } },
7929
- {
7930
- reviews: {
7931
- columnName: 'reviews',
7932
- foreignKeyColumn: { product_id: 'id' },
7933
- fields: [
7934
- 'id',
7935
- 'shop',
7936
- 'rate',
7937
- 'author',
7938
- 'email',
7939
- 'location',
7940
- 'review',
7941
- 'status',
7942
- 'title',
7943
- { personId: { columnName: 'person_id' } },
7944
- 'points',
7945
- { orderId: { columnName: 'order_id' } },
7946
- { createdAt: { columnName: 'created_at' } },
7947
- { updatedAt: { columnName: 'updated_at' } },
7948
- ],
7949
- },
7950
- },
7951
7673
  ],
7952
7674
  },
7953
7675
  },
@@ -8013,12 +7735,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8013
7735
  : await super.get(identifiers, options);
8014
7736
  if (product.productId)
8015
7737
  throw new NotFoundError('Product not found, it is a variant');
8016
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
8017
- if (!product.variants?.length) {
8018
- for (const [index, variant] of product.variants.entries()) {
8019
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8020
- }
8021
- }
7738
+ product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
8022
7739
  return product;
8023
7740
  }
8024
7741
  async find(params, optionsParams) {
@@ -8035,7 +7752,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8035
7752
  options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
8036
7753
  return super.find({
8037
7754
  ...options,
8038
- filters: { ...filters },
7755
+ filters: { ...filters, productId: { operator: Where.ISNULL } },
8039
7756
  fields: [
8040
7757
  ...bindFields,
8041
7758
  ...(bindFields.includes('price')
@@ -8060,9 +7777,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8060
7777
  const result = await this.find({
8061
7778
  filters: {
8062
7779
  slug,
8063
- productId: {
8064
- operator: Where.ISNULL,
8065
- },
8066
7780
  },
8067
7781
  fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
8068
7782
  options: {
@@ -8072,11 +7786,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8072
7786
  if (!result.data.length)
8073
7787
  return null;
8074
7788
  const product = result?.data?.shift();
8075
- if (!product.variants?.length) {
8076
- for (const [index, variant] of product.variants.entries()) {
8077
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8078
- }
8079
- }
8080
7789
  RoundProductPricesHelper.roundProductPrices(product);
8081
7790
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
8082
7791
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -8278,7 +7987,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8278
7987
  return data?.[0]?.id;
8279
7988
  throw new NotFoundError(`Product with id ${id} not found`);
8280
7989
  }
8281
- async findReviewsByProduct(productId, onlyApproved, options) {
7990
+ async findReviewsByProduct(productId, options) {
8282
7991
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
8283
7992
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
8284
7993
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -8291,16 +8000,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8291
8000
  where: {
8292
8001
  value: {
8293
8002
  product_id: { _eq: productId },
8294
- ...(onlyApproved && { status: { _eq: true } }),
8295
8003
  },
8296
8004
  type: 'product_review_bool_exp',
8297
8005
  required: true,
8298
8006
  },
8299
- order_by: {
8300
- type: '[product_review_order_by]',
8301
- value: [{ createdAt: 'desc' }],
8302
- required: true,
8303
- },
8304
8007
  });
8305
8008
  const reviews = data?.map((review) => this.bindReviewToModel(review));
8306
8009
  if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
@@ -8405,7 +8108,7 @@ __decorate([
8405
8108
  __decorate([
8406
8109
  Log(),
8407
8110
  __metadata("design:type", Function),
8408
- __metadata("design:paramtypes", [Number, Boolean, Object]),
8111
+ __metadata("design:paramtypes", [Number, Object]),
8409
8112
  __metadata("design:returntype", Promise)
8410
8113
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
8411
8114
 
@@ -8640,119 +8343,19 @@ const fieldsConfiguration$1 = [
8640
8343
  columnName: 'images',
8641
8344
  to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8642
8345
  },
8643
- },
8644
- {
8645
- miniatures: {
8646
- columnName: 'miniatures',
8647
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8648
- },
8649
- },
8650
- {
8651
- imagesCard: {
8652
- columnName: 'images_card',
8653
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8654
- },
8655
- },
8656
- 'slug',
8657
- 'brand',
8658
- 'name',
8659
- 'sku',
8660
- { NCM: { columnName: 'ncm' } },
8661
- { CEST: { columnName: 'cest' } },
8662
- {
8663
- description: {
8664
- columnName: 'description',
8665
- from: (description, data) => ({
8666
- description,
8667
- differentials: data.differentials,
8668
- whoMustUse: data.who_must_use,
8669
- howToUse: data.how_to_use,
8670
- brand: data.brand_description,
8671
- ingredients: data.ingredients,
8672
- purpose: data.purpose,
8673
- }),
8674
- bindFindFilter: (filters) => {
8675
- return {
8676
- ...(filters?.description && { description: filters.description }),
8677
- ...(filters.differentials && { differentials: filters.differentials }),
8678
- ...(filters.whoMustUse && {
8679
- who_must_use: filters.whoMustUse,
8680
- }),
8681
- ...(filters.howToUse && {
8682
- how_to_use: filters.howToUse,
8683
- }),
8684
- ...(filters.brand && {
8685
- brand_description: filters.brand,
8686
- }),
8687
- ...(filters.ingredients && {
8688
- ingredients: filters.ingredients,
8689
- }),
8690
- ...(filters.purpose && {
8691
- purpose: filters.purpose,
8692
- }),
8693
- };
8694
- },
8695
- bindPersistData: (descriptionData) => ({
8696
- ...(descriptionData?.description && { description: descriptionData.description }),
8697
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8698
- ...(descriptionData.whoMustUse && {
8699
- who_must_use: descriptionData.whoMustUse,
8700
- }),
8701
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8702
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8703
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8704
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8705
- }),
8706
- },
8707
- },
8708
- { differentials: { columnName: 'differentials' } },
8709
- { whoMustUse: { columnName: 'who_must_use' } },
8710
- { howToUse: { columnName: 'how_to_use' } },
8711
- { brandDescription: { columnName: 'brand_description' } },
8712
- { ingredients: { columnName: 'ingredients' } },
8713
- { purpose: { columnName: 'purpose' } },
8714
- 'gender',
8715
- { intGender: { columnName: 'int_gender' } },
8716
- 'label',
8717
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8718
- { rate: { columnName: 'rating' } },
8719
- { reviewsTotal: { columnName: 'reviews_total' } },
8720
- { shoppingCount: { columnName: 'shopping_count' } },
8721
- { categoryId: { columnName: 'category_id' } },
8722
- {
8723
- metadata: {
8724
- columnName: 'metadata',
8725
- fields: ['title', 'description'],
8726
- bindPersistData: (value) => ({
8727
- metadata: { data: value },
8728
- }),
8346
+ },
8347
+ {
8348
+ miniatures: {
8349
+ columnName: 'miniatures',
8350
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8729
8351
  },
8730
8352
  },
8731
8353
  {
8732
- reviews: {
8733
- columnName: 'reviews',
8734
- foreignKeyColumn: { product_id: 'id' },
8735
- fields: [
8736
- 'id',
8737
- 'shop',
8738
- 'rate',
8739
- 'author',
8740
- 'email',
8741
- 'location',
8742
- 'review',
8743
- 'status',
8744
- 'title',
8745
- { personId: { columnName: 'person_id' } },
8746
- 'points',
8747
- { orderId: { columnName: 'order_id' } },
8748
- { createdAt: { columnName: 'created_at' } },
8749
- { updatedAt: { columnName: 'updated_at' } },
8750
- ],
8354
+ imagesCard: {
8355
+ columnName: 'images_card',
8356
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8751
8357
  },
8752
8358
  },
8753
- { variantSlug: { columnName: 'variant_slug' } },
8754
- { createdAt: { columnName: 'created_at' } },
8755
- { updatedAt: { columnName: 'updated_at' } },
8756
8359
  ];
8757
8360
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8758
8361
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8793,37 +8396,18 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8793
8396
  return data.at(0);
8794
8397
  }
8795
8398
  async update(params) {
8796
- const { productId, id: checkId, metadata, ...data } = params;
8399
+ const { productId, id: checkId, ...data } = params;
8797
8400
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8798
8401
  if (!dataWithProductId.id) {
8799
8402
  throw new NotFoundError('Variant ID is required for update');
8800
8403
  }
8801
8404
  const id = await this.getId(dataWithProductId.id);
8802
8405
  const product = await super.update({ id, ...data });
8803
- product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8804
8406
  if (dataWithProductId.productId) {
8805
8407
  product.productId = dataWithProductId.productId;
8806
8408
  }
8807
8409
  return product;
8808
8410
  }
8809
- async updateMetadata(productId, { metadata }) {
8810
- const plainData = this.paramsToPlain({ metadata });
8811
- if (!plainData.metadata)
8812
- return null;
8813
- await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8814
- pk_columns: {
8815
- value: { product_id: productId },
8816
- type: 'product_metadata_pk_columns_input',
8817
- required: true,
8818
- },
8819
- _set: {
8820
- value: omit(metadata, ['product_id']),
8821
- type: 'product_metadata_set_input',
8822
- required: true,
8823
- },
8824
- });
8825
- return plainData.metadata;
8826
- }
8827
8411
  async getId(id) {
8828
8412
  if (!Number.isNaN(+id))
8829
8413
  return id;
@@ -9167,6 +8751,438 @@ __decorate([
9167
8751
  __metadata("design:returntype", Promise)
9168
8752
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
9169
8753
 
8754
+ class MercadoPagoRequestHelper {
8755
+ static build(data) {
8756
+ const { checkout, method, postback, card } = data;
8757
+ return {
8758
+ transaction_amount: +checkout.totalPrice.toFixed(2),
8759
+ notification_url: postback,
8760
+ metadata: {
8761
+ checkoutId: checkout.id,
8762
+ },
8763
+ payer: this.buildPayer(checkout, card),
8764
+ statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'Glam' : 'Mens Market',
8765
+ additional_info: {
8766
+ items: this.buildItems(checkout),
8767
+ },
8768
+ ...(method === 'credit_card' && this.buildCardPayment(card)),
8769
+ ...(method === 'pix' && this.buildPixPayment()),
8770
+ ...(method === 'boleto' && this.buildBoletoPayment(checkout)),
8771
+ };
8772
+ }
8773
+ static buildItems(checkout) {
8774
+ return checkout.lineItems
8775
+ .filter((item) => !item.isGift)
8776
+ .map((item) => {
8777
+ return {
8778
+ id: item.EAN,
8779
+ title: item.name,
8780
+ description: item.name,
8781
+ picture_url: item.image ?? null,
8782
+ category_id: item.category?.id ?? null,
8783
+ quantity: item.quantity,
8784
+ unit_price: +item.pricePaid.toFixed(2),
8785
+ };
8786
+ });
8787
+ }
8788
+ static buildPayer(checkout, card) {
8789
+ return {
8790
+ ...(card && { id: card.customerId }),
8791
+ first_name: checkout.user.firstName,
8792
+ last_name: checkout.user.lastName,
8793
+ email: checkout.user.email,
8794
+ identification: {
8795
+ type: 'CPF',
8796
+ number: checkout.user.cpf.replace(/\D/g, ''),
8797
+ },
8798
+ };
8799
+ }
8800
+ static buildFullPayer(checkout) {
8801
+ return {
8802
+ first_name: checkout.user.firstName,
8803
+ last_name: checkout.user.lastName,
8804
+ phone: {
8805
+ area_code: checkout.user.phone.substring(0, 2),
8806
+ number: checkout.user.phone.substring(2),
8807
+ },
8808
+ address: {
8809
+ zip_code: checkout.shippingAddress.zip,
8810
+ street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
8811
+ street_number: checkout.shippingAddress.number,
8812
+ neighborhood: checkout.shippingAddress.district,
8813
+ city: checkout.shippingAddress.city,
8814
+ federal_unit: checkout.shippingAddress.state,
8815
+ },
8816
+ };
8817
+ }
8818
+ static buildCardPayment(card) {
8819
+ return {
8820
+ installments: card.installments,
8821
+ token: card.cardId,
8822
+ binary_mode: true,
8823
+ capture: true,
8824
+ };
8825
+ }
8826
+ static buildPixPayment() {
8827
+ return {
8828
+ payment_method_id: 'pix',
8829
+ date_of_expiration: format(addDays(new Date(), 1), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
8830
+ };
8831
+ }
8832
+ static buildBoletoPayment(checkout) {
8833
+ return {
8834
+ payment_method_id: 'bolbradesco',
8835
+ date_of_expiration: format(addDays(new Date(), 3), 'yyyy-MM-dd') + 'T23:59:59.999-03:00',
8836
+ payer: {
8837
+ first_name: checkout.user.firstName,
8838
+ last_name: checkout.user.lastName,
8839
+ email: checkout.user.email,
8840
+ identification: {
8841
+ type: 'CPF',
8842
+ number: checkout.user.cpf.replace(/\D/g, ''),
8843
+ },
8844
+ phone: {
8845
+ area_code: checkout.user.phone.substring(0, 2),
8846
+ number: checkout.user.phone.substring(2),
8847
+ },
8848
+ address: {
8849
+ zip_code: checkout.shippingAddress.zip.replace(/\D/g, ''),
8850
+ street_name: `${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
8851
+ street_number: checkout.shippingAddress.number,
8852
+ neighborhood: checkout.shippingAddress.district,
8853
+ city: checkout.shippingAddress.city,
8854
+ federal_unit: checkout.shippingAddress.state,
8855
+ },
8856
+ },
8857
+ };
8858
+ }
8859
+ }
8860
+
8861
+ class MercadoPagoResponseHelper {
8862
+ static build(method, checkout, response) {
8863
+ return Payment.toInstance({
8864
+ createdAt: new Date(),
8865
+ updatedAt: new Date(),
8866
+ userId: checkout.user.id,
8867
+ checkoutId: checkout.id,
8868
+ totalPrice: checkout.totalPrice,
8869
+ paymentProvider: PaymentProviders.MERCADOPAGO,
8870
+ mercadoPagoId: response.id,
8871
+ transaction: this.buildPaymentTransaction(method, response),
8872
+ });
8873
+ }
8874
+ static buildPaymentTransaction(method, response) {
8875
+ return PaymentTransaction.toInstance({
8876
+ id: response.id.toString(),
8877
+ acquirer_name: PaymentProviders.MERCADOPAGO,
8878
+ amount: response.transaction_amount,
8879
+ status: this.statusMapping(response.status),
8880
+ status_reason: response.status_detail?.toString(),
8881
+ payment_method: method,
8882
+ currency: response.currency_id?.toString(),
8883
+ paid_amount: response.transaction_details?.total_paid_amount ?? null,
8884
+ paid_at: response.date_approved ?? null,
8885
+ charger_id: response.charges_details?.at(0)?.id?.toString() ?? null,
8886
+ ...(method == TransactionPaymentMethods.PIX && this.getPixReponse(response)),
8887
+ ...(method == TransactionPaymentMethods.CARD && this.getCardReponse(response)),
8888
+ ...(method == TransactionPaymentMethods.BANKSLIP && this.getBoletoReponse(response)),
8889
+ });
8890
+ }
8891
+ static getBoletoReponse(response) {
8892
+ return {
8893
+ boleto_url: response.transaction_details?.external_resource_url?.toString(),
8894
+ boleto_barcode: response.transaction_details?.barcode?.content?.toString(),
8895
+ boleto_line: response.transaction_details?.digitable_line?.toString(),
8896
+ boleto_expiration_date: response.date_of_expiration?.toString(),
8897
+ boleto_document_number: response.transaction_details?.verification_code?.toString(),
8898
+ };
8899
+ }
8900
+ static getPixReponse(response) {
8901
+ return {
8902
+ pix_qr_code: response.point_of_interaction?.transaction_data?.qr_code,
8903
+ pix_expiration_date: response.date_of_expiration?.toString(),
8904
+ };
8905
+ }
8906
+ static getCardReponse(response) {
8907
+ return {
8908
+ soft_descriptor: response.statement_descriptor?.toString(),
8909
+ installments: response.installments,
8910
+ card_brand: response.payment_method_id?.toString(),
8911
+ card_first_digits: response.card?.first_six_digits?.toString(),
8912
+ card_last_digits: response.card?.last_four_digits?.toString(),
8913
+ card_id: response.card?.id?.toString(),
8914
+ card_holder_name: response.card?.cardholder?.name?.toString(),
8915
+ card_expiration_month: response.card?.expiration_month?.toString(),
8916
+ card_expiration_year: response.card?.expiration_year?.toString(),
8917
+ capture_method: response.payment_type_id?.toString(),
8918
+ authorization_code: response.authorization_code?.toString(),
8919
+ paid_amount: this.statusMapping(response.status) == 'paid' ? response.transaction_details?.total_paid_amount : null,
8920
+ paid_at: this.statusMapping(response.status) == 'paid' ? response.date_approved : null,
8921
+ };
8922
+ }
8923
+ static statusMapping(status) {
8924
+ const statusMap = {
8925
+ approved: 'paid',
8926
+ pending: 'waiting_payment',
8927
+ in_process: 'processing',
8928
+ rejected: 'refused',
8929
+ cancelled: 'refused',
8930
+ refunded: 'refunded',
8931
+ charged_back: 'chargedback',
8932
+ };
8933
+ return statusMap[status] || status;
8934
+ }
8935
+ }
8936
+
8937
+ class MercadoPagoBankSlipAxiosAdapter {
8938
+ constructor(credentials, paymentRepository) {
8939
+ this.credentials = credentials;
8940
+ this.paymentRepository = paymentRepository;
8941
+ }
8942
+ async pay(checkout) {
8943
+ try {
8944
+ const payload = MercadoPagoRequestHelper.build({
8945
+ checkout,
8946
+ method: 'boleto',
8947
+ postback: this.credentials.postback,
8948
+ });
8949
+ console.warn('[MERCADO PAGO BOLETO DATA TO SEND]', JSON.stringify(payload));
8950
+ const { data } = await axios({
8951
+ method: 'POST',
8952
+ url: `${this.credentials.url}/v1/payments`,
8953
+ headers: {
8954
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
8955
+ Authorization: `Bearer ${this.credentials.api_key}`,
8956
+ 'Content-Type': 'application/json',
8957
+ },
8958
+ data: payload,
8959
+ });
8960
+ console.warn('[MERCADO PAGO RESPONSE BOLETO DATA]', JSON.stringify(data));
8961
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.BANKSLIP, checkout, data));
8962
+ return payment;
8963
+ }
8964
+ catch (error) {
8965
+ if (error instanceof AxiosError) {
8966
+ console.warn(JSON.stringify(error.response.data.message));
8967
+ }
8968
+ throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
8969
+ checkoutId: checkout.id,
8970
+ userEmail: checkout.user.email,
8971
+ info: error.response.data?.message || error.message?.toString(),
8972
+ });
8973
+ }
8974
+ }
8975
+ getBoletoTransaction(paymentId) {
8976
+ throw new Error('Method not implemented.');
8977
+ }
8978
+ }
8979
+
8980
+ class MercadoPagoCardAxiosAdapter {
8981
+ constructor(credentials, paymentRepository, orderBlockedRepository) {
8982
+ this.credentials = credentials;
8983
+ this.paymentRepository = paymentRepository;
8984
+ this.orderBlockedRepository = orderBlockedRepository;
8985
+ }
8986
+ async pay(checkout, card) {
8987
+ try {
8988
+ const payload = await this.getPaymentPayload(checkout, card);
8989
+ console.warn('[MERCADO PAGO CARD DATA TO SEND]', JSON.stringify(payload));
8990
+ const { data } = await axios({
8991
+ method: 'POST',
8992
+ url: `${this.credentials.url}/v1/payments`,
8993
+ headers: {
8994
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
8995
+ Authorization: `Bearer ${this.credentials.api_key}`,
8996
+ 'Content-Type': 'application/json',
8997
+ },
8998
+ data: payload,
8999
+ });
9000
+ console.warn('[MERCADO PAGO RESPONSE CARD DATA]', JSON.stringify(data));
9001
+ if (data.status == MercadoPagoStatusEnum.rejected) {
9002
+ await this.orderBlockedRepository.createBlockedOrderOrPayment({
9003
+ checkout,
9004
+ blockType: 'Card not authorized',
9005
+ type: 'Card',
9006
+ limiteRange: 'day',
9007
+ card,
9008
+ });
9009
+ 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', {
9010
+ checkoutId: checkout.id,
9011
+ userEmail: checkout.user.email,
9012
+ info: data,
9013
+ });
9014
+ }
9015
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.CARD, checkout, data));
9016
+ return payment;
9017
+ }
9018
+ catch (error) {
9019
+ if (error instanceof AxiosError) {
9020
+ console.warn(JSON.stringify(error.response.data.message));
9021
+ }
9022
+ 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', {
9023
+ checkoutId: checkout.id,
9024
+ userEmail: checkout.user.email,
9025
+ info: error.response.data?.message || error.message?.toString(),
9026
+ });
9027
+ }
9028
+ }
9029
+ async getPaymentPayload(checkout, card) {
9030
+ const cardResponse = await this.getCardByToken(card.customerId, card.cardId, card.cardCvv);
9031
+ const payload = MercadoPagoRequestHelper.build({
9032
+ checkout,
9033
+ method: 'credit_card',
9034
+ postback: this.credentials.postback,
9035
+ card: {
9036
+ ...card,
9037
+ cardId: cardResponse.id,
9038
+ },
9039
+ });
9040
+ return payload;
9041
+ }
9042
+ async addCard(card, customer) {
9043
+ return;
9044
+ }
9045
+ async getCardByToken(customerId, token, cardCvv) {
9046
+ try {
9047
+ const payload = { cardId: token, customerId: customerId, securityCode: cardCvv };
9048
+ console.warn('payload getCardByToken', payload);
9049
+ const { data } = await axios({
9050
+ method: 'POST',
9051
+ url: `${this.credentials.url}/v1/card_tokens`,
9052
+ headers: {
9053
+ Authorization: `Bearer ${this.credentials.api_key}`,
9054
+ 'Content-Type': 'application/json',
9055
+ },
9056
+ data: payload,
9057
+ });
9058
+ return data;
9059
+ }
9060
+ catch (error) {
9061
+ if (error instanceof AxiosError) {
9062
+ console.warn(JSON.stringify(error.response.data.cause));
9063
+ }
9064
+ throw error;
9065
+ }
9066
+ }
9067
+ createCardHash(bu, shop, card) {
9068
+ return;
9069
+ }
9070
+ createTransaction(info) {
9071
+ return;
9072
+ }
9073
+ async createOrUpdateCustomer(customer) {
9074
+ const { data } = await axios({
9075
+ method: 'POST',
9076
+ url: `${this.credentials.url}/v1/customers`,
9077
+ headers: {
9078
+ Authorization: `Bearer ${this.credentials.api_key}`,
9079
+ 'Content-Type': 'application/json',
9080
+ },
9081
+ data: {
9082
+ email: customer.email,
9083
+ first_name: customer.firstName,
9084
+ last_name: customer.lastName,
9085
+ phone: {
9086
+ area_code: customer.phone.substring(0, 2),
9087
+ number: customer.phone.substring(2),
9088
+ },
9089
+ identification: {
9090
+ type: 'CPF',
9091
+ number: customer.cpf.replace(/\D/g, ''),
9092
+ },
9093
+ },
9094
+ });
9095
+ return data;
9096
+ }
9097
+ }
9098
+
9099
+ class MercadoPagoPixAxiosAdapter {
9100
+ constructor(credentials, paymentRepository) {
9101
+ this.credentials = credentials;
9102
+ this.paymentRepository = paymentRepository;
9103
+ }
9104
+ async pay(checkout) {
9105
+ try {
9106
+ const payload = MercadoPagoRequestHelper.build({
9107
+ checkout,
9108
+ method: 'pix',
9109
+ postback: this.credentials.postback,
9110
+ });
9111
+ console.warn('[MERCADO PAGO PIX DATA TO SEND]', JSON.stringify(payload));
9112
+ const { data } = await axios({
9113
+ method: 'POST',
9114
+ url: `${this.credentials.url}/v1/payments`,
9115
+ headers: {
9116
+ 'X-Idempotency-Key': `${checkout.id}-${new Date().getTime()}`,
9117
+ Authorization: `Bearer ${this.credentials.api_key}`,
9118
+ 'Content-Type': 'application/json',
9119
+ },
9120
+ data: payload,
9121
+ });
9122
+ console.warn('[MERCADO PAGO RESPONSE PIX DATA]', JSON.stringify(data));
9123
+ const payment = await this.paymentRepository.create(MercadoPagoResponseHelper.build(TransactionPaymentMethods.PIX, checkout, data));
9124
+ return payment;
9125
+ }
9126
+ catch (error) {
9127
+ if (error instanceof AxiosError) {
9128
+ console.warn(JSON.stringify(error.response.data.message));
9129
+ }
9130
+ throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
9131
+ checkoutId: checkout.id,
9132
+ userEmail: checkout.user.email,
9133
+ info: error.response.data?.message || error.message?.toString(),
9134
+ });
9135
+ }
9136
+ }
9137
+ }
9138
+
9139
+ var MercadoPagoStatusDetailEnum;
9140
+ (function (MercadoPagoStatusDetailEnum) {
9141
+ MercadoPagoStatusDetailEnum["accredited"] = "accredited";
9142
+ MercadoPagoStatusDetailEnum["partially_refunded"] = "partially_refunded";
9143
+ MercadoPagoStatusDetailEnum["pending_capture"] = "pending_capture";
9144
+ MercadoPagoStatusDetailEnum["offline_process"] = "offline_process";
9145
+ MercadoPagoStatusDetailEnum["pending_contingency"] = "pending_contingency";
9146
+ MercadoPagoStatusDetailEnum["pending_review_manual"] = "pending_review_manual";
9147
+ MercadoPagoStatusDetailEnum["pending_waiting_transfer"] = "pending_waiting_transfer";
9148
+ MercadoPagoStatusDetailEnum["pending_waiting_payment"] = "pending_waiting_payment";
9149
+ MercadoPagoStatusDetailEnum["pending_challenge"] = "pending_challenge";
9150
+ MercadoPagoStatusDetailEnum["bank_error"] = "bank_error";
9151
+ MercadoPagoStatusDetailEnum["cc_rejected_3ds_mandatory"] = "cc_rejected_3ds_mandatory";
9152
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_card_number"] = "cc_rejected_bad_filled_card_number";
9153
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_date"] = "cc_rejected_bad_filled_date";
9154
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_other"] = "cc_rejected_bad_filled_other";
9155
+ MercadoPagoStatusDetailEnum["cc_rejected_bad_filled_security_code"] = "cc_rejected_bad_filled_security_code";
9156
+ MercadoPagoStatusDetailEnum["cc_rejected_blacklist"] = "cc_rejected_blacklist";
9157
+ MercadoPagoStatusDetailEnum["cc_rejected_call_for_authorize"] = "cc_rejected_call_for_authorize";
9158
+ MercadoPagoStatusDetailEnum["cc_rejected_card_disabled"] = "cc_rejected_card_disabled";
9159
+ MercadoPagoStatusDetailEnum["cc_rejected_card_error"] = "cc_rejected_card_error";
9160
+ MercadoPagoStatusDetailEnum["cc_rejected_duplicated_payment"] = "cc_rejected_duplicated_payment";
9161
+ MercadoPagoStatusDetailEnum["cc_rejected_high_risk"] = "cc_rejected_high_risk";
9162
+ MercadoPagoStatusDetailEnum["cc_rejected_insufficient_amount"] = "cc_rejected_insufficient_amount";
9163
+ MercadoPagoStatusDetailEnum["cc_rejected_invalid_installments"] = "cc_rejected_invalid_installments";
9164
+ MercadoPagoStatusDetailEnum["cc_rejected_max_attempts"] = "cc_rejected_max_attempts";
9165
+ MercadoPagoStatusDetailEnum["cc_rejected_other_reason"] = "cc_rejected_other_reason";
9166
+ MercadoPagoStatusDetailEnum["cc_amount_rate_limit_exceeded"] = "cc_amount_rate_limit_exceeded";
9167
+ MercadoPagoStatusDetailEnum["rejected_insufficient_data"] = "rejected_insufficient_data";
9168
+ MercadoPagoStatusDetailEnum["rejected_by_bank"] = "rejected_by_bank";
9169
+ MercadoPagoStatusDetailEnum["rejected_by_regulations"] = "rejected_by_regulations";
9170
+ MercadoPagoStatusDetailEnum["insufficient_amount"] = "insufficient_amount";
9171
+ MercadoPagoStatusDetailEnum["cc_rejected_card_type_not_allowed"] = "cc_rejected_card_type_not_allowed";
9172
+ })(MercadoPagoStatusDetailEnum || (MercadoPagoStatusDetailEnum = {}));
9173
+
9174
+ var MercadoPagoStatusEnum;
9175
+ (function (MercadoPagoStatusEnum) {
9176
+ MercadoPagoStatusEnum["approved"] = "approved";
9177
+ MercadoPagoStatusEnum["authorized"] = "authorized";
9178
+ MercadoPagoStatusEnum["pending"] = "pending";
9179
+ MercadoPagoStatusEnum["in_process"] = "in_process";
9180
+ MercadoPagoStatusEnum["rejected"] = "rejected";
9181
+ MercadoPagoStatusEnum["cancelled"] = "cancelled";
9182
+ MercadoPagoStatusEnum["refunded"] = "refunded";
9183
+ MercadoPagoStatusEnum["charged_back"] = "charged_back";
9184
+ })(MercadoPagoStatusEnum || (MercadoPagoStatusEnum = {}));
9185
+
9170
9186
  class PagarmeBankSlipAxiosAdapter {
9171
9187
  constructor(credentials, paymentRepository) {
9172
9188
  this.credentials = credentials;
@@ -9314,15 +9330,17 @@ class PagarMeV5RequestHelper {
9314
9330
  customer: this.buildCustomer(checkout),
9315
9331
  shipping: this.buildShipping(checkout),
9316
9332
  payments: this.buildPayment(checkout, method, card),
9333
+ ...this.buildAdditionalInfo(checkout),
9317
9334
  };
9318
9335
  }
9319
9336
  static buildItems(checkout) {
9337
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
9320
9338
  return checkout.lineItems
9321
9339
  .filter((item) => !item.isGift)
9322
9340
  .map((item) => {
9323
9341
  return {
9324
9342
  amount: Math.floor(item.pricePaid * 100),
9325
- description: item.name,
9343
+ description: isSubscriber ? `${item.name} - ASSINANTE` : item.name,
9326
9344
  quantity: item.quantity,
9327
9345
  code: item.EAN,
9328
9346
  };
@@ -9419,6 +9437,14 @@ class PagarMeV5RequestHelper {
9419
9437
  },
9420
9438
  };
9421
9439
  }
9440
+ static buildAdditionalInfo(checkout) {
9441
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
9442
+ if (isSubscriber)
9443
+ return {
9444
+ antifraude_enabled: false,
9445
+ };
9446
+ return {};
9447
+ }
9422
9448
  }
9423
9449
 
9424
9450
  class PagarMeV5ResponseHelper {
@@ -10151,4 +10177,4 @@ class ProductsVertexSearch {
10151
10177
  }
10152
10178
  }
10153
10179
 
10154
- 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, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQL, ProductCatalogHasuraGraphQLRepository, 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, 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 };
10180
+ 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, 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, MercadoPagoBankSlipAxiosAdapter, MercadoPagoCardAxiosAdapter, MercadoPagoPaymentMethodFactory, MercadoPagoPixAxiosAdapter, MercadoPagoRequestHelper, MercadoPagoResponseHelper, MercadoPagoStatusDetailEnum, MercadoPagoStatusEnum, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderPaymentStatus, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, 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, 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 };