@infrab4a/connect 4.12.0-beta.0 → 4.12.0-beta.1

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.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import 'reflect-metadata';
2
2
  import { __decorate, __metadata, __values, __spreadArray, __read, __extends, __rest } from 'tslib';
3
3
  import { plainToInstance, instanceToPlain, Type, Expose } from 'class-transformer';
4
- import { parseISO, format, startOfDay, endOfDay, subDays, addDays } from 'date-fns';
5
- export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
4
+ import { parseISO } from 'date-fns';
5
+ export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
6
6
  import { isNil, isArray, first, last, flatten, compact, get, isString, each, unset, isObject, set, isNumber, chunk, isEmpty, isDate, isBoolean, isInteger, isNaN as isNaN$1, sortBy, omit } from 'lodash';
7
7
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
8
8
  import { debug } from 'debug';
@@ -13,65 +13,6 @@ import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc
13
13
  import { ref, uploadBytes } from 'firebase/storage';
14
14
  import { mutation, query as query$1 } from 'gql-query-builder';
15
15
 
16
- var AntifraudProviders;
17
- (function (AntifraudProviders) {
18
- AntifraudProviders["BANKSLIP"] = "bankSlip";
19
- AntifraudProviders["CARD"] = "card";
20
- AntifraudProviders["PIX"] = "pix";
21
- AntifraudProviders["POINTS"] = "glampoints";
22
- })(AntifraudProviders || (AntifraudProviders = {}));
23
-
24
- var PaymentMethods;
25
- (function (PaymentMethods) {
26
- PaymentMethods["CARD"] = "card";
27
- PaymentMethods["BANKSLIP"] = "bankSlip";
28
- PaymentMethods["PIX"] = "pix";
29
- PaymentMethods["POINTS"] = "glampoints";
30
- })(PaymentMethods || (PaymentMethods = {}));
31
-
32
- var PaymentProviders;
33
- (function (PaymentProviders) {
34
- PaymentProviders["PAGARME"] = "pagarMe";
35
- PaymentProviders["ADYEN"] = "adyen";
36
- PaymentProviders["GLAMPOINTS"] = "glampoints";
37
- })(PaymentProviders || (PaymentProviders = {}));
38
-
39
- class BasePaymentMethodFactory {
40
- constructor(methods) {
41
- this.methods = methods;
42
- }
43
- build(method) {
44
- return this.methods[method];
45
- }
46
- }
47
-
48
- class AdyenPaymentMethodFactory extends BasePaymentMethodFactory {
49
- }
50
-
51
- class AntifraudProviderFactory {
52
- constructor(antifraudProviders) {
53
- this.antifraudProviders = antifraudProviders;
54
- }
55
- build(provider) {
56
- return this.antifraudProviders[provider];
57
- }
58
- }
59
-
60
- class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
61
- }
62
-
63
- class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
64
- }
65
-
66
- class PaymentProviderFactory {
67
- constructor(paymentProviders) {
68
- this.paymentProviders = paymentProviders;
69
- }
70
- build(provider) {
71
- return this.paymentProviders[provider];
72
- }
73
- }
74
-
75
16
  class BaseModel {
76
17
  get identifier() {
77
18
  const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
@@ -609,182 +550,175 @@ var Status;
609
550
  Status["CANCELLED"] = "Cancelado";
610
551
  })(Status || (Status = {}));
611
552
 
