@infrab4a/connect-angular 0.12.2 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/bundles/infrab4a-connect-angular.umd.js +1219 -1188
  2. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  3. package/esm2015/infrab4a-connect-angular.js +4 -4
  4. package/esm2015/lib/angular-connect.module.js +29 -29
  5. package/esm2015/lib/angular-firebase-auth.module.js +113 -113
  6. package/esm2015/lib/angular-firestore.module.js +336 -336
  7. package/esm2015/lib/consts/default-shop.const.js +1 -1
  8. package/esm2015/lib/consts/index.js +1 -1
  9. package/esm2015/lib/index.js +4 -4
  10. package/esm2015/lib/services/auth.service.js +41 -41
  11. package/esm2015/lib/services/cart.service.js +165 -165
  12. package/esm2015/lib/services/checkout-subscription.service.js +71 -37
  13. package/esm2015/lib/services/checkout.service.js +79 -79
  14. package/esm2015/lib/services/coupon.service.js +51 -51
  15. package/esm2015/lib/services/errors/index.js +1 -1
  16. package/esm2015/lib/services/errors/invalid-coupon.error.js +6 -6
  17. package/esm2015/lib/services/index.js +6 -6
  18. package/esm2015/lib/services/order.service.js +31 -31
  19. package/esm2015/lib/services/types/index.js +2 -2
  20. package/esm2015/lib/services/types/required-checkout-data.type.js +1 -1
  21. package/esm2015/lib/services/types/required-checkout-subscription-data.type.js +1 -1
  22. package/esm2015/public-api.js +1 -1
  23. package/fesm2015/infrab4a-connect-angular.js +841 -811
  24. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  25. package/infrab4a-connect-angular.d.ts +5 -5
  26. package/lib/angular-connect.module.d.ts +12 -12
  27. package/lib/angular-firebase-auth.module.d.ts +10 -10
  28. package/lib/angular-firestore.module.d.ts +10 -10
  29. package/lib/consts/default-shop.const.d.ts +1 -1
  30. package/lib/consts/index.d.ts +1 -1
  31. package/lib/index.d.ts +4 -4
  32. package/lib/services/auth.service.d.ts +19 -19
  33. package/lib/services/cart.service.d.ts +41 -41
  34. package/lib/services/checkout-subscription.service.d.ts +18 -13
  35. package/lib/services/checkout.service.d.ts +22 -22
  36. package/lib/services/coupon.service.d.ts +13 -13
  37. package/lib/services/errors/index.d.ts +1 -1
  38. package/lib/services/errors/invalid-coupon.error.d.ts +4 -4
  39. package/lib/services/index.d.ts +6 -6
  40. package/lib/services/order.service.d.ts +13 -13
  41. package/lib/services/types/index.d.ts +2 -2
  42. package/lib/services/types/required-checkout-data.type.d.ts +2 -2
  43. package/lib/services/types/required-checkout-subscription-data.type.d.ts +2 -2
  44. package/package.json +1 -1
  45. package/public-api.d.ts +1 -1
@@ -4,845 +4,875 @@ import * as i1 from '@angular/fire/auth';
4
4
  import { AngularFireAuth } from '@angular/fire/auth';
5
5
  import { of, combineLatest, from, throwError, Subject, iif } from 'rxjs';
6
6
  import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
7
- import * as i2 from '@infrab4a/connect';
7
+ import * as i1$1 from '@infrab4a/connect';
8
8
  import { Where, NotFoundError, FinancialCoupon, CheckoutTypes, Exclusivities, isNil, Checkout, pick, LineItem, CouponTypes, CouponSubtypes, CheckoutSubscription, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository } from '@infrab4a/connect';
9
9
  import { __awaiter } from 'tslib';
10
10
  import cookie from 'js-cookie';
11
- import * as i1$1 from '@angular/fire/firestore';
11
+ import * as i1$2 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
- class InvalidCouponError extends Error {
54
- constructor(message) {
55
- super(message);
56
- this.message = message;
57
- }
53
+ class InvalidCouponError extends Error {
54
+ constructor(message) {
55
+ super(message);
56
+ this.message = message;
57
+ }
58
58
  }
59
59
 
60
- class CouponService {
61
- constructor(couponRepository, defaultShop) {
62
- this.couponRepository = couponRepository;
63
- this.defaultShop = defaultShop;
64
- this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
65
- }
66
- checkCoupon(nickname, userEmail) {
67
- return from(this.couponRepository.find([
68
- {
69
- nickname: { operator: Where.EQUALS, value: nickname },
70
- shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
71
- },
72
- ])).pipe(concatMap((coupons) => coupons.count < 1 ? throwError(() => new NotFoundError('Coupon not found')) : of(coupons.data[0])), concatMap((coupon) => FinancialCoupon.isFinancialCoupon(coupon) && this.isValidCoupon(coupon, userEmail)
73
- ? of(coupon)
74
- : throwError(() => new InvalidCouponError('Coupon is not valid'))));
75
- }
76
- isValidCoupon(coupon, userEmail) {
77
- if (coupon.checkoutType !== CheckoutTypes.ECOMMERCE)
78
- throw new InvalidCouponError('Coupon is not ecommerce valid');
79
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
80
- throw new InvalidCouponError('User is not a collaborator');
81
- if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
82
- throw new InvalidCouponError('Coupon is not valid for user');
83
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
84
- throw new InvalidCouponError('Coupon is expired');
85
- return true;
86
- }
87
- }
88
- 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 });
89
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
90
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
91
- type: Injectable,
92
- args: [{
93
- providedIn: 'root',
94
- }]
95
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
96
- type: Inject,
97
- args: ['CouponRepository']
98
- }] }, { type: i2.Shops, decorators: [{
99
- type: Inject,
100
- args: [DEFAULT_SHOP]
60
+ class CouponService {
61
+ constructor(couponRepository, defaultShop) {
62
+ this.couponRepository = couponRepository;
63
+ this.defaultShop = defaultShop;
64
+ this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
65
+ }
66
+ checkCoupon(nickname, userEmail) {
67
+ return from(this.couponRepository.find([
68
+ {
69
+ nickname: { operator: Where.EQUALS, value: nickname },
70
+ shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
71
+ },
72
+ ])).pipe(concatMap((coupons) => coupons.count < 1 ? throwError(() => new NotFoundError('Coupon not found')) : of(coupons.data[0])), concatMap((coupon) => FinancialCoupon.isFinancialCoupon(coupon) && this.isValidCoupon(coupon, userEmail)
73
+ ? of(coupon)
74
+ : throwError(() => new InvalidCouponError('Coupon is not valid'))));
75
+ }
76
+ isValidCoupon(coupon, userEmail) {
77
+ if (coupon.checkoutType !== CheckoutTypes.ECOMMERCE)
78
+ throw new InvalidCouponError('Coupon is not ecommerce valid');
79
+ if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
80
+ throw new InvalidCouponError('User is not a collaborator');
81
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
82
+ throw new InvalidCouponError('Coupon is not valid for user');
83
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
84
+ throw new InvalidCouponError('Coupon is expired');
85
+ return true;
86
+ }
87
+ }
88
+ 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 });
89
+ CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
90
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
91
+ type: Injectable,
92
+ args: [{
93
+ providedIn: 'root',
94
+ }]
95
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
96
+ type: Inject,
97
+ args: ['CouponRepository']
98
+ }] }, { type: i1$1.Shops, decorators: [{
99
+ type: Inject,
100
+ args: [DEFAULT_SHOP]
101
101
  }] }]; } });
