@infrab4a/connect 5.4.0-beta.8 → 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 (51) hide show
  1. package/index.cjs.js +671 -623
  2. package/index.esm.js +670 -621
  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/repositories/catalog/index.d.ts +0 -1
  29. package/src/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +0 -1
  30. package/src/infra/index.d.ts +1 -0
  31. package/src/infra/mercado-pago/adapters/index.d.ts +3 -0
  32. package/src/infra/mercado-pago/adapters/mercado-pago-boleto-payment-axios.adapter.d.ts +8 -0
  33. package/src/infra/mercado-pago/adapters/mercado-pago-card-payment-axios.adapter.d.ts +20 -0
  34. package/src/infra/mercado-pago/adapters/mercado-pago-pix-payment-axios.adapter.d.ts +7 -0
  35. package/src/infra/mercado-pago/enums/index.d.ts +2 -0
  36. package/src/infra/mercado-pago/enums/mercado-pago-status-detail.enum.d.ts +33 -0
  37. package/src/infra/mercado-pago/enums/mercado-pago-status.enum.d.ts +10 -0
  38. package/src/infra/mercado-pago/helpers/index.d.ts +2 -0
  39. package/src/infra/mercado-pago/helpers/mercado-pago-request.helper.d.ts +60 -0
  40. package/src/infra/mercado-pago/helpers/mercado-pago-response.helper.d.ts +10 -0
  41. package/src/infra/mercado-pago/index.d.ts +4 -0
  42. package/src/infra/mercado-pago/types/index.d.ts +3 -0
  43. package/src/infra/mercado-pago/types/mercado-pago-request.type.d.ts +1 -0
  44. package/src/infra/mercado-pago/types/mercado-pago-response.type.d.ts +188 -0
  45. package/src/infra/mercado-pago/types/mercado-pago-status-detail.type.d.ts +2 -0
  46. package/src/infra/mercado-pago/types/mercado-pago-status.type.d.ts +2 -0
  47. package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +1 -0
  48. package/src/infra/pagarme/types/v5/pagarmev5-order-request-payload.type.d.ts +1 -0
  49. package/src/utils/index.d.ts +2 -2
  50. package/src/domain/catalog/repositories/product-catalog.repository.d.ts +0 -17
  51. package/src/infra/hasura-graphql/repositories/catalog/product-catalog-hasura-graphql.repository.d.ts +0 -20
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({
@@ -7192,7 +7284,83 @@ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasu
7192
7284
  }
7193
7285
  }
7194
7286
 
