@infrab4a/connect-angular 0.14.2-beta.0 → 0.14.2-beta.10

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