@infrab4a/connect-angular 3.5.1 → 3.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/angular-connect.module.d.ts +19 -19
  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/angular-hasura-graphql.module.d.ts +16 -16
  6. package/bundles/infrab4a-connect-angular.umd.js +1918 -1937
  7. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  8. package/consts/backend-url.const.d.ts +1 -1
  9. package/consts/default-shop.const.d.ts +1 -1
  10. package/consts/es-config.const.d.ts +1 -1
  11. package/consts/hasura-options.const.d.ts +1 -1
  12. package/consts/index.d.ts +4 -4
  13. package/esm2015/angular-connect.module.js +52 -52
  14. package/esm2015/angular-elastic-search.module.js +38 -38
  15. package/esm2015/angular-firebase-auth.module.js +113 -113
  16. package/esm2015/angular-firestore.module.js +352 -352
  17. package/esm2015/angular-hasura-graphql.module.js +156 -156
  18. package/esm2015/consts/backend-url.const.js +1 -1
  19. package/esm2015/consts/default-shop.const.js +2 -2
  20. package/esm2015/consts/es-config.const.js +2 -2
  21. package/esm2015/consts/hasura-options.const.js +2 -2
  22. package/esm2015/consts/index.js +5 -5
  23. package/esm2015/index.js +6 -6
  24. package/esm2015/infrab4a-connect-angular.js +4 -4
  25. package/esm2015/services/auth.service.js +42 -42
  26. package/esm2015/services/cart.service.js +148 -148
  27. package/esm2015/services/checkout-subscription.service.js +51 -51
  28. package/esm2015/services/checkout.service.js +75 -75
  29. package/esm2015/services/coupon.service.js +252 -266
  30. package/esm2015/services/errors/group-invalid-coupon.error.js +8 -8
  31. package/esm2015/services/errors/index.js +3 -3
  32. package/esm2015/services/errors/invalid-coupon.error.js +8 -8
  33. package/esm2015/services/home-shop.service.js +116 -116
  34. package/esm2015/services/index.js +9 -9
  35. package/esm2015/services/order.service.js +32 -32
  36. package/esm2015/services/shipping.service.js +98 -98
  37. package/esm2015/services/types/index.js +3 -3
  38. package/esm2015/services/types/required-checkout-data.type.js +2 -2
  39. package/esm2015/services/types/required-checkout-subscription-data.type.js +2 -2
  40. package/esm2015/services/types/shipping-methods.type.js +2 -2
  41. package/fesm2015/infrab4a-connect-angular.js +1412 -1426
  42. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  43. package/index.d.ts +5 -5
  44. package/infrab4a-connect-angular.d.ts +5 -5
  45. package/package.json +1 -1
  46. package/services/auth.service.d.ts +19 -19
  47. package/services/cart.service.d.ts +35 -35
  48. package/services/checkout-subscription.service.d.ts +18 -18
  49. package/services/checkout.service.d.ts +23 -23
  50. package/services/coupon.service.d.ts +26 -26
  51. package/services/errors/group-invalid-coupon.error.d.ts +6 -6
  52. package/services/errors/index.d.ts +2 -2
  53. package/services/errors/invalid-coupon.error.d.ts +5 -5
  54. package/services/home-shop.service.d.ts +25 -25
  55. package/services/index.d.ts +8 -8
  56. package/services/order.service.d.ts +13 -13
  57. package/services/shipping.service.d.ts +19 -19
  58. package/services/types/index.d.ts +2 -2
  59. package/services/types/required-checkout-data.type.d.ts +2 -2
  60. package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
  61. package/services/types/shipping-methods.type.d.ts +12 -12
@@ -6,7 +6,7 @@ import { of, combineLatest, from, throwError, Subject, iif, forkJoin } from 'rxj
6
6
  import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
7
7
  import { __awaiter } from 'tslib';
8
8
  import * as i1$1 from '@infrab4a/connect';
9
- import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, Status, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Category, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository } from '@infrab4a/connect';
9
+ import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Category, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository } from '@infrab4a/connect';
10
10
  import cookie from 'js-cookie';
11
11
  import { CustomError } from 'ts-custom-error';
12
12
  import * as i1$2 from '@angular/fire/firestore';
@@ -14,40 +14,40 @@ import { AngularFirestore } from '@angular/fire/firestore';
14
14
  import * as i1$3 from '@angular/common/http';
15
15
  import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
16
16
 
17
- class AuthService {
18
- constructor(angularFireAuth, userRepository) {
19
- this.angularFireAuth = angularFireAuth;
20
- this.userRepository = userRepository;
21
- }
22
- getAuthstate() {
23
- const observables = [
24
- this.angularFireAuth.authState.pipe(catchError(() => of(null))),
25
- this.getUser().pipe(catchError(() => of(null))),
26
- ];
27
- return combineLatest(observables).pipe(map(([fireUser, user]) => {
28
- return {
29
- user,
30
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
31
- };
32
- }));
33
- }
34
- getUser() {
35
- return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
36
- }
37
- getTokenId() {
38
- return this.angularFireAuth.idToken;
39
- }
40
- getFireUser() {
41
- return this.angularFireAuth.user.pipe(catchError(() => of(null)));
42
- }
43
- }
44
- 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 });
45
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
46
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
47
- type: Injectable
48
- }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
49
- type: Inject,
50
- args: ['UserRepository']
17
+ class AuthService {
18
+ constructor(angularFireAuth, userRepository) {
19
+ this.angularFireAuth = angularFireAuth;
20
+ this.userRepository = userRepository;
21
+ }
22
+ getAuthstate() {
23
+ const observables = [
24
+ this.angularFireAuth.authState.pipe(catchError(() => of(null))),
25
+ this.getUser().pipe(catchError(() => of(null))),
26
+ ];
27
+ return combineLatest(observables).pipe(map(([fireUser, user]) => {
28
+ return {
29
+ user,
30
+ isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
31
+ };
32
+ }));
33
+ }
34
+ getUser() {
35
+ return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))));
36
+ }
37
+ getTokenId() {
38
+ return this.angularFireAuth.idToken;
39
+ }
40
+ getFireUser() {
41
+ return this.angularFireAuth.user.pipe(catchError(() => of(null)));
42
+ }
43
+ }
44
+ 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 });
45
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
46
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
47
+ type: Injectable
48
+ }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
49
+ type: Inject,
50
+ args: ['UserRepository']
51
51
  }] }]; } });
52
52
 
53
53
  const BACKEND_URL = 'BACKEND_URL';
@@ -58,1425 +58,1411 @@ const ES_CONFIG = 'ES_CONFIG';
58
58
 
59
59
  const HASURA_OPTIONS = 'HASURA_OPTIONS';
60
60
 
