@infrab4a/connect-angular 0.5.0-beta.20 → 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());
472
- var pricePaid = _this.getProductPrice({
473
- product: item,
474
- shop: checkout.shop || _this.defaultShop,
475
- isSubscriber: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.isSubscriber,
476
- });
454
+ var pricePaid = _this.getProductPrice({ product: item, shop: checkout.shop, isSubscriber: isSubscriber });
477
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;
478
456
  var isGift = item.isGift || null;
479
- return i1$1.LineItem.toInstance({
457
+ return connect.LineItem.toInstance({
480
458
  id: id,
481
459
  name: name,
482
460
  brand: brand,
@@ -486,137 +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
- 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'];
499
476
  };
500
- this.checkMaxStock = function (item, quantity) {
477
+ this.checkMaxStock = function (item) {
501
478
  var _a;
502
479
  var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
503
- var currentItemAmount = item.quantity || 0;
504
- return currentItemAmount + quantity > maxStock;
480
+ var quantity = item.quantity || 1;
481
+ var currentItemAmount = item.quantity;
482
+ return quantity > maxStock || currentItemAmount + quantity > maxStock;
505
483
  };
506
484
  }
507
- CartService.prototype.addItem = function (item, quantity) {
485
+ CartService.prototype.addItem = function (item, quantity, checkout) {
508
486
  var _this = this;
509
487
  if (quantity === void 0) { quantity = 1; }
510
- 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) {
511
- var checkout = _d.checkout, lineItem = _d.lineItem;
512
- return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
513
- }), 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
+ }));
514
497
  };
515
498
  CartService.prototype.decreaseItem = function (item) {
516
499
  var _this = this;
517
500
  return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
518
501
  var _a;
519
502
  var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
520
- if (!i1$1.isNil(checkoutItem))
503
+ if (!connect.isNil(checkoutItem))
521
504
  checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
522
505
  return checkout;
523
- }), 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); }));
524
507
  };
525
- CartService.prototype.getCart = function (checkout) {
508
+ CartService.prototype.getCart = function () {
526
509
  var _this = this;
527
- this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
528
- 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)); }));
529
511
  };
530
512
  CartService.prototype.getDiscount = function (coupon) {
531
513
  switch (coupon.type) {
532
- case i1$1.CouponTypes.FINANCIAL:
514
+ case connect.CouponTypes.FINANCIAL:
533
515
  return this.getFinancialDiscount(coupon);
534
- case i1$1.CouponTypes.PRODUCT:
516
+ case connect.CouponTypes.PRODUCT:
535
517
  return function (subTotalPrice) { return subTotalPrice; };
536
- case i1$1.CouponTypes.GIFTCARD:
518
+ case connect.CouponTypes.GIFTCARD:
537
519
  return this.getFinancialDiscount(coupon);
538
- case i1$1.CouponTypes.VOUCHER:
520
+ case connect.CouponTypes.VOUCHER:
539
521
  return function (subTotalPrice) { return subTotalPrice; };
540
522
  }
541
523
  };
542
524
  CartService.prototype.getVariantPriceDiscount = function (item, shop) {
543
- 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); }));
544
526
  };
545
527
  CartService.prototype.removeItem = function (item) {
546
528
  var _this = this;
547
529
  return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
548
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
549
- if (index >= 0)
550
- checkout.lineItems.splice(index, 1);
551
- return checkout;
552
- }), 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); }));
553
- };
554
- CartService.prototype.updateUserCart = function (user) {
555
- var _this = this;
556
- 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); }));
557
- };
558
- CartService.prototype.clearCart = function () {
559
- var _this = this;
560
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
561
- _this.checkoutService.clearCheckoutFromSession();
530
+ checkout.lineItems.splice(checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; }), 1);
562
531
  return checkout;
563
- }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
564
- };
565
- CartService.prototype.buildCartFromCheckout = function (checkoutData) {
566
- var _this = this;
567
- 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); }));
568
533
  };