612
- class PaymentTransaction extends BaseModel {
553
+ class Payment extends BaseModel {
554
+ static get identifiersFields() {
555
+ return ['id'];
556
+ }
613
557
  }
614
558
  __decorate([
615
559
  Expose({ name: 'refuse_reason' }),
616
560
  __metadata("design:type", String)
617
- ], PaymentTransaction.prototype, "refuseReason", void 0);
561
+ ], Payment.prototype, "refuseReason", void 0);
618
562
  __decorate([
619
563
  Expose({ name: 'status_reason' }),
620
564
  __metadata("design:type", String)
621
- ], PaymentTransaction.prototype, "statusReason", void 0);
565
+ ], Payment.prototype, "statusReason", void 0);
622
566
  __decorate([
623
567
  Expose({ name: 'acquirer_response_code' }),
624
568
  __metadata("design:type", String)
625
- ], PaymentTransaction.prototype, "acquirerResponseCode", void 0);
569
+ ], Payment.prototype, "acquirerResponseCode", void 0);
626
570
  __decorate([
627
571
  Expose({ name: 'acquirer_name' }),
628
572
  __metadata("design:type", String)
629
- ], PaymentTransaction.prototype, "acquirerName", void 0);
573
+ ], Payment.prototype, "acquirerName", void 0);
630
574
  __decorate([
631
575
  Expose({ name: 'acquirer_id' }),
632
576
  __metadata("design:type", String)
633
- ], PaymentTransaction.prototype, "acquirerId", void 0);
577
+ ], Payment.prototype, "acquirerId", void 0);
634
578
  __decorate([
635
579
  Expose({ name: 'authorization_code' }),
636
580
  __metadata("design:type", String)
637
- ], PaymentTransaction.prototype, "authorizationCode", void 0);
581
+ ], Payment.prototype, "authorizationCode", void 0);
638
582
  __decorate([
639
583
  Expose({ name: 'soft_descriptor' }),
640
584
  __metadata("design:type", String)
641
- ], PaymentTransaction.prototype, "softDescriptor", void 0);
585
+ ], Payment.prototype, "softDescriptor", void 0);
642
586
  __decorate([
643
587
  Expose({ name: 'date_created' }),
644
588
  __metadata("design:type", String)
645
- ], PaymentTransaction.prototype, "dateCreated", void 0);
589
+ ], Payment.prototype, "dateCreated", void 0);
646
590
  __decorate([
647
591
  Expose({ name: 'date_updated' }),
648
592
  __metadata("design:type", String)
649
- ], PaymentTransaction.prototype, "dateUpdated", void 0);
593
+ ], Payment.prototype, "dateUpdated", void 0);
650
594
  __decorate([
651
595
  Expose({ name: 'authorized_amount' }),
652
596
  __metadata("design:type", Number)
653
- ], PaymentTransaction.prototype, "authorizedAmount", void 0);
597
+ ], Payment.prototype, "authorizedAmount", void 0);
654
598
  __decorate([
655
599
  Expose({ name: 'paid_amount' }),
656
600
  __metadata("design:type", Number)
657
- ], PaymentTransaction.prototype, "paidAmount", void 0);
601
+ ], Payment.prototype, "paidAmount", void 0);
658
602
  __decorate([
659
603
  Expose({ name: 'paid_at' }),
660
604
  __metadata("design:type", String)
661
- ], PaymentTransaction.prototype, "paidAt", void 0);
605
+ ], Payment.prototype, "paidAt", void 0);
662
606
  __decorate([
663
607
  Expose({ name: 'refunded_amount' }),
664
608
  __metadata("design:type", Number)
665
- ], PaymentTransaction.prototype, "refundedAmount", void 0);
609
+ ], Payment.prototype, "refundedAmount", void 0);
666
610
  __decorate([
667
611
  Expose({ name: 'card_holder_name' }),
668
612
  __metadata("design:type", String)
669
- ], PaymentTransaction.prototype, "cardHolderName", void 0);
613
+ ], Payment.prototype, "cardHolderName", void 0);
670
614
  __decorate([
671
615
  Expose({ name: 'card_last_digits' }),
672
616
  __metadata("design:type", String)
673
- ], PaymentTransaction.prototype, "cardLastDigits", void 0);
617
+ ], Payment.prototype, "cardLastDigits", void 0);
674
618
  __decorate([
675
619
  Expose({ name: 'card_first_digits' }),
676
620
  __metadata("design:type", String)
677
- ], PaymentTransaction.prototype, "cardFirstDigits", void 0);
621
+ ], Payment.prototype, "cardFirstDigits", void 0);
678
622
  __decorate([
679
623
  Expose({ name: 'card_brand' }),
680
624
  __metadata("design:type", String)
681
- ], PaymentTransaction.prototype, "cardBrand", void 0);
625
+ ], Payment.prototype, "cardBrand", void 0);
682
626
  __decorate([
683
627
  Expose({ name: 'card_pin_mode' }),
684
628
  __metadata("design:type", String)
685
- ], PaymentTransaction.prototype, "cardPinMode", void 0);
629
+ ], Payment.prototype, "cardPinMode", void 0);
686
630
  __decorate([
687
631
  Expose({ name: 'card_magstripe_fallback' }),
688
632
  __metadata("design:type", Boolean)
689
- ], PaymentTransaction.prototype, "cardMagstripeFallback", void 0);
633
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
690
634
  __decorate([
691
635
  Expose({ name: 'cvm_pin' }),
692
636
  __metadata("design:type", Boolean)
693
- ], PaymentTransaction.prototype, "cvmPin", void 0);
637
+ ], Payment.prototype, "cvmPin", void 0);
694
638
  __decorate([
695
639
  Expose({ name: 'postback_url' }),
696
640
  __metadata("design:type", String)
697
- ], PaymentTransaction.prototype, "postbackUrl", void 0);
641
+ ], Payment.prototype, "postbackUrl", void 0);
698
642
  __decorate([
699
643
  Expose({ name: 'payment_method' }),
700
644
  __metadata("design:type", String)
701
- ], PaymentTransaction.prototype, "paymentMethod", void 0);
645
+ ], Payment.prototype, "paymentMethod", void 0);
702
646
  __decorate([
703
647
  Expose({ name: 'capture_method' }),
704
648
  __metadata("design:type", String)
705
- ], PaymentTransaction.prototype, "captureMethod", void 0);
649
+ ], Payment.prototype, "captureMethod", void 0);
706
650
  __decorate([
707
651
  Expose({ name: 'antifraud_score' }),
708
652
  __metadata("design:type", String)
709
- ], PaymentTransaction.prototype, "antifraudScore", void 0);
653
+ ], Payment.prototype, "antifraudScore", void 0);
710
654
  __decorate([
711
655
  Expose({ name: 'boleto_url' }),
712
656
  __metadata("design:type", String)
713
- ], PaymentTransaction.prototype, "boletoUrl", void 0);
657
+ ], Payment.prototype, "boletoUrl", void 0);
714
658
  __decorate([
715
659
  Expose({ name: 'boleto_barcode' }),
716
660
  __metadata("design:type", String)
717
- ], PaymentTransaction.prototype, "boletoBarcode", void 0);
661
+ ], Payment.prototype, "boletoBarcode", void 0);
718
662
  __decorate([
719
663
  Expose({ name: 'boleto_expiration_date' }),
720
664
  __metadata("design:type", String)
721
- ], PaymentTransaction.prototype, "boletoExpirationDate", void 0);
665
+ ], Payment.prototype, "boletoExpirationDate", void 0);
722
666
  __decorate([
723
667
  Expose({ name: 'subscription_id' }),
724
668
  __metadata("design:type", String)
725
- ], PaymentTransaction.prototype, "subscriptionId", void 0);
669
+ ], Payment.prototype, "subscriptionId", void 0);
726
670
  __decorate([
727
671
  Expose({ name: 'split_rules' }),
728
672
  __metadata("design:type", String)
729
- ], PaymentTransaction.prototype, "splitRules", void 0);
673
+ ], Payment.prototype, "splitRules", void 0);
730
674
  __decorate([
731
675
  Expose({ name: 'antifraud_metadata' }),
732
676
  __metadata("design:type", Object)
733
- ], PaymentTransaction.prototype, "antifraudMetadata", void 0);
677
+ ], Payment.prototype, "antifraudMetadata", void 0);
734
678
  __decorate([
735
679
  Expose({ name: 'reference_key' }),
736
680
  __metadata("design:type", String)
737
- ], PaymentTransaction.prototype, "referenceKey", void 0);
681
+ ], Payment.prototype, "referenceKey", void 0);
738
682
  __decorate([
739
683
  Expose({ name: 'local_transaction_id' }),
740
684
  __metadata("design:type", String)
741
- ], PaymentTransaction.prototype, "localTransactionId", void 0);
685
+ ], Payment.prototype, "localTransactionId", void 0);
742
686
  __decorate([
743
687
  Expose({ name: 'local_time' }),
744
688
  __metadata("design:type", String)
745
- ], PaymentTransaction.prototype, "localTime", void 0);
689
+ ], Payment.prototype, "localTime", void 0);
746
690
  __decorate([
747
691
  Expose({ name: 'fraud_covered' }),
748
692
  __metadata("design:type", Boolean)
749
- ], PaymentTransaction.prototype, "fraudCovered", void 0);
693
+ ], Payment.prototype, "fraudCovered", void 0);
750
694
  __decorate([
751
695
  Expose({ name: 'fraud_reimbursed' }),
752
696
  __metadata("design:type", String)
753
- ], PaymentTransaction.prototype, "fraudReimbursed", void 0);
697
+ ], Payment.prototype, "fraudReimbursed", void 0);
754
698
  __decorate([
755
699
  Expose({ name: 'order_id' }),
756
700
  __metadata("design:type", String)
757
- ], PaymentTransaction.prototype, "orderId", void 0);
701
+ ], Payment.prototype, "orderId", void 0);
758
702
  __decorate([
759
703
  Expose({ name: 'risk_level' }),
760
704
  __metadata("design:type", String)
761
- ], PaymentTransaction.prototype, "riskLevel", void 0);
705
+ ], Payment.prototype, "riskLevel", void 0);
762
706
  __decorate([
763
707
  Expose({ name: 'receipt_url' }),
764
708
  __metadata("design:type", String)
765
- ], PaymentTransaction.prototype, "receiptUrl", void 0);
709
+ ], Payment.prototype, "receiptUrl", void 0);
766
710
  __decorate([
767
711
  Expose({ name: 'private_label' }),
768
712
  __metadata("design:type", String)
769
- ], PaymentTransaction.prototype, "privateLabel", void 0);
713
+ ], Payment.prototype, "privateLabel", void 0);
770
714
  __decorate([
771
715
  Expose({ name: 'pix_qr_code' }),
772
716
  __metadata("design:type", String)
773
- ], PaymentTransaction.prototype, "pixQrCode", void 0);
717
+ ], Payment.prototype, "pixQrCode", void 0);
774
718
  __decorate([
775
719
  Expose({ name: 'pix_expiration_date' }),
776
720
  __metadata("design:type", String)
777
- ], PaymentTransaction.prototype, "pixExpirationDate", void 0);
778
-
779
- class Payment extends BaseModel {
780
- static get identifiersFields() {
781
- return ['id'];
782
- }
783
- }
784
- __decorate([
785
- Type(() => PaymentTransaction),
786
- __metadata("design:type", PaymentTransaction)
787
- ], Payment.prototype, "transaction", void 0);
721
+ ], Payment.prototype, "pixExpirationDate", void 0);
788
722
 
