@infrab4a/connect-angular 0.13.0-beta.9 → 0.13.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 (47) hide show
  1. package/bundles/infrab4a-connect-angular.umd.js +434 -314
  2. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  3. package/esm2015/lib/angular-connect.module.js +8 -9
  4. package/esm2015/lib/angular-firebase-auth.module.js +33 -23
  5. package/esm2015/lib/angular-firestore.module.js +94 -100
  6. package/esm2015/lib/index.js +1 -3
  7. package/esm2015/lib/services/auth.service.js +13 -16
  8. package/esm2015/lib/services/cart.service.js +6 -2
  9. package/esm2015/lib/services/checkout-subscription.service.js +37 -6
  10. package/esm2015/lib/services/checkout.service.js +3 -3
  11. package/esm2015/lib/services/coupon.service.js +29 -10
  12. package/esm2015/lib/services/errors/group-invalid-coupon.error.js +7 -0
  13. package/esm2015/lib/services/errors/index.js +2 -1
  14. package/esm2015/lib/services/home-shop.service.js +106 -0
  15. package/esm2015/lib/services/index.js +2 -1
  16. package/esm2015/lib/services/order.service.js +13 -11
  17. package/fesm2015/infrab4a-connect-angular.js +397 -290
  18. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  19. package/lib/angular-connect.module.d.ts +4 -4
  20. package/lib/angular-firebase-auth.module.d.ts +4 -4
  21. package/lib/angular-firestore.module.d.ts +4 -3
  22. package/lib/index.d.ts +0 -2
  23. package/lib/services/auth.service.d.ts +3 -5
  24. package/lib/services/checkout-subscription.service.d.ts +7 -2
  25. package/lib/services/coupon.service.d.ts +3 -2
  26. package/lib/services/errors/group-invalid-coupon.error.d.ts +5 -0
  27. package/lib/services/errors/index.d.ts +1 -0
  28. package/lib/services/home-shop.service.d.ts +24 -0
  29. package/lib/services/index.d.ts +1 -0
  30. package/lib/services/order.service.d.ts +3 -3
  31. package/package.json +4 -3
  32. package/esm2015/lib/factories/firebase-app.factory.js +0 -18
  33. package/esm2015/lib/factories/firebase-auth.factory.js +0 -2
  34. package/esm2015/lib/factories/firebase-firestore.factory.js +0 -2
  35. package/esm2015/lib/factories/index.js +0 -4
  36. package/esm2015/lib/providers/firebase-app.provider.js +0 -12
  37. package/esm2015/lib/providers/firebase-auth.provider.js +0 -15
  38. package/esm2015/lib/providers/firebase-firestore.provider.js +0 -14
  39. package/esm2015/lib/providers/index.js +0 -4
  40. package/lib/factories/firebase-app.factory.d.ts +0 -4
  41. package/lib/factories/firebase-auth.factory.d.ts +0 -2
  42. package/lib/factories/firebase-firestore.factory.d.ts +0 -2
  43. package/lib/factories/index.d.ts +0 -3
  44. package/lib/providers/firebase-app.provider.d.ts +0 -17
  45. package/lib/providers/firebase-auth.provider.d.ts +0 -11
  46. package/lib/providers/firebase-firestore.provider.d.ts +0 -10
  47. package/lib/providers/index.d.ts +0 -3
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('firebase'), require('@infrab4a/connect'), require('firebase/app'), require('js-cookie')) :
3
- typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', 'firebase', '@infrab4a/connect', 'firebase/app', 'js-cookie'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.firebase, global["@infrab4a/connect"], global.firebase, global["js-cookie"]));
5
- })(this, (function (exports, i0, rxjs, operators, firebase$1, i2, firebase, cookie) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('@infrab4a/connect'), require('js-cookie'), require('@angular/fire/firestore'), require('@angular/fire')) :
3
+ typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/auth', '@infrab4a/connect', 'js-cookie', '@angular/fire/firestore', '@angular/fire'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["@infrab4a/connect"], global["js-cookie"], global.ng.fire.firestore, global.ng.fire));
5
+ })(this, (function (exports, i0, rxjs, operators, i1, i2, cookie, i1$1, fire) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -25,10 +25,10 @@
25
25
  }
26
26
 
27
27
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
- var firebase__default$1 = /*#__PURE__*/_interopDefaultLegacy(firebase$1);
28
+ var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
29
29
  var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
30
- var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
31
30
  var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
31
+ var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
32
32
 
33
33
  /*! *****************************************************************************
34
34
  Copyright (c) Microsoft Corporation.
@@ -348,60 +348,14 @@
348
348
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
349
349
  }
350
350
 
351
- var FirebaseAuthFactory = function (app) { return app.auth(); };
352
-
353
- var FirebaseAppFactory = function (options, zone, nameOrConfig) {
354
- var name = ((i2.isString(nameOrConfig) && nameOrConfig) || '[DEFAULT]').toString();
355
- var config = ((i2.isObject(nameOrConfig) && nameOrConfig) || {});
356
- config.name = config.name || name;
357
- var existingApp = firebase__default["default"].apps.filter(function (firebaseApp) { return firebaseApp && firebaseApp.name === config.name; })[0];
358
- var app = existingApp || zone.runOutsideAngular(function () { return firebase__default["default"].initializeApp(options, config); });
359
- try {
360
- if (JSON.stringify(options) !== JSON.stringify(app.options)) {
361
- console.error('error', app.name + " Firebase App already initialized with different options : '.'\n }");
362
- }
363
- }
364
- catch (e) { }
365
- return app;
366
- };
367
-
368
- var FIREBASE_OPTIONS = new i0.InjectionToken('connect-angular.app.options');
369
- var FIREBASE_APP_NAME = new i0.InjectionToken('connect-angular.app.nameOrConfig');
370
- var ConnectAngularFirebaseApp = /** @class */ (function () {
371
- function ConnectAngularFirebaseApp() {
372
- }
373
- return ConnectAngularFirebaseApp;
374
- }());
375
- var FirebaseAppProvider = {
376
- provide: ConnectAngularFirebaseApp,
377
- useFactory: FirebaseAppFactory,
378
- deps: [FIREBASE_OPTIONS, i0.NgZone, [new i0.Optional(), FIREBASE_APP_NAME]],
379
- };
380
-
381
- var ConnectAngularFirebaseAuth = /** @class */ (function () {
382
- function ConnectAngularFirebaseAuth() {
383
- this.onAuthStateChanged = firebase__default$1["default"].auth().onAuthStateChanged;
384
- this.currentUser = firebase__default$1["default"].auth().currentUser;
385
- }
386
- return ConnectAngularFirebaseAuth;
387
- }());
388
- var FirebaseAuthProvider = {
389
- provide: ConnectAngularFirebaseAuth,
390
- useFactory: FirebaseAuthFactory,
391
- deps: [ConnectAngularFirebaseApp],
392
- };
393
-
394
- var fromCallback = function (cb, zone) { return new rxjs.Observable(function (subscriber) { return ({ unsubscribe: zone.runOutsideAngular(function () { return cb(subscriber); }) }); }); };
395
351
  var AuthService = /** @class */ (function () {
396
- function AuthService(firebaseAuth, userRepository, zone) {
397
- this.firebaseAuth = firebaseAuth;
352
+ function AuthService(angularFireAuth, userRepository) {
353
+ this.angularFireAuth = angularFireAuth;
398
354
  this.userRepository = userRepository;
399
- this.zone = zone;
400
355
  }
401
356
  AuthService.prototype.getAuthstate = function () {
402
- this.firebaseAuth.onAuthStateChanged(function (user) { return user; });
403
357
  var observables = [
404
- fromCallback(this.firebaseAuth.onAuthStateChanged, this.zone).pipe(operators.catchError(function () { return rxjs.of(null); })),
358
+ this.angularFireAuth.authState.pipe(operators.catchError(function () { return rxjs.of(null); })),
405
359
  this.getUser().pipe(operators.catchError(function () { return rxjs.of(null); })),
406
360
  ];
407
361
  return rxjs.combineLatest(observables).pipe(operators.map(function (_a) {
@@ -417,22 +371,22 @@
417
371
  return this.getFireUser().pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.uid; }), operators.mergeMap(function (id) { return (id ? _this.userRepository.get({ id: id }) : rxjs.of(null)); }));
418
372
  };
419
373
  AuthService.prototype.getTokenId = function () {
420
- return rxjs.from(this.firebaseAuth.currentUser.getIdToken());
374
+ return this.angularFireAuth.idToken;
421
375
  };
422
376
  AuthService.prototype.getFireUser = function () {
423
- return rxjs.of(this.firebaseAuth.currentUser).pipe(operators.catchError(function () { return rxjs.of(null); }));
377
+ return this.angularFireAuth.user.pipe(operators.catchError(function () { return rxjs.of(null); }));
424
378
  };
425
379
  return AuthService;
426
380
  }());
427
- AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, deps: [{ token: ConnectAngularFirebaseAuth }, { token: 'UserRepository' }, { token: i0__namespace.NgZone }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
381
+ AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.AngularFireAuth }, { token: 'UserRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
428
382
  AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService });
429
383
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, decorators: [{
430
384
  type: i0.Injectable
431
385
  }], ctorParameters: function () {
432
- return [{ type: ConnectAngularFirebaseAuth }, { type: undefined, decorators: [{
386
+ return [{ type: i1__namespace.AngularFireAuth }, { type: undefined, decorators: [{
433
387
  type: i0.Inject,
434
388
  args: ['UserRepository']
435
- }] }, { type: i0__namespace.NgZone }];
389
+ }] }];
436
390
  } });
