@infrab4a/connect-angular 0.14.2 → 0.14.3-beta.1
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/angular-connect.module.d.ts +15 -15
- package/angular-elastic-search.module.d.ts +9 -9
- package/angular-firebase-auth.module.d.ts +10 -10
- package/angular-firestore.module.d.ts +15 -15
- package/bundles/infrab4a-connect-angular.umd.js +1432 -1418
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/consts/default-shop.const.d.ts +1 -1
- package/consts/es-config.const.d.ts +1 -1
- package/consts/index.d.ts +2 -2
- package/esm2015/angular-connect.module.js +47 -47
- package/esm2015/angular-elastic-search.module.js +38 -38
- package/esm2015/angular-firebase-auth.module.js +113 -113
- package/esm2015/angular-firestore.module.js +354 -340
- package/esm2015/consts/default-shop.const.js +2 -2
- package/esm2015/consts/es-config.const.js +2 -2
- package/esm2015/consts/index.js +3 -3
- package/esm2015/index.js +5 -5
- package/esm2015/infrab4a-connect-angular.js +4 -4
- package/esm2015/services/auth.service.js +42 -42
- package/esm2015/services/cart.service.js +167 -167
- package/esm2015/services/checkout-subscription.service.js +68 -68
- package/esm2015/services/checkout.service.js +79 -79
- package/esm2015/services/coupon.service.js +70 -70
- package/esm2015/services/errors/group-invalid-coupon.error.js +7 -7
- package/esm2015/services/errors/index.js +3 -3
- package/esm2015/services/errors/invalid-coupon.error.js +7 -7
- package/esm2015/services/home-shop.service.js +108 -108
- package/esm2015/services/index.js +8 -8
- package/esm2015/services/order.service.js +32 -32
- package/esm2015/services/types/index.js +3 -3
- package/esm2015/services/types/required-checkout-data.type.js +2 -2
- package/esm2015/services/types/required-checkout-subscription-data.type.js +2 -2
- package/fesm2015/infrab4a-connect-angular.js +1025 -1011
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/index.d.ts +4 -4
- package/infrab4a-connect-angular.d.ts +5 -5
- package/package.json +2 -2
- package/services/auth.service.d.ts +19 -19
- package/services/cart.service.d.ts +41 -41
- package/services/checkout-subscription.service.d.ts +18 -18
- package/services/checkout.service.d.ts +22 -22
- package/services/coupon.service.d.ts +14 -14
- package/services/errors/group-invalid-coupon.error.d.ts +5 -5
- package/services/errors/index.d.ts +2 -2
- package/services/errors/invalid-coupon.error.d.ts +4 -4
- package/services/home-shop.service.d.ts +24 -24
- package/services/index.d.ts +7 -7
- package/services/order.service.d.ts +13 -13
- package/services/types/index.d.ts +2 -2
- package/services/types/required-checkout-data.type.d.ts +2 -2
- package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
|
@@ -5,1053 +5,1067 @@ import { AngularFireAuth } from '@angular/fire/auth';
|
|
|
5
5
|
import { of, combineLatest, from, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
6
6
|
import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
|
|
7
7
|
import * as i2 from '@infrab4a/connect';
|
|
8
|
-
import { FinancialCoupon, Where, NotFoundError, Exclusivities, isNil, Checkout, CheckoutTypes, pick, LineItem, CouponTypes, CouponSubtypes, CheckoutSubscription, Order, Category, Product, Shops, RequiredArgumentError, add, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository } from '@infrab4a/connect';
|
|
8
|
+
import { FinancialCoupon, Where, NotFoundError, Exclusivities, isNil, Checkout, CheckoutTypes, pick, LineItem, CouponTypes, CouponSubtypes, CheckoutSubscription, Order, Category, Product, Shops, RequiredArgumentError, add, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository } from '@infrab4a/connect';
|
|
9
9
|
import { __awaiter } from 'tslib';
|
|
10
10
|
import cookie from 'js-cookie';
|
|
11
11
|
import * as i1$1 from '@angular/fire/firestore';
|
|
12
12
|
import { AngularFirestore } from '@angular/fire/firestore';
|
|
13
13
|
import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
|
|
14
14
|
|
|
15
|
-
class AuthService {
|
|
16
|
-
constructor(angularFireAuth, userRepository) {
|
|
17
|
-
this.angularFireAuth = angularFireAuth;
|
|
18
|
-
this.userRepository = userRepository;
|
|
19
|
-
}
|
|
20
|
-
getAuthstate() {
|
|
21
|
-
const observables = [
|
|
22
|
-
this.angularFireAuth.authState.pipe(catchError(() => of(null))),
|
|
23
|
-
this.getUser().pipe(catchError(() => of(null))),
|
|
24
|
-
];
|
|
25
|
-
return combineLatest(observables).pipe(map(([fireUser, user]) => {
|
|
26
|
-
return {
|
|
27
|
-
user,
|
|
28
|
-
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
29
|
-
};
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
getUser() {
|
|
33
|
-
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
|
|
34
|
-
}
|
|
35
|
-
getTokenId() {
|
|
36
|
-
return this.angularFireAuth.idToken;
|
|
37
|
-
}
|
|
38
|
-
getFireUser() {
|
|
39
|
-
return this.angularFireAuth.user.pipe(catchError(() => of(null)));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
43
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
|
|
44
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
|
|
45
|
-
type: Injectable
|
|
46
|
-
}], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
|
|
47
|
-
type: Inject,
|
|
48
|
-
args: ['UserRepository']
|
|
15
|
+
class AuthService {
|
|
16
|
+
constructor(angularFireAuth, userRepository) {
|
|
17
|
+
this.angularFireAuth = angularFireAuth;
|
|
18
|
+
this.userRepository = userRepository;
|
|
19
|
+
}
|
|
20
|
+
getAuthstate() {
|
|
21
|
+
const observables = [
|
|
22
|
+
this.angularFireAuth.authState.pipe(catchError(() => of(null))),
|
|
23
|
+
this.getUser().pipe(catchError(() => of(null))),
|
|
24
|
+
];
|
|
25
|
+
return combineLatest(observables).pipe(map(([fireUser, user]) => {
|
|
26
|
+
return {
|
|
27
|
+
user,
|
|
28
|
+
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
29
|
+
};
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
getUser() {
|
|
33
|
+
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
|
|
34
|
+
}
|
|
35
|
+
getTokenId() {
|
|
36
|
+
return this.angularFireAuth.idToken;
|
|
37
|
+
}
|
|
38
|
+
getFireUser() {
|
|
39
|
+
return this.angularFireAuth.user.pipe(catchError(() => of(null)));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
43
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
|
|
45
|
+
type: Injectable
|
|
46
|
+
}], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
|
|
47
|
+
type: Inject,
|
|
48
|
+
args: ['UserRepository']
|
|
49
49
|
}] }]; } });
|
|
50
50
|
|
|
51
51
|
const DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
52
52
|
|
|
53
53
|
const ES_CONFIG = 'ES_CONFIG';
|
|
54
54
|
|
|
55
|
-
class InvalidCouponError extends Error {
|
|
56
|
-
constructor(message) {
|
|
57
|
-
super(message);
|
|
58
|
-
this.message = message;
|
|
59
|
-
}
|
|
55
|
+
class InvalidCouponError extends Error {
|
|
56
|
+
constructor(message) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.message = message;
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
class GroupInvalidCouponError extends Error {
|
|
63
|
-
constructor(errors) {
|
|
64
|
-
super('Many coupon errors throw');
|
|
65
|
-
this.errors = errors;
|
|
66
|
-
}
|
|
62
|
+
class GroupInvalidCouponError extends Error {
|
|
63
|
+
constructor(errors) {
|
|
64
|
+
super('Many coupon errors throw');
|
|
65
|
+
this.errors = errors;
|
|
66
|
+
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
class CouponService {
|
|
70
|
-
constructor(couponRepository, defaultShop) {
|
|
71
|
-
this.couponRepository = couponRepository;
|
|
72
|
-
this.defaultShop = defaultShop;
|
|
73
|
-
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
74
|
-
this.separateValidCoupons = (coupons, userEmail) => coupons
|
|
75
|
-
.map((coupon) => {
|
|
76
|
-
try {
|
|
77
|
-
if (!FinancialCoupon.isFinancialCoupon(coupon))
|
|
78
|
-
throw new InvalidCouponError('Coupon is not valid');
|
|
79
|
-
if (this.isValidCoupon(coupon, userEmail))
|
|
80
|
-
return coupon;
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
return error;
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
.reduce((current, coupon) => (Object.assign(Object.assign({}, current), (FinancialCoupon.isFinancialCoupon(coupon)
|
|
87
|
-
? { valids: [...current.valids, coupon] }
|
|
88
|
-
: { invalids: [...current.invalids, coupon] }))), {
|
|
89
|
-
valids: [],
|
|
90
|
-
invalids: [],
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
checkCoupon(nickname, userEmail, checkoutType) {
|
|
94
|
-
return from(this.couponRepository.find([
|
|
95
|
-
{
|
|
96
|
-
nickname: { operator: Where.EQUALS, value: nickname },
|
|
97
|
-
shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
|
|
98
|
-
checkoutType: { operator: Where.EQUALS, value: checkoutType },
|
|
99
|
-
},
|
|
100
|
-
])).pipe(concatMap((coupons) => coupons.count < 1 ? throwError(() => new NotFoundError('Coupon not found')) : of(coupons.data)), map((coupons) => this.separateValidCoupons(coupons, userEmail)), map(({ valids, invalids }) => {
|
|
101
|
-
if (!valids.length)
|
|
102
|
-
throw new GroupInvalidCouponError(invalids);
|
|
103
|
-
return valids;
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
isValidCoupon(coupon, userEmail) {
|
|
107
|
-
if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
|
|
108
|
-
throw new InvalidCouponError('User is not a collaborator');
|
|
109
|
-
if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
|
|
110
|
-
throw new InvalidCouponError('Coupon is not valid for user');
|
|
111
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
|
|
112
|
-
throw new InvalidCouponError('Coupon is expired');
|
|
113
|
-
return true;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
117
|
-
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
118
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
|
|
119
|
-
type: Injectable,
|
|
120
|
-
args: [{
|
|
121
|
-
providedIn: 'root',
|
|
122
|
-
}]
|
|
123
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
124
|
-
type: Inject,
|
|
125
|
-
args: ['CouponRepository']
|
|
126
|
-
}] }, { type: i2.Shops, decorators: [{
|
|
127
|
-
type: Inject,
|
|
128
|
-
args: [DEFAULT_SHOP]
|
|
69
|
+
class CouponService {
|
|
70
|
+
constructor(couponRepository, defaultShop) {
|
|
71
|
+
this.couponRepository = couponRepository;
|
|
72
|
+
this.defaultShop = defaultShop;
|
|
73
|
+
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
74
|
+
this.separateValidCoupons = (coupons, userEmail) => coupons
|
|
75
|
+
.map((coupon) => {
|
|
76
|
+
try {
|
|
77
|
+
if (!FinancialCoupon.isFinancialCoupon(coupon))
|
|
78
|
+
throw new InvalidCouponError('Coupon is not valid');
|
|
79
|
+
if (this.isValidCoupon(coupon, userEmail))
|
|
80
|
+
return coupon;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
return error;
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
.reduce((current, coupon) => (Object.assign(Object.assign({}, current), (FinancialCoupon.isFinancialCoupon(coupon)
|
|
87
|
+
? { valids: [...current.valids, coupon] }
|
|
88
|
+
: { invalids: [...current.invalids, coupon] }))), {
|
|
89
|
+
valids: [],
|
|
90
|
+
invalids: [],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
checkCoupon(nickname, userEmail, checkoutType) {
|
|
94
|
+
return from(this.couponRepository.find([
|
|
95
|
+
{
|
|
96
|
+
nickname: { operator: Where.EQUALS, value: nickname },
|
|
97
|
+
shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
|
|
98
|
+
checkoutType: { operator: Where.EQUALS, value: checkoutType },
|
|
99
|
+
},
|
|
100
|
+
])).pipe(concatMap((coupons) => coupons.count < 1 ? throwError(() => new NotFoundError('Coupon not found')) : of(coupons.data)), map((coupons) => this.separateValidCoupons(coupons, userEmail)), map(({ valids, invalids }) => {
|
|
101
|
+
if (!valids.length)
|
|
102
|
+
throw new GroupInvalidCouponError(invalids);
|
|
103
|
+
return valids;
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
isValidCoupon(coupon, userEmail) {
|
|
107
|
+
if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
|
|
108
|
+
throw new InvalidCouponError('User is not a collaborator');
|
|
109
|
+
if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
|
|
110
|
+
throw new InvalidCouponError('Coupon is not valid for user');
|
|
111
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
|
|
112
|
+
throw new InvalidCouponError('Coupon is expired');
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
117
|
+
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
118
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
|
|
119
|
+
type: Injectable,
|
|
120
|
+
args: [{
|
|
121
|
+
providedIn: 'root',
|
|
122
|
+
}]
|
|
123
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
124
|
+
type: Inject,
|
|
125
|
+
args: ['CouponRepository']
|
|
126
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
127
|
+
type: Inject,
|
|
128
|
+
args: [DEFAULT_SHOP]
|
|
129
129
|
}] }]; } });
|
|
130
130
|
|
|
131
|
-
class CheckoutService {
|
|
132
|
-
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
133
|
-
this.couponService = couponService;
|
|
134
|
-
this.checkoutRepository = checkoutRepository;
|
|
135
|
-
this.orderRepository = orderRepository;
|
|
136
|
-
this.userRepository = userRepository;
|
|
137
|
-
this.defaultShop = defaultShop;
|
|
138
|
-
}
|
|
139
|
-
getCheckout(checkoutData) {
|
|
140
|
-
const checkoutId = cookie.get('checkoutId');
|
|
141
|
-
if (!isNil(checkoutId))
|
|
142
|
-
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
143
|
-
return from(this.createCheckout(checkoutData));
|
|
144
|
-
}
|
|
145
|
-
getUserByCheckout(checkoutId) {
|
|
146
|
-
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id })); }), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
147
|
-
}
|
|
148
|
-
updateCheckoutLineItems(checkout) {
|
|
149
|
-
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
150
|
-
}
|
|
151
|
-
updateCheckoutUser(checkout) {
|
|
152
|
-
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
153
|
-
}
|
|
154
|
-
clearCheckoutFromSession() {
|
|
155
|
-
cookie.remove('checkoutId');
|
|
156
|
-
return of();
|
|
157
|
-
}
|
|
158
|
-
checkCoupon(nickname) {
|
|
159
|
-
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
160
|
-
var _a;
|
|
161
|
-
return this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE).pipe(concatMap((coupons) => of(coupons.shift())), concatMap((coupon) => {
|
|
162
|
-
var _a, _b;
|
|
163
|
-
return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
|
|
164
|
-
? from(this.orderRepository.find([{ user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } }])).pipe(concatMap((orders) => {
|
|
165
|
-
if (orders.data.length >= (coupon.useLimit || Infinity))
|
|
166
|
-
return throwError(() => new Error('Coupon is already applied'));
|
|
167
|
-
return of(coupon);
|
|
168
|
-
}))
|
|
169
|
-
: of(coupon);
|
|
170
|
-
}));
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
createCheckout(checkoutData) {
|
|
174
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
-
const checkout = yield this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }));
|
|
176
|
-
cookie.set('checkoutId', checkout.id);
|
|
177
|
-
return checkout;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
182
|
-
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
|
|
183
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
|
|
184
|
-
type: Injectable
|
|
185
|
-
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
186
|
-
type: Inject,
|
|
187
|
-
args: ['CheckoutRepository']
|
|
188
|
-
}] }, { type: undefined, decorators: [{
|
|
189
|
-
type: Inject,
|
|
190
|
-
args: ['OrderRepository']
|
|
191
|
-
}] }, { type: undefined, decorators: [{
|
|
192
|
-
type: Inject,
|
|
193
|
-
args: ['UserRepository']
|
|
194
|
-
}] }, { type: i2.Shops, decorators: [{
|
|
195
|
-
type: Inject,
|
|
196
|
-
args: [DEFAULT_SHOP]
|
|
131
|
+
class CheckoutService {
|
|
132
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
133
|
+
this.couponService = couponService;
|
|
134
|
+
this.checkoutRepository = checkoutRepository;
|
|
135
|
+
this.orderRepository = orderRepository;
|
|
136
|
+
this.userRepository = userRepository;
|
|
137
|
+
this.defaultShop = defaultShop;
|
|
138
|
+
}
|
|
139
|
+
getCheckout(checkoutData) {
|
|
140
|
+
const checkoutId = cookie.get('checkoutId');
|
|
141
|
+
if (!isNil(checkoutId))
|
|
142
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
143
|
+
return from(this.createCheckout(checkoutData));
|
|
144
|
+
}
|
|
145
|
+
getUserByCheckout(checkoutId) {
|
|
146
|
+
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id })); }), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
147
|
+
}
|
|
148
|
+
updateCheckoutLineItems(checkout) {
|
|
149
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
150
|
+
}
|
|
151
|
+
updateCheckoutUser(checkout) {
|
|
152
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
153
|
+
}
|
|
154
|
+
clearCheckoutFromSession() {
|
|
155
|
+
cookie.remove('checkoutId');
|
|
156
|
+
return of();
|
|
157
|
+
}
|
|
158
|
+
checkCoupon(nickname) {
|
|
159
|
+
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
160
|
+
var _a;
|
|
161
|
+
return this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE).pipe(concatMap((coupons) => of(coupons.shift())), concatMap((coupon) => {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
|
|
164
|
+
? from(this.orderRepository.find([{ user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } }])).pipe(concatMap((orders) => {
|
|
165
|
+
if (orders.data.length >= (coupon.useLimit || Infinity))
|
|
166
|
+
return throwError(() => new Error('Coupon is already applied'));
|
|
167
|
+
return of(coupon);
|
|
168
|
+
}))
|
|
169
|
+
: of(coupon);
|
|
170
|
+
}));
|
|
171
|
+
}));
|
|
172
|
+
}
|
|
173
|
+
createCheckout(checkoutData) {
|
|
174
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
175
|
+
const checkout = yield this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }));
|
|
176
|
+
cookie.set('checkoutId', checkout.id);
|
|
177
|
+
return checkout;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
182
|
+
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
|
|
183
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
|
|
184
|
+
type: Injectable
|
|
185
|
+
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
186
|
+
type: Inject,
|
|
187
|
+
args: ['CheckoutRepository']
|
|
188
|
+
}] }, { type: undefined, decorators: [{
|
|
189
|
+
type: Inject,
|
|
190
|
+
args: ['OrderRepository']
|
|
191
|
+
}] }, { type: undefined, decorators: [{
|
|
192
|
+
type: Inject,
|
|
193
|
+
args: ['UserRepository']
|
|
194
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
195
|
+
type: Inject,
|
|
196
|
+
args: [DEFAULT_SHOP]
|
|
197
197
|
}] }]; } });
|
|
198
198
|
|
|
199
|
-
class CartService {
|
|
200
|
-
constructor(authService, checkoutService, defaultShop) {
|
|
201
|
-
this.authService = authService;
|
|
202
|
-
this.checkoutService = checkoutService;
|
|
203
|
-
this.defaultShop = defaultShop;
|
|
204
|
-
this.cartSubject = new Subject();
|
|
205
|
-
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
206
|
-
var _a;
|
|
207
|
-
const items = [];
|
|
208
|
-
const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
|
|
209
|
-
if (index > -1) {
|
|
210
|
-
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
211
|
-
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
212
|
-
}
|
|
213
|
-
else
|
|
214
|
-
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
215
|
-
return this.checkoutService
|
|
216
|
-
.updateCheckoutLineItems(checkoutLoaded)
|
|
217
|
-
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
218
|
-
}));
|
|
219
|
-
this.generateCartObject = (items) => {
|
|
220
|
-
const cart = {};
|
|
221
|
-
items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
222
|
-
var _a;
|
|
223
|
-
return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
|
|
224
|
-
});
|
|
225
|
-
return cart;
|
|
226
|
-
};
|
|
227
|
-
this.buildLineItem = ({ checkout, item, quantity, }) => {
|
|
228
|
-
var _a, _b, _c, _d, _e;
|
|
229
|
-
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((lineItem) => lineItem.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
230
|
-
if (this.checkMaxStock(item, quantity || 0))
|
|
231
|
-
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
232
|
-
const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
233
|
-
const { id, name, EAN, brand, slug, stock, price, weight, categories, sku } = item;
|
|
234
|
-
const isGift = item.isGift || null;
|
|
235
|
-
const pricePaid = this.getProductPrice({
|
|
236
|
-
product: item,
|
|
237
|
-
shop: checkout.shop || this.defaultShop,
|
|
238
|
-
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
239
|
-
});
|
|
240
|
-
return LineItem.toInstance({
|
|
241
|
-
id,
|
|
242
|
-
name,
|
|
243
|
-
EAN,
|
|
244
|
-
brand,
|
|
245
|
-
slug,
|
|
246
|
-
sku,
|
|
247
|
-
stock,
|
|
248
|
-
price,
|
|
249
|
-
image,
|
|
250
|
-
weight,
|
|
251
|
-
quantity: (item.quantity || 0) + (quantity || 0),
|
|
252
|
-
pricePaid,
|
|
253
|
-
categories,
|
|
254
|
-
isGift,
|
|
255
|
-
costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
|
|
256
|
-
});
|
|
257
|
-
};
|
|
258
|
-
this.getProductPrice = ({ product, shop, isSubscriber, }) => {
|
|
259
|
-
const info = product.getInfoByShop(shop);
|
|
260
|
-
if (product.isGift)
|
|
261
|
-
return 0;
|
|
262
|
-
return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
|
|
263
|
-
};
|
|
264
|
-
this.checkMaxStock = (item, quantity) => {
|
|
265
|
-
var _a;
|
|
266
|
-
const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
|
|
267
|
-
const currentItemAmount = item.quantity || 0;
|
|
268
|
-
return currentItemAmount + quantity > maxStock;
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
addItem(item, quantity = 1) {
|
|
272
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => ({
|
|
273
|
-
checkout,
|
|
274
|
-
lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }),
|
|
275
|
-
})), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
|
|
276
|
-
}
|
|
277
|
-
decreaseItem(item) {
|
|
278
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
279
|
-
var _a;
|
|
280
|
-
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
|
|
281
|
-
if (!isNil(checkoutItem))
|
|
282
|
-
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
283
|
-
return checkout;
|
|
284
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
285
|
-
}
|
|
286
|
-
getCart(checkout) {
|
|
287
|
-
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
288
|
-
return this.cartSubject;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* @deprecated The method should not be used
|
|
292
|
-
*/
|
|
293
|
-
getDiscount(coupon) {
|
|
294
|
-
switch (coupon.type) {
|
|
295
|
-
case CouponTypes.FINANCIAL:
|
|
296
|
-
return this.getFinancialDiscount(coupon);
|
|
297
|
-
case CouponTypes.PRODUCT:
|
|
298
|
-
return (subTotalPrice) => subTotalPrice;
|
|
299
|
-
case CouponTypes.GIFTCARD:
|
|
300
|
-
return this.getFinancialDiscount(coupon);
|
|
301
|
-
case CouponTypes.VOUCHER:
|
|
302
|
-
return (subTotalPrice) => subTotalPrice;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* @deprecated The method should not be used
|
|
307
|
-
*/
|
|
308
|
-
getVariantPriceDiscount(item, shop) {
|
|
309
|
-
return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice, of(item.getInfoByShop(shop).subscriberPrice), of(item.getInfoByShop(shop).price))), catchError(() => of(item.getInfoByShop(shop).price)));
|
|
310
|
-
}
|
|
311
|
-
removeItem(item) {
|
|
312
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
313
|
-
const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
|
|
314
|
-
if (index >= 0)
|
|
315
|
-
checkout.lineItems.splice(index, 1);
|
|
316
|
-
return checkout;
|
|
317
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
318
|
-
}
|
|
319
|
-
updateUserCart(user) {
|
|
320
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
|
|
321
|
-
var _a;
|
|
322
|
-
return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map((item) => this.buildLineItem({ checkout, item }))) || [] })));
|
|
323
|
-
}), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
324
|
-
}
|
|
325
|
-
clearCart() {
|
|
326
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
327
|
-
this.checkoutService.clearCheckoutFromSession();
|
|
328
|
-
return checkout;
|
|
329
|
-
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
330
|
-
}
|
|
331
|
-
buildCartFromCheckout(checkoutData) {
|
|
332
|
-
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
333
|
-
}
|
|
334
|
-
getFinancialDiscount(coupon) {
|
|
335
|
-
return (subTotalPrice) => {
|
|
336
|
-
if (FinancialCoupon.isFinancialCoupon(coupon))
|
|
337
|
-
switch (coupon.subtype) {
|
|
338
|
-
case CouponSubtypes.ABSOLUTE:
|
|
339
|
-
return subTotalPrice - coupon.discount * 100;
|
|
340
|
-
case CouponSubtypes.PERCENTAGE:
|
|
341
|
-
return subTotalPrice * (1 - coupon.discount / 100);
|
|
342
|
-
}
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
347
|
-
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
|
|
348
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
|
|
349
|
-
type: Injectable
|
|
350
|
-
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
|
|
351
|
-
type: Inject,
|
|
352
|
-
args: [DEFAULT_SHOP]
|
|
199
|
+
class CartService {
|
|
200
|
+
constructor(authService, checkoutService, defaultShop) {
|
|
201
|
+
this.authService = authService;
|
|
202
|
+
this.checkoutService = checkoutService;
|
|
203
|
+
this.defaultShop = defaultShop;
|
|
204
|
+
this.cartSubject = new Subject();
|
|
205
|
+
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
206
|
+
var _a;
|
|
207
|
+
const items = [];
|
|
208
|
+
const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
|
|
209
|
+
if (index > -1) {
|
|
210
|
+
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
211
|
+
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
212
|
+
}
|
|
213
|
+
else
|
|
214
|
+
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
215
|
+
return this.checkoutService
|
|
216
|
+
.updateCheckoutLineItems(checkoutLoaded)
|
|
217
|
+
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
218
|
+
}));
|
|
219
|
+
this.generateCartObject = (items) => {
|
|
220
|
+
const cart = {};
|
|
221
|
+
items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
222
|
+
var _a;
|
|
223
|
+
return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
|
|
224
|
+
});
|
|
225
|
+
return cart;
|
|
226
|
+
};
|
|
227
|
+
this.buildLineItem = ({ checkout, item, quantity, }) => {
|
|
228
|
+
var _a, _b, _c, _d, _e;
|
|
229
|
+
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((lineItem) => lineItem.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
230
|
+
if (this.checkMaxStock(item, quantity || 0))
|
|
231
|
+
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
232
|
+
const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
233
|
+
const { id, name, EAN, brand, slug, stock, price, weight, categories, sku } = item;
|
|
234
|
+
const isGift = item.isGift || null;
|
|
235
|
+
const pricePaid = this.getProductPrice({
|
|
236
|
+
product: item,
|
|
237
|
+
shop: checkout.shop || this.defaultShop,
|
|
238
|
+
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
239
|
+
});
|
|
240
|
+
return LineItem.toInstance({
|
|
241
|
+
id,
|
|
242
|
+
name,
|
|
243
|
+
EAN,
|
|
244
|
+
brand,
|
|
245
|
+
slug,
|
|
246
|
+
sku,
|
|
247
|
+
stock,
|
|
248
|
+
price,
|
|
249
|
+
image,
|
|
250
|
+
weight,
|
|
251
|
+
quantity: (item.quantity || 0) + (quantity || 0),
|
|
252
|
+
pricePaid,
|
|
253
|
+
categories,
|
|
254
|
+
isGift,
|
|
255
|
+
costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
this.getProductPrice = ({ product, shop, isSubscriber, }) => {
|
|
259
|
+
const info = product.getInfoByShop(shop);
|
|
260
|
+
if (product.isGift)
|
|
261
|
+
return 0;
|
|
262
|
+
return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
|
|
263
|
+
};
|
|
264
|
+
this.checkMaxStock = (item, quantity) => {
|
|
265
|
+
var _a;
|
|
266
|
+
const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
|
|
267
|
+
const currentItemAmount = item.quantity || 0;
|
|
268
|
+
return currentItemAmount + quantity > maxStock;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
addItem(item, quantity = 1) {
|
|
272
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => ({
|
|
273
|
+
checkout,
|
|
274
|
+
lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }),
|
|
275
|
+
})), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
|
|
276
|
+
}
|
|
277
|
+
decreaseItem(item) {
|
|
278
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
279
|
+
var _a;
|
|
280
|
+
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
|
|
281
|
+
if (!isNil(checkoutItem))
|
|
282
|
+
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
283
|
+
return checkout;
|
|
284
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
285
|
+
}
|
|
286
|
+
getCart(checkout) {
|
|
287
|
+
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
288
|
+
return this.cartSubject;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* @deprecated The method should not be used
|
|
292
|
+
*/
|
|
293
|
+
getDiscount(coupon) {
|
|
294
|
+
switch (coupon.type) {
|
|
295
|
+
case CouponTypes.FINANCIAL:
|
|
296
|
+
return this.getFinancialDiscount(coupon);
|
|
297
|
+
case CouponTypes.PRODUCT:
|
|
298
|
+
return (subTotalPrice) => subTotalPrice;
|
|
299
|
+
case CouponTypes.GIFTCARD:
|
|
300
|
+
return this.getFinancialDiscount(coupon);
|
|
301
|
+
case CouponTypes.VOUCHER:
|
|
302
|
+
return (subTotalPrice) => subTotalPrice;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* @deprecated The method should not be used
|
|
307
|
+
*/
|
|
308
|
+
getVariantPriceDiscount(item, shop) {
|
|
309
|
+
return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice, of(item.getInfoByShop(shop).subscriberPrice), of(item.getInfoByShop(shop).price))), catchError(() => of(item.getInfoByShop(shop).price)));
|
|
310
|
+
}
|
|
311
|
+
removeItem(item) {
|
|
312
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
313
|
+
const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
|
|
314
|
+
if (index >= 0)
|
|
315
|
+
checkout.lineItems.splice(index, 1);
|
|
316
|
+
return checkout;
|
|
317
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
318
|
+
}
|
|
319
|
+
updateUserCart(user) {
|
|
320
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
|
|
321
|
+
var _a;
|
|
322
|
+
return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map((item) => this.buildLineItem({ checkout, item }))) || [] })));
|
|
323
|
+
}), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
324
|
+
}
|
|
325
|
+
clearCart() {
|
|
326
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
327
|
+
this.checkoutService.clearCheckoutFromSession();
|
|
328
|
+
return checkout;
|
|
329
|
+
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
330
|
+
}
|
|
331
|
+
buildCartFromCheckout(checkoutData) {
|
|
332
|
+
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
333
|
+
}
|
|
334
|
+
getFinancialDiscount(coupon) {
|
|
335
|
+
return (subTotalPrice) => {
|
|
336
|
+
if (FinancialCoupon.isFinancialCoupon(coupon))
|
|
337
|
+
switch (coupon.subtype) {
|
|
338
|
+
case CouponSubtypes.ABSOLUTE:
|
|
339
|
+
return subTotalPrice - coupon.discount * 100;
|
|
340
|
+
case CouponSubtypes.PERCENTAGE:
|
|
341
|
+
return subTotalPrice * (1 - coupon.discount / 100);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
347
|
+
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
|
|
348
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
|
|
349
|
+
type: Injectable
|
|
350
|
+
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
|
|
351
|
+
type: Inject,
|
|
352
|
+
args: [DEFAULT_SHOP]
|
|
353
353
|
}] }]; } });
|
|
354
354
|
|
|
355
|
-
class CheckoutSubscriptionService {
|
|
356
|
-
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
357
|
-
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
358
|
-
this.subscriptionRepository = subscriptionRepository;
|
|
359
|
-
this.couponService = couponService;
|
|
360
|
-
this.checkCouponsWithCheckout = (coupons, checkout) => forkJoin(coupons.map((coupon) => {
|
|
361
|
-
var _a;
|
|
362
|
-
return from(this.subscriptionRepository.find([{ user: { email: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email }, coupon: { id: coupon.id } }])).pipe(map((subscriptions) => ({ coupon, subscriptions })));
|
|
363
|
-
})).pipe(map((results) => results.map(({ coupon, subscriptions }) => {
|
|
364
|
-
if (subscriptions.data.length >= (coupon.useLimit || Infinity))
|
|
365
|
-
return new InvalidCouponError('Coupon is already applied');
|
|
366
|
-
return coupon;
|
|
367
|
-
})), map((validatedCoupons) => ({
|
|
368
|
-
valids: validatedCoupons.filter((coupon) => FinancialCoupon.isFinancialCoupon(coupon)),
|
|
369
|
-
invalids: validatedCoupons.filter((coupon) => coupon instanceof InvalidCouponError),
|
|
370
|
-
})), concatMap(({ valids, invalids }) => valids.length ? of(valids) : throwError(new GroupInvalidCouponError(invalids))));
|
|
371
|
-
}
|
|
372
|
-
getCheckoutSubscription(checkoutData) {
|
|
373
|
-
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
374
|
-
if (!isNil(checkoutId))
|
|
375
|
-
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
376
|
-
return from(this.createCheckoutSubscription(checkoutData));
|
|
377
|
-
}
|
|
378
|
-
createCheckoutSubscription(checkoutData) {
|
|
379
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
380
|
-
const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
|
|
381
|
-
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
382
|
-
return checkout;
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
clearCheckoutSubscriptionFromSession() {
|
|
386
|
-
cookie.remove('checkoutSubscriptionId');
|
|
387
|
-
return of();
|
|
388
|
-
}
|
|
389
|
-
checkCoupon(nickname, userEmail) {
|
|
390
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION).pipe(concatMap((coupons) => {
|
|
391
|
-
const couponsWithSamePlan = coupons.filter((coupon) => checkout.subscriptionPlan.name === coupon.plan);
|
|
392
|
-
const couponsWithNoPlan = coupons.filter((coupon) => !coupon.plan);
|
|
393
|
-
if (couponsWithSamePlan.length > 0)
|
|
394
|
-
return of(couponsWithSamePlan);
|
|
395
|
-
if (couponsWithNoPlan.length > 0)
|
|
396
|
-
return of(couponsWithNoPlan);
|
|
397
|
-
throw new Error(`Coupon subscription plan is invalid.`);
|
|
398
|
-
}), concatMap((coupons) => { var _a; return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email) ? this.checkCouponsWithCheckout(coupons, checkout) : of(coupons); }), map((validatedCoupons) => validatedCoupons.shift()))));
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
402
|
-
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
|
|
403
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
404
|
-
type: Injectable
|
|
405
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
406
|
-
type: Inject,
|
|
407
|
-
args: ['CheckoutSubscriptionRepository']
|
|
408
|
-
}] }, { type: undefined, decorators: [{
|
|
409
|
-
type: Inject,
|
|
410
|
-
args: ['SubscriptionRepository']
|
|
355
|
+
class CheckoutSubscriptionService {
|
|
356
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
357
|
+
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
358
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
359
|
+
this.couponService = couponService;
|
|
360
|
+
this.checkCouponsWithCheckout = (coupons, checkout) => forkJoin(coupons.map((coupon) => {
|
|
361
|
+
var _a;
|
|
362
|
+
return from(this.subscriptionRepository.find([{ user: { email: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email }, coupon: { id: coupon.id } }])).pipe(map((subscriptions) => ({ coupon, subscriptions })));
|
|
363
|
+
})).pipe(map((results) => results.map(({ coupon, subscriptions }) => {
|
|
364
|
+
if (subscriptions.data.length >= (coupon.useLimit || Infinity))
|
|
365
|
+
return new InvalidCouponError('Coupon is already applied');
|
|
366
|
+
return coupon;
|
|
367
|
+
})), map((validatedCoupons) => ({
|
|
368
|
+
valids: validatedCoupons.filter((coupon) => FinancialCoupon.isFinancialCoupon(coupon)),
|
|
369
|
+
invalids: validatedCoupons.filter((coupon) => coupon instanceof InvalidCouponError),
|
|
370
|
+
})), concatMap(({ valids, invalids }) => valids.length ? of(valids) : throwError(new GroupInvalidCouponError(invalids))));
|
|
371
|
+
}
|
|
372
|
+
getCheckoutSubscription(checkoutData) {
|
|
373
|
+
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
374
|
+
if (!isNil(checkoutId))
|
|
375
|
+
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
376
|
+
return from(this.createCheckoutSubscription(checkoutData));
|
|
377
|
+
}
|
|
378
|
+
createCheckoutSubscription(checkoutData) {
|
|
379
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
380
|
+
const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
|
|
381
|
+
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
382
|
+
return checkout;
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
clearCheckoutSubscriptionFromSession() {
|
|
386
|
+
cookie.remove('checkoutSubscriptionId');
|
|
387
|
+
return of();
|
|
388
|
+
}
|
|
389
|
+
checkCoupon(nickname, userEmail) {
|
|
390
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION).pipe(concatMap((coupons) => {
|
|
391
|
+
const couponsWithSamePlan = coupons.filter((coupon) => checkout.subscriptionPlan.name === coupon.plan);
|
|
392
|
+
const couponsWithNoPlan = coupons.filter((coupon) => !coupon.plan);
|
|
393
|
+
if (couponsWithSamePlan.length > 0)
|
|
394
|
+
return of(couponsWithSamePlan);
|
|
395
|
+
if (couponsWithNoPlan.length > 0)
|
|
396
|
+
return of(couponsWithNoPlan);
|
|
397
|
+
throw new Error(`Coupon subscription plan is invalid.`);
|
|
398
|
+
}), concatMap((coupons) => { var _a; return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email) ? this.checkCouponsWithCheckout(coupons, checkout) : of(coupons); }), map((validatedCoupons) => validatedCoupons.shift()))));
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
402
|
+
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
|
|
403
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
404
|
+
type: Injectable
|
|
405
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
406
|
+
type: Inject,
|
|
407
|
+
args: ['CheckoutSubscriptionRepository']
|
|
408
|
+
}] }, { type: undefined, decorators: [{
|
|
409
|
+
type: Inject,
|
|
410
|
+
args: ['SubscriptionRepository']
|
|
411
411
|
}] }, { type: CouponService }]; } });
|
|
412
412
|
|
|
413
|
-
class OrderService {
|
|
414
|
-
constructor(angularFirestore, orderRepository) {
|
|
415
|
-
this.angularFirestore = angularFirestore;
|
|
416
|
-
this.orderRepository = orderRepository;
|
|
417
|
-
this.orderSubject = new Subject();
|
|
418
|
-
}
|
|
419
|
-
getOrder(id) {
|
|
420
|
-
this.angularFirestore
|
|
421
|
-
.doc(`${this.orderRepository.collectionName}/${id}`)
|
|
422
|
-
.valueChanges()
|
|
423
|
-
.pipe(map((doc) => Order.toInstance(doc)))
|
|
424
|
-
.subscribe((doc) => this.orderSubject.next(doc));
|
|
425
|
-
return this.orderSubject;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
429
|
-
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
|
|
430
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
|
|
431
|
-
type: Injectable
|
|
432
|
-
}], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i2.OrderFirestoreRepository, decorators: [{
|
|
433
|
-
type: Inject,
|
|
434
|
-
args: ['OrderRepository']
|
|
413
|
+
class OrderService {
|
|
414
|
+
constructor(angularFirestore, orderRepository) {
|
|
415
|
+
this.angularFirestore = angularFirestore;
|
|
416
|
+
this.orderRepository = orderRepository;
|
|
417
|
+
this.orderSubject = new Subject();
|
|
418
|
+
}
|
|
419
|
+
getOrder(id) {
|
|
420
|
+
this.angularFirestore
|
|
421
|
+
.doc(`${this.orderRepository.collectionName}/${id}`)
|
|
422
|
+
.valueChanges()
|
|
423
|
+
.pipe(map((doc) => Order.toInstance(doc)))
|
|
424
|
+
.subscribe((doc) => this.orderSubject.next(doc));
|
|
425
|
+
return this.orderSubject;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
429
|
+
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
|
|
430
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
|
|
431
|
+
type: Injectable
|
|
432
|
+
}], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i2.OrderFirestoreRepository, decorators: [{
|
|
433
|
+
type: Inject,
|
|
434
|
+
args: ['OrderRepository']
|
|
435
435
|
}] }]; } });
|
|
436
436
|
|
|
437
|
-
class HomeShopService {
|
|
438
|
-
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
439
|
-
this.categoryRepository = categoryRepository;
|
|
440
|
-
this.homeRepository = homeRepository;
|
|
441
|
-
this.productRepository = productRepository;
|
|
442
|
-
this.defaultShop = defaultShop;
|
|
443
|
-
this.buildCategoryGroupWithRequiredData = (group) => ({
|
|
444
|
-
category: Category.toInstance(pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
|
|
445
|
-
products: group.products.map((product) => Product.toInstance(pick(product.toPlain(), [
|
|
446
|
-
'id',
|
|
447
|
-
'price',
|
|
448
|
-
'reviews',
|
|
449
|
-
'hasVariants',
|
|
450
|
-
'slug',
|
|
451
|
-
'sku',
|
|
452
|
-
'stock',
|
|
453
|
-
'costPrice',
|
|
454
|
-
'images',
|
|
455
|
-
'miniatures',
|
|
456
|
-
'name',
|
|
457
|
-
'weight',
|
|
458
|
-
]))),
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
get homeId() {
|
|
462
|
-
if (this.defaultShop === Shops.GLAMSHOP)
|
|
463
|
-
return 'glamshop';
|
|
464
|
-
if (this.defaultShop === Shops.MENSMARKET)
|
|
465
|
-
return 'mens_market';
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
getHomeData() {
|
|
469
|
-
return this.getHomeConfiguration().pipe(tap((home) => { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), map((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); }), concatMap((home) => home
|
|
470
|
-
? of(home)
|
|
471
|
-
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
472
|
-
discoverProducts,
|
|
473
|
-
featuredProducts,
|
|
474
|
-
verticalProducts,
|
|
475
|
-
})), concatMap((data) => this.saveHomeData(data)))));
|
|
476
|
-
}
|
|
477
|
-
getBanners(type) {
|
|
478
|
-
return this.getHomeConfiguration().pipe(map((home) => {
|
|
479
|
-
if (type === 'brand')
|
|
480
|
-
return home.brandsCarousel;
|
|
481
|
-
if (type === 'buyToWin')
|
|
482
|
-
return [home.buyToWinBanner];
|
|
483
|
-
if (type === 'block')
|
|
484
|
-
return home.blockBanners;
|
|
485
|
-
if (type === 'blog')
|
|
486
|
-
return [home.blogBanner];
|
|
487
|
-
}));
|
|
488
|
-
}
|
|
489
|
-
getDiscoverProducts() {
|
|
490
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
491
|
-
}
|
|
492
|
-
getFeaturedProducts() {
|
|
493
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
494
|
-
}
|
|
495
|
-
getVerticalProducts() {
|
|
496
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => forkJoin([
|
|
497
|
-
this.categoryRepository.get({ id }),
|
|
498
|
-
this.productRepository.find([{ categories: { operator: Where.LIKE, value: [id] } }], { limit: 12 }),
|
|
499
|
-
]).pipe(map(([category, products]) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
500
|
-
}
|
|
501
|
-
getHomeConfiguration() {
|
|
502
|
-
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
503
|
-
? of(home)
|
|
504
|
-
: !this.homeId
|
|
505
|
-
? throwError(new RequiredArgumentError(['homeId']))
|
|
506
|
-
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
507
|
-
}
|
|
508
|
-
saveHomeData(homeData) {
|
|
509
|
-
const data = {
|
|
510
|
-
createdAt: new Date(),
|
|
511
|
-
expiresAt: add(new Date(), { hours: 1 }),
|
|
512
|
-
data: homeData,
|
|
513
|
-
};
|
|
514
|
-
return from(this.homeRepository.update({
|
|
515
|
-
id: this.homeId,
|
|
516
|
-
data,
|
|
517
|
-
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
521
|
-
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
|
|
522
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
|
|
523
|
-
type: Injectable
|
|
524
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
525
|
-
type: Inject,
|
|
526
|
-
args: ['CategoryRepository']
|
|
527
|
-
}] }, { type: undefined, decorators: [{
|
|
528
|
-
type: Inject,
|
|
529
|
-
args: ['HomeRepository']
|
|
530
|
-
}] }, { type: undefined, decorators: [{
|
|
531
|
-
type: Inject,
|
|
532
|
-
args: ['ProductRepository']
|
|
533
|
-
}] }, { type: i2.Shops, decorators: [{
|
|
534
|
-
type: Inject,
|
|
535
|
-
args: [DEFAULT_SHOP]
|
|
437
|
+
class HomeShopService {
|
|
438
|
+
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
439
|
+
this.categoryRepository = categoryRepository;
|
|
440
|
+
this.homeRepository = homeRepository;
|
|
441
|
+
this.productRepository = productRepository;
|
|
442
|
+
this.defaultShop = defaultShop;
|
|
443
|
+
this.buildCategoryGroupWithRequiredData = (group) => ({
|
|
444
|
+
category: Category.toInstance(pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
|
|
445
|
+
products: group.products.map((product) => Product.toInstance(pick(product.toPlain(), [
|
|
446
|
+
'id',
|
|
447
|
+
'price',
|
|
448
|
+
'reviews',
|
|
449
|
+
'hasVariants',
|
|
450
|
+
'slug',
|
|
451
|
+
'sku',
|
|
452
|
+
'stock',
|
|
453
|
+
'costPrice',
|
|
454
|
+
'images',
|
|
455
|
+
'miniatures',
|
|
456
|
+
'name',
|
|
457
|
+
'weight',
|
|
458
|
+
]))),
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
get homeId() {
|
|
462
|
+
if (this.defaultShop === Shops.GLAMSHOP)
|
|
463
|
+
return 'glamshop';
|
|
464
|
+
if (this.defaultShop === Shops.MENSMARKET)
|
|
465
|
+
return 'mens_market';
|
|
466
|
+
return null;
|
|
467
|
+
}
|
|
468
|
+
getHomeData() {
|
|
469
|
+
return this.getHomeConfiguration().pipe(tap((home) => { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), map((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); }), concatMap((home) => home
|
|
470
|
+
? of(home)
|
|
471
|
+
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
472
|
+
discoverProducts,
|
|
473
|
+
featuredProducts,
|
|
474
|
+
verticalProducts,
|
|
475
|
+
})), concatMap((data) => this.saveHomeData(data)))));
|
|
476
|
+
}
|
|
477
|
+
getBanners(type) {
|
|
478
|
+
return this.getHomeConfiguration().pipe(map((home) => {
|
|
479
|
+
if (type === 'brand')
|
|
480
|
+
return home.brandsCarousel;
|
|
481
|
+
if (type === 'buyToWin')
|
|
482
|
+
return [home.buyToWinBanner];
|
|
483
|
+
if (type === 'block')
|
|
484
|
+
return home.blockBanners;
|
|
485
|
+
if (type === 'blog')
|
|
486
|
+
return [home.blogBanner];
|
|
487
|
+
}));
|
|
488
|
+
}
|
|
489
|
+
getDiscoverProducts() {
|
|
490
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
491
|
+
}
|
|
492
|
+
getFeaturedProducts() {
|
|
493
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
494
|
+
}
|
|
495
|
+
getVerticalProducts() {
|
|
496
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => forkJoin([
|
|
497
|
+
this.categoryRepository.get({ id }),
|
|
498
|
+
this.productRepository.find([{ categories: { operator: Where.LIKE, value: [id] } }], { limit: 12 }),
|
|
499
|
+
]).pipe(map(([category, products]) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
500
|
+
}
|
|
501
|
+
getHomeConfiguration() {
|
|
502
|
+
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
503
|
+
? of(home)
|
|
504
|
+
: !this.homeId
|
|
505
|
+
? throwError(new RequiredArgumentError(['homeId']))
|
|
506
|
+
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
507
|
+
}
|
|
508
|
+
saveHomeData(homeData) {
|
|
509
|
+
const data = {
|
|
510
|
+
createdAt: new Date(),
|
|
511
|
+
expiresAt: add(new Date(), { hours: 1 }),
|
|
512
|
+
data: homeData,
|
|
513
|
+
};
|
|
514
|
+
return from(this.homeRepository.update({
|
|
515
|
+
id: this.homeId,
|
|
516
|
+
data,
|
|
517
|
+
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
521
|
+
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
|
|
522
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
|
|
523
|
+
type: Injectable
|
|
524
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
525
|
+
type: Inject,
|
|
526
|
+
args: ['CategoryRepository']
|
|
527
|
+
}] }, { type: undefined, decorators: [{
|
|
528
|
+
type: Inject,
|
|
529
|
+
args: ['HomeRepository']
|
|
530
|
+
}] }, { type: undefined, decorators: [{
|
|
531
|
+
type: Inject,
|
|
532
|
+
args: ['ProductRepository']
|
|
533
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
534
|
+
type: Inject,
|
|
535
|
+
args: [DEFAULT_SHOP]
|
|
536
536
|
}] }]; } });
|
|
537
537
|
|
|
538
|
-
class AngularFirebaseAuthModule {
|
|
539
|
-
static initializeApp(options, nameOrConfig) {
|
|
540
|
-
return {
|
|
541
|
-
ngModule: AngularFirebaseAuthModule,
|
|
542
|
-
providers: [
|
|
543
|
-
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
544
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
545
|
-
],
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
550
|
-
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
|
|
551
|
-
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
552
|
-
{
|
|
553
|
-
provide: 'Authentication',
|
|
554
|
-
useFactory: (authenticationService, userRepository) => {
|
|
555
|
-
return new Authentication(authenticationService, userRepository);
|
|
556
|
-
},
|
|
557
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
provide: 'AuthenticationService',
|
|
561
|
-
useFactory: (angularFireAuth) => {
|
|
562
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
563
|
-
},
|
|
564
|
-
deps: [AngularFireAuth],
|
|
565
|
-
},
|
|
566
|
-
{
|
|
567
|
-
provide: 'Register',
|
|
568
|
-
useFactory: (registerService, userRepository) => {
|
|
569
|
-
return new Register(registerService, userRepository);
|
|
570
|
-
},
|
|
571
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
572
|
-
},
|
|
573
|
-
{
|
|
574
|
-
provide: 'RegisterService',
|
|
575
|
-
useFactory: (angularFireAuth) => {
|
|
576
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
577
|
-
},
|
|
578
|
-
deps: [AngularFireAuth],
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
provide: 'SignOut',
|
|
582
|
-
useFactory: (authenticationService) => {
|
|
583
|
-
return new SignOut(authenticationService);
|
|
584
|
-
},
|
|
585
|
-
deps: ['AuthenticationService'],
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
provide: 'RecoveryPassword',
|
|
589
|
-
useFactory: (authenticationService) => {
|
|
590
|
-
return new RecoveryPassword(authenticationService);
|
|
591
|
-
},
|
|
592
|
-
deps: ['AuthenticationService'],
|
|
593
|
-
},
|
|
594
|
-
], imports: [[AngularFireModule]] });
|
|
595
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
596
|
-
type: NgModule,
|
|
597
|
-
args: [{
|
|
598
|
-
imports: [AngularFireModule],
|
|
599
|
-
providers: [
|
|
600
|
-
{
|
|
601
|
-
provide: 'Authentication',
|
|
602
|
-
useFactory: (authenticationService, userRepository) => {
|
|
603
|
-
return new Authentication(authenticationService, userRepository);
|
|
604
|
-
},
|
|
605
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
606
|
-
},
|
|
607
|
-
{
|
|
608
|
-
provide: 'AuthenticationService',
|
|
609
|
-
useFactory: (angularFireAuth) => {
|
|
610
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
611
|
-
},
|
|
612
|
-
deps: [AngularFireAuth],
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
provide: 'Register',
|
|
616
|
-
useFactory: (registerService, userRepository) => {
|
|
617
|
-
return new Register(registerService, userRepository);
|
|
618
|
-
},
|
|
619
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
provide: 'RegisterService',
|
|
623
|
-
useFactory: (angularFireAuth) => {
|
|
624
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
625
|
-
},
|
|
626
|
-
deps: [AngularFireAuth],
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
provide: 'SignOut',
|
|
630
|
-
useFactory: (authenticationService) => {
|
|
631
|
-
return new SignOut(authenticationService);
|
|
632
|
-
},
|
|
633
|
-
deps: ['AuthenticationService'],
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
provide: 'RecoveryPassword',
|
|
637
|
-
useFactory: (authenticationService) => {
|
|
638
|
-
return new RecoveryPassword(authenticationService);
|
|
639
|
-
},
|
|
640
|
-
deps: ['AuthenticationService'],
|
|
641
|
-
},
|
|
642
|
-
],
|
|
643
|
-
}]
|
|
538
|
+
class AngularFirebaseAuthModule {
|
|
539
|
+
static initializeApp(options, nameOrConfig) {
|
|
540
|
+
return {
|
|
541
|
+
ngModule: AngularFirebaseAuthModule,
|
|
542
|
+
providers: [
|
|
543
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
544
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
545
|
+
],
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
550
|
+
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
|
|
551
|
+
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
552
|
+
{
|
|
553
|
+
provide: 'Authentication',
|
|
554
|
+
useFactory: (authenticationService, userRepository) => {
|
|
555
|
+
return new Authentication(authenticationService, userRepository);
|
|
556
|
+
},
|
|
557
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
provide: 'AuthenticationService',
|
|
561
|
+
useFactory: (angularFireAuth) => {
|
|
562
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
563
|
+
},
|
|
564
|
+
deps: [AngularFireAuth],
|
|
565
|
+
},
|
|
566
|
+
{
|
|
567
|
+
provide: 'Register',
|
|
568
|
+
useFactory: (registerService, userRepository) => {
|
|
569
|
+
return new Register(registerService, userRepository);
|
|
570
|
+
},
|
|
571
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
provide: 'RegisterService',
|
|
575
|
+
useFactory: (angularFireAuth) => {
|
|
576
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
577
|
+
},
|
|
578
|
+
deps: [AngularFireAuth],
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
provide: 'SignOut',
|
|
582
|
+
useFactory: (authenticationService) => {
|
|
583
|
+
return new SignOut(authenticationService);
|
|
584
|
+
},
|
|
585
|
+
deps: ['AuthenticationService'],
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
provide: 'RecoveryPassword',
|
|
589
|
+
useFactory: (authenticationService) => {
|
|
590
|
+
return new RecoveryPassword(authenticationService);
|
|
591
|
+
},
|
|
592
|
+
deps: ['AuthenticationService'],
|
|
593
|
+
},
|
|
594
|
+
], imports: [[AngularFireModule]] });
|
|
595
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
596
|
+
type: NgModule,
|
|
597
|
+
args: [{
|
|
598
|
+
imports: [AngularFireModule],
|
|
599
|
+
providers: [
|
|
600
|
+
{
|
|
601
|
+
provide: 'Authentication',
|
|
602
|
+
useFactory: (authenticationService, userRepository) => {
|
|
603
|
+
return new Authentication(authenticationService, userRepository);
|
|
604
|
+
},
|
|
605
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
provide: 'AuthenticationService',
|
|
609
|
+
useFactory: (angularFireAuth) => {
|
|
610
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
611
|
+
},
|
|
612
|
+
deps: [AngularFireAuth],
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
provide: 'Register',
|
|
616
|
+
useFactory: (registerService, userRepository) => {
|
|
617
|
+
return new Register(registerService, userRepository);
|
|
618
|
+
},
|
|
619
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
provide: 'RegisterService',
|
|
623
|
+
useFactory: (angularFireAuth) => {
|
|
624
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
625
|
+
},
|
|
626
|
+
deps: [AngularFireAuth],
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
provide: 'SignOut',
|
|
630
|
+
useFactory: (authenticationService) => {
|
|
631
|
+
return new SignOut(authenticationService);
|
|
632
|
+
},
|
|
633
|
+
deps: ['AuthenticationService'],
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
provide: 'RecoveryPassword',
|
|
637
|
+
useFactory: (authenticationService) => {
|
|
638
|
+
return new RecoveryPassword(authenticationService);
|
|
639
|
+
},
|
|
640
|
+
deps: ['AuthenticationService'],
|
|
641
|
+
},
|
|
642
|
+
],
|
|
643
|
+
}]
|
|
644
644
|
}] });
|
|
645
645
|
|
|
646
|
-
class AngularElasticSeachModule {
|
|
647
|
-
static initializeApp(options) {
|
|
648
|
-
return {
|
|
649
|
-
ngModule: AngularElasticSeachModule,
|
|
650
|
-
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
655
|
-
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
|
|
656
|
-
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
657
|
-
{
|
|
658
|
-
provide: ProductsIndex,
|
|
659
|
-
useFactory: (configuration) => {
|
|
660
|
-
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
661
|
-
},
|
|
662
|
-
deps: [ES_CONFIG],
|
|
663
|
-
},
|
|
664
|
-
] });
|
|
665
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
666
|
-
type: NgModule,
|
|
667
|
-
args: [{
|
|
668
|
-
providers: [
|
|
669
|
-
{
|
|
670
|
-
provide: ProductsIndex,
|
|
671
|
-
useFactory: (configuration) => {
|
|
672
|
-
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
673
|
-
},
|
|
674
|
-
deps: [ES_CONFIG],
|
|
675
|
-
},
|
|
676
|
-
],
|
|
677
|
-
}]
|
|
646
|
+
class AngularElasticSeachModule {
|
|
647
|
+
static initializeApp(options) {
|
|
648
|
+
return {
|
|
649
|
+
ngModule: AngularElasticSeachModule,
|
|
650
|
+
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
655
|
+
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
|
|
656
|
+
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
657
|
+
{
|
|
658
|
+
provide: ProductsIndex,
|
|
659
|
+
useFactory: (configuration) => {
|
|
660
|
+
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
661
|
+
},
|
|
662
|
+
deps: [ES_CONFIG],
|
|
663
|
+
},
|
|
664
|
+
] });
|
|
665
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
666
|
+
type: NgModule,
|
|
667
|
+
args: [{
|
|
668
|
+
providers: [
|
|
669
|
+
{
|
|
670
|
+
provide: ProductsIndex,
|
|
671
|
+
useFactory: (configuration) => {
|
|
672
|
+
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
673
|
+
},
|
|
674
|
+
deps: [ES_CONFIG],
|
|
675
|
+
},
|
|
676
|
+
],
|
|
677
|
+
}]
|
|
678
678
|
}] });
|
|
679
679
|
|
|
680
|
-
class AngularFirestoreModule {
|
|
681
|
-
static initializeApp(options, nameOrConfig) {
|
|
682
|
-
return {
|
|
683
|
-
ngModule: AngularFirestoreModule,
|
|
684
|
-
providers: [
|
|
685
|
-
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
686
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
687
|
-
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
688
|
-
],
|
|
689
|
-
};
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
693
|
-
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
|
|
694
|
-
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
695
|
-
{
|
|
696
|
-
provide: 'BeautyProfileRepository',
|
|
697
|
-
useFactory: (firestore, userRepository) => {
|
|
698
|
-
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
699
|
-
},
|
|
700
|
-
deps: [AngularFirestore, 'UserRepository'],
|
|
701
|
-
},
|
|
702
|
-
{
|
|
703
|
-
provide: 'Buy2WinRepository',
|
|
704
|
-
useFactory: (firestore) => {
|
|
705
|
-
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
706
|
-
},
|
|
707
|
-
deps: [AngularFirestore],
|
|
708
|
-
},
|
|
709
|
-
{
|
|
710
|
-
provide: 'CategoryRepository',
|
|
711
|
-
useFactory: (firestore) => {
|
|
712
|
-
return new CategoryFirestoreRepository(firestore.firestore);
|
|
713
|
-
},
|
|
714
|
-
deps: [AngularFirestore],
|
|
715
|
-
},
|
|
716
|
-
{
|
|
717
|
-
provide: 'CheckoutRepository',
|
|
718
|
-
useFactory: (firestore) => {
|
|
719
|
-
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
720
|
-
},
|
|
721
|
-
deps: [AngularFirestore],
|
|
722
|
-
},
|
|
723
|
-
{
|
|
724
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
725
|
-
useFactory: (firestore) => {
|
|
726
|
-
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
727
|
-
},
|
|
728
|
-
deps: [AngularFirestore],
|
|
729
|
-
},
|
|
730
|
-
{
|
|
731
|
-
provide: 'CouponRepository',
|
|
732
|
-
useFactory: (firestore) => {
|
|
733
|
-
return new CouponFirestoreRepository(firestore.firestore);
|
|
734
|
-
},
|
|
735
|
-
deps: [AngularFirestore],
|
|
736
|
-
},
|
|
737
|
-
{
|
|
738
|
-
provide: 'EditionRepository',
|
|
739
|
-
useFactory: (firestore, subscriptionRepository) => {
|
|
740
|
-
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
741
|
-
},
|
|
742
|
-
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
743
|
-
},
|
|
744
|
-
{
|
|
745
|
-
provide: 'HomeRepository',
|
|
746
|
-
useFactory: (firestore) => {
|
|
747
|
-
return new HomeFirestoreRepository(firestore.firestore);
|
|
748
|
-
},
|
|
749
|
-
deps: [AngularFirestore],
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
provide: 'LeadRepository',
|
|
753
|
-
useFactory: (firestore) => {
|
|
754
|
-
return new LeadFirestoreRepository(firestore.firestore);
|
|
755
|
-
},
|
|
756
|
-
deps: [AngularFirestore],
|
|
757
|
-
},
|
|
758
|
-
{
|
|
759
|
-
provide: 'LegacyOrderRepository',
|
|
760
|
-
useFactory: (firestore) => {
|
|
761
|
-
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
762
|
-
},
|
|
763
|
-
deps: [AngularFirestore],
|
|
764
|
-
},
|
|
765
|
-
{
|
|
766
|
-
provide: 'ShopMenuRepository',
|
|
767
|
-
useFactory: (firestore) => {
|
|
768
|
-
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
769
|
-
},
|
|
770
|
-
deps: [AngularFirestore],
|
|
771
|
-
},
|
|
772
|
-
{
|
|
773
|
-
provide: 'OrderRepository',
|
|
774
|
-
useFactory: (firestore) => {
|
|
775
|
-
return new OrderFirestoreRepository(firestore.firestore);
|
|
776
|
-
},
|
|
777
|
-
deps: [AngularFirestore],
|
|
778
|
-
},
|
|
779
|
-
{
|
|
780
|
-
provide: 'PaymentRepository',
|
|
781
|
-
useFactory: (firestore) => {
|
|
782
|
-
return new PaymentFirestoreRepository(firestore.firestore);
|
|
783
|
-
},
|
|
784
|
-
deps: [AngularFirestore],
|
|
785
|
-
},
|
|
786
|
-
{
|
|
787
|
-
provide: 'ProductRepository',
|
|
788
|
-
useFactory: (firestore) => {
|
|
789
|
-
return new ProductFirestoreRepository(firestore.firestore);
|
|
790
|
-
},
|
|
791
|
-
deps: [AngularFirestore],
|
|
792
|
-
},
|
|
793
|
-
{
|
|
794
|
-
provide: '
|
|
795
|
-
useFactory: (firestore
|
|
796
|
-
return new
|
|
797
|
-
},
|
|
798
|
-
deps: [AngularFirestore
|
|
799
|
-
},
|
|
800
|
-
{
|
|
801
|
-
provide: '
|
|
802
|
-
useFactory: (firestore) => {
|
|
803
|
-
return new
|
|
804
|
-
},
|
|
805
|
-
deps: [AngularFirestore],
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
provide: '
|
|
809
|
-
useFactory: (firestore) => {
|
|
810
|
-
return new
|
|
811
|
-
},
|
|
812
|
-
deps: [AngularFirestore],
|
|
813
|
-
},
|
|
814
|
-
{
|
|
815
|
-
provide: '
|
|
816
|
-
useFactory: (firestore) => {
|
|
817
|
-
return new
|
|
818
|
-
},
|
|
819
|
-
deps: [AngularFirestore],
|
|
820
|
-
},
|
|
821
|
-
{
|
|
822
|
-
provide: '
|
|
823
|
-
useFactory: (firestore) => {
|
|
824
|
-
return new
|
|
825
|
-
},
|
|
826
|
-
deps: [AngularFirestore],
|
|
827
|
-
},
|
|
828
|
-
{
|
|
829
|
-
provide: '
|
|
830
|
-
useFactory: (firestore
|
|
831
|
-
return new
|
|
832
|
-
},
|
|
833
|
-
deps: [AngularFirestore
|
|
834
|
-
},
|
|
835
|
-
{
|
|
836
|
-
provide: '
|
|
837
|
-
useFactory: (firestore, userRepository) => {
|
|
838
|
-
return new
|
|
839
|
-
},
|
|
840
|
-
deps: [AngularFirestore, 'UserRepository'],
|
|
841
|
-
},
|
|
842
|
-
{
|
|
843
|
-
provide: '
|
|
844
|
-
useFactory: (firestore,
|
|
845
|
-
return new
|
|
846
|
-
},
|
|
847
|
-
deps: [AngularFirestore, '
|
|
848
|
-
},
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
{
|
|
863
|
-
provide: '
|
|
864
|
-
useFactory: (firestore) => {
|
|
865
|
-
return new
|
|
866
|
-
},
|
|
867
|
-
deps: [AngularFirestore],
|
|
868
|
-
},
|
|
869
|
-
{
|
|
870
|
-
provide: '
|
|
871
|
-
useFactory: (firestore) => {
|
|
872
|
-
return new
|
|
873
|
-
},
|
|
874
|
-
deps: [AngularFirestore],
|
|
875
|
-
},
|
|
876
|
-
{
|
|
877
|
-
provide: '
|
|
878
|
-
useFactory: (firestore) => {
|
|
879
|
-
return new
|
|
880
|
-
},
|
|
881
|
-
deps: [AngularFirestore],
|
|
882
|
-
},
|
|
883
|
-
{
|
|
884
|
-
provide: '
|
|
885
|
-
useFactory: (firestore) => {
|
|
886
|
-
return new
|
|
887
|
-
},
|
|
888
|
-
deps: [AngularFirestore],
|
|
889
|
-
},
|
|
890
|
-
{
|
|
891
|
-
provide: '
|
|
892
|
-
useFactory: (firestore) => {
|
|
893
|
-
return new
|
|
894
|
-
},
|
|
895
|
-
deps: [AngularFirestore],
|
|
896
|
-
},
|
|
897
|
-
{
|
|
898
|
-
provide: '
|
|
899
|
-
useFactory: (firestore
|
|
900
|
-
return new
|
|
901
|
-
},
|
|
902
|
-
deps: [AngularFirestore
|
|
903
|
-
},
|
|
904
|
-
{
|
|
905
|
-
provide: '
|
|
906
|
-
useFactory: (firestore) => {
|
|
907
|
-
return new
|
|
908
|
-
},
|
|
909
|
-
deps: [AngularFirestore],
|
|
910
|
-
},
|
|
911
|
-
{
|
|
912
|
-
provide: '
|
|
913
|
-
useFactory: (firestore) => {
|
|
914
|
-
return new
|
|
915
|
-
},
|
|
916
|
-
deps: [AngularFirestore],
|
|
917
|
-
},
|
|
918
|
-
{
|
|
919
|
-
provide: '
|
|
920
|
-
useFactory: (firestore) => {
|
|
921
|
-
return new
|
|
922
|
-
},
|
|
923
|
-
deps: [AngularFirestore],
|
|
924
|
-
},
|
|
925
|
-
{
|
|
926
|
-
provide: '
|
|
927
|
-
useFactory: (firestore) => {
|
|
928
|
-
return new
|
|
929
|
-
},
|
|
930
|
-
deps: [AngularFirestore],
|
|
931
|
-
},
|
|
932
|
-
{
|
|
933
|
-
provide: '
|
|
934
|
-
useFactory: (firestore) => {
|
|
935
|
-
return new
|
|
936
|
-
},
|
|
937
|
-
deps: [AngularFirestore],
|
|
938
|
-
},
|
|
939
|
-
{
|
|
940
|
-
provide: '
|
|
941
|
-
useFactory: (firestore) => {
|
|
942
|
-
return new
|
|
943
|
-
},
|
|
944
|
-
deps: [AngularFirestore],
|
|
945
|
-
},
|
|
946
|
-
{
|
|
947
|
-
provide: '
|
|
948
|
-
useFactory: (firestore) => {
|
|
949
|
-
return new
|
|
950
|
-
},
|
|
951
|
-
deps: [AngularFirestore],
|
|
952
|
-
},
|
|
953
|
-
{
|
|
954
|
-
provide: '
|
|
955
|
-
useFactory: (firestore
|
|
956
|
-
return new
|
|
957
|
-
},
|
|
958
|
-
deps: [AngularFirestore
|
|
959
|
-
},
|
|
960
|
-
{
|
|
961
|
-
provide: '
|
|
962
|
-
useFactory: (firestore) => {
|
|
963
|
-
return new
|
|
964
|
-
},
|
|
965
|
-
deps: [AngularFirestore],
|
|
966
|
-
},
|
|
967
|
-
{
|
|
968
|
-
provide: '
|
|
969
|
-
useFactory: (firestore) => {
|
|
970
|
-
return new
|
|
971
|
-
},
|
|
972
|
-
deps: [AngularFirestore],
|
|
973
|
-
},
|
|
974
|
-
{
|
|
975
|
-
provide: '
|
|
976
|
-
useFactory: (firestore) => {
|
|
977
|
-
return new
|
|
978
|
-
},
|
|
979
|
-
deps: [AngularFirestore],
|
|
980
|
-
},
|
|
981
|
-
{
|
|
982
|
-
provide: '
|
|
983
|
-
useFactory: (firestore) => {
|
|
984
|
-
return new
|
|
985
|
-
},
|
|
986
|
-
deps: [AngularFirestore],
|
|
987
|
-
},
|
|
988
|
-
{
|
|
989
|
-
provide: '
|
|
990
|
-
useFactory: (firestore
|
|
991
|
-
return new
|
|
992
|
-
},
|
|
993
|
-
deps: [AngularFirestore
|
|
994
|
-
},
|
|
995
|
-
{
|
|
996
|
-
provide: '
|
|
997
|
-
useFactory: (firestore
|
|
998
|
-
return new
|
|
999
|
-
},
|
|
1000
|
-
deps: [AngularFirestore
|
|
1001
|
-
},
|
|
1002
|
-
{
|
|
1003
|
-
provide: '
|
|
1004
|
-
useFactory: (firestore,
|
|
1005
|
-
return new
|
|
1006
|
-
},
|
|
1007
|
-
deps: [AngularFirestore, '
|
|
1008
|
-
},
|
|
1009
|
-
|
|
1010
|
-
|
|
680
|
+
class AngularFirestoreModule {
|
|
681
|
+
static initializeApp(options, nameOrConfig) {
|
|
682
|
+
return {
|
|
683
|
+
ngModule: AngularFirestoreModule,
|
|
684
|
+
providers: [
|
|
685
|
+
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
686
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
687
|
+
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
688
|
+
],
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
693
|
+
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
|
|
694
|
+
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
695
|
+
{
|
|
696
|
+
provide: 'BeautyProfileRepository',
|
|
697
|
+
useFactory: (firestore, userRepository) => {
|
|
698
|
+
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
699
|
+
},
|
|
700
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
701
|
+
},
|
|
702
|
+
{
|
|
703
|
+
provide: 'Buy2WinRepository',
|
|
704
|
+
useFactory: (firestore) => {
|
|
705
|
+
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
706
|
+
},
|
|
707
|
+
deps: [AngularFirestore],
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
provide: 'CategoryRepository',
|
|
711
|
+
useFactory: (firestore) => {
|
|
712
|
+
return new CategoryFirestoreRepository(firestore.firestore);
|
|
713
|
+
},
|
|
714
|
+
deps: [AngularFirestore],
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
provide: 'CheckoutRepository',
|
|
718
|
+
useFactory: (firestore) => {
|
|
719
|
+
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
720
|
+
},
|
|
721
|
+
deps: [AngularFirestore],
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
725
|
+
useFactory: (firestore) => {
|
|
726
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
727
|
+
},
|
|
728
|
+
deps: [AngularFirestore],
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
provide: 'CouponRepository',
|
|
732
|
+
useFactory: (firestore) => {
|
|
733
|
+
return new CouponFirestoreRepository(firestore.firestore);
|
|
734
|
+
},
|
|
735
|
+
deps: [AngularFirestore],
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
provide: 'EditionRepository',
|
|
739
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
740
|
+
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
741
|
+
},
|
|
742
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
provide: 'HomeRepository',
|
|
746
|
+
useFactory: (firestore) => {
|
|
747
|
+
return new HomeFirestoreRepository(firestore.firestore);
|
|
748
|
+
},
|
|
749
|
+
deps: [AngularFirestore],
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
provide: 'LeadRepository',
|
|
753
|
+
useFactory: (firestore) => {
|
|
754
|
+
return new LeadFirestoreRepository(firestore.firestore);
|
|
755
|
+
},
|
|
756
|
+
deps: [AngularFirestore],
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
provide: 'LegacyOrderRepository',
|
|
760
|
+
useFactory: (firestore) => {
|
|
761
|
+
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
762
|
+
},
|
|
763
|
+
deps: [AngularFirestore],
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
provide: 'ShopMenuRepository',
|
|
767
|
+
useFactory: (firestore) => {
|
|
768
|
+
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
769
|
+
},
|
|
770
|
+
deps: [AngularFirestore],
|
|
771
|
+
},
|
|
772
|
+
{
|
|
773
|
+
provide: 'OrderRepository',
|
|
774
|
+
useFactory: (firestore) => {
|
|
775
|
+
return new OrderFirestoreRepository(firestore.firestore);
|
|
776
|
+
},
|
|
777
|
+
deps: [AngularFirestore],
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
provide: 'PaymentRepository',
|
|
781
|
+
useFactory: (firestore) => {
|
|
782
|
+
return new PaymentFirestoreRepository(firestore.firestore);
|
|
783
|
+
},
|
|
784
|
+
deps: [AngularFirestore],
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
provide: 'ProductRepository',
|
|
788
|
+
useFactory: (firestore) => {
|
|
789
|
+
return new ProductFirestoreRepository(firestore.firestore);
|
|
790
|
+
},
|
|
791
|
+
deps: [AngularFirestore],
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
provide: 'ShopSettingsRepository',
|
|
795
|
+
useFactory: (firestore) => {
|
|
796
|
+
return new ShopSettingsFirestoreRepository(firestore.firestore);
|
|
797
|
+
},
|
|
798
|
+
deps: [AngularFirestore],
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
provide: 'SubscriptionPaymentRepository',
|
|
802
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
803
|
+
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
804
|
+
},
|
|
805
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
provide: 'SubscriptionPlanRepository',
|
|
809
|
+
useFactory: (firestore) => {
|
|
810
|
+
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
811
|
+
},
|
|
812
|
+
deps: [AngularFirestore],
|
|
813
|
+
},
|
|
814
|
+
{
|
|
815
|
+
provide: 'SubscriptionProductRepository',
|
|
816
|
+
useFactory: (firestore) => {
|
|
817
|
+
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
818
|
+
},
|
|
819
|
+
deps: [AngularFirestore],
|
|
820
|
+
},
|
|
821
|
+
{
|
|
822
|
+
provide: 'SubscriptionRepository',
|
|
823
|
+
useFactory: (firestore) => {
|
|
824
|
+
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
825
|
+
},
|
|
826
|
+
deps: [AngularFirestore],
|
|
827
|
+
},
|
|
828
|
+
{
|
|
829
|
+
provide: 'UserRepository',
|
|
830
|
+
useFactory: (firestore) => {
|
|
831
|
+
return new UserFirestoreRepository(firestore.firestore);
|
|
832
|
+
},
|
|
833
|
+
deps: [AngularFirestore],
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
provide: 'UserAddressRepository',
|
|
837
|
+
useFactory: (firestore, userRepository) => {
|
|
838
|
+
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
839
|
+
},
|
|
840
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
841
|
+
},
|
|
842
|
+
{
|
|
843
|
+
provide: 'UserPaymentMethodRepository',
|
|
844
|
+
useFactory: (firestore, userRepository) => {
|
|
845
|
+
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
846
|
+
},
|
|
847
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
provide: 'VariantRepository',
|
|
851
|
+
useFactory: (firestore, productRepository) => {
|
|
852
|
+
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
853
|
+
},
|
|
854
|
+
deps: [AngularFirestore, 'ProductRepository'],
|
|
855
|
+
},
|
|
856
|
+
], imports: [[AngularFireModule, AngularElasticSeachModule]] });
|
|
857
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
858
|
+
type: NgModule,
|
|
859
|
+
args: [{
|
|
860
|
+
imports: [AngularFireModule, AngularElasticSeachModule],
|
|
861
|
+
providers: [
|
|
862
|
+
{
|
|
863
|
+
provide: 'BeautyProfileRepository',
|
|
864
|
+
useFactory: (firestore, userRepository) => {
|
|
865
|
+
return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
|
|
866
|
+
},
|
|
867
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
provide: 'Buy2WinRepository',
|
|
871
|
+
useFactory: (firestore) => {
|
|
872
|
+
return new Buy2WinFirestoreRepository(firestore.firestore);
|
|
873
|
+
},
|
|
874
|
+
deps: [AngularFirestore],
|
|
875
|
+
},
|
|
876
|
+
{
|
|
877
|
+
provide: 'CategoryRepository',
|
|
878
|
+
useFactory: (firestore) => {
|
|
879
|
+
return new CategoryFirestoreRepository(firestore.firestore);
|
|
880
|
+
},
|
|
881
|
+
deps: [AngularFirestore],
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
provide: 'CheckoutRepository',
|
|
885
|
+
useFactory: (firestore) => {
|
|
886
|
+
return new CheckoutFirestoreRepository(firestore.firestore);
|
|
887
|
+
},
|
|
888
|
+
deps: [AngularFirestore],
|
|
889
|
+
},
|
|
890
|
+
{
|
|
891
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
892
|
+
useFactory: (firestore) => {
|
|
893
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
|
|
894
|
+
},
|
|
895
|
+
deps: [AngularFirestore],
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
provide: 'CouponRepository',
|
|
899
|
+
useFactory: (firestore) => {
|
|
900
|
+
return new CouponFirestoreRepository(firestore.firestore);
|
|
901
|
+
},
|
|
902
|
+
deps: [AngularFirestore],
|
|
903
|
+
},
|
|
904
|
+
{
|
|
905
|
+
provide: 'EditionRepository',
|
|
906
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
907
|
+
return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
908
|
+
},
|
|
909
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
provide: 'HomeRepository',
|
|
913
|
+
useFactory: (firestore) => {
|
|
914
|
+
return new HomeFirestoreRepository(firestore.firestore);
|
|
915
|
+
},
|
|
916
|
+
deps: [AngularFirestore],
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
provide: 'LeadRepository',
|
|
920
|
+
useFactory: (firestore) => {
|
|
921
|
+
return new LeadFirestoreRepository(firestore.firestore);
|
|
922
|
+
},
|
|
923
|
+
deps: [AngularFirestore],
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
provide: 'LegacyOrderRepository',
|
|
927
|
+
useFactory: (firestore) => {
|
|
928
|
+
return new LegacyOrderFirestoreRepository(firestore.firestore);
|
|
929
|
+
},
|
|
930
|
+
deps: [AngularFirestore],
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
provide: 'ShopMenuRepository',
|
|
934
|
+
useFactory: (firestore) => {
|
|
935
|
+
return new ShopMenuFirestoreRepository(firestore.firestore);
|
|
936
|
+
},
|
|
937
|
+
deps: [AngularFirestore],
|
|
938
|
+
},
|
|
939
|
+
{
|
|
940
|
+
provide: 'OrderRepository',
|
|
941
|
+
useFactory: (firestore) => {
|
|
942
|
+
return new OrderFirestoreRepository(firestore.firestore);
|
|
943
|
+
},
|
|
944
|
+
deps: [AngularFirestore],
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
provide: 'PaymentRepository',
|
|
948
|
+
useFactory: (firestore) => {
|
|
949
|
+
return new PaymentFirestoreRepository(firestore.firestore);
|
|
950
|
+
},
|
|
951
|
+
deps: [AngularFirestore],
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
provide: 'ProductRepository',
|
|
955
|
+
useFactory: (firestore) => {
|
|
956
|
+
return new ProductFirestoreRepository(firestore.firestore);
|
|
957
|
+
},
|
|
958
|
+
deps: [AngularFirestore],
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
provide: 'ShopSettingsRepository',
|
|
962
|
+
useFactory: (firestore) => {
|
|
963
|
+
return new ShopSettingsFirestoreRepository(firestore.firestore);
|
|
964
|
+
},
|
|
965
|
+
deps: [AngularFirestore],
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
provide: 'SubscriptionPaymentRepository',
|
|
969
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
970
|
+
return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
|
|
971
|
+
},
|
|
972
|
+
deps: [AngularFirestore, 'SubscriptionRepository'],
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
provide: 'SubscriptionPlanRepository',
|
|
976
|
+
useFactory: (firestore) => {
|
|
977
|
+
return new SubscriptionPlanFirestoreRepository(firestore.firestore);
|
|
978
|
+
},
|
|
979
|
+
deps: [AngularFirestore],
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
provide: 'SubscriptionProductRepository',
|
|
983
|
+
useFactory: (firestore) => {
|
|
984
|
+
return new SubscriptionProductFirestoreRepository(firestore.firestore);
|
|
985
|
+
},
|
|
986
|
+
deps: [AngularFirestore],
|
|
987
|
+
},
|
|
988
|
+
{
|
|
989
|
+
provide: 'SubscriptionRepository',
|
|
990
|
+
useFactory: (firestore) => {
|
|
991
|
+
return new SubscriptionFirestoreRepository(firestore.firestore);
|
|
992
|
+
},
|
|
993
|
+
deps: [AngularFirestore],
|
|
994
|
+
},
|
|
995
|
+
{
|
|
996
|
+
provide: 'UserRepository',
|
|
997
|
+
useFactory: (firestore) => {
|
|
998
|
+
return new UserFirestoreRepository(firestore.firestore);
|
|
999
|
+
},
|
|
1000
|
+
deps: [AngularFirestore],
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
provide: 'UserAddressRepository',
|
|
1004
|
+
useFactory: (firestore, userRepository) => {
|
|
1005
|
+
return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
|
|
1006
|
+
},
|
|
1007
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
provide: 'UserPaymentMethodRepository',
|
|
1011
|
+
useFactory: (firestore, userRepository) => {
|
|
1012
|
+
return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
|
|
1013
|
+
},
|
|
1014
|
+
deps: [AngularFirestore, 'UserRepository'],
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
provide: 'VariantRepository',
|
|
1018
|
+
useFactory: (firestore, productRepository) => {
|
|
1019
|
+
return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
|
|
1020
|
+
},
|
|
1021
|
+
deps: [AngularFirestore, 'ProductRepository'],
|
|
1022
|
+
},
|
|
1023
|
+
],
|
|
1024
|
+
}]
|
|
1011
1025
|
}] });
|
|
1012
1026
|
|
|
1013
|
-
class AngularConnectModule {
|
|
1014
|
-
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
1015
|
-
return {
|
|
1016
|
-
ngModule: AngularConnectModule,
|
|
1017
|
-
providers: [
|
|
1018
|
-
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
1019
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
|
|
1020
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
1021
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
1022
|
-
],
|
|
1023
|
-
};
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1027
|
-
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
|
|
1028
|
-
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
|
|
1029
|
-
AuthService,
|
|
1030
|
-
CartService,
|
|
1031
|
-
CheckoutService,
|
|
1032
|
-
CheckoutSubscriptionService,
|
|
1033
|
-
CouponService,
|
|
1034
|
-
HomeShopService,
|
|
1035
|
-
OrderService,
|
|
1036
|
-
], imports: [[AngularFireModule, AngularFirestoreModule]] });
|
|
1037
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
1038
|
-
type: NgModule,
|
|
1039
|
-
args: [{
|
|
1040
|
-
imports: [AngularFireModule, AngularFirestoreModule],
|
|
1041
|
-
providers: [
|
|
1042
|
-
AuthService,
|
|
1043
|
-
CartService,
|
|
1044
|
-
CheckoutService,
|
|
1045
|
-
CheckoutSubscriptionService,
|
|
1046
|
-
CouponService,
|
|
1047
|
-
HomeShopService,
|
|
1048
|
-
OrderService,
|
|
1049
|
-
],
|
|
1050
|
-
}]
|
|
1027
|
+
class AngularConnectModule {
|
|
1028
|
+
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
1029
|
+
return {
|
|
1030
|
+
ngModule: AngularConnectModule,
|
|
1031
|
+
providers: [
|
|
1032
|
+
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
1033
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
|
|
1034
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
1035
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
1036
|
+
],
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1041
|
+
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
|
|
1042
|
+
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
|
|
1043
|
+
AuthService,
|
|
1044
|
+
CartService,
|
|
1045
|
+
CheckoutService,
|
|
1046
|
+
CheckoutSubscriptionService,
|
|
1047
|
+
CouponService,
|
|
1048
|
+
HomeShopService,
|
|
1049
|
+
OrderService,
|
|
1050
|
+
], imports: [[AngularFireModule, AngularFirestoreModule]] });
|
|
1051
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
1052
|
+
type: NgModule,
|
|
1053
|
+
args: [{
|
|
1054
|
+
imports: [AngularFireModule, AngularFirestoreModule],
|
|
1055
|
+
providers: [
|
|
1056
|
+
AuthService,
|
|
1057
|
+
CartService,
|
|
1058
|
+
CheckoutService,
|
|
1059
|
+
CheckoutSubscriptionService,
|
|
1060
|
+
CouponService,
|
|
1061
|
+
HomeShopService,
|
|
1062
|
+
OrderService,
|
|
1063
|
+
],
|
|
1064
|
+
}]
|
|
1051
1065
|
}] });
|
|
1052
1066
|
|
|
1053
|
-
/**
|
|
1054
|
-
* Generated bundle index. Do not edit.
|
|
1067
|
+
/**
|
|
1068
|
+
* Generated bundle index. Do not edit.
|
|
1055
1069
|
*/
|
|
1056
1070
|
|
|
1057
1071
|
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService };
|