@infrab4a/connect-angular 0.5.0-beta.2 → 0.5.0-beta.20

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