@infrab4a/connect 4.12.0-beta.0 → 4.12.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 (66) hide show
  1. package/index.cjs.js +358 -1001
  2. package/index.esm.js +363 -980
  3. package/package.json +1 -1
  4. package/src/domain/catalog/repositories/product-reviews.repository.d.ts +1 -0
  5. package/src/domain/general/index.d.ts +0 -2
  6. package/src/domain/shopping/index.d.ts +0 -4
  7. package/src/domain/shopping/models/index.d.ts +0 -1
  8. package/src/domain/shopping/models/order.d.ts +2 -2
  9. package/src/domain/shopping/models/payment.d.ts +63 -10
  10. package/src/domain/shopping/models/types/index.d.ts +4 -4
  11. package/src/domain/shopping/types/index.d.ts +0 -5
  12. package/src/errors/index.d.ts +2 -7
  13. package/src/infra/elasticsearch/indexes/products-index.d.ts +1 -1
  14. package/src/infra/firebase/firestore/repositories/index.d.ts +2 -3
  15. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +1 -1
  16. package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +1 -0
  17. package/src/utils/index.d.ts +2 -2
  18. package/src/domain/general/models/index.d.ts +0 -1
  19. package/src/domain/general/models/sequences.d.ts +0 -9
  20. package/src/domain/general/repositories/index.d.ts +0 -1
  21. package/src/domain/general/repositories/sequences.repository.d.ts +0 -4
  22. package/src/domain/shopping/enums/antifraud-providers.enum.d.ts +0 -6
  23. package/src/domain/shopping/enums/index.d.ts +0 -3
  24. package/src/domain/shopping/enums/payment-methods.enum.d.ts +0 -6
  25. package/src/domain/shopping/enums/payment-providers.enum.d.ts +0 -5
  26. package/src/domain/shopping/factories/adyen-payment-method.factory.d.ts +0 -8
  27. package/src/domain/shopping/factories/antifraud-provider.factory.d.ts +0 -15
  28. package/src/domain/shopping/factories/base-payment-method.factory.d.ts +0 -7
  29. package/src/domain/shopping/factories/glampoints-payment-method.factory.d.ts +0 -8
  30. package/src/domain/shopping/factories/index.d.ts +0 -5
  31. package/src/domain/shopping/factories/pagarme-payment-method.factory.d.ts +0 -10
  32. package/src/domain/shopping/factories/payment-provider.factory.d.ts +0 -15
  33. package/src/domain/shopping/interfaces/antifraud-method-factory.interface.d.ts +0 -11
  34. package/src/domain/shopping/interfaces/antifraud-provider.interface.d.ts +0 -5
  35. package/src/domain/shopping/interfaces/index.d.ts +0 -7
  36. package/src/domain/shopping/interfaces/payment-method-factory.interface.d.ts +0 -14
  37. package/src/domain/shopping/interfaces/payment-provider-bank-slip.interface.d.ts +0 -5
  38. package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +0 -7
  39. package/src/domain/shopping/interfaces/payment-provider-glampoints.interface.d.ts +0 -5
  40. package/src/domain/shopping/interfaces/payment-provider-pix.interface.d.ts +0 -5
  41. package/src/domain/shopping/models/payment-transaction.d.ts +0 -67
  42. package/src/domain/shopping/services/adyen-card-payment.service.d.ts +0 -13
  43. package/src/domain/shopping/services/antifraud-bankslip.service.d.ts +0 -9
  44. package/src/domain/shopping/services/antifraud-card.service.d.ts +0 -18
  45. package/src/domain/shopping/services/antifraud-glampoints.service.d.ts +0 -6
  46. package/src/domain/shopping/services/antifraud-pix.service.d.ts +0 -6
  47. package/src/domain/shopping/services/glampoints-payment.service.d.ts +0 -8
  48. package/src/domain/shopping/services/index.d.ts +0 -9
  49. package/src/domain/shopping/services/pagarme-bank-slip-payment.service.d.ts +0 -11
  50. package/src/domain/shopping/services/pagarme-card-payment.service.d.ts +0 -13
  51. package/src/domain/shopping/services/pagarme-pix-payment.service.d.ts +0 -11
  52. package/src/domain/shopping/types/adyen-credentials.type.d.ts +0 -6
  53. package/src/domain/shopping/types/antifraud-provider.type.d.ts +0 -2
  54. package/src/domain/shopping/types/pagarme-credentials.type.d.ts +0 -5
  55. package/src/domain/shopping/types/payment-method.type.d.ts +0 -2
  56. package/src/domain/shopping/types/payment-provider.type.d.ts +0 -2
  57. package/src/errors/business.error.d.ts +0 -7
  58. package/src/errors/fraud-validation.error.d.ts +0 -7
  59. package/src/errors/payment.error.d.ts +0 -7
  60. package/src/errors/stock-limit.error.d.ts +0 -5
  61. package/src/errors/stock-out.error.d.ts +0 -5
  62. package/src/errors/types/checkout-additional-data-erro.type.d.ts +0 -5
  63. package/src/errors/types/index.d.ts +0 -1
  64. package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
  65. package/src/infra/firebase/firestore/repositories/general/sequences-firestore.repository.d.ts +0 -7
  66. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.d.ts +0 -9
package/index.cjs.js CHANGED
@@ -19,65 +19,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
19
19
 
20
20
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
21
21
 
22
- exports.AntifraudProviders = void 0;
23
- (function (AntifraudProviders) {
24
- AntifraudProviders["BANKSLIP"] = "bankSlip";
25
- AntifraudProviders["CARD"] = "card";
26
- AntifraudProviders["PIX"] = "pix";
27
- AntifraudProviders["POINTS"] = "glampoints";
28
- })(exports.AntifraudProviders || (exports.AntifraudProviders = {}));
29
-
30
- exports.PaymentMethods = void 0;
31
- (function (PaymentMethods) {
32
- PaymentMethods["CARD"] = "card";
33
- PaymentMethods["BANKSLIP"] = "bankSlip";
34
- PaymentMethods["PIX"] = "pix";
35
- PaymentMethods["POINTS"] = "glampoints";
36
- })(exports.PaymentMethods || (exports.PaymentMethods = {}));
37
-
38
- exports.PaymentProviders = void 0;
39
- (function (PaymentProviders) {
40
- PaymentProviders["PAGARME"] = "pagarMe";
41
- PaymentProviders["ADYEN"] = "adyen";
42
- PaymentProviders["GLAMPOINTS"] = "glampoints";
43
- })(exports.PaymentProviders || (exports.PaymentProviders = {}));
44
-
45
- class BasePaymentMethodFactory {
46
- constructor(methods) {
47
- this.methods = methods;
48
- }
49
- build(method) {
50
- return this.methods[method];
51
- }
52
- }
53
-
54
- class AdyenPaymentMethodFactory extends BasePaymentMethodFactory {
55
- }
56
-
57
- class AntifraudProviderFactory {
58
- constructor(antifraudProviders) {
59
- this.antifraudProviders = antifraudProviders;
60
- }
61
- build(provider) {
62
- return this.antifraudProviders[provider];
63
- }
64
- }
65
-
66
- class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
67
- }
68
-
69
- class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
70
- }
71
-
72
- class PaymentProviderFactory {
73
- constructor(paymentProviders) {
74
- this.paymentProviders = paymentProviders;
75
- }
76
- build(provider) {
77
- return this.paymentProviders[provider];
78
- }
79
- }
80
-
81
22
  class BaseModel {
82
23
  get identifier() {
83
24
  const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
@@ -615,182 +556,175 @@ exports.Status = void 0;
615
556
  Status["CANCELLED"] = "Cancelado";
616
557
  })(exports.Status || (exports.Status = {}));
617
558
 