102
102
 
103
- class CheckoutService {
104
- constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
105
- this.couponService = couponService;
106
- this.checkoutRepository = checkoutRepository;
107
- this.orderRepository = orderRepository;
108
- this.userRepository = userRepository;
109
- this.defaultShop = defaultShop;
110
- }
111
- getCheckout(checkoutData) {
112
- const checkoutId = cookie.get('checkoutId');
113
- if (!isNil(checkoutId))
114
- return from(this.checkoutRepository.get({ id: checkoutId }));
115
- return from(this.createCheckout(checkoutData));
116
- }
117
- getUserByCheckout(checkoutId) {
118
- 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'))));
119
- }
120
- updateCheckoutLineItems(checkout) {
121
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
122
- }
123
- updateCheckoutUser(checkout) {
124
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
125
- }
126
- clearCheckoutFromSession() {
127
- cookie.remove('checkoutId');
128
- return of();
129
- }
130
- checkCoupon(nickname) {
131
- return this.getCheckout().pipe(concatMap((checkout) => {
132
- var _a;
133
- return this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email).pipe(concatMap((coupon) => {
134
- var _a, _b;
135
- return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
136
- ? from(this.orderRepository.find([{ user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } }])).pipe(concatMap((orders) => {
137
- if (orders.data.length >= (coupon.useLimit || Infinity))
138
- return throwError(() => new Error('Coupon is already applied'));
139
- return of(coupon);
140
- }))
141
- : of(coupon);
142
- }));
143
- }));
144
- }
145
- createCheckout(checkoutData) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- 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 }));
148
- cookie.set('checkoutId', checkout.id);
149
- return checkout;
150
- });
151
- }
152
- }
153
- 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 });
154
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
155
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
156
- type: Injectable
157
- }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
158
- type: Inject,
159
- args: ['CheckoutRepository']
160
- }] }, { type: undefined, decorators: [{
161
- type: Inject,
162
- args: ['OrderRepository']
163
- }] }, { type: undefined, decorators: [{
164
- type: Inject,
165
- args: ['UserRepository']
166
- }] }, { type: i2.Shops, decorators: [{
167
- type: Inject,
168
- args: [DEFAULT_SHOP]
103
+ class CheckoutService {
104
+ constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
105
+ this.couponService = couponService;
106
+ this.checkoutRepository = checkoutRepository;
107
+ this.orderRepository = orderRepository;
108
+ this.userRepository = userRepository;
109
+ this.defaultShop = defaultShop;
110
+ }
111
+ getCheckout(checkoutData) {
112
+ const checkoutId = cookie.get('checkoutId');
113
+ if (!isNil(checkoutId))
114
+ return from(this.checkoutRepository.get({ id: checkoutId }));
115
+ return from(this.createCheckout(checkoutData));
116
+ }
117
+ getUserByCheckout(checkoutId) {
118
+ 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'))));
119
+ }
120
+ updateCheckoutLineItems(checkout) {
121
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
122
+ }
123
+ updateCheckoutUser(checkout) {
124
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
125
+ }
126
+ clearCheckoutFromSession() {
127
+ cookie.remove('checkoutId');
128
+ return of();
129
+ }
130
+ checkCoupon(nickname) {
131
+ return this.getCheckout().pipe(concatMap((checkout) => {
132
+ var _a;
133
+ return this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email).pipe(concatMap((coupon) => {
134
+ var _a, _b;
135
+ return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
136
+ ? from(this.orderRepository.find([{ user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } }])).pipe(concatMap((orders) => {
137
+ if (orders.data.length >= (coupon.useLimit || Infinity))
138
+ return throwError(() => new Error('Coupon is already applied'));
139
+ return of(coupon);
140
+ }))
141
+ : of(coupon);
142
+ }));
143
+ }));
144
+ }
145
+ createCheckout(checkoutData) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ 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 }));
148
+ cookie.set('checkoutId', checkout.id);
149
+ return checkout;
150
+ });
151
+ }
152
+ }
153
+ 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 });
154
+ CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
155
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
156
+ type: Injectable
157
+ }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
158
+ type: Inject,
159
+ args: ['CheckoutRepository']
160
+ }] }, { type: undefined, decorators: [{
161
+ type: Inject,
162
+ args: ['OrderRepository']
163
+ }] }, { type: undefined, decorators: [{
164
+ type: Inject,
165
+ args: ['UserRepository']
166
+ }] }, { type: i1$1.Shops, decorators: [{
167
+ type: Inject,
168
+ args: [DEFAULT_SHOP]
169
169
  }] }]; } });
170
170
 