569
534
  CartService.prototype.getFinancialDiscount = function (coupon) {
570
535
  return function (subTotalPrice) {
571
- if (i1$1.FinancialCoupon.isFinancialCoupon(coupon))
536
+ if (connect.FinancialCoupon.isFinancialCoupon(coupon))
572
537
  switch (coupon.subtype) {
573
- case i1$1.CouponSubtypes.ABSOLUTE:
538
+ case connect.CouponSubtypes.ABSOLUTE:
574
539
  return subTotalPrice - coupon.discount * 100;
575
- case i1$1.CouponSubtypes.PERCENTAGE:
540
+ case connect.CouponSubtypes.PERCENTAGE:
576
541
  return subTotalPrice * (1 - coupon.discount / 100);
577
542
  }
578
543
  };
579
544
  };
580
545
  return CartService;
581
546
  }());
582
- 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 });
583
548
  CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CartService });
584
549
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: CartService, decorators: [{
585
550
  type: i0.Injectable
586
- }], ctorParameters: function () {
587
- return [{ type: AuthService }, { type: CheckoutService }, { type: i1__namespace$1.Shops, decorators: [{
588
- type: i0.Inject,
589
- args: [DEFAULT_SHOP]
590
- }] }];
591
- } });
592
-
593
- var OrderService = /** @class */ (function () {
594
- function OrderService(angularFirestore, orderRepository) {
595
- this.angularFirestore = angularFirestore;
596
- this.orderRepository = orderRepository;
597
- this.orderSubject = new rxjs.Subject();
598
- }
599
- OrderService.prototype.getOrder = function (id) {
600
- var _this = this;
601
- this.angularFirestore
602
- .doc(this.orderRepository.collectionName + "/" + id)
603
- .valueChanges()
604
- .pipe(operators.map(function (doc) { return i1$1.Order.toInstance(doc); }))
605
- .subscribe(function (doc) { return _this.orderSubject.next(doc); });
606
- return this.orderSubject;
607
- };
608
- return OrderService;
609
- }());
610
- 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 });
611
- OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: OrderService });
612
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: OrderService, decorators: [{
613
- type: i0.Injectable
614
- }], ctorParameters: function () {
615
- return [{ type: i1__namespace$2.AngularFirestore }, { type: i1__namespace$1.OrderFirestoreRepository, decorators: [{
616
- type: i0.Inject,
617
- args: ['OrderRepository']
618
- }] }];
619
- } });
551
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }]; } });
620
552
 