618
- class PaymentTransaction extends BaseModel {
559
+ class Payment extends BaseModel {
560
+ static get identifiersFields() {
561
+ return ['id'];
562
+ }
619
563
  }
620
564
  tslib.__decorate([
621
565
  classTransformer.Expose({ name: 'refuse_reason' }),
622
566
  tslib.__metadata("design:type", String)
623
- ], PaymentTransaction.prototype, "refuseReason", void 0);
567
+ ], Payment.prototype, "refuseReason", void 0);
624
568
  tslib.__decorate([
625
569
  classTransformer.Expose({ name: 'status_reason' }),
626
570
  tslib.__metadata("design:type", String)
627
- ], PaymentTransaction.prototype, "statusReason", void 0);
571
+ ], Payment.prototype, "statusReason", void 0);
628
572
  tslib.__decorate([
629
573
  classTransformer.Expose({ name: 'acquirer_response_code' }),
630
574
  tslib.__metadata("design:type", String)
631
- ], PaymentTransaction.prototype, "acquirerResponseCode", void 0);
575
+ ], Payment.prototype, "acquirerResponseCode", void 0);
632
576
  tslib.__decorate([
633
577
  classTransformer.Expose({ name: 'acquirer_name' }),
634
578
  tslib.__metadata("design:type", String)
635
- ], PaymentTransaction.prototype, "acquirerName", void 0);
579
+ ], Payment.prototype, "acquirerName", void 0);
636
580
  tslib.__decorate([
637
581
  classTransformer.Expose({ name: 'acquirer_id' }),
638
582
  tslib.__metadata("design:type", String)
639
- ], PaymentTransaction.prototype, "acquirerId", void 0);
583
+ ], Payment.prototype, "acquirerId", void 0);
640
584
  tslib.__decorate([
641
585
  classTransformer.Expose({ name: 'authorization_code' }),
642
586
  tslib.__metadata("design:type", String)
643
- ], PaymentTransaction.prototype, "authorizationCode", void 0);
587
+ ], Payment.prototype, "authorizationCode", void 0);
644
588
  tslib.__decorate([
645
589
  classTransformer.Expose({ name: 'soft_descriptor' }),
646
590
  tslib.__metadata("design:type", String)
647
- ], PaymentTransaction.prototype, "softDescriptor", void 0);
591
+ ], Payment.prototype, "softDescriptor", void 0);
648
592
  tslib.__decorate([
649
593
  classTransformer.Expose({ name: 'date_created' }),
650
594
  tslib.__metadata("design:type", String)
651
- ], PaymentTransaction.prototype, "dateCreated", void 0);
595
+ ], Payment.prototype, "dateCreated", void 0);
652
596
  tslib.__decorate([
653
597
  classTransformer.Expose({ name: 'date_updated' }),
654
598
  tslib.__metadata("design:type", String)
655
- ], PaymentTransaction.prototype, "dateUpdated", void 0);
599
+ ], Payment.prototype, "dateUpdated", void 0);
656
600
  tslib.__decorate([
657
601
  classTransformer.Expose({ name: 'authorized_amount' }),
658
602
  tslib.__metadata("design:type", Number)
659
- ], PaymentTransaction.prototype, "authorizedAmount", void 0);
603
+ ], Payment.prototype, "authorizedAmount", void 0);
660
604
  tslib.__decorate([
661
605
  classTransformer.Expose({ name: 'paid_amount' }),
662
606
  tslib.__metadata("design:type", Number)
663
- ], PaymentTransaction.prototype, "paidAmount", void 0);
607
+ ], Payment.prototype, "paidAmount", void 0);
664
608
  tslib.__decorate([
665
609
  classTransformer.Expose({ name: 'paid_at' }),
666
610
  tslib.__metadata("design:type", String)
667
- ], PaymentTransaction.prototype, "paidAt", void 0);
611
+ ], Payment.prototype, "paidAt", void 0);
668
612
  tslib.__decorate([
669
613
  classTransformer.Expose({ name: 'refunded_amount' }),
670
614
  tslib.__metadata("design:type", Number)
671
- ], PaymentTransaction.prototype, "refundedAmount", void 0);
615
+ ], Payment.prototype, "refundedAmount", void 0);
672
616
  tslib.__decorate([
673
617
  classTransformer.Expose({ name: 'card_holder_name' }),
674
618
  tslib.__metadata("design:type", String)
675
- ], PaymentTransaction.prototype, "cardHolderName", void 0);
619
+ ], Payment.prototype, "cardHolderName", void 0);
676
620
  tslib.__decorate([
677
621
  classTransformer.Expose({ name: 'card_last_digits' }),
678
622
  tslib.__metadata("design:type", String)
679
- ], PaymentTransaction.prototype, "cardLastDigits", void 0);
623
+ ], Payment.prototype, "cardLastDigits", void 0);
680
624
  tslib.__decorate([
681
625
  classTransformer.Expose({ name: 'card_first_digits' }),
682
626
  tslib.__metadata("design:type", String)
683
- ], PaymentTransaction.prototype, "cardFirstDigits", void 0);
627
+ ], Payment.prototype, "cardFirstDigits", void 0);
684
628
  tslib.__decorate([
685
629
  classTransformer.Expose({ name: 'card_brand' }),
686
630
  tslib.__metadata("design:type", String)
687
- ], PaymentTransaction.prototype, "cardBrand", void 0);
631
+ ], Payment.prototype, "cardBrand", void 0);
688
632
  tslib.__decorate([
689
633
  classTransformer.Expose({ name: 'card_pin_mode' }),
690
634
  tslib.__metadata("design:type", String)
691
- ], PaymentTransaction.prototype, "cardPinMode", void 0);
635
+ ], Payment.prototype, "cardPinMode", void 0);
692
636
  tslib.__decorate([
693
637
  classTransformer.Expose({ name: 'card_magstripe_fallback' }),
694
638
  tslib.__metadata("design:type", Boolean)
695
- ], PaymentTransaction.prototype, "cardMagstripeFallback", void 0);
639
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
696
640
  tslib.__decorate([
697
641
  classTransformer.Expose({ name: 'cvm_pin' }),
698
642
  tslib.__metadata("design:type", Boolean)
699
- ], PaymentTransaction.prototype, "cvmPin", void 0);
643
+ ], Payment.prototype, "cvmPin", void 0);
700
644
  tslib.__decorate([
701
645
  classTransformer.Expose({ name: 'postback_url' }),
702
646
  tslib.__metadata("design:type", String)
703
- ], PaymentTransaction.prototype, "postbackUrl", void 0);
647
+ ], Payment.prototype, "postbackUrl", void 0);
704
648
  tslib.__decorate([
705
649
  classTransformer.Expose({ name: 'payment_method' }),
706
650
  tslib.__metadata("design:type", String)
707
- ], PaymentTransaction.prototype, "paymentMethod", void 0);
651
+ ], Payment.prototype, "paymentMethod", void 0);
708
652
  tslib.__decorate([
709
653
  classTransformer.Expose({ name: 'capture_method' }),
710
654
  tslib.__metadata("design:type", String)
711
- ], PaymentTransaction.prototype, "captureMethod", void 0);
655
+ ], Payment.prototype, "captureMethod", void 0);
712
656
  tslib.__decorate([
713
657
  classTransformer.Expose({ name: 'antifraud_score' }),
714
658
  tslib.__metadata("design:type", String)
715
- ], PaymentTransaction.prototype, "antifraudScore", void 0);
659
+ ], Payment.prototype, "antifraudScore", void 0);
716
660
  tslib.__decorate([
717
661
  classTransformer.Expose({ name: 'boleto_url' }),
718
662
  tslib.__metadata("design:type", String)
719
- ], PaymentTransaction.prototype, "boletoUrl", void 0);
663
+ ], Payment.prototype, "boletoUrl", void 0);
720
664
  tslib.__decorate([
721
665
  classTransformer.Expose({ name: 'boleto_barcode' }),
722
666
  tslib.__metadata("design:type", String)
723
- ], PaymentTransaction.prototype, "boletoBarcode", void 0);
667
+ ], Payment.prototype, "boletoBarcode", void 0);
724
668
  tslib.__decorate([
725
669
  classTransformer.Expose({ name: 'boleto_expiration_date' }),
726
670
  tslib.__metadata("design:type", String)
727
- ], PaymentTransaction.prototype, "boletoExpirationDate", void 0);
671
+ ], Payment.prototype, "boletoExpirationDate", void 0);
728
672
  tslib.__decorate([
729
673
  classTransformer.Expose({ name: 'subscription_id' }),
730
674
  tslib.__metadata("design:type", String)
731
- ], PaymentTransaction.prototype, "subscriptionId", void 0);
675
+ ], Payment.prototype, "subscriptionId", void 0);
732
676
  tslib.__decorate([
733
677
  classTransformer.Expose({ name: 'split_rules' }),
734
678
  tslib.__metadata("design:type", String)
735
- ], PaymentTransaction.prototype, "splitRules", void 0);
679
+ ], Payment.prototype, "splitRules", void 0);
736
680
  tslib.__decorate([
737
681
  classTransformer.Expose({ name: 'antifraud_metadata' }),
738
682
  tslib.__metadata("design:type", Object)
739
- ], PaymentTransaction.prototype, "antifraudMetadata", void 0);
683
+ ], Payment.prototype, "antifraudMetadata", void 0);
740
684
  tslib.__decorate([
741
685
  classTransformer.Expose({ name: 'reference_key' }),
742
686
  tslib.__metadata("design:type", String)
743
- ], PaymentTransaction.prototype, "referenceKey", void 0);
687
+ ], Payment.prototype, "referenceKey", void 0);
744
688
  tslib.__decorate([
745
689
  classTransformer.Expose({ name: 'local_transaction_id' }),
746
690
  tslib.__metadata("design:type", String)
747
- ], PaymentTransaction.prototype, "localTransactionId", void 0);
691
+ ], Payment.prototype, "localTransactionId", void 0);
748
692
  tslib.__decorate([
749
693
  classTransformer.Expose({ name: 'local_time' }),
750
694
  tslib.__metadata("design:type", String)
751
- ], PaymentTransaction.prototype, "localTime", void 0);
695
+ ], Payment.prototype, "localTime", void 0);
752
696
  tslib.__decorate([
753
697
  classTransformer.Expose({ name: 'fraud_covered' }),
754
698
  tslib.__metadata("design:type", Boolean)
755
- ], PaymentTransaction.prototype, "fraudCovered", void 0);
699
+ ], Payment.prototype, "fraudCovered", void 0);
756
700
  tslib.__decorate([
757
701
  classTransformer.Expose({ name: 'fraud_reimbursed' }),
758
702
  tslib.__metadata("design:type", String)
759
- ], PaymentTransaction.prototype, "fraudReimbursed", void 0);
703
+ ], Payment.prototype, "fraudReimbursed", void 0);
760
704
  tslib.__decorate([
761
705
  classTransformer.Expose({ name: 'order_id' }),
762
706
  tslib.__metadata("design:type", String)
763
- ], PaymentTransaction.prototype, "orderId", void 0);
707
+ ], Payment.prototype, "orderId", void 0);
764
708
  tslib.__decorate([
765
709
  classTransformer.Expose({ name: 'risk_level' }),
766
710
  tslib.__metadata("design:type", String)
767
- ], PaymentTransaction.prototype, "riskLevel", void 0);
711
+ ], Payment.prototype, "riskLevel", void 0);
768
712
  tslib.__decorate([
769
713
  classTransformer.Expose({ name: 'receipt_url' }),
770
714
  tslib.__metadata("design:type", String)
771
- ], PaymentTransaction.prototype, "receiptUrl", void 0);
715
+ ], Payment.prototype, "receiptUrl", void 0);
772
716
  tslib.__decorate([
773
717
  classTransformer.Expose({ name: 'private_label' }),
774
718
  tslib.__metadata("design:type", String)
775
- ], PaymentTransaction.prototype, "privateLabel", void 0);
719
+ ], Payment.prototype, "privateLabel", void 0);
776
720
  tslib.__decorate([
777
721
  classTransformer.Expose({ name: 'pix_qr_code' }),
778
722
  tslib.__metadata("design:type", String)
779
- ], PaymentTransaction.prototype, "pixQrCode", void 0);
723
+ ], Payment.prototype, "pixQrCode", void 0);
780
724
  tslib.__decorate([
781
725
  classTransformer.Expose({ name: 'pix_expiration_date' }),
782
726
  tslib.__metadata("design:type", String)
783
- ], PaymentTransaction.prototype, "pixExpirationDate", void 0);
784
-
785
- class Payment extends BaseModel {
786
- static get identifiersFields() {
787
- return ['id'];
788
- }
789
- }
790
- tslib.__decorate([
791
- classTransformer.Type(() => PaymentTransaction),
792
- tslib.__metadata("design:type", PaymentTransaction)
793
- ], Payment.prototype, "transaction", void 0);
727
+ ], Payment.prototype, "pixExpirationDate", void 0);
794
728
 