437
391
 
438
392
  var DEFAULT_SHOP = 'DEFAULT_SHOP';
@@ -447,26 +401,57 @@
447
401
  return InvalidCouponError;
448
402
  }(Error));
449
403
 
404
+ var GroupInvalidCouponError = /** @class */ (function (_super) {
405
+ __extends(GroupInvalidCouponError, _super);
406
+ function GroupInvalidCouponError(errors) {
407
+ var _this = _super.call(this, 'Many coupon errors throw') || this;
408
+ _this.errors = errors;
409
+ return _this;
410
+ }
411
+ return GroupInvalidCouponError;
412
+ }(Error));
413
+
450
414
  var CouponService = /** @class */ (function () {
451
415
  function CouponService(couponRepository, defaultShop) {
416
+ var _this = this;
452
417
  this.couponRepository = couponRepository;
453
418
  this.defaultShop = defaultShop;
454
419
  this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
420
+ this.separateValidCoupons = function (coupons, userEmail) { return coupons
421
+ .map(function (coupon) {
422
+ try {
423
+ if (!i2.FinancialCoupon.isFinancialCoupon(coupon))
424
+ throw new InvalidCouponError('Coupon is not valid');
425
+ if (_this.isValidCoupon(coupon, userEmail))
426
+ return coupon;
427
+ }
428
+ catch (error) {
429
+ return error;
430
+ }
431
+ })
432
+ .reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (i2.FinancialCoupon.isFinancialCoupon(coupon)
433
+ ? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
434
+ : { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
435
+ valids: [],
436
+ invalids: [],
437
+ }); };
455
438
  }
456
- CouponService.prototype.checkCoupon = function (nickname, userEmail) {
439
+ CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType) {
457
440
  var _this = this;
458
441
  return rxjs.from(this.couponRepository.find([
459
442
  {
460
443
  nickname: { operator: i2.Where.EQUALS, value: nickname },
461
444
  shopAvailability: { operator: i2.Where.EQUALS, value: this.defaultShop },
445
+ checkoutType: { operator: i2.Where.EQUALS, value: checkoutType },
462
446
  },
463
- ])).pipe(operators.concatMap(function (coupons) { return coupons.count < 1 ? rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); }) : rxjs.of(coupons.data[0]); }), operators.concatMap(function (coupon) { return i2.FinancialCoupon.isFinancialCoupon(coupon) && _this.isValidCoupon(coupon, userEmail)
464
- ? rxjs.of(coupon)
465
- : rxjs.throwError(function () { return new InvalidCouponError('Coupon is not valid'); }); }));
447
+ ])).pipe(operators.concatMap(function (coupons) { return coupons.count < 1 ? rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); }) : rxjs.of(coupons.data); }), operators.map(function (coupons) { return _this.separateValidCoupons(coupons, userEmail); }), operators.map(function (_a) {
448
+ var valids = _a.valids, invalids = _a.invalids;
449
+ if (!valids.length)
450
+ throw new GroupInvalidCouponError(invalids);
451
+ return valids;
452
+ }));
466
453
  };
467
454
  CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
468
- if (coupon.checkoutType !== i2.CheckoutTypes.ECOMMERCE)
469
- throw new InvalidCouponError('Coupon is not ecommerce valid');
470
455
  if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i2.Exclusivities.COLLABORATORS)
471
456
  throw new InvalidCouponError('User is not a collaborator');