61
- class InvalidCouponError extends CustomError {
62
- constructor(message) {
63
- super(message);
64
- this.message = message;
65
- }
61
+ class InvalidCouponError extends CustomError {
62
+ constructor(message) {
63
+ super(message);
64
+ this.message = message;
65
+ }
66
66
  }
67
67
 
68
- class GroupInvalidCouponError extends CustomError {
69
- constructor(errors) {
70
- super('Many coupon errors throw');
71
- this.errors = errors;
72
- }
68
+ class GroupInvalidCouponError extends CustomError {
69
+ constructor(errors) {
70
+ super('Many coupon errors throw');
71
+ this.errors = errors;
72
+ }
73
73
  }
74
74
 
75
- class CouponService {
76
- constructor(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
77
- this.couponRepository = couponRepository;
78
- this.defaultShop = defaultShop;
79
- this.orderRepository = orderRepository;
80
- this.subscriptionRepository = subscriptionRepository;
81
- this.categoryRepository = categoryRepository;
82
- this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
83
- this.separateValidCoupons = (coupons, userEmail) => coupons
84
- .map((coupon) => {
85
- try {
86
- if (!(coupon instanceof Coupon))
87
- throw new InvalidCouponError('Cupom inválido.');
88
- if (this.isValidCoupon(coupon, userEmail))
89
- return coupon;
90
- }
91
- catch (error) {
92
- return error;
93
- }
94
- })
95
- .reduce((current, coupon) => (Object.assign(Object.assign({}, current), (coupon instanceof Coupon
96
- ? { valids: [...current.valids, coupon] }
97
- : { invalids: [...current.invalids, coupon] }))), {
98
- valids: [],
99
- invalids: [],
100
- });
101
- }
102
- checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
103
- return from(this.couponRepository.find({
104
- filters: {
105
- nickname: { operator: Where.EQUALS, value: nickname },
106
- active: { operator: Where.EQUALS, value: true },
107
- },
108
- })).pipe(concatMap((coupons) => this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription)), concatMap((coupon) => this.checkCouponUseAndLimit(coupon, userEmail, checkout)), map((coupon) => this.isValidCoupon(coupon, userEmail)), map((coupon) => coupon));
109
- }
110
- checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
111
- // Caso não ache nenhum cupom, retorna erro
112
- if (coupons.count < 1) {
113
- return throwError('Cupom inválido.');
114
- }
115
- // Get Primeiro Cupom (o find do repository retorna um array)
116
- const coupon = coupons.data.shift();
117
- // Verifica se o cupom é aplicavel na loja
118
- const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
119
- // Cupon não aplicavel a loja retorna erro
120
- if (!isInShop)
121
- return throwError('Cupom inválido para loja.');
122
- // Verifica se o coupon é aplicado no checkout que está sendo realizado
123
- const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
124
- // Cupon não aplicavel ao checkout retorna erro
125
- if (!isCheckoutType)
126
- return throwError('Cupom inválido. Erro de checkout.');
127
- // Verifica se o cupom é ou pode ser aplicado para subscription
128
- if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
129
- // Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
130
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
131
- return throwError('Cupom inválido para sua assinatura.');
132
- }
133
- if (isSubscription)
134
- return of(coupon);
135
- // Verifica se possui o valor minimo de compra para utilização do cupom
136
- const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
137
- // Se não tem valor mínimo atingido, retorna erro
138
- if (!hasMinSubTotal)
139
- return throwError('Valor mínimo não atingido');
140
- return of(coupon);
141
- }
142
- isValidCoupon(coupon, userEmail) {
143
- // Verifica a data de inicio de validade do cupom
144
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
145
- throw new InvalidCouponError('Cupom ainda não liberado.');
146
- // Verifica a data de validade do cupom
147
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
148
- throw new InvalidCouponError('Cupom expirado.');
149
- return coupon;
150
- }
151
- checkCouponUseAndLimit(coupon, userEmail, checkout) {
152
- return __awaiter(this, void 0, void 0, function* () {
153
- const orders = yield this.orderRepository.find({
154
- filters: {
155
- coupon: { id: coupon.id },
156
- payment: { status: 'paid' },
157
- },
158
- });
159
- // orders que usuario ja fez com o cupom
160
- const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
161
- // Verifica o limite de uso de cupom por usuario
162
- if (coupon.useLimitPerUser && ordersUserCoupon.length)
163
- throw new InvalidCouponError('Limite de uso por usuário atingido.');
164
- // Verifica o limite de uso geral por usuario
165
- if (coupon.useLimit && orders.data.length >= coupon.useLimit)
166
- throw new InvalidCouponError('Limite de uso atingido.');
167
- const validUser = yield this.userValidationAndSubscriptionStatus(coupon, userEmail);
168
- if (!validUser)
169
- throw new InvalidCouponError('Usuário não elegível.');
170
- const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
171
- if (!hasProductCategories)
172
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
173
- return coupon;
174
- });
175
- }
176
- calcDiscountSubscription(coupon, checkout) {
177
- //
178
- let discount = 0;
179
- if (coupon.type === CouponTypes.ABSOLUTE)
180
- discount = coupon.discount;
181
- else if (coupon.type === CouponTypes.PERCENTAGE)
182
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
183
- return of(discount);
184
- }
185
- calcDiscountShopping(coupon, checkout) {
186
- return __awaiter(this, void 0, void 0, function* () {
187
- let discount = 0;
188
- switch (coupon.type) {
189
- case CouponTypes.ABSOLUTE: {
190
- discount = coupon.discount;
191
- break;
192
- }
193
- case CouponTypes.PERCENTAGE: {
194
- discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
195
- break;
196
- }
197
- }
198
- return discount;
199
- });
200
- }
201
- calcShoppingPercentageDiscount(coupon, checkout) {
202
- var _a;
203
- return __awaiter(this, void 0, void 0, function* () {
204
- let discount = 0;
205
- const shop = checkout.shop;
206
- let lineItensDiscount = [];
207
- const couponCategories = yield this.getCouponCategoriesId(coupon);
208
- if (coupon.productsCategories && coupon.productsCategories.length) {
209
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
210
- var _a;
211
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
212
- return i.categories.some((c) => couponCategories.some(cat => (cat.id == c || cat.firestoreId == c)));
213
- }
214
- return true;
215
- });
216
- }
217
- else {
218
- lineItensDiscount = checkout.lineItems;
219
- }
220
- const subTotal = lineItensDiscount.reduce((acc, curr) => {
221
- var _a, _b, _c;
222
- return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
223
- ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
224
- : acc + curr.pricePaid * curr.quantity;
225
- }, 0) || 0;
226
- discount = subTotal * (coupon.discount / 100);
227
- return discount;
228
- });
229
- }
230
- hasMinSubTotal(coupon, checkout) {
231
- var _a;
232
- if (!coupon.minSubTotalValue)
233
- return true;
234
- const shop = checkout.shop;
235
- let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
236
- var _a, _b, _c;
237
- return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
238
- ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
239
- : acc + curr.pricePaid * curr.quantity;
240
- }, 0)) || 0;
241
- if (coupon.minSubTotalValue <= subTotal)
242
- return true;
243
- return false;
244
- }
245
- hasProductCategories(coupon, checkout) {
246
- var _a;
247
- return __awaiter(this, void 0, void 0, function* () {
248
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
249
- return true;
250
- }
251
- const couponCategories = yield this.getCouponCategoriesId(coupon);
252
- const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(i => {
253
- var _a;
254
- if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
255
- return true;
256
- return i.categories.some((c) => couponCategories.some(cat => (cat.id == c || cat.firestoreId == c)));
257
- });
258
- return hasCategories.length ? true : false;
259
- });
260
- }
261
- userValidationAndSubscriptionStatus(coupon, userEmail) {
262
- return __awaiter(this, void 0, void 0, function* () {
263
- // Verifica se o email do usuário é coorporativo
264
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
265
- throw new InvalidCouponError('Você não é colaborador.');
266
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
267
- if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
268
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
269
- const couponRuleSubscription = coupon.exclusivityType === Exclusivities.ACTIVE_SUBSCRIBER ||
270
- coupon.exclusivityType === Exclusivities.INACTIVE_SUBSCRIBER ||
271
- coupon.exclusivityType === Exclusivities.NON_SUBSCRIBER;
272
- if (couponRuleSubscription && userEmail) {
273
- const sub = yield this.subscriptionRepository
274
- .find({
275
- filters: {
276
- user: {
277
- email: { operator: Where.EQUALS, value: userEmail },
278
- },
279
- },
280
- })
281
- .then((sub) => sub.data);
282
- const activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter((s) => s.status === Status.ACTIVE);
283
- switch (coupon.exclusivityType) {
284
- case Exclusivities.ACTIVE_SUBSCRIBER:
285
- return activeSubs.length > 0;
286
- case Exclusivities.INACTIVE_SUBSCRIBER:
287
- return activeSubs.length === 0;
288
- case Exclusivities.NON_SUBSCRIBER:
289
- return sub.length === 0;
290
- default:
291
- return false;
292
- }
293
- }
294
- return true;
295
- });
296
- }
297
- getCouponCategoriesId(coupon) {
298
- return __awaiter(this, void 0, void 0, function* () {
299
- let couponCategories = [];
300
- for (let index = 0; index < coupon.productsCategories.length; index++) {
301
- let c = yield this.categoryRepository.get({ id: coupon.productsCategories[index] });
302
- couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
303
- }
304
- return couponCategories;
305
- });
306
- }
307
- }
308
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
309
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
310
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
311
- type: Injectable,
312
- args: [{
313
- providedIn: 'root',
314
- }]
315
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
316
- type: Inject,
317
- args: ['CouponRepository']
318
- }] }, { type: i1$1.Shops, decorators: [{
319
- type: Inject,
320
- args: [DEFAULT_SHOP]
321
- }] }, { type: undefined, decorators: [{
322
- type: Inject,
323
- args: ['OrderRepository']
324
- }] }, { type: undefined, decorators: [{
325
- type: Inject,
326
- args: ['SubscriptionRepository']
327
- }] }, { type: undefined, decorators: [{
328
- type: Inject,
329
- args: ['CategoryRepository']
75
+ class CouponService {
76
+ constructor(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
77
+ this.couponRepository = couponRepository;
78
+ this.defaultShop = defaultShop;
79
+ this.orderRepository = orderRepository;
80
+ this.subscriptionRepository = subscriptionRepository;
81
+ this.categoryRepository = categoryRepository;
82
+ this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
83
+ this.separateValidCoupons = (coupons, userEmail) => coupons
84
+ .map((coupon) => {
85
+ try {
86
+ if (!(coupon instanceof Coupon))
87
+ throw new InvalidCouponError('Cupom inválido.');
88
+ if (this.isValidCoupon(coupon, userEmail))
89
+ return coupon;
90
+ }
91
+ catch (error) {
92
+ return error;
93
+ }
94
+ })
95
+ .reduce((current, coupon) => (Object.assign(Object.assign({}, current), (coupon instanceof Coupon
96
+ ? { valids: [...current.valids, coupon] }
97
+ : { invalids: [...current.invalids, coupon] }))), {
98
+ valids: [],
99
+ invalids: [],
100
+ });
101
+ }
102
+ checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
103
+ return from(this.couponRepository.find({
104
+ filters: {
105
+ nickname: { operator: Where.EQUALS, value: nickname },
106
+ active: { operator: Where.EQUALS, value: true },
107
+ },
108
+ })).pipe(concatMap((coupons) => this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription)), concatMap((coupon) => this.checkCouponUseAndLimit(coupon, userEmail, checkout)), map((coupon) => this.isValidCoupon(coupon, userEmail)), map((coupon) => coupon));
109
+ }
110
+ checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
111
+ // Caso não ache nenhum cupom, retorna erro
112
+ if (coupons.count < 1) {
113
+ return throwError('Cupom inválido.');
114
+ }
115
+ // Get Primeiro Cupom (o find do repository retorna um array)
116
+ const coupon = coupons.data.shift();
117
+ // Verifica se o cupom é aplicavel na loja
118
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
119
+ // Cupon não aplicavel a loja retorna erro
120
+ if (!isInShop)
121
+ return throwError('Cupom inválido para loja.');
122
+ // Verifica se o coupon é aplicado no checkout que está sendo realizado
123
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
124
+ // Cupon não aplicavel ao checkout retorna erro
125
+ if (!isCheckoutType)
126
+ return throwError('Cupom inválido. Erro de checkout.');
127
+ // Verifica se o cupom é ou pode ser aplicado para subscription
128
+ if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
129
+ // Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
130
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
131
+ return throwError('Cupom inválido para sua assinatura.');
132
+ }
133
+ if (isSubscription)
134
+ return of(coupon);
135
+ // Verifica se possui o valor minimo de compra para utilização do cupom
136
+ const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
137
+ // Se não tem valor mínimo atingido, retorna erro
138
+ if (!hasMinSubTotal)
139
+ return throwError('Valor mínimo não atingido');
140
+ return of(coupon);
141
+ }
142
+ isValidCoupon(coupon, userEmail) {
143
+ // Verifica a data de inicio de validade do cupom
144
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
145
+ throw new InvalidCouponError('Cupom ainda não liberado.');
146
+ // Verifica a data de validade do cupom
147
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
148
+ throw new InvalidCouponError('Cupom expirado.');
149
+ return coupon;
150
+ }
151
+ checkCouponUseAndLimit(coupon, userEmail, checkout) {
152
+ return __awaiter(this, void 0, void 0, function* () {
153
+ const orders = yield this.orderRepository.find({
154
+ filters: {
155
+ coupon: { id: coupon.id },
156
+ payment: { status: 'paid' },
157
+ },
158
+ });
159
+ // orders que usuario ja fez com o cupom
160
+ const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
161
+ // Verifica o limite de uso de cupom por usuario
162
+ if (coupon.useLimitPerUser && ordersUserCoupon.length)
163
+ throw new InvalidCouponError('Limite de uso por usuário atingido.');
164
+ // Verifica o limite de uso geral por usuario
165
+ if (coupon.useLimit && orders.data.length >= coupon.useLimit)
166
+ throw new InvalidCouponError('Limite de uso atingido.');
167
+ const validUser = yield this.userValidationAndSubscriptionStatus(coupon, checkout.user);
168
+ if (!validUser)
169
+ throw new InvalidCouponError('Usuário não elegível.');
170
+ const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
171
+ if (!hasProductCategories)
172
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
173
+ return coupon;
174
+ });
175
+ }
176
+ calcDiscountSubscription(coupon, checkout) {
177
+ //
178
+ let discount = 0;
179
+ if (coupon.type === CouponTypes.ABSOLUTE)
180
+ discount = coupon.discount;
181
+ else if (coupon.type === CouponTypes.PERCENTAGE)
182
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
183
+ return of(discount);
184
+ }
185
+ calcDiscountShopping(coupon, checkout) {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ let discount = 0;
188
+ switch (coupon.type) {
189
+ case CouponTypes.ABSOLUTE: {
190
+ discount = coupon.discount;
191
+ break;
192
+ }
193
+ case CouponTypes.PERCENTAGE: {
194
+ discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
195
+ break;
196
+ }
197
+ }
198
+ return discount;
199
+ });
200
+ }
201
+ calcShoppingPercentageDiscount(coupon, checkout) {
202
+ var _a;
203
+ return __awaiter(this, void 0, void 0, function* () {
204
+ let discount = 0;
205
+ const shop = checkout.shop;
206
+ let lineItensDiscount = [];
207
+ const couponCategories = yield this.getCouponCategoriesId(coupon);
208
+ if (coupon.productsCategories && coupon.productsCategories.length) {
209
+ lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
210
+ var _a;
211
+ if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
212
+ return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
213
+ }
214
+ return true;
215
+ });
216
+ }
217
+ else {
218
+ lineItensDiscount = checkout.lineItems;
219
+ }
220
+ const subTotal = lineItensDiscount.reduce((acc, curr) => {
221
+ var _a, _b, _c;
222
+ return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
223
+ ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
224
+ : acc + curr.pricePaid * curr.quantity;
225
+ }, 0) || 0;
226
+ discount = subTotal * (coupon.discount / 100);
227
+ return discount;
228
+ });
229
+ }
230
+ hasMinSubTotal(coupon, checkout) {
231
+ var _a;
232
+ if (!coupon.minSubTotalValue)
233
+ return true;
234
+ const shop = checkout.shop;
235
+ let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
236
+ var _a, _b, _c;
237
+ return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
238
+ ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
239
+ : acc + curr.pricePaid * curr.quantity;
240
+ }, 0)) || 0;
241
+ if (coupon.minSubTotalValue <= subTotal)
242
+ return true;
243
+ return false;
244
+ }
245
+ hasProductCategories(coupon, checkout) {
246
+ var _a;
247
+ return __awaiter(this, void 0, void 0, function* () {
248
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
249
+ return true;
250
+ }
251
+ const couponCategories = yield this.getCouponCategoriesId(coupon);
252
+ const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
253
+ var _a;
254
+ if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
255
+ return true;
256
+ return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
257
+ });
258
+ return hasCategories.length ? true : false;
259
+ });
260
+ }
261
+ userValidationAndSubscriptionStatus(coupon, user) {
262
+ return __awaiter(this, void 0, void 0, function* () {
263
+ // Verifica se o email do usuário é coorporativo
264
+ if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
265
+ throw new InvalidCouponError('Você não é colaborador.');
266
+ // Verifica se o email do usuário é associado ao cupom de uso por usuario
267
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
268
+ throw new InvalidCouponError('Cupom não é válido para este usuário.');
269
+ switch (coupon.exclusivityType) {
270
+ case Exclusivities.ACTIVE_SUBSCRIBER:
271
+ return user.isSubscriber ? true : false;
272
+ case Exclusivities.INACTIVE_SUBSCRIBER:
273
+ return user.isSubscriber ? false : true;
274
+ case Exclusivities.NON_SUBSCRIBER:
275
+ return user.isSubscriber ? false : true;
276
+ default:
277
+ return false;
278
+ }
279
+ });
280
+ }
281
+ getCouponCategoriesId(coupon) {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ let couponCategories = [];
284
+ for (let index = 0; index < coupon.productsCategories.length; index++) {
285
+ let c = yield this.categoryRepository.get({
286
+ id: coupon.productsCategories[index],
287
+ });
288
+ couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
289
+ }
290
+ return couponCategories;
291
+ });
292
+ }
293
+ }
294
+ CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
295
+ CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
296
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
297
+ type: Injectable,
298
+ args: [{
299
+ providedIn: 'root',
300
+ }]
301
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
302
+ type: Inject,
303
+ args: ['CouponRepository']
304
+ }] }, { type: i1$1.Shops, decorators: [{
305
+ type: Inject,
306
+ args: [DEFAULT_SHOP]
307
+ }] }, { type: undefined, decorators: [{
308
+ type: Inject,
309
+ args: ['OrderRepository']
310
+ }] }, { type: undefined, decorators: [{
311
+ type: Inject,
312
+ args: ['SubscriptionRepository']
313
+ }] }, { type: undefined, decorators: [{
314
+ type: Inject,
315
+ args: ['CategoryRepository']
330
316
  }] }]; } });