795
729
  class SubscriptionPayment extends BaseModel {
796
730
  static get identifiersFields() {
@@ -2263,8 +2197,8 @@ exports.OrderStatus = void 0;
2263
2197
  class Order extends Checkout {
2264
2198
  }
2265
2199
  tslib.__decorate([
2266
- classTransformer.Type(() => PaymentTransaction),
2267
- tslib.__metadata("design:type", PaymentTransaction)
2200
+ classTransformer.Type(() => Payment),
2201
+ tslib.__metadata("design:type", Payment)
2268
2202
  ], Order.prototype, "payment", void 0);
2269
2203
 
2270
2204
  class OrderBlocked extends BaseModel {
@@ -2295,592 +2229,6 @@ tslib.__decorate([
2295
2229
  tslib.__metadata("design:type", Coupon)
2296
2230
  ], CheckoutSubscription.prototype, "coupon", void 0);
2297
2231
 
2298
- class BusinessError extends tsCustomError.CustomError {
2299
- constructor(message, additionalData, type = '') {
2300
- super(message);
2301
- this.additionalData = additionalData;
2302
- this.type = type;
2303
- }
2304
- }
2305
-
2306
- class DuplicatedResultsError extends tsCustomError.CustomError {
2307
- constructor(message) {
2308
- super(message);
2309
- }
2310
- }
2311
-
2312
- class FraudValidationError extends tsCustomError.CustomError {
2313
- constructor(message, additionalData) {
2314
- super(message);
2315
- this.additionalData = additionalData;
2316
- this.type = 'antifraud';
2317
- }
2318
- }
2319
-
2320
- class InvalidArgumentError extends tsCustomError.CustomError {
2321
- constructor(message) {
2322
- super(message);
2323
- }
2324
- }
2325
-
2326
- class NotFoundError extends tsCustomError.CustomError {
2327
- constructor(message) {
2328
- super(message);
2329
- }
2330
- }
2331
-
2332
- class PaymentError extends tsCustomError.CustomError {
2333
- constructor(message, additionalData) {
2334
- super(message);
2335
- this.additionalData = additionalData;
2336
- this.type = 'payment';
2337
- }
2338
- }
2339
-
2340
- class RequiredArgumentError extends tsCustomError.CustomError {
2341
- constructor(args) {
2342
- super(`Required arguments: ${args.join(', ')}`);
2343
- this.args = args;
2344
- this.arguments = args;
2345
- }
2346
- }
2347
-
2348
- class StockLimitError extends BusinessError {
2349
- constructor(message, additionalData) {
2350
- super(message, additionalData);
2351
- this.type = 'stock-limit';
2352
- }
2353
- }
2354
-
2355
- class StockOutError extends BusinessError {
2356
- constructor(message, additionalData) {
2357
- super(message, additionalData);
2358
- this.type = 'stock-out';
2359
- }
2360
- }
2361
-
2362
- class AdyenCardService {
2363
- constructor(credentials, paymentRepository, orderBlockedRepository) {
2364
- this.credentials = credentials;
2365
- this.paymentRepository = paymentRepository;
2366
- this.orderBlockedRepository = orderBlockedRepository;
2367
- }
2368
- async pay(checkout, card) {
2369
- try {
2370
- const result = await axios__default["default"]({
2371
- method: 'POST',
2372
- url: this.credentials.URL_TRANSACTION,
2373
- headers: {
2374
- 'x-api-key': this.credentials.API_KEY,
2375
- 'content-type': 'application/json',
2376
- },
2377
- data: this.createCardPayment(checkout, card),
2378
- });
2379
- if (result.data.resultCode !== 'Authorised') {
2380
- this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2381
- return Promise.reject(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`, {
2382
- checkoutId: checkout.id,
2383
- userEmail: checkout.user.email,
2384
- info: result.data,
2385
- }));
2386
- }
2387
- const payment = await this.paymentRepository.create(Payment.toInstance({
2388
- createdAt: new Date(),
2389
- updatedAt: new Date(),
2390
- userId: checkout.user.id,
2391
- checkoutId: checkout.id,
2392
- totalPrice: checkout.totalPrice,
2393
- paymentProvider: 'adyen',
2394
- transaction: Object.assign(Object.assign({}, result.data), { status: 'paid' }),
2395
- }));
2396
- return payment;
2397
- }
2398
- catch (error) {
2399
- 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', {
2400
- checkoutId: checkout.id,
2401
- userEmail: checkout.user.email,
2402
- info: error.message,
2403
- });
2404
- }
2405
- }
2406
- createCardPayment(checkout, card) {
2407
- return {
2408
- amount: {
2409
- currency: 'BRL',
2410
- value: ((checkout === null || checkout === void 0 ? void 0 : checkout.totalPrice) || 0) * 100,
2411
- },
2412
- paymentMethod: {
2413
- type: 'scheme',
2414
- storedPaymentMethodId: card.cardId,
2415
- },
2416
- reference: checkout.id,
2417
- shopperInteraction: 'Ecommerce',
2418
- merchantAccount: this.credentials.MERCHANT_ACCOUNT,
2419
- shopperReference: checkout.user.id,
2420
- recurringProcessingModel: 'CardOnFile',
2421
- returnUrl: this.credentials.URL_POSTBACK,
2422
- installments: {
2423
- value: card.installments,
2424
- },
2425
- };
2426
- }
2427
- addCard() {
2428
- throw new Error('Method not implemented.');
2429
- }
2430
- }
2431
-
2432
- class AntifraudBankSlipService {
2433
- constructor(orderBlockedRepository) {
2434
- this.orderBlockedRepository = orderBlockedRepository;
2435
- this.MAX_ORDER_VALUE = 5000;
2436
- }
2437
- async validate(checkout) {
2438
- var _a, _b;
2439
- if (checkout.totalPrice && checkout.totalPrice > this.MAX_ORDER_VALUE && !((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber)) {
2440
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Boleto not authorized', 'Boleto', 'day');
2441
- throw new FraudValidationError('Boleto não autorizado para cliente não assinante', {
2442
- checkoutId: checkout.id,
2443
- userEmail: checkout.user.email,
2444
- info: {
2445
- isSubscriber: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.isSubscriber,
2446
- subtotal: checkout.subTotalPrice,
2447
- total: checkout.totalPrice,
2448
- },
2449
- });
2450
- }
2451
- return true;
2452
- }
2453
- }
2454
-
2455
- class AntifraudCardService {
2456
- constructor(orderRepository, orderBlockedRepository) {
2457
- this.orderRepository = orderRepository;
2458
- this.orderBlockedRepository = orderBlockedRepository;
2459
- this.LIMIT_ORDERS_DAY = 2;
2460
- this.LIMIT_ORDERS_WEEK = 7;
2461
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
2462
- }
2463
- async validate(checkout, card) {
2464
- var _a, _b;
2465
- if (!(await this.verifyBlockedOrderAttempts(checkout, card)))
2466
- throw new FraudValidationError('Cliente com mais de 5 compras negadas/bloqueadas no dia', {
2467
- checkoutId: checkout.id,
2468
- userEmail: checkout.user.email,
2469
- info: {
2470
- isSubscriber: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber,
2471
- subtotal: checkout.subTotalPrice,
2472
- total: checkout.totalPrice,
2473
- },
2474
- });
2475
- if (!(await this.verifyDayAndWeekOrders(checkout, card)))
2476
- throw new FraudValidationError('Cliente tentando comprar mais de 2 vezes no dia ou 7 vezes na semana', {
2477
- checkoutId: checkout.id,
2478
- userEmail: checkout.user.email,
2479
- info: {
2480
- isSubscriber: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.isSubscriber,
2481
- subtotal: checkout.subTotalPrice,
2482
- total: checkout.totalPrice,
2483
- },
2484
- });
2485
- return true;
2486
- }
2487
- async verifyBlockedOrderAttempts(checkout, card) {
2488
- var _a, _b, _c, _d;
2489
- const day = `${dateFns.format(new Date(), 'YYYY-MM-DD')}T00:00:00`;
2490
- const endOfDay = `${dateFns.format(new Date(), 'YYYY-MM-DD')}T23:59:59`;
2491
- const ordersBlockedWithCpf = await this.orderBlockedRepository
2492
- .find({
2493
- filters: {
2494
- customer: { cpf: { operator: exports.Where.EQUALS, value: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf } },
2495
- date: [
2496
- { operator: exports.Where.GTE, value: new Date(day) },
2497
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
2498
- ],
2499
- },
2500
- })
2501
- .then((data) => data.data);
2502
- const ordersBlockedWithEmail = await this.orderBlockedRepository
2503
- .find({
2504
- filters: {
2505
- customer: { email: { operator: exports.Where.EQUALS, value: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email } },
2506
- date: [
2507
- { operator: exports.Where.GTE, value: new Date(day) },
2508
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
2509
- ],
2510
- },
2511
- })
2512
- .then((data) => data.data);
2513
- const ordersBlockedWithCep = await this.orderBlockedRepository
2514
- .find({
2515
- filters: {
2516
- customer: { shippingAddress: { zip: { operator: exports.Where.EQUALS, value: (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip } } },
2517
- date: [
2518
- { operator: exports.Where.GTE, value: new Date(day) },
2519
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
2520
- ],
2521
- },
2522
- })
2523
- .then((data) => data.data);
2524
- const ordersBlockedWithPhone = await this.orderBlockedRepository
2525
- .find({
2526
- filters: {
2527
- customer: { phoneNumber: { operator: exports.Where.EQUALS, value: (_d = checkout.user) === null || _d === void 0 ? void 0 : _d.phone } },
2528
- date: [
2529
- { operator: exports.Where.GTE, value: new Date(day) },
2530
- { operator: exports.Where.LTE, value: new Date(endOfDay) },
2531
- ],
2532
- },
2533
- })
2534
- .then((data) => data.data);
2535
- const blockedUniqueEmails = ordersBlockedWithEmail.filter((e) => {
2536
- var _a;
2537
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf);
2538
- });
2539
- const blockedUniqueCeps = ordersBlockedWithCep.filter((e) => {
2540
- var _a, _b;
2541
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) && e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email);
2542
- });
2543
- const blockedUniquePhone = ordersBlockedWithPhone.filter((e) => {
2544
- var _a, _b, _c, _d, _e, _f;
2545
- return (e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) &&
2546
- e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email) &&
2547
- ((_d = (_c = e.customer.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip) === null || _d === void 0 ? void 0 : _d.toString()) !== ((_f = (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.zip) === null || _f === void 0 ? void 0 : _f.toString()));
2548
- });
2549
- const blockedAttempts = ordersBlockedWithCpf
2550
- .concat(blockedUniqueEmails)
2551
- .concat(blockedUniqueCeps)
2552
- .concat(blockedUniquePhone);
2553
- if (blockedAttempts.length >= this.LIMIT_BLOCKED_ORDERS_DAY) {
2554
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'More than 5 attempts have failed', 'Failed attempts', 'day', card || null);
2555
- return false;
2556
- }
2557
- return true;
2558
- }
2559
- async verifyDayAndWeekOrders(checkout, card) {
2560
- var _a, _b, _c, _d, _e, _f, _g, _h;
2561
- const ordersPerDay = await this.validateOrdersByRange((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf, (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email, (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.phone, (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.zip, card, this.getDateRange('day'));
2562
- for (const key in ordersPerDay) {
2563
- if (ordersPerDay[key] > this.LIMIT_ORDERS_DAY) {
2564
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'day');
2565
- return false;
2566
- }
2567
- }
2568
- const ordersPerWeek = await this.validateOrdersByRange((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.cpf, (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.email, (_g = checkout.user) === null || _g === void 0 ? void 0 : _g.phone, (_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip, card, this.getDateRange('week'));
2569
- for (const key in ordersPerWeek) {
2570
- if (ordersPerDay[key] > this.LIMIT_ORDERS_WEEK) {
2571
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'week');
2572
- return false;
2573
- }
2574
- }
2575
- return true;
2576
- }
2577
- async validateOrdersByRange(cpf, email, phone, zip, card, range) {
2578
- const ordersCpf = await this.countOrdersByField('user', 'cpf', cpf, range);
2579
- const ordersByEmail = await this.countOrdersByField('user', 'email', email, range);
2580
- const ordersByPhone = await this.countOrdersByField('user', 'phone', phone, range);
2581
- const ordersByZip = await this.countOrdersByField('shippingAddress', 'zip', zip, range);
2582
- return {
2583
- cpf: ordersCpf,
2584
- email: ordersByEmail,
2585
- phone: ordersByPhone,
2586
- zip: ordersByZip,
2587
- };
2588
- }
2589
- async countOrdersByField(property, field, value, range) {
2590
- const filters = {
2591
- [property]: {
2592
- [field]: value,
2593
- },
2594
- ['createdAt']: [
2595
- { operator: exports.Where.GTE, value: range.firstDate },
2596
- { operator: exports.Where.LTE, value: range.lastDate },
2597
- ],
2598
- };
2599
- const docs = await (await this.orderRepository.find({ filters })).count;
2600
- return docs;
2601
- }
2602
- getDateRange(range = 'day') {
2603
- switch (range) {
2604
- case 'day':
2605
- return {
2606
- firstDate: dateFns.startOfDay(new Date()).getTime(),
2607
- lastDate: dateFns.endOfDay(new Date()).getTime(),
2608
- };
2609
- case 'week':
2610
- return {
2611
- firstDate: dateFns.startOfDay(dateFns.subDays(new Date(), 7)).getTime(),
2612
- lastDate: dateFns.endOfDay(new Date()).getTime(),
2613
- };
2614
- default:
2615
- return {
2616
- firstDate: dateFns.startOfDay(new Date()).getTime(),
2617
- lastDate: dateFns.endOfDay(new Date()).getTime(),
2618
- };
2619
- }
2620
- }
2621
- }
2622
-
2623
- class AntifraudGlampointsService {
2624
- constructor() { }
2625
- async validate(checkout) {
2626
- return true;
2627
- }
2628
- }
2629
-
2630
- class AntifraudPixService {
2631
- constructor() { }
2632
- async validate(checkout) {
2633
- return true;
2634
- }
2635
- }
2636
-
2637
- class GlampointsPaymentService {
2638
- constructor(paymentRepository) {
2639
- this.paymentRepository = paymentRepository;
2640
- }
2641
- async pay(checkout) {
2642
- const payment = await this.paymentRepository.create(Payment.toInstance({
2643
- createdAt: new Date(),
2644
- updatedAt: new Date(),
2645
- userId: checkout.user.id,
2646
- checkoutId: checkout.id,
2647
- totalPrice: checkout.totalPrice,
2648
- paymentProvider: 'glampoints',
2649
- transaction: {
2650
- amount: 0,
2651
- acquirerResponseCode: '0000',
2652
- acquirerName: 'glampoints',
2653
- authorizedAmount: 0,
2654
- captureMethod: 'ecommerce',
2655
- installments: 1,
2656
- cost: 0,
2657
- paidAmount: 0,
2658
- paidAt: new Date().toISOString(),
2659
- paymentMethod: 'glampoints',
2660
- referer: 'api_key',
2661
- refundedAmount: 0,
2662
- status: 'paid',
2663
- statusReason: 'acquirer',
2664
- },
2665
- }));
2666
- return payment;
2667
- }
2668
- }
2669
-
2670
- class PagarmeBankSlipService {
2671
- constructor(credentials, paymentRepository) {
2672
- this.credentials = credentials;
2673
- this.paymentRepository = paymentRepository;
2674
- }
2675
- async pay(checkout) {
2676
- try {
2677
- const result = await axios__default["default"]({
2678
- method: 'POST',
2679
- url: this.credentials.URL_TRANSACTION,
2680
- data: this.createBoletoPayment(checkout),
2681
- });
2682
- if (result.data.status !== 'processing') {
2683
- return Promise.reject(new PaymentError(`Houve uma falha ao gerar o boleto. Tente novamente`, {
2684
- checkoutId: checkout.id,
2685
- userEmail: checkout.user.email,
2686
- info: result.data,
2687
- }));
2688
- }
2689
- const payment = await this.paymentRepository.create(Payment.toInstance({
2690
- createdAt: new Date(),
2691
- updatedAt: new Date(),
2692
- userId: checkout.user.id,
2693
- checkoutId: checkout.id,
2694
- totalPrice: checkout.totalPrice,
2695
- paymentProvider: 'pagarMe',
2696
- transaction: result.data,
2697
- }));
2698
- return payment;
2699
- }
2700
- catch (error) {
2701
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
2702
- checkoutId: checkout.id,
2703
- userEmail: checkout.user.email,
2704
- info: error.response.data,
2705
- });
2706
- }
2707
- }
2708
- createBoletoPayment(checkout) {
2709
- return {
2710
- api_key: this.credentials.API_KEY,
2711
- amount: Math.floor(checkout.totalPrice * 100),
2712
- boleto_rules: ['strict_expiration_date'],
2713
- boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
2714
- boleto_expiration_date: dateFns.format(dateFns.addDays(new Date(), 3), 'yyyy-MM-dd'),
2715
- payment_method: 'boleto',
2716
- postback_url: this.credentials.URL_POSTBACK,
2717
- customer: {
2718
- external_id: checkout.user.id,
2719
- type: 'individual',
2720
- country: 'br',
2721
- name: checkout.user.displayName,
2722
- documents: [
2723
- {
2724
- type: 'cpf',
2725
- number: checkout.user.cpf,
2726
- },
2727
- ],
2728
- },
2729
- };
2730
- }
2731
- }
2732
-
2733
- class PagarmeCardService {
2734
- constructor(credentials, paymentRepository, orderBlockedRepository) {
2735
- this.credentials = credentials;
2736
- this.paymentRepository = paymentRepository;
2737
- this.orderBlockedRepository = orderBlockedRepository;
2738
- }
2739
- async pay(checkout, card) {
2740
- var _a;
2741
- try {
2742
- const result = await axios__default["default"]({
2743
- method: 'POST',
2744
- url: this.credentials.URL_TRANSACTION,
2745
- data: this.createCardPayment(checkout, card),
2746
- });
2747
- if (result.data.status !== 'paid') {
2748
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2749
- return Promise.reject(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`, {
2750
- checkoutId: checkout.id,
2751
- userEmail: checkout.user.email,
2752
- info: result.data,
2753
- }));
2754
- }
2755
- const payment = await this.paymentRepository.create(Payment.toInstance({
2756
- createdAt: new Date(),
2757
- updatedAt: new Date(),
2758
- userId: checkout.user.id,
2759
- checkoutId: checkout.id,
2760
- totalPrice: checkout.totalPrice,
2761
- paymentProvider: exports.PaymentProviders.PAGARME,
2762
- transaction: Object.assign(Object.assign({}, result.data), { paidAt: new Date() }),
2763
- }));
2764
- return payment;
2765
- }
2766
- catch (error) {
2767
- 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', {
2768
- checkoutId: checkout.id,
2769
- userEmail: checkout.user.email,
2770
- info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
2771
- });
2772
- }
2773
- }
2774
- addCard() {
2775
- throw new Error('Method not implemented.');
2776
- }
2777
- createCardPayment(checkout, card) {
2778
- var _a, _b, _c, _d, _e, _f;
2779
- return {
2780
- api_key: this.credentials.API_KEY,
2781
- amount: Math.floor(checkout.totalPrice * 100),
2782
- card_id: card.cardId,
2783
- payment_method: 'credit_card',
2784
- installments: card.installments,
2785
- soft_descriptor: checkout.shop,
2786
- customer: {
2787
- external_id: checkout.user.id,
2788
- name: checkout.user.displayName,
2789
- type: 'individual',
2790
- country: 'br',
2791
- email: checkout.user.email,
2792
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2793
- documents: [
2794
- {
2795
- type: 'cpf',
2796
- number: checkout.user.cpf,
2797
- },
2798
- ],
2799
- },
2800
- billing: {
2801
- name: checkout.user.displayName,
2802
- address: {
2803
- country: 'br',
2804
- state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
2805
- city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
2806
- neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
2807
- street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
2808
- street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
2809
- zipcode: checkout.billingAddress
2810
- ? checkout.billingAddress.zip.replace('-', '')
2811
- : (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
2812
- },
2813
- },
2814
- items: checkout.lineItems.map((item) => {
2815
- return {
2816
- id: item.id,
2817
- title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
2818
- unit_price: Math.floor(item.pricePaid * 100),
2819
- quantity: item.quantity,
2820
- tangible: true,
2821
- };
2822
- }),
2823
- };
2824
- }
2825
- }
2826
-
2827
- class PagarmePixService {
2828
- constructor(credentials, paymentRepository) {
2829
- this.credentials = credentials;
2830
- this.paymentRepository = paymentRepository;
2831
- }
2832
- async pay(checkout) {
2833
- var _a;
2834
- try {
2835
- const result = await axios__default["default"]({
2836
- method: 'POST',
2837
- url: this.credentials.URL_TRANSACTION,
2838
- data: this.createPixPayment(checkout),
2839
- });
2840
- const payment = await this.paymentRepository.create(Payment.toInstance({
2841
- createdAt: new Date(),
2842
- updatedAt: new Date(),
2843
- userId: checkout.user.id,
2844
- checkoutId: checkout.id,
2845
- totalPrice: checkout.totalPrice,
2846
- paymentProvider: 'pagarMe',
2847
- transaction: Object.assign(Object.assign({}, result.data), { paidAt: new Date() }),
2848
- }));
2849
- return payment;
2850
- }
2851
- catch (error) {
2852
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
2853
- checkoutId: checkout.id,
2854
- userEmail: checkout.user.email,
2855
- info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
2856
- });
2857
- }
2858
- }
2859
- createPixPayment(checkout) {
2860
- return {
2861
- payment_method: 'pix',
2862
- amount: Math.floor(checkout.totalPrice * 100),
2863
- api_key: this.credentials.API_KEY,
2864
- postback_url: this.credentials.URL_POSTBACK,
2865
- pix_expiration_date: dateFns.format(dateFns.addDays(new Date(), 1), 'yyyy-MM-dd'),
2866
- customer: {
2867
- external_id: checkout.user.id,
2868
- type: 'individual',
2869
- country: 'br',
2870
- name: checkout.user.displayName,
2871
- email: checkout.user.email.trim(),
2872
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2873
- documents: [
2874
- {
2875
- type: 'cpf',
2876
- number: checkout.user.cpf,
2877
- },
2878
- ],
2879
- },
2880
- };
2881
- }
2882
- }
2883
-
2884
2232
  class RoundProductPricesHelper {
2885
2233
  static roundProductPrices(product) {
2886
2234
  product.price.price = Number(product.price.price.toFixed(2));
@@ -2895,12 +2243,6 @@ class RoundProductPricesHelper {
2895
2243
  }
2896
2244
  }
2897
2245
 
2898
- class Sequence extends BaseModel {
2899
- static get identifiersFields() {
2900
- return ['id'];
2901
- }
2902
- }
2903
-
2904
2246
  exports.FilterType = void 0;
2905
2247
  (function (FilterType) {
2906
2248
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -3039,12 +2381,38 @@ class ShopSettings extends BaseModel {
3039
2381
  }
3040
2382
  }
3041
2383
 
3042
- class AxiosAdapter {
3043
- constructor(config) {
3044
- this.config = config;
3045
- this.logger = DebugHelper.from(this);
2384
+ class InvalidArgumentError extends tsCustomError.CustomError {
2385
+ constructor(message) {
2386
+ super(message);
3046
2387
  }
3047
- async get(index, id) {
2388
+ }
2389
+
2390
+ class RequiredArgumentError extends tsCustomError.CustomError {
2391
+ constructor(args) {
2392
+ super(`Required arguments: ${args.join(', ')}`);
2393
+ this.args = args;
2394
+ this.arguments = args;
2395
+ }
2396
+ }
2397
+
2398
+ class NotFoundError extends tsCustomError.CustomError {
2399
+ constructor(message) {
2400
+ super(message);
2401
+ }
2402
+ }
2403
+
2404
+ class DuplicatedResultsError extends tsCustomError.CustomError {
2405
+ constructor(message) {
2406
+ super(message);
2407
+ }
2408
+ }
2409
+
2410
+ class AxiosAdapter {
2411
+ constructor(config) {
2412
+ this.config = config;
2413
+ this.logger = DebugHelper.from(this);
2414
+ }
2415
+ async get(index, id) {
3048
2416
  const logger = this.logger.with('get');
3049
2417
  const req = {
3050
2418
  url: `${this.config.url}/${index}/_doc/${id}`,
@@ -3173,8 +2541,6 @@ class ProductsIndex {
3173
2541
  'rate',
3174
2542
  ];
3175
2543
  const filter = [{ term: { published: true } }];
3176
- if (shop && shop !== exports.Shops.ALL)
3177
- filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
3178
2544
  if (size > 9)
3179
2545
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
3180
2546
  const query = {
@@ -3742,6 +3108,180 @@ const withCrudFirestore = (MixinBase) => {
3742
3108
  };
3743
3109
  };
3744
3110
 
3111
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3112
+ constructor({ firestore, interceptors }) {
3113
+ super({
3114
+ firestore,
3115
+ collectionName: 'leads',
3116
+ model: Lead,
3117
+ interceptors,
3118
+ });
3119
+ }
3120
+ }
3121
+
3122
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3123
+ constructor({ firestore, interceptors }, parentRepository) {
3124
+ super({
3125
+ firestore,
3126
+ collectionName: 'editions',
3127
+ parentIdField: 'subscriptionId',
3128
+ model: Edition,
3129
+ interceptors,
3130
+ });
3131
+ this.parentRepository = parentRepository;
3132
+ }
3133
+ }
3134
+
3135
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3136
+ constructor({ firestore, interceptors, }) {
3137
+ super({
3138
+ firestore,
3139
+ collectionName: 'subscription',
3140
+ model: Subscription,
3141
+ interceptors,
3142
+ });
3143
+ }
3144
+ }
3145
+
3146
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3147
+ constructor({ firestore, interceptors }) {
3148
+ super({
3149
+ firestore,
3150
+ collectionName: 'subscriptionMaterialization',
3151
+ model: SubscriptionMaterialization,
3152
+ interceptors,
3153
+ });
3154
+ }
3155
+ }
3156
+
3157
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3158
+ constructor({ firestore, interceptors }, parentRepository) {
3159
+ super({
3160
+ firestore,
3161
+ collectionName: 'payments',
3162
+ parentIdField: 'subscriptionId',
3163
+ model: SubscriptionPayment,
3164
+ interceptors,
3165
+ });
3166
+ this.parentRepository = parentRepository;
3167
+ }
3168
+ }
3169
+
3170
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3171
+ constructor({ firestore, interceptors, }) {
3172
+ super({
3173
+ firestore,
3174
+ collectionName: 'subscriptionSummary',
3175
+ model: SubscriptionSummary,
3176
+ interceptors,
3177
+ });
3178
+ }
3179
+ }
3180
+
3181
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3182
+ constructor({ firestore, interceptors }, parentRepository) {
3183
+ super({
3184
+ firestore,
3185
+ collectionName: 'address',
3186
+ parentIdField: 'userId',
3187
+ model: UserAddress,
3188
+ interceptors,
3189
+ });
3190
+ this.parentRepository = parentRepository;
3191
+ }
3192
+ }
3193
+
3194
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3195
+ constructor({ firestore, interceptors }, parentRepository) {
3196
+ super({
3197
+ firestore,
3198
+ collectionName: 'CX',
3199
+ parentIdField: 'userId',
3200
+ model: BeautyProfile,
3201
+ interceptors,
3202
+ });
3203
+ this.parentRepository = parentRepository;
3204
+ }
3205
+ }
3206
+
3207
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3208
+ constructor({ firestore, interceptors }) {
3209
+ super({
3210
+ firestore,
3211
+ collectionName: 'users',
3212
+ model: User,
3213
+ interceptors,
3214
+ });
3215
+ }
3216
+ async get(identifiers) {
3217
+ const user = await super.get({ id: identifiers.id });
3218
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3219
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3220
+ return user;
3221
+ }
3222
+ async checkIfExistsByField(field, value) {
3223
+ const result = await this.find({ filters: { [field]: value } });
3224
+ return result.count > 0;
3225
+ }
3226
+ buildModelInstance() {
3227
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3228
+ return {
3229
+ toFirestore: (data) => {
3230
+ const plain = toFirestore(data);
3231
+ delete plain.isSubscriber;
3232
+ return plain;
3233
+ },
3234
+ fromFirestore,
3235
+ };
3236
+ }
3237
+ async getBeautyProfile(userId) {
3238
+ const beautyProfile = await this.firestore
3239
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3240
+ .withConverter(this.buildBeautyProfileModelInstance())
3241
+ .getDoc('beautyProfile')
3242
+ .get();
3243
+ return beautyProfile.data();
3244
+ }
3245
+ async checkIfIsSubscriber(userId) {
3246
+ const docs = await this.collection('subscription')
3247
+ .where('user.id', '==', userId)
3248
+ .where('status', '==', 'active')
3249
+ .getDocs();
3250
+ return !!docs && !!docs.size;
3251
+ }
3252
+ buildBeautyProfileModelInstance() {
3253
+ return {
3254
+ toFirestore: (data) => data.toPlain(),
3255
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3256
+ };
3257
+ }
3258
+ }
3259
+ tslib.__decorate([
3260
+ Log(),
3261
+ tslib.__metadata("design:type", Function),
3262
+ tslib.__metadata("design:paramtypes", [Object]),
3263
+ tslib.__metadata("design:returntype", Promise)
3264
+ ], UserFirestoreRepository.prototype, "get", null);
3265
+ tslib.__decorate([
3266
+ Log(),
3267
+ tslib.__metadata("design:type", Function),
3268
+ tslib.__metadata("design:paramtypes", [String, String]),
3269
+ tslib.__metadata("design:returntype", Promise)
3270
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3271
+
3272
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3273
+ constructor({ firestore, interceptors }, parentRepository) {
3274
+ super({
3275
+ firestore,
3276
+ collectionName: 'payment_method',
3277
+ parentIdField: 'userId',
3278
+ model: UserPaymentMethod,
3279
+ interceptors,
3280
+ });
3281
+ this.parentRepository = parentRepository;
3282
+ }
3283
+ }
3284
+
3745
3285
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3746
3286
  constructor({ firestore, interceptors }) {
3747
3287
  super({
@@ -3891,131 +3431,36 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
3891
3431
  }
3892
3432
  tslib.__decorate([
3893
3433
  Log(),
3894
- tslib.__metadata("design:type", Function),
3895
- tslib.__metadata("design:paramtypes", [String]),
3896
- tslib.__metadata("design:returntype", Promise)
3897
- ], ProductFirestoreRepository.prototype, "getBySlug", null);
3898
- tslib.__decorate([
3899
- Log(),
3900
- tslib.__metadata("design:type", Function),
3901
- tslib.__metadata("design:paramtypes", [String]),
3902
- tslib.__metadata("design:returntype", Promise)
3903
- ], ProductFirestoreRepository.prototype, "fetchReviews", null);
3904
-
3905
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3906
- constructor({ firestore, interceptors }, parentRepository) {
3907
- super({
3908
- firestore,
3909
- collectionName: 'variants',
3910
- parentIdField: 'productId',
3911
- model: Variant,
3912
- interceptors,
3913
- });
3914
- this.parentRepository = parentRepository;
3915
- }
3916
- }
3917
-
3918
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3919
- constructor({ firestore, interceptors }) {
3920
- super({
3921
- firestore,
3922
- collectionName: 'subscriptionProducts',
3923
- model: Product,
3924
- interceptors,
3925
- });
3926
- }
3927
- }
3928
-
3929
- class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3930
- constructor({ firestore, interceptors }) {
3931
- super({
3932
- firestore,
3933
- collectionName: 'sequences',
3934
- model: Sequence,
3935
- interceptors,
3936
- });
3937
- }
3938
- }
3939
-
3940
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3941
- constructor({ firestore, interceptors }) {
3942
- super({
3943
- firestore,
3944
- collectionName: 'dms',
3945
- model: Home,
3946
- interceptors,
3947
- });
3948
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3949
- var _a, _b, _c;
3950
- return ({
3951
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3952
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3953
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3954
- products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
3955
- });
3956
- };
3957
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3958
- var _a;
3959
- return ({
3960
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3961
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3962
- });
3963
- };
3964
- }
3965
- buildModelInstance() {
3966
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3967
- return {
3968
- toFirestore: (data) => {
3969
- const modifiedData = this.homeToFirestore(data);
3970
- return toFirestore(modifiedData);
3971
- },
3972
- fromFirestore: (snap) => {
3973
- const instance = fromFirestore(snap);
3974
- return this.homeFromFirestore(instance);
3975
- },
3976
- };
3977
- }
3978
- homeToFirestore(home) {
3979
- var _a, _b, _c, _d;
3980
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3981
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3982
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3983
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3984
- }
3985
- return home;
3986
- }
3987
- homeFromFirestore(home) {
3988
- var _a;
3989
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3990
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3991
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3992
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3993
- home.data.createdAt =
3994
- home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3995
- home.data.expiresAt =
3996
- home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3997
- }
3998
- return home;
3999
- }
4000
- }
3434
+ tslib.__metadata("design:type", Function),
3435
+ tslib.__metadata("design:paramtypes", [String]),
3436
+ tslib.__metadata("design:returntype", Promise)
3437
+ ], ProductFirestoreRepository.prototype, "getBySlug", null);
3438
+ tslib.__decorate([
3439
+ Log(),
3440
+ tslib.__metadata("design:type", Function),
3441
+ tslib.__metadata("design:paramtypes", [String]),
3442
+ tslib.__metadata("design:returntype", Promise)
3443
+ ], ProductFirestoreRepository.prototype, "fetchReviews", null);
4001
3444
 