789
723
  class SubscriptionPayment extends BaseModel {
790
724
  static get identifiersFields() {
@@ -2257,8 +2191,8 @@ var OrderStatus;
2257
2191
  class Order extends Checkout {
2258
2192
  }
2259
2193
  __decorate([
2260
- Type(() => PaymentTransaction),
2261
- __metadata("design:type", PaymentTransaction)
2194
+ Type(() => Payment),
2195
+ __metadata("design:type", Payment)
2262
2196
  ], Order.prototype, "payment", void 0);
2263
2197
 
2264
2198
  class OrderBlocked extends BaseModel {
@@ -2289,592 +2223,6 @@ __decorate([
2289
2223
  __metadata("design:type", Coupon)
2290
2224
  ], CheckoutSubscription.prototype, "coupon", void 0);
2291
2225
 
2292
- class BusinessError extends CustomError {
2293
- constructor(message, additionalData, type = '') {
2294
- super(message);
2295
- this.additionalData = additionalData;
2296
- this.type = type;
2297
- }
2298
- }
2299
-
2300
- class DuplicatedResultsError extends CustomError {
2301
- constructor(message) {
2302
- super(message);
2303
- }
2304
- }
2305
-
2306
- class FraudValidationError extends CustomError {
2307
- constructor(message, additionalData) {
2308
- super(message);
2309
- this.additionalData = additionalData;
2310
- this.type = 'antifraud';
2311
- }
2312
- }
2313
-
2314
- class InvalidArgumentError extends CustomError {
2315
- constructor(message) {
2316
- super(message);
2317
- }
2318
- }
2319
-
2320
- class NotFoundError extends CustomError {
2321
- constructor(message) {
2322
- super(message);
2323
- }
2324
- }
2325
-
2326
- class PaymentError extends CustomError {
2327
- constructor(message, additionalData) {
2328
- super(message);
2329
- this.additionalData = additionalData;
2330
- this.type = 'payment';
2331
- }
2332
- }
2333
-
2334
- class RequiredArgumentError extends CustomError {
2335
- constructor(args) {
2336
- super(`Required arguments: ${args.join(', ')}`);
2337
- this.args = args;
2338
- this.arguments = args;
2339
- }
2340
- }
2341
-
2342
- class StockLimitError extends BusinessError {
2343
- constructor(message, additionalData) {
2344
- super(message, additionalData);
2345
- this.type = 'stock-limit';
2346
- }
2347
- }
2348
-
2349
- class StockOutError extends BusinessError {
2350
- constructor(message, additionalData) {
2351
- super(message, additionalData);
2352
- this.type = 'stock-out';
2353
- }
2354
- }
2355
-
2356
- class AdyenCardService {
2357
- constructor(credentials, paymentRepository, orderBlockedRepository) {
2358
- this.credentials = credentials;
2359
- this.paymentRepository = paymentRepository;
2360
- this.orderBlockedRepository = orderBlockedRepository;
2361
- }
2362
- async pay(checkout, card) {
2363
- try {
2364
- const result = await axios({
2365
- method: 'POST',
2366
- url: this.credentials.URL_TRANSACTION,
2367
- headers: {
2368
- 'x-api-key': this.credentials.API_KEY,
2369
- 'content-type': 'application/json',
2370
- },
2371
- data: this.createCardPayment(checkout, card),
2372
- });
2373
- if (result.data.resultCode !== 'Authorised') {
2374
- this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2375
- 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`, {
2376
- checkoutId: checkout.id,
2377
- userEmail: checkout.user.email,
2378
- info: result.data,
2379
- }));
2380
- }
2381
- const payment = await this.paymentRepository.create(Payment.toInstance({
2382
- createdAt: new Date(),
2383
- updatedAt: new Date(),
2384
- userId: checkout.user.id,
2385
- checkoutId: checkout.id,
2386
- totalPrice: checkout.totalPrice,
2387
- paymentProvider: 'adyen',
2388
- transaction: Object.assign(Object.assign({}, result.data), { status: 'paid' }),
2389
- }));
2390
- return payment;
2391
- }
2392
- catch (error) {
2393
- 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', {
2394
- checkoutId: checkout.id,
2395
- userEmail: checkout.user.email,
2396
- info: error.message,
2397
- });
2398
- }
2399
- }
2400
- createCardPayment(checkout, card) {
2401
- return {
2402
- amount: {
2403
- currency: 'BRL',
2404
- value: ((checkout === null || checkout === void 0 ? void 0 : checkout.totalPrice) || 0) * 100,
2405
- },
2406
- paymentMethod: {
2407
- type: 'scheme',
2408
- storedPaymentMethodId: card.cardId,
2409
- },
2410
- reference: checkout.id,
2411
- shopperInteraction: 'Ecommerce',
2412
- merchantAccount: this.credentials.MERCHANT_ACCOUNT,
2413
- shopperReference: checkout.user.id,
2414
- recurringProcessingModel: 'CardOnFile',
2415
- returnUrl: this.credentials.URL_POSTBACK,
2416
- installments: {
2417
- value: card.installments,
2418
- },
2419
- };
2420
- }
2421
- addCard() {
2422
- throw new Error('Method not implemented.');
2423
- }
2424
- }
2425
-
2426
- class AntifraudBankSlipService {
2427
- constructor(orderBlockedRepository) {
2428
- this.orderBlockedRepository = orderBlockedRepository;
2429
- this.MAX_ORDER_VALUE = 5000;
2430
- }
2431
- async validate(checkout) {
2432
- var _a, _b;
2433
- if (checkout.totalPrice && checkout.totalPrice > this.MAX_ORDER_VALUE && !((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber)) {
2434
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Boleto not authorized', 'Boleto', 'day');
2435
- throw new FraudValidationError('Boleto não autorizado para cliente não assinante', {
2436
- checkoutId: checkout.id,
2437
- userEmail: checkout.user.email,
2438
- info: {
2439
- isSubscriber: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.isSubscriber,
2440
- subtotal: checkout.subTotalPrice,
2441
- total: checkout.totalPrice,
2442
- },
2443
- });
2444
- }
2445
- return true;
2446
- }
2447
- }
2448
-
2449
- class AntifraudCardService {
2450
- constructor(orderRepository, orderBlockedRepository) {
2451
- this.orderRepository = orderRepository;
2452
- this.orderBlockedRepository = orderBlockedRepository;
2453
- this.LIMIT_ORDERS_DAY = 2;
2454
- this.LIMIT_ORDERS_WEEK = 7;
2455
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
2456
- }
2457
- async validate(checkout, card) {
2458
- var _a, _b;
2459
- if (!(await this.verifyBlockedOrderAttempts(checkout, card)))
2460
- throw new FraudValidationError('Cliente com mais de 5 compras negadas/bloqueadas no dia', {
2461
- checkoutId: checkout.id,
2462
- userEmail: checkout.user.email,
2463
- info: {
2464
- isSubscriber: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber,
2465
- subtotal: checkout.subTotalPrice,
2466
- total: checkout.totalPrice,
2467
- },
2468
- });
2469
- if (!(await this.verifyDayAndWeekOrders(checkout, card)))
2470
- throw new FraudValidationError('Cliente tentando comprar mais de 2 vezes no dia ou 7 vezes na semana', {
2471
- checkoutId: checkout.id,
2472
- userEmail: checkout.user.email,
2473
- info: {
2474
- isSubscriber: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.isSubscriber,
2475
- subtotal: checkout.subTotalPrice,
2476
- total: checkout.totalPrice,
2477
- },
2478
- });
2479
- return true;
2480
- }
2481
- async verifyBlockedOrderAttempts(checkout, card) {
2482
- var _a, _b, _c, _d;
2483
- const day = `${format(new Date(), 'YYYY-MM-DD')}T00:00:00`;
2484
- const endOfDay = `${format(new Date(), 'YYYY-MM-DD')}T23:59:59`;
2485
- const ordersBlockedWithCpf = await this.orderBlockedRepository
2486
- .find({
2487
- filters: {
2488
- customer: { cpf: { operator: Where.EQUALS, value: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf } },
2489
- date: [
2490
- { operator: Where.GTE, value: new Date(day) },
2491
- { operator: Where.LTE, value: new Date(endOfDay) },
2492
- ],
2493
- },
2494
- })
2495
- .then((data) => data.data);
2496
- const ordersBlockedWithEmail = await this.orderBlockedRepository
2497
- .find({
2498
- filters: {
2499
- customer: { email: { operator: Where.EQUALS, value: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email } },
2500
- date: [
2501
- { operator: Where.GTE, value: new Date(day) },
2502
- { operator: Where.LTE, value: new Date(endOfDay) },
2503
- ],
2504
- },
2505
- })
2506
- .then((data) => data.data);
2507
- const ordersBlockedWithCep = await this.orderBlockedRepository
2508
- .find({
2509
- filters: {
2510
- customer: { shippingAddress: { zip: { operator: Where.EQUALS, value: (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip } } },
2511
- date: [
2512
- { operator: Where.GTE, value: new Date(day) },
2513
- { operator: Where.LTE, value: new Date(endOfDay) },
2514
- ],
2515
- },
2516
- })
2517
- .then((data) => data.data);
2518
- const ordersBlockedWithPhone = await this.orderBlockedRepository
2519
- .find({
2520
- filters: {
2521
- customer: { phoneNumber: { operator: Where.EQUALS, value: (_d = checkout.user) === null || _d === void 0 ? void 0 : _d.phone } },
2522
- date: [
2523
- { operator: Where.GTE, value: new Date(day) },
2524
- { operator: Where.LTE, value: new Date(endOfDay) },
2525
- ],
2526
- },
2527
- })
2528
- .then((data) => data.data);
2529
- const blockedUniqueEmails = ordersBlockedWithEmail.filter((e) => {
2530
- var _a;
2531
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf);
2532
- });
2533
- const blockedUniqueCeps = ordersBlockedWithCep.filter((e) => {
2534
- var _a, _b;
2535
- 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);
2536
- });
2537
- const blockedUniquePhone = ordersBlockedWithPhone.filter((e) => {
2538
- var _a, _b, _c, _d, _e, _f;
2539
- return (e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) &&
2540
- e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email) &&
2541
- ((_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()));
2542
- });
2543
- const blockedAttempts = ordersBlockedWithCpf
2544
- .concat(blockedUniqueEmails)
2545
- .concat(blockedUniqueCeps)
2546
- .concat(blockedUniquePhone);
2547
- if (blockedAttempts.length >= this.LIMIT_BLOCKED_ORDERS_DAY) {
2548
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'More than 5 attempts have failed', 'Failed attempts', 'day', card || null);
2549
- return false;
2550
- }
2551
- return true;
2552
- }
2553
- async verifyDayAndWeekOrders(checkout, card) {
2554
- var _a, _b, _c, _d, _e, _f, _g, _h;
2555
- 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'));
2556
- for (const key in ordersPerDay) {
2557
- if (ordersPerDay[key] > this.LIMIT_ORDERS_DAY) {
2558
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'day');
2559
- return false;
2560
- }
2561
- }
2562
- 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'));
2563
- for (const key in ordersPerWeek) {
2564
- if (ordersPerDay[key] > this.LIMIT_ORDERS_WEEK) {
2565
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'week');
2566
- return false;
2567
- }
2568
- }
2569
- return true;
2570
- }
2571
- async validateOrdersByRange(cpf, email, phone, zip, card, range) {
2572
- const ordersCpf = await this.countOrdersByField('user', 'cpf', cpf, range);
2573
- const ordersByEmail = await this.countOrdersByField('user', 'email', email, range);
2574
- const ordersByPhone = await this.countOrdersByField('user', 'phone', phone, range);
2575
- const ordersByZip = await this.countOrdersByField('shippingAddress', 'zip', zip, range);
2576
- return {
2577
- cpf: ordersCpf,
2578
- email: ordersByEmail,
2579
- phone: ordersByPhone,
2580
- zip: ordersByZip,
2581
- };
2582
- }
2583
- async countOrdersByField(property, field, value, range) {
2584
- const filters = {
2585
- [property]: {
2586
- [field]: value,
2587
- },
2588
- ['createdAt']: [
2589
- { operator: Where.GTE, value: range.firstDate },
2590
- { operator: Where.LTE, value: range.lastDate },
2591
- ],
2592
- };
2593
- const docs = await (await this.orderRepository.find({ filters })).count;
2594
- return docs;
2595
- }
2596
- getDateRange(range = 'day') {
2597
- switch (range) {
2598
- case 'day':
2599
- return {
2600
- firstDate: startOfDay(new Date()).getTime(),
2601
- lastDate: endOfDay(new Date()).getTime(),
2602
- };
2603
- case 'week':
2604
- return {
2605
- firstDate: startOfDay(subDays(new Date(), 7)).getTime(),
2606
- lastDate: endOfDay(new Date()).getTime(),
2607
- };
2608
- default:
2609
- return {
2610
- firstDate: startOfDay(new Date()).getTime(),
2611
- lastDate: endOfDay(new Date()).getTime(),
2612
- };
2613
- }
2614
- }
2615
- }
2616
-
2617
- class AntifraudGlampointsService {
2618
- constructor() { }
2619
- async validate(checkout) {
2620
- return true;
2621
- }
2622
- }
2623
-
2624
- class AntifraudPixService {
2625
- constructor() { }
2626
- async validate(checkout) {
2627
- return true;
2628
- }
2629
- }
2630
-
2631
- class GlampointsPaymentService {
2632
- constructor(paymentRepository) {
2633
- this.paymentRepository = paymentRepository;
2634
- }
2635
- async pay(checkout) {
2636
- const payment = await this.paymentRepository.create(Payment.toInstance({
2637
- createdAt: new Date(),
2638
- updatedAt: new Date(),
2639
- userId: checkout.user.id,
2640
- checkoutId: checkout.id,
2641
- totalPrice: checkout.totalPrice,
2642
- paymentProvider: 'glampoints',
2643
- transaction: {
2644
- amount: 0,
2645
- acquirerResponseCode: '0000',
2646
- acquirerName: 'glampoints',
2647
- authorizedAmount: 0,
2648
- captureMethod: 'ecommerce',
2649
- installments: 1,
2650
- cost: 0,
2651
- paidAmount: 0,
2652
- paidAt: new Date().toISOString(),
2653
- paymentMethod: 'glampoints',
2654
- referer: 'api_key',
2655
- refundedAmount: 0,
2656
- status: 'paid',
2657
- statusReason: 'acquirer',
2658
- },
2659
- }));
2660
- return payment;
2661
- }
2662
- }
2663
-
2664
- class PagarmeBankSlipService {
2665
- constructor(credentials, paymentRepository) {
2666
- this.credentials = credentials;
2667
- this.paymentRepository = paymentRepository;
2668
- }
2669
- async pay(checkout) {
2670
- try {
2671
- const result = await axios({
2672
- method: 'POST',
2673
- url: this.credentials.URL_TRANSACTION,
2674
- data: this.createBoletoPayment(checkout),
2675
- });
2676
- if (result.data.status !== 'processing') {
2677
- return Promise.reject(new PaymentError(`Houve uma falha ao gerar o boleto. Tente novamente`, {
2678
- checkoutId: checkout.id,
2679
- userEmail: checkout.user.email,
2680
- info: result.data,
2681
- }));
2682
- }
2683
- const payment = await this.paymentRepository.create(Payment.toInstance({
2684
- createdAt: new Date(),
2685
- updatedAt: new Date(),
2686
- userId: checkout.user.id,
2687
- checkoutId: checkout.id,
2688
- totalPrice: checkout.totalPrice,
2689
- paymentProvider: 'pagarMe',
2690
- transaction: result.data,
2691
- }));
2692
- return payment;
2693
- }
2694
- catch (error) {
2695
- throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
2696
- checkoutId: checkout.id,
2697
- userEmail: checkout.user.email,
2698
- info: error.response.data,
2699
- });
2700
- }
2701
- }
2702
- createBoletoPayment(checkout) {
2703
- return {
2704
- api_key: this.credentials.API_KEY,
2705
- amount: Math.floor(checkout.totalPrice * 100),
2706
- boleto_rules: ['strict_expiration_date'],
2707
- boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
2708
- boleto_expiration_date: format(addDays(new Date(), 3), 'yyyy-MM-dd'),
2709
- payment_method: 'boleto',
2710
- postback_url: this.credentials.URL_POSTBACK,
2711
- customer: {
2712
- external_id: checkout.user.id,
2713
- type: 'individual',
2714
- country: 'br',
2715
- name: checkout.user.displayName,
2716
- documents: [
2717
- {
2718
- type: 'cpf',
2719
- number: checkout.user.cpf,
2720
- },
2721
- ],
2722
- },
2723
- };
2724
- }
2725
- }
2726
-
2727
- class PagarmeCardService {
2728
- constructor(credentials, paymentRepository, orderBlockedRepository) {
2729
- this.credentials = credentials;
2730
- this.paymentRepository = paymentRepository;
2731
- this.orderBlockedRepository = orderBlockedRepository;
2732
- }
2733
- async pay(checkout, card) {
2734
- var _a;
2735
- try {
2736
- const result = await axios({
2737
- method: 'POST',
2738
- url: this.credentials.URL_TRANSACTION,
2739
- data: this.createCardPayment(checkout, card),
2740
- });
2741
- if (result.data.status !== 'paid') {
2742
- await this.orderBlockedRepository.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2743
- 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`, {
2744
- checkoutId: checkout.id,
2745
- userEmail: checkout.user.email,
2746
- info: result.data,
2747
- }));
2748
- }
2749
- const payment = await this.paymentRepository.create(Payment.toInstance({
2750
- createdAt: new Date(),
2751
- updatedAt: new Date(),
2752
- userId: checkout.user.id,
2753
- checkoutId: checkout.id,
2754
- totalPrice: checkout.totalPrice,
2755
- paymentProvider: PaymentProviders.PAGARME,
2756
- transaction: Object.assign(Object.assign({}, result.data), { paidAt: new Date() }),
2757
- }));
2758
- return payment;
2759
- }
2760
- catch (error) {
2761
- 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', {
2762
- checkoutId: checkout.id,
2763
- userEmail: checkout.user.email,
2764
- info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
2765
- });
2766
- }
2767
- }
2768
- addCard() {
2769
- throw new Error('Method not implemented.');
2770
- }
2771
- createCardPayment(checkout, card) {
2772
- var _a, _b, _c, _d, _e, _f;
2773
- return {
2774
- api_key: this.credentials.API_KEY,
2775
- amount: Math.floor(checkout.totalPrice * 100),
2776
- card_id: card.cardId,
2777
- payment_method: 'credit_card',
2778
- installments: card.installments,
2779
- soft_descriptor: checkout.shop,
2780
- customer: {
2781
- external_id: checkout.user.id,
2782
- name: checkout.user.displayName,
2783
- type: 'individual',
2784
- country: 'br',
2785
- email: checkout.user.email,
2786
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2787
- documents: [
2788
- {
2789
- type: 'cpf',
2790
- number: checkout.user.cpf,
2791
- },
2792
- ],
2793
- },
2794
- billing: {
2795
- name: checkout.user.displayName,
2796
- address: {
2797
- country: 'br',
2798
- state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
2799
- city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
2800
- neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
2801
- street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
2802
- street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
2803
- zipcode: checkout.billingAddress
2804
- ? checkout.billingAddress.zip.replace('-', '')
2805
- : (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
2806
- },
2807
- },
2808
- items: checkout.lineItems.map((item) => {
2809
- return {
2810
- id: item.id,
2811
- title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
2812
- unit_price: Math.floor(item.pricePaid * 100),
2813
- quantity: item.quantity,
2814
- tangible: true,
2815
- };
2816
- }),
2817
- };
2818
- }
2819
- }
2820
-
2821
- class PagarmePixService {
2822
- constructor(credentials, paymentRepository) {
2823
- this.credentials = credentials;
2824
- this.paymentRepository = paymentRepository;
2825
- }
2826
- async pay(checkout) {
2827
- var _a;
2828
- try {
2829
- const result = await axios({
2830
- method: 'POST',
2831
- url: this.credentials.URL_TRANSACTION,
2832
- data: this.createPixPayment(checkout),
2833
- });
2834
- const payment = await this.paymentRepository.create(Payment.toInstance({
2835
- createdAt: new Date(),
2836
- updatedAt: new Date(),
2837
- userId: checkout.user.id,
2838
- checkoutId: checkout.id,
2839
- totalPrice: checkout.totalPrice,
2840
- paymentProvider: 'pagarMe',
2841
- transaction: Object.assign(Object.assign({}, result.data), { paidAt: new Date() }),
2842
- }));
2843
- return payment;
2844
- }
2845
- catch (error) {
2846
- throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
2847
- checkoutId: checkout.id,
2848
- userEmail: checkout.user.email,
2849
- info: (_a = error.response) === null || _a === void 0 ? void 0 : _a.data,
2850
- });
2851
- }
2852
- }
2853
- createPixPayment(checkout) {
2854
- return {
2855
- payment_method: 'pix',
2856
- amount: Math.floor(checkout.totalPrice * 100),
2857
- api_key: this.credentials.API_KEY,
2858
- postback_url: this.credentials.URL_POSTBACK,
2859
- pix_expiration_date: format(addDays(new Date(), 1), 'yyyy-MM-dd'),
2860
- customer: {
2861
- external_id: checkout.user.id,
2862
- type: 'individual',
2863
- country: 'br',
2864
- name: checkout.user.displayName,
2865
- email: checkout.user.email.trim(),
2866
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2867
- documents: [
2868
- {
2869
- type: 'cpf',
2870
- number: checkout.user.cpf,
2871
- },
2872
- ],
2873
- },
2874
- };
2875
- }
2876
- }
2877
-
2878
2226
  class RoundProductPricesHelper {
2879
2227
  static roundProductPrices(product) {
2880
2228
  product.price.price = Number(product.price.price.toFixed(2));
@@ -2889,12 +2237,6 @@ class RoundProductPricesHelper {
2889
2237
  }
2890
2238
  }
2891
2239
 
2892
- class Sequence extends BaseModel {
2893
- static get identifiersFields() {
2894
- return ['id'];
2895
- }
2896
- }
2897
-
2898
2240
  var FilterType;
2899
2241
  (function (FilterType) {
2900
2242
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -3033,12 +2375,38 @@ class ShopSettings extends BaseModel {
3033
2375
  }
3034
2376
  }
3035
2377
 
3036
- class AxiosAdapter {
3037
- constructor(config) {
3038
- this.config = config;
3039
- this.logger = DebugHelper.from(this);
2378
+ class InvalidArgumentError extends CustomError {
2379
+ constructor(message) {
2380
+ super(message);
3040
2381
  }
3041
- async get(index, id) {
2382
+ }
2383
+
2384
+ class RequiredArgumentError extends CustomError {
2385
+ constructor(args) {
2386
+ super(`Required arguments: ${args.join(', ')}`);
2387
+ this.args = args;
2388
+ this.arguments = args;
2389
+ }
2390
+ }
2391
+
2392
+ class NotFoundError extends CustomError {
2393
+ constructor(message) {
2394
+ super(message);
2395
+ }
2396
+ }
2397
+
2398
+ class DuplicatedResultsError extends CustomError {
2399
+ constructor(message) {
2400
+ super(message);
2401
+ }
2402
+ }
2403
+
2404
+ class AxiosAdapter {
2405
+ constructor(config) {
2406
+ this.config = config;
2407
+ this.logger = DebugHelper.from(this);
2408
+ }
2409
+ async get(index, id) {
3042
2410
  const logger = this.logger.with('get');
3043
2411
  const req = {
3044
2412
  url: `${this.config.url}/${index}/_doc/${id}`,
@@ -3167,8 +2535,6 @@ class ProductsIndex {
3167
2535
  'rate',
3168
2536
  ];
3169
2537
  const filter = [{ term: { published: true } }];
3170
- if (shop && shop !== Shops.ALL)
3171
- filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
3172
2538
  if (size > 9)
3173
2539
  fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
3174
2540
  const query = {
@@ -3736,6 +3102,180 @@ const withCrudFirestore = (MixinBase) => {
3736
3102
  };
3737
3103
  };
3738
3104
 
3105
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3106
+ constructor({ firestore, interceptors }) {
3107
+ super({
3108
+ firestore,
3109
+ collectionName: 'leads',
3110
+ model: Lead,
3111
+ interceptors,
3112
+ });
3113
+ }
3114
+ }
3115
+
3116
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3117
+ constructor({ firestore, interceptors }, parentRepository) {
3118
+ super({
3119
+ firestore,
3120
+ collectionName: 'editions',
3121
+ parentIdField: 'subscriptionId',
3122
+ model: Edition,
3123
+ interceptors,
3124
+ });
3125
+ this.parentRepository = parentRepository;
3126
+ }
3127
+ }
3128
+
3129
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3130
+ constructor({ firestore, interceptors, }) {
3131
+ super({
3132
+ firestore,
3133
+ collectionName: 'subscription',
3134
+ model: Subscription,
3135
+ interceptors,
3136
+ });
3137
+ }
3138
+ }
3139
+
3140
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3141
+ constructor({ firestore, interceptors }) {
3142
+ super({
3143
+ firestore,
3144
+ collectionName: 'subscriptionMaterialization',
3145
+ model: SubscriptionMaterialization,
3146
+ interceptors,
3147
+ });
3148
+ }
3149
+ }
3150
+
3151
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3152
+ constructor({ firestore, interceptors }, parentRepository) {
3153
+ super({
3154
+ firestore,
3155
+ collectionName: 'payments',
3156
+ parentIdField: 'subscriptionId',
3157
+ model: SubscriptionPayment,
3158
+ interceptors,
3159
+ });
3160
+ this.parentRepository = parentRepository;
3161
+ }
3162
+ }
3163
+
3164
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3165
+ constructor({ firestore, interceptors, }) {
3166
+ super({
3167
+ firestore,
3168
+ collectionName: 'subscriptionSummary',
3169
+ model: SubscriptionSummary,
3170
+ interceptors,
3171
+ });
3172
+ }
3173
+ }
3174
+
3175
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3176
+ constructor({ firestore, interceptors }, parentRepository) {
3177
+ super({
3178
+ firestore,
3179
+ collectionName: 'address',
3180
+ parentIdField: 'userId',
3181
+ model: UserAddress,
3182
+ interceptors,
3183
+ });
3184
+ this.parentRepository = parentRepository;
3185
+ }
3186
+ }
3187
+
3188
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3189
+ constructor({ firestore, interceptors }, parentRepository) {
3190
+ super({
3191
+ firestore,
3192
+ collectionName: 'CX',
3193
+ parentIdField: 'userId',
3194
+ model: BeautyProfile,
3195
+ interceptors,
3196
+ });
3197
+ this.parentRepository = parentRepository;
3198
+ }
3199
+ }
3200
+
3201
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3202
+ constructor({ firestore, interceptors }) {
3203
+ super({
3204
+ firestore,
3205
+ collectionName: 'users',
3206
+ model: User,
3207
+ interceptors,
3208
+ });
3209
+ }
3210
+ async get(identifiers) {
3211
+ const user = await super.get({ id: identifiers.id });
3212
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3213
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3214
+ return user;
3215
+ }
3216
+ async checkIfExistsByField(field, value) {
3217
+ const result = await this.find({ filters: { [field]: value } });
3218
+ return result.count > 0;
3219
+ }
3220
+ buildModelInstance() {
3221
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3222
+ return {
3223
+ toFirestore: (data) => {
3224
+ const plain = toFirestore(data);
3225
+ delete plain.isSubscriber;
3226
+ return plain;
3227
+ },
3228
+ fromFirestore,
3229
+ };
3230
+ }
3231
+ async getBeautyProfile(userId) {
3232
+ const beautyProfile = await this.firestore
3233
+ .getCollection(`${this.collectionName}/${userId}/CX`)
3234
+ .withConverter(this.buildBeautyProfileModelInstance())
3235
+ .getDoc('beautyProfile')
3236
+ .get();
3237
+ return beautyProfile.data();
3238
+ }
3239
+ async checkIfIsSubscriber(userId) {
3240
+ const docs = await this.collection('subscription')
3241
+ .where('user.id', '==', userId)
3242
+ .where('status', '==', 'active')
3243
+ .getDocs();
3244
+ return !!docs && !!docs.size;
3245
+ }
3246
+ buildBeautyProfileModelInstance() {
3247
+ return {
3248
+ toFirestore: (data) => data.toPlain(),
3249
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3250
+ };
3251
+ }
3252
+ }
3253
+ __decorate([
3254
+ Log(),
3255
+ __metadata("design:type", Function),
3256
+ __metadata("design:paramtypes", [Object]),
3257
+ __metadata("design:returntype", Promise)
3258
+ ], UserFirestoreRepository.prototype, "get", null);
3259
+ __decorate([
3260
+ Log(),
3261
+ __metadata("design:type", Function),
3262
+ __metadata("design:paramtypes", [String, String]),
3263
+ __metadata("design:returntype", Promise)
3264
+ ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
3265
+
3266
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3267
+ constructor({ firestore, interceptors }, parentRepository) {
3268
+ super({
3269
+ firestore,
3270
+ collectionName: 'payment_method',
3271
+ parentIdField: 'userId',
3272
+ model: UserPaymentMethod,
3273
+ interceptors,
3274
+ });
3275
+ this.parentRepository = parentRepository;
3276
+ }
3277
+ }
3278
+
3739
3279
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3740
3280
  constructor({ firestore, interceptors }) {
3741
3281
  super({
@@ -3883,133 +3423,38 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
3883
3423
  return Promise.resolve([]);
3884
3424
  }
3885
3425
  }
3886
- __decorate([
3887
- Log(),
3888
- __metadata("design:type", Function),
3889
- __metadata("design:paramtypes", [String]),
3890
- __metadata("design:returntype", Promise)
3891
- ], ProductFirestoreRepository.prototype, "getBySlug", null);
3892
- __decorate([
3893
- Log(),
3894
- __metadata("design:type", Function),
3895
- __metadata("design:paramtypes", [String]),
3896
- __metadata("design:returntype", Promise)
3897
- ], ProductFirestoreRepository.prototype, "fetchReviews", null);
3898
-
3899
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3900
- constructor({ firestore, interceptors }, parentRepository) {
3901
- super({
3902
- firestore,
3903
- collectionName: 'variants',
3904
- parentIdField: 'productId',
3905
- model: Variant,
3906
- interceptors,
3907
- });
3908
- this.parentRepository = parentRepository;
3909
- }
3910
- }
3911
-
3912
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3913
- constructor({ firestore, interceptors }) {
3914
- super({
3915
- firestore,
3916
- collectionName: 'subscriptionProducts',
3917
- model: Product,
3918
- interceptors,
3919
- });
3920
- }
3921
- }
3922
-
3923
- class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3924
- constructor({ firestore, interceptors }) {
3925
- super({
3926
- firestore,
3927
- collectionName: 'sequences',
3928
- model: Sequence,
3929
- interceptors,
3930
- });
3931
- }
3932
- }
3933
-
3934
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3935
- constructor({ firestore, interceptors }) {
3936
- super({
3937
- firestore,
3938
- collectionName: 'dms',
3939
- model: Home,
3940
- interceptors,
3941
- });
3942
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3943
- var _a, _b, _c;
3944
- return ({
3945
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3946
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3947
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3948
- 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)) || [],
3949
- });
3950
- };
3951
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3952
- var _a;
3953
- return ({
3954
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3955
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3956
- });
3957
- };
3958
- }
3959
- buildModelInstance() {
3960
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3961
- return {
3962
- toFirestore: (data) => {
3963
- const modifiedData = this.homeToFirestore(data);
3964
- return toFirestore(modifiedData);
3965
- },
3966
- fromFirestore: (snap) => {
3967
- const instance = fromFirestore(snap);
3968
- return this.homeFromFirestore(instance);
3969
- },
3970
- };
3971
- }
3972
- homeToFirestore(home) {
3973
- var _a, _b, _c, _d;
3974
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3975
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3976
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3977
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3978
- }
3979
- return home;
3980
- }
3981
- homeFromFirestore(home) {
3982
- var _a;
3983
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3984
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3985
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3986
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3987
- home.data.createdAt =
3988
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3989
- home.data.expiresAt =
3990
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3991
- }
3992
- return home;
3993
- }
3994
- }
3426
+ __decorate([
3427
+ Log(),
3428
+ __metadata("design:type", Function),
3429
+ __metadata("design:paramtypes", [String]),
3430
+ __metadata("design:returntype", Promise)
3431
+ ], ProductFirestoreRepository.prototype, "getBySlug", null);
3432
+ __decorate([
3433
+ Log(),
3434
+ __metadata("design:type", Function),
3435
+ __metadata("design:paramtypes", [String]),
3436
+ __metadata("design:returntype", Promise)
3437
+ ], ProductFirestoreRepository.prototype, "fetchReviews", null);
3995
3438
 