472
457
  if (coupon.exclusivityType === i2.Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
@@ -526,7 +511,7 @@
526
511
  var _this = this;
527
512
  return this.getCheckout().pipe(operators.concatMap(function (checkout) {
528
513
  var _a;
529
- return _this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email).pipe(operators.concatMap(function (coupon) {
514
+ return _this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, i2.CheckoutTypes.ECOMMERCE).pipe(operators.concatMap(function (coupons) { return rxjs.of(coupons.shift()); }), operators.concatMap(function (coupon) {
530
515
  var _a, _b;
531
516
  return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
532
517
  ? rxjs.from(_this.orderRepository.find([{ user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } }])).pipe(operators.concatMap(function (orders) {
@@ -631,6 +616,7 @@
631
616
  pricePaid: pricePaid,
632
617
  categories: categories,
633
618
  isGift: isGift,
619
+ costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
634
620
  });
635
621
  };
636
622
  this.getProductPrice = function (_f) {
@@ -650,7 +636,10 @@
650
636
  CartService.prototype.addItem = function (item, quantity) {
651
637
  var _this = this;
652
638
  if (quantity === void 0) { quantity = 1; }
653
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({ checkout: checkout, lineItem: _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }) }); }), operators.concatMap(function (_f) {
639
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({
640
+ checkout: checkout,
641
+ lineItem: _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }),
642
+ }); }), operators.concatMap(function (_f) {
654
643
  var checkout = _f.checkout, lineItem = _f.lineItem;
655
644
  return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
656
645
  }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
@@ -743,8 +732,26 @@
743
732
  } });
744
733
 
745
734
  var CheckoutSubscriptionService = /** @class */ (function () {
746
- function CheckoutSubscriptionService(checkoutSubscriptionRepository) {
735
+ function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
736
+ var _this = this;
747
737
  this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
738
+ this.subscriptionRepository = subscriptionRepository;
739
+ this.couponService = couponService;
740
+ this.checkCouponsWithCheckout = function (coupons, checkout) { return rxjs.forkJoin(coupons.map(function (coupon) {
741
+ var _a;
742
+ return rxjs.from(_this.subscriptionRepository.find([{ user: { email: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email }, coupon: { id: coupon.id } }])).pipe(operators.map(function (subscriptions) { return ({ coupon: coupon, subscriptions: subscriptions }); }));
743
+ })).pipe(operators.map(function (results) { return results.map(function (_b) {
744
+ var coupon = _b.coupon, subscriptions = _b.subscriptions;
745
+ if (subscriptions.data.length >= (coupon.useLimit || Infinity))
746
+ return new InvalidCouponError('Coupon is already applied');
747
+ return coupon;
748
+ }); }), operators.map(function (validatedCoupons) { return ({
749
+ valids: validatedCoupons.filter(function (coupon) { return i2.FinancialCoupon.isFinancialCoupon(coupon); }),
750
+ invalids: validatedCoupons.filter(function (coupon) { return coupon instanceof InvalidCouponError; }),
751
+ }); }), operators.concatMap(function (_b) {
752
+ var valids = _b.valids, invalids = _b.invalids;
753
+ return valids.length ? rxjs.of(valids) : rxjs.throwError(new GroupInvalidCouponError(invalids));
754
+ })); };
748
755
  }
749
756
  CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
750
757
  var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
@@ -755,11 +762,11 @@
755
762
  CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
756
763
  return __awaiter(this, void 0, void 0, function () {
757
764
  var checkout;
758
- return __generator(this, function (_a) {
759
- switch (_a.label) {
765
+ return __generator(this, function (_b) {
766
+ switch (_b.label) {
760
767
  case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i2.CheckoutSubscription.toInstance(i2.pick(checkoutData, ['user', 'shop'])).toPlain()))];
761
768
  case 1:
762
- checkout = _a.sent();
769
+ checkout = _b.sent();
763
770
  cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
764
771
  return [2 /*return*/, checkout];
765
772
  }
@@ -770,9 +777,21 @@
770
777
  cookie__default["default"].remove('checkoutSubscriptionId');
771
778
  return rxjs.of();
772
779
  };
780
+ CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
781
+ var _this = this;
782
+ return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, userEmail, i2.CheckoutTypes.SUBSCRIPTION).pipe(operators.concatMap(function (coupons) {
783
+ var couponsWithSamePlan = coupons.filter(function (coupon) { return checkout.subscriptionPlan.name === coupon.plan; });
784
+ var couponsWithNoPlan = coupons.filter(function (coupon) { return !coupon.plan; });
785
+ if (couponsWithSamePlan.length > 0)
786
+ return rxjs.of(couponsWithSamePlan);
787
+ if (couponsWithNoPlan.length > 0)
788
+ return rxjs.of(couponsWithNoPlan);
789
+ throw new Error("Coupon subscription plan is invalid.");
790
+ }), operators.concatMap(function (coupons) { var _a; return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email) ? _this.checkCouponsWithCheckout(coupons, checkout) : rxjs.of(coupons); }), operators.map(function (validatedCoupons) { return validatedCoupons.shift(); })); }));
791
+ };
773
792
  return CheckoutSubscriptionService;
774
793
  }());
775
- CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
794
+ CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
776
795
  CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
777
796
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
778
797
  type: i0.Injectable
@@ -780,50 +799,269 @@
780
799
  return [{ type: undefined, decorators: [{
781
800
  type: i0.Inject,
782
801
  args: ['CheckoutSubscriptionRepository']
783
- }] }];
802
+ }] }, { type: undefined, decorators: [{
803
+ type: i0.Inject,
804
+ args: ['SubscriptionRepository']
805
+ }] }, { type: CouponService }];
784
806
  } });
785
807
 