4002
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4003
- constructor({ firestore, interceptors }) {
3445
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3446
+ constructor({ firestore, interceptors }, parentRepository) {
4004
3447
  super({
4005
3448
  firestore,
4006
- collectionName: 'shopMenus',
4007
- model: ShopMenu,
3449
+ collectionName: 'variants',
3450
+ parentIdField: 'productId',
3451
+ model: Variant,
4008
3452
  interceptors,
4009
3453
  });
3454
+ this.parentRepository = parentRepository;
4010
3455
  }
4011
3456
  }
4012
3457
 
4013
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4014
- constructor({ firestore, interceptors, }) {
3458
+ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3459
+ constructor({ firestore, interceptors }) {
4015
3460
  super({
4016
3461
  firestore,
4017
- collectionName: 'shopSettings',
4018
- model: ShopSettings,
3462
+ collectionName: 'subscriptionProducts',
3463
+ model: Product,
4019
3464
  interceptors,
4020
3465
  });
4021
3466
  }
@@ -4214,177 +3659,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
4214
3659
  }
4215
3660
  }
4216
3661
 
4217
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3662
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4218
3663
  constructor({ firestore, interceptors }) {
4219
3664
  super({
4220
3665
  firestore,
4221
- collectionName: 'leads',
4222
- model: Lead,
3666
+ collectionName: 'dms',
3667
+ model: Home,
4223
3668
  interceptors,
4224
3669
  });
3670
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3671
+ var _a, _b, _c;
3672
+ return ({
3673
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3674
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3675
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3676
+ products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
3677
+ });
3678
+ };
3679
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3680
+ var _a;
3681
+ return ({
3682
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3683
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3684
+ });
3685
+ };
4225
3686
  }
