@infrab4a/connect-angular 1.0.0-beta.26 → 1.0.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.
Files changed (78) hide show
  1. package/bundles/infrab4a-connect-angular.umd.js +111 -495
  2. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  3. package/esm2015/infrab4a-connect-angular.js +2 -2
  4. package/esm2015/lib/angular-connect.module.js +30 -0
  5. package/esm2015/lib/angular-firebase-auth.module.js +99 -0
  6. package/esm2015/lib/angular-firestore.module.js +337 -0
  7. package/esm2015/lib/consts/default-shop.const.js +2 -0
  8. package/esm2015/lib/consts/index.js +2 -0
  9. package/esm2015/lib/index.js +5 -0
  10. package/esm2015/lib/services/auth.service.js +42 -0
  11. package/esm2015/lib/services/cart.service.js +127 -0
  12. package/esm2015/lib/services/checkout-subscription.service.js +37 -0
  13. package/esm2015/lib/services/checkout.service.js +98 -0
  14. package/esm2015/lib/services/coupon.service.js +51 -0
  15. package/esm2015/lib/services/errors/index.js +2 -0
  16. package/esm2015/lib/services/errors/invalid-coupon.error.js +7 -0
  17. package/esm2015/lib/services/index.js +7 -0
  18. package/esm2015/lib/services/order.service.js +32 -0
  19. package/esm2015/lib/services/types/index.js +3 -0
  20. package/esm2015/lib/services/types/required-checkout-data.type.js +2 -0
  21. package/esm2015/lib/services/types/required-checkout-subscription-data.type.js +2 -0
  22. package/esm2015/public-api.js +2 -0
  23. package/fesm2015/infrab4a-connect-angular.js +90 -430
  24. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  25. package/infrab4a-connect-angular.d.ts +1 -1
  26. package/{angular-connect.module.d.ts → lib/angular-connect.module.d.ts} +3 -9
  27. package/{angular-firestore.module.d.ts → lib/angular-firestore.module.d.ts} +2 -7
  28. package/lib/consts/index.d.ts +1 -0
  29. package/{index.d.ts → lib/index.d.ts} +0 -1
  30. package/{services → lib/services}/cart.service.d.ts +2 -16
  31. package/{services → lib/services}/checkout-subscription.service.d.ts +2 -7
  32. package/{services → lib/services}/checkout.service.d.ts +7 -2
  33. package/{services → lib/services}/coupon.service.d.ts +2 -3
  34. package/lib/services/errors/index.d.ts +1 -0
  35. package/lib/services/errors/invalid-coupon.error.d.ts +4 -0
  36. package/{services → lib/services}/index.d.ts +0 -1
  37. package/package.json +3 -3
  38. package/public-api.d.ts +1 -0
  39. package/angular-elastic-search.module.d.ts +0 -9
  40. package/angular-hasura-graphql.module.d.ts +0 -16
  41. package/consts/es-config.const.d.ts +0 -1
  42. package/consts/hasura-options.const.d.ts +0 -1
  43. package/consts/index.d.ts +0 -3
  44. package/esm2015/angular-connect.module.js +0 -49
  45. package/esm2015/angular-elastic-search.module.js +0 -38
  46. package/esm2015/angular-firebase-auth.module.js +0 -113
  47. package/esm2015/angular-firestore.module.js +0 -340
  48. package/esm2015/angular-hasura-graphql.module.js +0 -90
  49. package/esm2015/consts/default-shop.const.js +0 -2
  50. package/esm2015/consts/es-config.const.js +0 -2
  51. package/esm2015/consts/hasura-options.const.js +0 -2
  52. package/esm2015/consts/index.js +0 -4
  53. package/esm2015/index.js +0 -6
  54. package/esm2015/services/auth.service.js +0 -42
  55. package/esm2015/services/cart.service.js +0 -173
  56. package/esm2015/services/checkout-subscription.service.js +0 -70
  57. package/esm2015/services/checkout.service.js +0 -81
  58. package/esm2015/services/coupon.service.js +0 -70
  59. package/esm2015/services/errors/group-invalid-coupon.error.js +0 -8
  60. package/esm2015/services/errors/index.js +0 -3
  61. package/esm2015/services/errors/invalid-coupon.error.js +0 -8
  62. package/esm2015/services/home-shop.service.js +0 -108
  63. package/esm2015/services/index.js +0 -8
  64. package/esm2015/services/order.service.js +0 -32
  65. package/esm2015/services/types/index.js +0 -3
  66. package/esm2015/services/types/required-checkout-data.type.js +0 -2
  67. package/esm2015/services/types/required-checkout-subscription-data.type.js +0 -2
  68. package/services/errors/group-invalid-coupon.error.d.ts +0 -6
  69. package/services/errors/index.d.ts +0 -2
  70. package/services/errors/invalid-coupon.error.d.ts +0 -5
  71. package/services/home-shop.service.d.ts +0 -24
  72. /package/{angular-firebase-auth.module.d.ts → lib/angular-firebase-auth.module.d.ts} +0 -0
  73. /package/{consts → lib/consts}/default-shop.const.d.ts +0 -0
  74. /package/{services → lib/services}/auth.service.d.ts +0 -0
  75. /package/{services → lib/services}/order.service.d.ts +0 -0
  76. /package/{services → lib/services}/types/index.d.ts +0 -0
  77. /package/{services → lib/services}/types/required-checkout-data.type.d.ts +0 -0
  78. /package/{services → lib/services}/types/required-checkout-subscription-data.type.d.ts +0 -0