7195
- 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 = [
7196
7364
  {
7197
7365
  id: {
7198
7366
  columnName: 'id',
@@ -7359,388 +7527,36 @@ const commonFields$1 = [
7359
7527
  { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7360
7528
  { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7361
7529
  { daysOfUse: { columnName: 'days_of_use' } },
7362
- { showVariants: { columnName: 'show_variants' } },
7363
- { variantSlug: { columnName: 'variant_slug' } },
7364
7530
  ];
7365
- class ProductCatalogHasuraGraphQLRepository extends withFindHasuraGraphQL(withHasuraGraphQL(Base)) {
7366
- constructor({ endpoint, authOptions, interceptors, cache, }) {
7367
- super({
7368
- tableName: 'product_catalog',
7369
- model: ProductHasuraGraphQL,
7370
- endpoint,
7371
- authOptions,
7372
- interceptors,
7373
- fields: commonFields$1,
7374
- cache,
7375
- });
7376
- }
7377
- async get({ id }) {
7378
- return super
7379
- .find({
7380
- filters: {
7381
- id,
7382
- },
7383
- limits: {
7384
- limit: 1,
7385
- },
7386
- })
7387
- .then((res) => res.data.at(0));
7388
- }
7389
- async getByEAN(EAN, options) {
7390
- if (this.cache?.cacheAdapter && options?.cache?.enabled) {
7391
- const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7392
- const cachedData = await this.cache.cacheAdapter.get(cacheKey);
7393
- if (cachedData) {
7394
- this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
7395
- return this.model.toInstance(deserialize(cachedData));
7396
- }
7397
- }
7398
- const product = await super
7399
- .find({
7400
- filters: {
7401
- EAN,
7402
- },
7403
- limits: {
7404
- limit: 1,
7405
- },
7406
- })
7407
- .then((res) => res.data.at(0));
7408
- if (!product)
7409
- return null;
7410
- RoundProductPricesHelper.roundProductPrices(product);
7411
- if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
7412
- const cacheKey = `${this.model.name.toLowerCase()}:EAN:${EAN}`;
7413
- await this.cache.cacheAdapter.set({
7414
- key: cacheKey,
7415
- data: serialize(product),
7416
- expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
7417
- });
7418
- this.logger.log(`Dados salvos no cache: ${cacheKey}`);
7419
- }
7420
- return product;
7421
- }
7422
- async find(params, optionsParams) {
7423
- const { filters, fields, ...options } = params || {};
7424
- const bindFields = fields ||
7425
- this.fields
7426
- .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
7427
- .filter((field) => field !== 'reviews' && field !== 'categories');
7428
- if (options.options?.minimal?.includes('price'))
7429
- options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7430
- if (options.options?.maximum?.includes('price'))
7431
- options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
7432
- options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
7433
- options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
7434
- return super.find({
7435
- ...options,
7436
- 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' },
7437
7548
  fields: [
7438
- ...bindFields,
7439
- ...(bindFields.includes('price')
7440
- ? [
7441
- 'subscriberPrice',
7442
- 'subscriberDiscountPercentage',
7443
- 'fullPrice',
7444
- ]
7445
- : []),
7549
+ { productId: { columnName: 'product_id' } },
7550
+ { kitProductId: { columnName: 'kit_product_id' } },
7551
+ 'quantity',
7552
+ { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
7446
7553
  ],
7447
- }, optionsParams);
7448
- }
7449
- async findCatalog(params, mainGender, options) {
7450
- const result = await this.find({
7451
- ...params,
7452
- filters: { ...params.filters, published: true },
7453
- orderBy: {
7454
- hasStock: 'desc',
7455
- ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
7456
- ...omit(params.orderBy, ['hasStock', 'intGender']),
7457
- },
7458
- }, options);
7459
- return result;
7460
- }
7461
- }
7462
- __decorate([
7463
- Log(),
7464
- __metadata("design:type", Function),
7465
- __metadata("design:paramtypes", [Object, Object, Object]),
7466
- __metadata("design:returntype", Promise)
7467
- ], ProductCatalogHasuraGraphQLRepository.prototype, "findCatalog", null);
7468
-
7469
- class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
7470
- constructor({ endpoint, authOptions, interceptors, cache, }, productRepository) {
7471
- super({
7472
- tableName: 'product_errors',
7473
- model: ProductErrorsHasuraGraphQL,
7474
- endpoint,
7475
- authOptions,
7476
- interceptors,
7477
- cache,
7478
- fields: [
7479
- {
7480
- productId: {
7481
- columnName: 'product_id',
7482
- to: (value) => +value,
7483
- from: (value) => value.toString(),
7484
- },
7485
- },
7486
- 'source',
7487
- 'error',
7488
- { createdAt: { columnName: 'created_at' } },
7489
- { updatedAt: { columnName: 'updated_at' } },
7490
- {
7491
- product: {
7492
- columnName: 'product',
7493
- foreignKeyColumn: { id: 'productId' },
7494
- fields: [
7495
- { id: { columnName: 'id', from: (value) => value.toString() } },
7496
- { productId: { columnName: 'main_product_id' } },
7497
- 'name',
7498
- 'published',
7499
- 'group',
7500
- 'validity',
7501
- { createdAt: { columnName: 'created_at' } },
7502
- { updatedAt: { columnName: 'updated_at' } },
7503
- ],
7504
- },
7505
- },
7506
- ],
7507
- });
7508
- this.productRepository = productRepository;
7509
- }
7510
- async get(params) {
7511
- const result = await super.get(params);
7512
- if (result instanceof VariantHasuraGraphQL) {
7513
- const product = await this.productRepository.get({ id: result.productId.toString() });
7514
- result.product.name = product.name;
7515
- result.product.group = product.group;
7516
- }
7517
- return result;
7518
- }
7519
- async find(params) {
7520
- const result = await super.find(params);
7521
- const variantsWithNoData = result.data.filter((item) => item.product instanceof VariantHasuraGraphQL &&
7522
- (isEmpty(item.product.name) || isEmpty(item.product.group) || isEmpty(item.product)));
7523
- if (variantsWithNoData.length > 0) {
7524
- const { data: products } = await this.productRepository.find({
7525
- filters: {
7526
- id: {
7527
- operator: Where.IN,
7528
- value: Array.from(new Set(variantsWithNoData.map((item) => item.product.productId?.toString()))),
7529
- },
7530
- },
7531
- });
7532
- products.forEach((product) => {
7533
- result.data
7534
- .filter((variant) => variant.product.productId?.toString() === product.id.toString())
7535
- .forEach((variant) => {
7536
- variant.product.name = product.name;
7537
- variant.product.group = product.group;
7538
- });
7539
- });
7540
- }
7541
- return result;
7542
- }
7543
- }
7544
-
7545
- const commonFields = [
7546
- {
7547
- id: {
7548
- columnName: 'id',
7549
- to: (value) => +value,
7550
- from: (value) => value.toString(),
7551
- },
7552
- },
7553
- { firestoreId: { columnName: 'firestore_id' } },
7554
- { productId: { columnName: 'main_product_id' } },
7555
- { CEST: { columnName: 'cest' } },
7556
- { EAN: { columnName: 'ean' } },
7557
- { NCM: { columnName: 'ncm' } },
7558
- 'brand',
7559
- { costPrice: { columnName: 'cost_price' } },
7560
- {
7561
- description: {
7562
- columnName: 'description',
7563
- from: (description, data) => ({
7564
- description,
7565
- differentials: data.differentials,
7566
- whoMustUse: data.who_must_use,
7567
- howToUse: data.how_to_use,
7568
- brand: data.brand_description,
7569
- ingredients: data.ingredients,
7570
- purpose: data.purpose,
7571
- }),
7572
- bindFindFilter: (filters) => {
7573
- return {
7574
- ...(filters?.description && { description: filters.description }),
7575
- ...(filters.differentials && { differentials: filters.differentials }),
7576
- ...(filters.whoMustUse && {
7577
- who_must_use: filters.whoMustUse,
7578
- }),
7579
- ...(filters.howToUse && {
7580
- how_to_use: filters.howToUse,
7581
- }),
7582
- ...(filters.brand && {
7583
- brand_description: filters.brand,
7584
- }),
7585
- ...(filters.ingredients && {
7586
- ingredients: filters.ingredients,
7587
- }),
7588
- ...(filters.purpose && {
7589
- purpose: filters.purpose,
7590
- }),
7591
- };
7592
- },
7593
- bindPersistData: (descriptionData) => ({
7594
- ...(descriptionData?.description && { description: descriptionData.description }),
7595
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7596
- ...(descriptionData.whoMustUse && {
7597
- who_must_use: descriptionData.whoMustUse,
7598
- }),
7599
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7600
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7601
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7602
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7603
- }),
7604
- },
7605
- },
7606
- { differentials: { columnName: 'differentials' } },
7607
- { whoMustUse: { columnName: 'who_must_use' } },
7608
- { howToUse: { columnName: 'how_to_use' } },
7609
- { brandDescription: { columnName: 'brand_description' } },
7610
- { ingredients: { columnName: 'ingredients' } },
7611
- { purpose: { columnName: 'purpose' } },
7612
- { hasVariants: { columnName: 'has_variants' } },
7613
- {
7614
- images: {
7615
- columnName: 'images',
7616
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7617
- },
7618
- },
7619
- {
7620
- miniatures: {
7621
- columnName: 'miniatures',
7622
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7623
- },
7624
- },
7625
- {
7626
- imagesCard: {
7627
- columnName: 'images_card',
7628
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
7629
- },
7630
- },
7631
- 'name',
7632
- {
7633
- price: {
7634
- columnName: 'price',
7635
- from: (price, data) => ({
7636
- price,
7637
- fullPrice: data.full_price,
7638
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
7639
- fullPriceDiscountPercentage: data.full_price_discount_percentage,
7640
- subscriberPrice: data.subscriber_price,
7641
- }),
7642
- bindFindFilter: (filters) => {
7643
- return {
7644
- ...((filters?.price || filters?.price === 0) && { price: filters.price }),
7645
- ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
7646
- ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
7647
- subscriber_discount_percentage: filters.subscriberDiscountPercentage,
7648
- }),
7649
- ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
7650
- subscriber_price: filters.subscriberPrice,
7651
- }),
7652
- ...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
7653
- full_price_discount_percentage: filters.fullPriceDiscountPercentage,
7654
- }),
7655
- };
7656
- },
7657
- bindPersistData: (priceData) => ({
7658
- ...(priceData?.price >= 0 && { price: priceData.price }),
7659
- ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
7660
- ...(priceData.subscriberDiscountPercentage >= 0 && {
7661
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
7662
- }),
7663
- ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
7664
- ...(priceData.fullPriceDiscountPercentage >= 0 && {
7665
- full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
7666
- }),
7667
- }),
7668
- },
7669
- },
7670
- { fullPrice: { columnName: 'full_price' } },
7671
- { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7672
- { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7673
- { subscriberPrice: { columnName: 'subscriber_price' } },
7674
- 'published',
7675
- 'outlet',
7676
- 'label',
7677
- 'sku',
7678
- {
7679
- stock: {
7680
- columnName: 'stock',
7681
- from: (quantity) => ({ quantity }),
7682
- to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
7683
- },
7684
- },
7685
- { hasStock: { columnName: 'has_stock' } },
7686
- 'slug',
7687
- 'type',
7688
- 'video',
7689
- 'weight',
7690
- 'gender',
7691
- { intGender: { columnName: 'int_gender' } },
7692
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
7693
- { isKit: { columnName: 'is_kit' } },
7694
- { createdAt: { columnName: 'created_at' } },
7695
- { updatedAt: { columnName: 'updated_at' } },
7696
- { rate: { columnName: 'rating' } },
7697
- { reviewsTotal: { columnName: 'reviews_total' } },
7698
- { shoppingCount: { columnName: 'shopping_count' } },
7699
- { categoryId: { columnName: 'category_id' } },
7700
- {
7701
- category: {
7702
- columnName: 'category',
7703
- foreignKeyColumn: { id: 'categoryId' },
7704
- fields: ['id', 'name', 'reference', 'slug'],
7705
- },
7706
- },
7707
- 'group',
7708
- 'validity',
7709
- { tagsCollection: { columnName: 'tags_collection', type: HasuraGraphQLColumnType.Jsonb } },
7710
- { tagsProfile: { columnName: 'tags_profile', type: HasuraGraphQLColumnType.Jsonb } },
7711
- { daysOfUse: { columnName: 'days_of_use' } },
7712
- { showVariants: { columnName: 'show_variants' } },
7713
- { variantSlug: { columnName: 'variant_slug' } },
7714
- ];
7715
- const fieldsConfiguration$2 = [
7716
- ...commonFields,
7717
- {
7718
- categories: {
7719
- columnName: 'categories',
7720
- fields: ['category_id'],
7721
- bindPersistData: (value) => ({
7722
- categories: { data: value.map((category) => ({ category_id: +category })) },
7723
- }),
7724
- to: (categories) => categories.map((categoryId) => +categoryId),
7725
- from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
7726
- },
7727
- },
7728
- {
7729
- kitProducts: {
7730
- columnName: 'kit_products',
7731
- foreignKeyColumn: { productId: 'id' },
7732
- fields: [
7733
- { productId: { columnName: 'product_id' } },
7734
- { kitProductId: { columnName: 'kit_product_id' } },
7735
- 'quantity',
7736
- { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
7737
- ],
7738
- },
7739
- },
7740
- {
7741
- reviews: {
7742
- columnName: 'reviews',
7743
- foreignKeyColumn: { product_id: 'id' },
7554
+ },
7555
+ },
7556
+ {
7557
+ reviews: {
7558
+ columnName: 'reviews',
7559
+ foreignKeyColumn: { product_id: 'id' },
7744
7560
  fields: [
7745
7561
  'id',
7746
7562
  'shop',
@@ -7774,61 +7590,9 @@ const fieldsConfiguration$2 = [
7774
7590
  foreignKeyColumn: { product_id: 'id' },
7775
7591
  fields: [
7776
7592
  'id',
7777
- 'name',
7778
7593
  'ean',
7779
7594
  'sku',
7780
- {
7781
- description: {
7782
- columnName: 'description',
7783
- from: (description, data) => ({
7784
- description,
7785
- differentials: data.differentials,
7786
- whoMustUse: data.who_must_use,
7787
- howToUse: data.how_to_use,
7788
- brand: data.brand_description,
7789
- ingredients: data.ingredients,
7790
- purpose: data.purpose,
7791
- }),
7792
- bindFindFilter: (filters) => {
7793
- return {
7794
- ...(filters?.description && { description: filters.description }),
7795
- ...(filters.differentials && { differentials: filters.differentials }),
7796
- ...(filters.whoMustUse && {
7797
- who_must_use: filters.whoMustUse,
7798
- }),
7799
- ...(filters.howToUse && {
7800
- how_to_use: filters.howToUse,
7801
- }),
7802
- ...(filters.brand && {
7803
- brand_description: filters.brand,
7804
- }),
7805
- ...(filters.ingredients && {
7806
- ingredients: filters.ingredients,
7807
- }),
7808
- ...(filters.purpose && {
7809
- purpose: filters.purpose,
7810
- }),
7811
- };
7812
- },
7813
- bindPersistData: (descriptionData) => ({
7814
- ...(descriptionData?.description && { description: descriptionData.description }),
7815
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
7816
- ...(descriptionData.whoMustUse && {
7817
- who_must_use: descriptionData.whoMustUse,
7818
- }),
7819
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
7820
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
7821
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
7822
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
7823
- }),
7824
- },
7825
- },
7826
- { differentials: { columnName: 'differentials' } },
7827
- { whoMustUse: { columnName: 'who_must_use' } },
7828
- { howToUse: { columnName: 'how_to_use' } },
7829
- { brandDescription: { columnName: 'brand_description' } },
7830
- { ingredients: { columnName: 'ingredients' } },
7831
- { purpose: { columnName: 'purpose' } },
7595
+ 'description',
7832
7596
  {
7833
7597
  grade: {
7834
7598
  columnName: 'grade',
@@ -7874,6 +7638,10 @@ const fieldsConfiguration$2 = [
7874
7638
  }),
7875
7639
  },
7876
7640
  },
7641
+ { fullPrice: { columnName: 'full_price' } },
7642
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
7643
+ { subscriberPrice: { columnName: 'subscriber_price' } },
7644
+ { fullPriceDiscountPercentage: { columnName: 'full_price_discount_percentage' } },
7877
7645
  'published',
7878
7646
  {
7879
7647
  stock: {
@@ -7902,29 +7670,6 @@ const fieldsConfiguration$2 = [
7902
7670
  },
7903
7671
  { tagsProfile: { columnName: 'tags_profile' } },
7904
7672
  { tagsCollection: { columnName: 'tags_collection' } },
7905
- { variantSlug: { columnName: 'variant_slug' } },
7906
- {
7907
- reviews: {
7908
- columnName: 'reviews',
7909
- foreignKeyColumn: { product_id: 'id' },
7910
- fields: [
7911
- 'id',
7912
- 'shop',
7913
- 'rate',
7914
- 'author',
7915
- 'email',
7916
- 'location',
7917
- 'review',
7918
- 'status',
7919
- 'title',
7920
- { personId: { columnName: 'person_id' } },
7921
- 'points',
7922
- { orderId: { columnName: 'order_id' } },
7923
- { createdAt: { columnName: 'created_at' } },
7924
- { updatedAt: { columnName: 'updated_at' } },
7925
- ],
7926
- },
7927
- },
7928
7673
  ],
7929
7674
  },
7930
7675
  },
@@ -7990,12 +7735,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
7990
7735
  : await super.get(identifiers, options);
7991
7736
  if (product.productId)
7992
7737
  throw new NotFoundError('Product not found, it is a variant');
7993
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, false, options));
7994
- if (!product.variants?.length) {
7995
- for (const [index, variant] of product.variants.entries()) {
7996
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
7997
- }
7998
- }
7738
+ product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id, options));
7999
7739
  return product;
8000
7740
  }
8001
7741
  async find(params, optionsParams) {
@@ -8012,7 +7752,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8012
7752
  options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
8013
7753
  return super.find({
8014
7754
  ...options,
8015
- filters: { ...filters },
7755
+ filters: { ...filters, productId: { operator: Where.ISNULL } },
8016
7756
  fields: [
8017
7757
  ...bindFields,
8018
7758
  ...(bindFields.includes('price')
@@ -8037,9 +7777,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8037
7777
  const result = await this.find({
8038
7778
  filters: {
8039
7779
  slug,
8040
- productId: {
8041
- operator: Where.ISNULL,
8042
- },
8043
7780
  },
8044
7781
  fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
8045
7782
  options: {
@@ -8049,11 +7786,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8049
7786
  if (!result.data.length)
8050
7787
  return null;
8051
7788
  const product = result?.data?.shift();
8052
- if (!product.variants?.length) {
8053
- for (const [index, variant] of product.variants.entries()) {
8054
- product.variants[index].reviews = await this.findReviewsByProduct(+variant.id, true);
8055
- }
8056
- }
8057
7789
  RoundProductPricesHelper.roundProductPrices(product);
8058
7790
  if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
8059
7791
  const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
@@ -8255,7 +7987,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8255
7987
  return data?.[0]?.id;
8256
7988
  throw new NotFoundError(`Product with id ${id} not found`);
8257
7989
  }
8258
- async findReviewsByProduct(productId, onlyApproved, options) {
7990
+ async findReviewsByProduct(productId, options) {
8259
7991
  if (this.cache?.cacheAdapter && options?.cache?.enabled) {
8260
7992
  const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
8261
7993
  const cachedData = await this.cache.cacheAdapter.get(cacheKey);
@@ -8268,16 +8000,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8268
8000
  where: {
8269
8001
  value: {
8270
8002
  product_id: { _eq: productId },
8271
- ...(onlyApproved && { status: { _eq: true } }),
8272
8003
  },
8273
8004
  type: 'product_review_bool_exp',
8274
8005
  required: true,
8275
8006
  },
8276
- order_by: {
8277
- type: '[product_review_order_by]',
8278
- value: [{ createdAt: 'desc' }],
8279
- required: true,
8280
- },
8281
8007
  });
8282
8008
  const reviews = data?.map((review) => this.bindReviewToModel(review));
8283
8009
  if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
@@ -8382,7 +8108,7 @@ __decorate([
8382
8108
  __decorate([
8383
8109
  Log(),
8384
8110
  __metadata("design:type", Function),
8385
- __metadata("design:paramtypes", [Number, Boolean, Object]),
8111
+ __metadata("design:paramtypes", [Number, Object]),
8386
8112
  __metadata("design:returntype", Promise)
8387
8113
  ], ProductHasuraGraphQLRepository.prototype, "findReviewsByProduct", null);
8388
8114
 
@@ -8617,119 +8343,19 @@ const fieldsConfiguration$1 = [
8617
8343
  columnName: 'images',
8618
8344
  to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8619
8345
  },
8620
- },
8621
- {
8622
- miniatures: {
8623
- columnName: 'miniatures',
8624
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8625
- },
8626
- },
8627
- {
8628
- imagesCard: {
8629
- columnName: 'images_card',
8630
- to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8631
- },
8632
- },
8633
- 'slug',
8634
- 'brand',
8635
- 'name',
8636
- 'sku',
8637
- { NCM: { columnName: 'ncm' } },
8638
- { CEST: { columnName: 'cest' } },
8639
- {
8640
- description: {
8641
- columnName: 'description',
8642
- from: (description, data) => ({
8643
- description,
8644
- differentials: data.differentials,
8645
- whoMustUse: data.who_must_use,
8646
- howToUse: data.how_to_use,
8647
- brand: data.brand_description,
8648
- ingredients: data.ingredients,
8649
- purpose: data.purpose,
8650
- }),
8651
- bindFindFilter: (filters) => {
8652
- return {
8653
- ...(filters?.description && { description: filters.description }),
8654
- ...(filters.differentials && { differentials: filters.differentials }),
8655
- ...(filters.whoMustUse && {
8656
- who_must_use: filters.whoMustUse,
8657
- }),
8658
- ...(filters.howToUse && {
8659
- how_to_use: filters.howToUse,
8660
- }),
8661
- ...(filters.brand && {
8662
- brand_description: filters.brand,
8663
- }),
8664
- ...(filters.ingredients && {
8665
- ingredients: filters.ingredients,
8666
- }),
8667
- ...(filters.purpose && {
8668
- purpose: filters.purpose,
8669
- }),
8670
- };
8671
- },
8672
- bindPersistData: (descriptionData) => ({
8673
- ...(descriptionData?.description && { description: descriptionData.description }),
8674
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
8675
- ...(descriptionData.whoMustUse && {
8676
- who_must_use: descriptionData.whoMustUse,
8677
- }),
8678
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
8679
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
8680
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
8681
- ...(descriptionData.purpose && { purpose: descriptionData.purpose }),
8682
- }),
8683
- },
8684
- },
8685
- { differentials: { columnName: 'differentials' } },
8686
- { whoMustUse: { columnName: 'who_must_use' } },
8687
- { howToUse: { columnName: 'how_to_use' } },
8688
- { brandDescription: { columnName: 'brand_description' } },
8689
- { ingredients: { columnName: 'ingredients' } },
8690
- { purpose: { columnName: 'purpose' } },
8691
- 'gender',
8692
- { intGender: { columnName: 'int_gender' } },
8693
- 'label',
8694
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
8695
- { rate: { columnName: 'rating' } },
8696
- { reviewsTotal: { columnName: 'reviews_total' } },
8697
- { shoppingCount: { columnName: 'shopping_count' } },
8698
- { categoryId: { columnName: 'category_id' } },
8699
- {
8700
- metadata: {
8701
- columnName: 'metadata',
8702
- fields: ['title', 'description'],
8703
- bindPersistData: (value) => ({
8704
- metadata: { data: value },
8705
- }),
8346
+ },
8347
+ {
8348
+ miniatures: {
8349
+ columnName: 'miniatures',
8350
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8706
8351
  },
8707
8352
  },
8708
8353
  {
8709
- reviews: {
8710
- columnName: 'reviews',
8711
- foreignKeyColumn: { product_id: 'id' },
8712
- fields: [
8713
- 'id',
8714
- 'shop',
8715
- 'rate',
8716
- 'author',
8717
- 'email',
8718
- 'location',
8719
- 'review',
8720
- 'status',
8721
- 'title',
8722
- { personId: { columnName: 'person_id' } },
8723
- 'points',
8724
- { orderId: { columnName: 'order_id' } },
8725
- { createdAt: { columnName: 'created_at' } },
8726
- { updatedAt: { columnName: 'updated_at' } },
8727
- ],
8354
+ imagesCard: {
8355
+ columnName: 'images_card',
8356
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
8728
8357
  },
8729
8358
  },
8730
- { variantSlug: { columnName: 'variant_slug' } },
8731
- { createdAt: { columnName: 'created_at' } },
8732
- { updatedAt: { columnName: 'updated_at' } },
8733
8359
  ];
8734
8360
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
8735
8361
  constructor({ endpoint, authOptions, interceptors, cache, }) {
@@ -8770,37 +8396,18 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
8770
8396
  return data.at(0);
8771
8397
  }
8772
8398
  async update(params) {
8773
- const { productId, id: checkId, metadata, ...data } = params;
8399
+ const { productId, id: checkId, ...data } = params;
8774
8400
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
8775
8401
  if (!dataWithProductId.id) {
8776
8402
  throw new NotFoundError('Variant ID is required for update');
8777
8403
  }
8778
8404
  const id = await this.getId(dataWithProductId.id);
8779
8405
  const product = await super.update({ id, ...data });
8780
- product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
8781
8406
  if (dataWithProductId.productId) {
8782
8407
  product.productId = dataWithProductId.productId;
8783
8408
  }
8784
8409
  return product;
8785
8410
  }
8786
- async updateMetadata(productId, { metadata }) {
8787
- const plainData = this.paramsToPlain({ metadata });
8788
- if (!plainData.metadata)
8789
- return null;
8790
- await this.mutation('update_product_metadata_by_pk', ['product_id'], {
8791
- pk_columns: {
8792
- value: { product_id: productId },
8793
- type: 'product_metadata_pk_columns_input',
8794
- required: true,
8795
- },
8796
- _set: {
8797
- value: omit(metadata, ['product_id']),
8798
- type: 'product_metadata_set_input',
8799
- required: true,
8800
- },
8801
- });
8802
- return plainData.metadata;
8803
- }
8804
8411
  async getId(id) {
8805
8412
  if (!Number.isNaN(+id))
8806
8413
  return id;
@@ -9144,6 +8751,438 @@ __decorate([
9144
8751
  __metadata("design:returntype", Promise)
9145
8752
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
9146
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
+
9147
9186
  class PagarmeBankSlipAxiosAdapter {
9148
9187
  constructor(credentials, paymentRepository) {
9149
9188
  this.credentials = credentials;
@@ -9291,15 +9330,17 @@ class PagarMeV5RequestHelper {
9291
9330
  customer: this.buildCustomer(checkout),
9292
9331
  shipping: this.buildShipping(checkout),
9293
9332
  payments: this.buildPayment(checkout, method, card),
9333
+ ...this.buildAdditionalInfo(checkout),
9294
9334
  };
9295
9335
  }
9296
9336
  static buildItems(checkout) {
9337
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
9297
9338
  return checkout.lineItems
9298
9339
  .filter((item) => !item.isGift)
9299
9340
  .map((item) => {
9300
9341
  return {
9301
9342
  amount: Math.floor(item.pricePaid * 100),
9302
- description: item.name,
9343
+ description: isSubscriber ? `${item.name} - ASSINANTE` : item.name,
9303
9344
  quantity: item.quantity,
9304
9345
  code: item.EAN,
9305
9346
  };
@@ -9396,6 +9437,14 @@ class PagarMeV5RequestHelper {
9396
9437
  },
9397
9438
  };
9398
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
+ }
9399
9448
  }
9400
9449
 
9401
9450
  class PagarMeV5ResponseHelper {
@@ -10128,4 +10177,4 @@ class ProductsVertexSearch {
10128
10177
  }
10129
10178
  }
10130
10179
 
10131
- 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, 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 };