4226
- }
4227
-
4228
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4229
- constructor({ firestore, interceptors }, parentRepository) {
4230
- super({
4231
- firestore,
4232
- collectionName: 'editions',
4233
- parentIdField: 'subscriptionId',
4234
- model: Edition,
4235
- interceptors,
4236
- });
4237
- this.parentRepository = parentRepository;
3687
+ buildModelInstance() {
3688
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3689
+ return {
3690
+ toFirestore: (data) => {
3691
+ const modifiedData = this.homeToFirestore(data);
3692
+ return toFirestore(modifiedData);
3693
+ },
3694
+ fromFirestore: (snap) => {
3695
+ const instance = fromFirestore(snap);
3696
+ return this.homeFromFirestore(instance);
3697
+ },
3698
+ };
4238
3699
  }
4239
- }
4240
-
4241
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4242
- constructor({ firestore, interceptors, }) {
4243
- super({
4244
- firestore,
4245
- collectionName: 'subscription',
4246
- model: Subscription,
4247
- interceptors,
4248
- });
3700
+ homeToFirestore(home) {
3701
+ var _a, _b, _c, _d;
3702
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3703
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3704
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3705
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3706
+ }
3707
+ return home;
4249
3708
  }
4250
- }
4251
-
4252
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4253
- constructor({ firestore, interceptors }) {
4254
- super({
4255
- firestore,
4256
- collectionName: 'subscriptionMaterialization',
4257
- model: SubscriptionMaterialization,
4258
- interceptors,
4259
- });
3709
+ homeFromFirestore(home) {
3710
+ var _a;
3711
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3712
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3713
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3714
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3715
+ home.data.createdAt =
3716
+ home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3717
+ home.data.expiresAt =
3718
+ home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3719
+ }
3720
+ return home;
4260
3721
  }