621
553
  var AngularFirebaseAuthModule = /** @class */ (function () {
622
554
  function AngularFirebaseAuthModule() {
@@ -638,21 +570,21 @@
638
570
  {
639
571
  provide: 'Authentication',
640
572
  useFactory: function (authenticationService, userRepository) {
641
- return new i1$1.Authentication(authenticationService, userRepository);
573
+ return new connect.Authentication(authenticationService, userRepository);
642
574
  },
643
575
  deps: ['AuthenticationService', 'UserRepository'],
644
576
  },
645
577
  {
646
578
  provide: 'AuthenticationService',
647
579
  useFactory: function (angularFireAuth) {
648
- return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
580
+ return new connect.AuthenticationFirebaseAuthService(angularFireAuth);
649
581
  },
650
582
  deps: [i1.AngularFireAuth],
651
583
  },
652
584
  {
653
585
  provide: 'SignOut',
654
586
  useFactory: function (authenticationService) {
655
- return new i1$1.SignOut(authenticationService);
587
+ return new connect.SignOut(authenticationService);
656
588
  },
657
589
  deps: ['AuthenticationService'],
658
590
  },
@@ -665,21 +597,21 @@
665
597
  {
666
598
  provide: 'Authentication',
667
599
  useFactory: function (authenticationService, userRepository) {
668
- return new i1$1.Authentication(authenticationService, userRepository);
600
+ return new connect.Authentication(authenticationService, userRepository);
669
601
  },
670
602
  deps: ['AuthenticationService', 'UserRepository'],
671
603
  },
672
604
  {
673
605
  provide: 'AuthenticationService',
674
606
  useFactory: function (angularFireAuth) {
675
- return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
607
+ return new connect.AuthenticationFirebaseAuthService(angularFireAuth);
676
608
  },
677
609
  deps: [i1.AngularFireAuth],
678
610
  },
679
611
  {
680
612
  provide: 'SignOut',
681
613
  useFactory: function (authenticationService) {
682
- return new i1$1.SignOut(authenticationService);
614
+ return new connect.SignOut(authenticationService);
683
615
  },
684
616
  deps: ['AuthenticationService'],
685
617
  },
@@ -707,128 +639,128 @@
707
639
  {
708
640
  provide: 'BeautyProfileRepository',
709
641
  useFactory: function (firestore, userRepository) {
710
- return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
642
+ return new connect.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
711
643
  },
712
- deps: [i1$2.AngularFirestore, 'UserRepository'],
644
+ deps: [firestore.AngularFirestore, 'UserRepository'],
713
645
  },
714
646
  {
715
647
  provide: 'Buy2WinRepository',
716
648
  useFactory: function (firestore) {
717
- return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
649
+ return new connect.Buy2WinFirestoreRepository(firestore.firestore);
718
650
  },
719
- deps: [i1$2.AngularFirestore],
651
+ deps: [firestore.AngularFirestore],
720
652
  },
721
653
  {
722
654
  provide: 'CategoryRepository',
723
655
  useFactory: function (firestore) {
724
- return new i1$1.CategoryFirestoreRepository(firestore.firestore);
656
+ return new connect.CategoryFirestoreRepository(firestore.firestore);
725
657
  },
726
- deps: [i1$2.AngularFirestore],
658
+ deps: [firestore.AngularFirestore],
727
659
  },
728
660
  {
729
661
  provide: 'CheckoutRepository',
730
662
  useFactory: function (firestore) {
731
- return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
663
+ return new connect.CheckoutFirestoreRepository(firestore.firestore);
732
664
  },
733
- deps: [i1$2.AngularFirestore],
665
+ deps: [firestore.AngularFirestore],
734
666
  },
735
667
  {
736
668
  provide: 'CheckoutSubscriptionRepository',
737
669
  useFactory: function (firestore) {
738
- return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
670
+ return new connect.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
739
671
  },
740
- deps: [i1$2.AngularFirestore],
672
+ deps: [firestore.AngularFirestore],
741
673
  },
742
674
  {
743
675
  provide: 'CouponRepository',
744
676
  useFactory: function (firestore) {
745
- return new i1$1.CouponFirestoreRepository(firestore.firestore);
677
+ return new connect.CouponFirestoreRepository(firestore.firestore);
746
678
  },
747
- deps: [i1$2.AngularFirestore],
679
+ deps: [firestore.AngularFirestore],
748
680
  },
749
681
  {
750
682
  provide: 'EditionRepository',
751
683
  useFactory: function (firestore, subscriptionRepository) {
752
- return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
684
+ return new connect.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
753
685
  },
754
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
686
+ deps: [firestore.AngularFirestore, 'SubscriptionRepository'],
755
687
  },
756
688
  {
757
689
  provide: 'HomeRepository',
758
690
  useFactory: function (firestore) {
759
- return new i1$1.HomeFirestoreRepository(firestore.firestore);
691
+ return new connect.HomeFirestoreRepository(firestore.firestore);
760
692
  },
761
- deps: [i1$2.AngularFirestore],
693
+ deps: [firestore.AngularFirestore],
762
694
  },
763
695
  {
764
696
  provide: 'ShopMenuRepository',
765
697
  useFactory: function (firestore) {
766
- return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
698
+ return new connect.ShopMenuFirestoreRepository(firestore.firestore);
767
699
  },
768
- deps: [i1$2.AngularFirestore],
700
+ deps: [firestore.AngularFirestore],
769
701
  },
770
702
  {
771
703
  provide: 'OrderRepository',
772
704
  useFactory: function (firestore) {
773
- return new i1$1.OrderFirestoreRepository(firestore.firestore);
705
+ return new connect.OrderFirestoreRepository(firestore.firestore);
774
706
  },
775
- deps: [i1$2.AngularFirestore],
707
+ deps: [firestore.AngularFirestore],
776
708
  },
777
709
  {
778
710
  provide: 'PaymentRepository',
779
711
  useFactory: function (firestore) {
780
- return new i1$1.PaymentFirestoreRepository(firestore.firestore);
712
+ return new connect.PaymentFirestoreRepository(firestore.firestore);
781
713
  },
782
- deps: [i1$2.AngularFirestore],
714
+ deps: [firestore.AngularFirestore],
783
715
  },
784
716
  {
785
717
  provide: 'ProductRepository',
786
718
  useFactory: function (firestore) {
787
- return new i1$1.ProductFirestoreRepository(firestore.firestore);
719
+ return new connect.ProductFirestoreRepository(firestore.firestore);
788
720
  },
789
- deps: [i1$2.AngularFirestore],
721
+ deps: [firestore.AngularFirestore],
790
722
  },
791
723
  {
792
724
  provide: 'SubscriptionPaymentRepository',
793
725
  useFactory: function (firestore, subscriptionRepository) {
794
- return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
726
+ return new connect.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
795
727
  },
796
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
728
+ deps: [firestore.AngularFirestore, 'SubscriptionRepository'],
797
729
  },
798
730
  {
799
731
  provide: 'SubscriptionPlanRepository',
800
732
  useFactory: function (firestore) {
801
- return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
733
+ return new connect.SubscriptionPlanFirestoreRepository(firestore.firestore);
802
734
  },
803
- deps: [i1$2.AngularFirestore],
735
+ deps: [firestore.AngularFirestore],
804
736
  },
805
737
  {
806
738
  provide: 'SubscriptionRepository',
807
739
  useFactory: function (firestore) {
808
- return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
740
+ return new connect.SubscriptionFirestoreRepository(firestore.firestore);
809
741
  },
810
- deps: [i1$2.AngularFirestore],
742
+ deps: [firestore.AngularFirestore],
811
743
  },
812
744
  {
813
745
  provide: 'UserRepository',
814
746
  useFactory: function (firestore) {
815
- return new i1$1.UserFirestoreRepository(firestore.firestore);
747
+ return new connect.UserFirestoreRepository(firestore.firestore);
816
748
  },
817
- deps: [i1$2.AngularFirestore],
749
+ deps: [firestore.AngularFirestore],
818
750
  },
819
751
  {
820
752
  provide: 'UserAddressRepository',
821
753
  useFactory: function (firestore, userRepository) {
822
- return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
754
+ return new connect.UserAddressFirestoreRepository(firestore.firestore, userRepository);
823
755
  },
824
- deps: [i1$2.AngularFirestore, 'UserRepository'],
756
+ deps: [firestore.AngularFirestore, 'UserRepository'],
825
757
  },
826
758
  {
827
759
  provide: 'VariantRepository',
828
760
  useFactory: function (firestore, productRepository) {
829
- return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
761
+ return new connect.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
830
762
  },
831
- deps: [i1$2.AngularFirestore, 'ProductRepository'],
763
+ deps: [firestore.AngularFirestore, 'ProductRepository'],
832
764
  },
833
765
  ], imports: [[fire.AngularFireModule]] });