331
317
 
332
- class CheckoutService {
333
- constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
334
- this.couponService = couponService;
335
- this.checkoutRepository = checkoutRepository;
336
- this.orderRepository = orderRepository;
337
- this.userRepository = userRepository;
338
- this.defaultShop = defaultShop;
339
- }
340
- getCheckout(checkoutData) {
341
- const checkoutId = cookie.get('checkoutId');
342
- if (!isNil(checkoutId))
343
- return from(this.checkoutRepository.get({ id: checkoutId }));
344
- return from(this.createCheckout(checkoutData));
345
- }
346
- getUserByCheckout(checkoutId) {
347
- 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'))));
348
- }
349
- updateCheckoutLineItems(checkout) {
350
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
351
- }
352
- updateCheckoutUser(checkout) {
353
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
354
- }
355
- clearCheckoutFromSession() {
356
- cookie.remove('checkoutId');
357
- return of();
358
- }
359
- calcDiscount(coupon) {
360
- return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
361
- }
362
- checkCoupon(nickname, checkoutType) {
363
- return this.getCheckout().pipe(concatMap((checkout) => {
364
- var _a;
365
- return this.couponService
366
- .checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
367
- .pipe();
368
- }));
369
- }
370
- createCheckout(checkoutData) {
371
- return __awaiter(this, void 0, void 0, function* () {
372
- 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 }));
373
- cookie.set('checkoutId', checkout.id);
374
- return checkout;
375
- });
376
- }
377
- }
378
- 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 });
379
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
380
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
381
- type: Injectable
382
- }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
383
- type: Inject,
384
- args: ['CheckoutRepository']
385
- }] }, { type: undefined, decorators: [{
386
- type: Inject,
387
- args: ['OrderRepository']
388
- }] }, { type: undefined, decorators: [{
389
- type: Inject,
390
- args: ['UserRepository']
391
- }] }, { type: i1$1.Shops, decorators: [{
392
- type: Inject,
393
- args: [DEFAULT_SHOP]
318
+ class CheckoutService {
319
+ constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
320
+ this.couponService = couponService;
321
+ this.checkoutRepository = checkoutRepository;
322
+ this.orderRepository = orderRepository;
323
+ this.userRepository = userRepository;
324
+ this.defaultShop = defaultShop;
325
+ }
326
+ getCheckout(checkoutData) {
327
+ const checkoutId = cookie.get('checkoutId');
328
+ if (!isNil(checkoutId))
329
+ return from(this.checkoutRepository.get({ id: checkoutId }));
330
+ return from(this.createCheckout(checkoutData));
331
+ }
332
+ getUserByCheckout(checkoutId) {
333
+ 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'))));
334
+ }
335
+ updateCheckoutLineItems(checkout) {
336
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
337
+ }
338
+ updateCheckoutUser(checkout) {
339
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
340
+ }
341
+ clearCheckoutFromSession() {
342
+ cookie.remove('checkoutId');
343
+ return of();
344
+ }
345
+ calcDiscount(coupon) {
346
+ return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
347
+ }
348
+ checkCoupon(nickname, checkoutType) {
349
+ return this.getCheckout().pipe(concatMap((checkout) => {
350
+ var _a;
351
+ return this.couponService
352
+ .checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
353
+ .pipe();
354
+ }));
355
+ }
356
+ createCheckout(checkoutData) {
357
+ return __awaiter(this, void 0, void 0, function* () {
358
+ 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 }));
359
+ cookie.set('checkoutId', checkout.id);
360
+ return checkout;
361
+ });
362
+ }
363
+ }
364
+ 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 });
365
+ CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
366
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
367
+ type: Injectable
368
+ }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
369
+ type: Inject,
370
+ args: ['CheckoutRepository']
371
+ }] }, { type: undefined, decorators: [{
372
+ type: Inject,
373
+ args: ['OrderRepository']
374
+ }] }, { type: undefined, decorators: [{
375
+ type: Inject,
376
+ args: ['UserRepository']
377
+ }] }, { type: i1$1.Shops, decorators: [{
378
+ type: Inject,
379
+ args: [DEFAULT_SHOP]
394
380
  }] }]; } });
395
381
 
396
- class CartService {
397
- constructor(authService, checkoutService, defaultShop, productRepository) {
398
- this.authService = authService;
399
- this.checkoutService = checkoutService;
400
- this.defaultShop = defaultShop;
401
- this.productRepository = productRepository;
402
- this.cartSubject = new Subject();
403
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
404
- var _a;
405
- const items = [];
406
- const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
407
- if (index > -1) {
408
- checkoutLoaded.lineItems[index].quantity += quantity;
409
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
410
- }
411
- else
412
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
413
- return this.checkoutService
414
- .updateCheckoutLineItems(checkoutLoaded)
415
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
416
- }));
417
- this.generateCartObject = (items) => {
418
- const cart = {};
419
- items === null || items === void 0 ? void 0 : items.forEach((item) => {
420
- var _a;
421
- 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) })));
422
- });
423
- return cart;
424
- };
425
- this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
426
- var _a, _b, _c, _d, _e, _f, _g;
427
- const product = yield this.productRepository.get({ id: item.id });
428
- 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;
429
- if (this.checkMaxStock(item, quantity || 0))
430
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
431
- const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
432
- const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
433
- const isGift = item.isGift || null;
434
- const pricePaid = this.getProductPrice({
435
- product: item,
436
- shop: checkout.shop || this.defaultShop,
437
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
438
- });
439
- return {
440
- checkout,
441
- lineItem: LineItem.toInstance({
442
- id,
443
- name: name !== null && name !== void 0 ? name : product.name,
444
- EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
445
- brand: product.brand,
446
- slug: slug !== null && slug !== void 0 ? slug : product.slug,
447
- sku: sku !== null && sku !== void 0 ? sku : product.sku,
448
- stock,
449
- price,
450
- image,
451
- weight: weight !== null && weight !== void 0 ? weight : product.weight,
452
- quantity: (item.quantity || 0) + (quantity || 0),
453
- pricePaid,
454
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
455
- isGift: isGift !== null && isGift !== void 0 ? isGift : null,
456
- costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
457
- type,
458
- }),
459
- };
460
- });
461
- this.getProductPrice = ({ product, isSubscriber, }) => {
462
- const info = product.price;
463
- if (product.isGift)
464
- return 0;
465
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
466
- };
467
- this.checkMaxStock = (item, quantity) => {
468
- var _a;
469
- const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
470
- const currentItemAmount = item.quantity || 0;
471
- return currentItemAmount + quantity > maxStock;
472
- };
473
- }
474
- addItem(item, quantity = 1) {
475
- return from(this.checkoutService.getCheckout()).pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.buildLineItem({ checkout, item, quantity: quantity || 1 }); })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
476
- }
477
- decreaseItem(item) {
478
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
479
- var _a;
480
- const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
481
- if (!isNil(checkoutItem))
482
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
483
- return checkout;
484
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
485
- }
486
- getCart(checkout) {
487
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
488
- return this.cartSubject;
489
- }
490
- /**
491
- * @deprecated The method should not be used
492
- */
493
- getVariantPriceDiscount(item) {
494
- return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
495
- }
496
- removeItem(item) {
497
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
498
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
499
- if (index >= 0)
500
- checkout.lineItems.splice(index, 1);
501
- return checkout;
502
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
503
- }
504
- updateUserCart(user) {
505
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
506
- var _a, _b;
507
- return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length) ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; }))) : [] }))).toPromise();
508
- })), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
509
- }
510
- clearCart() {
511
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
512
- this.checkoutService.clearCheckoutFromSession();
513
- return checkout;
514
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
515
- }
516
- buildCartFromCheckout(checkoutData) {
517
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
518
- }
519
- }
520
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
521
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
522
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
523
- type: Injectable
524
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
525
- type: Inject,
526
- args: [DEFAULT_SHOP]
527
- }] }, { type: undefined, decorators: [{
528
- type: Inject,
529
- args: ['ProductRepository']
382
+ class CartService {
383
+ constructor(authService, checkoutService, defaultShop, productRepository) {
384
+ this.authService = authService;
385
+ this.checkoutService = checkoutService;
386
+ this.defaultShop = defaultShop;
387
+ this.productRepository = productRepository;
388
+ this.cartSubject = new Subject();
389
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
390
+ var _a;
391
+ const items = [];
392
+ const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
393
+ if (index > -1) {
394
+ checkoutLoaded.lineItems[index].quantity += quantity;
395
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
396
+ }
397
+ else
398
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
399
+ return this.checkoutService
400
+ .updateCheckoutLineItems(checkoutLoaded)
401
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
402
+ }));
403
+ this.generateCartObject = (items) => {
404
+ const cart = {};
405
+ items === null || items === void 0 ? void 0 : items.forEach((item) => {
406
+ var _a;
407
+ 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) })));
408
+ });
409
+ return cart;
410
+ };
411
+ this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
412
+ var _a, _b, _c, _d, _e, _f, _g;
413
+ const product = yield this.productRepository.get({ id: item.id });
414
+ 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;
415
+ if (this.checkMaxStock(item, quantity || 0))
416
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
417
+ const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
418
+ const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
419
+ const isGift = item.isGift || null;
420
+ const pricePaid = this.getProductPrice({
421
+ product: item,
422
+ shop: checkout.shop || this.defaultShop,
423
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
424
+ });
425
+ return {
426
+ checkout,
427
+ lineItem: LineItem.toInstance({
428
+ id,
429
+ name: name !== null && name !== void 0 ? name : product.name,
430
+ EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
431
+ brand: product.brand,
432
+ slug: slug !== null && slug !== void 0 ? slug : product.slug,
433
+ sku: sku !== null && sku !== void 0 ? sku : product.sku,
434
+ stock,
435
+ price,
436
+ image,
437
+ weight: weight !== null && weight !== void 0 ? weight : product.weight,
438
+ quantity: (item.quantity || 0) + (quantity || 0),
439
+ pricePaid,
440
+ categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
441
+ isGift: isGift !== null && isGift !== void 0 ? isGift : null,
442
+ costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
443
+ type,
444
+ }),
445
+ };
446
+ });
447
+ this.getProductPrice = ({ product, isSubscriber, }) => {
448
+ const info = product.price;
449
+ if (product.isGift)
450
+ return 0;
451
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
452
+ };
453
+ this.checkMaxStock = (item, quantity) => {
454
+ var _a;
455
+ const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
456
+ const currentItemAmount = item.quantity || 0;
457
+ return currentItemAmount + quantity > maxStock;
458
+ };
459
+ }
460
+ addItem(item, quantity = 1) {
461
+ return from(this.checkoutService.getCheckout()).pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.buildLineItem({ checkout, item, quantity: quantity || 1 }); })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
462
+ }
463
+ decreaseItem(item) {
464
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
465
+ var _a;
466
+ const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
467
+ if (!isNil(checkoutItem))
468
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
469
+ return checkout;
470
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
471
+ }
472
+ getCart(checkout) {
473
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
474
+ return this.cartSubject;
475
+ }
476
+ /**
477
+ * @deprecated The method should not be used
478
+ */
479
+ getVariantPriceDiscount(item) {
480
+ return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
481
+ }
482
+ removeItem(item) {
483
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
484
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
485
+ if (index >= 0)
486
+ checkout.lineItems.splice(index, 1);
487
+ return checkout;
488
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
489
+ }
490
+ updateUserCart(user) {
491
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
492
+ var _a, _b;
493
+ return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length) ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; }))) : [] }))).toPromise();
494
+ })), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
495
+ }
496
+ clearCart() {
497
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
498
+ this.checkoutService.clearCheckoutFromSession();
499
+ return checkout;
500
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
501
+ }
502
+ buildCartFromCheckout(checkoutData) {
503
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
504
+ }
505
+ }
506
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
507
+ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
508
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
509
+ type: Injectable
510
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
511
+ type: Inject,
512
+ args: [DEFAULT_SHOP]
513
+ }] }, { type: undefined, decorators: [{
514
+ type: Inject,
515
+ args: ['ProductRepository']
530
516
  }] }]; } });