4261
3722
  }
4262
3723
 
4263
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4264
- constructor({ firestore, interceptors }, parentRepository) {
3724
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3725
+ constructor({ firestore, interceptors }) {
4265
3726
  super({
4266
3727
  firestore,
4267
- collectionName: 'payments',
4268
- parentIdField: 'subscriptionId',
4269
- model: SubscriptionPayment,
3728
+ collectionName: 'shopMenus',
3729
+ model: ShopMenu,
4270
3730
  interceptors,
4271
3731
  });
4272
- this.parentRepository = parentRepository;
4273
3732
  }
4274
3733
  }
4275
3734
 
4276
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3735
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4277
3736
  constructor({ firestore, interceptors, }) {
4278
3737
  super({
4279
3738
  firestore,
4280
- collectionName: 'subscriptionSummary',
4281
- model: SubscriptionSummary,
4282
- interceptors,
4283
- });
4284
- }
4285
- }
4286
-
4287
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4288
- constructor({ firestore, interceptors }, parentRepository) {
4289
- super({
4290
- firestore,
4291
- collectionName: 'address',
4292
- parentIdField: 'userId',
4293
- model: UserAddress,
4294
- interceptors,
4295
- });
4296
- this.parentRepository = parentRepository;
4297
- }
4298
- }
4299
-
4300
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4301
- constructor({ firestore, interceptors }, parentRepository) {
4302
- super({
4303
- firestore,
4304
- collectionName: 'CX',
4305
- parentIdField: 'userId',
4306
- model: BeautyProfile,
4307
- interceptors,
4308
- });
4309
- this.parentRepository = parentRepository;
4310
- }
4311
- }
4312
-
4313
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4314
- constructor({ firestore, interceptors }) {
4315
- super({
4316
- firestore,
4317
- collectionName: 'users',
4318
- model: User,
4319
- interceptors,
4320
- });
4321
- }
4322
- async get(identifiers) {
4323
- const user = await super.get({ id: identifiers.id });
4324
- user.beautyProfile = await this.getBeautyProfile(user.id);
4325
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
4326
- return user;
4327
- }
4328
- async checkIfExistsByField(field, value) {
4329
- const result = await this.find({ filters: { [field]: value } });
4330
- return result.count > 0;
4331
- }
4332
- buildModelInstance() {
4333
- const { fromFirestore, toFirestore } = super.buildModelInstance();
4334
- return {
4335
- toFirestore: (data) => {
4336
- const plain = toFirestore(data);
4337
- delete plain.isSubscriber;
4338
- return plain;
4339
- },
4340
- fromFirestore,
4341
- };
4342
- }
4343
- async getBeautyProfile(userId) {
4344
- const beautyProfile = await this.firestore
4345
- .getCollection(`${this.collectionName}/${userId}/CX`)
4346
- .withConverter(this.buildBeautyProfileModelInstance())
4347
- .getDoc('beautyProfile')
4348
- .get();
4349
- return beautyProfile.data();
4350
- }
4351
- async checkIfIsSubscriber(userId) {
4352
- const docs = await this.collection('subscription')
4353
- .where('user.id', '==', userId)
4354
- .where('status', '==', 'active')
4355
- .getDocs();
4356
- return !!docs && !!docs.size;
4357
- }
4358
- buildBeautyProfileModelInstance() {
4359
- return {
4360
- toFirestore: (data) => data.toPlain(),
4361
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
4362
- };
4363
- }
4364
- }
4365
- tslib.__decorate([
4366
- Log(),
4367
- tslib.__metadata("design:type", Function),
4368
- tslib.__metadata("design:paramtypes", [Object]),
4369
- tslib.__metadata("design:returntype", Promise)
4370
- ], UserFirestoreRepository.prototype, "get", null);
4371
- tslib.__decorate([
4372
- Log(),
4373
- tslib.__metadata("design:type", Function),
4374
- tslib.__metadata("design:paramtypes", [String, String]),
4375
- tslib.__metadata("design:returntype", Promise)
4376
- ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
4377
-
4378
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4379
- constructor({ firestore, interceptors }, parentRepository) {
4380
- super({
4381
- firestore,
4382
- collectionName: 'payment_method',
4383
- parentIdField: 'userId',
4384
- model: UserPaymentMethod,
3739
+ collectionName: 'shopSettings',
3740
+ model: ShopSettings,
4385
3741
  interceptors,
4386
3742
  });
4387
- this.parentRepository = parentRepository;
4388
3743
  }
4389
3744
  }
4390
3745
 
@@ -6525,6 +5880,24 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
6525
5880
  ],
