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