3996
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3997
- constructor({ firestore, interceptors }) {
3439
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3440
+ constructor({ firestore, interceptors }, parentRepository) {
3998
3441
  super({
3999
3442
  firestore,
4000
- collectionName: 'shopMenus',
4001
- model: ShopMenu,
3443
+ collectionName: 'variants',
3444
+ parentIdField: 'productId',
3445
+ model: Variant,
4002
3446
  interceptors,
4003
3447
  });
3448
+ this.parentRepository = parentRepository;
4004
3449
  }
4005
3450
  }
4006
3451
 
4007
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4008
- constructor({ firestore, interceptors, }) {
3452
+ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3453
+ constructor({ firestore, interceptors }) {
4009
3454
  super({
4010
3455
  firestore,
4011
- collectionName: 'shopSettings',
4012
- model: ShopSettings,
3456
+ collectionName: 'subscriptionProducts',
3457
+ model: Product,
4013
3458
  interceptors,
4014
3459
  });
4015
3460
  }
@@ -4208,177 +3653,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
4208
3653
  }
4209
3654
  }
4210
3655
 
4211
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3656
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4212
3657
  constructor({ firestore, interceptors }) {
4213
3658
  super({
4214
3659
  firestore,
4215
- collectionName: 'leads',
4216
- model: Lead,
3660
+ collectionName: 'dms',
3661
+ model: Home,
4217
3662
  interceptors,
4218
3663
  });
3664
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3665
+ var _a, _b, _c;
3666
+ return ({
3667
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3668
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3669
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3670
+ 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)) || [],
3671
+ });
3672
+ };
3673
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3674
+ var _a;
3675
+ return ({
3676
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3677
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3678
+ });
3679
+ };
4219
3680
  }