6526
5881
  });
6527
5882
  }
5883
+ async updateManyStatus(reviews) {
5884
+ return await this.mutation('update_product_review_many', ['affected_rows'], {
5885
+ updates: {
5886
+ type: '[product_review_updates!]',
5887
+ required: true,
5888
+ value: [
5889
+ {
5890
+ _set: { status: true },
5891
+ where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
5892
+ },
5893
+ {
5894
+ _set: { status: false },
5895
+ where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
5896
+ },
5897
+ ],
5898
+ },
5899
+ });
5900
+ }
6528
5901
  aproveReview(id) {
6529
5902
  return this.update({ id, status: true });
6530
5903
  }
@@ -6786,6 +6159,15 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6786
6159
  }),
6787
6160
  },
6788
6161
  },
6162
+ {
6163
+ metadatas: {
6164
+ columnName: 'metadatas',
6165
+ fields: ['shop', 'title', 'description'],
6166
+ bindPersistData: (value) => ({
6167
+ metadatas: { data: value },
6168
+ }),
6169
+ },
6170
+ },
6789
6171
  { isCollection: { columnName: 'is_collection' } },
6790
6172
  { isWishlist: { columnName: 'is_wishlist' } },
6791
6173
  'reference',
@@ -6805,6 +6187,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6805
6187
  'theme',