171
- class CartService {
172
- constructor(authService, checkoutService, defaultShop) {
173
- this.authService = authService;
174
- this.checkoutService = checkoutService;
175
- this.defaultShop = defaultShop;
176
- this.cartSubject = new Subject();
177
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
178
- var _a;
179
- const items = [];
180
- const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
181
- if (index > -1) {
182
- checkoutLoaded.lineItems[index].quantity += quantity;
183
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
184
- }
185
- else
186
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
187
- return this.checkoutService
188
- .updateCheckoutLineItems(checkoutLoaded)
189
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
190
- }));
191
- this.generateCartObject = (items) => {
192
- const cart = {};
193
- items === null || items === void 0 ? void 0 : items.forEach((item) => {
194
- var _a;
195
- 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) })));
196
- });
197
- return cart;
198
- };
199
- this.buildLineItem = ({ checkout, item, quantity, }) => {
200
- var _a, _b, _c, _d, _e;
201
- 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;
202
- if (this.checkMaxStock(item, quantity || 0))
203
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
204
- const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
205
- const { id, name, brand, slug, stock, price, weight, categories, sku } = item;
206
- const isGift = item.isGift || null;
207
- const pricePaid = this.getProductPrice({
208
- product: item,
209
- shop: checkout.shop || this.defaultShop,
210
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
211
- });
212
- return LineItem.toInstance({
213
- id,
214
- name,
215
- brand,
216
- slug,
217
- sku,
218
- stock,
219
- price,
220
- image,
221
- weight,
222
- quantity: (item.quantity || 0) + (quantity || 0),
223
- pricePaid,
224
- categories,
225
- isGift,
226
- costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
227
- });
228
- };
229
- this.getProductPrice = ({ product, shop, isSubscriber, }) => {
230
- const info = product.getInfoByShop(shop);
231
- if (product.isGift)
232
- return 0;
233
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
234
- };
235
- this.checkMaxStock = (item, quantity) => {
236
- var _a;
237
- const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
238
- const currentItemAmount = item.quantity || 0;
239
- return currentItemAmount + quantity > maxStock;
240
- };
241
- }
242
- addItem(item, quantity = 1) {
243
- return this.checkoutService.getCheckout().pipe(map((checkout) => ({
244
- checkout,
245
- lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }),
246
- })), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
247
- }
248
- decreaseItem(item) {
249
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
250
- var _a;
251
- const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
252
- if (!isNil(checkoutItem))
253
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
254
- return checkout;
255
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
256
- }
257
- getCart(checkout) {
258
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
259
- return this.cartSubject;
260
- }
261
- /**
262
- * @deprecated The method should not be used
263
- */
264
- getDiscount(coupon) {
265
- switch (coupon.type) {
266
- case CouponTypes.FINANCIAL:
267
- return this.getFinancialDiscount(coupon);
268
- case CouponTypes.PRODUCT:
269
- return (subTotalPrice) => subTotalPrice;
270
- case CouponTypes.GIFTCARD:
271
- return this.getFinancialDiscount(coupon);
272
- case CouponTypes.VOUCHER:
273
- return (subTotalPrice) => subTotalPrice;
274
- }
275
- }
276
- /**
277
- * @deprecated The method should not be used
278
- */
279
- getVariantPriceDiscount(item, shop) {
280
- 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)));
281
- }
282
- removeItem(item) {
283
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
284
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
285
- if (index >= 0)
286
- checkout.lineItems.splice(index, 1);
287
- return checkout;
288
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
289
- }
290
- updateUserCart(user) {
291
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
292
- var _a;
293
- 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 }))) || [] })));
294
- }), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
295
- }
296
- clearCart() {
297
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
298
- this.checkoutService.clearCheckoutFromSession();
299
- return checkout;
300
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
301
- }
302
- buildCartFromCheckout(checkoutData) {
303
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
304
- }
305
- getFinancialDiscount(coupon) {
306
- return (subTotalPrice) => {
307
- if (FinancialCoupon.isFinancialCoupon(coupon))
308
- switch (coupon.subtype) {
309
- case CouponSubtypes.ABSOLUTE:
310
- return subTotalPrice - coupon.discount * 100;
311
- case CouponSubtypes.PERCENTAGE:
312
- return subTotalPrice * (1 - coupon.discount / 100);
313
- }
314
- };
315
- }
316
- }
317
- 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 });
318
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
319
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
320
- type: Injectable
321
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
322
- type: Inject,
323
- args: [DEFAULT_SHOP]
171
+ class CartService {
172
+ constructor(authService, checkoutService, defaultShop) {
173
+ this.authService = authService;
174
+ this.checkoutService = checkoutService;
175
+ this.defaultShop = defaultShop;
176
+ this.cartSubject = new Subject();
177
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
178
+ var _a;
179
+ const items = [];
180
+ const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
181
+ if (index > -1) {
182
+ checkoutLoaded.lineItems[index].quantity += quantity;
183
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
184
+ }
185
+ else
186
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
187
+ return this.checkoutService
188
+ .updateCheckoutLineItems(checkoutLoaded)
189
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
190
+ }));
191
+ this.generateCartObject = (items) => {
192
+ const cart = {};
193
+ items === null || items === void 0 ? void 0 : items.forEach((item) => {
194
+ var _a;
195
+ 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) })));
196
+ });
197
+ return cart;
198
+ };
199
+ this.buildLineItem = ({ checkout, item, quantity, }) => {
200
+ var _a, _b, _c, _d, _e;
201
+ 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;
202
+ if (this.checkMaxStock(item, quantity || 0))
203
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
204
+ const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
205
+ const { id, name, brand, slug, stock, price, weight, categories, sku } = item;
206
+ const isGift = item.isGift || null;
207
+ const pricePaid = this.getProductPrice({
208
+ product: item,
209
+ shop: checkout.shop || this.defaultShop,
210
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
211
+ });
212
+ return LineItem.toInstance({
213
+ id,
214
+ name,
215
+ brand,
216
+ slug,
217
+ sku,
218
+ stock,
219
+ price,
220
+ image,
221
+ weight,
222
+ quantity: (item.quantity || 0) + (quantity || 0),
223
+ pricePaid,
224
+ categories,
225
+ isGift,
226
+ costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
227
+ });
228
+ };
229
+ this.getProductPrice = ({ product, shop, isSubscriber, }) => {
230
+ const info = product.getInfoByShop(shop);
231
+ if (product.isGift)
232
+ return 0;
233
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
234
+ };
235
+ this.checkMaxStock = (item, quantity) => {
236
+ var _a;
237
+ const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
238
+ const currentItemAmount = item.quantity || 0;
239
+ return currentItemAmount + quantity > maxStock;
240
+ };
241
+ }
242
+ addItem(item, quantity = 1) {
243
+ return this.checkoutService.getCheckout().pipe(map((checkout) => ({
244
+ checkout,
245
+ lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }),
246
+ })), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
247
+ }
248
+ decreaseItem(item) {
249
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
250
+ var _a;
251
+ const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
252
+ if (!isNil(checkoutItem))
253
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
254
+ return checkout;
255
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
256
+ }
257
+ getCart(checkout) {
258
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
259
+ return this.cartSubject;
260
+ }
261
+ /**
262
+ * @deprecated The method should not be used
263
+ */
264
+ getDiscount(coupon) {
265
+ switch (coupon.type) {
266
+ case CouponTypes.FINANCIAL:
267
+ return this.getFinancialDiscount(coupon);
268
+ case CouponTypes.PRODUCT:
269
+ return (subTotalPrice) => subTotalPrice;
270
+ case CouponTypes.GIFTCARD:
271
+ return this.getFinancialDiscount(coupon);
272
+ case CouponTypes.VOUCHER:
273
+ return (subTotalPrice) => subTotalPrice;
274
+ }
275
+ }
276
+ /**
277
+ * @deprecated The method should not be used
278
+ */
279
+ getVariantPriceDiscount(item, shop) {
280
+ 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)));
281
+ }
282
+ removeItem(item) {
283
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
284
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
285
+ if (index >= 0)
286
+ checkout.lineItems.splice(index, 1);
287
+ return checkout;
288
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
289
+ }
290
+ updateUserCart(user) {
291
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
292
+ var _a;
293
+ 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 }))) || [] })));
294
+ }), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
295
+ }
296
+ clearCart() {
297
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
298
+ this.checkoutService.clearCheckoutFromSession();
299
+ return checkout;
300
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
301
+ }
302
+ buildCartFromCheckout(checkoutData) {
303
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
304
+ }
305
+ getFinancialDiscount(coupon) {
306
+ return (subTotalPrice) => {
307
+ if (FinancialCoupon.isFinancialCoupon(coupon))
308
+ switch (coupon.subtype) {
309
+ case CouponSubtypes.ABSOLUTE:
310
+ return subTotalPrice - coupon.discount * 100;
311
+ case CouponSubtypes.PERCENTAGE:
312
+ return subTotalPrice * (1 - coupon.discount / 100);
313
+ }
314
+ };
315
+ }
316
+ }
317
+ 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 });
318
+ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
319
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
320
+ type: Injectable
321
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
322
+ type: Inject,
323
+ args: [DEFAULT_SHOP]
324
324
  }] }]; } });