@@ -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('ts-custom-error'), 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', 'ts-custom-error', '@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["ts-custom-error"], global.ng.fire.firestore, global.ng.fire));
5
- })(this, (function (exports, i0, rxjs, operators, i1, i2, cookie, tsCustomError, i1$1, 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/firestore'), require('@angular/fire')) :
3
+ typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/auth', '@infrab4a/connect', 'js-cookie', '@angular/fire/firestore', '@angular/fire'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["@infrab4a/connect"], global["js-cookie"], global.ng.fire.firestore, global.ng.fire));
5
+ })(this, (function (exports, i0, rxjs, operators, i1, i2, cookie, i1$1, fire) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -391,10 +391,6 @@
391
391
 
392
392
  var DEFAULT_SHOP = 'DEFAULT_SHOP';
393
393
 
394
- var ES_CONFIG = 'ES_CONFIG';
395
-
396
- var HASURA_OPTIONS = 'HASURA_OPTIONS';
397
-
398
394
  var InvalidCouponError = /** @class */ (function (_super) {
399
395
  __extends(InvalidCouponError, _super);
400
396
  function InvalidCouponError(message) {
@@ -403,64 +399,33 @@
403
399
  return _this;
404
400
  }
405
401
  return InvalidCouponError;
406
- }(tsCustomError.CustomError));
407
-
408
- var GroupInvalidCouponError = /** @class */ (function (_super) {
409
- __extends(GroupInvalidCouponError, _super);
410
- function GroupInvalidCouponError(errors) {
411
- var _this = _super.call(this, 'Many coupon errors throw') || this;
412
- _this.errors = errors;
413
- return _this;
414
- }
415
- return GroupInvalidCouponError;
416
- }(tsCustomError.CustomError));
402
+ }(Error));
417
403
 
418
404
  var CouponService = /** @class */ (function () {
419
405
  function CouponService(couponRepository, defaultShop) {
420
- var _this = this;
421
406
  this.couponRepository = couponRepository;
422
407
  this.defaultShop = defaultShop;
423
408
  this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
424
- this.separateValidCoupons = function (coupons, userEmail) { return coupons
425
- .map(function (coupon) {
426
- try {
427
- if (!i2.FinancialCoupon.isFinancialCoupon(coupon))
428
- throw new InvalidCouponError('Coupon is not valid');
429
- if (_this.isValidCoupon(coupon, userEmail))
430
- return coupon;
431
- }
432
- catch (error) {
433
- return error;
434
- }
435
- })
436
- .reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (i2.FinancialCoupon.isFinancialCoupon(coupon)
437
- ? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
438
- : { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
439
- valids: [],
440
- invalids: [],
441
- }); };
442
409
  }
443
- CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType) {
410
+ CouponService.prototype.checkCoupon = function (nickname, userEmail) {
444
411
  var _this = this;
445
- return rxjs.from(this.couponRepository.find({
446
- filters: {
412
+ return rxjs.from(this.couponRepository.find([
413
+ {
447
414
  nickname: { operator: i2.Where.EQUALS, value: nickname },
448
415
  shopAvailability: { operator: i2.Where.EQUALS, value: this.defaultShop },
449
- checkoutType: { operator: i2.Where.EQUALS, value: checkoutType },
450
416
  },
451
- })).pipe(operators.concatMap(function (coupons) { return coupons.count < 1 ? rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); }) : rxjs.of(coupons.data); }), operators.map(function (coupons) { return _this.separateValidCoupons(coupons, userEmail); }), operators.map(function (_a) {
452
- var valids = _a.valids, invalids = _a.invalids;
453
- if (!valids.length)
454
- throw new GroupInvalidCouponError(invalids);
455
- return valids;
456
- }));
417
+ ])).pipe(operators.concatMap(function (coupons) { return coupons.count < 1 ? rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); }) : rxjs.of(coupons.data[0]); }), operators.concatMap(function (coupon) { return _this.isValidCoupon(coupon, userEmail)
418
+ ? rxjs.of(coupon)
419
+ : rxjs.throwError(function () { return new InvalidCouponError('Coupon is not valid'); }); }));
457
420
  };
458
421
  CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
459
422
  if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i2.Exclusivities.COLLABORATORS)
460
423
  throw new InvalidCouponError('User is not a collaborator');
461
424
  if (coupon.exclusivityType === i2.Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
462
425
  throw new InvalidCouponError('Coupon is not valid for user');
463
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
426
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
427
+ throw new InvalidCouponError('Coupon is not active');
428
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresAt) < new Date())
464
429
  throw new InvalidCouponError('Coupon is expired');
465
430
  return true;
466
431
  };
@@ -490,6 +455,7 @@
490
455
  this.orderRepository = orderRepository;
491
456
  this.userRepository = userRepository;
492
457
  this.defaultShop = defaultShop;
458
+ this.checkIfItemHasCouponCategory = function (item, coupon) { return item.categories.filter(function (categoryId) { return coupon.categories.find(function (category) { return category.id === categoryId; }); }).length > 0; };
493
459
  }
494
460
  CheckoutService.prototype.getCheckout = function (checkoutData) {
495
461
  var checkoutId = cookie__default["default"].get('checkoutId');
@@ -502,10 +468,12 @@
502
468
  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 i2.NotFoundError('User is not found'); }); }));
503
469
  };
504
470
  CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