834
766
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
@@ -839,128 +771,128 @@
839
771
  {
840
772
  provide: 'BeautyProfileRepository',
841
773
  useFactory: function (firestore, userRepository) {
842
- return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
774
+ return new connect.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
843
775
  },
844
- deps: [i1$2.AngularFirestore, 'UserRepository'],
776
+ deps: [firestore.AngularFirestore, 'UserRepository'],
845
777
  },
846
778
  {
847
779
  provide: 'Buy2WinRepository',
848
780
  useFactory: function (firestore) {
849
- return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
781
+ return new connect.Buy2WinFirestoreRepository(firestore.firestore);
850
782
  },
851
- deps: [i1$2.AngularFirestore],
783
+ deps: [firestore.AngularFirestore],
852
784
  },
853
785
  {
854
786
  provide: 'CategoryRepository',
855
787
  useFactory: function (firestore) {
856
- return new i1$1.CategoryFirestoreRepository(firestore.firestore);
788
+ return new connect.CategoryFirestoreRepository(firestore.firestore);
857
789
  },
858
- deps: [i1$2.AngularFirestore],
790
+ deps: [firestore.AngularFirestore],
859
791
  },
860
792
  {
861
793
  provide: 'CheckoutRepository',
862
794
  useFactory: function (firestore) {
863
- return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
795
+ return new connect.CheckoutFirestoreRepository(firestore.firestore);
864
796
  },
865
- deps: [i1$2.AngularFirestore],
797
+ deps: [firestore.AngularFirestore],
866
798
  },