531
517
 
532
- class CheckoutSubscriptionService {
533
- constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
534
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
535
- this.subscriptionRepository = subscriptionRepository;
536
- this.couponService = couponService;
537
- }
538
- getCheckoutSubscription(checkoutData) {
539
- const checkoutId = cookie.get('checkoutSubscriptionId');
540
- if (!isNil(checkoutId))
541
- return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
542
- return from(this.createCheckoutSubscription(checkoutData));
543
- }
544
- createCheckoutSubscription(checkoutData) {
545
- return __awaiter(this, void 0, void 0, function* () {
546
- const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
547
- cookie.set('checkoutSubscriptionId', checkout.id);
548
- return checkout;
549
- });
550
- }
551
- clearCheckoutSubscriptionFromSession() {
552
- cookie.remove('checkoutSubscriptionId');
553
- return of();
554
- }
555
- checkCoupon(nickname, userEmail) {
556
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
557
- }
558
- calcDiscountSubscription(coupon) {
559
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
560
- }
561
- }
562
- 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 });
563
- CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
564
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
565
- type: Injectable
566
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
567
- type: Inject,
568
- args: ['CheckoutSubscriptionRepository']
569
- }] }, { type: undefined, decorators: [{
570
- type: Inject,
571
- args: ['SubscriptionRepository']
518
+ class CheckoutSubscriptionService {
519
+ constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
520
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
521
+ this.subscriptionRepository = subscriptionRepository;
522
+ this.couponService = couponService;
523
+ }
524
+ getCheckoutSubscription(checkoutData) {
525
+ const checkoutId = cookie.get('checkoutSubscriptionId');
526
+ if (!isNil(checkoutId))
527
+ return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
528
+ return from(this.createCheckoutSubscription(checkoutData));
529
+ }
530
+ createCheckoutSubscription(checkoutData) {
531
+ return __awaiter(this, void 0, void 0, function* () {
532
+ const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
533
+ cookie.set('checkoutSubscriptionId', checkout.id);
534
+ return checkout;
535
+ });
536
+ }
537
+ clearCheckoutSubscriptionFromSession() {
538
+ cookie.remove('checkoutSubscriptionId');
539
+ return of();
540
+ }
541
+ checkCoupon(nickname, userEmail) {
542
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
543
+ }
544
+ calcDiscountSubscription(coupon) {
545
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
546
+ }
547
+ }
548
+ 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 });
549
+ CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
550
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
551
+ type: Injectable
552
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
553
+ type: Inject,
554
+ args: ['CheckoutSubscriptionRepository']
555
+ }] }, { type: undefined, decorators: [{
556
+ type: Inject,
557
+ args: ['SubscriptionRepository']
572
558
  }] }, { type: CouponService }]; } });
573
559
 
574
- class HomeShopService {
575
- constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
576
- this.categoryRepository = categoryRepository;
577
- this.homeRepository = homeRepository;
578
- this.productRepository = productRepository;
579
- this.defaultShop = defaultShop;
580
- this.buildCategoryGroupWithRequiredData = (group) => {
581
- var _a, _b;
582
- return ({
583
- category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
584
- products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
585
- 'id',
586
- 'price',
587
- 'reviews',
588
- 'hasVariants',
589
- 'slug',
590
- 'sku',
591
- 'stock',
592
- 'costPrice',
593
- 'images',
594
- 'miniatures',
595
- 'name',
596
- 'weight',
597
- 'rate',
598
- 'type',
599
- ])))) || [],
600
- });
601
- };
602
- }
603
- get homeId() {
604
- if (this.defaultShop === Shops.GLAMSHOP)
605
- return 'glamshop';
606
- if (this.defaultShop === Shops.MENSMARKET)
607
- return 'mens_market';
608
- return null;
609
- }
610
- getHomeData() {
611
- return this.getHomeConfiguration().pipe(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
612
- ? of(home)
613
- : forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
614
- discoverProducts,
615
- featuredProducts,
616
- verticalProducts,
617
- })), concatMap((data) => this.saveHomeData(data)))));
618
- }
619
- getBanners(type) {
620
- return this.getHomeConfiguration().pipe(map((home) => {
621
- if (type === 'brand')
622
- return home.brandsCarousel;
623
- if (type === 'buyToWin')
624
- return [home.buyToWinBanner];
625
- if (type === 'block')
626
- return home.blockBanners;
627
- if (type === 'blog')
628
- return [home.blogBanner];
629
- }));
630
- }
631
- getMinValueForFreeShipping() {
632
- return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
633
- }
634
- getDiscoverProducts() {
635
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
636
- }
637
- getFeaturedProducts() {
638
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
639
- }
640
- getVerticalProducts() {
641
- return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
642
- filters: { categories: { operator: Where.IN, value: [category.id] } },
643
- limits: { limit: 12 },
644
- })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
645
- }
646
- getHomeConfiguration() {
647
- return of(this.homeConfiguration).pipe(concatMap((home) => home
648
- ? of(home)
649
- : !this.homeId
650
- ? throwError(new RequiredArgumentError(['homeId']))
651
- : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
652
- }
653
- saveHomeData(homeData) {
654
- const data = {
655
- createdAt: new Date(),
656
- expiresAt: add(new Date(), { hours: 1 }),
657
- data: homeData,
658
- };
659
- return from(this.homeRepository.update({
660
- id: this.homeId,
661
- data,
662
- })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
663
- }
664
- }
665
- 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 });
666
- HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
667
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
668
- type: Injectable
669
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
670
- type: Inject,
671
- args: ['CategoryRepository']
672
- }] }, { type: undefined, decorators: [{
673
- type: Inject,
674
- args: ['HomeRepository']
675
- }] }, { type: undefined, decorators: [{
676
- type: Inject,
677
- args: ['ProductRepository']
678
- }] }, { type: i1$1.Shops, decorators: [{
679
- type: Inject,
680
- args: [DEFAULT_SHOP]
560
+ class HomeShopService {
561
+ constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
562
+ this.categoryRepository = categoryRepository;
563
+ this.homeRepository = homeRepository;
564
+ this.productRepository = productRepository;
565
+ this.defaultShop = defaultShop;
566
+ this.buildCategoryGroupWithRequiredData = (group) => {
567
+ var _a, _b;
568
+ return ({
569
+ category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
570
+ products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
571
+ 'id',
572
+ 'price',
573
+ 'reviews',
574
+ 'hasVariants',
575
+ 'slug',
576
+ 'sku',
577
+ 'stock',
578
+ 'costPrice',
579
+ 'images',
580
+ 'miniatures',
581
+ 'name',
582
+ 'weight',
583
+ 'rate',
584
+ 'type',
585
+ ])))) || [],
586
+ });
587
+ };
588
+ }
589
+ get homeId() {
590
+ if (this.defaultShop === Shops.GLAMSHOP)
591
+ return 'glamshop';
592
+ if (this.defaultShop === Shops.MENSMARKET)
593
+ return 'mens_market';
594
+ return null;
595
+ }
596
+ getHomeData() {
597
+ return this.getHomeConfiguration().pipe(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
598
+ ? of(home)
599
+ : forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
600
+ discoverProducts,
601
+ featuredProducts,
602
+ verticalProducts,
603
+ })), concatMap((data) => this.saveHomeData(data)))));
604
+ }
605
+ getBanners(type) {
606
+ return this.getHomeConfiguration().pipe(map((home) => {
607
+ if (type === 'brand')
608
+ return home.brandsCarousel;
609
+ if (type === 'buyToWin')
610
+ return [home.buyToWinBanner];
611
+ if (type === 'block')
612
+ return home.blockBanners;
613
+ if (type === 'blog')
614
+ return [home.blogBanner];
615
+ }));
616
+ }
617
+ getMinValueForFreeShipping() {
618
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
619
+ }
620
+ getDiscoverProducts() {
621
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
622
+ }
623
+ getFeaturedProducts() {
624
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
625
+ }
626
+ getVerticalProducts() {
627
+ return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
628
+ filters: { categories: { operator: Where.IN, value: [category.id] } },
629
+ limits: { limit: 12 },
630
+ })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
631
+ }
632
+ getHomeConfiguration() {
633
+ return of(this.homeConfiguration).pipe(concatMap((home) => home
634
+ ? of(home)
635
+ : !this.homeId
636
+ ? throwError(new RequiredArgumentError(['homeId']))
637
+ : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
638
+ }
639
+ saveHomeData(homeData) {
640
+ const data = {
641
+ createdAt: new Date(),
642
+ expiresAt: add(new Date(), { hours: 1 }),
643
+ data: homeData,
644
+ };
645
+ return from(this.homeRepository.update({
646
+ id: this.homeId,
647
+ data,
648
+ })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
649
+ }
650
+ }
651
+ 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 });
652
+ HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
653
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
654
+ type: Injectable
655
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
656
+ type: Inject,
657
+ args: ['CategoryRepository']
658
+ }] }, { type: undefined, decorators: [{
659
+ type: Inject,
660
+ args: ['HomeRepository']
661
+ }] }, { type: undefined, decorators: [{
662
+ type: Inject,
663
+ args: ['ProductRepository']
664
+ }] }, { type: i1$1.Shops, decorators: [{
665
+ type: Inject,
666
+ args: [DEFAULT_SHOP]
681
667
  }] }]; } });
682
668
 
683
- class OrderService {
684
- constructor(angularFirestore, orderRepository) {
685
- this.angularFirestore = angularFirestore;
686
- this.orderRepository = orderRepository;
687
- this.orderSubject = new Subject();
688
- }
689
- getOrder(id) {
690
- this.angularFirestore
691
- .doc(`${this.orderRepository.collectionName}/${id}`)
692
- .valueChanges()
693
- .pipe(map((doc) => Order.toInstance(doc)))
694
- .subscribe((doc) => this.orderSubject.next(doc));
695
- return this.orderSubject;
696
- }
697
- }
698
- 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 });
699
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
700
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
701
- type: Injectable
702
- }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
703
- type: Inject,
704
- args: ['OrderRepository']
669
+ class OrderService {
670
+ constructor(angularFirestore, orderRepository) {
671
+ this.angularFirestore = angularFirestore;
672
+ this.orderRepository = orderRepository;
673
+ this.orderSubject = new Subject();
674
+ }
675
+ getOrder(id) {
676
+ this.angularFirestore
677
+ .doc(`${this.orderRepository.collectionName}/${id}`)
678
+ .valueChanges()
679
+ .pipe(map((doc) => Order.toInstance(doc)))
680
+ .subscribe((doc) => this.orderSubject.next(doc));
681
+ return this.orderSubject;
682
+ }
683
+ }
684
+ 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 });
685
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
686
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
687
+ type: Injectable
688
+ }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
689
+ type: Inject,
690
+ args: ['OrderRepository']
705
691
  }] }]; } });