325
325
 
326
- class CheckoutSubscriptionService {
327
- constructor(checkoutSubscriptionRepository) {
328
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
329
- }
330
- getCheckoutSubscription(checkoutData) {
331
- const checkoutId = cookie.get('checkoutSubscriptionId');
332
- if (!isNil(checkoutId))
333
- return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
334
- return from(this.createCheckoutSubscription(checkoutData));
335
- }
336
- createCheckoutSubscription(checkoutData) {
337
- return __awaiter(this, void 0, void 0, function* () {
338
- const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
339
- cookie.set('checkoutSubscriptionId', checkout.id);
340
- return checkout;
341
- });
342
- }
343
- clearCheckoutSubscriptionFromSession() {
344
- cookie.remove('checkoutSubscriptionId');
345
- return of();
346
- }
347
- }
348
- CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
349
- CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
350
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
351
- type: Injectable
352
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
353
- type: Inject,
354
- args: ['CheckoutSubscriptionRepository']
326
+ class CheckoutSubscriptionService {
327
+ constructor(checkoutSubscriptionRepository, couponRepository, defaultShop) {
328
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
329
+ this.couponRepository = couponRepository;
330
+ this.defaultShop = defaultShop;
331
+ this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
332
+ }
333
+ getCheckoutSubscription(checkoutData) {
334
+ const checkoutId = cookie.get('checkoutSubscriptionId');
335
+ if (!isNil(checkoutId))
336
+ return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
337
+ return from(this.createCheckoutSubscription(checkoutData));
338
+ }
339
+ createCheckoutSubscription(checkoutData) {
340
+ return __awaiter(this, void 0, void 0, function* () {
341
+ const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
342
+ cookie.set('checkoutSubscriptionId', checkout.id);
343
+ return checkout;
344
+ });
345
+ }
346
+ clearCheckoutSubscriptionFromSession() {
347
+ cookie.remove('checkoutSubscriptionId');
348
+ return of();
349
+ }
350
+ checkCoupon(nickname, userEmail) {
351
+ return from(this.couponRepository.find([
352
+ {
353
+ nickname: { operator: Where.EQUALS, value: nickname },
354
+ shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
355
+ },
356
+ ])).pipe(concatMap((coupons) => coupons.count < 1 ? throwError(() => new NotFoundError('Coupon not found')) : of(coupons.data[0])), concatMap((coupon) => FinancialCoupon.isFinancialCoupon(coupon) && this.isValidCoupon(coupon, userEmail)
357
+ ? of(coupon)
358
+ : throwError(() => new InvalidCouponError('Coupon is not valid'))));
359
+ }
360
+ isValidCoupon(coupon, userEmail) {
361
+ if (+coupon.checkoutType !== CheckoutTypes.SUBSCRIPTION)
362
+ throw new InvalidCouponError('Coupon is not subscription valid');
363
+ if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
364
+ throw new InvalidCouponError('User is not a collaborator');
365
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
366
+ throw new InvalidCouponError('Coupon is not valid for user');
367
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
368
+ throw new InvalidCouponError('Coupon is expired');
369
+ return true;
370
+ }
371
+ }
372
+ CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'CouponRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
373
+ CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
374
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
375
+ type: Injectable
376
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
377
+ type: Inject,
378
+ args: ['CheckoutSubscriptionRepository']
379
+ }] }, { type: undefined, decorators: [{
380
+ type: Inject,
381
+ args: ['CouponRepository']
382
+ }] }, { type: i1$1.Shops, decorators: [{
383
+ type: Inject,
384
+ args: [DEFAULT_SHOP]
355
385
  }] }]; } });
356
386
 
357
- class OrderService {
358
- constructor(angularFirestore, orderRepository) {
359
- this.angularFirestore = angularFirestore;
360
- this.orderRepository = orderRepository;
361
- this.orderSubject = new Subject();
362
- }
363
- getOrder(id) {
364
- this.angularFirestore
365
- .doc(`${this.orderRepository.collectionName}/${id}`)
366
- .valueChanges()
367
- .pipe(map((doc) => Order.toInstance(doc)))
368
- .subscribe((doc) => this.orderSubject.next(doc));
369
- return this.orderSubject;
370
- }
371
- }
372
- 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 });
373
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
374
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
375
- type: Injectable
376
- }], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i2.OrderFirestoreRepository, decorators: [{
377
- type: Inject,
378
- args: ['OrderRepository']
387
+ class OrderService {
388
+ constructor(angularFirestore, orderRepository) {
389
+ this.angularFirestore = angularFirestore;
390
+ this.orderRepository = orderRepository;
391
+ this.orderSubject = new Subject();
392
+ }
393
+ getOrder(id) {
394
+ this.angularFirestore
395
+ .doc(`${this.orderRepository.collectionName}/${id}`)
396
+ .valueChanges()
397
+ .pipe(map((doc) => Order.toInstance(doc)))
398
+ .subscribe((doc) => this.orderSubject.next(doc));
399
+ return this.orderSubject;
400
+ }
401
+ }
402
+ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
403
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
404
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
405
+ type: Injectable
406
+ }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
407
+ type: Inject,
408
+ args: ['OrderRepository']
379
409
  }] }]; } });
380
410
 
381
- class AngularFirebaseAuthModule {
382
- static initializeApp(options, nameOrConfig) {
383
- return {
384
- ngModule: AngularFirebaseAuthModule,
385
- providers: [
386
- { provide: FIREBASE_OPTIONS, useValue: options },
387
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
388
- ],
389
- };
390
- }
391
- }
392
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
393
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
394
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
395
- {
396
- provide: 'Authentication',
397
- useFactory: (authenticationService, userRepository) => {
398
- return new Authentication(authenticationService, userRepository);
399
- },
400
- deps: ['AuthenticationService', 'UserRepository'],
401
- },
402
- {
403
- provide: 'AuthenticationService',
404
- useFactory: (angularFireAuth) => {
405
- return new AuthenticationFirebaseAuthService(angularFireAuth);
406
- },
407
- deps: [AngularFireAuth],
408
- },
409
- {
410
- provide: 'Register',
411
- useFactory: (registerService, userRepository) => {
412
- return new Register(registerService, userRepository);
413
- },
414
- deps: ['RegisterService', 'UserRepository'],
415
- },
416
- {
417
- provide: 'RegisterService',
418
- useFactory: (angularFireAuth) => {
419
- return new RegisterFirebaseAuthService(angularFireAuth);
420
- },
421
- deps: [AngularFireAuth],
422
- },
423
- {
424
- provide: 'SignOut',
425
- useFactory: (authenticationService) => {
426
- return new SignOut(authenticationService);
427
- },
428
- deps: ['AuthenticationService'],
429
- },
430
- {
431
- provide: 'RecoveryPassword',
432
- useFactory: (authenticationService) => {
433
- return new RecoveryPassword(authenticationService);
434
- },
435
- deps: ['AuthenticationService'],
436
- },
437
- ], imports: [[AngularFireModule]] });
438
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
439
- type: NgModule,
440
- args: [{
441
- imports: [AngularFireModule],
442
- providers: [
443
- {
444
- provide: 'Authentication',
445
- useFactory: (authenticationService, userRepository) => {
446
- return new Authentication(authenticationService, userRepository);
447
- },
448
- deps: ['AuthenticationService', 'UserRepository'],
449
- },
450
- {
451
- provide: 'AuthenticationService',
452
- useFactory: (angularFireAuth) => {
453
- return new AuthenticationFirebaseAuthService(angularFireAuth);
454
- },
455
- deps: [AngularFireAuth],
456
- },
457
- {
458
- provide: 'Register',
459
- useFactory: (registerService, userRepository) => {
460
- return new Register(registerService, userRepository);
461
- },
462
- deps: ['RegisterService', 'UserRepository'],
463
- },
464
- {
465
- provide: 'RegisterService',
466
- useFactory: (angularFireAuth) => {
467
- return new RegisterFirebaseAuthService(angularFireAuth);
468
- },
469
- deps: [AngularFireAuth],
470
- },
471
- {
472
- provide: 'SignOut',
473
- useFactory: (authenticationService) => {
474
- return new SignOut(authenticationService);
475
- },
476
- deps: ['AuthenticationService'],
477
- },
478
- {
479
- provide: 'RecoveryPassword',
480
- useFactory: (authenticationService) => {
481
- return new RecoveryPassword(authenticationService);
482
- },
483
- deps: ['AuthenticationService'],
484
- },
485
- ],
486
- }]
411
+ class AngularFirebaseAuthModule {
412
+ static initializeApp(options, nameOrConfig) {
413
+ return {
414
+ ngModule: AngularFirebaseAuthModule,
415
+ providers: [
416
+ { provide: FIREBASE_OPTIONS, useValue: options },
417
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
418
+ ],
419
+ };
420
+ }
421
+ }
422
+ AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
423
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
424
+ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
425
+ {
426
+ provide: 'Authentication',
427
+ useFactory: (authenticationService, userRepository) => {
428
+ return new Authentication(authenticationService, userRepository);
429
+ },
430
+ deps: ['AuthenticationService', 'UserRepository'],
431
+ },
432
+ {
433
+ provide: 'AuthenticationService',
434
+ useFactory: (angularFireAuth) => {
435
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
436
+ },
437
+ deps: [AngularFireAuth],
438
+ },
439
+ {
440
+ provide: 'Register',
441
+ useFactory: (registerService, userRepository) => {
442
+ return new Register(registerService, userRepository);
443
+ },
444
+ deps: ['RegisterService', 'UserRepository'],
445
+ },
446
+ {
447
+ provide: 'RegisterService',
448
+ useFactory: (angularFireAuth) => {
449
+ return new RegisterFirebaseAuthService(angularFireAuth);
450
+ },
451
+ deps: [AngularFireAuth],
452
+ },
453
+ {
454
+ provide: 'SignOut',
455
+ useFactory: (authenticationService) => {
456
+ return new SignOut(authenticationService);
457
+ },
458
+ deps: ['AuthenticationService'],
459
+ },
460
+ {
461
+ provide: 'RecoveryPassword',
462
+ useFactory: (authenticationService) => {
463
+ return new RecoveryPassword(authenticationService);
464
+ },
465
+ deps: ['AuthenticationService'],
466
+ },
467
+ ], imports: [[AngularFireModule]] });
468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
469
+ type: NgModule,
470
+ args: [{
471
+ imports: [AngularFireModule],
472
+ providers: [
473
+ {
474
+ provide: 'Authentication',
475
+ useFactory: (authenticationService, userRepository) => {
476
+ return new Authentication(authenticationService, userRepository);
477
+ },
478
+ deps: ['AuthenticationService', 'UserRepository'],
479
+ },
480
+ {
481
+ provide: 'AuthenticationService',
482
+ useFactory: (angularFireAuth) => {
483
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
484
+ },
485
+ deps: [AngularFireAuth],
486
+ },
487
+ {
488
+ provide: 'Register',
489
+ useFactory: (registerService, userRepository) => {
490
+ return new Register(registerService, userRepository);
491
+ },
492
+ deps: ['RegisterService', 'UserRepository'],
493
+ },
494
+ {
495
+ provide: 'RegisterService',
496
+ useFactory: (angularFireAuth) => {
497
+ return new RegisterFirebaseAuthService(angularFireAuth);
498
+ },
499
+ deps: [AngularFireAuth],
500
+ },
501
+ {
502
+ provide: 'SignOut',
503
+ useFactory: (authenticationService) => {
504
+ return new SignOut(authenticationService);
505
+ },
506
+ deps: ['AuthenticationService'],
507
+ },
508
+ {
509
+ provide: 'RecoveryPassword',
510
+ useFactory: (authenticationService) => {
511
+ return new RecoveryPassword(authenticationService);
512
+ },
513
+ deps: ['AuthenticationService'],
514
+ },
515
+ ],
516
+ }]
487
517
  }] });
488
518
 