867
799
  {
868
800
  provide: 'CheckoutSubscriptionRepository',
869
801
  useFactory: function (firestore) {
870
- return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
802
+ return new connect.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
871
803
  },
872
- deps: [i1$2.AngularFirestore],
804
+ deps: [firestore.AngularFirestore],
873
805
  },
874
806
  {
875
807
  provide: 'CouponRepository',
876
808
  useFactory: function (firestore) {
877
- return new i1$1.CouponFirestoreRepository(firestore.firestore);
809
+ return new connect.CouponFirestoreRepository(firestore.firestore);
878
810
  },
879
- deps: [i1$2.AngularFirestore],
811
+ deps: [firestore.AngularFirestore],
880
812
  },
881
813
  {
882
814
  provide: 'EditionRepository',
883
815
  useFactory: function (firestore, subscriptionRepository) {
884
- return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
816
+ return new connect.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
885
817
  },
886
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
818
+ deps: [firestore.AngularFirestore, 'SubscriptionRepository'],
887
819
  },
888
820
  {
889
821
  provide: 'HomeRepository',
890
822
  useFactory: function (firestore) {
891
- return new i1$1.HomeFirestoreRepository(firestore.firestore);
823
+ return new connect.HomeFirestoreRepository(firestore.firestore);
892
824
  },
893
- deps: [i1$2.AngularFirestore],
825
+ deps: [firestore.AngularFirestore],
894
826
  },
895
827
  {
896
828
  provide: 'ShopMenuRepository',
897
829
  useFactory: function (firestore) {
898
- return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
830
+ return new connect.ShopMenuFirestoreRepository(firestore.firestore);
899
831
  },
900
- deps: [i1$2.AngularFirestore],
832
+ deps: [firestore.AngularFirestore],
901
833
  },
902
834
  {
903
835
  provide: 'OrderRepository',
904
836
  useFactory: function (firestore) {
905
- return new i1$1.OrderFirestoreRepository(firestore.firestore);
837
+ return new connect.OrderFirestoreRepository(firestore.firestore);
906
838
  },
907
- deps: [i1$2.AngularFirestore],
839
+ deps: [firestore.AngularFirestore],
908
840
  },
909
841
  {
910
842
  provide: 'PaymentRepository',
911
843
  useFactory: function (firestore) {
912
- return new i1$1.PaymentFirestoreRepository(firestore.firestore);
844
+ return new connect.PaymentFirestoreRepository(firestore.firestore);
913
845
  },
914
- deps: [i1$2.AngularFirestore],
846
+ deps: [firestore.AngularFirestore],
915
847
  },