4220
- }
4221
-
4222
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4223
- constructor({ firestore, interceptors }, parentRepository) {
4224
- super({
4225
- firestore,
4226
- collectionName: 'editions',
4227
- parentIdField: 'subscriptionId',
4228
- model: Edition,
4229
- interceptors,
4230
- });
4231
- this.parentRepository = parentRepository;
3681
+ buildModelInstance() {
3682
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3683
+ return {
3684
+ toFirestore: (data) => {
3685
+ const modifiedData = this.homeToFirestore(data);
3686
+ return toFirestore(modifiedData);
3687
+ },
3688
+ fromFirestore: (snap) => {
3689
+ const instance = fromFirestore(snap);
3690
+ return this.homeFromFirestore(instance);
3691
+ },
3692
+ };
4232
3693
  }
4233
- }
4234
-
4235
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4236
- constructor({ firestore, interceptors, }) {
4237
- super({
4238
- firestore,
4239
- collectionName: 'subscription',
4240
- model: Subscription,
4241
- interceptors,
4242
- });
3694
+ homeToFirestore(home) {
3695
+ var _a, _b, _c, _d;
3696
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3697
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3698
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3699
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3700
+ }
3701
+ return home;
4243
3702
  }
4244
- }
4245
-
4246
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4247
- constructor({ firestore, interceptors }) {
4248
- super({
4249
- firestore,
4250
- collectionName: 'subscriptionMaterialization',
4251
- model: SubscriptionMaterialization,
4252
- interceptors,
4253
- });
3703
+ homeFromFirestore(home) {
3704
+ var _a;
3705
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3706
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3707
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3708
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3709
+ home.data.createdAt =
3710
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3711
+ home.data.expiresAt =
3712
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3713
+ }
3714
+ return home;
4254
3715
  }