786
- var FirebaseFirestoreFactory = function (app) { return app.firestore(); };
787
-
788
- var ConnectAngularFirebaseFirestore = /** @class */ (function () {
789
- function ConnectAngularFirebaseFirestore() {
790
- this.doc = firebase__default$1["default"].firestore().doc;
791
- }
792
- return ConnectAngularFirebaseFirestore;
793
- }());
794
- var FirebaseFirestoreProvider = {
795
- provide: ConnectAngularFirebaseFirestore,
796
- useFactory: FirebaseFirestoreFactory,
797
- deps: [ConnectAngularFirebaseApp],
798
- };
799
-
800
808
  var OrderService = /** @class */ (function () {
801
- function OrderService(firebaseFirestore, orderRepository) {
802
- this.firebaseFirestore = firebaseFirestore;
809
+ function OrderService(angularFirestore, orderRepository) {
810
+ this.angularFirestore = angularFirestore;
803
811
  this.orderRepository = orderRepository;
804
812
  this.orderSubject = new rxjs.Subject();
805
813
  }
806
814
  OrderService.prototype.getOrder = function (id) {
807
815
  var _this = this;
808
- this.firebaseFirestore.doc(this.orderRepository.collectionName + "/" + id).onSnapshot(function (doc) {
809
- var order = i2.Order.toInstance(Object.assign(Object.assign({}, doc.data()), { id: doc.id }));
810
- _this.orderSubject.next(order);
811
- });
816
+ this.angularFirestore
817
+ .doc(this.orderRepository.collectionName + "/" + id)
818
+ .valueChanges()
819
+ .pipe(operators.map(function (doc) { return i2.Order.toInstance(doc); }))
820
+ .subscribe(function (doc) { return _this.orderSubject.next(doc); });
812
821
  return this.orderSubject;
813
822
  };
814
823
  return OrderService;
815
824
  }());
816
- OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: ConnectAngularFirebaseFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
825
+ OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
817
826
  OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
818
827
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
819
828
  type: i0.Injectable
820
829
  }], ctorParameters: function () {
821
- return [{ type: ConnectAngularFirebaseFirestore }, { type: i2__namespace.OrderFirestoreRepository, decorators: [{
830
+ return [{ type: i1__namespace$1.AngularFirestore }, { type: i2__namespace.OrderFirestoreRepository, decorators: [{
822
831
  type: i0.Inject,
823
832
  args: ['OrderRepository']
824
833
  }] }];
825
834
  } });
826
835
 
836
+ var HomeShopService = /** @class */ (function () {
837
+ function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
838
+ this.categoryRepository = categoryRepository;
839
+ this.homeRepository = homeRepository;
840
+ this.productRepository = productRepository;
841
+ this.defaultShop = defaultShop;
842
+ this.buildCategoryGroupWithRequiredData = function (group) { return ({
843
+ category: i2.Category.toInstance(i2.pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
844
+ products: group.products.map(function (product) { return i2.Product.toInstance(i2.pick(product.toPlain(), [
845
+ 'id',
846
+ 'price',
847
+ 'reviews',
848
+ 'hasVariants',
849
+ 'slug',
850
+ 'sku',
851
+ 'stock',
852
+ 'costPrice',
853
+ 'images',
854
+ 'miniatures',
855
+ ])); }),
856
+ }); };
857
+ }
858
+ Object.defineProperty(HomeShopService.prototype, "homeId", {
859
+ get: function () {
860
+ if (this.defaultShop === i2.Shops.GLAMSHOP)
861
+ return 'glamshop';
862
+ if (this.defaultShop === i2.Shops.MENSMARKET)
863
+ return 'mens_market';
864
+ return null;
865
+ },
866
+ enumerable: false,
867
+ configurable: true
868
+ });
869
+ HomeShopService.prototype.getHomeData = function () {
870
+ var _this = this;
871
+ return this.getHomeConfiguration().pipe(operators.tap(function (home) { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), operators.map(function (home) { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), operators.concatMap(function (home) { return home
872
+ ? rxjs.of(home)
873
+ : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_b) {
874
+ var _c = __read(_b, 3), discoverProducts = _c[0], featuredProducts = _c[1], verticalProducts = _c[2];
875
+ return ({
876
+ discoverProducts: discoverProducts,
877
+ featuredProducts: featuredProducts,
878
+ verticalProducts: verticalProducts,
879
+ });
880
+ }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
881
+ };
882
+ HomeShopService.prototype.getBanners = function (type) {
883
+ return this.getHomeConfiguration().pipe(operators.map(function (home) {
884
+ if (type === 'brand')
885
+ return home.brandsCarousel;
886
+ if (type === 'buyToWin')
887
+ return [home.buyToWinBanner];
888
+ if (type === 'block')
889
+ return home.blockBanners;
890
+ if (type === 'blog')
891
+ return [home.blogBanner];
892
+ }));
893
+ };
894
+ HomeShopService.prototype.getDiscoverProducts = function () {
895
+ var _this = this;
896
+ return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
897
+ };
898
+ HomeShopService.prototype.getFeaturedProducts = function () {
899
+ var _this = this;
900
+ return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
901
+ };
902
+ HomeShopService.prototype.getVerticalProducts = function () {
903
+ var _this = this;
904
+ return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.map(function (id) { return rxjs.forkJoin([
905
+ _this.categoryRepository.get({ id: id }),
906
+ _this.productRepository.find([{ categories: { operator: i2.Where.LIKE, value: [id] } }], { limit: 12 }),
907
+ ]).pipe(operators.map(function (_b) {
908
+ var _c = __read(_b, 2), category = _c[0], products = _c[1];
909
+ return ({ category: category, products: products.data });
910
+ }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
911
+ };
912
+ HomeShopService.prototype.getHomeConfiguration = function () {
913
+ var _this = this;
914
+ return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
915
+ ? rxjs.of(home)
916
+ : !_this.homeId
917
+ ? rxjs.throwError(new i2.RequiredArgumentError(['homeId']))
918
+ : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
919
+ };
920
+ HomeShopService.prototype.saveHomeData = function (homeData) {
921
+ var _this = this;
922
+ var data = {
923
+ createdAt: new Date(),
924
+ expiresAt: i2.add(new Date(), { hours: 1 }),
925
+ data: homeData,
926
+ };
927
+ return rxjs.from(this.homeRepository.update({
928
+ id: this.homeId,
929
+ data: data,
930
+ })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
931
+ };
932
+ return HomeShopService;
933
+ }());
934
+ HomeShopService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
935
+ HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
936
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
937
+ type: i0.Injectable
938
+ }], ctorParameters: function () {
939
+ return [{ type: undefined, decorators: [{
940
+ type: i0.Inject,
941
+ args: ['CategoryRepository']
942
+ }] }, { type: undefined, decorators: [{
943
+ type: i0.Inject,
944
+ args: ['HomeRepository']
945
+ }] }, { type: undefined, decorators: [{
946
+ type: i0.Inject,
947
+ args: ['ProductRepository']
948
+ }] }, { type: i2__namespace.Shops, decorators: [{
949
+ type: i0.Inject,
950
+ args: [DEFAULT_SHOP]
951
+ }] }];
952
+ } });
953
+
954
+ var AngularFirebaseAuthModule = /** @class */ (function () {
955
+ function AngularFirebaseAuthModule() {
956
+ }
957
+ AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
958
+ return {
959
+ ngModule: AngularFirebaseAuthModule,
960
+ providers: [
961
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
962
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
963
+ ],
964
+ };
965
+ };
966
+ return AngularFirebaseAuthModule;
967
+ }());
968
+ AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
969
+ AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
970
+ AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
971
+ {
972
+ provide: 'Authentication',
973
+ useFactory: function (authenticationService, userRepository) {
974
+ return new i2.Authentication(authenticationService, userRepository);
975
+ },
976
+ deps: ['AuthenticationService', 'UserRepository'],
977
+ },
978
+ {
979
+ provide: 'AuthenticationService',
980
+ useFactory: function (angularFireAuth) {
981
+ return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
982
+ },
983
+ deps: [i1.AngularFireAuth],
984
+ },
985
+ {
986
+ provide: 'Register',
987
+ useFactory: function (registerService, userRepository) {
988
+ return new i2.Register(registerService, userRepository);
989
+ },
990
+ deps: ['RegisterService', 'UserRepository'],
991
+ },
992
+ {
993
+ provide: 'RegisterService',
994
+ useFactory: function (angularFireAuth) {
995
+ return new i2.RegisterFirebaseAuthService(angularFireAuth);
996
+ },
997
+ deps: [i1.AngularFireAuth],
998
+ },
999
+ {
1000
+ provide: 'SignOut',
1001
+ useFactory: function (authenticationService) {
1002
+ return new i2.SignOut(authenticationService);
1003
+ },
1004
+ deps: ['AuthenticationService'],
1005
+ },
1006
+ {
1007
+ provide: 'RecoveryPassword',
1008
+ useFactory: function (authenticationService) {
1009
+ return new i2.RecoveryPassword(authenticationService);
1010
+ },
1011
+ deps: ['AuthenticationService'],
1012
+ },
1013
+ ], imports: [[fire.AngularFireModule]] });
1014
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1015
+ type: i0.NgModule,
1016
+ args: [{
1017
+ imports: [fire.AngularFireModule],
1018
+ providers: [
1019
+ {
1020
+ provide: 'Authentication',
1021
+ useFactory: function (authenticationService, userRepository) {
1022
+ return new i2.Authentication(authenticationService, userRepository);
1023
+ },
1024
+ deps: ['AuthenticationService', 'UserRepository'],
1025
+ },
1026
+ {
1027
+ provide: 'AuthenticationService',
1028
+ useFactory: function (angularFireAuth) {
1029
+ return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
1030
+ },
1031
+ deps: [i1.AngularFireAuth],
1032
+ },
1033
+ {
1034
+ provide: 'Register',
1035
+ useFactory: function (registerService, userRepository) {
1036
+ return new i2.Register(registerService, userRepository);
1037
+ },
1038
+ deps: ['RegisterService', 'UserRepository'],
1039
+ },
1040
+ {
1041
+ provide: 'RegisterService',
1042
+ useFactory: function (angularFireAuth) {
1043
+ return new i2.RegisterFirebaseAuthService(angularFireAuth);
1044
+ },
1045
+ deps: [i1.AngularFireAuth],
1046
+ },
1047
+ {
1048
+ provide: 'SignOut',
1049
+ useFactory: function (authenticationService) {
1050
+ return new i2.SignOut(authenticationService);
1051
+ },
1052
+ deps: ['AuthenticationService'],
1053
+ },
1054
+ {
1055
+ provide: 'RecoveryPassword',
1056
+ useFactory: function (authenticationService) {
1057
+ return new i2.RecoveryPassword(authenticationService);
1058
+ },
1059
+ deps: ['AuthenticationService'],
1060
+ },
1061
+ ],
1062
+ }]
1063
+ }] });
1064
+
827
1065
  var AngularFirestoreModule = /** @class */ (function () {
828
1066
  function AngularFirestoreModule() {
829
1067
  }
@@ -831,437 +1069,329 @@
831
1069
  return {
832
1070
  ngModule: AngularFirestoreModule,
833
1071
  providers: [
834
- { provide: FIREBASE_OPTIONS, useValue: options },
835
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
1072
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
1073
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
836
1074
  ],
837
1075
  };
838
1076
  };
839
1077
  return AngularFirestoreModule;
840
1078
  }());
841
1079
  AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
842
- AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule });
1080
+ AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule] });
843
1081
  AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
844
- FirebaseAppProvider,
845
- FirebaseFirestoreProvider,
846
1082
  {
847
1083
  provide: 'BeautyProfileRepository',
848
1084
  useFactory: function (firestore, userRepository) {
849
- return new i2.UserBeautyProfileFirestoreRepository(firestore, userRepository);
1085
+ return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
850
1086
  },
851
- deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
1087
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
852
1088
  },
853
1089
  {
854
1090
  provide: 'Buy2WinRepository',
855
1091
  useFactory: function (firestore) {
856
- return new i2.Buy2WinFirestoreRepository(firestore);
1092
+ return new i2.Buy2WinFirestoreRepository(firestore.firestore);
857
1093
  },
858
- deps: [ConnectAngularFirebaseFirestore],
1094
+ deps: [i1$1.AngularFirestore],
859
1095
  },
860
1096
  {
861
1097
  provide: 'CategoryRepository',
862
1098
  useFactory: function (firestore) {
863
- return new i2.CategoryFirestoreRepository(firestore);
1099
+ return new i2.CategoryFirestoreRepository(firestore.firestore);
864
1100
  },
865
- deps: [ConnectAngularFirebaseFirestore],
1101
+ deps: [i1$1.AngularFirestore],
866
1102
  },
867
1103
  {
868
1104
  provide: 'CheckoutRepository',
869
1105
  useFactory: function (firestore) {
870
- return new i2.CheckoutFirestoreRepository(firestore);
1106
+ return new i2.CheckoutFirestoreRepository(firestore.firestore);
871
1107
  },
872
- deps: [ConnectAngularFirebaseFirestore],
1108
+ deps: [i1$1.AngularFirestore],
873
1109
  },
874
1110
  {
875
1111
  provide: 'CheckoutSubscriptionRepository',
876
1112
  useFactory: function (firestore) {
877
- return new i2.CheckoutSubscriptionFirestoreRepository(firestore);
1113
+ return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
878
1114
  },
879
- deps: [ConnectAngularFirebaseFirestore],
1115
+ deps: [i1$1.AngularFirestore],
880
1116
  },
881
1117
  {
882
1118
  provide: 'CouponRepository',
883
1119
  useFactory: function (firestore) {
884
- return new i2.CouponFirestoreRepository(firestore);
1120
+ return new i2.CouponFirestoreRepository(firestore.firestore);
885
1121
  },
886
- deps: [ConnectAngularFirebaseFirestore],
1122
+ deps: [i1$1.AngularFirestore],
887
1123
  },
888
1124
  {
889
1125
  provide: 'EditionRepository',
890
1126
  useFactory: function (firestore, subscriptionRepository) {
891
- return new i2.SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
1127
+ return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
892
1128
  },
893
- deps: [ConnectAngularFirebaseFirestore, 'SubscriptionRepository'],
1129
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
894
1130
  },
895
1131
  {
896
1132
  provide: 'HomeRepository',
897
1133
  useFactory: function (firestore) {
898
- return new i2.HomeFirestoreRepository(firestore);
1134
+ return new i2.HomeFirestoreRepository(firestore.firestore);
899
1135
  },
900
- deps: [ConnectAngularFirebaseFirestore],
1136
+ deps: [i1$1.AngularFirestore],
901
1137
  },
902
1138
  {
903
1139
  provide: 'LeadRepository',
904
1140
  useFactory: function (firestore) {
905
- return new i2.LeadFirestoreRepository(firestore);
1141
+ return new i2.LeadFirestoreRepository(firestore.firestore);
906
1142
  },
907
- deps: [ConnectAngularFirebaseFirestore],
1143
+ deps: [i1$1.AngularFirestore],
908
1144
  },
909
1145
  {
910
1146
  provide: 'LegacyOrderRepository',
911
1147
  useFactory: function (firestore) {
912
- return new i2.LegacyOrderFirestoreRepository(firestore);
1148
+ return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
913
1149
  },
914
- deps: [ConnectAngularFirebaseFirestore],
1150
+ deps: [i1$1.AngularFirestore],
915
1151
  },