916
848
  {
917
849
  provide: 'ProductRepository',
918
850
  useFactory: function (firestore) {
919
- return new i1$1.ProductFirestoreRepository(firestore.firestore);
851
+ return new connect.ProductFirestoreRepository(firestore.firestore);
920
852
  },
921
- deps: [i1$2.AngularFirestore],
853
+ deps: [firestore.AngularFirestore],
922
854
  },
923
855
  {
924
856
  provide: 'SubscriptionPaymentRepository',
925
857
  useFactory: function (firestore, subscriptionRepository) {
926
- return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
858
+ return new connect.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
927
859
  },
928
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
860
+ deps: [firestore.AngularFirestore, 'SubscriptionRepository'],
929
861
  },
930
862
  {
931
863
  provide: 'SubscriptionPlanRepository',
932
864
  useFactory: function (firestore) {
933
- return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
865
+ return new connect.SubscriptionPlanFirestoreRepository(firestore.firestore);
934
866
  },
935
- deps: [i1$2.AngularFirestore],
867
+ deps: [firestore.AngularFirestore],
936
868
  },
937
869
  {
938
870
  provide: 'SubscriptionRepository',
939
871
  useFactory: function (firestore) {
940
- return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
872
+ return new connect.SubscriptionFirestoreRepository(firestore.firestore);
941
873
  },
942
- deps: [i1$2.AngularFirestore],
874
+ deps: [firestore.AngularFirestore],
943
875
  },
944
876
  {
945
877
  provide: 'UserRepository',
946
878
  useFactory: function (firestore) {
947
- return new i1$1.UserFirestoreRepository(firestore.firestore);
879
+ return new connect.UserFirestoreRepository(firestore.firestore);
948
880
  },
949
- deps: [i1$2.AngularFirestore],
881
+ deps: [firestore.AngularFirestore],
950
882
  },
951
883
  {
952
884
  provide: 'UserAddressRepository',
953
885
  useFactory: function (firestore, userRepository) {
954
- return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
886
+ return new connect.UserAddressFirestoreRepository(firestore.firestore, userRepository);
955
887
  },
956
- deps: [i1$2.AngularFirestore, 'UserRepository'],
888
+ deps: [firestore.AngularFirestore, 'UserRepository'],
957
889
  },
958
890
  {
959
891
  provide: 'VariantRepository',
960
892
  useFactory: function (firestore, productRepository) {
961
- return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
893
+ return new connect.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
962
894
  },
963
- deps: [i1$2.AngularFirestore, 'ProductRepository'],
895
+ deps: [firestore.AngularFirestore, 'ProductRepository'],
964
896
  },
965
897
  ],
966
898
  }]
@@ -969,22 +901,25 @@
969
901
  var AngularConnectModule = /** @class */ (function () {
970
902
  function AngularConnectModule() {
971
903
  }
972
- AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
904
+ AngularConnectModule.initializeApp = function (options, nameOrConfig) {
973
905
  return {
974
906
  ngModule: AngularConnectModule,
975
- 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
+ ],
976
911
  };
977
912
  };
978
913
  return AngularConnectModule;
979
914
  }());
980
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 });
981
916
  AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
982
- 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]] });
983
918
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
984
919
  type: i0.NgModule,
985
920
  args: [{
986
921
  imports: [fire.AngularFireModule, AngularFirestoreModule],
987
- providers: [AuthService, CartService, CheckoutService, OrderService],
922
+ providers: [AuthService, CartService, CheckoutService],
988
923
  }]
989
924
  }] });
990
925
 
@@ -998,7 +933,6 @@
998
933
  exports.AuthService = AuthService;
999
934
  exports.CartService = CartService;
1000
935
  exports.CheckoutService = CheckoutService;
1001
- exports.OrderService = OrderService;
1002
936
 
1003
937
  Object.defineProperty(exports, '__esModule', { value: true });
1004
938