@infrab4a/connect-angular 0.5.0-beta.21 → 0.5.0-beta.3

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.
@@ -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('@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, i1$1, cookie, i1$2, fire) { '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'), require('@angular/fire/firestore')) :
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', '@angular/fire/firestore'], 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, global.ng.fire.firestore));
5
+ })(this, (function (exports, i0, rxjs, operators, i1, connect, cookie, fire, firestore) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -26,9 +26,7 @@
26
26
 
27
27
  var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
28
  var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
29
- var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
30
29
  var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
31
- var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
32
30
 
33
31
  var AuthService = /** @class */ (function () {
34
32
  function AuthService(angularFireAuth, userRepository) {
@@ -55,8 +53,6 @@
55
53
  }] }];
56
54
  } });
57
55
 
58
- var DEFAULT_SHOP = 'DEFAULT_SHOP';
59
-
60
56
  /*! *****************************************************************************
61
57
  Copyright (c) Microsoft Corporation.
62
58
 
@@ -376,37 +372,29 @@
376
372
  }
377
373
 
378
374
  var CheckoutService = /** @class */ (function () {
379
- function CheckoutService(checkoutRepository, userRepository, defaultShop) {
375
+ function CheckoutService(checkoutRepository, userRepository) {
380
376
  this.checkoutRepository = checkoutRepository;
381
377
  this.userRepository = userRepository;
382
- this.defaultShop = defaultShop;
383
378
  }
384
- CheckoutService.prototype.getCheckout = function (checkoutData) {
379
+ CheckoutService.prototype.getCheckout = function () {
385
380
  var checkoutId = cookie__default["default"].get('checkoutId');
386
- if (!i1$1.isNil(checkoutId))
381
+ if (!connect.isNil(checkoutId))
387
382
  return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
388
- return rxjs.from(this.createCheckout(checkoutData));
383
+ return rxjs.from(this.createCheckout());
389
384
  };
390
385
  CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
391
386
  var _this = this;
392
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId })).pipe(operators.concatMap(function (checkout) { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? rxjs.of(checkout.user) : rxjs.from(_this.userRepository.get({ id: checkout.user.id })); }), operators.concatMap(function (user) { return rxjs.of(user) || rxjs.throwError(function () { return new i1$1.NotFoundError('User is not found'); }); }));
387
+ return rxjs.from(this.checkoutRepository.get({ id: checkoutId })).pipe(operators.mergeMap(function (checkout) { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? rxjs.of(checkout.user) : rxjs.from(_this.userRepository.get({ id: checkout.user.id })); }), operators.mergeMap(function (user) { return rxjs.of(user) || rxjs.throwError(function () { return new connect.NotFoundError('User is not found'); }); }));
393
388
  };
394
389
  CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
