@infrab4a/connect 0.5.0 → 0.6.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 (27) hide show
  1. package/bundles/infrab4a-connect.umd.js +356 -230
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/esm2015/lib/domain/catalog/models/product.js +3 -2
  4. package/esm2015/lib/domain/catalog/repositories/category.repository.js +1 -1
  5. package/esm2015/lib/domain/shopping/models/buy-2-win.js +8 -1
  6. package/esm2015/lib/domain/shopping/models/checkout.js +32 -1
  7. package/esm2015/lib/domain/shopping/models/coupons/coupon.js +8 -4
  8. package/esm2015/lib/domain/shopping/models/order.js +8 -1
  9. package/esm2015/lib/domain/shopping/models/payment.js +82 -42
  10. package/esm2015/lib/domain/shopping/models/subscription/checkout.js +22 -1
  11. package/esm2015/lib/domain/users/models/subscription/payment.js +8 -1
  12. package/esm2015/lib/domain/users/models/subscription/subscription.js +37 -1
  13. package/esm2015/lib/domain/users/models/user.js +11 -2
  14. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +21 -23
  15. package/esm2015/public-api.js +2 -1
  16. package/fesm2015/infrab4a-connect.js +339 -212
  17. package/fesm2015/infrab4a-connect.js.map +1 -1
  18. package/lib/domain/catalog/repositories/category.repository.d.ts +1 -1
  19. package/lib/domain/shopping/models/buy-2-win.d.ts +1 -1
  20. package/lib/domain/shopping/models/checkout.d.ts +6 -6
  21. package/lib/domain/shopping/models/subscription/checkout.d.ts +4 -4
  22. package/lib/domain/users/models/subscription/payment.d.ts +1 -1
  23. package/lib/domain/users/models/subscription/subscription.d.ts +6 -6
  24. package/lib/domain/users/models/user.d.ts +1 -1
  25. package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -1
  26. package/package.json +1 -1
  27. package/public-api.d.ts +1 -0
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('class-transformer'), require('lodash'), require('ts-md5'), require('firebase'), require('firebase/app')) :
3
- typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'class-transformer', 'lodash', 'ts-md5', 'firebase', 'firebase/app'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), global["class-transformer"], global.lodash, global.tsMd5, global.firebase, global.firebase$1));
5
- })(this, (function (exports, classTransformer, lodash, tsMd5, firebase, firebase$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('lodash'), require('ts-md5'), require('firebase'), require('firebase/app')) :
3
+ typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'lodash', 'ts-md5', 'firebase', 'firebase/app'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global.lodash, global.tsMd5, global.firebase, global.firebase$1));
5
+ })(this, (function (exports, reflectMetadata, classTransformer, lodash, tsMd5, firebase, firebase$1) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -442,6 +442,177 @@
442
442
  return Edition;
443
443
  }(BaseModel));
444
444
 