505
- return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
471
+ var _this = this;
472
+ return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems }))).pipe(operators.concatMap(function (checkoutWithItems) { var _a; return _this.applyCoupon((_a = checkoutWithItems.coupon) === null || _a === void 0 ? void 0 : _a.nickname); }));
506
473
  };
507
474
  CheckoutService.prototype.updateCheckoutUser = function (checkout) {
508
- return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
475
+ var _this = this;
476
+ return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, user: checkout.user }))).pipe(operators.concatMap(function (checkoutWithUser) { var _a; return _this.applyCoupon((_a = checkoutWithUser.coupon) === null || _a === void 0 ? void 0 : _a.nickname); }));
509
477
  };
510
478
  CheckoutService.prototype.clearCheckoutFromSession = function () {
511
479
  cookie__default["default"].remove('checkoutId');
@@ -513,36 +481,54 @@
513
481
  };
514
482
  CheckoutService.prototype.checkCoupon = function (nickname) {
515
483
  var _this = this;
484
+ if (i2.isNil(nickname))
485
+ return rxjs.of();
516
486
  return this.getCheckout().pipe(operators.concatMap(function (checkout) {
517
487
  var _a;
518
- return _this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, i2.CheckoutTypes.ECOMMERCE).pipe(operators.concatMap(function (coupons) { return rxjs.of(coupons.shift()); }), operators.concatMap(function (coupon) {
519
- var _a, _b;
520
- return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
521
- ? rxjs.from(_this.orderRepository.find({
522
- filters: { user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } },
523
- })).pipe(operators.concatMap(function (orders) {
524
- if (orders.data.length >= (coupon.useLimit || Infinity))
525
- return rxjs.throwError(function () { return new Error('Coupon is already applied'); });
526
- return rxjs.of(coupon);
527
- }))
528
- : rxjs.of(coupon);
529
- }));
488
+ return _this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email).pipe(operators.concatMap(function (coupon) { return i2.StoreCoupon.isStoreCoupon(coupon) ? rxjs.of(coupon) : rxjs.throwError(function () { return new Error('Coupon is invalid'); }); }), operators.concatMap(function (coupon) { var _a; return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email) ? _this.checkLimitOfUsePerUser(coupon, checkout.user.email) : rxjs.of(coupon); }), operators.concatMap(function (coupon) { return _this.checkTotalLimitOfUse(coupon); }));
530
489
  }));
531
490
  };
491
+ CheckoutService.prototype.applyCoupon = function (nickname) {
492
+ var _this = this;
493
+ return this.getCheckout().pipe(operators.concatMap(function (checkout) { return (!!checkout.coupon ? rxjs.of(checkout.coupon) : _this.checkCoupon(nickname)).pipe(operators.concatMap(function (coupon) { return i2.isNil(coupon)
494
+ ? rxjs.of(checkout)
495
+ : rxjs.of(_this.calculeTotalThatCanBeDiscounted(checkout, coupon)).pipe(operators.concatMap(function (discount) { return _this.checkoutRepository.update({ id: checkout.id, coupon: coupon, discount: discount }); })); })); }));
496
+ };
532
497
  CheckoutService.prototype.createCheckout = function (checkoutData) {
533
498
  return __awaiter(this, void 0, void 0, function () {
534
499
  var checkout;
535
- return __generator(this, function (_c) {
536
- switch (_c.label) {
500
+ return __generator(this, function (_b) {
501
+ switch (_b.label) {
537
502
  case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i2.Checkout.toInstance(i2.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
538
503
  case 1:
539
- checkout = _c.sent();
504
+ checkout = _b.sent();
540
505
  cookie__default["default"].set('checkoutId', checkout.id);
541
506
  return [2 /*return*/, checkout];
542
507
  }
543
508
  });
544
509
  });
545
510
  };
511
+ CheckoutService.prototype.checkLimitOfUsePerUser = function (coupon, userEmail) {
512
+ return rxjs.from(this.orderRepository.find([{ user: { email: userEmail }, coupon: { id: coupon.id } }])).pipe(operators.concatMap(function (orders) {
513
+ if (orders.data.length >= (coupon.quantityPerUser || Infinity))
514
+ return rxjs.throwError(function () { return new Error('Coupon is already applied'); });
515
+ return rxjs.of(coupon);
516
+ }));
517
+ };
518
+ CheckoutService.prototype.checkTotalLimitOfUse = function (coupon) {
519
+ return rxjs.from(this.orderRepository.find([{ coupon: { id: coupon.id } }])).pipe(operators.concatMap(function (orders) {
520
+ if (orders.data.length >= (coupon.useLimit || Infinity))
521
+ return rxjs.throwError(function () { return new Error('Coupon is invalid'); });
522
+ return rxjs.of(coupon);
523
+ }));
524
+ };
525
+ CheckoutService.prototype.calculeTotalThatCanBeDiscounted = function (checkout, coupon) {
526
+ var _this = this;
527
+ var _a;
528
+ if (!coupon.categories || ((_a = coupon.categories) === null || _a === void 0 ? void 0 : _a.length) <= 0)
529
+ return coupon.calculeDiscount(checkout.subTotalPrice);
530
+ return coupon.calculeDiscount(checkout.lineItems.reduce(function (total, lineItem) { return (_this.checkIfItemHasCouponCategory(lineItem, coupon) ? total + lineItem.pricePaid : 0); }, 0));
531
+ };
546
532
  return CheckoutService;
547
533
  }());
548
534
  CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
@@ -566,12 +552,10 @@
566
552
  } });