395
- return rxjs.from(this.checkoutRepository.update(i1$1.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
396
- };
397
- CheckoutService.prototype.updateCheckoutUser = function (checkout) {
398
- return rxjs.from(this.checkoutRepository.update(i1$1.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
390
+ return rxjs.from(this.checkoutRepository.update(connect.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
399
391
  };
400
- CheckoutService.prototype.clearCheckoutFromSession = function () {
401
- cookie__default["default"].remove('checkoutId');
402
- return rxjs.of();
403
- };
404
- CheckoutService.prototype.createCheckout = function (checkoutData) {
392
+ CheckoutService.prototype.createCheckout = function () {
405
393
  return __awaiter(this, void 0, void 0, function () {
406
394
  var checkout;
407
395
  return __generator(this, function (_b) {
408
396
  switch (_b.label) {
409
- case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i1$1.Checkout.toInstance(i1$1.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
397
+ case 0: return [4 /*yield*/, this.checkoutRepository.create({ createdAt: new Date() })];
410
398
  case 1:
411
399
  checkout = _b.sent();
412
400
  cookie__default["default"].set('checkoutId', checkout.id);
@@ -417,7 +405,7 @@
417
405
  };
418
406
  return CheckoutService;
419
407
  }());
420
- CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
408
+ CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
421
409
  CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CheckoutService });
422
410
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CheckoutService, decorators: [{
423
411
  type: i0.Injectable
@@ -428,55 +416,45 @@
428
416
  }] }, { type: undefined, decorators: [{
429
417
  type: i0.Inject,
430
418
  args: ['UserRepository']
431
- }] }, { type: i1__namespace$1.Shops, decorators: [{
432
- type: i0.Inject,
433
- args: [DEFAULT_SHOP]
434
419
  }] }];
435
420
  } });
436
421
 
437
422
  var CartService = /** @class */ (function () {
438
- function CartService(authService, checkoutService, defaultShop) {
423
+ function CartService(authService, checkoutService) {
439
424
  var _this = this;
440
425
  this.authService = authService;
441
426
  this.checkoutService = checkoutService;
442
- this.defaultShop = defaultShop;
443
- this.cartSubject = new rxjs.Subject();
444
- this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i1$1.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
427
+ this.updateLineItemInCart = function (lineItem, quantity) { return _this.checkoutService.getCheckout().pipe(operators.mergeMap(function (checkoutLoaded) {
445
428
  var _a;
446
429
  var items = [];
447
430
  var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.sku; }).indexOf(lineItem.sku);
448
431
  if (index > -1) {
449
432
  checkoutLoaded.lineItems[index].quantity += quantity;
450
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
451
433
  }
452
434
  else
453
435
  checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
454
436
  return _this.checkoutService
455
437
  .updateCheckoutLineItems(checkoutLoaded)
456
- .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
438
+ .pipe(operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }));
457
439
  })); };
458
440
  this.generateCartObject = function (items) {
459
441
  var cart = {};
460
442
  items === null || items === void 0 ? void 0 : items.forEach(function (item) {
461
443
  var _a;
462
- return (cart[item.sku] = i1$1.LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
444
+ return (cart[item.sku] = connect.LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
463
445
  });
464
446
  return cart;
465
447
  };
466
- this.buildLineItem = function (_d) {
467
- var checkout = _d.checkout, item = _d.item, quantity = _d.quantity;
468
- var _a, _b, _c;
469
- if (_this.checkMaxStock(item, quantity || 0))
448
+ this.buildLineItem = function (_c) {
449
+ var checkout = _c.checkout, item = _c.item, isSubscriber = _c.isSubscriber, quantity = _c.quantity;
450
+ var _a, _b;
451
+ if (_this.checkMaxStock(item))
470
452
  throw new Error('Desculpe! Temos apenas ' + ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) + ' em estoque.');
471
453
  var image = item.image || ((_b = item.images) === null || _b === void 0 ? void 0 : _b.shift());
454
+ var pricePaid = _this.getProductPrice({ product: item, shop: checkout.shop, isSubscriber: isSubscriber });
472
455
  var id = item.id, name = item.name, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku;
473
456
  var isGift = item.isGift || null;
474
- var pricePaid = _this.getProductPrice({
475
- product: item,
476
- shop: checkout.shop || _this.defaultShop,
477
- isSubscriber: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.isSubscriber,
478
- });
479
- return i1$1.LineItem.toInstance({
457
+ return connect.LineItem.toInstance({
480
458
  id: id,
481
459
  name: name,
482
460
  brand: brand,
@@ -486,139 +464,91 @@
486
464
  price: price,
487
465
  image: image,
488
466
  weight: weight,
489
- quantity: (item.quantity || 0) + (quantity || 0),
467
+ quantity: quantity,
490
468
  pricePaid: pricePaid,
491
469
  categories: categories,
492
470
  isGift: isGift,
493
471
  });
494
472
  };
495
- this.getProductPrice = function (_d) {
496
- var product = _d.product, shop = _d.shop, isSubscriber = _d.isSubscriber;
497
- var info = product.getInfoByShop(shop);
498
- if (product.isGift)
499
- return 0;
500
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
473
+ this.getProductPrice = function (_c) {
474
+ var product = _c.product, shop = _c.shop, isSubscriber = _c.isSubscriber;
475
+ return product.getInfoByShop(shop)[isSubscriber ? 'subscriberPrice' : 'price'];
501
476
  };
502
- this.checkMaxStock = function (item, quantity) {
477
+ this.checkMaxStock = function (item) {
503
478
  var _a;
504
479
  var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
505
- var currentItemAmount = item.quantity || 0;
506
- return currentItemAmount + quantity > maxStock;
480
+ var quantity = item.quantity || 1;
481
+ var currentItemAmount = item.quantity;
482
+ return quantity > maxStock || currentItemAmount + quantity > maxStock;
507
483
  };
508
484
  }
509
- CartService.prototype.addItem = function (item, quantity) {
485
+ CartService.prototype.addItem = function (item, quantity, checkout) {
510
486
  var _this = this;
511
487
  if (quantity === void 0) { quantity = 1; }
512
- 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 (_d) {
513
- var checkout = _d.checkout, lineItem = _d.lineItem;
514
- return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
515
- }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
488
+ return rxjs.of(checkout).pipe(operators.mergeMap(function (checkout) { return (connect.isEmpty(checkout === null || checkout === void 0 ? void 0 : checkout.id) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)); }), operators.mergeMap(function (checkout) {
489
+ var _a;
490
+ quantity = quantity || 1;
491
+ return rxjs.of((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber).pipe(operators.mergeMap(function (isSubscriber) { return isSubscriber
492
+ ? rxjs.of(isSubscriber)
493
+ : _this.checkoutService.getUserByCheckout(checkout.id).pipe(operators.catchError(function () { return rxjs.of({ isSubscriber: false }); }), operators.map(function (user) { return user.isSubscriber; })); }), operators.mergeMap(function (isSubscriber) {
494
+ return _this.getCart().pipe(operators.map(function () { return _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity, isSubscriber: isSubscriber }); }), operators.mergeMap(function (lineItem) { return _this.updateLineItemInCart(lineItem, quantity); }));
495
+ }));
496
+ }));
516
497
  };
517
498
  CartService.prototype.decreaseItem = function (item) {
518
499
  var _this = this;
519
500
  return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
520
501
  var _a;
521
502
  var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
522
- if (!i1$1.isNil(checkoutItem))
503
+ if (!connect.isNil(checkoutItem))
523
504
  checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
524
505
  return checkout;
525
- }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
506
+ }), operators.mergeMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }));
526
507
  };
527
- CartService.prototype.getCart = function (checkout) {
508
+ CartService.prototype.getCart = function () {
528
509
  var _this = this;
529
- this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
530
- return this.cartSubject;
510
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.mergeMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
531
511
  };
532
512
  CartService.prototype.getDiscount = function (coupon) {
533
513
  switch (coupon.type) {
534
- case i1$1.CouponTypes.FINANCIAL:
514
+ case connect.CouponTypes.FINANCIAL:
535
515
  return this.getFinancialDiscount(coupon);
536
- case i1$1.CouponTypes.PRODUCT:
516
+ case connect.CouponTypes.PRODUCT:
537
517
  return function (subTotalPrice) { return subTotalPrice; };
538
- case i1$1.CouponTypes.GIFTCARD:
518
+ case connect.CouponTypes.GIFTCARD:
539
519
  return this.getFinancialDiscount(coupon);
540
- case i1$1.CouponTypes.VOUCHER:
520
+ case connect.CouponTypes.VOUCHER:
541
521
  return function (subTotalPrice) { return subTotalPrice; };
542
522
  }
543
523
  };
544
524
  CartService.prototype.getVariantPriceDiscount = function (item, shop) {
545
- return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice; }, rxjs.of(item.getInfoByShop(shop).subscriberPrice), rxjs.of(item.getInfoByShop(shop).price)); }), operators.catchError(function () { return rxjs.of(item.getInfoByShop(shop).price); }));
525
+ return this.authService.getUser().pipe(operators.mergeMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice; }, rxjs.of(item.getInfoByShop(shop).subscriberPrice), rxjs.of(item.getInfoByShop(shop).price)); }), operators.catchError(function () { return rxjs.of(item.getInfoByShop(shop).price); }));
546
526
  };