445
+ var Payment = /** @class */ (function (_super) {
446
+ __extends(Payment, _super);
447
+ function Payment() {
448
+ return _super !== null && _super.apply(this, arguments) || this;
449
+ }
450
+ Payment.prototype.identifierFields = function () {
451
+ return ['id'];
452
+ };
453
+ return Payment;
454
+ }(BaseModel));
455
+ __decorate([
456
+ classTransformer.Expose({ name: 'refuse_reason' }),
457
+ __metadata("design:type", String)
458
+ ], Payment.prototype, "refuseReason", void 0);
459
+ __decorate([
460
+ classTransformer.Expose({ name: 'status_reason' }),
461
+ __metadata("design:type", String)
462
+ ], Payment.prototype, "statusReason", void 0);
463
+ __decorate([
464
+ classTransformer.Expose({ name: 'acquirer_response_code' }),
465
+ __metadata("design:type", String)
466
+ ], Payment.prototype, "acquirerResponseCode", void 0);
467
+ __decorate([
468
+ classTransformer.Expose({ name: 'acquirer_name' }),
469
+ __metadata("design:type", String)
470
+ ], Payment.prototype, "acquirerName", void 0);
471
+ __decorate([
472
+ classTransformer.Expose({ name: 'acquirer_id' }),
473
+ __metadata("design:type", String)
474
+ ], Payment.prototype, "acquirerId", void 0);
475
+ __decorate([
476
+ classTransformer.Expose({ name: 'authorization_code' }),
477
+ __metadata("design:type", String)
478
+ ], Payment.prototype, "authorizationCode", void 0);
479
+ __decorate([
480
+ classTransformer.Expose({ name: 'soft_descriptor' }),
481
+ __metadata("design:type", String)
482
+ ], Payment.prototype, "softDescriptor", void 0);
483
+ __decorate([
484
+ classTransformer.Expose({ name: 'date_created' }),
485
+ __metadata("design:type", String)
486
+ ], Payment.prototype, "dateCreated", void 0);
487
+ __decorate([
488
+ classTransformer.Expose({ name: 'date_updated' }),
489
+ __metadata("design:type", String)
490
+ ], Payment.prototype, "dateUpdated", void 0);
491
+ __decorate([
492
+ classTransformer.Expose({ name: 'authorized_amount' }),
493
+ __metadata("design:type", Number)
494
+ ], Payment.prototype, "authorizedAmount", void 0);
495
+ __decorate([
496
+ classTransformer.Expose({ name: 'paid_amount' }),
497
+ __metadata("design:type", Number)
498
+ ], Payment.prototype, "paidAmount", void 0);
499
+ __decorate([
500
+ classTransformer.Expose({ name: 'refunded_amount' }),
501
+ __metadata("design:type", Number)
502
+ ], Payment.prototype, "refundedAmount", void 0);
503
+ __decorate([
504
+ classTransformer.Expose({ name: 'card_holder_name' }),
505
+ __metadata("design:type", String)
506
+ ], Payment.prototype, "cardHolderName", void 0);
507
+ __decorate([
508
+ classTransformer.Expose({ name: 'card_last_digits' }),
509
+ __metadata("design:type", String)
510
+ ], Payment.prototype, "cardLastDigits", void 0);
511
+ __decorate([
512
+ classTransformer.Expose({ name: 'card_first_digits' }),
513
+ __metadata("design:type", String)
514
+ ], Payment.prototype, "cardFirstDigits", void 0);
515
+ __decorate([
516
+ classTransformer.Expose({ name: 'card_brand' }),
517
+ __metadata("design:type", String)
518
+ ], Payment.prototype, "cardBrand", void 0);
519
+ __decorate([
520
+ classTransformer.Expose({ name: 'card_pin_mode' }),
521
+ __metadata("design:type", String)
522
+ ], Payment.prototype, "cardPinMode", void 0);
523
+ __decorate([
524
+ classTransformer.Expose({ name: 'card_magstripe_fallback' }),
525
+ __metadata("design:type", Boolean)
526
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
527
+ __decorate([
528
+ classTransformer.Expose({ name: 'cvm_pin' }),
529
+ __metadata("design:type", Boolean)
530
+ ], Payment.prototype, "cvmPin", void 0);
531
+ __decorate([
532
+ classTransformer.Expose({ name: 'postback_url' }),
533
+ __metadata("design:type", String)
534
+ ], Payment.prototype, "postbackUrl", void 0);
535
+ __decorate([
536
+ classTransformer.Expose({ name: 'payment_method' }),
537
+ __metadata("design:type", String)
538
+ ], Payment.prototype, "paymentMethod", void 0);
539
+ __decorate([
540
+ classTransformer.Expose({ name: 'capture_method' }),
541
+ __metadata("design:type", String)
542
+ ], Payment.prototype, "captureMethod", void 0);
543
+ __decorate([
544
+ classTransformer.Expose({ name: 'antifraud_score' }),
545
+ __metadata("design:type", String)
546
+ ], Payment.prototype, "antifraudScore", void 0);
547
+ __decorate([
548
+ classTransformer.Expose({ name: 'boleto_url' }),
549
+ __metadata("design:type", String)
550
+ ], Payment.prototype, "boletoUrl", void 0);
551
+ __decorate([
552
+ classTransformer.Expose({ name: 'boleto_barcode' }),
553
+ __metadata("design:type", String)
554
+ ], Payment.prototype, "boletoBarcode", void 0);
555
+ __decorate([
556
+ classTransformer.Expose({ name: 'boleto_expiration_date' }),
557
+ __metadata("design:type", String)
558
+ ], Payment.prototype, "boletoExpirationDate", void 0);
559
+ __decorate([
560
+ classTransformer.Expose({ name: 'subscription_id' }),
561
+ __metadata("design:type", String)
562
+ ], Payment.prototype, "subscriptionId", void 0);
563
+ __decorate([
564
+ classTransformer.Expose({ name: 'split_rules' }),
565
+ __metadata("design:type", String)
566
+ ], Payment.prototype, "splitRules", void 0);
567
+ __decorate([
568
+ classTransformer.Expose({ name: 'antifraud_metadata' }),
569
+ __metadata("design:type", Object)
570
+ ], Payment.prototype, "antifraudMetadata", void 0);
571
+ __decorate([
572
+ classTransformer.Expose({ name: 'reference_key' }),
573
+ __metadata("design:type", String)
574
+ ], Payment.prototype, "referenceKey", void 0);
575
+ __decorate([
576
+ classTransformer.Expose({ name: 'local_transaction_id' }),
577
+ __metadata("design:type", String)
578
+ ], Payment.prototype, "localTransactionId", void 0);
579
+ __decorate([
580
+ classTransformer.Expose({ name: 'local_time' }),
581
+ __metadata("design:type", String)
582
+ ], Payment.prototype, "localTime", void 0);
583
+ __decorate([
584
+ classTransformer.Expose({ name: 'fraud_covered' }),
585
+ __metadata("design:type", Boolean)
586
+ ], Payment.prototype, "fraudCovered", void 0);
587
+ __decorate([
588
+ classTransformer.Expose({ name: 'fraud_reimbursed' }),
589
+ __metadata("design:type", String)
590
+ ], Payment.prototype, "fraudReimbursed", void 0);
591
+ __decorate([
592
+ classTransformer.Expose({ name: 'order_id' }),
593
+ __metadata("design:type", String)
594
+ ], Payment.prototype, "orderId", void 0);
595
+ __decorate([
596
+ classTransformer.Expose({ name: 'risk_level' }),
597
+ __metadata("design:type", String)
598
+ ], Payment.prototype, "riskLevel", void 0);
599
+ __decorate([
600
+ classTransformer.Expose({ name: 'receipt_url' }),
601
+ __metadata("design:type", String)
602
+ ], Payment.prototype, "receiptUrl", void 0);
603
+ __decorate([
604
+ classTransformer.Expose({ name: 'private_label' }),
605
+ __metadata("design:type", String)
606
+ ], Payment.prototype, "privateLabel", void 0);
607
+ __decorate([
608
+ classTransformer.Expose({ name: 'pix_qr_code' }),
609
+ __metadata("design:type", String)
610
+ ], Payment.prototype, "pixQrCode", void 0);
611
+ __decorate([
612
+ classTransformer.Expose({ name: 'pix_expiration_date' }),
613
+ __metadata("design:type", String)
614
+ ], Payment.prototype, "pixExpirationDate", void 0);
615
+
445
616
  var SubscriptionPayment = /** @class */ (function (_super) {
446
617
  __extends(SubscriptionPayment, _super);
447
618
  function SubscriptionPayment() {
@@ -452,39 +623,60 @@
452
623
  };
453
624
  return SubscriptionPayment;
454
625
  }(BaseModel));
626
+ __decorate([
627
+ classTransformer.Type(function () { return Payment; }),
628
+ __metadata("design:type", Payment)
629
+ ], SubscriptionPayment.prototype, "payment", void 0);
455
630
 
456
- var Subscription = /** @class */ (function (_super) {
457
- __extends(Subscription, _super);
458
- function Subscription() {
631
+ var Address = /** @class */ (function (_super) {
632
+ __extends(Address, _super);
633
+ function Address() {
459
634
  return _super !== null && _super.apply(this, arguments) || this;
460
635
  }
461
- Subscription.prototype.identifierFields = function () {
636
+ return Address;
637
+ }(BaseModel));
638
+
639
+ var Coupon = /** @class */ (function (_super) {
640
+ __extends(Coupon, _super);
641
+ function Coupon() {
642
+ return _super !== null && _super.apply(this, arguments) || this;
643
+ }
644
+ Coupon.prototype.identifierFields = function () {
462
645
  return ['id'];
463
646
  };
464
- return Subscription;
647
+ return Coupon;
465
648
  }(BaseModel));
649
+ __decorate([
650
+ classTransformer.Expose({ name: 'checkout_type' }),
651
+ __metadata("design:type", Number)
652
+ ], Coupon.prototype, "checkoutType", void 0);
653
+ __decorate([
654
+ classTransformer.Expose({ name: 'exclusivity_type' }),
655
+ __metadata("design:type", Number)
656
+ ], Coupon.prototype, "exclusivityType", void 0);
466
657
 
467
- var User = /** @class */ (function (_super) {
468
- __extends(User, _super);
469
- function User() {
658
+ var SubscriptionPlan = /** @class */ (function (_super) {
659
+ __extends(SubscriptionPlan, _super);
660
+ function SubscriptionPlan() {
470
661
  return _super !== null && _super.apply(this, arguments) || this;
471
662
  }
472
- User.toInstance = function (data) {
473
- var instance = _super.toInstance.call(this, data);
474
- instance.displayName = data.firstName + " " + data.lastName;
475
- return instance;
476
- };
477
- User.prototype.identifierFields = function () {
663
+ SubscriptionPlan.prototype.identifierFields = function () {
478
664
  return ['id'];
479
665
  };
480
- User.prototype.toPlain = function () {
481
- var plain = _super.prototype.toPlain.call(this);
482
- delete plain.beautyProfile;
483
- return plain;
484
- };
485
- return User;
666
+ return SubscriptionPlan;
486
667
  }(BaseModel));
487
668
 
669
+ var Base = /** @class */ (function () {
670
+ function Base() {
671
+ var args = [];
672
+ for (var _i = 0; _i < arguments.length; _i++) {
673
+ args[_i] = arguments[_i];
674
+ }
675
+ Object.assign.apply(Object, __spreadArray([this], __read(args)));
676
+ }
677
+ return Base;
678
+ }());
679
+
488
680
  var BeautyProfile = /** @class */ (function (_super) {
489
681
  __extends(BeautyProfile, _super);
490
682
  function BeautyProfile() {
@@ -501,13 +693,70 @@
501
693
  return BeautyProfile;
502
694
  }(BaseModel));
503
695
 
504
- var Address = /** @class */ (function (_super) {
505
- __extends(Address, _super);
506
- function Address() {
696
+ var User = /** @class */ (function (_super) {
697
+ __extends(User, _super);
698
+ function User() {
507
699
  return _super !== null && _super.apply(this, arguments) || this;
508
700
  }
509
- return Address;
701
+ User.toInstance = function (data) {
702
+ var instance = _super.toInstance.call(this, data);
703
+ if (!lodash.isNil(data.firstName))
704
+ instance.displayName = "" + data.firstName + (!lodash.isNil(data.lastName) ? " " + data.lastName : '');
705
+ return instance;
706
+ };
707
+ User.prototype.identifierFields = function () {
708
+ return ['id'];
709
+ };
710
+ User.prototype.toPlain = function () {
711
+ var plain = _super.prototype.toPlain.call(this);
712
+ delete plain.beautyProfile;
713
+ return plain;
714
+ };
715
+ return User;
716
+ }(BaseModel));
717
+ __decorate([
718
+ classTransformer.Type(function () { return BeautyProfile; }),
719
+ __metadata("design:type", BeautyProfile)
720
+ ], User.prototype, "beautyProfile", void 0);
721
+
722
+ var Subscription = /** @class */ (function (_super) {
723
+ __extends(Subscription, _super);
724
+ function Subscription() {
725
+ return _super !== null && _super.apply(this, arguments) || this;
726
+ }
727
+ Subscription.prototype.identifierFields = function () {
728
+ return ['id'];
729
+ };
730
+ return Subscription;
510
731
  }(BaseModel));
732
+ __decorate([
733
+ classTransformer.Type(function () { return User; }),
734
+ __metadata("design:type", User)
735
+ ], Subscription.prototype, "user", void 0);
736
+ __decorate([
737
+ classTransformer.Type(function () { return SubscriptionPlan; }),
738
+ __metadata("design:type", SubscriptionPlan)
739
+ ], Subscription.prototype, "subscriptionPlan", void 0);
740
+ __decorate([
741
+ classTransformer.Type(function () { return Address; }),
742
+ __metadata("design:type", Address)
743
+ ], Subscription.prototype, "shippingAddress", void 0);
744
+ __decorate([
745
+ classTransformer.Type(function () { return Address; }),
746
+ __metadata("design:type", Address)
747
+ ], Subscription.prototype, "billingAddress", void 0);
748
+ __decorate([
749
+ classTransformer.Type(function () { return Coupon; }),
750
+ __metadata("design:type", Coupon)
751
+ ], Subscription.prototype, "coupon", void 0);
752
+ __decorate([
753
+ classTransformer.Type(function () { return Edition; }),
754
+ __metadata("design:type", Array)
755
+ ], Subscription.prototype, "editions", void 0);
756
+ __decorate([
757
+ classTransformer.Type(function () { return SubscriptionPayment; }),
758
+ __metadata("design:type", Array)
759
+ ], Subscription.prototype, "payment", void 0);
511
760
 
512
761
  var UserAddress = /** @class */ (function (_super) {
513
762
  __extends(UserAddress, _super);
@@ -520,17 +769,6 @@
520
769
  return UserAddress;
521
770
  }(Address));
522
771
 
523
- var Base = /** @class */ (function () {
524
- function Base() {
525
- var args = [];
526
- for (var _i = 0; _i < arguments.length; _i++) {
527
- args[_i] = arguments[_i];
528
- }
529
- Object.assign.apply(Object, __spreadArray([this], __read(args)));
530
- }
531
- return Base;
532
- }());
533
-
534
772
  var UnauthorizedError = /** @class */ (function (_super) {
535
773
  __extends(UnauthorizedError, _super);
536
774
  function UnauthorizedError(message) {
@@ -635,7 +873,8 @@
635
873
  return ['id'];
636
874
  };
637
875
  Product.prototype.getInfoByShop = function (shop) {
638
- return Object.assign(Object.assign({ description: this.description[shop].description }, this.price[shop]), this.stock[shop]);
876
+ var _a, _b, _c, _d, _e, _f;
877
+ return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
639
878
  };
640
879
  return Product;
641
880
  }(BaseModel));
@@ -672,23 +911,6 @@
672
911
  Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
673
912
  })(exports.Exclusivities || (exports.Exclusivities = {}));
674
913
 
675
- var Coupon = /** @class */ (function (_super) {
676
- __extends(Coupon, _super);
677
- function Coupon() {
678
- return _super !== null && _super.apply(this, arguments) || this;
679
- }
680
- Coupon.prototype.identifierFields = function () {
681
- return ['id'];
682
- };
683
- return Coupon;
684
- }(BaseModel));
685
- __decorate([
686
- classTransformer.Expose({ name: 'checkout_type' })
687
- ], Coupon.prototype, "checkoutType", void 0);
688
- __decorate([
689
- classTransformer.Expose({ name: 'exclusivity_type' })
690
- ], Coupon.prototype, "exclusivityType", void 0);
691
-
692
914
  exports.CheckoutTypes = void 0;
693
915
  (function (CheckoutTypes) {
694
916
  CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
@@ -734,17 +956,6 @@
734
956
  OrderStatus["CREDIT_CARD"] = "credit_card";
735
957
  })(exports.OrderStatus || (exports.OrderStatus = {}));
736
958
 
737
- var Checkout = /** @class */ (function (_super) {
738
- __extends(Checkout, _super);
739
- function Checkout() {
740
- return _super !== null && _super.apply(this, arguments) || this;
741
- }
742
- Checkout.prototype.identifierFields = function () {
743
- return ['id'];
744
- };
745
- return Checkout;
746
- }(BaseModel));
747
-
748
959
  var LineItem = /** @class */ (function (_super) {
749
960
  __extends(LineItem, _super);
750
961
  function LineItem() {
@@ -753,155 +964,63 @@
753
964
  return LineItem;
754
965
  }(Product));
755
966
 
756
- var Order = /** @class */ (function (_super) {
757
- __extends(Order, _super);
758
- function Order() {
967
+ var ShippingMethod = /** @class */ (function (_super) {
968
+ __extends(ShippingMethod, _super);
969
+ function ShippingMethod() {
759
970
  return _super !== null && _super.apply(this, arguments) || this;
760
971
  }
761
- return Order;
762
- }(Checkout));
972
+ ShippingMethod.prototype.identifierFields = function () {
973
+ return ['id'];
974
+ };
975
+ return ShippingMethod;
976
+ }(BaseModel));
763
977
 
764
- var Payment = /** @class */ (function (_super) {
765
- __extends(Payment, _super);
766
- function Payment() {
978
+ var Checkout = /** @class */ (function (_super) {
979
+ __extends(Checkout, _super);
980
+ function Checkout() {
767
981
  return _super !== null && _super.apply(this, arguments) || this;
768
982
  }
769
- Payment.prototype.identifierFields = function () {
983
+ Checkout.prototype.identifierFields = function () {
770
984
  return ['id'];
771
985
  };
772
- return Payment;
986
+ return Checkout;
773
987
  }(BaseModel));
774
988
  __decorate([
775
- classTransformer.Expose({ name: 'refuse_reason' })
776
- ], Payment.prototype, "refuseReason", void 0);
777
- __decorate([
778
- classTransformer.Expose({ name: 'status_reason' })
779
- ], Payment.prototype, "statusReason", void 0);
780
- __decorate([
781
- classTransformer.Expose({ name: 'acquirer_response_code' })
782
- ], Payment.prototype, "acquirerResponseCode", void 0);
783
- __decorate([
784
- classTransformer.Expose({ name: 'acquirer_name' })
785
- ], Payment.prototype, "acquirerName", void 0);
786
- __decorate([
787
- classTransformer.Expose({ name: 'acquirer_id' })
788
- ], Payment.prototype, "acquirerId", void 0);
789
- __decorate([
790
- classTransformer.Expose({ name: 'authorization_code' })
791
- ], Payment.prototype, "authorizationCode", void 0);
792
- __decorate([
793
- classTransformer.Expose({ name: 'soft_descriptor' })
794
- ], Payment.prototype, "softDescriptor", void 0);
795
- __decorate([
796
- classTransformer.Expose({ name: 'date_created' })
797
- ], Payment.prototype, "dateCreated", void 0);
798
- __decorate([
799
- classTransformer.Expose({ name: 'date_updated' })
800
- ], Payment.prototype, "dateUpdated", void 0);
801
- __decorate([
802
- classTransformer.Expose({ name: 'authorized_amount' })
803
- ], Payment.prototype, "authorizedAmount", void 0);
804
- __decorate([
805
- classTransformer.Expose({ name: 'paid_amount' })
806
- ], Payment.prototype, "paidAmount", void 0);
807
- __decorate([
808
- classTransformer.Expose({ name: 'refunded_amount' })
809
- ], Payment.prototype, "refundedAmount", void 0);
810
- __decorate([
811
- classTransformer.Expose({ name: 'card_holder_name' })
812
- ], Payment.prototype, "cardHolderName", void 0);
813
- __decorate([
814
- classTransformer.Expose({ name: 'card_last_digits' })
815
- ], Payment.prototype, "cardLastDigits", void 0);
816
- __decorate([
817
- classTransformer.Expose({ name: 'card_first_digits' })
818
- ], Payment.prototype, "cardFirstDigits", void 0);
819
- __decorate([
820
- classTransformer.Expose({ name: 'card_brand' })
821
- ], Payment.prototype, "cardBrand", void 0);
822
- __decorate([
823
- classTransformer.Expose({ name: 'card_pin_mode' })
824
- ], Payment.prototype, "cardPinMode", void 0);
825
- __decorate([
826
- classTransformer.Expose({ name: 'card_magstripe_fallback' })
827
- ], Payment.prototype, "cardMagstripeFallback", void 0);
828
- __decorate([
829
- classTransformer.Expose({ name: 'cvm_pin' })
830
- ], Payment.prototype, "cvmPin", void 0);
831
- __decorate([
832
- classTransformer.Expose({ name: 'postback_url' })
833
- ], Payment.prototype, "postbackUrl", void 0);
834
- __decorate([
835
- classTransformer.Expose({ name: 'payment_method' })
836
- ], Payment.prototype, "paymentMethod", void 0);
837
- __decorate([
838
- classTransformer.Expose({ name: 'capture_method' })
839
- ], Payment.prototype, "captureMethod", void 0);
840
- __decorate([
841
- classTransformer.Expose({ name: 'antifraud_score' })
842
- ], Payment.prototype, "antifraudScore", void 0);
843
- __decorate([
844
- classTransformer.Expose({ name: 'boleto_url' })
845
- ], Payment.prototype, "boletoUrl", void 0);
846
- __decorate([
847
- classTransformer.Expose({ name: 'boleto_barcode' })
848
- ], Payment.prototype, "boletoBarcode", void 0);
849
- __decorate([
850
- classTransformer.Expose({ name: 'boleto_expiration_date' })
851
- ], Payment.prototype, "boletoExpirationDate", void 0);
989
+ classTransformer.Type(function () { return LineItem; }),
990
+ __metadata("design:type", Array)
991
+ ], Checkout.prototype, "lineItems", void 0);
852
992
  __decorate([
853
- classTransformer.Expose({ name: 'subscription_id' })
854
- ], Payment.prototype, "subscriptionId", void 0);
855
- __decorate([
856
- classTransformer.Expose({ name: 'split_rules' })
857
- ], Payment.prototype, "splitRules", void 0);
993
+ classTransformer.Type(function () { return User; }),
994
+ __metadata("design:type", User)
995
+ ], Checkout.prototype, "user", void 0);
858
996
  __decorate([
859
- classTransformer.Expose({ name: 'antifraud_metadata' })
860
- ], Payment.prototype, "antifraudMetadata", void 0);
997
+ classTransformer.Type(function () { return Address; }),
998
+ __metadata("design:type", Address)
999
+ ], Checkout.prototype, "shippingAddress", void 0);
861
1000
  __decorate([
862
- classTransformer.Expose({ name: 'reference_key' })
863
- ], Payment.prototype, "referenceKey", void 0);
1001
+ classTransformer.Type(function () { return Address; }),
1002
+ __metadata("design:type", Address)
1003
+ ], Checkout.prototype, "billingAddress", void 0);
864
1004
  __decorate([
865
- classTransformer.Expose({ name: 'local_transaction_id' })
866
- ], Payment.prototype, "localTransactionId", void 0);
1005
+ classTransformer.Type(function () { return ShippingMethod; }),
1006
+ __metadata("design:type", ShippingMethod)
1007
+ ], Checkout.prototype, "shipping", void 0);
867
1008
  __decorate([
868
- classTransformer.Expose({ name: 'local_time' })
869
- ], Payment.prototype, "localTime", void 0);
870
- __decorate([
871
- classTransformer.Expose({ name: 'fraud_covered' })
872
- ], Payment.prototype, "fraudCovered", void 0);
873
- __decorate([
874
- classTransformer.Expose({ name: 'fraud_reimbursed' })
875
- ], Payment.prototype, "fraudReimbursed", void 0);
876
- __decorate([
877
- classTransformer.Expose({ name: 'order_id' })
878
- ], Payment.prototype, "orderId", void 0);
879
- __decorate([
880
- classTransformer.Expose({ name: 'risk_level' })
881
- ], Payment.prototype, "riskLevel", void 0);
882
- __decorate([
883
- classTransformer.Expose({ name: 'receipt_url' })
884
- ], Payment.prototype, "receiptUrl", void 0);
885
- __decorate([
886
- classTransformer.Expose({ name: 'private_label' })
887
- ], Payment.prototype, "privateLabel", void 0);
888
- __decorate([
889
- classTransformer.Expose({ name: 'pix_qr_code' })
890
- ], Payment.prototype, "pixQrCode", void 0);
891
- __decorate([
892
- classTransformer.Expose({ name: 'pix_expiration_date' })
893
- ], Payment.prototype, "pixExpirationDate", void 0);
1009
+ classTransformer.Type(function () { return Coupon; }),
1010
+ __metadata("design:type", Coupon)
1011
+ ], Checkout.prototype, "coupon", void 0);
894
1012
 
895
- var ShippingMethod = /** @class */ (function (_super) {
896
- __extends(ShippingMethod, _super);
897
- function ShippingMethod() {
1013
+ var Order = /** @class */ (function (_super) {
1014
+ __extends(Order, _super);
1015
+ function Order() {
898
1016
  return _super !== null && _super.apply(this, arguments) || this;
899
1017
  }
900
- ShippingMethod.prototype.identifierFields = function () {
901
- return ['id'];
902
- };
903
- return ShippingMethod;
904
- }(BaseModel));
1018
+ return Order;
1019
+ }(Checkout));
1020
+ __decorate([
1021
+ classTransformer.Type(function () { return Payment; }),
1022
+ __metadata("design:type", Payment)
1023
+ ], Order.prototype, "payment", void 0);
905
1024
 
906
1025
  var CheckoutSubscription = /** @class */ (function (_super) {
907
1026
  __extends(CheckoutSubscription, _super);
@@ -913,17 +1032,22 @@
913
1032
  };
914
1033
  return CheckoutSubscription;
915
1034
  }(BaseModel));
916
-
917
- var SubscriptionPlan = /** @class */ (function (_super) {
918
- __extends(SubscriptionPlan, _super);
919
- function SubscriptionPlan() {
920
- return _super !== null && _super.apply(this, arguments) || this;
921
- }
922
- SubscriptionPlan.prototype.identifierFields = function () {
923
- return ['id'];
924
- };
925
- return SubscriptionPlan;
926
- }(BaseModel));
1035
+ __decorate([
1036
+ classTransformer.Type(function () { return Address; }),
1037
+ __metadata("design:type", Address)
1038
+ ], CheckoutSubscription.prototype, "shippingAddress", void 0);
1039
+ __decorate([
1040
+ classTransformer.Type(function () { return Address; }),
1041
+ __metadata("design:type", Address)
1042
+ ], CheckoutSubscription.prototype, "billingAddress", void 0);
1043
+ __decorate([
1044
+ classTransformer.Type(function () { return SubscriptionPlan; }),
1045
+ __metadata("design:type", SubscriptionPlan)
1046
+ ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
1047
+ __decorate([
1048
+ classTransformer.Type(function () { return Coupon; }),
1049
+ __metadata("design:type", Coupon)
1050
+ ], CheckoutSubscription.prototype, "coupon", void 0);
927
1051
 
928
1052
  var Buy2Win = /** @class */ (function (_super) {
929
1053
  __extends(Buy2Win, _super);
@@ -935,6 +1059,10 @@
935
1059
  };
936
1060
  return Buy2Win;
937
1061
  }(BaseModel));
1062
+ __decorate([
1063
+ classTransformer.Type(function () { return Category; }),
1064
+ __metadata("design:type", Array)
1065
+ ], Buy2Win.prototype, "categories", void 0);
938
1066
 
939
1067
  var Home = /** @class */ (function (_super) {
940
1068
  __extends(Home, _super);
@@ -1490,16 +1618,18 @@
1490
1618
  }
1491
1619
  CategoryFirestoreRepository.prototype.getCategoryBySlug = function (slug, shop) {
1492
1620
  return this.collection(this.collectionName)
1493
- .where("slug", "==", slug)
1494
- .where("shop", "==", shop)
1495
- .where("published", "==", true)
1496
- .get().then(function (snap) {
1621
+ .where('slug', '==', slug)
1622
+ .where('shop', '==', shop)
1623
+ .where('published', '==', true)
1624
+ .get()
1625
+ .then(function (snap) {
1497
1626
  if (snap.size > 1)
1498
- throw new DuplicatedResultsError("Query returned duplicated values");
1627
+ throw new DuplicatedResultsError('Query returned duplicated values');
1499
1628
  if (snap.empty)
1500
1629
  throw new NotFoundError("Document with slug " + slug + " not found");
1501
1630
  return snap.docs[0].data();
1502
- }).catch(function (error) { return error; });
1631
+ })
1632
+ .catch(function (error) { return error; });
1503
1633
  };
1504
1634
  CategoryFirestoreRepository.prototype.getCategoriesForHome = function (categoryIds) {
1505
1635
  return __awaiter(this, void 0, void 0, function () {
@@ -1508,13 +1638,13 @@
1508
1638
  return __generator(this, function (_b) {
1509
1639
  switch (_b.label) {
1510
1640
  case 0: return [4 /*yield*/, this.collection(this.collectionName)
1511
- .where("id", "in", categoryIds)
1512
- .where("published", "==", true)
1641
+ .where('id', 'in', categoryIds)
1642
+ .where('published', '==', true)
1513
1643
  .get()];
1514
1644
  case 1:
1515
1645
  categorySnap = _b.sent();
1516
1646
  if (categorySnap.empty)
1517
- throw new NotFoundError("Categories not found");
1647
+ throw new NotFoundError('Categories not found');
1518
1648
  categories = categorySnap.docs.map(function (doc) { return doc.data(); });
1519
1649
  homeSections = [];
1520
1650
  _b.label = 2;
@@ -1525,16 +1655,15 @@
1525
1655
  case 3:
1526
1656
  if (!!categories_1_1.done) return [3 /*break*/, 6];
1527
1657
  category = categories_1_1.value;
1528
- return [4 /*yield*/, this.collection("products")
1529
- .where("categories", "array-contains", category.id)
1530
- // .where("published", "==", true)
1531
- .where("stock.quantity", ">", 1)
1658
+ return [4 /*yield*/, this.collection('products')
1659
+ .where('categories', 'array-contains', category.id)
1660
+ .where('stock.quantity', '>', 1)
1532
1661
  .limit(4)
1533
1662
  .get()];
1534
1663
  case 4:
1535
1664
  productSnap = _b.sent();
1536
1665
  products = productSnap.docs.map(function (doc) { return doc.data(); });
1537
- homeSections.push({ title: category.name, products: products });
1666
+ homeSections.push({ category: category, products: products });
1538
1667
  _b.label = 5;
1539
1668
  case 5:
1540
1669
  categories_1_1 = categories_1.next();
@@ -1563,7 +1692,7 @@
1563
1692
  switch (_b.label) {
1564
1693
  case 0:
1565
1694
  if (!category.products)
1566
- throw new RequiredArgumentError(["Category products is empty"]);
1695
+ throw new RequiredArgumentError(['Category products is empty']);
1567
1696
  chunks = category.products.reduce(function (resultArray, item, index) {
1568
1697
  var chunkIndex = Math.floor(index / 10);
1569
1698
  if (!resultArray[chunkIndex])
@@ -1580,10 +1709,7 @@
1580
1709
  case 2:
1581
1710
  if (!!chunks_1_1.done) return [3 /*break*/, 5];
1582
1711
  productIds = chunks_1_1.value;
1583
- return [4 /*yield*/, this.collection("products")
1584
- .where("id", "in", productIds)
1585
- // .where("published", "==", true)
1586
- .get()];
1712
+ return [4 /*yield*/, this.collection('products').where('id', 'in', productIds).get()];
1587
1713
  case 3:
1588
1714
  productSnap = _b.sent();
1589
1715
  if (productSnap.empty)