567
553
 
568
554
  var CartService = /** @class */ (function () {
569
- function CartService(authService, checkoutService, defaultShop, productRepository) {
555
+ function CartService(checkoutService, defaultShop) {
570
556
  var _this = this;
571
- this.authService = authService;
572
557
  this.checkoutService = checkoutService;
573
558
  this.defaultShop = defaultShop;
574
- this.productRepository = productRepository;
575
559
  this.cartSubject = new rxjs.Subject();
576
560
  this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i2.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
577
561
  var _a;
@@ -595,52 +579,38 @@
595
579
  });
596
580
  return cart;
597
581
  };
598
- this.buildLineItem = function (_g) {
599
- var checkout = _g.checkout, item = _g.item, quantity = _g.quantity;
600
- return __awaiter(_this, void 0, void 0, function () {
601
- var _a, _b, _c, _d, _e, _f, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku, isGift, pricePaid;
602
- return __generator(this, function (_g) {
603
- switch (_g.label) {
604
- case 0: return [4 /*yield*/, this.productRepository.get({ id: item.id })];
605
- case 1:
606
- product = _g.sent();
607
- item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
608
- if (this.checkMaxStock(item, quantity || 0))
609
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
610
- image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
611
- id = item.id, name = item.name, EAN = item.EAN, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku;
612
- isGift = item.isGift || null;
613
- pricePaid = this.getProductPrice({
614
- product: item,
615
- shop: checkout.shop || this.defaultShop,
616
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
617
- });
618
- return [2 /*return*/, {
619
- checkout: checkout,
620
- lineItem: i2.LineItem.toInstance({
621
- id: id,
622
- name: name,
623
- EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
624
- brand: product.brand,
625
- slug: slug,
626
- sku: sku,
627
- stock: stock,
628
- price: price,
629
- image: image,
630
- weight: weight !== null && weight !== void 0 ? weight : product.weight,
631
- quantity: (item.quantity || 0) + (quantity || 0),
632
- pricePaid: pricePaid,
633
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
634
- isGift: isGift !== null && isGift !== void 0 ? isGift : null,
635
- costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
636
- }),
637
- }];
638
- }
639
- });
582
+ this.buildLineItem = function (_f) {
583
+ var checkout = _f.checkout, item = _f.item, quantity = _f.quantity;
584
+ var _a, _b, _c, _d, _e;
585
+ item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
586
+ if (_this.checkMaxStock(item, quantity || 0))
587
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
588
+ var image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
589
+ 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;
590
+ var isGift = item.isGift || null;
591
+ var pricePaid = _this.getProductPrice({
592
+ product: item,
593
+ shop: checkout.shop || _this.defaultShop,
594
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
595
+ });
596
+ return i2.LineItem.toInstance({
597
+ id: id,
598
+ name: name,
599
+ brand: brand,
600
+ slug: slug,
601
+ sku: sku,
602
+ stock: stock,
603
+ price: price,
604
+ image: image,
605
+ weight: weight,
606
+ quantity: (item.quantity || 0) + (quantity || 0),
607
+ pricePaid: pricePaid,
608
+ categories: categories,
609
+ isGift: isGift,
640
610
  });
641
611
  };
642
- this.getProductPrice = function (_g) {
643
- var product = _g.product, shop = _g.shop, isSubscriber = _g.isSubscriber;
612
+ this.getProductPrice = function (_f) {
613
+ var product = _f.product, shop = _f.shop, isSubscriber = _f.isSubscriber;
644
614
  var info = product.getInfoByShop(shop);
645
615
  if (product.isGift)
646
616
  return 0;
@@ -656,8 +626,8 @@
656
626
  CartService.prototype.addItem = function (item, quantity) {
657
627
  var _this = this;
658
628
  if (quantity === void 0) { quantity = 1; }
659
- return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }); }), operators.mergeMap(function (_g) {
660
- var checkout = _g.checkout, lineItem = _g.lineItem;
629
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({ checkout: checkout, lineItem: _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }) }); }), operators.concatMap(function (_f) {
630
+ var checkout = _f.checkout, lineItem = _f.lineItem;
661
631
  return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
662
632
  }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
663
633
  };
@@ -676,27 +646,6 @@
676
646
  this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
677
647
  return this.cartSubject;
678
648
  };
679
- /**
680
- * @deprecated The method should not be used
681
- */
682
- CartService.prototype.getDiscount = function (coupon) {
683
- switch (coupon.type) {
684
- case i2.CouponTypes.FINANCIAL:
685
- return this.getFinancialDiscount(coupon);
686
- case i2.CouponTypes.PRODUCT:
687
- return function (subTotalPrice) { return subTotalPrice; };
688
- case i2.CouponTypes.GIFTCARD:
689
- return this.getFinancialDiscount(coupon);
690
- case i2.CouponTypes.VOUCHER:
691
- return function (subTotalPrice) { return subTotalPrice; };
692
- }
693
- };
694
- /**
695
- * @deprecated The method should not be used
696
- */
697
- CartService.prototype.getVariantPriceDiscount = function (item, shop) {
698
- 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); }));
699
- };
700
649
  CartService.prototype.removeItem = function (item) {
701
650
  var _this = this;
702
651
  return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
@@ -710,12 +659,7 @@
710
659
  var _this = this;
711
660
  return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i2.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) {
712
661
  var _a;
713
- return _this.checkoutService.updateCheckoutLineItems(i2.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_g) {
714
- switch (_g.label) {
715
- case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
716
- case 1: return [2 /*return*/, _g.sent()];
717
- }
718
- }); }); })) || [] })));
662
+ return _this.checkoutService.updateCheckoutLineItems(i2.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (item) { return _this.buildLineItem({ checkout: checkout, item: item }); })) || [] })));
719
663
  }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