4255
3716
  }
4256
3717
 
4257
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4258
- constructor({ firestore, interceptors }, parentRepository) {
3718
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3719
+ constructor({ firestore, interceptors }) {
4259
3720
  super({
4260
3721
  firestore,
4261
- collectionName: 'payments',
4262
- parentIdField: 'subscriptionId',
4263
- model: SubscriptionPayment,
3722
+ collectionName: 'shopMenus',
3723
+ model: ShopMenu,
4264
3724
  interceptors,
4265
3725
  });
4266
- this.parentRepository = parentRepository;
4267
3726
  }
4268
3727
  }
4269
3728
 
4270
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3729
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4271
3730
  constructor({ firestore, interceptors, }) {
4272
3731
  super({
4273
3732
  firestore,
4274
- collectionName: 'subscriptionSummary',
4275
- model: SubscriptionSummary,
4276
- interceptors,
4277
- });
4278
- }
4279
- }
4280
-
4281
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4282
- constructor({ firestore, interceptors }, parentRepository) {
4283
- super({
4284
- firestore,
4285
- collectionName: 'address',
4286
- parentIdField: 'userId',
4287
- model: UserAddress,
4288
- interceptors,
4289
- });
4290
- this.parentRepository = parentRepository;
4291
- }
4292
- }
4293
-
4294
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4295
- constructor({ firestore, interceptors }, parentRepository) {
4296
- super({
4297
- firestore,
4298
- collectionName: 'CX',
4299
- parentIdField: 'userId',
4300
- model: BeautyProfile,
4301
- interceptors,
4302
- });
4303
- this.parentRepository = parentRepository;
4304
- }
4305
- }
4306
-
4307
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
4308
- constructor({ firestore, interceptors }) {
4309
- super({
4310
- firestore,
4311
- collectionName: 'users',
4312
- model: User,
4313
- interceptors,
4314
- });
4315
- }
4316
- async get(identifiers) {
4317
- const user = await super.get({ id: identifiers.id });
4318
- user.beautyProfile = await this.getBeautyProfile(user.id);
4319
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
4320
- return user;
4321
- }
4322
- async checkIfExistsByField(field, value) {
4323
- const result = await this.find({ filters: { [field]: value } });
4324
- return result.count > 0;
4325
- }
4326
- buildModelInstance() {
4327
- const { fromFirestore, toFirestore } = super.buildModelInstance();
4328
- return {
4329
- toFirestore: (data) => {
4330
- const plain = toFirestore(data);
4331
- delete plain.isSubscriber;
4332
- return plain;
4333
- },
4334
- fromFirestore,
4335
- };
4336
- }
4337
- async getBeautyProfile(userId) {
4338
- const beautyProfile = await this.firestore
4339
- .getCollection(`${this.collectionName}/${userId}/CX`)
4340
- .withConverter(this.buildBeautyProfileModelInstance())
4341
- .getDoc('beautyProfile')
4342
- .get();
4343
- return beautyProfile.data();
4344
- }
4345
- async checkIfIsSubscriber(userId) {
4346
- const docs = await this.collection('subscription')
4347
- .where('user.id', '==', userId)
4348
- .where('status', '==', 'active')
4349
- .getDocs();
4350
- return !!docs && !!docs.size;
4351
- }
4352
- buildBeautyProfileModelInstance() {
4353
- return {
4354
- toFirestore: (data) => data.toPlain(),
4355
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
4356
- };
4357
- }
4358
- }
4359
- __decorate([
4360
- Log(),
4361
- __metadata("design:type", Function),
4362
- __metadata("design:paramtypes", [Object]),
4363
- __metadata("design:returntype", Promise)
4364
- ], UserFirestoreRepository.prototype, "get", null);
4365
- __decorate([
4366
- Log(),
4367
- __metadata("design:type", Function),
4368
- __metadata("design:paramtypes", [String, String]),
4369
- __metadata("design:returntype", Promise)
4370
- ], UserFirestoreRepository.prototype, "checkIfExistsByField", null);
4371
-
4372
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4373
- constructor({ firestore, interceptors }, parentRepository) {
4374
- super({
4375
- firestore,
4376
- collectionName: 'payment_method',
4377
- parentIdField: 'userId',
4378
- model: UserPaymentMethod,
3733
+ collectionName: 'shopSettings',
3734
+ model: ShopSettings,
4379
3735
  interceptors,
4380
3736
  });
4381
- this.parentRepository = parentRepository;
4382
3737
  }