489
- class AngularFirestoreModule {
490
- static initializeApp(options, nameOrConfig) {
491
- return {
492
- ngModule: AngularFirestoreModule,
493
- providers: [
494
- { provide: FIREBASE_OPTIONS, useValue: options },
495
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
496
- ],
497
- };
498
- }
499
- }
500
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
501
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule] });
502
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
503
- {
504
- provide: 'BeautyProfileRepository',
505
- useFactory: (firestore, userRepository) => {
506
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
507
- },
508
- deps: [AngularFirestore, 'UserRepository'],
509
- },
510
- {
511
- provide: 'Buy2WinRepository',
512
- useFactory: (firestore) => {
513
- return new Buy2WinFirestoreRepository(firestore.firestore);
514
- },
515
- deps: [AngularFirestore],
516
- },
517
- {
518
- provide: 'CategoryRepository',
519
- useFactory: (firestore) => {
520
- return new CategoryFirestoreRepository(firestore.firestore);
521
- },
522
- deps: [AngularFirestore],
523
- },
524
- {
525
- provide: 'CheckoutRepository',
526
- useFactory: (firestore) => {
527
- return new CheckoutFirestoreRepository(firestore.firestore);
528
- },
529
- deps: [AngularFirestore],
530
- },
531
- {
532
- provide: 'CheckoutSubscriptionRepository',
533
- useFactory: (firestore) => {
534
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
535
- },
536
- deps: [AngularFirestore],
537
- },
538
- {
539
- provide: 'CouponRepository',
540
- useFactory: (firestore) => {
541
- return new CouponFirestoreRepository(firestore.firestore);
542
- },
543
- deps: [AngularFirestore],
544
- },
545
- {
546
- provide: 'EditionRepository',
547
- useFactory: (firestore, subscriptionRepository) => {
548
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
549
- },
550
- deps: [AngularFirestore, 'SubscriptionRepository'],
551
- },
552
- {
553
- provide: 'HomeRepository',
554
- useFactory: (firestore) => {
555
- return new HomeFirestoreRepository(firestore.firestore);
556
- },
557
- deps: [AngularFirestore],
558
- },
559
- {
560
- provide: 'LeadRepository',
561
- useFactory: (firestore) => {
562
- return new LeadFirestoreRepository(firestore.firestore);
563
- },
564
- deps: [AngularFirestore],
565
- },
566
- {
567
- provide: 'LegacyOrderRepository',
568
- useFactory: (firestore) => {
569
- return new LegacyOrderFirestoreRepository(firestore.firestore);
570
- },
571
- deps: [AngularFirestore],
572
- },
573
- {
574
- provide: 'ShopMenuRepository',
575
- useFactory: (firestore) => {
576
- return new ShopMenuFirestoreRepository(firestore.firestore);
577
- },
578
- deps: [AngularFirestore],
579
- },
580
- {
581
- provide: 'OrderRepository',
582
- useFactory: (firestore) => {
583
- return new OrderFirestoreRepository(firestore.firestore);
584
- },
585
- deps: [AngularFirestore],
586
- },
587
- {
588
- provide: 'PaymentRepository',
589
- useFactory: (firestore) => {
590
- return new PaymentFirestoreRepository(firestore.firestore);
591
- },
592
- deps: [AngularFirestore],
593
- },
594
- {
595
- provide: 'ProductRepository',
596
- useFactory: (firestore) => {
597
- return new ProductFirestoreRepository(firestore.firestore);
598
- },
599
- deps: [AngularFirestore],
600
- },
601
- {
602
- provide: 'SubscriptionPaymentRepository',
603
- useFactory: (firestore, subscriptionRepository) => {
604
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
605
- },
606
- deps: [AngularFirestore, 'SubscriptionRepository'],
607
- },
608
- {
609
- provide: 'SubscriptionPlanRepository',
610
- useFactory: (firestore) => {
611
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
612
- },
613
- deps: [AngularFirestore],
614
- },
615
- {
616
- provide: 'SubscriptionProductRepository',
617
- useFactory: (firestore) => {
618
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
619
- },
620
- deps: [AngularFirestore],
621
- },
622
- {
623
- provide: 'SubscriptionRepository',
624
- useFactory: (firestore) => {
625
- return new SubscriptionFirestoreRepository(firestore.firestore);
626
- },
627
- deps: [AngularFirestore],
628
- },
629
- {
630
- provide: 'UserRepository',
631
- useFactory: (firestore) => {
632
- return new UserFirestoreRepository(firestore.firestore);
633
- },
634
- deps: [AngularFirestore],
635
- },
636
- {
637
- provide: 'UserAddressRepository',
638
- useFactory: (firestore, userRepository) => {
639
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
640
- },
641
- deps: [AngularFirestore, 'UserRepository'],
642
- },
643
- {
644
- provide: 'UserPaymentMethodRepository',
645
- useFactory: (firestore, userRepository) => {
646
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
647
- },
648
- deps: [AngularFirestore, 'UserRepository'],
649
- },
650
- {
651
- provide: 'VariantRepository',
652
- useFactory: (firestore, productRepository) => {
653
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
654
- },
655
- deps: [AngularFirestore, 'ProductRepository'],
656
- },
657
- ], imports: [[AngularFireModule]] });
658
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
659
- type: NgModule,
660
- args: [{
661
- imports: [AngularFireModule],
662
- providers: [
663
- {
664
- provide: 'BeautyProfileRepository',
665
- useFactory: (firestore, userRepository) => {
666
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
667
- },
668
- deps: [AngularFirestore, 'UserRepository'],
669
- },
670
- {
671
- provide: 'Buy2WinRepository',
672
- useFactory: (firestore) => {
673
- return new Buy2WinFirestoreRepository(firestore.firestore);
674
- },
675
- deps: [AngularFirestore],
676
- },
677
- {
678
- provide: 'CategoryRepository',
679
- useFactory: (firestore) => {
680
- return new CategoryFirestoreRepository(firestore.firestore);
681
- },
682
- deps: [AngularFirestore],
683
- },
684
- {
685
- provide: 'CheckoutRepository',
686
- useFactory: (firestore) => {
687
- return new CheckoutFirestoreRepository(firestore.firestore);
688
- },
689
- deps: [AngularFirestore],
690
- },
691
- {
692
- provide: 'CheckoutSubscriptionRepository',
693
- useFactory: (firestore) => {
694
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
695
- },
696
- deps: [AngularFirestore],
697
- },
698
- {
699
- provide: 'CouponRepository',
700
- useFactory: (firestore) => {
701
- return new CouponFirestoreRepository(firestore.firestore);
702
- },
703
- deps: [AngularFirestore],
704
- },
705
- {
706
- provide: 'EditionRepository',
707
- useFactory: (firestore, subscriptionRepository) => {
708
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
709
- },
710
- deps: [AngularFirestore, 'SubscriptionRepository'],
711
- },
712
- {
713
- provide: 'HomeRepository',
714
- useFactory: (firestore) => {
715
- return new HomeFirestoreRepository(firestore.firestore);
716
- },
717
- deps: [AngularFirestore],
718
- },
719
- {
720
- provide: 'LeadRepository',
721
- useFactory: (firestore) => {
722
- return new LeadFirestoreRepository(firestore.firestore);
723
- },
724
- deps: [AngularFirestore],
725
- },
726
- {
727
- provide: 'LegacyOrderRepository',
728
- useFactory: (firestore) => {
729
- return new LegacyOrderFirestoreRepository(firestore.firestore);
730
- },
731
- deps: [AngularFirestore],
732
- },
733
- {
734
- provide: 'ShopMenuRepository',
735
- useFactory: (firestore) => {
736
- return new ShopMenuFirestoreRepository(firestore.firestore);
737
- },
738
- deps: [AngularFirestore],
739
- },
740
- {
741
- provide: 'OrderRepository',
742
- useFactory: (firestore) => {
743
- return new OrderFirestoreRepository(firestore.firestore);
744
- },
745
- deps: [AngularFirestore],
746
- },
747
- {
748
- provide: 'PaymentRepository',
749
- useFactory: (firestore) => {
750
- return new PaymentFirestoreRepository(firestore.firestore);
751
- },
752
- deps: [AngularFirestore],
753
- },
754
- {
755
- provide: 'ProductRepository',
756
- useFactory: (firestore) => {
757
- return new ProductFirestoreRepository(firestore.firestore);
758
- },
759
- deps: [AngularFirestore],
760
- },
761
- {
762
- provide: 'SubscriptionPaymentRepository',
763
- useFactory: (firestore, subscriptionRepository) => {
764
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
765
- },
766
- deps: [AngularFirestore, 'SubscriptionRepository'],
767
- },
768
- {
769
- provide: 'SubscriptionPlanRepository',
770
- useFactory: (firestore) => {
771
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
772
- },
773
- deps: [AngularFirestore],
774
- },
775
- {
776
- provide: 'SubscriptionProductRepository',
777
- useFactory: (firestore) => {
778
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
779
- },
780
- deps: [AngularFirestore],
781
- },
782
- {
783
- provide: 'SubscriptionRepository',
784
- useFactory: (firestore) => {
785
- return new SubscriptionFirestoreRepository(firestore.firestore);
786
- },
787
- deps: [AngularFirestore],
788
- },
789
- {
790
- provide: 'UserRepository',
791
- useFactory: (firestore) => {
792
- return new UserFirestoreRepository(firestore.firestore);
793
- },
794
- deps: [AngularFirestore],
795
- },
796
- {
797
- provide: 'UserAddressRepository',
798
- useFactory: (firestore, userRepository) => {
799
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
800
- },
801
- deps: [AngularFirestore, 'UserRepository'],
802
- },
803
- {
804
- provide: 'UserPaymentMethodRepository',
805
- useFactory: (firestore, userRepository) => {
806
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
807
- },
808
- deps: [AngularFirestore, 'UserRepository'],
809
- },
810
- {
811
- provide: 'VariantRepository',
812
- useFactory: (firestore, productRepository) => {
813
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
814
- },
815
- deps: [AngularFirestore, 'ProductRepository'],
816
- },
817
- ],
818
- }]
519
+ class AngularFirestoreModule {
520
+ static initializeApp(options, nameOrConfig) {
521
+ return {
522
+ ngModule: AngularFirestoreModule,
523
+ providers: [
524
+ { provide: FIREBASE_OPTIONS, useValue: options },
525
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
526
+ ],
527
+ };
528
+ }
529
+ }
530
+ AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
531
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule] });
532
+ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
533
+ {
534
+ provide: 'BeautyProfileRepository',
535
+ useFactory: (firestore, userRepository) => {
536
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
537
+ },
538
+ deps: [AngularFirestore, 'UserRepository'],
539
+ },
540
+ {
541
+ provide: 'Buy2WinRepository',
542
+ useFactory: (firestore) => {
543
+ return new Buy2WinFirestoreRepository(firestore.firestore);
544
+ },
545
+ deps: [AngularFirestore],
546
+ },
547
+ {
548
+ provide: 'CategoryRepository',
549
+ useFactory: (firestore) => {
550
+ return new CategoryFirestoreRepository(firestore.firestore);
551
+ },
552
+ deps: [AngularFirestore],
553
+ },
554
+ {
555
+ provide: 'CheckoutRepository',
556
+ useFactory: (firestore) => {
557
+ return new CheckoutFirestoreRepository(firestore.firestore);
558
+ },
559
+ deps: [AngularFirestore],
560
+ },
561
+ {
562
+ provide: 'CheckoutSubscriptionRepository',
563
+ useFactory: (firestore) => {
564
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
565
+ },
566
+ deps: [AngularFirestore],
567
+ },
568
+ {
569
+ provide: 'CouponRepository',
570
+ useFactory: (firestore) => {
571
+ return new CouponFirestoreRepository(firestore.firestore);
572
+ },
573
+ deps: [AngularFirestore],
574
+ },
575
+ {
576
+ provide: 'EditionRepository',
577
+ useFactory: (firestore, subscriptionRepository) => {
578
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
579
+ },
580
+ deps: [AngularFirestore, 'SubscriptionRepository'],
581
+ },
582
+ {
583
+ provide: 'HomeRepository',
584
+ useFactory: (firestore) => {
585
+ return new HomeFirestoreRepository(firestore.firestore);
586
+ },
587
+ deps: [AngularFirestore],
588
+ },
589
+ {
590
+ provide: 'LeadRepository',
591
+ useFactory: (firestore) => {
592
+ return new LeadFirestoreRepository(firestore.firestore);
593
+ },
594
+ deps: [AngularFirestore],
595
+ },
596
+ {
597
+ provide: 'LegacyOrderRepository',
598
+ useFactory: (firestore) => {
599
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
600
+ },
601
+ deps: [AngularFirestore],
602
+ },
603
+ {
604
+ provide: 'ShopMenuRepository',
605
+ useFactory: (firestore) => {
606
+ return new ShopMenuFirestoreRepository(firestore.firestore);
607
+ },
608
+ deps: [AngularFirestore],
609
+ },
610
+ {
611
+ provide: 'OrderRepository',
612
+ useFactory: (firestore) => {
613
+ return new OrderFirestoreRepository(firestore.firestore);
614
+ },
615
+ deps: [AngularFirestore],
616
+ },
617
+ {
618
+ provide: 'PaymentRepository',
619
+ useFactory: (firestore) => {
620
+ return new PaymentFirestoreRepository(firestore.firestore);
621
+ },
622
+ deps: [AngularFirestore],
623
+ },
624
+ {
625
+ provide: 'ProductRepository',
626
+ useFactory: (firestore) => {
627
+ return new ProductFirestoreRepository(firestore.firestore);
628
+ },
629
+ deps: [AngularFirestore],
630
+ },
631
+ {
632
+ provide: 'SubscriptionPaymentRepository',
633
+ useFactory: (firestore, subscriptionRepository) => {
634
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
635
+ },
636
+ deps: [AngularFirestore, 'SubscriptionRepository'],
637
+ },
638
+ {
639
+ provide: 'SubscriptionPlanRepository',
640
+ useFactory: (firestore) => {
641
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
642
+ },
643
+ deps: [AngularFirestore],
644
+ },
645
+ {
646
+ provide: 'SubscriptionProductRepository',
647
+ useFactory: (firestore) => {
648
+ return new SubscriptionProductFirestoreRepository(firestore.firestore);
649
+ },
650
+ deps: [AngularFirestore],
651
+ },
652
+ {
653
+ provide: 'SubscriptionRepository',
654
+ useFactory: (firestore) => {
655
+ return new SubscriptionFirestoreRepository(firestore.firestore);
656
+ },
657
+ deps: [AngularFirestore],
658
+ },
659
+ {
660
+ provide: 'UserRepository',
661
+ useFactory: (firestore) => {
662
+ return new UserFirestoreRepository(firestore.firestore);
663
+ },
664
+ deps: [AngularFirestore],
665
+ },
666
+ {
667
+ provide: 'UserAddressRepository',
668
+ useFactory: (firestore, userRepository) => {
669
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
670
+ },
671
+ deps: [AngularFirestore, 'UserRepository'],
672
+ },
673
+ {
674
+ provide: 'UserPaymentMethodRepository',
675
+ useFactory: (firestore, userRepository) => {
676
+ return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
677
+ },
678
+ deps: [AngularFirestore, 'UserRepository'],
679
+ },
680
+ {
681
+ provide: 'VariantRepository',
682
+ useFactory: (firestore, productRepository) => {
683
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
684
+ },
685
+ deps: [AngularFirestore, 'ProductRepository'],
686
+ },
687
+ ], imports: [[AngularFireModule]] });
688
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
689
+ type: NgModule,
690
+ args: [{
691
+ imports: [AngularFireModule],
692
+ providers: [
693
+ {
694
+ provide: 'BeautyProfileRepository',
695
+ useFactory: (firestore, userRepository) => {
696
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
697
+ },
698
+ deps: [AngularFirestore, 'UserRepository'],
699
+ },
700
+ {
701
+ provide: 'Buy2WinRepository',
702
+ useFactory: (firestore) => {
703
+ return new Buy2WinFirestoreRepository(firestore.firestore);
704
+ },
705
+ deps: [AngularFirestore],
706
+ },
707
+ {
708
+ provide: 'CategoryRepository',
709
+ useFactory: (firestore) => {
710
+ return new CategoryFirestoreRepository(firestore.firestore);
711
+ },
712
+ deps: [AngularFirestore],
713
+ },
714
+ {
715
+ provide: 'CheckoutRepository',
716
+ useFactory: (firestore) => {
717
+ return new CheckoutFirestoreRepository(firestore.firestore);
718
+ },
719
+ deps: [AngularFirestore],
720
+ },
721
+ {
722
+ provide: 'CheckoutSubscriptionRepository',
723
+ useFactory: (firestore) => {
724
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
725
+ },
726
+ deps: [AngularFirestore],
727
+ },
728
+ {
729
+ provide: 'CouponRepository',
730
+ useFactory: (firestore) => {
731
+ return new CouponFirestoreRepository(firestore.firestore);
732
+ },
733
+ deps: [AngularFirestore],
734
+ },
735
+ {
736
+ provide: 'EditionRepository',
737
+ useFactory: (firestore, subscriptionRepository) => {
738
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
739
+ },
740
+ deps: [AngularFirestore, 'SubscriptionRepository'],
741
+ },
742
+ {
743
+ provide: 'HomeRepository',
744
+ useFactory: (firestore) => {
745
+ return new HomeFirestoreRepository(firestore.firestore);
746
+ },
747
+ deps: [AngularFirestore],
748
+ },
749
+ {
750
+ provide: 'LeadRepository',
751
+ useFactory: (firestore) => {
752
+ return new LeadFirestoreRepository(firestore.firestore);
753
+ },
754
+ deps: [AngularFirestore],
755
+ },
756
+ {
757
+ provide: 'LegacyOrderRepository',
758
+ useFactory: (firestore) => {
759
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
760
+ },
761
+ deps: [AngularFirestore],
762
+ },
763
+ {
764
+ provide: 'ShopMenuRepository',
765
+ useFactory: (firestore) => {
766
+ return new ShopMenuFirestoreRepository(firestore.firestore);
767
+ },
768
+ deps: [AngularFirestore],
769
+ },
770
+ {
771
+ provide: 'OrderRepository',
772
+ useFactory: (firestore) => {
773
+ return new OrderFirestoreRepository(firestore.firestore);
774
+ },
775
+ deps: [AngularFirestore],
776
+ },
777
+ {
778
+ provide: 'PaymentRepository',
779
+ useFactory: (firestore) => {
780
+ return new PaymentFirestoreRepository(firestore.firestore);
781
+ },
782
+ deps: [AngularFirestore],
783
+ },
784
+ {
785
+ provide: 'ProductRepository',
786
+ useFactory: (firestore) => {
787
+ return new ProductFirestoreRepository(firestore.firestore);
788
+ },
789
+ deps: [AngularFirestore],
790
+ },
791
+ {
792
+ provide: 'SubscriptionPaymentRepository',
793
+ useFactory: (firestore, subscriptionRepository) => {
794
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
795
+ },
796
+ deps: [AngularFirestore, 'SubscriptionRepository'],
797
+ },
798
+ {
799
+ provide: 'SubscriptionPlanRepository',
800
+ useFactory: (firestore) => {
801
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
802
+ },
803
+ deps: [AngularFirestore],
804
+ },
805
+ {
806
+ provide: 'SubscriptionProductRepository',
807
+ useFactory: (firestore) => {
808
+ return new SubscriptionProductFirestoreRepository(firestore.firestore);
809
+ },
810
+ deps: [AngularFirestore],
811
+ },
812
+ {
813
+ provide: 'SubscriptionRepository',
814
+ useFactory: (firestore) => {
815
+ return new SubscriptionFirestoreRepository(firestore.firestore);
816
+ },
817
+ deps: [AngularFirestore],
818
+ },
819
+ {
820
+ provide: 'UserRepository',
821
+ useFactory: (firestore) => {
822
+ return new UserFirestoreRepository(firestore.firestore);
823
+ },
824
+ deps: [AngularFirestore],
825
+ },
826
+ {
827
+ provide: 'UserAddressRepository',
828
+ useFactory: (firestore, userRepository) => {
829
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
830
+ },
831
+ deps: [AngularFirestore, 'UserRepository'],
832
+ },
833
+ {
834
+ provide: 'UserPaymentMethodRepository',
835
+ useFactory: (firestore, userRepository) => {
836
+ return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
837
+ },
838
+ deps: [AngularFirestore, 'UserRepository'],
839
+ },
840
+ {
841
+ provide: 'VariantRepository',
842
+ useFactory: (firestore, productRepository) => {
843
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
844
+ },
845
+ deps: [AngularFirestore, 'ProductRepository'],
846
+ },
847
+ ],
848
+ }]
819
849
  }] });
820
850
 
821
- class AngularConnectModule {
822
- static initializeApp(defaultShop, options, nameOrConfig) {
823
- return {
824
- ngModule: AngularConnectModule,
825
- providers: [
826
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
827
- ...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
828
- ...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
829
- ],
830
- };
831
- }
832
- }
833
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
834
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
835
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, OrderService], imports: [[AngularFireModule, AngularFirestoreModule]] });
836
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
837
- type: NgModule,
838
- args: [{
839
- imports: [AngularFireModule, AngularFirestoreModule],
840
- providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, OrderService],
841
- }]
851
+ class AngularConnectModule {
852
+ static initializeApp(defaultShop, options, nameOrConfig) {
853
+ return {
854
+ ngModule: AngularConnectModule,
855
+ providers: [
856
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
857
+ ...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
858
+ ...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
859
+ ],
860
+ };
861
+ }
862
+ }
863
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
864
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
865
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, OrderService], imports: [[AngularFireModule, AngularFirestoreModule]] });
866
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
867
+ type: NgModule,
868
+ args: [{
869
+ imports: [AngularFireModule, AngularFirestoreModule],
870
+ providers: [AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, OrderService],
871
+ }]
842
872
  }] });
843
873
 
844
- /**
845
- * Generated bundle index. Do not edit.
874
+ /**
875
+ * Generated bundle index. Do not edit.
846
876
  */
847
877
 
848
878
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, OrderService };