720
664
  };
721
665
  CartService.prototype.clearCart = function () {
@@ -729,56 +673,22 @@
729
673
  var _this = this;
730
674
  return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
731
675
  };
732
- CartService.prototype.getFinancialDiscount = function (coupon) {
733
- return function (subTotalPrice) {
734
- if (i2.FinancialCoupon.isFinancialCoupon(coupon))
735
- switch (coupon.subtype) {
736
- case i2.CouponSubtypes.ABSOLUTE:
737
- return subTotalPrice - coupon.discount * 100;
738
- case i2.CouponSubtypes.PERCENTAGE:
739
- return subTotalPrice * (1 - coupon.discount / 100);
740
- }
741
- };
742
- };
743
676
  return CartService;
744
677
  }());
745
- CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
678
+ CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, deps: [{ token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
746
679
  CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
747
680
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
748
681
  type: i0.Injectable
749
682
  }], ctorParameters: function () {
750
- return [{ type: AuthService }, { type: CheckoutService }, { type: i2__namespace.Shops, decorators: [{
683
+ return [{ type: CheckoutService }, { type: i2__namespace.Shops, decorators: [{
751
684
  type: i0.Inject,
752
685
  args: [DEFAULT_SHOP]
753
- }] }, { type: undefined, decorators: [{
754
- type: i0.Inject,
755
- args: ['ProductRepository']
756
686
  }] }];
757
687
  } });
758
688
 
759
689
  var CheckoutSubscriptionService = /** @class */ (function () {
760
- function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
761
- var _this = this;
690
+ function CheckoutSubscriptionService(checkoutSubscriptionRepository) {
762
691
  this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
763
- this.subscriptionRepository = subscriptionRepository;
764
- this.couponService = couponService;
765
- this.checkCouponsWithCheckout = function (coupons, checkout) { return rxjs.forkJoin(coupons.map(function (coupon) {
766
- var _a;
767
- return rxjs.from(_this.subscriptionRepository.find({
768
- filters: { user: { email: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email }, coupon: { id: coupon.id } },
769
- })).pipe(operators.map(function (subscriptions) { return ({ coupon: coupon, subscriptions: subscriptions }); }));
770
- })).pipe(operators.map(function (results) { return results.map(function (_b) {
771
- var coupon = _b.coupon, subscriptions = _b.subscriptions;
772
- if (subscriptions.data.length >= (coupon.useLimit || Infinity))
773
- return new InvalidCouponError('Coupon is already applied');
774
- return coupon;
775
- }); }), operators.map(function (validatedCoupons) { return ({
776
- valids: validatedCoupons.filter(function (coupon) { return i2.FinancialCoupon.isFinancialCoupon(coupon); }),
777
- invalids: validatedCoupons.filter(function (coupon) { return coupon instanceof InvalidCouponError; }),
778
- }); }), operators.concatMap(function (_b) {
779
- var valids = _b.valids, invalids = _b.invalids;
780
- return valids.length ? rxjs.of(valids) : rxjs.throwError(new GroupInvalidCouponError(invalids));
781
- })); };
782
692
  }
783
693
  CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
784
694
  var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
@@ -789,11 +699,11 @@
789
699
  CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
790
700
  return __awaiter(this, void 0, void 0, function () {
791
701
  var checkout;
792
- return __generator(this, function (_b) {
793
- switch (_b.label) {
702
+ return __generator(this, function (_a) {
703
+ switch (_a.label) {
794
704
  case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i2.CheckoutSubscription.toInstance(i2.pick(checkoutData, ['user', 'shop'])).toPlain()))];
795
705
  case 1:
796
- checkout = _b.sent();
706
+ checkout = _a.sent();
797
707
  cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
798
708
  return [2 /*return*/, checkout];
799
709
  }
@@ -804,21 +714,9 @@
804
714
  cookie__default["default"].remove('checkoutSubscriptionId');
805
715
  return rxjs.of();
806
716
  };
807
- CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
808
- var _this = this;
809
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, userEmail, i2.CheckoutTypes.SUBSCRIPTION).pipe(operators.concatMap(function (coupons) {
810
- var couponsWithSamePlan = coupons.filter(function (coupon) { return checkout.subscriptionPlan.name === coupon.plan; });
811
- var couponsWithNoPlan = coupons.filter(function (coupon) { return !coupon.plan; });
812
- if (couponsWithSamePlan.length > 0)
813
- return rxjs.of(couponsWithSamePlan);
814
- if (couponsWithNoPlan.length > 0)
815
- return rxjs.of(couponsWithNoPlan);
816
- throw new Error("Coupon subscription plan is invalid.");
817
- }), operators.concatMap(function (coupons) { var _a; return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email) ? _this.checkCouponsWithCheckout(coupons, checkout) : rxjs.of(coupons); }), operators.map(function (validatedCoupons) { return validatedCoupons.shift(); })); }));
818
- };
819
717
  return CheckoutSubscriptionService;
820
718
  }());
821
- CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
719
+ CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
822
720
  CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
823
721
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
824
722
  type: i0.Injectable
