@infrab4a/connect-angular 4.0.0-beta.8 → 4.0.1-beta.0

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