547
527
  CartService.prototype.removeItem = function (item) {
548
528
  var _this = this;
549
529
  return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
550
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
551
- if (index >= 0)
552
- checkout.lineItems.splice(index, 1);
553
- return checkout;
554
- }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
555
- };
556
- CartService.prototype.updateUserCart = function (user) {
557
- var _this = this;
558
- return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i1$1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(i1$1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: checkout.lineItems.map(function (item) { return _this.buildLineItem({ checkout: checkout, item: item }); }) }))); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
559
- };
560
- CartService.prototype.clearCart = function () {
561
- var _this = this;
562
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
563
- _this.checkoutService.clearCheckoutFromSession();
530
+ checkout.lineItems.splice(checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; }), 1);
564
531
  return checkout;
565
- }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
566
- };
567
- CartService.prototype.buildCartFromCheckout = function (checkoutData) {
568
- var _this = this;
569
- return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
532
+ }), operators.mergeMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }));
570
533
  };
571
534
  CartService.prototype.getFinancialDiscount = function (coupon) {
572
535
  return function (subTotalPrice) {
573
- if (i1$1.FinancialCoupon.isFinancialCoupon(coupon))
536
+ if (connect.FinancialCoupon.isFinancialCoupon(coupon))
574
537
  switch (coupon.subtype) {
575
- case i1$1.CouponSubtypes.ABSOLUTE:
538
+ case connect.CouponSubtypes.ABSOLUTE:
576
539
  return subTotalPrice - coupon.discount * 100;
577
- case i1$1.CouponSubtypes.PERCENTAGE:
540
+ case connect.CouponSubtypes.PERCENTAGE:
578
541
  return subTotalPrice * (1 - coupon.discount / 100);
579
542
  }
580
543
  };
581
544
  };
