@infrab4a/connect-angular 0.14.2-beta.11 → 0.14.2-beta.2

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