706
692
 
707
- class ShippingService {
708
- constructor(http, apiUrl, homeService) {
709
- this.http = http;
710
- this.apiUrl = apiUrl;
711
- this.homeService = homeService;
712
- }
713
- getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
714
- return combineLatest([
715
- this.homeService.getHomeData(),
716
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
717
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
718
- let shippingMethods = shippingMethodsResponse.result;
719
- if (!shippingMethods.length)
720
- return [];
721
- shippingMethods = shippingMethods.map((s) => {
722
- if (s.ShippingCompanyName == 'Same Day EG')
723
- s.ShippingCompanyName = 'Same Day';
724
- else
725
- return s;
726
- });
727
- const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
728
- if (this.isHolidays(datasSameDayNotAvaliable)) {
729
- shippingMethods = shippingMethods.filter((method) => method.ShippingCompanyName !== 'Same Day');
730
- }
731
- if (totalPrice >= 200) {
732
- shippingMethods = shippingMethods.map((s) => {
733
- if (s.serviceName !== 'Same Day')
734
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
735
- else
736
- return s;
737
- });
738
- }
739
- if (shop == Shops.GLAMSHOP)
740
- return shippingMethods;
741
- if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
742
- shippingMethods = shippingMethods.map((s) => {
743
- if (s.serviceName == 'Same Day')
744
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
745
- else
746
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
747
- });
748
- }
749
- if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
750
- shippingMethods = shippingMethods.map((s) => {
751
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
752
- });
753
- }
754
- return shippingMethods;
755
- }));
756
- }
757
- isFreeShippingBySubscription(shop, subscriptionPlan) {
758
- if (!subscriptionPlan)
759
- return false;
760
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
761
- return true;
762
- }
763
- return false;
764
- }
765
- isHalfShippingBySubscription(shop, subscriptionPlan) {
766
- if (!subscriptionPlan)
767
- return false;
768
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
769
- return true;
770
- }
771
- return false;
772
- }
773
- isHolidays(datas) {
774
- const today = new Date();
775
- for (const key in datas) {
776
- let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
777
- let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
778
- if (start > end)
779
- end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
780
- if (today >= start && today <= end)
781
- return true;
782
- }
783
- return false;
784
- }
785
- }
786
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
787
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
788
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
789
- type: Injectable
790
- }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
791
- type: Inject,
792
- args: [BACKEND_URL]
693
+ class ShippingService {
694
+ constructor(http, apiUrl, homeService) {
695
+ this.http = http;
696
+ this.apiUrl = apiUrl;
697
+ this.homeService = homeService;
698
+ }
699
+ getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
700
+ return combineLatest([
701
+ this.homeService.getHomeData(),
702
+ this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
703
+ ]).pipe(map(([datas, shippingMethodsResponse]) => {
704
+ let shippingMethods = shippingMethodsResponse.result;
705
+ if (!shippingMethods.length)
706
+ return [];
707
+ shippingMethods = shippingMethods.map((s) => {
708
+ if (s.ShippingCompanyName == 'Same Day EG')
709
+ s.ShippingCompanyName = 'Same Day';
710
+ else
711
+ return s;
712
+ });
713
+ const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
714
+ if (this.isHolidays(datasSameDayNotAvaliable)) {
715
+ shippingMethods = shippingMethods.filter((method) => method.ShippingCompanyName !== 'Same Day');
716
+ }
717
+ if (totalPrice >= 200) {
718
+ shippingMethods = shippingMethods.map((s) => {
719
+ if (s.serviceName !== 'Same Day')
720
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
721
+ else
722
+ return s;
723
+ });
724
+ }
725
+ if (shop == Shops.GLAMSHOP)
726
+ return shippingMethods;
727
+ if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
728
+ shippingMethods = shippingMethods.map((s) => {
729
+ if (s.serviceName == 'Same Day')
730
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
731
+ else
732
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
733
+ });
734
+ }
735
+ if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
736
+ shippingMethods = shippingMethods.map((s) => {
737
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
738
+ });
739
+ }
740
+ return shippingMethods;
741
+ }));
742
+ }
743
+ isFreeShippingBySubscription(shop, subscriptionPlan) {
744
+ if (!subscriptionPlan)
745
+ return false;
746
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
747
+ return true;
748
+ }
749
+ return false;
750
+ }
751
+ isHalfShippingBySubscription(shop, subscriptionPlan) {
752
+ if (!subscriptionPlan)
753
+ return false;
754
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
755
+ return true;
756
+ }
757
+ return false;
758
+ }
759
+ isHolidays(datas) {
760
+ const today = new Date();
761
+ for (const key in datas) {
762
+ let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
763
+ let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
764
+ if (start > end)
765
+ end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
766
+ if (today >= start && today <= end)
767
+ return true;
768
+ }
769
+ return false;
770
+ }
771
+ }
772
+ ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
773
+ ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
774
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
775
+ type: Injectable
776
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
777
+ type: Inject,
778
+ args: [BACKEND_URL]
793
779
  }] }, { type: HomeShopService }]; } });
794
780
 
795
- class AngularFirebaseAuthModule {
796
- static initializeApp(options, nameOrConfig) {
797
- return {
798
- ngModule: AngularFirebaseAuthModule,
799
- providers: [
800
- { provide: FIREBASE_OPTIONS, useValue: options },
801
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
802
- ],
803
- };
804
- }
805
- }
806
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
807
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
808
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
809
- {
810
- provide: 'Authentication',
811
- useFactory: (authenticationService, userRepository) => {
812
- return new Authentication(authenticationService, userRepository);
813
- },
814
- deps: ['AuthenticationService', 'UserRepository'],
815
- },
816
- {
817
- provide: 'AuthenticationService',
818
- useFactory: (angularFireAuth) => {
819
- return new AuthenticationFirebaseAuthService(angularFireAuth);
820
- },
821
- deps: [AngularFireAuth],
822
- },
823
- {
824
- provide: 'Register',
825
- useFactory: (registerService, userRepository) => {
826
- return new Register(registerService, userRepository);
827
- },
828
- deps: ['RegisterService', 'UserRepository'],
829
- },
830
- {
831
- provide: 'RegisterService',
832
- useFactory: (angularFireAuth) => {
833
- return new RegisterFirebaseAuthService(angularFireAuth);
834
- },
835
- deps: [AngularFireAuth],
836
- },
837
- {
838
- provide: 'SignOut',
839
- useFactory: (authenticationService) => {
840
- return new SignOut(authenticationService);
841
- },
842
- deps: ['AuthenticationService'],
843
- },
844
- {
845
- provide: 'RecoveryPassword',
846
- useFactory: (authenticationService) => {
847
- return new RecoveryPassword(authenticationService);
848
- },
849
- deps: ['AuthenticationService'],
850
- },
851
- ], imports: [[AngularFireModule]] });
852
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
853
- type: NgModule,
854
- args: [{
855
- imports: [AngularFireModule],
856
- providers: [
857
- {
858
- provide: 'Authentication',
859
- useFactory: (authenticationService, userRepository) => {
860
- return new Authentication(authenticationService, userRepository);
861
- },
862
- deps: ['AuthenticationService', 'UserRepository'],
863
- },
864
- {
865
- provide: 'AuthenticationService',
866
- useFactory: (angularFireAuth) => {
867
- return new AuthenticationFirebaseAuthService(angularFireAuth);
868
- },
869
- deps: [AngularFireAuth],
870
- },
871
- {
872
- provide: 'Register',
873
- useFactory: (registerService, userRepository) => {
874
- return new Register(registerService, userRepository);
875
- },
876
- deps: ['RegisterService', 'UserRepository'],
877
- },
878
- {
879
- provide: 'RegisterService',
880
- useFactory: (angularFireAuth) => {
881
- return new RegisterFirebaseAuthService(angularFireAuth);
882
- },
883
- deps: [AngularFireAuth],
884
- },
885
- {
886
- provide: 'SignOut',
887
- useFactory: (authenticationService) => {
888
- return new SignOut(authenticationService);
889
- },
890
- deps: ['AuthenticationService'],
891
- },
892
- {
893
- provide: 'RecoveryPassword',
894
- useFactory: (authenticationService) => {
895
- return new RecoveryPassword(authenticationService);
896
- },
897
- deps: ['AuthenticationService'],
898
- },
899
- ],
900
- }]
781
+ class AngularFirebaseAuthModule {
782
+ static initializeApp(options, nameOrConfig) {
783
+ return {
784
+ ngModule: AngularFirebaseAuthModule,
785
+ providers: [
786
+ { provide: FIREBASE_OPTIONS, useValue: options },
787
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
788
+ ],
789
+ };
790
+ }
791
+ }
792
+ AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
793
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
794
+ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
795
+ {
796
+ provide: 'Authentication',
797
+ useFactory: (authenticationService, userRepository) => {
798
+ return new Authentication(authenticationService, userRepository);
799
+ },
800
+ deps: ['AuthenticationService', 'UserRepository'],
801
+ },
802
+ {
803
+ provide: 'AuthenticationService',
804
+ useFactory: (angularFireAuth) => {
805
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
806
+ },
807
+ deps: [AngularFireAuth],
808
+ },
809
+ {
810
+ provide: 'Register',
811
+ useFactory: (registerService, userRepository) => {
812
+ return new Register(registerService, userRepository);
813
+ },
814
+ deps: ['RegisterService', 'UserRepository'],
815
+ },
816
+ {
817
+ provide: 'RegisterService',
818
+ useFactory: (angularFireAuth) => {
819
+ return new RegisterFirebaseAuthService(angularFireAuth);
820
+ },
821
+ deps: [AngularFireAuth],
822
+ },
823
+ {
824
+ provide: 'SignOut',
825
+ useFactory: (authenticationService) => {
826
+ return new SignOut(authenticationService);
827
+ },
828
+ deps: ['AuthenticationService'],
829
+ },
830
+ {
831
+ provide: 'RecoveryPassword',
832
+ useFactory: (authenticationService) => {
833
+ return new RecoveryPassword(authenticationService);
834
+ },
835
+ deps: ['AuthenticationService'],
836
+ },
837
+ ], imports: [[AngularFireModule]] });
838
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
839
+ type: NgModule,
840
+ args: [{
841
+ imports: [AngularFireModule],
842
+ providers: [
843
+ {
844
+ provide: 'Authentication',
845
+ useFactory: (authenticationService, userRepository) => {
846
+ return new Authentication(authenticationService, userRepository);
847
+ },
848
+ deps: ['AuthenticationService', 'UserRepository'],
849
+ },
850
+ {
851
+ provide: 'AuthenticationService',
852
+ useFactory: (angularFireAuth) => {
853
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
854
+ },
855
+ deps: [AngularFireAuth],
856
+ },
857
+ {
858
+ provide: 'Register',
859
+ useFactory: (registerService, userRepository) => {
860
+ return new Register(registerService, userRepository);
861
+ },
862
+ deps: ['RegisterService', 'UserRepository'],
863
+ },
864
+ {
865
+ provide: 'RegisterService',
866
+ useFactory: (angularFireAuth) => {
867
+ return new RegisterFirebaseAuthService(angularFireAuth);
868
+ },
869
+ deps: [AngularFireAuth],
870
+ },
871
+ {
872
+ provide: 'SignOut',
873
+ useFactory: (authenticationService) => {
874
+ return new SignOut(authenticationService);
875
+ },
876
+ deps: ['AuthenticationService'],
877
+ },
878
+ {
879
+ provide: 'RecoveryPassword',
880
+ useFactory: (authenticationService) => {
881
+ return new RecoveryPassword(authenticationService);
882
+ },
883
+ deps: ['AuthenticationService'],
884
+ },
885
+ ],
886
+ }]
901
887
  }] });