4383
3738
  }
4384
3739
 
@@ -6519,6 +5874,24 @@ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
6519
5874
  ],
6520
5875
  });
6521
5876
  }
5877
+ async updateManyStatus(reviews) {
5878
+ return await this.mutation('update_product_review_many', ['affected_rows'], {
5879
+ updates: {
5880
+ type: '[product_review_updates!]',
5881
+ required: true,
5882
+ value: [
5883
+ {
5884
+ _set: { status: true },
5885
+ where: { id: { _in: reviews.filter((review) => review.status).map((review) => review.id) } },
5886
+ },
5887
+ {
5888
+ _set: { status: false },
5889
+ where: { id: { _in: reviews.filter((review) => !review.status).map((review) => review.id) } },
5890
+ },
5891
+ ],
5892
+ },
5893
+ });
5894
+ }
6522
5895
  aproveReview(id) {
6523
5896
  return this.update({ id, status: true });
6524
5897
  }
@@ -6780,6 +6153,15 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6780
6153
  }),
6781
6154
  },
6782
6155
  },
6156
+ {
6157
+ metadatas: {
6158
+ columnName: 'metadatas',
6159
+ fields: ['shop', 'title', 'description'],
6160
+ bindPersistData: (value) => ({
6161
+ metadatas: { data: value },
6162
+ }),
6163
+ },
6164
+ },
6783
6165
  { isCollection: { columnName: 'is_collection' } },
6784
6166
  { isWishlist: { columnName: 'is_wishlist' } },
6785
6167
  'reference',
@@ -6799,6 +6181,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6799
6181
  'theme',
6800
6182
  { bannerUrl: { columnName: 'banner_url' } },
6801
6183
  { personHasPhoto: { columnName: 'person_has_photo' } },
6184
+ { mostRelevants: { columnName: 'most_relevants', type: HasuraGraphQLColumnType.Jsonb } },
6802
6185
  ],
6803
6186
  });
6804
6187
  this.categoryFilterRepository = categoryFilterRepository;
@@ -7011,4 +6394,4 @@ __decorate([
7011
6394
  __metadata("design:returntype", Promise)
7012
6395
  ], WishlistHasuraGraphQLRepository.prototype, "findBfluOrGlamgirlWishlists", null);
7013
6396
 
7014
- export { AccessoryImportances, Address, AdyenCardService, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BusinessError, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponFirestoreRepository, 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, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, PagarmeBankSlipService, PagarmeCardService, PagarmePaymentMethodFactory, PagarmePixService, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
6397
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, PersonTypes, Plans, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };