@infrab4a/connect-angular 0.13.0-beta.8 → 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 (43) hide show
  1. package/bundles/infrab4a-connect-angular.umd.js +434 -299
  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 -96
  6. package/esm2015/lib/services/auth.service.js +13 -16
  7. package/esm2015/lib/services/cart.service.js +6 -2
  8. package/esm2015/lib/services/checkout-subscription.service.js +37 -6
  9. package/esm2015/lib/services/checkout.service.js +3 -3
  10. package/esm2015/lib/services/coupon.service.js +29 -10
  11. package/esm2015/lib/services/errors/group-invalid-coupon.error.js +7 -0
  12. package/esm2015/lib/services/errors/index.js +2 -1
  13. package/esm2015/lib/services/home-shop.service.js +106 -0
  14. package/esm2015/lib/services/index.js +2 -1
  15. package/esm2015/lib/services/order.service.js +13 -11
  16. package/fesm2015/infrab4a-connect-angular.js +397 -286
  17. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  18. package/lib/angular-connect.module.d.ts +4 -4
  19. package/lib/angular-firebase-auth.module.d.ts +4 -4
  20. package/lib/angular-firestore.module.d.ts +4 -3
  21. package/lib/services/auth.service.d.ts +3 -5
  22. package/lib/services/checkout-subscription.service.d.ts +7 -2
  23. package/lib/services/coupon.service.d.ts +3 -2
  24. package/lib/services/errors/group-invalid-coupon.error.d.ts +5 -0
  25. package/lib/services/errors/index.d.ts +1 -0
  26. package/lib/services/home-shop.service.d.ts +24 -0
  27. package/lib/services/index.d.ts +1 -0
  28. package/lib/services/order.service.d.ts +3 -3
  29. package/package.json +4 -3
  30. package/esm2015/lib/factories/firebase-app.factory.js +0 -18
  31. package/esm2015/lib/factories/firebase-auth.factory.js +0 -2
  32. package/esm2015/lib/factories/firebase-firestore.factory.js +0 -2
  33. package/esm2015/lib/providers/firebase-app.provider.js +0 -12
  34. package/esm2015/lib/providers/firebase-auth.provider.js +0 -15
  35. package/esm2015/lib/providers/firebase-firestore.provider.js +0 -14
  36. package/esm2015/lib/providers/index.js +0 -4
  37. package/lib/factories/firebase-app.factory.d.ts +0 -4
  38. package/lib/factories/firebase-auth.factory.d.ts +0 -2
  39. package/lib/factories/firebase-firestore.factory.d.ts +0 -2
  40. package/lib/providers/firebase-app.provider.d.ts +0 -17
  41. package/lib/providers/firebase-auth.provider.d.ts +0 -11
  42. package/lib/providers/firebase-firestore.provider.d.ts +0 -10
  43. 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,433 +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: [FirebaseFirestoreProvider, '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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider, '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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider, '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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
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: [FirebaseFirestoreProvider],
1206
+ deps: [i1$1.AngularFirestore],
971
1207
  },
972
1208
  {
973
1209
  provide: 'UserRepository',
974
1210
  useFactory: function (firestore) {
975
- return new i2.UserFirestoreRepository(firestore);
1211
+ return new i2.UserFirestoreRepository(firestore.firestore);
976
1212
  },
977
- deps: [FirebaseFirestoreProvider],
1213
+ deps: [i1$1.AngularFirestore],
978
1214
  },
979
1215
  {
980
1216
  provide: 'UserAddressRepository',
981
1217
  useFactory: function (firestore, userRepository) {
982
- return new i2.UserAddressFirestoreRepository(firestore, userRepository);
1218
+ return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
983
1219
  },
984
- deps: [FirebaseFirestoreProvider, 'UserRepository'],
1220
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
985
1221
  },
986
1222
  {
987
1223
  provide: 'UserPaymentMethodRepository',
988
1224
  useFactory: function (firestore, userRepository) {
989
- return new i2.UserPaymentMethodFirestoreRepository(firestore, userRepository);
1225
+ return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
990
1226
  },
991
- deps: [FirebaseFirestoreProvider, 'UserRepository'],
1227
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
992
1228
  },
993
1229
  {
994
1230
  provide: 'VariantRepository',
995
1231
  useFactory: function (firestore, productRepository) {
996
- return new i2.ProductVariantFirestoreRepository(firestore, productRepository);
1232
+ return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
997
1233
  },
998
- deps: [FirebaseFirestoreProvider, 'ProductRepository'],
1234
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
999
1235
  },
1000
- ] });
1236
+ ], imports: [[fire.AngularFireModule]] });
1001
1237
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1002
1238
  type: i0.NgModule,
1003
1239
  args: [{
1240
+ imports: [fire.AngularFireModule],
1004
1241
  providers: [
1005
- FirebaseAppProvider,
1006
- FirebaseFirestoreProvider,
1007
1242
  {
1008
1243
  provide: 'BeautyProfileRepository',
1009
1244
  useFactory: function (firestore, userRepository) {
1010
- return new i2.UserBeautyProfileFirestoreRepository(firestore, userRepository);
1245
+ return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1011
1246
  },
1012
- deps: [FirebaseFirestoreProvider, 'UserRepository'],
1247
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1013
1248
  },
1014
1249
  {
1015
1250
  provide: 'Buy2WinRepository',
1016
1251
  useFactory: function (firestore) {
1017
- return new i2.Buy2WinFirestoreRepository(firestore);
1252
+ return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1018
1253
  },
1019
- deps: [FirebaseFirestoreProvider],
1254
+ deps: [i1$1.AngularFirestore],
1020
1255
  },
1021
1256
  {
1022
1257
  provide: 'CategoryRepository',
1023
1258
  useFactory: function (firestore) {
1024
- return new i2.CategoryFirestoreRepository(firestore);
1259
+ return new i2.CategoryFirestoreRepository(firestore.firestore);
1025
1260
  },
1026
- deps: [FirebaseFirestoreProvider],
1261
+ deps: [i1$1.AngularFirestore],
1027
1262
  },
1028
1263
  {
1029
1264
  provide: 'CheckoutRepository',
1030
1265
  useFactory: function (firestore) {
1031
- return new i2.CheckoutFirestoreRepository(firestore);
1266
+ return new i2.CheckoutFirestoreRepository(firestore.firestore);
1032
1267
  },
1033
- deps: [FirebaseFirestoreProvider],
1268
+ deps: [i1$1.AngularFirestore],
1034
1269
  },
1035
1270
  {
1036
1271
  provide: 'CheckoutSubscriptionRepository',
1037
1272
  useFactory: function (firestore) {
1038
- return new i2.CheckoutSubscriptionFirestoreRepository(firestore);
1273
+ return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1039
1274
  },
1040
- deps: [FirebaseFirestoreProvider],
1275
+ deps: [i1$1.AngularFirestore],
1041
1276
  },
1042
1277
  {
1043
1278
  provide: 'CouponRepository',
1044
1279
  useFactory: function (firestore) {
1045
- return new i2.CouponFirestoreRepository(firestore);
1280
+ return new i2.CouponFirestoreRepository(firestore.firestore);
1046
1281
  },
1047
- deps: [FirebaseFirestoreProvider],
1282
+ deps: [i1$1.AngularFirestore],
1048
1283
  },
1049
1284
  {
1050
1285
  provide: 'EditionRepository',
1051
1286
  useFactory: function (firestore, subscriptionRepository) {
1052
- return new i2.SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
1287
+ return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1053
1288
  },
1054
- deps: [FirebaseFirestoreProvider, 'SubscriptionRepository'],
1289
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1055
1290
  },
1056
1291
  {
1057
1292
  provide: 'HomeRepository',
1058
1293
  useFactory: function (firestore) {
1059
- return new i2.HomeFirestoreRepository(firestore);
1294
+ return new i2.HomeFirestoreRepository(firestore.firestore);
1060
1295
  },
1061
- deps: [FirebaseFirestoreProvider],
1296
+ deps: [i1$1.AngularFirestore],
1062
1297
  },
1063
1298
  {
1064
1299
  provide: 'LeadRepository',
1065
1300
  useFactory: function (firestore) {
1066
- return new i2.LeadFirestoreRepository(firestore);
1301
+ return new i2.LeadFirestoreRepository(firestore.firestore);
1067
1302
  },
1068
- deps: [FirebaseFirestoreProvider],
1303
+ deps: [i1$1.AngularFirestore],
1069
1304
  },
1070
1305
  {
1071
1306
  provide: 'LegacyOrderRepository',
1072
1307
  useFactory: function (firestore) {
1073
- return new i2.LegacyOrderFirestoreRepository(firestore);
1308
+ return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1074
1309
  },
1075
- deps: [FirebaseFirestoreProvider],
1310
+ deps: [i1$1.AngularFirestore],
1076
1311
  },
1077
1312
  {
1078
1313
  provide: 'ShopMenuRepository',
1079
1314
  useFactory: function (firestore) {
1080
- return new i2.ShopMenuFirestoreRepository(firestore);
1315
+ return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1081
1316
  },
1082
- deps: [FirebaseFirestoreProvider],
1317
+ deps: [i1$1.AngularFirestore],
1083
1318
  },
1084
1319
  {
1085
1320
  provide: 'OrderRepository',
1086
1321
  useFactory: function (firestore) {
1087
- return new i2.OrderFirestoreRepository(firestore);
1322
+ return new i2.OrderFirestoreRepository(firestore.firestore);
1088
1323
  },
1089
- deps: [FirebaseFirestoreProvider],
1324
+ deps: [i1$1.AngularFirestore],
1090
1325
  },
1091
1326
  {
1092
1327
  provide: 'PaymentRepository',
1093
1328
  useFactory: function (firestore) {
1094
- return new i2.PaymentFirestoreRepository(firestore);
1329
+ return new i2.PaymentFirestoreRepository(firestore.firestore);
1095
1330
  },
1096
- deps: [FirebaseFirestoreProvider],
1331
+ deps: [i1$1.AngularFirestore],
1097
1332
  },
1098
1333
  {
1099
1334
  provide: 'ProductRepository',
1100
1335
  useFactory: function (firestore) {
1101
- return new i2.ProductFirestoreRepository(firestore);
1336
+ return new i2.ProductFirestoreRepository(firestore.firestore);
1102
1337
  },
1103
- deps: [FirebaseFirestoreProvider],
1338
+ deps: [i1$1.AngularFirestore],
1104
1339
  },
1105
1340
  {
1106
1341
  provide: 'SubscriptionPaymentRepository',
1107
1342
  useFactory: function (firestore, subscriptionRepository) {
1108
- return new i2.SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
1343
+ return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1109
1344
  },
1110
- deps: [FirebaseFirestoreProvider, 'SubscriptionRepository'],
1345
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1111
1346
  },
1112
1347
  {
1113
1348
  provide: 'SubscriptionPlanRepository',
1114
1349
  useFactory: function (firestore) {
1115
- return new i2.SubscriptionPlanFirestoreRepository(firestore);
1350
+ return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1116
1351
  },
1117
- deps: [FirebaseFirestoreProvider],
1352
+ deps: [i1$1.AngularFirestore],
1118
1353
  },
1119
1354
  {
1120
1355
  provide: 'SubscriptionProductRepository',
1121
1356
  useFactory: function (firestore) {
1122
- return new i2.SubscriptionProductFirestoreRepository(firestore);
1357
+ return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1123
1358
  },
1124
- deps: [FirebaseFirestoreProvider],
1359
+ deps: [i1$1.AngularFirestore],
1125
1360
  },
1126
1361
  {
1127
1362
  provide: 'SubscriptionRepository',
1128
1363
  useFactory: function (firestore) {
1129
- return new i2.SubscriptionFirestoreRepository(firestore);
1364
+ return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1130
1365
  },
1131
- deps: [FirebaseFirestoreProvider],
1366
+ deps: [i1$1.AngularFirestore],
1132
1367
  },
1133
1368
  {
1134
1369
  provide: 'UserRepository',
1135
1370
  useFactory: function (firestore) {
1136
- return new i2.UserFirestoreRepository(firestore);
1371
+ return new i2.UserFirestoreRepository(firestore.firestore);
1137
1372
  },
1138
- deps: [FirebaseFirestoreProvider],
1373
+ deps: [i1$1.AngularFirestore],
1139
1374
  },
1140
1375
  {
1141
1376
  provide: 'UserAddressRepository',
1142
1377
  useFactory: function (firestore, userRepository) {
1143
- return new i2.UserAddressFirestoreRepository(firestore, userRepository);
1378
+ return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1144
1379
  },
1145
- deps: [FirebaseFirestoreProvider, 'UserRepository'],
1380
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1146
1381
  },
1147
1382
  {
1148
1383
  provide: 'UserPaymentMethodRepository',
1149
1384
  useFactory: function (firestore, userRepository) {
1150
- return new i2.UserPaymentMethodFirestoreRepository(firestore, userRepository);
1385
+ return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1151
1386
  },
1152
- deps: [FirebaseFirestoreProvider, 'UserRepository'],
1387
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1153
1388
  },
1154
1389
  {
1155
1390
  provide: 'VariantRepository',
1156
1391
  useFactory: function (firestore, productRepository) {
1157
- return new i2.ProductVariantFirestoreRepository(firestore, productRepository);
1158
- },
1159
- deps: [FirebaseFirestoreProvider, 'ProductRepository'],
1160
- },
1161
- ],
1162
- }]
1163
- }] });
1164
-
1165
- var AngularFirebaseAuthModule = /** @class */ (function () {
1166
- function AngularFirebaseAuthModule() {
1167
- }
1168
- AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
1169
- return {
1170
- ngModule: AngularFirebaseAuthModule,
1171
- providers: [
1172
- { provide: FIREBASE_OPTIONS, useValue: options },
1173
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
1174
- ],
1175
- };
1176
- };
1177
- return AngularFirebaseAuthModule;
1178
- }());
1179
- AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1180
- AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [AngularFirestoreModule] });
1181
- AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
1182
- FirebaseAppProvider,
1183
- FirebaseAuthProvider,
1184
- {
1185
- provide: 'Authentication',
1186
- useFactory: function (authenticationService, userRepository) {
1187
- return new i2.Authentication(authenticationService, userRepository);
1188
- },
1189
- deps: ['AuthenticationService', 'UserRepository'],
1190
- },
1191
- {
1192
- provide: 'AuthenticationService',
1193
- useFactory: function (app) {
1194
- return new i2.AuthenticationFirebaseAuthService(app.auth());
1195
- },
1196
- deps: [FirebaseAppProvider],
1197
- },
1198
- {
1199
- provide: 'Register',
1200
- useFactory: function (registerService, userRepository) {
1201
- return new i2.Register(registerService, userRepository);
1202
- },
1203
- deps: ['RegisterService', 'UserRepository'],
1204
- },
1205
- {
1206
- provide: 'RegisterService',
1207
- useFactory: function (app) {
1208
- return new i2.RegisterFirebaseAuthService(app.auth());
1209
- },
1210
- deps: [FirebaseAppProvider],
1211
- },
1212
- {
1213
- provide: 'SignOut',
1214
- useFactory: function (authenticationService) {
1215
- return new i2.SignOut(authenticationService);
1216
- },
1217
- deps: ['AuthenticationService'],
1218
- },
1219
- ], imports: [[AngularFirestoreModule]] });
1220
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1221
- type: i0.NgModule,
1222
- args: [{
1223
- imports: [AngularFirestoreModule],
1224
- providers: [
1225
- FirebaseAppProvider,
1226
- FirebaseAuthProvider,
1227
- {
1228
- provide: 'Authentication',
1229
- useFactory: function (authenticationService, userRepository) {
1230
- return new i2.Authentication(authenticationService, userRepository);
1231
- },
1232
- deps: ['AuthenticationService', 'UserRepository'],
1233
- },
1234
- {
1235
- provide: 'AuthenticationService',
1236
- useFactory: function (app) {
1237
- return new i2.AuthenticationFirebaseAuthService(app.auth());
1238
- },
1239
- deps: [FirebaseAppProvider],
1240
- },
1241
- {
1242
- provide: 'Register',
1243
- useFactory: function (registerService, userRepository) {
1244
- return new i2.Register(registerService, userRepository);
1245
- },
1246
- deps: ['RegisterService', 'UserRepository'],
1247
- },
1248
- {
1249
- provide: 'RegisterService',
1250
- useFactory: function (app) {
1251
- return new i2.RegisterFirebaseAuthService(app.auth());
1392
+ return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1252
1393
  },
1253
- deps: [FirebaseAppProvider],
1254
- },
1255
- {
1256
- provide: 'SignOut',
1257
- useFactory: function (authenticationService) {
1258
- return new i2.SignOut(authenticationService);
1259
- },
1260
- deps: ['AuthenticationService'],
1394
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1261
1395
  },
1262
1396
  ],
1263
1397
  }]
@@ -1269,34 +1403,34 @@
1269
1403
  AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1270
1404
  return {
1271
1405
  ngModule: AngularConnectModule,
1272
- 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 }]))),
1273
1407
  };
1274
1408
  };
1275
1409
  return AngularConnectModule;
1276
1410
  }());
1277
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 });
1278
- 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] });
1279
1413
  AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
1280
1414
  AuthService,
1281
1415
  CartService,
1282
1416
  CheckoutService,
1283
1417
  CheckoutSubscriptionService,
1284
1418
  CouponService,
1419
+ HomeShopService,
1285
1420
  OrderService,
1286
- FirebaseAppProvider,
1287
- ], imports: [[AngularFirebaseAuthModule, AngularFirestoreModule]] });
1421
+ ], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1288
1422
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1289
1423
  type: i0.NgModule,
1290
1424
  args: [{
1291
- imports: [AngularFirebaseAuthModule, AngularFirestoreModule],
1425
+ imports: [fire.AngularFireModule, AngularFirestoreModule],
1292
1426
  providers: [
1293
1427
  AuthService,
1294
1428
  CartService,
1295
1429
  CheckoutService,
1296
1430
  CheckoutSubscriptionService,
1297
1431
  CouponService,
1432
+ HomeShopService,
1298
1433
  OrderService,
1299
- FirebaseAppProvider,
1300
1434
  ],
1301
1435
  }]
1302
1436
  }] });
@@ -1313,6 +1447,7 @@
1313
1447
  exports.CheckoutService = CheckoutService;
1314
1448
  exports.CheckoutSubscriptionService = CheckoutSubscriptionService;
1315
1449
  exports.CouponService = CouponService;
1450
+ exports.HomeShopService = HomeShopService;
1316
1451
  exports.OrderService = OrderService;
1317
1452
 
1318
1453
  Object.defineProperty(exports, '__esModule', { value: true });