902
888
 
903
- class AngularElasticSeachModule {
904
- static initializeApp(options) {
905
- return {
906
- ngModule: AngularElasticSeachModule,
907
- providers: [{ provide: ES_CONFIG, useValue: options }],
908
- };
909
- }
910
- }
911
- AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
912
- AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
913
- AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
914
- {
915
- provide: ProductsIndex,
916
- useFactory: (configuration) => {
917
- return new ProductsIndex(new AxiosAdapter(configuration));
918
- },
919
- deps: [ES_CONFIG],
920
- },
921
- ] });
922
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
923
- type: NgModule,
924
- args: [{
925
- providers: [
926
- {
927
- provide: ProductsIndex,
928
- useFactory: (configuration) => {
929
- return new ProductsIndex(new AxiosAdapter(configuration));
930
- },
931
- deps: [ES_CONFIG],
932
- },
933
- ],
934
- }]
889
+ class AngularElasticSeachModule {
890
+ static initializeApp(options) {
891
+ return {
892
+ ngModule: AngularElasticSeachModule,
893
+ providers: [{ provide: ES_CONFIG, useValue: options }],
894
+ };
895
+ }
896
+ }
897
+ AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
898
+ AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
899
+ AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
900
+ {
901
+ provide: ProductsIndex,
902
+ useFactory: (configuration) => {
903
+ return new ProductsIndex(new AxiosAdapter(configuration));
904
+ },
905
+ deps: [ES_CONFIG],
906
+ },
907
+ ] });
908
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
909
+ type: NgModule,
910
+ args: [{
911
+ providers: [
912
+ {
913
+ provide: ProductsIndex,
914
+ useFactory: (configuration) => {
915
+ return new ProductsIndex(new AxiosAdapter(configuration));
916
+ },
917
+ deps: [ES_CONFIG],
918
+ },
919
+ ],
920
+ }]
935
921
  }] });
936
922
 
