@infrab4a/connect-angular 1.0.0-beta.3 → 1.0.0-beta.4
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.
- package/{lib/angular-connect.module.d.ts → angular-connect.module.d.ts} +5 -2
- package/angular-elastic-search.module.d.ts +9 -0
- package/{lib/angular-firestore.module.d.ts → angular-firestore.module.d.ts} +7 -2
- package/bundles/infrab4a-connect-angular.umd.js +279 -19
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/consts/es-config.const.d.ts +1 -0
- package/{lib/consts → consts}/index.d.ts +1 -0
- package/esm2015/angular-connect.module.js +47 -0
- package/esm2015/angular-elastic-search.module.js +38 -0
- package/esm2015/angular-firebase-auth.module.js +113 -0
- package/esm2015/angular-firestore.module.js +340 -0
- package/esm2015/consts/default-shop.const.js +2 -0
- package/esm2015/consts/es-config.const.js +2 -0
- package/esm2015/consts/index.js +3 -0
- package/esm2015/index.js +5 -0
- package/esm2015/infrab4a-connect-angular.js +2 -2
- package/esm2015/services/auth.service.js +42 -0
- package/esm2015/services/cart.service.js +131 -0
- package/esm2015/services/checkout-subscription.service.js +69 -0
- package/esm2015/services/checkout.service.js +98 -0
- package/esm2015/services/coupon.service.js +70 -0
- package/esm2015/services/errors/group-invalid-coupon.error.js +7 -0
- package/esm2015/services/errors/index.js +3 -0
- package/esm2015/services/errors/invalid-coupon.error.js +7 -0
- package/esm2015/services/home-shop.service.js +108 -0
- package/esm2015/services/index.js +8 -0
- package/esm2015/services/order.service.js +32 -0
- package/esm2015/services/types/index.js +3 -0
- package/esm2015/services/types/required-checkout-data.type.js +2 -0
- package/esm2015/services/types/required-checkout-subscription-data.type.js +2 -0
- package/fesm2015/infrab4a-connect-angular.js +247 -20
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/infrab4a-connect-angular.d.ts +1 -1
- package/package.json +2 -2
- package/{lib/services → services}/checkout-subscription.service.d.ts +7 -2
- package/{lib/services → services}/coupon.service.d.ts +3 -2
- package/services/errors/group-invalid-coupon.error.d.ts +5 -0
- package/services/errors/index.d.ts +2 -0
- package/services/home-shop.service.d.ts +24 -0
- package/{lib/services → services}/index.d.ts +1 -0
- package/esm2015/lib/angular-connect.module.js +0 -30
- package/esm2015/lib/angular-firebase-auth.module.js +0 -99
- package/esm2015/lib/angular-firestore.module.js +0 -337
- package/esm2015/lib/consts/default-shop.const.js +0 -2
- package/esm2015/lib/consts/index.js +0 -2
- package/esm2015/lib/index.js +0 -5
- package/esm2015/lib/services/auth.service.js +0 -42
- package/esm2015/lib/services/cart.service.js +0 -127
- package/esm2015/lib/services/checkout-subscription.service.js +0 -37
- package/esm2015/lib/services/checkout.service.js +0 -98
- package/esm2015/lib/services/coupon.service.js +0 -51
- package/esm2015/lib/services/errors/index.js +0 -2
- package/esm2015/lib/services/errors/invalid-coupon.error.js +0 -7
- package/esm2015/lib/services/index.js +0 -7
- package/esm2015/lib/services/order.service.js +0 -32
- package/esm2015/lib/services/types/index.js +0 -3
- package/esm2015/lib/services/types/required-checkout-data.type.js +0 -2
- package/esm2015/lib/services/types/required-checkout-subscription-data.type.js +0 -2
- package/esm2015/public-api.js +0 -2
- package/lib/services/errors/index.d.ts +0 -1
- package/public-api.d.ts +0 -1
- /package/{lib/angular-firebase-auth.module.d.ts → angular-firebase-auth.module.d.ts} +0 -0
- /package/{lib/consts → consts}/default-shop.const.d.ts +0 -0
- /package/{lib/index.d.ts → index.d.ts} +0 -0
- /package/{lib/services → services}/auth.service.d.ts +0 -0
- /package/{lib/services → services}/cart.service.d.ts +0 -0
- /package/{lib/services → services}/checkout.service.d.ts +0 -0
- /package/{lib/services → services}/errors/invalid-coupon.error.d.ts +0 -0
- /package/{lib/services → services}/order.service.d.ts +0 -0
- /package/{lib/services → services}/types/index.d.ts +0 -0
- /package/{lib/services → services}/types/required-checkout-data.type.d.ts +0 -0
- /package/{lib/services → services}/types/required-checkout-subscription-data.type.d.ts +0 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { ModuleWithProviders } from '@angular/core';
|
|
2
2
|
import { AngularFireModule, FirebaseAppConfig, FirebaseOptions } from '@angular/fire';
|
|
3
|
-
import { Shops } from '@infrab4a/connect';
|
|
3
|
+
import { AxiosElasticSearchConfig, Shops } from '@infrab4a/connect';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
import * as i1 from "@angular/fire";
|
|
6
6
|
import * as i2 from "./angular-firestore.module";
|
|
7
7
|
export declare class AngularConnectModule {
|
|
8
|
-
static initializeApp(defaultShop: Shops, options:
|
|
8
|
+
static initializeApp(defaultShop: Shops, options: {
|
|
9
|
+
firebase: FirebaseOptions;
|
|
10
|
+
elasticSearch: AxiosElasticSearchConfig;
|
|
11
|
+
}, nameOrConfig?: string | FirebaseAppConfig): ModuleWithProviders<AngularFireModule>;
|
|
9
12
|
static ɵfac: i0.ɵɵFactoryDeclaration<AngularConnectModule, never>;
|
|
10
13
|
static ɵmod: i0.ɵɵNgModuleDeclaration<AngularConnectModule, never, [typeof i1.AngularFireModule, typeof i2.AngularFirestoreModule], never>;
|
|
11
14
|
static ɵinj: i0.ɵɵInjectorDeclaration<AngularConnectModule>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import { AxiosElasticSearchConfig } from '@infrab4a/connect';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
export declare class AngularElasticSeachModule {
|
|
5
|
+
static initializeApp(options: AxiosElasticSearchConfig): ModuleWithProviders<AngularElasticSeachModule>;
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AngularElasticSeachModule, never>;
|
|
7
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<AngularElasticSeachModule, never, never, never>;
|
|
8
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<AngularElasticSeachModule>;
|
|
9
|
+
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { ModuleWithProviders } from '@angular/core';
|
|
2
2
|
import { AngularFireModule, FirebaseAppConfig, FirebaseOptions } from '@angular/fire';
|
|
3
|
+
import { AxiosElasticSearchConfig } from '@infrab4a/connect';
|
|
3
4
|
import * as i0 from "@angular/core";
|
|
4
5
|
import * as i1 from "@angular/fire";
|
|
6
|
+
import * as i2 from "./angular-elastic-search.module";
|
|
5
7
|
export declare class AngularFirestoreModule {
|
|
6
|
-
static initializeApp(options:
|
|
8
|
+
static initializeApp(options: {
|
|
9
|
+
firebase: FirebaseOptions;
|
|
10
|
+
elasticSearch: AxiosElasticSearchConfig;
|
|
11
|
+
}, nameOrConfig?: string | FirebaseAppConfig): ModuleWithProviders<AngularFireModule>;
|
|
7
12
|
static ɵfac: i0.ɵɵFactoryDeclaration<AngularFirestoreModule, never>;
|
|
8
|
-
static ɵmod: i0.ɵɵNgModuleDeclaration<AngularFirestoreModule, never, [typeof i1.AngularFireModule], never>;
|
|
13
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<AngularFirestoreModule, never, [typeof i1.AngularFireModule, typeof i2.AngularElasticSeachModule], never>;
|
|
9
14
|
static ɵinj: i0.ɵɵInjectorDeclaration<AngularFirestoreModule>;
|
|
10
15
|
}
|
|
@@ -391,6 +391,8 @@
|
|
|
391
391
|
|
|
392
392
|
var DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
393
393
|
|
|
394
|
+
var ES_CONFIG = 'ES_CONFIG';
|
|
395
|
+
|
|
394
396
|
var InvalidCouponError = /** @class */ (function (_super) {
|
|
395
397
|
__extends(InvalidCouponError, _super);
|
|
396
398
|
function InvalidCouponError(message) {
|
|
@@ -401,22 +403,53 @@
|
|
|
401
403
|
return InvalidCouponError;
|
|
402
404
|
}(Error));
|
|
403
405
|
|
|
406
|
+
var GroupInvalidCouponError = /** @class */ (function (_super) {
|
|
407
|
+
__extends(GroupInvalidCouponError, _super);
|
|
408
|
+
function GroupInvalidCouponError(errors) {
|
|
409
|
+
var _this = _super.call(this, 'Many coupon errors throw') || this;
|
|
410
|
+
_this.errors = errors;
|
|
411
|
+
return _this;
|
|
412
|
+
}
|
|
413
|
+
return GroupInvalidCouponError;
|
|
414
|
+
}(Error));
|
|
415
|
+
|
|
404
416
|
var CouponService = /** @class */ (function () {
|
|
405
417
|
function CouponService(couponRepository, defaultShop) {
|
|
418
|
+
var _this = this;
|
|
406
419
|
this.couponRepository = couponRepository;
|
|
407
420
|
this.defaultShop = defaultShop;
|
|
408
421
|
this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
|
|
422
|
+
this.separateValidCoupons = function (coupons, userEmail) { return coupons
|
|
423
|
+
.map(function (coupon) {
|
|
424
|
+
try {
|
|
425
|
+
if (_this.isValidCoupon(coupon, userEmail))
|
|
426
|
+
return coupon;
|
|
427
|
+
}
|
|
428
|
+
catch (error) {
|
|
429
|
+
return error;
|
|
430
|
+
}
|
|
431
|
+
})
|
|
432
|
+
.reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (coupon instanceof i2.Coupon
|
|
433
|
+
? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
|
|
434
|
+
: { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
|
|
435
|
+
valids: [],
|
|
436
|
+
invalids: [],
|
|
437
|
+
}); };
|
|
409
438
|
}
|
|
410
|
-
CouponService.prototype.checkCoupon = function (nickname, userEmail) {
|
|
439
|
+
CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType) {
|
|
411
440
|
var _this = this;
|
|
412
441
|
return rxjs.from(this.couponRepository.find([
|
|
413
442
|
{
|
|
414
443
|
nickname: { operator: i2.Where.EQUALS, value: nickname },
|
|
415
444
|
shopAvailability: { operator: i2.Where.EQUALS, value: this.defaultShop },
|
|
445
|
+
checkoutType: { operator: i2.Where.EQUALS, value: checkoutType },
|
|
416
446
|
},
|
|
417
|
-
])).pipe(operators.concatMap(function (coupons) { return coupons.count < 1 ? rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); }) : rxjs.of(coupons.data
|
|
418
|
-
|
|
419
|
-
|
|
447
|
+
])).pipe(operators.concatMap(function (coupons) { return coupons.count < 1 ? rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); }) : rxjs.of(coupons.data); }), operators.map(function (coupons) { return _this.separateValidCoupons(coupons, userEmail); }), operators.map(function (_a) {
|
|
448
|
+
var valids = _a.valids, invalids = _a.invalids;
|
|
449
|
+
if (!valids.length)
|
|
450
|
+
throw new GroupInvalidCouponError(invalids);
|
|
451
|
+
return valids;
|
|
452
|
+
}));
|
|
420
453
|
};
|
|
421
454
|
CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
|
|
422
455
|
if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i2.Exclusivities.COLLABORATORS)
|
|
@@ -485,7 +518,7 @@
|
|
|
485
518
|
return rxjs.of();
|
|
486
519
|
return this.getCheckout().pipe(operators.concatMap(function (checkout) {
|
|
487
520
|
var _a;
|
|
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); }));
|
|
521
|
+
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) { 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); }));
|
|
489
522
|
}));
|
|
490
523
|
};
|
|
491
524
|
CheckoutService.prototype.applyCoupon = function (nickname) {
|
|
@@ -607,6 +640,7 @@
|
|
|
607
640
|
pricePaid: pricePaid,
|
|
608
641
|
categories: categories,
|
|
609
642
|
isGift: isGift,
|
|
643
|
+
costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
|
|
610
644
|
});
|
|
611
645
|
};
|
|
612
646
|
this.getProductPrice = function (_f) {
|
|
@@ -626,7 +660,10 @@
|
|
|
626
660
|
CartService.prototype.addItem = function (item, quantity) {
|
|
627
661
|
var _this = this;
|
|
628
662
|
if (quantity === void 0) { quantity = 1; }
|
|
629
|
-
return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({
|
|
663
|
+
return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({
|
|
664
|
+
checkout: checkout,
|
|
665
|
+
lineItem: _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }),
|
|
666
|
+
}); }), operators.concatMap(function (_f) {
|
|
630
667
|
var checkout = _f.checkout, lineItem = _f.lineItem;
|
|
631
668
|
return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
|
|
632
669
|
}), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
|
|
@@ -687,8 +724,26 @@
|
|
|
687
724
|
} });
|
|
688
725
|
|
|
689
726
|
var CheckoutSubscriptionService = /** @class */ (function () {
|
|
690
|
-
function CheckoutSubscriptionService(checkoutSubscriptionRepository) {
|
|
727
|
+
function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
728
|
+
var _this = this;
|
|
691
729
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
730
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
731
|
+
this.couponService = couponService;
|
|
732
|
+
this.checkCouponsWithCheckout = function (coupons, checkout) { return rxjs.forkJoin(coupons.map(function (coupon) {
|
|
733
|
+
var _a;
|
|
734
|
+
return rxjs.from(_this.subscriptionRepository.find([{ user: { email: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email }, coupon: { id: coupon.id } }])).pipe(operators.map(function (subscriptions) { return ({ coupon: coupon, subscriptions: subscriptions }); }));
|
|
735
|
+
})).pipe(operators.map(function (results) { return results.map(function (_b) {
|
|
736
|
+
var coupon = _b.coupon, subscriptions = _b.subscriptions;
|
|
737
|
+
if (subscriptions.data.length >= (coupon.useLimit || Infinity))
|
|
738
|
+
return new InvalidCouponError('Coupon is already applied');
|
|
739
|
+
return coupon;
|
|
740
|
+
}); }), operators.map(function (validatedCoupons) { return ({
|
|
741
|
+
valids: validatedCoupons.filter(function (coupon) { return coupon instanceof i2.ClubCoupon; }),
|
|
742
|
+
invalids: validatedCoupons.filter(function (coupon) { return coupon instanceof InvalidCouponError; }),
|
|
743
|
+
}); }), operators.concatMap(function (_b) {
|
|
744
|
+
var valids = _b.valids, invalids = _b.invalids;
|
|
745
|
+
return valids.length ? rxjs.of(valids) : rxjs.throwError(new GroupInvalidCouponError(invalids));
|
|
746
|
+
})); };
|
|
692
747
|
}
|
|
693
748
|
CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
|
|
694
749
|
var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
|
|
@@ -699,11 +754,11 @@
|
|
|
699
754
|
CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
|
|
700
755
|
return __awaiter(this, void 0, void 0, function () {
|
|
701
756
|
var checkout;
|
|
702
|
-
return __generator(this, function (
|
|
703
|
-
switch (
|
|
757
|
+
return __generator(this, function (_b) {
|
|
758
|
+
switch (_b.label) {
|
|
704
759
|
case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i2.CheckoutSubscription.toInstance(i2.pick(checkoutData, ['user', 'shop'])).toPlain()))];
|
|
705
760
|
case 1:
|
|
706
|
-
checkout =
|
|
761
|
+
checkout = _b.sent();
|
|
707
762
|
cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
|
|
708
763
|
return [2 /*return*/, checkout];
|
|
709
764
|
}
|
|
@@ -714,9 +769,22 @@
|
|
|
714
769
|
cookie__default["default"].remove('checkoutSubscriptionId');
|
|
715
770
|
return rxjs.of();
|
|
716
771
|
};
|
|
772
|
+
CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
|
|
773
|
+
var _this = this;
|
|
774
|
+
return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, userEmail, i2.CheckoutTypes.SUBSCRIPTION).pipe(operators.concatMap(function (coupons) {
|
|
775
|
+
var clubCoupons = coupons.filter(function (coupon) { return i2.ClubCoupon.isClubCoupon(coupon); });
|
|
776
|
+
var couponsWithSamePlan = clubCoupons.filter(function (coupon) { return checkout.subscriptionPlan.name === coupon.plan; });
|
|
777
|
+
var couponsWithNoPlan = clubCoupons.filter(function (coupon) { return !coupon.plan; });
|
|
778
|
+
if (couponsWithSamePlan.length > 0)
|
|
779
|
+
return rxjs.of(couponsWithSamePlan);
|
|
780
|
+
if (couponsWithNoPlan.length > 0)
|
|
781
|
+
return rxjs.of(couponsWithNoPlan);
|
|
782
|
+
throw new Error("Coupon subscription plan is invalid.");
|
|
783
|
+
}), 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(); })); }));
|
|
784
|
+
};
|
|
717
785
|
return CheckoutSubscriptionService;
|
|
718
786
|
}());
|
|
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 });
|
|
787
|
+
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 });
|
|
720
788
|
CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
|
|
721
789
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
|
|
722
790
|
type: i0.Injectable
|
|
@@ -724,7 +792,10 @@
|
|
|
724
792
|
return [{ type: undefined, decorators: [{
|
|
725
793
|
type: i0.Inject,
|
|
726
794
|
args: ['CheckoutSubscriptionRepository']
|
|
727
|
-
}] }
|
|
795
|
+
}] }, { type: undefined, decorators: [{
|
|
796
|
+
type: i0.Inject,
|
|
797
|
+
args: ['SubscriptionRepository']
|
|
798
|
+
}] }, { type: CouponService }];
|
|
728
799
|
} });
|
|
729
800
|
|
|
730
801
|
var OrderService = /** @class */ (function () {
|
|
@@ -755,6 +826,126 @@
|
|
|
755
826
|
}] }];
|
|
756
827
|
} });
|
|
757
828
|
|
|
829
|
+
var HomeShopService = /** @class */ (function () {
|
|
830
|
+
function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
831
|
+
this.categoryRepository = categoryRepository;
|
|
832
|
+
this.homeRepository = homeRepository;
|
|
833
|
+
this.productRepository = productRepository;
|
|
834
|
+
this.defaultShop = defaultShop;
|
|
835
|
+
this.buildCategoryGroupWithRequiredData = function (group) { return ({
|
|
836
|
+
category: i2.Category.toInstance(i2.pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
|
|
837
|
+
products: group.products.map(function (product) { return i2.Product.toInstance(i2.pick(product.toPlain(), [
|
|
838
|
+
'id',
|
|
839
|
+
'price',
|
|
840
|
+
'reviews',
|
|
841
|
+
'hasVariants',
|
|
842
|
+
'slug',
|
|
843
|
+
'sku',
|
|
844
|
+
'stock',
|
|
845
|
+
'costPrice',
|
|
846
|
+
'images',
|
|
847
|
+
'miniatures',
|
|
848
|
+
'name',
|
|
849
|
+
'weight',
|
|
850
|
+
])); }),
|
|
851
|
+
}); };
|
|
852
|
+
}
|
|
853
|
+
Object.defineProperty(HomeShopService.prototype, "homeId", {
|
|
854
|
+
get: function () {
|
|
855
|
+
if (this.defaultShop === i2.Shops.GLAMSHOP)
|
|
856
|
+
return 'glamshop';
|
|
857
|
+
if (this.defaultShop === i2.Shops.MENSMARKET)
|
|
858
|
+
return 'mens_market';
|
|
859
|
+
return null;
|
|
860
|
+
},
|
|
861
|
+
enumerable: false,
|
|
862
|
+
configurable: true
|
|
863
|
+
});
|
|
864
|
+
HomeShopService.prototype.getHomeData = function () {
|
|
865
|
+
var _this = this;
|
|
866
|
+
return this.getHomeConfiguration().pipe(operators.tap(function (home) { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), operators.map(function (home) { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), operators.concatMap(function (home) { return home
|
|
867
|
+
? rxjs.of(home)
|
|
868
|
+
: rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_b) {
|
|
869
|
+
var _c = __read(_b, 3), discoverProducts = _c[0], featuredProducts = _c[1], verticalProducts = _c[2];
|
|
870
|
+
return ({
|
|
871
|
+
discoverProducts: discoverProducts,
|
|
872
|
+
featuredProducts: featuredProducts,
|
|
873
|
+
verticalProducts: verticalProducts,
|
|
874
|
+
});
|
|
875
|
+
}), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
|
|
876
|
+
};
|
|
877
|
+
HomeShopService.prototype.getBanners = function (type) {
|
|
878
|
+
return this.getHomeConfiguration().pipe(operators.map(function (home) {
|
|
879
|
+
if (type === 'brand')
|
|
880
|
+
return home.brandsCarousel;
|
|
881
|
+
if (type === 'buyToWin')
|
|
882
|
+
return [home.buyToWinBanner];
|
|
883
|
+
if (type === 'block')
|
|
884
|
+
return home.blockBanners;
|
|
885
|
+
if (type === 'blog')
|
|
886
|
+
return [home.blogBanner];
|
|
887
|
+
}));
|
|
888
|
+
};
|
|
889
|
+
HomeShopService.prototype.getDiscoverProducts = function () {
|
|
890
|
+
var _this = this;
|
|
891
|
+
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); })); }));
|
|
892
|
+
};
|
|
893
|
+
HomeShopService.prototype.getFeaturedProducts = function () {
|
|
894
|
+
var _this = this;
|
|
895
|
+
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); })); }));
|
|
896
|
+
};
|
|
897
|
+
HomeShopService.prototype.getVerticalProducts = function () {
|
|
898
|
+
var _this = this;
|
|
899
|
+
return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.forkJoin([
|
|
900
|
+
_this.categoryRepository.get({ id: id }),
|
|
901
|
+
_this.productRepository.find([{ categories: { operator: i2.Where.LIKE, value: [id] } }], { limit: 12 }),
|
|
902
|
+
]).pipe(operators.map(function (_b) {
|
|
903
|
+
var _c = __read(_b, 2), category = _c[0], products = _c[1];
|
|
904
|
+
return ({ category: category, products: products.data });
|
|
905
|
+
}), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
|
|
906
|
+
};
|
|
907
|
+
HomeShopService.prototype.getHomeConfiguration = function () {
|
|
908
|
+
var _this = this;
|
|
909
|
+
return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
|
|
910
|
+
? rxjs.of(home)
|
|
911
|
+
: !_this.homeId
|
|
912
|
+
? rxjs.throwError(new i2.RequiredArgumentError(['homeId']))
|
|
913
|
+
: rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
|
|
914
|
+
};
|
|
915
|
+
HomeShopService.prototype.saveHomeData = function (homeData) {
|
|
916
|
+
var _this = this;
|
|
917
|
+
var data = {
|
|
918
|
+
createdAt: new Date(),
|
|
919
|
+
expiresAt: i2.add(new Date(), { hours: 1 }),
|
|
920
|
+
data: homeData,
|
|
921
|
+
};
|
|
922
|
+
return rxjs.from(this.homeRepository.update({
|
|
923
|
+
id: this.homeId,
|
|
924
|
+
data: data,
|
|
925
|
+
})).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
|
|
926
|
+
};
|
|
927
|
+
return HomeShopService;
|
|
928
|
+
}());
|
|
929
|
+
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 });
|
|
930
|
+
HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
|
|
931
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
|
|
932
|
+
type: i0.Injectable
|
|
933
|
+
}], ctorParameters: function () {
|
|
934
|
+
return [{ type: undefined, decorators: [{
|
|
935
|
+
type: i0.Inject,
|
|
936
|
+
args: ['CategoryRepository']
|
|
937
|
+
}] }, { type: undefined, decorators: [{
|
|
938
|
+
type: i0.Inject,
|
|
939
|
+
args: ['HomeRepository']
|
|
940
|
+
}] }, { type: undefined, decorators: [{
|
|
941
|
+
type: i0.Inject,
|
|
942
|
+
args: ['ProductRepository']
|
|
943
|
+
}] }, { type: i2__namespace.Shops, decorators: [{
|
|
944
|
+
type: i0.Inject,
|
|
945
|
+
args: [DEFAULT_SHOP]
|
|
946
|
+
}] }];
|
|
947
|
+
} });
|
|
948
|
+
|
|
758
949
|
var AngularFirebaseAuthModule = /** @class */ (function () {
|
|
759
950
|
function AngularFirebaseAuthModule() {
|
|
760
951
|
}
|
|
@@ -807,6 +998,13 @@
|
|
|
807
998
|
},
|
|
808
999
|
deps: ['AuthenticationService'],
|
|
809
1000
|
},
|
|
1001
|
+
{
|
|
1002
|
+
provide: 'RecoveryPassword',
|
|
1003
|
+
useFactory: function (authenticationService) {
|
|
1004
|
+
return new i2.RecoveryPassword(authenticationService);
|
|
1005
|
+
},
|
|
1006
|
+
deps: ['AuthenticationService'],
|
|
1007
|
+
},
|
|
810
1008
|
], imports: [[fire.AngularFireModule]] });
|
|
811
1009
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
|
|
812
1010
|
type: i0.NgModule,
|
|
@@ -848,6 +1046,50 @@
|
|
|
848
1046
|
},
|
|
849
1047
|
deps: ['AuthenticationService'],
|
|
850
1048
|
},
|
|
1049
|
+
{
|
|
1050
|
+
provide: 'RecoveryPassword',
|
|
1051
|
+
useFactory: function (authenticationService) {
|
|
1052
|
+
return new i2.RecoveryPassword(authenticationService);
|
|
1053
|
+
},
|
|
1054
|
+
deps: ['AuthenticationService'],
|
|
1055
|
+
},
|
|
1056
|
+
],
|
|
1057
|
+
}]
|
|
1058
|
+
}] });
|
|
1059
|
+
|
|
1060
|
+
var AngularElasticSeachModule = /** @class */ (function () {
|
|
1061
|
+
function AngularElasticSeachModule() {
|
|
1062
|
+
}
|
|
1063
|
+
AngularElasticSeachModule.initializeApp = function (options) {
|
|
1064
|
+
return {
|
|
1065
|
+
ngModule: AngularElasticSeachModule,
|
|
1066
|
+
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
1067
|
+
};
|
|
1068
|
+
};
|
|
1069
|
+
return AngularElasticSeachModule;
|
|
1070
|
+
}());
|
|
1071
|
+
AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1072
|
+
AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
|
|
1073
|
+
AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
|
|
1074
|
+
{
|
|
1075
|
+
provide: i2.ProductsIndex,
|
|
1076
|
+
useFactory: function (configuration) {
|
|
1077
|
+
return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
|
|
1078
|
+
},
|
|
1079
|
+
deps: [ES_CONFIG],
|
|
1080
|
+
},
|
|
1081
|
+
] });
|
|
1082
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
|
|
1083
|
+
type: i0.NgModule,
|
|
1084
|
+
args: [{
|
|
1085
|
+
providers: [
|
|
1086
|
+
{
|
|
1087
|
+
provide: i2.ProductsIndex,
|
|
1088
|
+
useFactory: function (configuration) {
|
|
1089
|
+
return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
|
|
1090
|
+
},
|
|
1091
|
+
deps: [ES_CONFIG],
|
|
1092
|
+
},
|
|
851
1093
|
],
|
|
852
1094
|
}]
|
|
853
1095
|
}] });
|
|
@@ -859,15 +1101,16 @@
|
|
|
859
1101
|
return {
|
|
860
1102
|
ngModule: AngularFirestoreModule,
|
|
861
1103
|
providers: [
|
|
862
|
-
{ provide: fire.FIREBASE_OPTIONS, useValue: options },
|
|
1104
|
+
{ provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
|
|
863
1105
|
{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
1106
|
+
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
864
1107
|
],
|
|
865
1108
|
};
|
|
866
1109
|
};
|
|
867
1110
|
return AngularFirestoreModule;
|
|
868
1111
|
}());
|
|
869
1112
|
AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
870
|
-
AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule] });
|
|
1113
|
+
AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
|
|
871
1114
|
AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
|
|
872
1115
|
{
|
|
873
1116
|
provide: 'BeautyProfileRepository',
|
|
@@ -1023,11 +1266,11 @@
|
|
|
1023
1266
|
},
|
|
1024
1267
|
deps: [i1$1.AngularFirestore, 'ProductRepository'],
|
|
1025
1268
|
},
|
|
1026
|
-
], imports: [[fire.AngularFireModule]] });
|
|
1269
|
+
], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
|
|
1027
1270
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
|
|
1028
1271
|
type: i0.NgModule,
|
|
1029
1272
|
args: [{
|
|
1030
|
-
imports: [fire.AngularFireModule],
|
|
1273
|
+
imports: [fire.AngularFireModule, AngularElasticSeachModule],
|
|
1031
1274
|
providers: [
|
|
1032
1275
|
{
|
|
1033
1276
|
provide: 'BeautyProfileRepository',
|
|
@@ -1193,19 +1436,35 @@
|
|
|
1193
1436
|
AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
|
|
1194
1437
|
return {
|
|
1195
1438
|
ngModule: AngularConnectModule,
|
|
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 }]))),
|
|
1439
|
+
providers: __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 }]))),
|
|
1197
1440
|
};
|
|
1198
1441
|
};
|
|
1199
1442
|
return AngularConnectModule;
|
|
1200
1443
|
}());
|
|
1201
1444
|
AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
1202
1445
|
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: [
|
|
1446
|
+
AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
|
|
1447
|
+
AuthService,
|
|
1448
|
+
CartService,
|
|
1449
|
+
CheckoutService,
|
|
1450
|
+
CheckoutSubscriptionService,
|
|
1451
|
+
CouponService,
|
|
1452
|
+
HomeShopService,
|
|
1453
|
+
OrderService,
|
|
1454
|
+
], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
|
|
1204
1455
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
|
|
1205
1456
|
type: i0.NgModule,
|
|
1206
1457
|
args: [{
|
|
1207
1458
|
imports: [fire.AngularFireModule, AngularFirestoreModule],
|
|
1208
|
-
providers: [
|
|
1459
|
+
providers: [
|
|
1460
|
+
AuthService,
|
|
1461
|
+
CartService,
|
|
1462
|
+
CheckoutService,
|
|
1463
|
+
CheckoutSubscriptionService,
|
|
1464
|
+
CouponService,
|
|
1465
|
+
HomeShopService,
|
|
1466
|
+
OrderService,
|
|
1467
|
+
],
|
|
1209
1468
|
}]
|
|
1210
1469
|
}] });
|
|
1211
1470
|
|
|
@@ -1221,6 +1480,7 @@
|
|
|
1221
1480
|
exports.CheckoutService = CheckoutService;
|
|
1222
1481
|
exports.CheckoutSubscriptionService = CheckoutSubscriptionService;
|
|
1223
1482
|
exports.CouponService = CouponService;
|
|
1483
|
+
exports.HomeShopService = HomeShopService;
|
|
1224
1484
|
exports.OrderService = OrderService;
|
|
1225
1485
|
|
|
1226
1486
|
Object.defineProperty(exports, '__esModule', { value: true });
|