916
1152
  {
917
1153
  provide: 'ShopMenuRepository',
918
1154
  useFactory: function (firestore) {
919
- return new i2.ShopMenuFirestoreRepository(firestore);
1155
+ return new i2.ShopMenuFirestoreRepository(firestore.firestore);
920
1156
  },
921
- deps: [ConnectAngularFirebaseFirestore],
1157
+ deps: [i1$1.AngularFirestore],
922
1158
  },
923
1159
  {
924
1160
  provide: 'OrderRepository',
925
1161
  useFactory: function (firestore) {
926
- return new i2.OrderFirestoreRepository(firestore);
1162
+ return new i2.OrderFirestoreRepository(firestore.firestore);
927
1163
  },
928
- deps: [ConnectAngularFirebaseFirestore],
1164
+ deps: [i1$1.AngularFirestore],
929
1165
  },
930
1166
  {
931
1167
  provide: 'PaymentRepository',
932
1168
  useFactory: function (firestore) {
933
- return new i2.PaymentFirestoreRepository(firestore);
1169
+ return new i2.PaymentFirestoreRepository(firestore.firestore);
934
1170
  },
935
- deps: [ConnectAngularFirebaseFirestore],
1171
+ deps: [i1$1.AngularFirestore],
936
1172
  },
937
1173
  {
938
1174
  provide: 'ProductRepository',
939
1175
  useFactory: function (firestore) {
940
- return new i2.ProductFirestoreRepository(firestore);
1176
+ return new i2.ProductFirestoreRepository(firestore.firestore);
941
1177
  },
942
- deps: [ConnectAngularFirebaseFirestore],
1178
+ deps: [i1$1.AngularFirestore],
943
1179
  },
944
1180
  {
945
1181
  provide: 'SubscriptionPaymentRepository',
946
1182
  useFactory: function (firestore, subscriptionRepository) {
947
- return new i2.SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
1183
+ return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
948
1184
  },
949
- deps: [ConnectAngularFirebaseFirestore, 'SubscriptionRepository'],
1185
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
950
1186
  },
951
1187
  {
952
1188
  provide: 'SubscriptionPlanRepository',
953
1189
  useFactory: function (firestore) {
954
- return new i2.SubscriptionPlanFirestoreRepository(firestore);
1190
+ return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
955
1191
  },
956
- deps: [ConnectAngularFirebaseFirestore],
1192
+ deps: [i1$1.AngularFirestore],
957
1193
  },
958
1194
  {
959
1195
  provide: 'SubscriptionProductRepository',
960
1196
  useFactory: function (firestore) {
961
- return new i2.SubscriptionProductFirestoreRepository(firestore);
1197
+ return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
962
1198
  },
963
- deps: [ConnectAngularFirebaseFirestore],
1199
+ deps: [i1$1.AngularFirestore],
964
1200
  },
965
1201
  {
966
1202
  provide: 'SubscriptionRepository',
967
1203
  useFactory: function (firestore) {
968
- return new i2.SubscriptionFirestoreRepository(firestore);
1204
+ return new i2.SubscriptionFirestoreRepository(firestore.firestore);
969
1205
  },
970
- deps: [ConnectAngularFirebaseFirestore],
1206
+ deps: [i1$1.AngularFirestore],
971
1207
  },
972
1208
  {
973
1209
  provide: 'UserRepository',
974
1210
  useFactory: function (firestore) {
975
- console.log('teste');
976
- console.log(firestore);
977
- return new i2.UserFirestoreRepository(firestore);
1211
+ return new i2.UserFirestoreRepository(firestore.firestore);
978
1212
  },
979
- deps: [ConnectAngularFirebaseFirestore],
1213
+ deps: [i1$1.AngularFirestore],
980
1214
  },
981
1215
  {
982
1216
  provide: 'UserAddressRepository',
983
1217
  useFactory: function (firestore, userRepository) {
984
- return new i2.UserAddressFirestoreRepository(firestore, userRepository);
1218
+ return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
985
1219
  },
986
- deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
1220
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
987
1221
  },
988
1222
  {
989
1223
  provide: 'UserPaymentMethodRepository',
990
1224
  useFactory: function (firestore, userRepository) {
991
- return new i2.UserPaymentMethodFirestoreRepository(firestore, userRepository);
1225
+ return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
992
1226
  },
993
- deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
1227
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
994
1228
  },
995
1229
  {
996
1230
  provide: 'VariantRepository',
997
1231
  useFactory: function (firestore, productRepository) {
998
- return new i2.ProductVariantFirestoreRepository(firestore, productRepository);
1232
+ return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
999
1233
  },
1000
- deps: [ConnectAngularFirebaseFirestore, 'ProductRepository'],
1234
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1001
1235
  },
1002
- ] });
1236
+ ], imports: [[fire.AngularFireModule]] });
1003
1237
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1004
1238
  type: i0.NgModule,