582
545
  return CartService;
583
546
  }());
584
- CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
547
+ CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
585
548
  CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CartService });
586
549
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CartService, decorators: [{
587
550
  type: i0.Injectable
588
- }], ctorParameters: function () {
589
- return [{ type: AuthService }, { type: CheckoutService }, { type: i1__namespace$1.Shops, decorators: [{
590
- type: i0.Inject,
591
- args: [DEFAULT_SHOP]
592
- }] }];
593
- } });
594
-
595
- var OrderService = /** @class */ (function () {
596
- function OrderService(angularFirestore, orderRepository) {
597
- this.angularFirestore = angularFirestore;
598
- this.orderRepository = orderRepository;
599
- this.orderSubject = new rxjs.Subject();
600
- }
601
- OrderService.prototype.getOrder = function (id) {
602
- var _this = this;
603
- this.angularFirestore
604
- .doc(this.orderRepository.collectionName + "/" + id)
605
- .valueChanges()
606
- .pipe(operators.map(function (doc) { return i1$1.Order.toInstance(doc); }))
607
- .subscribe(function (doc) { return _this.orderSubject.next(doc); });
608
- return this.orderSubject;
609
- };
610
- return OrderService;
611
- }());
612
- OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
613
- OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: OrderService });
614
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: OrderService, decorators: [{
615
- type: i0.Injectable
616
- }], ctorParameters: function () {
617
- return [{ type: i1__namespace$2.AngularFirestore }, { type: i1__namespace$1.OrderFirestoreRepository, decorators: [{
618
- type: i0.Inject,
619
- args: ['OrderRepository']
620
- }] }];
621
- } });
551
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }]; } });
622
552
 