937
- class AngularFirestoreModule {
938
- static initializeApp(options, nameOrConfig) {
939
- return {
940
- ngModule: AngularFirestoreModule,
941
- providers: [
942
- { provide: FIREBASE_OPTIONS, useValue: options.firebase },
943
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
944
- { provide: ES_CONFIG, useValue: options.elasticSearch },
945
- ],
946
- };
947
- }
948
- }
949
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
950
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
951
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
952
- {
953
- provide: 'BeautyProfileRepository',
954
- useFactory: (firestore, userRepository) => {
955
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
956
- },
957
- deps: [AngularFirestore, 'UserRepository'],
958
- },
959
- {
960
- provide: 'Buy2WinRepository',
961
- useFactory: (firestore) => {
962
- return new Buy2WinFirestoreRepository(firestore.firestore);
963
- },
964
- deps: [AngularFirestore],
965
- },
966
- {
967
- provide: CategoryFirestoreRepository,
968
- useFactory: (firestore) => {
969
- return new CategoryFirestoreRepository(firestore.firestore);
970
- },
971
- deps: [AngularFirestore],
972
- },
973
- {
974
- provide: 'CheckoutRepository',
975
- useFactory: (firestore) => {
976
- return new CheckoutFirestoreRepository(firestore.firestore);
977
- },
978
- deps: [AngularFirestore],
979
- },
980
- {
981
- provide: 'CheckoutSubscriptionRepository',
982
- useFactory: (firestore) => {
983
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
984
- },
985
- deps: [AngularFirestore],
986
- },
987
- {
988
- provide: 'CouponRepository',
989
- useFactory: (firestore) => {
990
- return new CouponFirestoreRepository(firestore.firestore);
991
- },
992
- deps: [AngularFirestore],
993
- },
994
- {
995
- provide: 'EditionRepository',
996
- useFactory: (firestore, subscriptionRepository) => {
997
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
998
- },
999
- deps: [AngularFirestore, 'SubscriptionRepository'],
1000
- },
1001
- {
1002
- provide: 'HomeRepository',
1003
- useFactory: (firestore) => {
1004
- return new HomeFirestoreRepository(firestore.firestore);
1005
- },
1006
- deps: [AngularFirestore],
1007
- },
1008
- {
1009
- provide: 'LeadRepository',
1010
- useFactory: (firestore) => {
1011
- return new LeadFirestoreRepository(firestore.firestore);
1012
- },
1013
- deps: [AngularFirestore],
1014
- },
1015
- {
1016
- provide: 'LegacyOrderRepository',
1017
- useFactory: (firestore) => {
1018
- return new LegacyOrderFirestoreRepository(firestore.firestore);
1019
- },
1020
- deps: [AngularFirestore],
1021
- },
1022
- {
1023
- provide: 'ShopMenuRepository',
1024
- useFactory: (firestore) => {
1025
- return new ShopMenuFirestoreRepository(firestore.firestore);
1026
- },
1027
- deps: [AngularFirestore],
1028
- },
1029
- {
1030
- provide: 'OrderRepository',
1031
- useFactory: (firestore) => {
1032
- return new OrderFirestoreRepository(firestore.firestore);
1033
- },
1034
- deps: [AngularFirestore],
1035
- },
1036
- {
1037
- provide: 'PaymentRepository',
1038
- useFactory: (firestore) => {
1039
- return new PaymentFirestoreRepository(firestore.firestore);
1040
- },
1041
- deps: [AngularFirestore],
1042
- },
1043
- {
1044
- provide: ProductFirestoreRepository,
1045
- useFactory: (firestore) => {
1046
- return new ProductFirestoreRepository(firestore.firestore);
1047
- },
1048
- deps: [AngularFirestore],
1049
- },
1050
- {
1051
- provide: 'SubscriptionPaymentRepository',
1052
- useFactory: (firestore, subscriptionRepository) => {
1053
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1054
- },
1055
- deps: [AngularFirestore, 'SubscriptionRepository'],
1056
- },
1057
- {
1058
- provide: 'SubscriptionPlanRepository',
1059
- useFactory: (firestore) => {
1060
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1061
- },
1062
- deps: [AngularFirestore],
1063
- },
1064
- {
1065
- provide: 'SubscriptionProductRepository',
1066
- useFactory: (firestore) => {
1067
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
1068
- },
1069
- deps: [AngularFirestore],
1070
- },
1071
- {
1072
- provide: 'SubscriptionRepository',
1073
- useFactory: (firestore) => {
1074
- return new SubscriptionFirestoreRepository(firestore.firestore);
1075
- },
1076
- deps: [AngularFirestore],
1077
- },
1078
- {
1079
- provide: 'UserRepository',
1080
- useFactory: (firestore) => {
1081
- return new UserFirestoreRepository(firestore.firestore);
1082
- },
1083
- deps: [AngularFirestore],
1084
- },
1085
- {
1086
- provide: 'UserAddressRepository',
1087
- useFactory: (firestore, userRepository) => {
1088
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1089
- },
1090
- deps: [AngularFirestore, 'UserRepository'],
1091
- },
1092
- {
1093
- provide: 'UserPaymentMethodRepository',
1094
- useFactory: (firestore, userRepository) => {
1095
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1096
- },
1097
- deps: [AngularFirestore, 'UserRepository'],
1098
- },
1099
- {
1100
- provide: ProductVariantFirestoreRepository,
1101
- useFactory: (firestore, productRepository) => {
1102
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1103
- },
1104
- deps: [AngularFirestore, ProductFirestoreRepository],
1105
- },
1106
- {
1107
- provide: APP_INITIALIZER,
1108
- useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1109
- deps: [AngularFirestore],
1110
- multi: true,
1111
- },
1112
- ], imports: [[AngularFireModule, AngularElasticSeachModule]] });
1113
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
1114
- type: NgModule,
1115
- args: [{
1116
- imports: [AngularFireModule, AngularElasticSeachModule],
1117
- providers: [
1118
- {
1119
- provide: 'BeautyProfileRepository',
1120
- useFactory: (firestore, userRepository) => {
1121
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1122
- },
1123
- deps: [AngularFirestore, 'UserRepository'],
1124
- },
1125
- {
1126
- provide: 'Buy2WinRepository',
1127
- useFactory: (firestore) => {
1128
- return new Buy2WinFirestoreRepository(firestore.firestore);
1129
- },
1130
- deps: [AngularFirestore],
1131
- },
1132
- {
1133
- provide: CategoryFirestoreRepository,
1134
- useFactory: (firestore) => {
1135
- return new CategoryFirestoreRepository(firestore.firestore);
1136
- },
1137
- deps: [AngularFirestore],
1138
- },
1139
- {
1140
- provide: 'CheckoutRepository',
1141
- useFactory: (firestore) => {
1142
- return new CheckoutFirestoreRepository(firestore.firestore);
1143
- },
1144
- deps: [AngularFirestore],
1145
- },
1146
- {
1147
- provide: 'CheckoutSubscriptionRepository',
1148
- useFactory: (firestore) => {
1149
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1150
- },
1151
- deps: [AngularFirestore],
1152
- },
1153
- {
1154
- provide: 'CouponRepository',
1155
- useFactory: (firestore) => {
1156
- return new CouponFirestoreRepository(firestore.firestore);
1157
- },
1158
- deps: [AngularFirestore],
1159
- },
1160
- {
1161
- provide: 'EditionRepository',
1162
- useFactory: (firestore, subscriptionRepository) => {
1163
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1164
- },
1165
- deps: [AngularFirestore, 'SubscriptionRepository'],
1166
- },
1167
- {
1168
- provide: 'HomeRepository',
1169
- useFactory: (firestore) => {
1170
- return new HomeFirestoreRepository(firestore.firestore);
1171
- },
1172
- deps: [AngularFirestore],
1173
- },
1174
- {
1175
- provide: 'LeadRepository',
1176
- useFactory: (firestore) => {
1177
- return new LeadFirestoreRepository(firestore.firestore);
1178
- },
1179
- deps: [AngularFirestore],
1180
- },
1181
- {
1182
- provide: 'LegacyOrderRepository',
1183
- useFactory: (firestore) => {
1184
- return new LegacyOrderFirestoreRepository(firestore.firestore);
1185
- },
1186
- deps: [AngularFirestore],
1187
- },
1188
- {
1189
- provide: 'ShopMenuRepository',
1190
- useFactory: (firestore) => {
1191
- return new ShopMenuFirestoreRepository(firestore.firestore);
1192
- },
1193
- deps: [AngularFirestore],
1194
- },
1195
- {
1196
- provide: 'OrderRepository',
1197
- useFactory: (firestore) => {
1198
- return new OrderFirestoreRepository(firestore.firestore);
1199
- },
1200
- deps: [AngularFirestore],
1201
- },
1202
- {
1203
- provide: 'PaymentRepository',
1204
- useFactory: (firestore) => {
1205
- return new PaymentFirestoreRepository(firestore.firestore);
1206
- },
1207
- deps: [AngularFirestore],
1208
- },
1209
- {
1210
- provide: ProductFirestoreRepository,
1211
- useFactory: (firestore) => {
1212
- return new ProductFirestoreRepository(firestore.firestore);
1213
- },
1214
- deps: [AngularFirestore],
1215
- },
1216
- {
1217
- provide: 'SubscriptionPaymentRepository',
1218
- useFactory: (firestore, subscriptionRepository) => {
1219
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1220
- },
1221
- deps: [AngularFirestore, 'SubscriptionRepository'],
1222
- },
1223
- {
1224
- provide: 'SubscriptionPlanRepository',
1225
- useFactory: (firestore) => {
1226
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1227
- },
1228
- deps: [AngularFirestore],
1229
- },
1230
- {
1231
- provide: 'SubscriptionProductRepository',
1232
- useFactory: (firestore) => {
1233
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
1234
- },
1235
- deps: [AngularFirestore],
1236
- },
1237
- {
1238
- provide: 'SubscriptionRepository',
1239
- useFactory: (firestore) => {
1240
- return new SubscriptionFirestoreRepository(firestore.firestore);
1241
- },
1242
- deps: [AngularFirestore],
1243
- },
1244
- {
1245
- provide: 'UserRepository',
1246
- useFactory: (firestore) => {
1247
- return new UserFirestoreRepository(firestore.firestore);
1248
- },
1249
- deps: [AngularFirestore],
1250
- },
1251
- {
1252
- provide: 'UserAddressRepository',
1253
- useFactory: (firestore, userRepository) => {
1254
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1255
- },
1256
- deps: [AngularFirestore, 'UserRepository'],
1257
- },
1258
- {
1259
- provide: 'UserPaymentMethodRepository',
1260
- useFactory: (firestore, userRepository) => {
1261
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1262
- },
1263
- deps: [AngularFirestore, 'UserRepository'],
1264
- },
1265
- {
1266
- provide: ProductVariantFirestoreRepository,
1267
- useFactory: (firestore, productRepository) => {
1268
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1269
- },
1270
- deps: [AngularFirestore, ProductFirestoreRepository],
1271
- },
1272
- {
1273
- provide: APP_INITIALIZER,
1274
- useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1275
- deps: [AngularFirestore],
1276
- multi: true,
1277
- },
1278
- ],
1279
- }]
923
+ class AngularFirestoreModule {
924
+ static initializeApp(options, nameOrConfig) {
925
+ return {
926
+ ngModule: AngularFirestoreModule,
927
+ providers: [
928
+ { provide: FIREBASE_OPTIONS, useValue: options.firebase },
929
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
930
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
931
+ ],
932
+ };
933
+ }
934
+ }
935
+ AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
936
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
937
+ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
938
+ {
939
+ provide: 'BeautyProfileRepository',
940
+ useFactory: (firestore, userRepository) => {
941
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
942
+ },
943
+ deps: [AngularFirestore, 'UserRepository'],
944
+ },
945
+ {
946
+ provide: 'Buy2WinRepository',
947
+ useFactory: (firestore) => {
948
+ return new Buy2WinFirestoreRepository(firestore.firestore);
949
+ },
950
+ deps: [AngularFirestore],
951
+ },
952
+ {
953
+ provide: CategoryFirestoreRepository,
954
+ useFactory: (firestore) => {
955
+ return new CategoryFirestoreRepository(firestore.firestore);
956
+ },
957
+ deps: [AngularFirestore],
958
+ },
959
+ {
960
+ provide: 'CheckoutRepository',
961
+ useFactory: (firestore) => {
962
+ return new CheckoutFirestoreRepository(firestore.firestore);
963
+ },
964
+ deps: [AngularFirestore],
965
+ },
966
+ {
967
+ provide: 'CheckoutSubscriptionRepository',
968
+ useFactory: (firestore) => {
969
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
970
+ },
971
+ deps: [AngularFirestore],
972
+ },
973
+ {
974
+ provide: 'CouponRepository',
975
+ useFactory: (firestore) => {
976
+ return new CouponFirestoreRepository(firestore.firestore);
977
+ },
978
+ deps: [AngularFirestore],
979
+ },
980
+ {
981
+ provide: 'EditionRepository',
982
+ useFactory: (firestore, subscriptionRepository) => {
983
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
984
+ },
985
+ deps: [AngularFirestore, 'SubscriptionRepository'],
986
+ },
987
+ {
988
+ provide: 'HomeRepository',
989
+ useFactory: (firestore) => {
990
+ return new HomeFirestoreRepository(firestore.firestore);
991
+ },
992
+ deps: [AngularFirestore],
993
+ },
994
+ {
995
+ provide: 'LeadRepository',
996
+ useFactory: (firestore) => {
997
+ return new LeadFirestoreRepository(firestore.firestore);
998
+ },
999
+ deps: [AngularFirestore],
1000
+ },
1001
+ {
1002
+ provide: 'LegacyOrderRepository',
1003
+ useFactory: (firestore) => {
1004
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
1005
+ },
1006
+ deps: [AngularFirestore],
1007
+ },
1008
+ {
1009
+ provide: 'ShopMenuRepository',
1010
+ useFactory: (firestore) => {
1011
+ return new ShopMenuFirestoreRepository(firestore.firestore);
1012
+ },
1013
+ deps: [AngularFirestore],
1014
+ },
1015
+ {
1016
+ provide: 'OrderRepository',
1017
+ useFactory: (firestore) => {
1018
+ return new OrderFirestoreRepository(firestore.firestore);
1019
+ },
1020
+ deps: [AngularFirestore],
1021
+ },
1022
+ {
1023
+ provide: 'PaymentRepository',
1024
+ useFactory: (firestore) => {
1025
+ return new PaymentFirestoreRepository(firestore.firestore);
1026
+ },
1027
+ deps: [AngularFirestore],
1028
+ },
1029
+ {
1030
+ provide: ProductFirestoreRepository,
1031
+ useFactory: (firestore) => {
1032
+ return new ProductFirestoreRepository(firestore.firestore);
1033
+ },
1034
+ deps: [AngularFirestore],
1035
+ },
1036
+ {
1037
+ provide: 'SubscriptionPaymentRepository',
1038
+ useFactory: (firestore, subscriptionRepository) => {
1039
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1040
+ },
1041
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1042
+ },
1043
+ {
1044
+ provide: 'SubscriptionPlanRepository',
1045
+ useFactory: (firestore) => {
1046
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1047
+ },
1048
+ deps: [AngularFirestore],
1049
+ },
1050
+ {
1051
+ provide: 'SubscriptionProductRepository',
1052
+ useFactory: (firestore) => {
1053
+ return new SubscriptionProductFirestoreRepository(firestore.firestore);
1054
+ },
1055
+ deps: [AngularFirestore],
1056
+ },
1057
+ {
1058
+ provide: 'SubscriptionRepository',
1059
+ useFactory: (firestore) => {
1060
+ return new SubscriptionFirestoreRepository(firestore.firestore);
1061
+ },
1062
+ deps: [AngularFirestore],
1063
+ },
1064
+ {
1065
+ provide: 'UserRepository',
1066
+ useFactory: (firestore) => {
1067
+ return new UserFirestoreRepository(firestore.firestore);
1068
+ },
1069
+ deps: [AngularFirestore],
1070
+ },
1071
+ {
1072
+ provide: 'UserAddressRepository',
1073
+ useFactory: (firestore, userRepository) => {
1074
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1075
+ },
1076
+ deps: [AngularFirestore, 'UserRepository'],
1077
+ },
1078
+ {
1079
+ provide: 'UserPaymentMethodRepository',
1080
+ useFactory: (firestore, userRepository) => {
1081
+ return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1082
+ },
1083
+ deps: [AngularFirestore, 'UserRepository'],
1084
+ },
1085
+ {
1086
+ provide: ProductVariantFirestoreRepository,
1087
+ useFactory: (firestore, productRepository) => {
1088
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1089
+ },
1090
+ deps: [AngularFirestore, ProductFirestoreRepository],
1091
+ },
1092
+ {
1093
+ provide: APP_INITIALIZER,
1094
+ useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1095
+ deps: [AngularFirestore],
1096
+ multi: true,
1097
+ },
1098
+ ], imports: [[AngularFireModule, AngularElasticSeachModule]] });
1099
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
1100
+ type: NgModule,
1101
+ args: [{
1102
+ imports: [AngularFireModule, AngularElasticSeachModule],
1103
+ providers: [
1104
+ {
1105
+ provide: 'BeautyProfileRepository',
1106
+ useFactory: (firestore, userRepository) => {
1107
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1108
+ },
1109
+ deps: [AngularFirestore, 'UserRepository'],
1110
+ },
1111
+ {
1112
+ provide: 'Buy2WinRepository',
1113
+ useFactory: (firestore) => {
1114
+ return new Buy2WinFirestoreRepository(firestore.firestore);
1115
+ },
1116
+ deps: [AngularFirestore],
1117
+ },
1118
+ {
1119
+ provide: CategoryFirestoreRepository,
1120
+ useFactory: (firestore) => {
1121
+ return new CategoryFirestoreRepository(firestore.firestore);
1122
+ },
1123
+ deps: [AngularFirestore],
1124
+ },
1125
+ {
1126
+ provide: 'CheckoutRepository',
1127
+ useFactory: (firestore) => {
1128
+ return new CheckoutFirestoreRepository(firestore.firestore);
1129
+ },
1130
+ deps: [AngularFirestore],
1131
+ },
1132
+ {
1133
+ provide: 'CheckoutSubscriptionRepository',
1134
+ useFactory: (firestore) => {
1135
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1136
+ },
1137
+ deps: [AngularFirestore],
1138
+ },
1139
+ {
1140
+ provide: 'CouponRepository',
1141
+ useFactory: (firestore) => {
1142
+ return new CouponFirestoreRepository(firestore.firestore);
1143
+ },
1144
+ deps: [AngularFirestore],
1145
+ },
1146
+ {
1147
+ provide: 'EditionRepository',
1148
+ useFactory: (firestore, subscriptionRepository) => {
1149
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1150
+ },
1151
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1152
+ },
1153
+ {
1154
+ provide: 'HomeRepository',
1155
+ useFactory: (firestore) => {
1156
+ return new HomeFirestoreRepository(firestore.firestore);
1157
+ },
1158
+ deps: [AngularFirestore],
1159
+ },
1160
+ {
1161
+ provide: 'LeadRepository',
1162
+ useFactory: (firestore) => {
1163
+ return new LeadFirestoreRepository(firestore.firestore);
1164
+ },
1165
+ deps: [AngularFirestore],
1166
+ },
1167
+ {
1168
+ provide: 'LegacyOrderRepository',
1169
+ useFactory: (firestore) => {
1170
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
1171
+ },
1172
+ deps: [AngularFirestore],
1173
+ },
1174
+ {
1175
+ provide: 'ShopMenuRepository',
1176
+ useFactory: (firestore) => {
1177
+ return new ShopMenuFirestoreRepository(firestore.firestore);
1178
+ },
1179
+ deps: [AngularFirestore],
1180
+ },
1181
+ {
1182
+ provide: 'OrderRepository',
1183
+ useFactory: (firestore) => {
1184
+ return new OrderFirestoreRepository(firestore.firestore);
1185
+ },
1186
+ deps: [AngularFirestore],
1187
+ },
1188
+ {
1189
+ provide: 'PaymentRepository',
1190
+ useFactory: (firestore) => {
1191
+ return new PaymentFirestoreRepository(firestore.firestore);
1192
+ },
1193
+ deps: [AngularFirestore],
1194
+ },
1195
+ {
1196
+ provide: ProductFirestoreRepository,
1197
+ useFactory: (firestore) => {
1198
+ return new ProductFirestoreRepository(firestore.firestore);
1199
+ },
1200
+ deps: [AngularFirestore],
1201
+ },
1202
+ {
1203
+ provide: 'SubscriptionPaymentRepository',
1204
+ useFactory: (firestore, subscriptionRepository) => {
1205
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1206
+ },
1207
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1208
+ },
1209
+ {
1210
+ provide: 'SubscriptionPlanRepository',
1211
+ useFactory: (firestore) => {
1212
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1213
+ },
1214
+ deps: [AngularFirestore],
1215
+ },
1216
+ {
1217
+ provide: 'SubscriptionProductRepository',
1218
+ useFactory: (firestore) => {
1219
+ return new SubscriptionProductFirestoreRepository(firestore.firestore);
1220
+ },
1221
+ deps: [AngularFirestore],
1222
+ },
1223
+ {
1224
+ provide: 'SubscriptionRepository',
1225
+ useFactory: (firestore) => {
1226
+ return new SubscriptionFirestoreRepository(firestore.firestore);
1227
+ },
1228
+ deps: [AngularFirestore],
1229
+ },
1230
+ {
1231
+ provide: 'UserRepository',
1232
+ useFactory: (firestore) => {
1233
+ return new UserFirestoreRepository(firestore.firestore);
1234
+ },
1235
+ deps: [AngularFirestore],
1236
+ },
1237
+ {
1238
+ provide: 'UserAddressRepository',
1239
+ useFactory: (firestore, userRepository) => {
1240
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1241
+ },
1242
+ deps: [AngularFirestore, 'UserRepository'],
1243
+ },
1244
+ {
1245
+ provide: 'UserPaymentMethodRepository',
1246
+ useFactory: (firestore, userRepository) => {
1247
+ return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1248
+ },
1249
+ deps: [AngularFirestore, 'UserRepository'],
1250
+ },
1251
+ {
1252
+ provide: ProductVariantFirestoreRepository,
1253
+ useFactory: (firestore, productRepository) => {
1254
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1255
+ },
1256
+ deps: [AngularFirestore, ProductFirestoreRepository],
1257
+ },
1258
+ {
1259
+ provide: APP_INITIALIZER,
1260
+ useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1261
+ deps: [AngularFirestore],
1262
+ multi: true,
1263
+ },
1264
+ ],
1265
+ }]
1280
1266
  }] });