1005
1239
  args: [{
1240
+ imports: [fire.AngularFireModule],
1006
1241
  providers: [
1007
- FirebaseAppProvider,
1008
- FirebaseFirestoreProvider,
1009
1242
  {
1010
1243
  provide: 'BeautyProfileRepository',
1011
1244
  useFactory: function (firestore, userRepository) {
1012
- return new i2.UserBeautyProfileFirestoreRepository(firestore, userRepository);
1245
+ return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1013
1246
  },
1014
- deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
1247
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1015
1248
  },
1016
1249
  {
1017
1250
  provide: 'Buy2WinRepository',
1018
1251
  useFactory: function (firestore) {
1019
- return new i2.Buy2WinFirestoreRepository(firestore);
1252
+ return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1020
1253
  },
1021
- deps: [ConnectAngularFirebaseFirestore],
1254
+ deps: [i1$1.AngularFirestore],
1022
1255
  },
1023
1256
  {
1024
1257
  provide: 'CategoryRepository',
1025
1258
  useFactory: function (firestore) {
1026
- return new i2.CategoryFirestoreRepository(firestore);
1259
+ return new i2.CategoryFirestoreRepository(firestore.firestore);
1027
1260
  },
1028
- deps: [ConnectAngularFirebaseFirestore],
1261
+ deps: [i1$1.AngularFirestore],
1029
1262
  },
1030
1263
  {
1031
1264
  provide: 'CheckoutRepository',
1032
1265
  useFactory: function (firestore) {
1033
- return new i2.CheckoutFirestoreRepository(firestore);
1266
+ return new i2.CheckoutFirestoreRepository(firestore.firestore);
1034
1267
  },
1035
- deps: [ConnectAngularFirebaseFirestore],
1268
+ deps: [i1$1.AngularFirestore],
1036
1269
  },
1037
1270
  {
1038
1271
  provide: 'CheckoutSubscriptionRepository',
1039
1272
  useFactory: function (firestore) {
1040
- return new i2.CheckoutSubscriptionFirestoreRepository(firestore);
1273
+ return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1041
1274
  },
1042
- deps: [ConnectAngularFirebaseFirestore],
1275
+ deps: [i1$1.AngularFirestore],
1043
1276
  },
1044
1277
  {
1045
1278
  provide: 'CouponRepository',
1046
1279
  useFactory: function (firestore) {
1047
- return new i2.CouponFirestoreRepository(firestore);
1280
+ return new i2.CouponFirestoreRepository(firestore.firestore);
1048
1281
  },
1049
- deps: [ConnectAngularFirebaseFirestore],
1282
+ deps: [i1$1.AngularFirestore],
1050
1283
  },
1051
1284
  {
1052
1285
  provide: 'EditionRepository',
1053
1286
  useFactory: function (firestore, subscriptionRepository) {
1054
- return new i2.SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
1287
+ return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1055
1288
  },
1056
- deps: [ConnectAngularFirebaseFirestore, 'SubscriptionRepository'],
1289
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1057
1290
  },
1058
1291
  {
1059
1292
  provide: 'HomeRepository',
1060
1293
  useFactory: function (firestore) {
1061
- return new i2.HomeFirestoreRepository(firestore);
1294
+ return new i2.HomeFirestoreRepository(firestore.firestore);
1062
1295
  },
1063
- deps: [ConnectAngularFirebaseFirestore],
1296
+ deps: [i1$1.AngularFirestore],
1064
1297
  },
1065
1298
  {
1066
1299
  provide: 'LeadRepository',
1067
1300
  useFactory: function (firestore) {
1068
- return new i2.LeadFirestoreRepository(firestore);
1301
+ return new i2.LeadFirestoreRepository(firestore.firestore);
1069
1302
  },
1070
- deps: [ConnectAngularFirebaseFirestore],
1303
+ deps: [i1$1.AngularFirestore],
1071
1304
  },
1072
1305
  {
1073
1306
  provide: 'LegacyOrderRepository',
1074
1307
  useFactory: function (firestore) {
1075
- return new i2.LegacyOrderFirestoreRepository(firestore);
1308
+ return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1076
1309
  },
1077
- deps: [ConnectAngularFirebaseFirestore],
1310
+ deps: [i1$1.AngularFirestore],
1078
1311
  },
1079
1312
  {
1080
1313
  provide: 'ShopMenuRepository',
1081
1314
  useFactory: function (firestore) {
1082
- return new i2.ShopMenuFirestoreRepository(firestore);
1315
+ return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1083
1316
  },
1084
- deps: [ConnectAngularFirebaseFirestore],
1317
+ deps: [i1$1.AngularFirestore],
1085
1318
  },
1086
1319
  {
1087
1320
  provide: 'OrderRepository',
1088
1321
  useFactory: function (firestore) {
1089
- return new i2.OrderFirestoreRepository(firestore);
1322
+ return new i2.OrderFirestoreRepository(firestore.firestore);
1090
1323
  },
1091
- deps: [ConnectAngularFirebaseFirestore],
1324
+ deps: [i1$1.AngularFirestore],
1092
1325
  },
1093
1326
  {
1094
1327
  provide: 'PaymentRepository',
1095
1328
  useFactory: function (firestore) {
1096
- return new i2.PaymentFirestoreRepository(firestore);
1329
+ return new i2.PaymentFirestoreRepository(firestore.firestore);
1097
1330
  },
1098
- deps: [ConnectAngularFirebaseFirestore],
1331
+ deps: [i1$1.AngularFirestore],
1099
1332
  },
1100
1333
  {
1101
1334
  provide: 'ProductRepository',
1102
1335
  useFactory: function (firestore) {
1103
- return new i2.ProductFirestoreRepository(firestore);
1336
+ return new i2.ProductFirestoreRepository(firestore.firestore);
1104
1337
  },
1105
- deps: [ConnectAngularFirebaseFirestore],
1338
+ deps: [i1$1.AngularFirestore],
1106
1339
  },
1107
1340
  {
1108
1341
  provide: 'SubscriptionPaymentRepository',
1109
1342
  useFactory: function (firestore, subscriptionRepository) {
1110
- return new i2.SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
1343
+ return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1111
1344
  },
1112
- deps: [ConnectAngularFirebaseFirestore, 'SubscriptionRepository'],
1345
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1113
1346
  },
1114
1347
  {
1115
1348
  provide: 'SubscriptionPlanRepository',
1116
1349
  useFactory: function (firestore) {
1117
- return new i2.SubscriptionPlanFirestoreRepository(firestore);
1350
+ return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1118
1351
  },
1119
- deps: [ConnectAngularFirebaseFirestore],
1352
+ deps: [i1$1.AngularFirestore],
1120
1353
  },
1121
1354
  {
1122
1355
  provide: 'SubscriptionProductRepository',
1123
1356
  useFactory: function (firestore) {
1124
- return new i2.SubscriptionProductFirestoreRepository(firestore);
1357
+ return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1125
1358
  },
1126
- deps: [ConnectAngularFirebaseFirestore],
1359
+ deps: [i1$1.AngularFirestore],
1127
1360
  },
1128
1361
  {
1129
1362
  provide: 'SubscriptionRepository',
1130
1363
  useFactory: function (firestore) {
1131
- return new i2.SubscriptionFirestoreRepository(firestore);
1364
+ return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1132
1365
  },
1133
- deps: [ConnectAngularFirebaseFirestore],
1366
+ deps: [i1$1.AngularFirestore],
1134
1367
  },
1135
1368
  {
1136
1369
  provide: 'UserRepository',
1137
1370
  useFactory: function (firestore) {
1138
- console.log('teste');
1139
- console.log(firestore);
1140
- return new i2.UserFirestoreRepository(firestore);
1371
+ return new i2.UserFirestoreRepository(firestore.firestore);
1141
1372
  },
1142
- deps: [ConnectAngularFirebaseFirestore],
1373
+ deps: [i1$1.AngularFirestore],
1143
1374
  },
1144
1375
  {
1145
1376
  provide: 'UserAddressRepository',
1146
1377
  useFactory: function (firestore, userRepository) {
1147
- return new i2.UserAddressFirestoreRepository(firestore, userRepository);
1378
+ return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1148
1379
  },
1149
- deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
1380
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1150
1381
  },
1151
1382
  {
1152
1383
  provide: 'UserPaymentMethodRepository',
1153
1384
  useFactory: function (firestore, userRepository) {
1154
- return new i2.UserPaymentMethodFirestoreRepository(firestore, userRepository);
1385
+ return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1155
1386
  },
1156
- deps: [ConnectAngularFirebaseFirestore, 'UserRepository'],
1387
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1157
1388
  },
1158
1389
  {
1159
1390
  provide: 'VariantRepository',
1160
1391
  useFactory: function (firestore, productRepository) {
1161
- return new i2.ProductVariantFirestoreRepository(firestore, productRepository);
1162
- },
1163
- deps: [ConnectAngularFirebaseFirestore, 'ProductRepository'],
1164
- },
1165
- ],
1166
- }]
1167
- }] });
1168
-
1169
- var AngularFirebaseAuthModule = /** @class */ (function () {
1170
- function AngularFirebaseAuthModule() {
1171
- }
1172
- AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
1173
- return {
1174
- ngModule: AngularFirebaseAuthModule,
1175
- providers: [
1176
- { provide: FIREBASE_OPTIONS, useValue: options },
1177
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
1178
- ],
1179
- };
1180
- };
1181
- return AngularFirebaseAuthModule;
1182
- }());
1183
- AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1184
- AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [AngularFirestoreModule] });
1185
- AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
1186
- FirebaseAppProvider,
1187
- FirebaseAuthProvider,
1188
- {
1189
- provide: 'Authentication',
1190
- useFactory: function (authenticationService, userRepository) {
1191
- return new i2.Authentication(authenticationService, userRepository);
1192
- },
1193
- deps: ['AuthenticationService', 'UserRepository'],
1194
- },
1195
- {
1196
- provide: 'AuthenticationService',
1197
- useFactory: function (auth) {
1198
- return new i2.AuthenticationFirebaseAuthService(auth);
1199
- },
1200
- deps: [ConnectAngularFirebaseAuth],
1201
- },
1202
- {
1203
- provide: 'Register',
1204
- useFactory: function (registerService, userRepository) {
1205
- return new i2.Register(registerService, userRepository);
1206
- },
1207
- deps: ['RegisterService', 'UserRepository'],
1208
- },
1209
- {
1210
- provide: 'RegisterService',
1211
- useFactory: function (auth) {
1212
- return new i2.RegisterFirebaseAuthService(auth);
1213
- },
1214
- deps: [ConnectAngularFirebaseAuth],
1215
- },
1216
- {
1217
- provide: 'SignOut',
1218
- useFactory: function (authenticationService) {
1219
- return new i2.SignOut(authenticationService);
1220
- },
1221
- deps: ['AuthenticationService'],
1222
- },
1223
- ], imports: [[AngularFirestoreModule]] });
1224
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1225
- type: i0.NgModule,
1226
- args: [{
1227
- imports: [AngularFirestoreModule],
1228
- providers: [
1229
- FirebaseAppProvider,
1230
- FirebaseAuthProvider,
1231
- {
1232
- provide: 'Authentication',
1233
- useFactory: function (authenticationService, userRepository) {
1234
- return new i2.Authentication(authenticationService, userRepository);
1235
- },
1236
- deps: ['AuthenticationService', 'UserRepository'],
1237
- },
1238
- {
1239
- provide: 'AuthenticationService',
1240
- useFactory: function (auth) {
1241
- return new i2.AuthenticationFirebaseAuthService(auth);
1242
- },
1243
- deps: [ConnectAngularFirebaseAuth],
1244
- },
1245
- {
1246
- provide: 'Register',
1247
- useFactory: function (registerService, userRepository) {
1248
- return new i2.Register(registerService, userRepository);
1249
- },
1250
- deps: ['RegisterService', 'UserRepository'],
1251
- },
1252
- {
1253
- provide: 'RegisterService',
1254
- useFactory: function (auth) {
1255
- return new i2.RegisterFirebaseAuthService(auth);
1392
+ return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1256
1393
  },
1257
- deps: [ConnectAngularFirebaseAuth],
1258
- },
1259
- {
1260
- provide: 'SignOut',
1261
- useFactory: function (authenticationService) {
1262
- return new i2.SignOut(authenticationService);
1263
- },
1264
- deps: ['AuthenticationService'],
1394
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1265
1395
  },
1266
1396
  ],
1267
1397
  }]
@@ -1273,34 +1403,34 @@
1273
1403
  AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1274
1404
  return {
1275
1405
  ngModule: AngularConnectModule,
1276
- providers: __spreadArray(__spreadArray(__spreadArray([], __read((i2.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i2.isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]))), __read((i2.isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]))),
1406
+ providers: __spreadArray(__spreadArray(__spreadArray([], __read((i2.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i2.isNil(options) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options }]))), __read((i2.isNil(options) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))),
1277
1407
  };
1278
1408
  };
1279
1409
  return AngularConnectModule;
1280
1410
  }());
1281
1411
  AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1282
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [AngularFirebaseAuthModule, AngularFirestoreModule] });
1412
+ AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
1283
1413
  AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
1284
1414
  AuthService,
1285
1415
  CartService,
1286
1416
  CheckoutService,
1287
1417
  CheckoutSubscriptionService,
1288
1418
  CouponService,
1419
+ HomeShopService,
1289
1420
  OrderService,
1290
- FirebaseAppProvider,
1291
- ], imports: [[AngularFirebaseAuthModule, AngularFirestoreModule]] });
1421
+ ], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1292
1422
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1293
1423
  type: i0.NgModule,
1294
1424
  args: [{
1295
- imports: [AngularFirebaseAuthModule, AngularFirestoreModule],
1425
+ imports: [fire.AngularFireModule, AngularFirestoreModule],
1296
1426
  providers: [
1297
1427
  AuthService,
1298
1428
  CartService,
1299
1429
  CheckoutService,
1300
1430
  CheckoutSubscriptionService,
1301
1431
  CouponService,
1432
+ HomeShopService,
1302
1433
  OrderService,
1303
- FirebaseAppProvider,
1304
1434
  ],
1305
1435
  }]
1306
1436
  }] });
@@ -1316,18 +1446,8 @@
1316
1446
  exports.CartService = CartService;
1317
1447
  exports.CheckoutService = CheckoutService;
1318
1448
  exports.CheckoutSubscriptionService = CheckoutSubscriptionService;
1319
- exports.ConnectAngularFirebaseApp = ConnectAngularFirebaseApp;
1320
- exports.ConnectAngularFirebaseAuth = ConnectAngularFirebaseAuth;
1321
- exports.ConnectAngularFirebaseFirestore = ConnectAngularFirebaseFirestore;
1322
1449
  exports.CouponService = CouponService;
1323
- exports.FIREBASE_APP_NAME = FIREBASE_APP_NAME;
1324
- exports.FIREBASE_OPTIONS = FIREBASE_OPTIONS;
1325
- exports.FirebaseAppFactory = FirebaseAppFactory;
1326
- exports.FirebaseAppProvider = FirebaseAppProvider;
1327
- exports.FirebaseAuthFactory = FirebaseAuthFactory;
1328
- exports.FirebaseAuthProvider = FirebaseAuthProvider;
1329
- exports.FirebaseFirestoreFactory = FirebaseFirestoreFactory;
1330
- exports.FirebaseFirestoreProvider = FirebaseFirestoreProvider;
1450
+ exports.HomeShopService = HomeShopService;
1331
1451
  exports.OrderService = OrderService;
1332
1452
 
1333
1453
  Object.defineProperty(exports, '__esModule', { value: true });