@@ -826,10 +724,7 @@
826
724
  return [{ type: undefined, decorators: [{
827
725
  type: i0.Inject,
828
726
  args: ['CheckoutSubscriptionRepository']
829
- }] }, { type: undefined, decorators: [{
830
- type: i0.Inject,
831
- args: ['SubscriptionRepository']
832
- }] }, { type: CouponService }];
727
+ }] }];
833
728
  } });
834
729
 
835
730
  var OrderService = /** @class */ (function () {
@@ -860,126 +755,6 @@
860
755
  }] }];
861
756
  } });
862
757
 
863
- var HomeShopService = /** @class */ (function () {
864
- function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
865
- this.categoryRepository = categoryRepository;
866
- this.homeRepository = homeRepository;
867
- this.productRepository = productRepository;
868
- this.defaultShop = defaultShop;
869
- this.buildCategoryGroupWithRequiredData = function (group) { return ({
870
- category: i2.Category.toInstance(i2.pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
871
- products: group.products.map(function (product) { return i2.Product.toInstance(i2.pick(product.toPlain(), [
872
- 'id',
873
- 'price',
874
- 'reviews',
875
- 'hasVariants',
876
- 'slug',
877
- 'sku',
878
- 'stock',
879
- 'costPrice',
880
- 'images',
881
- 'miniatures',
882
- 'name',
883
- 'weight',
884
- ])); }),
885
- }); };
886
- }
887
- Object.defineProperty(HomeShopService.prototype, "homeId", {
888
- get: function () {
889
- if (this.defaultShop === i2.Shops.GLAMSHOP)
890
- return 'glamshop';
891
- if (this.defaultShop === i2.Shops.MENSMARKET)
892
- return 'mens_market';
893
- return null;
894
- },
895
- enumerable: false,
896
- configurable: true
897
- });
898
- HomeShopService.prototype.getHomeData = function () {
899
- var _this = this;
900
- return this.getHomeConfiguration().pipe(operators.map(function (home) { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), operators.concatMap(function (home) { return home
901
- ? rxjs.of(home)
902
- : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_b) {
903
- var _c = __read(_b, 3), discoverProducts = _c[0], featuredProducts = _c[1], verticalProducts = _c[2];
904
- return ({
905
- discoverProducts: discoverProducts,
906
- featuredProducts: featuredProducts,
907
- verticalProducts: verticalProducts,
908
- });
909
- }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
910
- };
911
- HomeShopService.prototype.getBanners = function (type) {
912
- return this.getHomeConfiguration().pipe(operators.map(function (home) {
913
- if (type === 'brand')
914
- return home.brandsCarousel;
915
- if (type === 'buyToWin')
916
- return [home.buyToWinBanner];
917
- if (type === 'block')
918
- return home.blockBanners;
919
- if (type === 'blog')
920
- return [home.blogBanner];
921
- }));
922
- };
923
- HomeShopService.prototype.getDiscoverProducts = function () {
924
- var _this = this;
925
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
926
- };
927
- HomeShopService.prototype.getFeaturedProducts = function () {
928
- var _this = this;
929
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
930
- };
931
- HomeShopService.prototype.getVerticalProducts = function () {
932
- var _this = this;
933
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.from(_this.categoryRepository.get({ id: id })).pipe(operators.concatMap(function (category) { return rxjs.from(_this.productRepository.find({
934
- filters: { categories: { operator: i2.Where.IN, value: [category.id] } },
935
- limits: { limit: 12 },
936
- })).pipe(operators.map(function (products) { return ({ category: category, products: products }); })); }), operators.map(function (_b) {
937
- var category = _b.category, products = _b.products;
938
- return ({ category: category, products: products.data });
939
- }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
940
- };
941
- HomeShopService.prototype.getHomeConfiguration = function () {
942
- var _this = this;
943
- return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
944
- ? rxjs.of(home)
945
- : !_this.homeId
946
- ? rxjs.throwError(new i2.RequiredArgumentError(['homeId']))
947
- : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
948
- };
949
- HomeShopService.prototype.saveHomeData = function (homeData) {
950
- var _this = this;
951
- var data = {
952
- createdAt: new Date(),
953
- expiresAt: i2.add(new Date(), { hours: 1 }),
954
- data: homeData,
955
- };
956
- return rxjs.from(this.homeRepository.update({
957
- id: this.homeId,
958
- data: data,
959
- })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
960
- };
961
- return HomeShopService;
962
- }());
963
- HomeShopService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
964
- HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
965
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
966
- type: i0.Injectable
967
- }], ctorParameters: function () {
968
- return [{ type: undefined, decorators: [{
969
- type: i0.Inject,
970
- args: ['CategoryRepository']
971
- }] }, { type: undefined, decorators: [{
972
- type: i0.Inject,
973
- args: ['HomeRepository']
974
- }] }, { type: undefined, decorators: [{
975
- type: i0.Inject,
976
- args: ['ProductRepository']
977
- }] }, { type: i2__namespace.Shops, decorators: [{
978
- type: i0.Inject,
979
- args: [DEFAULT_SHOP]
980
- }] }];
981
- } });
982
-
983
758
  var AngularFirebaseAuthModule = /** @class */ (function () {
984
759
  function AngularFirebaseAuthModule() {
985
760
  }
@@ -1032,13 +807,6 @@
1032
807
  },
1033
808
  deps: ['AuthenticationService'],
1034
809
  },
1035
- {
1036
- provide: 'RecoveryPassword',
1037
- useFactory: function (authenticationService) {
1038
- return new i2.RecoveryPassword(authenticationService);
1039
- },
1040
- deps: ['AuthenticationService'],
1041
- },
1042
810
  ], imports: [[fire.AngularFireModule]] });
1043
811
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1044
812
  type: i0.NgModule,
@@ -1080,50 +848,6 @@
1080
848
  },
1081
849
  deps: ['AuthenticationService'],
1082
850
  },
1083
- {
1084
- provide: 'RecoveryPassword',
1085
- useFactory: function (authenticationService) {
1086
- return new i2.RecoveryPassword(authenticationService);
1087
- },
1088
- deps: ['AuthenticationService'],
1089
- },
1090
- ],
1091
- }]
1092
- }] });
1093
-
1094
- var AngularElasticSeachModule = /** @class */ (function () {
1095
- function AngularElasticSeachModule() {
1096
- }
1097
- AngularElasticSeachModule.initializeApp = function (options) {
1098
- return {
1099
- ngModule: AngularElasticSeachModule,
1100
- providers: [{ provide: ES_CONFIG, useValue: options }],
1101
- };
1102
- };
1103
- return AngularElasticSeachModule;
1104
- }());
1105
- AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1106
- AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
1107
- AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
1108
- {
1109
- provide: i2.ProductsIndex,
1110
- useFactory: function (configuration) {
1111
- return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1112
- },
1113
- deps: [ES_CONFIG],
1114
- },
1115
- ] });
1116
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
1117
- type: i0.NgModule,
1118
- args: [{
1119
- providers: [
1120
- {
1121
- provide: i2.ProductsIndex,
1122
- useFactory: function (configuration) {
1123
- return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1124
- },
1125
- deps: [ES_CONFIG],
1126
- },
1127
851
  ],
1128
852
  }]
1129
853
  }] });
@@ -1135,16 +859,15 @@
1135
859
  return {
1136
860
  ngModule: AngularFirestoreModule,
1137
861
  providers: [
1138
- { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
862
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
1139
863
  { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1140
- { provide: ES_CONFIG, useValue: options.elasticSearch },
1141
864
  ],
1142
865
  };
1143
866
  };
1144
867
  return AngularFirestoreModule;
1145
868
  }());
1146
869
  AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1147
- AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
870
+ AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule] });
1148
871
  AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
1149
872
  {
1150
873
  provide: 'BeautyProfileRepository',
@@ -1161,7 +884,7 @@
1161
884
  deps: [i1$1.AngularFirestore],
1162
885
  },
1163
886
  {
1164
- provide: i2.CategoryFirestoreRepository,
887
+ provide: 'CategoryRepository',
1165
888
  useFactory: function (firestore) {
1166
889
  return new i2.CategoryFirestoreRepository(firestore.firestore);
1167
890
  },
@@ -1238,7 +961,7 @@
1238
961
  deps: [i1$1.AngularFirestore],
1239
962
  },
1240
963
  {
1241
- provide: i2.ProductFirestoreRepository,
964
+ provide: 'ProductRepository',
1242
965
  useFactory: function (firestore) {
1243
966
  return new i2.ProductFirestoreRepository(firestore.firestore);
1244
967
  },
@@ -1294,17 +1017,17 @@
1294
1017
  deps: [i1$1.AngularFirestore, 'UserRepository'],
1295
1018
  },
1296
1019
  {
1297
- provide: i2.ProductVariantFirestoreRepository,
1020
+ provide: 'VariantRepository',
1298
1021
  useFactory: function (firestore, productRepository) {
1299
1022
  return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1300
1023
  },
1301
- deps: [i1$1.AngularFirestore, i2.ProductFirestoreRepository],
1024
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1302
1025
  },
1303
- ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
1026
+ ], imports: [[fire.AngularFireModule]] });
1304
1027
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1305
1028
  type: i0.NgModule,
1306
1029
  args: [{
1307
- imports: [fire.AngularFireModule, AngularElasticSeachModule],
1030
+ imports: [fire.AngularFireModule],
1308
1031
  providers: [
1309
1032
  {
1310
1033
  provide: 'BeautyProfileRepository',
@@ -1321,7 +1044,7 @@
1321
1044
  deps: [i1$1.AngularFirestore],
1322
1045
  },
1323
1046
  {
1324
- provide: i2.CategoryFirestoreRepository,
1047
+ provide: 'CategoryRepository',
1325
1048
  useFactory: function (firestore) {
1326
1049
  return new i2.CategoryFirestoreRepository(firestore.firestore);
1327
1050
  },
@@ -1398,7 +1121,7 @@
1398
1121
  deps: [i1$1.AngularFirestore],
1399
1122
  },
1400
1123
  {
1401
- provide: i2.ProductFirestoreRepository,
1124
+ provide: 'ProductRepository',
1402
1125
  useFactory: function (firestore) {
1403
1126
  return new i2.ProductFirestoreRepository(firestore.firestore);
1404
1127
  },
@@ -1454,100 +1177,11 @@
1454
1177
  deps: [i1$1.AngularFirestore, 'UserRepository'],
1455
1178
  },
1456
1179
  {
1457
- provide: i2.ProductVariantFirestoreRepository,
1180
+ provide: 'VariantRepository',
1458
1181
  useFactory: function (firestore, productRepository) {
1459
1182
  return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1460
1183
  },
1461
- deps: [i1$1.AngularFirestore, i2.ProductFirestoreRepository],
1462
- },
1463
- ],
1464
- }]
1465
- }] });
1466
-
1467
- var AngularHasuraGraphQLModule = /** @class */ (function () {
1468
- function AngularHasuraGraphQLModule() {
1469
- }
1470
- AngularHasuraGraphQLModule.initializeApp = function (options) {
1471
- return {
1472
- ngModule: AngularHasuraGraphQLModule,
1473
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1474
- };
1475
- };
1476
- return AngularHasuraGraphQLModule;
1477
- }());
1478
- AngularHasuraGraphQLModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1479
- AngularHasuraGraphQLModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule });
1480
- AngularHasuraGraphQLModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, providers: [
1481
- {
1482
- provide: 'CategoryRepository',
1483
- useExisting: i2.CategoryHasuraGraphQLRepository,
1484
- },
1485
- {
1486
- provide: i2.CategoryHasuraGraphQLRepository,
1487
- useFactory: function (options, productRepository) {
1488
- return new i2.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1489
- },
1490
- deps: [HASURA_OPTIONS, i2.ProductHasuraGraphQLRepository],
1491
- },
1492
- {
1493
- provide: 'ProductRepository',
1494
- useExisting: i2.ProductHasuraGraphQLRepository,
1495
- },
1496
- {
1497
- provide: i2.ProductHasuraGraphQLRepository,
1498
- useFactory: function (options) {
1499
- return new i2.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1500
- },
1501
- deps: [HASURA_OPTIONS],
1502
- },
1503
- {
1504
- provide: 'VariantRepository',
1505
- useExisting: i2.VariantHasuraGraphQLRepository,
1506
- },
1507
- {
1508
- provide: i2.VariantHasuraGraphQLRepository,
1509
- useFactory: function (options) {
1510
- return new i2.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1511
- },
1512
- deps: [HASURA_OPTIONS],
1513
- },
1514
- ] });
1515
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
1516
- type: i0.NgModule,
1517
- args: [{
1518
- providers: [
1519
- {
1520
- provide: 'CategoryRepository',
1521
- useExisting: i2.CategoryHasuraGraphQLRepository,
1522
- },
1523
- {
1524
- provide: i2.CategoryHasuraGraphQLRepository,
1525
- useFactory: function (options, productRepository) {
1526
- return new i2.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1527
- },
1528
- deps: [HASURA_OPTIONS, i2.ProductHasuraGraphQLRepository],
1529
- },
1530
- {
1531
- provide: 'ProductRepository',
1532
- useExisting: i2.ProductHasuraGraphQLRepository,
1533
- },
1534
- {
1535
- provide: i2.ProductHasuraGraphQLRepository,
1536
- useFactory: function (options) {
1537
- return new i2.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1538
- },
1539
- deps: [HASURA_OPTIONS],
1540
- },
1541
- {
1542
- provide: 'VariantRepository',
1543
- useExisting: i2.VariantHasuraGraphQLRepository,
1544
- },
1545
- {
1546
- provide: i2.VariantHasuraGraphQLRepository,
1547
- useFactory: function (options) {
1548
- return new i2.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1549
- },
1550
- deps: [HASURA_OPTIONS],
1184
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1551
1185
  },
1552
1186
  ],
1553
1187
  }]
@@ -1559,35 +1193,19 @@
1559
1193
  AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1560
1194
  return {
1561
1195
  ngModule: AngularConnectModule,
1562
- providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((i2.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i2.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]))), __read((i2.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i2.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i2.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))),
1196
+ providers: __spreadArray(__spreadArray(__spreadArray([], __read((i2.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i2.isNil(options) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options }]))), __read((i2.isNil(options) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))),
1563
1197
  };
1564
1198
  };
1565
1199
  return AngularConnectModule;
1566
1200
  }());
1567
1201
  AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1568
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1569
- AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
1570
- AuthService,
1571
- CartService,
1572
- CheckoutService,
1573
- CheckoutSubscriptionService,
1574
- CouponService,
1575
- HomeShopService,
1576
- OrderService,
1577
- ], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1202
+ AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
1203
+ AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, OrderService], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1578
1204
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1579
1205
  type: i0.NgModule,
1580
1206
  args: [{
1581
- imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1582
- providers: [
1583
- AuthService,
1584
- CartService,
1585
- CheckoutService,
1586
- CheckoutSubscriptionService,
1587
- CouponService,
1588
- HomeShopService,
1589
- OrderService,
1590
- ],
1207
+ imports: [fire.AngularFireModule, AngularFirestoreModule],
1208
+ providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, OrderService],
1591
1209
  }]
1592
1210
  }] });
1593
1211
 
@@ -1598,13 +1216,11 @@
1598
1216
  exports.AngularConnectModule = AngularConnectModule;
1599
1217
  exports.AngularFirebaseAuthModule = AngularFirebaseAuthModule;
1600
1218
  exports.AngularFirestoreModule = AngularFirestoreModule;
1601
- exports.AngularHasuraGraphQLModule = AngularHasuraGraphQLModule;
1602
1219
  exports.AuthService = AuthService;
1603
1220
  exports.CartService = CartService;
1604
1221
  exports.CheckoutService = CheckoutService;
1605
1222
  exports.CheckoutSubscriptionService = CheckoutSubscriptionService;
1606
1223
  exports.CouponService = CouponService;
1607
- exports.HomeShopService = HomeShopService;
1608
1224
  exports.OrderService = OrderService;
1609
1225
 
1610
1226
  Object.defineProperty(exports, '__esModule', { value: true });