1281
1267
 
1282
- class AngularHasuraGraphQLModule {
1283
- static initializeApp(options) {
1284
- return {
1285
- ngModule: AngularHasuraGraphQLModule,
1286
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1287
- };
1288
- }
1289
- }
1290
- AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1291
- AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
1292
- AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
1293
- {
1294
- provide: 'CategoryRepository',
1295
- useExisting: CategoryHasuraGraphQLRepository,
1296
- },
1297
- {
1298
- provide: CategoryHasuraGraphQLRepository,
1299
- useFactory: (options, productRepository, categoryFilterRepository) => {
1300
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1301
- },
1302
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1303
- },
1304
- {
1305
- provide: 'ProductRepository',
1306
- useExisting: ProductHasuraGraphQLRepository,
1307
- },
1308
- {
1309
- provide: ProductHasuraGraphQLRepository,
1310
- useFactory: (options) => {
1311
- return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1312
- },
1313
- deps: [HASURA_OPTIONS],
1314
- },
1315
- {
1316
- provide: 'VariantRepository',
1317
- useExisting: VariantHasuraGraphQLRepository,
1318
- },
1319
- {
1320
- provide: VariantHasuraGraphQLRepository,
1321
- useFactory: (options) => {
1322
- return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1323
- },
1324
- deps: [HASURA_OPTIONS],
1325
- },
1326
- {
1327
- provide: 'CategoryFilterRepository',
1328
- useExisting: CategoryFilterHasuraGraphQLRepository,
1329
- },
1330
- {
1331
- provide: CategoryFilterHasuraGraphQLRepository,
1332
- useFactory: (options) => {
1333
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1334
- },
1335
- deps: [HASURA_OPTIONS],
1336
- },
1337
- {
1338
- provide: 'FilterOptionRepository',
1339
- useExisting: FilterOptionHasuraGraphQLRepository,
1340
- },
1341
- {
1342
- provide: FilterOptionHasuraGraphQLRepository,
1343
- useFactory: (options) => {
1344
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1345
- },
1346
- deps: [HASURA_OPTIONS],
1347
- },
1348
- {
1349
- provide: 'FilterRepository',
1350
- useExisting: FilterHasuraGraphQLRepository,
1351
- },
1352
- {
1353
- provide: FilterHasuraGraphQLRepository,
1354
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1355
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1356
- },
1357
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1358
- },
1359
- ] });
1360
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1361
- type: NgModule,
1362
- args: [{
1363
- providers: [
1364
- {
1365
- provide: 'CategoryRepository',
1366
- useExisting: CategoryHasuraGraphQLRepository,
1367
- },
1368
- {
1369
- provide: CategoryHasuraGraphQLRepository,
1370
- useFactory: (options, productRepository, categoryFilterRepository) => {
1371
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1372
- },
1373
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1374
- },
1375
- {
1376
- provide: 'ProductRepository',
1377
- useExisting: ProductHasuraGraphQLRepository,
1378
- },
1379
- {
1380
- provide: ProductHasuraGraphQLRepository,
1381
- useFactory: (options) => {
1382
- return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1383
- },
1384
- deps: [HASURA_OPTIONS],
1385
- },
1386
- {
1387
- provide: 'VariantRepository',
1388
- useExisting: VariantHasuraGraphQLRepository,
1389
- },
1390
- {
1391
- provide: VariantHasuraGraphQLRepository,
1392
- useFactory: (options) => {
1393
- return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1394
- },
1395
- deps: [HASURA_OPTIONS],
1396
- },
1397
- {
1398
- provide: 'CategoryFilterRepository',
1399
- useExisting: CategoryFilterHasuraGraphQLRepository,
1400
- },
1401
- {
1402
- provide: CategoryFilterHasuraGraphQLRepository,
1403
- useFactory: (options) => {
1404
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1405
- },
1406
- deps: [HASURA_OPTIONS],
1407
- },
1408
- {
1409
- provide: 'FilterOptionRepository',
1410
- useExisting: FilterOptionHasuraGraphQLRepository,
1411
- },
1412
- {
1413
- provide: FilterOptionHasuraGraphQLRepository,
1414
- useFactory: (options) => {
1415
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1416
- },
1417
- deps: [HASURA_OPTIONS],
1418
- },
1419
- {
1420
- provide: 'FilterRepository',
1421
- useExisting: FilterHasuraGraphQLRepository,
1422
- },
1423
- {
1424
- provide: FilterHasuraGraphQLRepository,
1425
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1426
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1427
- },
1428
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1429
- },
1430
- ],
1431
- }]
1268
+ class AngularHasuraGraphQLModule {
1269
+ static initializeApp(options) {
1270
+ return {
1271
+ ngModule: AngularHasuraGraphQLModule,
1272
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1273
+ };
1274
+ }
1275
+ }
1276
+ AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1277
+ AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
1278
+ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
1279
+ {
1280
+ provide: 'CategoryRepository',
1281
+ useExisting: CategoryHasuraGraphQLRepository,
1282
+ },
1283
+ {
1284
+ provide: CategoryHasuraGraphQLRepository,
1285
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1286
+ return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1287
+ },
1288
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1289
+ },
1290
+ {
1291
+ provide: 'ProductRepository',
1292
+ useExisting: ProductHasuraGraphQLRepository,
1293
+ },
1294
+ {
1295
+ provide: ProductHasuraGraphQLRepository,
1296
+ useFactory: (options) => {
1297
+ return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1298
+ },
1299
+ deps: [HASURA_OPTIONS],
1300
+ },
1301
+ {
1302
+ provide: 'VariantRepository',
1303
+ useExisting: VariantHasuraGraphQLRepository,
1304
+ },
1305
+ {
1306
+ provide: VariantHasuraGraphQLRepository,
1307
+ useFactory: (options) => {
1308
+ return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1309
+ },
1310
+ deps: [HASURA_OPTIONS],
1311
+ },
1312
+ {
1313
+ provide: 'CategoryFilterRepository',
1314
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1315
+ },
1316
+ {
1317
+ provide: CategoryFilterHasuraGraphQLRepository,
1318
+ useFactory: (options) => {
1319
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1320
+ },
1321
+ deps: [HASURA_OPTIONS],
1322
+ },
1323
+ {
1324
+ provide: 'FilterOptionRepository',
1325
+ useExisting: FilterOptionHasuraGraphQLRepository,
1326
+ },
1327
+ {
1328
+ provide: FilterOptionHasuraGraphQLRepository,
1329
+ useFactory: (options) => {
1330
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1331
+ },
1332
+ deps: [HASURA_OPTIONS],
1333
+ },
1334
+ {
1335
+ provide: 'FilterRepository',
1336
+ useExisting: FilterHasuraGraphQLRepository,
1337
+ },
1338
+ {
1339
+ provide: FilterHasuraGraphQLRepository,
1340
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1341
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1342
+ },
1343
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1344
+ },
1345
+ ] });
1346
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1347
+ type: NgModule,
1348
+ args: [{
1349
+ providers: [
1350
+ {
1351
+ provide: 'CategoryRepository',
1352
+ useExisting: CategoryHasuraGraphQLRepository,
1353
+ },
1354
+ {
1355
+ provide: CategoryHasuraGraphQLRepository,
1356
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1357
+ return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1358
+ },
1359
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1360
+ },
1361
+ {
1362
+ provide: 'ProductRepository',
1363
+ useExisting: ProductHasuraGraphQLRepository,
1364
+ },
1365
+ {
1366
+ provide: ProductHasuraGraphQLRepository,
1367
+ useFactory: (options) => {
1368
+ return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1369
+ },
1370
+ deps: [HASURA_OPTIONS],
1371
+ },
1372
+ {
1373
+ provide: 'VariantRepository',
1374
+ useExisting: VariantHasuraGraphQLRepository,
1375
+ },
1376
+ {
1377
+ provide: VariantHasuraGraphQLRepository,
1378
+ useFactory: (options) => {
1379
+ return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1380
+ },
1381
+ deps: [HASURA_OPTIONS],
1382
+ },
1383
+ {
1384
+ provide: 'CategoryFilterRepository',
1385
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1386
+ },
1387
+ {
1388
+ provide: CategoryFilterHasuraGraphQLRepository,
1389
+ useFactory: (options) => {
1390
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1391
+ },
1392
+ deps: [HASURA_OPTIONS],
1393
+ },
1394
+ {
1395
+ provide: 'FilterOptionRepository',
1396
+ useExisting: FilterOptionHasuraGraphQLRepository,
1397
+ },
1398
+ {
1399
+ provide: FilterOptionHasuraGraphQLRepository,
1400
+ useFactory: (options) => {
1401
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1402
+ },
1403
+ deps: [HASURA_OPTIONS],
1404
+ },
1405
+ {
1406
+ provide: 'FilterRepository',
1407
+ useExisting: FilterHasuraGraphQLRepository,
1408
+ },
1409
+ {
1410
+ provide: FilterHasuraGraphQLRepository,
1411
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1412
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1413
+ },
1414
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1415
+ },
1416
+ ],
1417
+ }]
1432
1418
  }] });
1433
1419
 
1434
- class AngularConnectModule {
1435
- static initializeApp(defaultShop, options, nameOrConfig) {
1436
- return {
1437
- ngModule: AngularConnectModule,
1438
- providers: [
1439
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1440
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1441
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1442
- ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1443
- ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
1444
- ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
1445
- ],
1446
- };
1447
- }
1448
- }
1449
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1450
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1451
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
1452
- AuthService,
1453
- CartService,
1454
- CheckoutService,
1455
- CheckoutSubscriptionService,
1456
- CouponService,
1457
- HomeShopService,
1458
- OrderService,
1459
- ShippingService,
1460
- ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1461
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1462
- type: NgModule,
1463
- args: [{
1464
- imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1465
- providers: [
1466
- AuthService,
1467
- CartService,
1468
- CheckoutService,
1469
- CheckoutSubscriptionService,
1470
- CouponService,
1471
- HomeShopService,
1472
- OrderService,
1473
- ShippingService,
1474
- ],
1475
- }]
1420
+ class AngularConnectModule {
1421
+ static initializeApp(defaultShop, options, nameOrConfig) {
1422
+ return {
1423
+ ngModule: AngularConnectModule,
1424
+ providers: [
1425
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1426
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1427
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1428
+ ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1429
+ ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
1430
+ ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
1431
+ ],
1432
+ };
1433
+ }
1434
+ }
1435
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1436
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1437
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
1438
+ AuthService,
1439
+ CartService,
1440
+ CheckoutService,
1441
+ CheckoutSubscriptionService,
1442
+ CouponService,
1443
+ HomeShopService,
1444
+ OrderService,
1445
+ ShippingService,
1446
+ ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1447
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1448
+ type: NgModule,
1449
+ args: [{
1450
+ imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1451
+ providers: [
1452
+ AuthService,
1453
+ CartService,
1454
+ CheckoutService,
1455
+ CheckoutSubscriptionService,
1456
+ CouponService,
1457
+ HomeShopService,
1458
+ OrderService,
1459
+ ShippingService,
1460
+ ],
1461
+ }]
1476
1462
  }] });
1477
1463
 
1478
- /**
1479
- * Generated bundle index. Do not edit.
1464
+ /**
1465
+ * Generated bundle index. Do not edit.
1480
1466
  */
1481
1467
 
1482
1468
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ShippingService };