6806
6188
  { bannerUrl: { columnName: 'banner_url' } },
6807
6189
  { personHasPhoto: { columnName: 'person_has_photo' } },
6190
+ { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6808
6191
  ],
6809
6192
  });
6810
6193
  this.categoryFilterRepository = categoryFilterRepository;
@@ -7061,10 +6444,6 @@ Object.defineProperty(exports, 'sub', {
7061
6444
  enumerable: true,
7062
6445
  get: function () { return dateFns.sub; }
7063
6446
  });
7064
- Object.defineProperty(exports, 'subDays', {
7065
- enumerable: true,
7066
- get: function () { return dateFns.subDays; }
7067
- });
7068
6447
  Object.defineProperty(exports, 'chunk', {
7069
6448
  enumerable: true,
7070
6449
  get: function () { return lodash.chunk; }
@@ -7138,13 +6517,6 @@ Object.defineProperty(exports, 'unset', {
7138
6517
  get: function () { return lodash.unset; }
7139
6518
  });
7140
6519
  exports.Address = Address;
7141
- exports.AdyenCardService = AdyenCardService;
7142
- exports.AdyenPaymentMethodFactory = AdyenPaymentMethodFactory;
7143
- exports.AntifraudBankSlipService = AntifraudBankSlipService;
7144
- exports.AntifraudCardService = AntifraudCardService;
7145
- exports.AntifraudGlampointsService = AntifraudGlampointsService;
7146
- exports.AntifraudPixService = AntifraudPixService;
7147
- exports.AntifraudProviderFactory = AntifraudProviderFactory;
7148
6520
  exports.Authentication = Authentication;
7149
6521
  exports.AuthenticationFirebaseAuthService = AuthenticationFirebaseAuthService;
7150
6522
  exports.AxiosAdapter = AxiosAdapter;
@@ -7152,7 +6524,6 @@ exports.Base = Base;
7152
6524
  exports.BaseModel = BaseModel;
7153
6525
  exports.BeautyProfile = BeautyProfile;
7154
6526
  exports.BeautyQuestionsHelper = BeautyQuestionsHelper;
7155
- exports.BusinessError = BusinessError;
7156
6527
  exports.Buy2Win = Buy2Win;
7157
6528
  exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
7158
6529
  exports.Campaign = Campaign;
@@ -7190,9 +6561,6 @@ exports.FilterHasuraGraphQLRepository = FilterHasuraGraphQLRepository;
7190
6561
  exports.FilterOption = FilterOption;
7191
6562
  exports.FilterOptionHasuraGraphQLRepository = FilterOptionHasuraGraphQLRepository;
7192
6563
  exports.FirebaseFileUploaderService = FirebaseFileUploaderService;
7193
- exports.FraudValidationError = FraudValidationError;
7194
- exports.GlampointsPaymentMethodFactory = GlampointsPaymentMethodFactory;
7195
- exports.GlampointsPaymentService = GlampointsPaymentService;
7196
6564
  exports.Home = Home;
7197
6565
  exports.HomeFirestoreRepository = HomeFirestoreRepository;
7198
6566
  exports.InvalidArgumentError = InvalidArgumentError;
@@ -7209,15 +6577,8 @@ exports.Order = Order;
7209
6577
  exports.OrderBlocked = OrderBlocked;
7210
6578
  exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
7211
6579
  exports.OrderFirestoreRepository = OrderFirestoreRepository;
7212
- exports.PagarmeBankSlipService = PagarmeBankSlipService;
7213
- exports.PagarmeCardService = PagarmeCardService;
7214
- exports.PagarmePaymentMethodFactory = PagarmePaymentMethodFactory;
7215
- exports.PagarmePixService = PagarmePixService;
7216
6580
  exports.Payment = Payment;
7217
- exports.PaymentError = PaymentError;
7218
6581
  exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
7219
- exports.PaymentProviderFactory = PaymentProviderFactory;
7220
- exports.PaymentTransaction = PaymentTransaction;
7221
6582
  exports.Product = Product;
7222
6583
  exports.ProductFirestoreRepository = ProductFirestoreRepository;
7223
6584
  exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
@@ -7234,16 +6595,12 @@ exports.Register = Register;
7234
6595
  exports.RegisterFirebaseAuthService = RegisterFirebaseAuthService;
7235
6596
  exports.RequiredArgumentError = RequiredArgumentError;
7236
6597
  exports.RoundProductPricesHelper = RoundProductPricesHelper;
7237
- exports.Sequence = Sequence;
7238
- exports.SequenceFirestoreRepository = SequenceFirestoreRepository;
7239
6598
  exports.ShippingMethod = ShippingMethod;
7240
6599
  exports.ShopMenu = ShopMenu;
7241
6600
  exports.ShopMenuFirestoreRepository = ShopMenuFirestoreRepository;
7242
6601
  exports.ShopSettings = ShopSettings;
7243
6602
  exports.ShopSettingsFirestoreRepository = ShopSettingsFirestoreRepository;
7244
6603
  exports.SignOut = SignOut;
7245
- exports.StockLimitError = StockLimitError;
7246
- exports.StockOutError = StockOutError;
7247
6604
  exports.Subscription = Subscription;
7248
6605
  exports.SubscriptionEditionFirestoreRepository = SubscriptionEditionFirestoreRepository;
7249
6606
  exports.SubscriptionFirestoreRepository = SubscriptionFirestoreRepository;