623
553
  var AngularFirebaseAuthModule = /** @class */ (function () {
624
554
  function AngularFirebaseAuthModule() {
@@ -640,21 +570,21 @@
640
570
  {
641
571
  provide: 'Authentication',
642
572
  useFactory: function (authenticationService, userRepository) {
643
- return new i1$1.Authentication(authenticationService, userRepository);
573
+ return new connect.Authentication(authenticationService, userRepository);
644
574
  },
645
575
  deps: ['AuthenticationService', 'UserRepository'],
646
576
  },
647
577
  {
648
578
  provide: 'AuthenticationService',
649
579
  useFactory: function (angularFireAuth) {
650
- return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
580
+ return new connect.AuthenticationFirebaseAuthService(angularFireAuth);
651
581
  },
652
582
  deps: [i1.AngularFireAuth],
653
583
  },
654
584
  {
655
585
  provide: 'SignOut',
656
586
  useFactory: function (authenticationService) {
657
- return new i1$1.SignOut(authenticationService);
587
+ return new connect.SignOut(authenticationService);
658
588
  },
659
589
  deps: ['AuthenticationService'],
660
590
  },
@@ -667,21 +597,21 @@
667
597
  {
668
598
  provide: 'Authentication',
669
599
  useFactory: function (authenticationService, userRepository) {
670
- return new i1$1.Authentication(authenticationService, userRepository);
600
+ return new connect.Authentication(authenticationService, userRepository);
671
601
  },
672
602
  deps: ['AuthenticationService', 'UserRepository'],
673
603
  },
674
604
  {
675
605
  provide: 'AuthenticationService',
676
606
  useFactory: function (angularFireAuth) {
677
- return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
607
+ return new connect.AuthenticationFirebaseAuthService(angularFireAuth);
678
608
  },
679
609
  deps: [i1.AngularFireAuth],
680
610
  },
681
611
  {
682
612
  provide: 'SignOut',
683
613
  useFactory: function (authenticationService) {
684
- return new i1$1.SignOut(authenticationService);
614
+ return new connect.SignOut(authenticationService);
685
615
  },
686
616
  deps: ['AuthenticationService'],
687
617
  },
@@ -709,128 +639,128 @@
709
639
  {
710
640
  provide: 'BeautyProfileRepository',
711
641
  useFactory: function (firestore, userRepository) {
712
- return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
642
+ return new connect.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
713
643
  },
714
- deps: [i1$2.AngularFirestore, 'UserRepository'],
644
+ deps: [firestore.AngularFirestore, 'UserRepository'],
715
645
  },
716
646
  {
717
647
  provide: 'Buy2WinRepository',
718
648
  useFactory: function (firestore) {
719
- return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
649
+ return new connect.Buy2WinFirestoreRepository(firestore.firestore);
720
650
  },
721
- deps: [i1$2.AngularFirestore],
651
+ deps: [firestore.AngularFirestore],
722
652
  },
723
653
  {
724
654
  provide: 'CategoryRepository',
725
655
  useFactory: function (firestore) {
726
- return new i1$1.CategoryFirestoreRepository(firestore.firestore);
656
+ return new connect.CategoryFirestoreRepository(firestore.firestore);
727
657
  },
728
- deps: [i1$2.AngularFirestore],
658
+ deps: [firestore.AngularFirestore],
729
659
  },
730
660
  {
731
661
  provide: 'CheckoutRepository',
732
662
  useFactory: function (firestore) {
733
- return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
663
+ return new connect.CheckoutFirestoreRepository(firestore.firestore);
734
664
  },
735
- deps: [i1$2.AngularFirestore],
665
+ deps: [firestore.AngularFirestore],
736
666
  },
737
667
  {
738
668
  provide: 'CheckoutSubscriptionRepository',
739
669
  useFactory: function (firestore) {
740
- return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
670
+ return new connect.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
741
671
  },
742
- deps: [i1$2.AngularFirestore],
672
+ deps: [firestore.AngularFirestore],
743
673
  },
744
674
  {
745
675
  provide: 'CouponRepository',
746
676
  useFactory: function (firestore) {
747
- return new i1$1.CouponFirestoreRepository(firestore.firestore);
677
+ return new connect.CouponFirestoreRepository(firestore.firestore);
748
678
  },
749
- deps: [i1$2.AngularFirestore],
679
+ deps: [firestore.AngularFirestore],
750
680
  },
751
681
  {
752
682
  provide: 'EditionRepository',
753
683
  useFactory: function (firestore, subscriptionRepository) {
754
- return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
684
+ return new connect.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
755
685
  },
756
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
686
+ deps: [firestore.AngularFirestore, 'SubscriptionRepository'],
757
687
  },
758
688
  {
759
689
  provide: 'HomeRepository',
760
690
  useFactory: function (firestore) {
761
- return new i1$1.HomeFirestoreRepository(firestore.firestore);
691
+ return new connect.HomeFirestoreRepository(firestore.firestore);
762
692
  },
763
- deps: [i1$2.AngularFirestore],
693
+ deps: [firestore.AngularFirestore],
764
694
  },
765
695
  {
766
696
  provide: 'ShopMenuRepository',
767
697
  useFactory: function (firestore) {
768
- return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
698
+ return new connect.ShopMenuFirestoreRepository(firestore.firestore);
769
699
  },
770
- deps: [i1$2.AngularFirestore],
700
+ deps: [firestore.AngularFirestore],
771
701
  },
772
702
  {
773
703
  provide: 'OrderRepository',
774
704
  useFactory: function (firestore) {
775
- return new i1$1.OrderFirestoreRepository(firestore.firestore);
705
+ return new connect.OrderFirestoreRepository(firestore.firestore);
776
706
  },
777
- deps: [i1$2.AngularFirestore],
707
+ deps: [firestore.AngularFirestore],
778
708
  },
779
709
  {
780
710
  provide: 'PaymentRepository',
781
711
  useFactory: function (firestore) {
782
- return new i1$1.PaymentFirestoreRepository(firestore.firestore);
712
+ return new connect.PaymentFirestoreRepository(firestore.firestore);
783
713
  },
784
- deps: [i1$2.AngularFirestore],
714
+ deps: [firestore.AngularFirestore],
785
715
  },
786
716
  {
787
717
  provide: 'ProductRepository',
788
718
  useFactory: function (firestore) {
789
- return new i1$1.ProductFirestoreRepository(firestore.firestore);
719
+ return new connect.ProductFirestoreRepository(firestore.firestore);
790
720
  },
791
- deps: [i1$2.AngularFirestore],
721
+ deps: [firestore.AngularFirestore],
792
722
  },
793
723
  {
794
724
  provide: 'SubscriptionPaymentRepository',
795
725
  useFactory: function (firestore, subscriptionRepository) {
796
- return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
726
+ return new connect.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
797
727
  },
798
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
728
+ deps: [firestore.AngularFirestore, 'SubscriptionRepository'],
799
729
  },
800
730
  {
801
731
  provide: 'SubscriptionPlanRepository',
802
732
  useFactory: function (firestore) {
803
- return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
733
+ return new connect.SubscriptionPlanFirestoreRepository(firestore.firestore);
804
734
  },
805
- deps: [i1$2.AngularFirestore],
735
+ deps: [firestore.AngularFirestore],
806
736
  },
807
737
  {
808
738
  provide: 'SubscriptionRepository',
809
739
  useFactory: function (firestore) {
810
- return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
740
+ return new connect.SubscriptionFirestoreRepository(firestore.firestore);
811
741
  },
812
- deps: [i1$2.AngularFirestore],
742
+ deps: [firestore.AngularFirestore],
813
743
  },
814
744
  {
815
745
  provide: 'UserRepository',
816
746
  useFactory: function (firestore) {
817
- return new i1$1.UserFirestoreRepository(firestore.firestore);
747
+ return new connect.UserFirestoreRepository(firestore.firestore);
818
748
  },
819
- deps: [i1$2.AngularFirestore],
749
+ deps: [firestore.AngularFirestore],
820
750
  },
821
751
  {
822
752
  provide: 'UserAddressRepository',
823
753
  useFactory: function (firestore, userRepository) {
824
- return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
754
+ return new connect.UserAddressFirestoreRepository(firestore.firestore, userRepository);
825
755
  },
826
- deps: [i1$2.AngularFirestore, 'UserRepository'],
756
+ deps: [firestore.AngularFirestore, 'UserRepository'],
827
757
  },
828
758
  {
829
759
  provide: 'VariantRepository',
830
760
  useFactory: function (firestore, productRepository) {
831
- return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
761
+ return new connect.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
832
762
  },
833
- deps: [i1$2.AngularFirestore, 'ProductRepository'],
763
+ deps: [firestore.AngularFirestore, 'ProductRepository'],
834
764
  },
835
765
  ], imports: [[fire.AngularFireModule]] });
836
766
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
@@ -841,128 +771,128 @@
841
771
  {
842
772
  provide: 'BeautyProfileRepository',
843
773
  useFactory: function (firestore, userRepository) {
844
- return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
774
+ return new connect.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
845
775
  },
846
- deps: [i1$2.AngularFirestore, 'UserRepository'],
776
+ deps: [firestore.AngularFirestore, 'UserRepository'],
847
777
  },
848
778
  {
849
779
  provide: 'Buy2WinRepository',
850
780
  useFactory: function (firestore) {
851
- return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
781
+ return new connect.Buy2WinFirestoreRepository(firestore.firestore);
852
782
  },
853
- deps: [i1$2.AngularFirestore],
783
+ deps: [firestore.AngularFirestore],
854
784
  },
855
785
  {
856
786
  provide: 'CategoryRepository',
857
787
  useFactory: function (firestore) {
858
- return new i1$1.CategoryFirestoreRepository(firestore.firestore);
788
+ return new connect.CategoryFirestoreRepository(firestore.firestore);
859
789
  },
860
- deps: [i1$2.AngularFirestore],
790
+ deps: [firestore.AngularFirestore],
861
791
  },
862
792
  {
863
793
  provide: 'CheckoutRepository',
864
794
  useFactory: function (firestore) {
865
- return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
795
+ return new connect.CheckoutFirestoreRepository(firestore.firestore);
866
796
  },
867
- deps: [i1$2.AngularFirestore],
797
+ deps: [firestore.AngularFirestore],
868
798
  },
869
799
  {
870
800
  provide: 'CheckoutSubscriptionRepository',
871
801
  useFactory: function (firestore) {
872
- return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
802
+ return new connect.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
873
803
  },
874
- deps: [i1$2.AngularFirestore],
804
+ deps: [firestore.AngularFirestore],
875
805
  },
876
806
  {
877
807
  provide: 'CouponRepository',
878
808
  useFactory: function (firestore) {
879
- return new i1$1.CouponFirestoreRepository(firestore.firestore);
809
+ return new connect.CouponFirestoreRepository(firestore.firestore);
880
810
  },
881
- deps: [i1$2.AngularFirestore],
811
+ deps: [firestore.AngularFirestore],
882
812
  },
883
813
  {
884
814
  provide: 'EditionRepository',
885
815
  useFactory: function (firestore, subscriptionRepository) {
886
- return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
816
+ return new connect.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
887
817
  },
888
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
818
+ deps: [firestore.AngularFirestore, 'SubscriptionRepository'],
889
819
  },
890
820
  {
891
821
  provide: 'HomeRepository',
892
822
  useFactory: function (firestore) {
893
- return new i1$1.HomeFirestoreRepository(firestore.firestore);
823
+ return new connect.HomeFirestoreRepository(firestore.firestore);
894
824
  },
895
- deps: [i1$2.AngularFirestore],
825
+ deps: [firestore.AngularFirestore],
896
826
  },
897
827
  {
898
828
  provide: 'ShopMenuRepository',
899
829
  useFactory: function (firestore) {
900
- return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
830
+ return new connect.ShopMenuFirestoreRepository(firestore.firestore);
901
831
  },
902
- deps: [i1$2.AngularFirestore],
832
+ deps: [firestore.AngularFirestore],
903
833
  },
904
834
  {
905
835
  provide: 'OrderRepository',
906
836
  useFactory: function (firestore) {
907
- return new i1$1.OrderFirestoreRepository(firestore.firestore);
837
+ return new connect.OrderFirestoreRepository(firestore.firestore);
908
838
  },
909
- deps: [i1$2.AngularFirestore],
839
+ deps: [firestore.AngularFirestore],
910
840
  },
911
841
  {
912
842
  provide: 'PaymentRepository',
913
843
  useFactory: function (firestore) {
914
- return new i1$1.PaymentFirestoreRepository(firestore.firestore);
844
+ return new connect.PaymentFirestoreRepository(firestore.firestore);
915
845
  },
916
- deps: [i1$2.AngularFirestore],
846
+ deps: [firestore.AngularFirestore],
917
847
  },
918
848
  {
919
849
  provide: 'ProductRepository',
920
850
  useFactory: function (firestore) {
921
- return new i1$1.ProductFirestoreRepository(firestore.firestore);
851
+ return new connect.ProductFirestoreRepository(firestore.firestore);
922
852
  },
923
- deps: [i1$2.AngularFirestore],
853
+ deps: [firestore.AngularFirestore],
924
854
  },
925
855
  {
926
856
  provide: 'SubscriptionPaymentRepository',
927
857
  useFactory: function (firestore, subscriptionRepository) {
928
- return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
858
+ return new connect.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
929
859
  },
930
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
860
+ deps: [firestore.AngularFirestore, 'SubscriptionRepository'],
931
861
  },
932
862
  {
933
863
  provide: 'SubscriptionPlanRepository',
934
864
  useFactory: function (firestore) {
935
- return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
865
+ return new connect.SubscriptionPlanFirestoreRepository(firestore.firestore);
936
866
  },
937
- deps: [i1$2.AngularFirestore],
867
+ deps: [firestore.AngularFirestore],
938
868
  },
939
869
  {
940
870
  provide: 'SubscriptionRepository',
941
871
  useFactory: function (firestore) {
942
- return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
872
+ return new connect.SubscriptionFirestoreRepository(firestore.firestore);
943
873
  },
944
- deps: [i1$2.AngularFirestore],
874
+ deps: [firestore.AngularFirestore],
945
875
  },
946
876
  {
947
877
  provide: 'UserRepository',
948
878
  useFactory: function (firestore) {
949
- return new i1$1.UserFirestoreRepository(firestore.firestore);
879
+ return new connect.UserFirestoreRepository(firestore.firestore);
950
880
  },
951
- deps: [i1$2.AngularFirestore],
881
+ deps: [firestore.AngularFirestore],
952
882
  },
953
883
  {
954
884
  provide: 'UserAddressRepository',
955
885
  useFactory: function (firestore, userRepository) {
956
- return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
886
+ return new connect.UserAddressFirestoreRepository(firestore.firestore, userRepository);
957
887
  },
958
- deps: [i1$2.AngularFirestore, 'UserRepository'],
888
+ deps: [firestore.AngularFirestore, 'UserRepository'],
959
889
  },
960
890
  {
961
891
  provide: 'VariantRepository',
962
892
  useFactory: function (firestore, productRepository) {
963
- return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
893
+ return new connect.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
964
894
  },
965
- deps: [i1$2.AngularFirestore, 'ProductRepository'],
895
+ deps: [firestore.AngularFirestore, 'ProductRepository'],
966
896
  },
967
897
  ],
968
898
  }]
@@ -971,22 +901,25 @@
971
901
  var AngularConnectModule = /** @class */ (function () {
972
902
  function AngularConnectModule() {
973
903
  }
974
- AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
904
+ AngularConnectModule.initializeApp = function (options, nameOrConfig) {
975
905
  return {
976
906
  ngModule: AngularConnectModule,
977
- providers: __spreadArray(__spreadArray(__spreadArray([], __read((i1$1.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i1$1.isNil(options) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options }]))), __read((i1$1.isNil(options) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))),
907
+ providers: [
908
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
909
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
910
+ ],
978
911
  };
979
912
  };
980
913
  return AngularConnectModule;
981
914
  }());
982
915
  AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
983
916
  AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
984
- AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, OrderService], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
917
+ AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
985
918
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
986
919
  type: i0.NgModule,
987
920
  args: [{
988
921
  imports: [fire.AngularFireModule, AngularFirestoreModule],
989
- providers: [AuthService, CartService, CheckoutService, OrderService],
922
+ providers: [AuthService, CartService, CheckoutService],
990
923
  }]
991
924
  }] });
992
925
 
@@ -1000,7 +933,6 @@
1000
933
  exports.AuthService = AuthService;
1001
934
  exports.CartService = CartService;
1002
935
  exports.CheckoutService = CheckoutService;
1003
- exports.OrderService = OrderService;
1004
936
 
1005
937
  Object.defineProperty(exports, '__esModule', { value: true });
1006
938