@infrab4a/connect-angular 4.0.0-beta.38 → 4.0.0-beta.4
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 +19 -21
- package/angular-elastic-search.module.d.ts +9 -9
- package/angular-firebase-auth.module.d.ts +12 -12
- package/angular-firestore.module.d.ts +17 -18
- package/angular-hasura-graphql.module.d.ts +16 -16
- package/consts/default-shop.const.d.ts +1 -1
- package/consts/es-config.const.d.ts +1 -1
- package/consts/firebase-const.d.ts +3 -3
- package/consts/hasura-options.const.d.ts +1 -1
- package/consts/index.d.ts +4 -6
- package/esm2020/angular-connect.module.mjs +49 -63
- package/esm2020/angular-elastic-search.module.mjs +38 -34
- package/esm2020/angular-firebase-auth.module.mjs +130 -130
- package/esm2020/angular-firestore.module.mjs +358 -447
- package/esm2020/angular-hasura-graphql.module.mjs +131 -219
- package/esm2020/consts/default-shop.const.mjs +2 -2
- package/esm2020/consts/es-config.const.mjs +2 -2
- package/esm2020/consts/firebase-const.mjs +4 -4
- package/esm2020/consts/hasura-options.const.mjs +2 -2
- package/esm2020/consts/index.mjs +5 -7
- package/esm2020/index.mjs +6 -6
- package/esm2020/infrab4a-connect-angular.mjs +4 -4
- package/esm2020/services/auth.service.mjs +37 -37
- package/esm2020/services/cart.service.mjs +143 -281
- package/esm2020/services/checkout-subscription.service.mjs +51 -53
- package/esm2020/services/checkout.service.mjs +73 -71
- package/esm2020/services/coupon.service.mjs +226 -214
- package/esm2020/services/errors/group-invalid-coupon.error.mjs +8 -0
- package/esm2020/services/errors/index.mjs +3 -0
- package/esm2020/services/errors/invalid-coupon.error.mjs +7 -0
- package/esm2020/services/home-shop.service.mjs +114 -114
- package/esm2020/services/index.mjs +8 -10
- package/esm2020/services/order.service.mjs +30 -30
- package/esm2020/services/types/index.mjs +3 -3
- package/esm2020/services/types/required-checkout-data.type.mjs +2 -2
- package/esm2020/services/types/required-checkout-subscription-data.type.mjs +2 -2
- package/esm2020/types/firebase-app-config.type.mjs +2 -2
- package/esm2020/types/index.mjs +2 -2
- package/fesm2015/infrab4a-connect-angular.mjs +1341 -1959
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +1297 -1902
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/index.d.ts +5 -5
- package/package.json +3 -2
- package/services/auth.service.d.ts +18 -18
- package/services/cart.service.d.ts +35 -42
- package/services/checkout-subscription.service.d.ts +18 -18
- package/services/checkout.service.d.ts +23 -23
- package/services/coupon.service.d.ts +25 -28
- package/services/errors/group-invalid-coupon.error.d.ts +6 -0
- package/services/errors/index.d.ts +2 -0
- package/services/errors/invalid-coupon.error.d.ts +4 -0
- package/services/home-shop.service.d.ts +25 -25
- package/services/index.d.ts +7 -9
- 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
- package/types/firebase-app-config.type.d.ts +1 -1
- package/types/index.d.ts +1 -1
- package/consts/backend-url.const.d.ts +0 -1
- package/consts/category-structure.d.ts +0 -1
- package/esm2020/consts/backend-url.const.mjs +0 -2
- package/esm2020/consts/category-structure.mjs +0 -2
- package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +0 -2
- package/esm2020/services/catalog/adapters/index.mjs +0 -4
- package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +0 -42
- package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +0 -23
- package/esm2020/services/catalog/catalog.service.mjs +0 -96
- package/esm2020/services/catalog/category.service.mjs +0 -51
- package/esm2020/services/catalog/enums/index.mjs +0 -2
- package/esm2020/services/catalog/enums/product-sorts.enum.mjs +0 -11
- package/esm2020/services/catalog/index.mjs +0 -6
- package/esm2020/services/catalog/models/category-with-tree.model.mjs +0 -10
- package/esm2020/services/catalog/models/index.mjs +0 -2
- package/esm2020/services/catalog/types/index.mjs +0 -2
- package/esm2020/services/catalog/types/product-sort.type.mjs +0 -2
- package/esm2020/services/shipping.service.mjs +0 -96
- package/esm2020/services/types/shipping-methods.type.mjs +0 -2
- package/services/catalog/adapters/category-structure.adapter.d.ts +0 -4
- package/services/catalog/adapters/index.d.ts +0 -3
- package/services/catalog/adapters/new-category-structure.adapter.d.ts +0 -14
- package/services/catalog/adapters/old-category-structure.adapter.d.ts +0 -10
- package/services/catalog/catalog.service.d.ts +0 -54
- package/services/catalog/category.service.d.ts +0 -15
- package/services/catalog/enums/index.d.ts +0 -1
- package/services/catalog/enums/product-sorts.enum.d.ts +0 -9
- package/services/catalog/index.d.ts +0 -5
- package/services/catalog/models/category-with-tree.model.d.ts +0 -4
- package/services/catalog/models/index.d.ts +0 -1
- package/services/catalog/types/index.d.ts +0 -1
- package/services/catalog/types/product-sort.type.d.ts +0 -2
- package/services/shipping.service.d.ts +0 -19
- package/services/types/shipping-methods.type.d.ts +0 -12
|
@@ -1,1995 +1,1377 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import {
|
|
3
|
-
import * as i1
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
7
|
-
import * as i1$1 from '@angular/fire/auth';
|
|
8
|
-
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
9
|
-
import { isPlatformBrowser } from '@angular/common';
|
|
10
|
-
import * as i1$2 from '@angular/fire/firestore';
|
|
11
|
-
import { Firestore, provideFirestore, docSnapshots, doc } from '@angular/fire/firestore';
|
|
12
|
-
import { initializeApp as initializeApp$1 } from 'firebase/app';
|
|
13
|
-
import { getFirestore } from 'firebase/firestore';
|
|
14
|
-
import { combineLatest, from, of, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
2
|
+
import { Injectable, Inject, InjectionToken, NgModule, PLATFORM_ID } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/fire/auth';
|
|
4
|
+
import { getIdToken, authState, Auth, provideAuth, getAuth } from '@angular/fire/auth';
|
|
5
|
+
import { combineLatest, of, from, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
15
6
|
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
16
|
-
import { __awaiter
|
|
7
|
+
import { __awaiter } from 'tslib';
|
|
8
|
+
import * as i2 from '@infrab4a/connect';
|
|
9
|
+
import { Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, Status, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Order, Category, Product, RequiredArgumentError, add, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, VariantHasuraGraphQLRepository } from '@infrab4a/connect';
|
|
17
10
|
import cookie from 'js-cookie';
|
|
18
|
-
import {
|
|
19
|
-
import * as i1$
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
import { CustomError } from 'ts-custom-error';
|
|
12
|
+
import * as i1$1 from '@angular/fire/firestore';
|
|
13
|
+
import { docSnapshots, doc, Firestore, provideFirestore, getFirestore } from '@angular/fire/firestore';
|
|
14
|
+
import * as i1$2 from '@angular/fire/app';
|
|
15
|
+
import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
|
|
16
|
+
import { isPlatformServer } from '@angular/common';
|
|
22
17
|
|
|
23
|
-
|
|
18
|
+
class AuthService {
|
|
19
|
+
constructor(angularFireAuth, userRepository) {
|
|
20
|
+
this.angularFireAuth = angularFireAuth;
|
|
21
|
+
this.userRepository = userRepository;
|
|
22
|
+
}
|
|
23
|
+
getAuthstate() {
|
|
24
|
+
const observables = [this.getFireUser(), this.getUser()];
|
|
25
|
+
return combineLatest(observables).pipe(map(([fireUser, user]) => ({
|
|
26
|
+
user,
|
|
27
|
+
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
30
|
+
getUser() {
|
|
31
|
+
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))), catchError(() => of(null)));
|
|
32
|
+
}
|
|
33
|
+
getTokenId() {
|
|
34
|
+
return from(getIdToken(this.angularFireAuth.currentUser));
|
|
35
|
+
}
|
|
36
|
+
getFireUser() {
|
|
37
|
+
return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, deps: [{ token: i1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
41
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
|
|
42
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
|
|
43
|
+
type: Injectable
|
|
44
|
+
}], ctorParameters: function () {
|
|
45
|
+
return [{ type: i1.Auth }, { type: undefined, decorators: [{
|
|
46
|
+
type: Inject,
|
|
47
|
+
args: ['UserRepository']
|
|
48
|
+
}] }];
|
|
49
|
+
} });
|
|
24
50
|
|
|
25
51
|
const DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
26
52
|
|
|
27
53
|
const ES_CONFIG = 'ES_CONFIG';
|
|
28
54
|
|
|
29
|
-
const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
|
|
55
|
+
const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
|
|
30
56
|
const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
|
|
31
57
|
|
|
32
58
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
33
59
|
|
|
34
|
-
class
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
40
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
46
|
-
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.FirebaseAppModule, i1$1.AuthModule] });
|
|
47
|
-
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
48
|
-
{
|
|
49
|
-
provide: 'Authentication',
|
|
50
|
-
useFactory: (authenticationService, userRepository) => {
|
|
51
|
-
return new Authentication(authenticationService, userRepository);
|
|
52
|
-
},
|
|
53
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
provide: 'AuthenticationService',
|
|
57
|
-
useFactory: (angularFireAuth) => {
|
|
58
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
59
|
-
},
|
|
60
|
-
deps: [Auth],
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
provide: 'Register',
|
|
64
|
-
useFactory: (registerService, userRepository) => {
|
|
65
|
-
return new Register(registerService, userRepository);
|
|
66
|
-
},
|
|
67
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
provide: 'RegisterService',
|
|
71
|
-
useFactory: (angularFireAuth) => {
|
|
72
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
73
|
-
},
|
|
74
|
-
deps: [Auth],
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
provide: 'SignOut',
|
|
78
|
-
useFactory: (authenticationService) => {
|
|
79
|
-
return new SignOut(authenticationService);
|
|
80
|
-
},
|
|
81
|
-
deps: ['AuthenticationService'],
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
provide: 'RecoveryPassword',
|
|
85
|
-
useFactory: (authenticationService) => {
|
|
86
|
-
return new RecoveryPassword(authenticationService);
|
|
87
|
-
},
|
|
88
|
-
deps: ['AuthenticationService'],
|
|
89
|
-
},
|
|
90
|
-
], imports: [provideFirebaseApp((injector) => {
|
|
91
|
-
const appName = injector.get(FIREBASE_APP_NAME);
|
|
92
|
-
return appName
|
|
93
|
-
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
94
|
-
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
95
|
-
}),
|
|
96
|
-
provideAuth(() => getAuth())] });
|
|
97
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
98
|
-
type: NgModule,
|
|
99
|
-
args: [{
|
|
100
|
-
imports: [
|
|
101
|
-
provideFirebaseApp((injector) => {
|
|
102
|
-
const appName = injector.get(FIREBASE_APP_NAME);
|
|
103
|
-
return appName
|
|
104
|
-
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
105
|
-
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
106
|
-
}),
|
|
107
|
-
provideAuth(() => getAuth()),
|
|
108
|
-
],
|
|
109
|
-
providers: [
|
|
110
|
-
{
|
|
111
|
-
provide: 'Authentication',
|
|
112
|
-
useFactory: (authenticationService, userRepository) => {
|
|
113
|
-
return new Authentication(authenticationService, userRepository);
|
|
114
|
-
},
|
|
115
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
provide: 'AuthenticationService',
|
|
119
|
-
useFactory: (angularFireAuth) => {
|
|
120
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
121
|
-
},
|
|
122
|
-
deps: [Auth],
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
provide: 'Register',
|
|
126
|
-
useFactory: (registerService, userRepository) => {
|
|
127
|
-
return new Register(registerService, userRepository);
|
|
128
|
-
},
|
|
129
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
provide: 'RegisterService',
|
|
133
|
-
useFactory: (angularFireAuth) => {
|
|
134
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
135
|
-
},
|
|
136
|
-
deps: [Auth],
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
provide: 'SignOut',
|
|
140
|
-
useFactory: (authenticationService) => {
|
|
141
|
-
return new SignOut(authenticationService);
|
|
142
|
-
},
|
|
143
|
-
deps: ['AuthenticationService'],
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
provide: 'RecoveryPassword',
|
|
147
|
-
useFactory: (authenticationService) => {
|
|
148
|
-
return new RecoveryPassword(authenticationService);
|
|
149
|
-
},
|
|
150
|
-
deps: ['AuthenticationService'],
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
}]
|
|
154
|
-
}] });
|
|
155
|
-
|
|
156
|
-
class AngularElasticSeachModule {
|
|
157
|
-
static initializeApp(options) {
|
|
158
|
-
return {
|
|
159
|
-
ngModule: AngularElasticSeachModule,
|
|
160
|
-
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
165
|
-
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
|
|
166
|
-
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
167
|
-
{
|
|
168
|
-
provide: ProductsIndex,
|
|
169
|
-
useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
|
|
170
|
-
deps: [ES_CONFIG],
|
|
171
|
-
},
|
|
172
|
-
] });
|
|
173
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
174
|
-
type: NgModule,
|
|
175
|
-
args: [{
|
|
176
|
-
providers: [
|
|
177
|
-
{
|
|
178
|
-
provide: ProductsIndex,
|
|
179
|
-
useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
|
|
180
|
-
deps: [ES_CONFIG],
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
}]
|
|
184
|
-
}] });
|
|
185
|
-
|
|
186
|
-
class AngularFirestoreModule {
|
|
187
|
-
static initializeApp(options, nameOrConfig) {
|
|
188
|
-
return {
|
|
189
|
-
ngModule: AngularFirestoreModule,
|
|
190
|
-
providers: [
|
|
191
|
-
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
192
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
193
|
-
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
194
|
-
],
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
199
|
-
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1.FirebaseAppModule, i1$2.FirestoreModule] });
|
|
200
|
-
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
201
|
-
{
|
|
202
|
-
provide: 'FirestoreOptions',
|
|
203
|
-
useFactory: (firestore, platformId) => ({
|
|
204
|
-
firestore,
|
|
205
|
-
interceptors: {
|
|
206
|
-
request: (request) => {
|
|
207
|
-
if (isPlatformBrowser(platformId))
|
|
208
|
-
return request;
|
|
209
|
-
const interval = setInterval(() => { }, 100);
|
|
210
|
-
request.interval = interval;
|
|
211
|
-
return request;
|
|
212
|
-
},
|
|
213
|
-
response: (response, request) => {
|
|
214
|
-
if (isPlatformBrowser(platformId))
|
|
215
|
-
return response;
|
|
216
|
-
clearInterval(request.interval);
|
|
217
|
-
return response;
|
|
218
|
-
},
|
|
219
|
-
},
|
|
220
|
-
}),
|
|
221
|
-
deps: [Firestore, PLATFORM_ID],
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
provide: 'BeautyProfileRepository',
|
|
225
|
-
useFactory: (config, userRepository) => {
|
|
226
|
-
return new UserBeautyProfileFirestoreRepository(config, userRepository);
|
|
227
|
-
},
|
|
228
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
provide: 'Buy2WinRepository',
|
|
232
|
-
useFactory: (options) => {
|
|
233
|
-
return new Buy2WinFirestoreRepository(options);
|
|
234
|
-
},
|
|
235
|
-
deps: ['FirestoreOptions'],
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
provide: CategoryFirestoreRepository,
|
|
239
|
-
useFactory: (options) => {
|
|
240
|
-
return new CategoryFirestoreRepository(options);
|
|
241
|
-
},
|
|
242
|
-
deps: ['FirestoreOptions'],
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
provide: 'CheckoutRepository',
|
|
246
|
-
useFactory: (options) => {
|
|
247
|
-
return new CheckoutFirestoreRepository(options);
|
|
248
|
-
},
|
|
249
|
-
deps: ['FirestoreOptions'],
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
253
|
-
useFactory: (options) => {
|
|
254
|
-
return new CheckoutSubscriptionFirestoreRepository(options);
|
|
255
|
-
},
|
|
256
|
-
deps: ['FirestoreOptions'],
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
provide: 'CouponRepository',
|
|
260
|
-
useFactory: (options) => {
|
|
261
|
-
return new CouponFirestoreRepository(options);
|
|
262
|
-
},
|
|
263
|
-
deps: ['FirestoreOptions'],
|
|
264
|
-
},
|
|
265
|
-
{
|
|
266
|
-
provide: 'CampaignHashtagRepository',
|
|
267
|
-
useFactory: (options) => {
|
|
268
|
-
return new CampaignHashtagFirestoreRepository(options);
|
|
269
|
-
},
|
|
270
|
-
deps: ['FirestoreOptions'],
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
provide: 'CampaignDashboardRepository',
|
|
274
|
-
useFactory: (options) => {
|
|
275
|
-
return new CampaignDashboardFirestoreRepository(options);
|
|
276
|
-
},
|
|
277
|
-
deps: ['FirestoreOptions'],
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
provide: 'EditionRepository',
|
|
281
|
-
useFactory: (options, subscriptionRepository) => {
|
|
282
|
-
return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
|
|
283
|
-
},
|
|
284
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
provide: 'HomeRepository',
|
|
288
|
-
useFactory: (options) => {
|
|
289
|
-
return new HomeFirestoreRepository(options);
|
|
290
|
-
},
|
|
291
|
-
deps: ['FirestoreOptions'],
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
provide: 'LeadRepository',
|
|
295
|
-
useFactory: (options) => {
|
|
296
|
-
return new LeadFirestoreRepository(options);
|
|
297
|
-
},
|
|
298
|
-
deps: ['FirestoreOptions'],
|
|
299
|
-
},
|
|
300
|
-
{
|
|
301
|
-
provide: 'LegacyOrderRepository',
|
|
302
|
-
useFactory: (options) => {
|
|
303
|
-
return new LegacyOrderFirestoreRepository(options);
|
|
304
|
-
},
|
|
305
|
-
deps: ['FirestoreOptions'],
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
provide: 'ShopMenuRepository',
|
|
309
|
-
useFactory: (options) => {
|
|
310
|
-
return new ShopMenuFirestoreRepository(options);
|
|
311
|
-
},
|
|
312
|
-
deps: ['FirestoreOptions'],
|
|
313
|
-
},
|
|
314
|
-
{
|
|
315
|
-
provide: 'OrderRepository',
|
|
316
|
-
useFactory: (options) => {
|
|
317
|
-
return new OrderFirestoreRepository(options);
|
|
318
|
-
},
|
|
319
|
-
deps: ['FirestoreOptions'],
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
provide: 'PaymentRepository',
|
|
323
|
-
useFactory: (options) => {
|
|
324
|
-
return new PaymentFirestoreRepository(options);
|
|
325
|
-
},
|
|
326
|
-
deps: ['FirestoreOptions'],
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
provide: ProductFirestoreRepository,
|
|
330
|
-
useFactory: (options) => {
|
|
331
|
-
return new ProductFirestoreRepository(options);
|
|
332
|
-
},
|
|
333
|
-
deps: ['FirestoreOptions'],
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
provide: 'ShopSettingsRepository',
|
|
337
|
-
useFactory: (options) => {
|
|
338
|
-
return new ShopSettingsFirestoreRepository(options);
|
|
339
|
-
},
|
|
340
|
-
deps: ['FirestoreOptions'],
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
provide: 'SubscriptionPaymentRepository',
|
|
344
|
-
useFactory: (options, subscriptionRepository) => {
|
|
345
|
-
return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
|
|
346
|
-
},
|
|
347
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
348
|
-
},
|
|
349
|
-
{
|
|
350
|
-
provide: 'SubscriptionPlanRepository',
|
|
351
|
-
useFactory: (options) => {
|
|
352
|
-
return new SubscriptionPlanFirestoreRepository(options);
|
|
353
|
-
},
|
|
354
|
-
deps: ['FirestoreOptions'],
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
provide: 'SubscriptionProductRepository',
|
|
358
|
-
useFactory: (options) => {
|
|
359
|
-
return new SubscriptionProductFirestoreRepository(options);
|
|
360
|
-
},
|
|
361
|
-
deps: ['FirestoreOptions'],
|
|
362
|
-
},
|
|
363
|
-
{
|
|
364
|
-
provide: 'SubscriptionRepository',
|
|
365
|
-
useFactory: (options) => {
|
|
366
|
-
return new SubscriptionFirestoreRepository(options);
|
|
367
|
-
},
|
|
368
|
-
deps: ['FirestoreOptions'],
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
provide: 'UserRepository',
|
|
372
|
-
useFactory: (options) => {
|
|
373
|
-
return new UserFirestoreRepository(options);
|
|
374
|
-
},
|
|
375
|
-
deps: ['FirestoreOptions'],
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
provide: 'UserAddressRepository',
|
|
379
|
-
useFactory: (options, userRepository) => {
|
|
380
|
-
return new UserAddressFirestoreRepository(options, userRepository);
|
|
381
|
-
},
|
|
382
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
383
|
-
},
|
|
384
|
-
{
|
|
385
|
-
provide: 'UserPaymentMethodRepository',
|
|
386
|
-
useFactory: (options, userRepository) => {
|
|
387
|
-
return new UserPaymentMethodFirestoreRepository(options, userRepository);
|
|
388
|
-
},
|
|
389
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
provide: ProductVariantFirestoreRepository,
|
|
393
|
-
useFactory: (options, productRepository) => {
|
|
394
|
-
return new ProductVariantFirestoreRepository(options, productRepository);
|
|
395
|
-
},
|
|
396
|
-
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
397
|
-
},
|
|
398
|
-
], imports: [AngularElasticSeachModule,
|
|
399
|
-
provideFirebaseApp((injector) => {
|
|
400
|
-
const appName = injector.get(FIREBASE_APP_NAME);
|
|
401
|
-
return appName
|
|
402
|
-
? initializeApp$1(injector.get(FIREBASE_OPTIONS), appName)
|
|
403
|
-
: initializeApp$1(injector.get(FIREBASE_OPTIONS));
|
|
404
|
-
}),
|
|
405
|
-
provideFirestore(() => getFirestore())] });
|
|
406
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
407
|
-
type: NgModule,
|
|
408
|
-
args: [{
|
|
409
|
-
imports: [
|
|
410
|
-
AngularElasticSeachModule,
|
|
411
|
-
provideFirebaseApp((injector) => {
|
|
412
|
-
const appName = injector.get(FIREBASE_APP_NAME);
|
|
413
|
-
return appName
|
|
414
|
-
? initializeApp$1(injector.get(FIREBASE_OPTIONS), appName)
|
|
415
|
-
: initializeApp$1(injector.get(FIREBASE_OPTIONS));
|
|
416
|
-
}),
|
|
417
|
-
provideFirestore(() => getFirestore()),
|
|
418
|
-
],
|
|
419
|
-
providers: [
|
|
420
|
-
{
|
|
421
|
-
provide: 'FirestoreOptions',
|
|
422
|
-
useFactory: (firestore, platformId) => ({
|
|
423
|
-
firestore,
|
|
424
|
-
interceptors: {
|
|
425
|
-
request: (request) => {
|
|
426
|
-
if (isPlatformBrowser(platformId))
|
|
427
|
-
return request;
|
|
428
|
-
const interval = setInterval(() => { }, 100);
|
|
429
|
-
request.interval = interval;
|
|
430
|
-
return request;
|
|
431
|
-
},
|
|
432
|
-
response: (response, request) => {
|
|
433
|
-
if (isPlatformBrowser(platformId))
|
|
434
|
-
return response;
|
|
435
|
-
clearInterval(request.interval);
|
|
436
|
-
return response;
|
|
437
|
-
},
|
|
438
|
-
},
|
|
439
|
-
}),
|
|
440
|
-
deps: [Firestore, PLATFORM_ID],
|
|
441
|
-
},
|
|
442
|
-
{
|
|
443
|
-
provide: 'BeautyProfileRepository',
|
|
444
|
-
useFactory: (config, userRepository) => {
|
|
445
|
-
return new UserBeautyProfileFirestoreRepository(config, userRepository);
|
|
446
|
-
},
|
|
447
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
448
|
-
},
|
|
449
|
-
{
|
|
450
|
-
provide: 'Buy2WinRepository',
|
|
451
|
-
useFactory: (options) => {
|
|
452
|
-
return new Buy2WinFirestoreRepository(options);
|
|
453
|
-
},
|
|
454
|
-
deps: ['FirestoreOptions'],
|
|
455
|
-
},
|
|
456
|
-
{
|
|
457
|
-
provide: CategoryFirestoreRepository,
|
|
458
|
-
useFactory: (options) => {
|
|
459
|
-
return new CategoryFirestoreRepository(options);
|
|
460
|
-
},
|
|
461
|
-
deps: ['FirestoreOptions'],
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
provide: 'CheckoutRepository',
|
|
465
|
-
useFactory: (options) => {
|
|
466
|
-
return new CheckoutFirestoreRepository(options);
|
|
467
|
-
},
|
|
468
|
-
deps: ['FirestoreOptions'],
|
|
469
|
-
},
|
|
470
|
-
{
|
|
471
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
472
|
-
useFactory: (options) => {
|
|
473
|
-
return new CheckoutSubscriptionFirestoreRepository(options);
|
|
474
|
-
},
|
|
475
|
-
deps: ['FirestoreOptions'],
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
provide: 'CouponRepository',
|
|
479
|
-
useFactory: (options) => {
|
|
480
|
-
return new CouponFirestoreRepository(options);
|
|
481
|
-
},
|
|
482
|
-
deps: ['FirestoreOptions'],
|
|
483
|
-
},
|
|
484
|
-
{
|
|
485
|
-
provide: 'CampaignHashtagRepository',
|
|
486
|
-
useFactory: (options) => {
|
|
487
|
-
return new CampaignHashtagFirestoreRepository(options);
|
|
488
|
-
},
|
|
489
|
-
deps: ['FirestoreOptions'],
|
|
490
|
-
},
|
|
491
|
-
{
|
|
492
|
-
provide: 'CampaignDashboardRepository',
|
|
493
|
-
useFactory: (options) => {
|
|
494
|
-
return new CampaignDashboardFirestoreRepository(options);
|
|
495
|
-
},
|
|
496
|
-
deps: ['FirestoreOptions'],
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
provide: 'EditionRepository',
|
|
500
|
-
useFactory: (options, subscriptionRepository) => {
|
|
501
|
-
return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
|
|
502
|
-
},
|
|
503
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
504
|
-
},
|
|
505
|
-
{
|
|
506
|
-
provide: 'HomeRepository',
|
|
507
|
-
useFactory: (options) => {
|
|
508
|
-
return new HomeFirestoreRepository(options);
|
|
509
|
-
},
|
|
510
|
-
deps: ['FirestoreOptions'],
|
|
511
|
-
},
|
|
512
|
-
{
|
|
513
|
-
provide: 'LeadRepository',
|
|
514
|
-
useFactory: (options) => {
|
|
515
|
-
return new LeadFirestoreRepository(options);
|
|
516
|
-
},
|
|
517
|
-
deps: ['FirestoreOptions'],
|
|
518
|
-
},
|
|
519
|
-
{
|
|
520
|
-
provide: 'LegacyOrderRepository',
|
|
521
|
-
useFactory: (options) => {
|
|
522
|
-
return new LegacyOrderFirestoreRepository(options);
|
|
523
|
-
},
|
|
524
|
-
deps: ['FirestoreOptions'],
|
|
525
|
-
},
|
|
526
|
-
{
|
|
527
|
-
provide: 'ShopMenuRepository',
|
|
528
|
-
useFactory: (options) => {
|
|
529
|
-
return new ShopMenuFirestoreRepository(options);
|
|
530
|
-
},
|
|
531
|
-
deps: ['FirestoreOptions'],
|
|
532
|
-
},
|
|
533
|
-
{
|
|
534
|
-
provide: 'OrderRepository',
|
|
535
|
-
useFactory: (options) => {
|
|
536
|
-
return new OrderFirestoreRepository(options);
|
|
537
|
-
},
|
|
538
|
-
deps: ['FirestoreOptions'],
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
provide: 'PaymentRepository',
|
|
542
|
-
useFactory: (options) => {
|
|
543
|
-
return new PaymentFirestoreRepository(options);
|
|
544
|
-
},
|
|
545
|
-
deps: ['FirestoreOptions'],
|
|
546
|
-
},
|
|
547
|
-
{
|
|
548
|
-
provide: ProductFirestoreRepository,
|
|
549
|
-
useFactory: (options) => {
|
|
550
|
-
return new ProductFirestoreRepository(options);
|
|
551
|
-
},
|
|
552
|
-
deps: ['FirestoreOptions'],
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
provide: 'ShopSettingsRepository',
|
|
556
|
-
useFactory: (options) => {
|
|
557
|
-
return new ShopSettingsFirestoreRepository(options);
|
|
558
|
-
},
|
|
559
|
-
deps: ['FirestoreOptions'],
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
provide: 'SubscriptionPaymentRepository',
|
|
563
|
-
useFactory: (options, subscriptionRepository) => {
|
|
564
|
-
return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
|
|
565
|
-
},
|
|
566
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
567
|
-
},
|
|
568
|
-
{
|
|
569
|
-
provide: 'SubscriptionPlanRepository',
|
|
570
|
-
useFactory: (options) => {
|
|
571
|
-
return new SubscriptionPlanFirestoreRepository(options);
|
|
572
|
-
},
|
|
573
|
-
deps: ['FirestoreOptions'],
|
|
574
|
-
},
|
|
575
|
-
{
|
|
576
|
-
provide: 'SubscriptionProductRepository',
|
|
577
|
-
useFactory: (options) => {
|
|
578
|
-
return new SubscriptionProductFirestoreRepository(options);
|
|
579
|
-
},
|
|
580
|
-
deps: ['FirestoreOptions'],
|
|
581
|
-
},
|
|
582
|
-
{
|
|
583
|
-
provide: 'SubscriptionRepository',
|
|
584
|
-
useFactory: (options) => {
|
|
585
|
-
return new SubscriptionFirestoreRepository(options);
|
|
586
|
-
},
|
|
587
|
-
deps: ['FirestoreOptions'],
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
provide: 'UserRepository',
|
|
591
|
-
useFactory: (options) => {
|
|
592
|
-
return new UserFirestoreRepository(options);
|
|
593
|
-
},
|
|
594
|
-
deps: ['FirestoreOptions'],
|
|
595
|
-
},
|
|
596
|
-
{
|
|
597
|
-
provide: 'UserAddressRepository',
|
|
598
|
-
useFactory: (options, userRepository) => {
|
|
599
|
-
return new UserAddressFirestoreRepository(options, userRepository);
|
|
600
|
-
},
|
|
601
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
602
|
-
},
|
|
603
|
-
{
|
|
604
|
-
provide: 'UserPaymentMethodRepository',
|
|
605
|
-
useFactory: (options, userRepository) => {
|
|
606
|
-
return new UserPaymentMethodFirestoreRepository(options, userRepository);
|
|
607
|
-
},
|
|
608
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
609
|
-
},
|
|
610
|
-
{
|
|
611
|
-
provide: ProductVariantFirestoreRepository,
|
|
612
|
-
useFactory: (options, productRepository) => {
|
|
613
|
-
return new ProductVariantFirestoreRepository(options, productRepository);
|
|
614
|
-
},
|
|
615
|
-
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
616
|
-
},
|
|
617
|
-
],
|
|
618
|
-
}]
|
|
619
|
-
}] });
|
|
620
|
-
|
|
621
|
-
class AngularHasuraGraphQLModule {
|
|
622
|
-
static initializeApp(options) {
|
|
623
|
-
return {
|
|
624
|
-
ngModule: AngularHasuraGraphQLModule,
|
|
625
|
-
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
626
|
-
};
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
630
|
-
AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
|
|
631
|
-
AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
|
|
632
|
-
{
|
|
633
|
-
provide: 'HasuraConfig',
|
|
634
|
-
useFactory: (options, platformId) => ({
|
|
635
|
-
endpoint: options.endpoint,
|
|
636
|
-
authOptions: options.credentials,
|
|
637
|
-
interceptors: {
|
|
638
|
-
request: (request) => {
|
|
639
|
-
if (isPlatformBrowser(platformId))
|
|
640
|
-
return request;
|
|
641
|
-
const interval = setInterval(() => { }, 100);
|
|
642
|
-
request.interval = interval;
|
|
643
|
-
return request;
|
|
644
|
-
},
|
|
645
|
-
response: (response, request) => {
|
|
646
|
-
if (isPlatformBrowser(platformId))
|
|
647
|
-
return response;
|
|
648
|
-
clearInterval(request.interval);
|
|
649
|
-
return response;
|
|
650
|
-
},
|
|
651
|
-
},
|
|
652
|
-
}),
|
|
653
|
-
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
654
|
-
},
|
|
655
|
-
{
|
|
656
|
-
provide: 'CategoryRepository',
|
|
657
|
-
useExisting: CategoryHasuraGraphQLRepository,
|
|
658
|
-
},
|
|
659
|
-
{
|
|
660
|
-
provide: CategoryHasuraGraphQLRepository,
|
|
661
|
-
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
662
|
-
return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
|
|
663
|
-
},
|
|
664
|
-
deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
665
|
-
},
|
|
666
|
-
{
|
|
667
|
-
provide: 'ProductRepository',
|
|
668
|
-
useExisting: ProductHasuraGraphQLRepository,
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
provide: ProductHasuraGraphQLRepository,
|
|
672
|
-
useFactory: (hasuraConfig) => {
|
|
673
|
-
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
674
|
-
},
|
|
675
|
-
deps: ['HasuraConfig'],
|
|
676
|
-
},
|
|
677
|
-
{
|
|
678
|
-
provide: 'VariantRepository',
|
|
679
|
-
useExisting: VariantHasuraGraphQLRepository,
|
|
680
|
-
},
|
|
681
|
-
{
|
|
682
|
-
provide: VariantHasuraGraphQLRepository,
|
|
683
|
-
useFactory: (hasuraConfig) => {
|
|
684
|
-
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
685
|
-
},
|
|
686
|
-
deps: ['HasuraConfig'],
|
|
687
|
-
},
|
|
688
|
-
{
|
|
689
|
-
provide: 'CategoryFilterRepository',
|
|
690
|
-
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
691
|
-
},
|
|
692
|
-
{
|
|
693
|
-
provide: CategoryFilterHasuraGraphQLRepository,
|
|
694
|
-
useFactory: (options) => {
|
|
695
|
-
return new CategoryFilterHasuraGraphQLRepository(options);
|
|
696
|
-
},
|
|
697
|
-
deps: ['HasuraConfig'],
|
|
698
|
-
},
|
|
699
|
-
{
|
|
700
|
-
provide: 'FilterOptionRepository',
|
|
701
|
-
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
702
|
-
},
|
|
703
|
-
{
|
|
704
|
-
provide: FilterOptionHasuraGraphQLRepository,
|
|
705
|
-
useFactory: (options) => {
|
|
706
|
-
return new FilterOptionHasuraGraphQLRepository(options);
|
|
707
|
-
},
|
|
708
|
-
deps: ['HasuraConfig'],
|
|
709
|
-
},
|
|
710
|
-
{
|
|
711
|
-
provide: 'FilterRepository',
|
|
712
|
-
useExisting: FilterHasuraGraphQLRepository,
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
provide: FilterHasuraGraphQLRepository,
|
|
716
|
-
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
717
|
-
return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
|
|
718
|
-
},
|
|
719
|
-
deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
720
|
-
},
|
|
721
|
-
{
|
|
722
|
-
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
723
|
-
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
|
|
724
|
-
},
|
|
725
|
-
{
|
|
726
|
-
provide: 'CategoryCollectionChildrenRepository',
|
|
727
|
-
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
728
|
-
},
|
|
729
|
-
] });
|
|
730
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
731
|
-
type: NgModule,
|
|
732
|
-
args: [{
|
|
733
|
-
providers: [
|
|
734
|
-
{
|
|
735
|
-
provide: 'HasuraConfig',
|
|
736
|
-
useFactory: (options, platformId) => ({
|
|
737
|
-
endpoint: options.endpoint,
|
|
738
|
-
authOptions: options.credentials,
|
|
739
|
-
interceptors: {
|
|
740
|
-
request: (request) => {
|
|
741
|
-
if (isPlatformBrowser(platformId))
|
|
742
|
-
return request;
|
|
743
|
-
const interval = setInterval(() => { }, 100);
|
|
744
|
-
request.interval = interval;
|
|
745
|
-
return request;
|
|
746
|
-
},
|
|
747
|
-
response: (response, request) => {
|
|
748
|
-
if (isPlatformBrowser(platformId))
|
|
749
|
-
return response;
|
|
750
|
-
clearInterval(request.interval);
|
|
751
|
-
return response;
|
|
752
|
-
},
|
|
753
|
-
},
|
|
754
|
-
}),
|
|
755
|
-
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
provide: 'CategoryRepository',
|
|
759
|
-
useExisting: CategoryHasuraGraphQLRepository,
|
|
760
|
-
},
|
|
761
|
-
{
|
|
762
|
-
provide: CategoryHasuraGraphQLRepository,
|
|
763
|
-
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
764
|
-
return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
|
|
765
|
-
},
|
|
766
|
-
deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
767
|
-
},
|
|
768
|
-
{
|
|
769
|
-
provide: 'ProductRepository',
|
|
770
|
-
useExisting: ProductHasuraGraphQLRepository,
|
|
771
|
-
},
|
|
772
|
-
{
|
|
773
|
-
provide: ProductHasuraGraphQLRepository,
|
|
774
|
-
useFactory: (hasuraConfig) => {
|
|
775
|
-
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
776
|
-
},
|
|
777
|
-
deps: ['HasuraConfig'],
|
|
778
|
-
},
|
|
779
|
-
{
|
|
780
|
-
provide: 'VariantRepository',
|
|
781
|
-
useExisting: VariantHasuraGraphQLRepository,
|
|
782
|
-
},
|
|
783
|
-
{
|
|
784
|
-
provide: VariantHasuraGraphQLRepository,
|
|
785
|
-
useFactory: (hasuraConfig) => {
|
|
786
|
-
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
787
|
-
},
|
|
788
|
-
deps: ['HasuraConfig'],
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
provide: 'CategoryFilterRepository',
|
|
792
|
-
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
793
|
-
},
|
|
794
|
-
{
|
|
795
|
-
provide: CategoryFilterHasuraGraphQLRepository,
|
|
796
|
-
useFactory: (options) => {
|
|
797
|
-
return new CategoryFilterHasuraGraphQLRepository(options);
|
|
798
|
-
},
|
|
799
|
-
deps: ['HasuraConfig'],
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
provide: 'FilterOptionRepository',
|
|
803
|
-
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
804
|
-
},
|
|
805
|
-
{
|
|
806
|
-
provide: FilterOptionHasuraGraphQLRepository,
|
|
807
|
-
useFactory: (options) => {
|
|
808
|
-
return new FilterOptionHasuraGraphQLRepository(options);
|
|
809
|
-
},
|
|
810
|
-
deps: ['HasuraConfig'],
|
|
811
|
-
},
|
|
812
|
-
{
|
|
813
|
-
provide: 'FilterRepository',
|
|
814
|
-
useExisting: FilterHasuraGraphQLRepository,
|
|
815
|
-
},
|
|
816
|
-
{
|
|
817
|
-
provide: FilterHasuraGraphQLRepository,
|
|
818
|
-
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
819
|
-
return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
|
|
820
|
-
},
|
|
821
|
-
deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
822
|
-
},
|
|
823
|
-
{
|
|
824
|
-
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
825
|
-
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
|
|
826
|
-
},
|
|
827
|
-
{
|
|
828
|
-
provide: 'CategoryCollectionChildrenRepository',
|
|
829
|
-
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
830
|
-
},
|
|
831
|
-
],
|
|
832
|
-
}]
|
|
833
|
-
}] });
|
|
834
|
-
|
|
835
|
-
class AuthService {
|
|
836
|
-
constructor(angularFireAuth, userRepository) {
|
|
837
|
-
this.angularFireAuth = angularFireAuth;
|
|
838
|
-
this.userRepository = userRepository;
|
|
839
|
-
}
|
|
840
|
-
getAuthstate() {
|
|
841
|
-
const observables = [this.getFireUser(), this.getUser()];
|
|
842
|
-
return combineLatest(observables).pipe(map(([fireUser, user]) => ({
|
|
843
|
-
user,
|
|
844
|
-
isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
|
|
845
|
-
})));
|
|
846
|
-
}
|
|
847
|
-
getUser() {
|
|
848
|
-
return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
|
|
849
|
-
}
|
|
850
|
-
getTokenId() {
|
|
851
|
-
return from(getIdToken(this.angularFireAuth.currentUser));
|
|
852
|
-
}
|
|
853
|
-
getFireUser() {
|
|
854
|
-
return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, deps: [{ token: i1$1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
858
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
|
|
859
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
|
|
860
|
-
type: Injectable
|
|
861
|
-
}], ctorParameters: function () {
|
|
862
|
-
return [{ type: i1$1.Auth }, { type: undefined, decorators: [{
|
|
863
|
-
type: Inject,
|
|
864
|
-
args: ['UserRepository']
|
|
865
|
-
}] }];
|
|
866
|
-
} });
|
|
60
|
+
class InvalidCouponError extends CustomError {
|
|
61
|
+
constructor(message) {
|
|
62
|
+
super(message);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
867
65
|
|
|
868
|
-
class
|
|
869
|
-
constructor(
|
|
870
|
-
|
|
871
|
-
this.
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
875
|
-
}
|
|
876
|
-
checkCoupon(nickname, checkoutType, checkout, plan) {
|
|
877
|
-
return from(this.couponRepository
|
|
878
|
-
.find({
|
|
879
|
-
filters: {
|
|
880
|
-
nickname: { operator: Where.EQUALS, value: nickname },
|
|
881
|
-
active: { operator: Where.EQUALS, value: true },
|
|
882
|
-
},
|
|
883
|
-
})
|
|
884
|
-
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
|
|
885
|
-
}
|
|
886
|
-
couponValidation(coupon, checkoutType) {
|
|
887
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
888
|
-
if (!coupon)
|
|
889
|
-
throw 'Cupom inválido.';
|
|
890
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
|
|
891
|
-
throw 'Cupom inválido.';
|
|
892
|
-
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
|
|
893
|
-
throw 'Cupom expirado.';
|
|
894
|
-
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
895
|
-
if (!isInShop)
|
|
896
|
-
throw 'Cupom inválido para loja.';
|
|
897
|
-
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
898
|
-
if (!isCheckoutType)
|
|
899
|
-
throw 'Cupom inválido. Erro de checkout.';
|
|
900
|
-
return coupon;
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
couponRulesValidation(coupon, checkoutType, checkout, plan) {
|
|
904
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
905
|
-
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
906
|
-
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
907
|
-
throw 'Cupom inválido para sua assinatura.';
|
|
908
|
-
return coupon;
|
|
909
|
-
}
|
|
910
|
-
const validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
911
|
-
if (!validUser)
|
|
912
|
-
throw 'Usuário não elegível.';
|
|
913
|
-
const orders = yield this.getOrdersWithCoupon(coupon);
|
|
914
|
-
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
915
|
-
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
916
|
-
if (couponUseLimits.limitedPerUser && ordersWithUser > 0)
|
|
917
|
-
throw 'Limite de uso por usuário atingido.';
|
|
918
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
919
|
-
throw 'Limite de uso atingido.';
|
|
920
|
-
const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
|
|
921
|
-
if (!hasProductCategories)
|
|
922
|
-
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
923
|
-
const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
|
|
924
|
-
if (!hasMinSubTotal)
|
|
925
|
-
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
|
|
926
|
-
return coupon;
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
calcDiscountSubscription(coupon, checkout) {
|
|
930
|
-
let discount = 0;
|
|
931
|
-
if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
|
|
932
|
-
discount = coupon.discount.subscription.value;
|
|
933
|
-
else
|
|
934
|
-
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
|
|
935
|
-
return of(discount);
|
|
936
|
-
}
|
|
937
|
-
calcDiscountShopping(coupon, checkout) {
|
|
938
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
939
|
-
let discount = 0;
|
|
940
|
-
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
941
|
-
discount = yield this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
942
|
-
}
|
|
943
|
-
else {
|
|
944
|
-
discount = yield this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
945
|
-
}
|
|
946
|
-
return discount;
|
|
947
|
-
});
|
|
948
|
-
}
|
|
949
|
-
calcDiscountByType(type, value, categories, checkout) {
|
|
950
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
951
|
-
let discount = 0;
|
|
952
|
-
let lineItensDiscount = yield this.getLineItensEligebleForDiscount(categories, checkout);
|
|
953
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
954
|
-
if (type == CouponTypes.ABSOLUTE) {
|
|
955
|
-
discount = value > subTotal ? subTotal : value;
|
|
956
|
-
}
|
|
957
|
-
else {
|
|
958
|
-
discount = subTotal * (value / 100);
|
|
959
|
-
}
|
|
960
|
-
return discount;
|
|
961
|
-
});
|
|
962
|
-
}
|
|
963
|
-
hasMinSubTotal(coupon, checkout) {
|
|
964
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
965
|
-
if (!coupon.minSubTotalValue)
|
|
966
|
-
return true;
|
|
967
|
-
let lineItensDiscount = yield this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
968
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
969
|
-
if (coupon.minSubTotalValue <= subTotal)
|
|
970
|
-
return true;
|
|
971
|
-
return false;
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
hasProductCategories(coupon, checkout) {
|
|
975
|
-
var _a;
|
|
976
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
977
|
-
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
978
|
-
return true;
|
|
979
|
-
}
|
|
980
|
-
const couponCategories = yield this.getCouponCategoriesId(coupon.productsCategories);
|
|
981
|
-
const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
982
|
-
var _a;
|
|
983
|
-
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
984
|
-
return true;
|
|
985
|
-
return i.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
986
|
-
});
|
|
987
|
-
return hasCategories.length ? true : false;
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
coupomUserValidation(coupon, user) {
|
|
991
|
-
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
992
|
-
return true;
|
|
993
|
-
let userTypes = [];
|
|
994
|
-
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) && this.emailIsFromCollaborator(user.email))
|
|
995
|
-
userTypes.push(Exclusivities.COLLABORATORS);
|
|
996
|
-
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) && coupon.userExclusiveEmail.includes(user.email))
|
|
997
|
-
userTypes.push(Exclusivities.SPECIFIC_USER);
|
|
998
|
-
if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
999
|
-
user.isSubscriber &&
|
|
1000
|
-
user.subscriptionPlan != '')
|
|
1001
|
-
userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
|
|
1002
|
-
if (user.isSubscriber &&
|
|
1003
|
-
user.subscriptionPlan == '' &&
|
|
1004
|
-
coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
|
|
1005
|
-
userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
|
|
1006
|
-
if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
1007
|
-
userTypes.push(Exclusivities.NON_SUBSCRIBER);
|
|
1008
|
-
return coupon.exclusivityType.some((r) => userTypes.includes(r));
|
|
1009
|
-
}
|
|
1010
|
-
getCouponCategoriesId(productsCategories) {
|
|
1011
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1012
|
-
const couponCategories = [];
|
|
1013
|
-
for (let index = 0; index < productsCategories.length; index++) {
|
|
1014
|
-
const category = yield this.categoryRepository.get({
|
|
1015
|
-
id: productsCategories[index],
|
|
1016
|
-
});
|
|
1017
|
-
if (category) {
|
|
1018
|
-
const children = yield this.categoryRepository.getChildren(parseInt(productsCategories[index]));
|
|
1019
|
-
couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
return [...new Set(couponCategories)];
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
getLineItensEligebleForDiscount(productsCategories, checkout) {
|
|
1026
|
-
var _a;
|
|
1027
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1028
|
-
let lineItensDiscount = [];
|
|
1029
|
-
const couponCategories = yield this.getCouponCategoriesId(productsCategories);
|
|
1030
|
-
if (productsCategories && productsCategories.length) {
|
|
1031
|
-
lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
1032
|
-
var _a;
|
|
1033
|
-
if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1034
|
-
return i.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
1035
|
-
}
|
|
1036
|
-
return true;
|
|
1037
|
-
});
|
|
1038
|
-
}
|
|
1039
|
-
else {
|
|
1040
|
-
lineItensDiscount = checkout.lineItems;
|
|
1041
|
-
}
|
|
1042
|
-
return lineItensDiscount;
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
calcCheckoutSubtotal(lineItens, user, shop) {
|
|
1046
|
-
return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce((acc, curr) => {
|
|
1047
|
-
var _a;
|
|
1048
|
-
return (user === null || user === void 0 ? void 0 : user.isSubscriber) && curr.price.subscriberPrice
|
|
1049
|
-
? acc + ((_a = curr.price) === null || _a === void 0 ? void 0 : _a.subscriberPrice) * curr.quantity
|
|
1050
|
-
: acc + curr.pricePaid * curr.quantity;
|
|
1051
|
-
}, 0)) || 0);
|
|
1052
|
-
}
|
|
1053
|
-
getOrdersWithCoupon(coupon) {
|
|
1054
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1055
|
-
return yield this.orderRepository
|
|
1056
|
-
.find({
|
|
1057
|
-
filters: {
|
|
1058
|
-
coupon: { id: coupon.id },
|
|
1059
|
-
payment: { status: 'paid' },
|
|
1060
|
-
},
|
|
1061
|
-
})
|
|
1062
|
-
.then((result) => result.data);
|
|
1063
|
-
});
|
|
1064
|
-
}
|
|
1065
|
-
countOrdersWithUser(orders, email) {
|
|
1066
|
-
return orders.filter((o) => o.user.email == email).length;
|
|
1067
|
-
}
|
|
1068
|
-
getCouponUseLimits(coupon, checkoutType, user) {
|
|
1069
|
-
let couponUseLimits;
|
|
1070
|
-
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
1071
|
-
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1072
|
-
}
|
|
1073
|
-
else {
|
|
1074
|
-
couponUseLimits = coupon.useLimits.subscription;
|
|
1075
|
-
}
|
|
1076
|
-
return couponUseLimits;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1080
|
-
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
1081
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
|
|
1082
|
-
type: Injectable,
|
|
1083
|
-
args: [{
|
|
1084
|
-
providedIn: 'root',
|
|
1085
|
-
}]
|
|
1086
|
-
}], ctorParameters: function () {
|
|
1087
|
-
return [{ type: undefined, decorators: [{
|
|
1088
|
-
type: Inject,
|
|
1089
|
-
args: ['CouponRepository']
|
|
1090
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
1091
|
-
type: Inject,
|
|
1092
|
-
args: [DEFAULT_SHOP]
|
|
1093
|
-
}] }, { type: undefined, decorators: [{
|
|
1094
|
-
type: Inject,
|
|
1095
|
-
args: ['OrderRepository']
|
|
1096
|
-
}] }, { type: undefined, decorators: [{
|
|
1097
|
-
type: Inject,
|
|
1098
|
-
args: ['CategoryRepository']
|
|
1099
|
-
}] }];
|
|
1100
|
-
} });
|
|
66
|
+
class GroupInvalidCouponError extends CustomError {
|
|
67
|
+
constructor(errors) {
|
|
68
|
+
super('Many coupon errors throw');
|
|
69
|
+
this.errors = errors;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
1101
72
|
|
|
1102
|
-
class
|
|
1103
|
-
constructor(
|
|
1104
|
-
this.
|
|
1105
|
-
this.
|
|
1106
|
-
this.orderRepository = orderRepository;
|
|
1107
|
-
this.
|
|
1108
|
-
this.
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
73
|
+
class CouponService {
|
|
74
|
+
constructor(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
|
|
75
|
+
this.couponRepository = couponRepository;
|
|
76
|
+
this.defaultShop = defaultShop;
|
|
77
|
+
this.orderRepository = orderRepository;
|
|
78
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
79
|
+
this.categoryRepository = categoryRepository;
|
|
80
|
+
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
81
|
+
}
|
|
82
|
+
checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
|
|
83
|
+
return from(this.couponRepository.find({
|
|
84
|
+
filters: {
|
|
85
|
+
nickname: { operator: Where.EQUALS, value: nickname },
|
|
86
|
+
active: { operator: Where.EQUALS, value: true },
|
|
87
|
+
},
|
|
88
|
+
})).pipe(concatMap((coupons) => this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription)), concatMap((coupon) => this.checkCouponUseAndLimit(coupon, userEmail, checkout)), map((coupon) => this.isValidCoupon(coupon, userEmail)), map((coupon) => coupon));
|
|
89
|
+
}
|
|
90
|
+
checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
|
|
91
|
+
// Caso não ache nenhum cupom, retorna erro
|
|
92
|
+
if (coupons.count < 1) {
|
|
93
|
+
return throwError('Cupom inválido.');
|
|
94
|
+
}
|
|
95
|
+
// Get Primeiro Cupom (o find do repository retorna um array)
|
|
96
|
+
const coupon = coupons.data.shift();
|
|
97
|
+
// Verifica se o cupom é aplicavel na loja
|
|
98
|
+
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
99
|
+
// Cupon não aplicavel a loja retorna erro
|
|
100
|
+
if (!isInShop)
|
|
101
|
+
return throwError('Cupom inválido para loja.');
|
|
102
|
+
// Verifica se o coupon é aplicado no checkout que está sendo realizado
|
|
103
|
+
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
104
|
+
// Cupon não aplicavel ao checkout retorna erro
|
|
105
|
+
if (!isCheckoutType)
|
|
106
|
+
return throwError('Cupom inválido. Erro de checkout.');
|
|
107
|
+
// Verifica se o cupom é ou pode ser aplicado para subscription
|
|
108
|
+
if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
|
|
109
|
+
// Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
|
|
110
|
+
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
111
|
+
return throwError('Cupom inválido para sua assinatura.');
|
|
112
|
+
}
|
|
113
|
+
if (isSubscription)
|
|
114
|
+
return of(coupon);
|
|
115
|
+
// Verifica se possui o valor minimo de compra para utilização do cupom
|
|
116
|
+
const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
|
|
117
|
+
// Se não tem valor mínimo atingido, retorna erro
|
|
118
|
+
if (!hasMinSubTotal)
|
|
119
|
+
return throwError('Valor mínimo não atingido');
|
|
120
|
+
return of(coupon);
|
|
121
|
+
}
|
|
122
|
+
isValidCoupon(coupon, userEmail) {
|
|
123
|
+
// Verifica a data de inicio de validade do cupom
|
|
124
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
|
|
125
|
+
throw new InvalidCouponError('Cupom ainda não liberado.');
|
|
126
|
+
// Verifica a data de validade do cupom
|
|
127
|
+
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
|
|
128
|
+
throw new InvalidCouponError('Cupom expirado.');
|
|
129
|
+
return coupon;
|
|
130
|
+
}
|
|
131
|
+
checkCouponUseAndLimit(coupon, userEmail, checkout) {
|
|
132
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
133
|
+
const orders = yield this.orderRepository.find({
|
|
134
|
+
filters: {
|
|
135
|
+
coupon: { id: coupon.id },
|
|
136
|
+
payment: { status: 'paid' },
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
// orders que usuario ja fez com o cupom
|
|
140
|
+
const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
|
|
141
|
+
// Verifica o limite de uso de cupom por usuario
|
|
142
|
+
if (coupon.useLimitPerUser && ordersUserCoupon.length)
|
|
143
|
+
throw new InvalidCouponError('Limite de uso por usuário atingido.');
|
|
144
|
+
// Verifica o limite de uso geral por usuario
|
|
145
|
+
if (coupon.useLimit && orders.data.length >= coupon.useLimit)
|
|
146
|
+
throw new InvalidCouponError('Limite de uso atingido.');
|
|
147
|
+
const validUser = yield this.userValidationAndSubscriptionStatus(coupon, userEmail);
|
|
148
|
+
if (!validUser)
|
|
149
|
+
throw new InvalidCouponError('Usuário não elegível.');
|
|
150
|
+
const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
|
|
151
|
+
if (!hasProductCategories)
|
|
152
|
+
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
153
|
+
return coupon;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
calcDiscountSubscription(coupon, checkout) {
|
|
157
|
+
//
|
|
158
|
+
let discount = 0;
|
|
159
|
+
if (coupon.type === CouponTypes.ABSOLUTE)
|
|
160
|
+
discount = coupon.discount;
|
|
161
|
+
else if (coupon.type === CouponTypes.PERCENTAGE)
|
|
162
|
+
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
|
|
163
|
+
return of(discount);
|
|
164
|
+
}
|
|
165
|
+
calcDiscountShopping(coupon, checkout) {
|
|
166
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
167
|
+
let discount = 0;
|
|
168
|
+
switch (coupon.type) {
|
|
169
|
+
case CouponTypes.ABSOLUTE: {
|
|
170
|
+
discount = coupon.discount;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case CouponTypes.PERCENTAGE: {
|
|
174
|
+
discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return discount;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
calcShoppingPercentageDiscount(coupon, checkout) {
|
|
182
|
+
var _a;
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
let discount = 0;
|
|
185
|
+
const shop = checkout.shop;
|
|
186
|
+
let lineItensDiscount = [];
|
|
187
|
+
const couponCategories = yield this.getCouponCategoriesId(coupon);
|
|
188
|
+
if (coupon.productsCategories && coupon.productsCategories.length) {
|
|
189
|
+
lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
190
|
+
var _a;
|
|
191
|
+
if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
192
|
+
return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
|
|
193
|
+
}
|
|
194
|
+
return true;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
lineItensDiscount = checkout.lineItems;
|
|
199
|
+
}
|
|
200
|
+
const subTotal = lineItensDiscount.reduce((acc, curr) => {
|
|
201
|
+
var _a, _b, _c;
|
|
202
|
+
return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
|
|
203
|
+
? acc + ((_c = curr.price) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
|
|
204
|
+
: acc + curr.pricePaid * curr.quantity;
|
|
205
|
+
}, 0) || 0;
|
|
206
|
+
discount = subTotal * (coupon.discount / 100);
|
|
207
|
+
return discount;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
hasMinSubTotal(coupon, checkout) {
|
|
211
|
+
var _a;
|
|
212
|
+
if (!coupon.minSubTotalValue)
|
|
213
|
+
return true;
|
|
214
|
+
const shop = checkout.shop;
|
|
215
|
+
let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
|
|
216
|
+
var _a, _b, _c;
|
|
217
|
+
return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
|
|
218
|
+
? acc + ((_c = curr.price) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
|
|
219
|
+
: acc + curr.pricePaid * curr.quantity;
|
|
220
|
+
}, 0)) || 0;
|
|
221
|
+
if (coupon.minSubTotalValue <= subTotal)
|
|
222
|
+
return true;
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
hasProductCategories(coupon, checkout) {
|
|
226
|
+
var _a;
|
|
227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
const couponCategories = yield this.getCouponCategoriesId(coupon);
|
|
232
|
+
const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
|
|
233
|
+
var _a;
|
|
234
|
+
if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
235
|
+
return true;
|
|
236
|
+
return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
|
|
237
|
+
});
|
|
238
|
+
return hasCategories.length ? true : false;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
userValidationAndSubscriptionStatus(coupon, userEmail) {
|
|
242
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
243
|
+
// Verifica se o email do usuário é coorporativo
|
|
244
|
+
if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
|
|
245
|
+
throw new InvalidCouponError('Você não é colaborador.');
|
|
246
|
+
// Verifica se o email do usuário é associado ao cupom de uso por usuario
|
|
247
|
+
if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
|
|
248
|
+
throw new InvalidCouponError('Cupom não é válido para este usuário.');
|
|
249
|
+
const couponRuleSubscription = coupon.exclusivityType === Exclusivities.ACTIVE_SUBSCRIBER ||
|
|
250
|
+
coupon.exclusivityType === Exclusivities.INACTIVE_SUBSCRIBER ||
|
|
251
|
+
coupon.exclusivityType === Exclusivities.NON_SUBSCRIBER;
|
|
252
|
+
if (couponRuleSubscription && userEmail) {
|
|
253
|
+
const sub = yield this.subscriptionRepository
|
|
254
|
+
.find({
|
|
255
|
+
filters: {
|
|
256
|
+
user: {
|
|
257
|
+
email: { operator: Where.EQUALS, value: userEmail },
|
|
258
|
+
},
|
|
259
|
+
},
|
|
260
|
+
})
|
|
261
|
+
.then((sub) => sub.data);
|
|
262
|
+
const activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter((s) => s.status === Status.ACTIVE);
|
|
263
|
+
switch (coupon.exclusivityType) {
|
|
264
|
+
case Exclusivities.ACTIVE_SUBSCRIBER:
|
|
265
|
+
return activeSubs.length > 0;
|
|
266
|
+
case Exclusivities.INACTIVE_SUBSCRIBER:
|
|
267
|
+
return activeSubs.length === 0;
|
|
268
|
+
case Exclusivities.NON_SUBSCRIBER:
|
|
269
|
+
return sub.length === 0;
|
|
270
|
+
default:
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return true;
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
getCouponCategoriesId(coupon) {
|
|
278
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
279
|
+
let couponCategories = [];
|
|
280
|
+
for (let index = 0; index < coupon.productsCategories.length; index++) {
|
|
281
|
+
let c = yield this.categoryRepository.get({
|
|
282
|
+
id: coupon.productsCategories[index],
|
|
283
|
+
});
|
|
284
|
+
couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
|
|
285
|
+
}
|
|
286
|
+
return couponCategories;
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
291
|
+
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
292
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
|
|
293
|
+
type: Injectable,
|
|
294
|
+
args: [{
|
|
295
|
+
providedIn: 'root',
|
|
296
|
+
}]
|
|
297
|
+
}], ctorParameters: function () {
|
|
298
|
+
return [{ type: undefined, decorators: [{
|
|
299
|
+
type: Inject,
|
|
300
|
+
args: ['CouponRepository']
|
|
301
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
302
|
+
type: Inject,
|
|
303
|
+
args: [DEFAULT_SHOP]
|
|
304
|
+
}] }, { type: undefined, decorators: [{
|
|
305
|
+
type: Inject,
|
|
306
|
+
args: ['OrderRepository']
|
|
307
|
+
}] }, { type: undefined, decorators: [{
|
|
308
|
+
type: Inject,
|
|
309
|
+
args: ['SubscriptionRepository']
|
|
310
|
+
}] }, { type: undefined, decorators: [{
|
|
311
|
+
type: Inject,
|
|
312
|
+
args: ['CategoryRepository']
|
|
313
|
+
}] }];
|
|
1161
314
|
} });
|
|
1162
315
|
|
|
1163
|
-
class
|
|
1164
|
-
constructor(
|
|
1165
|
-
this.
|
|
1166
|
-
this.
|
|
1167
|
-
this.
|
|
1168
|
-
this.
|
|
1169
|
-
this.
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
this.
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
});
|
|
1228
|
-
this.getProductPrice = ({ product, isSubscriber, }) => {
|
|
1229
|
-
const info = product.price;
|
|
1230
|
-
if (product.isGift)
|
|
1231
|
-
return 0;
|
|
1232
|
-
return isSubscriber && info.subscriberPrice > 0
|
|
1233
|
-
? Number(info.subscriberPrice.toFixed(2))
|
|
1234
|
-
: Number(info.price.toFixed(2));
|
|
1235
|
-
};
|
|
1236
|
-
this.checkMaxStock = (item, quantity) => {
|
|
1237
|
-
var _a;
|
|
1238
|
-
const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
|
|
1239
|
-
const currentItemAmount = item.quantity || 0;
|
|
1240
|
-
return currentItemAmount + quantity > maxStock;
|
|
1241
|
-
};
|
|
1242
|
-
}
|
|
1243
|
-
addItem(item, quantity = 1) {
|
|
1244
|
-
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)));
|
|
1245
|
-
}
|
|
1246
|
-
decreaseItem(item) {
|
|
1247
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1248
|
-
var _a;
|
|
1249
|
-
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id);
|
|
1250
|
-
if (!isNil(checkoutItem))
|
|
1251
|
-
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
1252
|
-
return checkout;
|
|
1253
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1254
|
-
}
|
|
1255
|
-
getCart(checkout) {
|
|
1256
|
-
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
1257
|
-
return this.cartSubject;
|
|
1258
|
-
}
|
|
1259
|
-
/**
|
|
1260
|
-
* @deprecated The method should not be used
|
|
1261
|
-
*/
|
|
1262
|
-
getVariantPriceDiscount(item) {
|
|
1263
|
-
return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
|
|
1264
|
-
}
|
|
1265
|
-
removeItem(item) {
|
|
1266
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1267
|
-
const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
|
|
1268
|
-
if (index >= 0)
|
|
1269
|
-
checkout.lineItems.splice(index, 1);
|
|
1270
|
-
return checkout;
|
|
1271
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1272
|
-
}
|
|
1273
|
-
updateUserCart(user) {
|
|
1274
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
|
|
1275
|
-
var _a, _b;
|
|
1276
|
-
return this.checkoutService
|
|
1277
|
-
.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)
|
|
1278
|
-
? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; })))
|
|
1279
|
-
: [] })))
|
|
1280
|
-
.toPromise();
|
|
1281
|
-
})), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1282
|
-
}
|
|
1283
|
-
clearCart() {
|
|
1284
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1285
|
-
this.checkoutService.clearCheckoutFromSession();
|
|
1286
|
-
return checkout;
|
|
1287
|
-
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
1288
|
-
}
|
|
1289
|
-
buildCartFromCheckout(checkoutData) {
|
|
1290
|
-
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1291
|
-
}
|
|
1292
|
-
roundPrice(productPrice) {
|
|
1293
|
-
const { price, fullPrice, subscriberPrice } = productPrice;
|
|
1294
|
-
return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
|
|
1295
|
-
}
|
|
1296
|
-
getProductData(productId) {
|
|
1297
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1298
|
-
let product;
|
|
1299
|
-
let variant;
|
|
1300
|
-
try {
|
|
1301
|
-
product = yield this.productRepository.get({ id: productId });
|
|
1302
|
-
}
|
|
1303
|
-
catch (error) {
|
|
1304
|
-
if (!(error instanceof NotFoundError))
|
|
1305
|
-
throw error;
|
|
1306
|
-
const { data: variants } = yield this.variantRepository.find({ filters: { id: productId } });
|
|
1307
|
-
variant = variants.shift();
|
|
1308
|
-
if (!variant)
|
|
1309
|
-
throw error;
|
|
1310
|
-
product = yield this.productRepository.get({ id: variant.productId });
|
|
1311
|
-
}
|
|
1312
|
-
return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
|
|
1313
|
-
});
|
|
1314
|
-
}
|
|
1315
|
-
getGifts() {
|
|
1316
|
-
return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
|
|
1317
|
-
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1318
|
-
if (!notGiftItems.length)
|
|
1319
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: [] });
|
|
1320
|
-
const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1321
|
-
const campaigns = yield this.buy2WinRepository
|
|
1322
|
-
.find({
|
|
1323
|
-
filters: {
|
|
1324
|
-
active: { operator: Where.EQUALS, value: true },
|
|
1325
|
-
shop: { operator: Where.EQUALS, value: this.defaultShop },
|
|
1326
|
-
},
|
|
1327
|
-
})
|
|
1328
|
-
.then((data) => data.data);
|
|
1329
|
-
if (!campaigns.length)
|
|
1330
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1331
|
-
const elegibleCampaigns = [];
|
|
1332
|
-
for (const campaign of campaigns) {
|
|
1333
|
-
const today = new Date().getDate();
|
|
1334
|
-
if (!(campaign.startDate.getDate() <= today) && !(campaign.endDate.getDate() >= today))
|
|
1335
|
-
continue;
|
|
1336
|
-
if (campaign.activeCategory) {
|
|
1337
|
-
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
1338
|
-
const categoriesCampaingFullTree = [];
|
|
1339
|
-
for (const id of categoriesCampaing) {
|
|
1340
|
-
const children = yield this.categoryRepository.getChildren(parseInt(id));
|
|
1341
|
-
categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
|
|
1342
|
-
}
|
|
1343
|
-
const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
|
|
1344
|
-
const filterProductsCategories = checkout.lineItems.filter((l) => {
|
|
1345
|
-
var _a;
|
|
1346
|
-
if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
1347
|
-
return true;
|
|
1348
|
-
return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
|
|
1349
|
-
});
|
|
1350
|
-
if (filterProductsCategories.length) {
|
|
1351
|
-
const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1352
|
-
if (cartTotalCategories >= campaign.cartValueMin)
|
|
1353
|
-
elegibleCampaigns.push(campaign);
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
else {
|
|
1357
|
-
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
1358
|
-
if (campaign.cartValue <= cartTotal)
|
|
1359
|
-
elegibleCampaigns.push(campaign);
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
if (!elegibleCampaigns.length)
|
|
1364
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1365
|
-
const campaingnProducts = [];
|
|
1366
|
-
for (const campaign of elegibleCampaigns) {
|
|
1367
|
-
let elegibleProducts = [];
|
|
1368
|
-
for (const product of campaign.products) {
|
|
1369
|
-
const { data: productData } = yield this.productRepository.find({ filters: { sku: product } });
|
|
1370
|
-
if (!productData.length)
|
|
1371
|
-
continue;
|
|
1372
|
-
const gift = productData.shift();
|
|
1373
|
-
if (gift.stock.quantity < 1)
|
|
1374
|
-
continue;
|
|
1375
|
-
elegibleProducts.push(gift);
|
|
1376
|
-
}
|
|
1377
|
-
campaingnProducts.push(elegibleProducts);
|
|
1378
|
-
}
|
|
1379
|
-
if (!campaingnProducts.length)
|
|
1380
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
|
|
1381
|
-
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
1382
|
-
return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
|
|
1383
|
-
})), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1384
|
-
}
|
|
1385
|
-
giftToLineItems(items) {
|
|
1386
|
-
return items.map((item) => {
|
|
1387
|
-
var _a;
|
|
1388
|
-
const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
|
|
1389
|
-
const image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
|
|
1390
|
-
return LineItem.toInstance({
|
|
1391
|
-
brand,
|
|
1392
|
-
categories,
|
|
1393
|
-
id: id.toString(),
|
|
1394
|
-
name,
|
|
1395
|
-
price,
|
|
1396
|
-
sku,
|
|
1397
|
-
slug,
|
|
1398
|
-
stock,
|
|
1399
|
-
weight,
|
|
1400
|
-
EAN,
|
|
1401
|
-
image,
|
|
1402
|
-
pricePaid: 0,
|
|
1403
|
-
quantity: 1,
|
|
1404
|
-
isGift: true,
|
|
1405
|
-
});
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
}
|
|
1409
|
-
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1410
|
-
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
1411
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
|
|
1412
|
-
type: Injectable
|
|
1413
|
-
}], ctorParameters: function () {
|
|
1414
|
-
return [{ type: AuthService }, { type: CheckoutService }, { type: i1$3.Shops, decorators: [{
|
|
1415
|
-
type: Inject,
|
|
1416
|
-
args: [DEFAULT_SHOP]
|
|
1417
|
-
}] }, { type: undefined, decorators: [{
|
|
1418
|
-
type: Inject,
|
|
1419
|
-
args: ['ProductRepository']
|
|
1420
|
-
}] }, { type: undefined, decorators: [{
|
|
1421
|
-
type: Inject,
|
|
1422
|
-
args: ['CategoryRepository']
|
|
1423
|
-
}] }, { type: undefined, decorators: [{
|
|
1424
|
-
type: Inject,
|
|
1425
|
-
args: ['VariantRepository']
|
|
1426
|
-
}] }, { type: i1$3.Buy2WinFirestoreRepository, decorators: [{
|
|
1427
|
-
type: Inject,
|
|
1428
|
-
args: ['Buy2WinRepository']
|
|
1429
|
-
}] }];
|
|
316
|
+
class CheckoutService {
|
|
317
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
318
|
+
this.couponService = couponService;
|
|
319
|
+
this.checkoutRepository = checkoutRepository;
|
|
320
|
+
this.orderRepository = orderRepository;
|
|
321
|
+
this.userRepository = userRepository;
|
|
322
|
+
this.defaultShop = defaultShop;
|
|
323
|
+
}
|
|
324
|
+
getCheckout(checkoutData) {
|
|
325
|
+
const checkoutId = cookie.get('checkoutId');
|
|
326
|
+
if (!isNil(checkoutId))
|
|
327
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
328
|
+
return from(this.createCheckout(checkoutData));
|
|
329
|
+
}
|
|
330
|
+
getUserByCheckout(checkoutId) {
|
|
331
|
+
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'))));
|
|
332
|
+
}
|
|
333
|
+
updateCheckoutLineItems(checkout) {
|
|
334
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
335
|
+
}
|
|
336
|
+
updateCheckoutUser(checkout) {
|
|
337
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
338
|
+
}
|
|
339
|
+
clearCheckoutFromSession() {
|
|
340
|
+
cookie.remove('checkoutId');
|
|
341
|
+
return of();
|
|
342
|
+
}
|
|
343
|
+
calcDiscount(coupon) {
|
|
344
|
+
return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
|
|
345
|
+
}
|
|
346
|
+
checkCoupon(nickname, checkoutType) {
|
|
347
|
+
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
348
|
+
var _a;
|
|
349
|
+
return this.couponService
|
|
350
|
+
.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
|
|
351
|
+
.pipe();
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
354
|
+
createCheckout(checkoutData) {
|
|
355
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
356
|
+
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 }));
|
|
357
|
+
cookie.set('checkoutId', checkout.id);
|
|
358
|
+
return checkout;
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
363
|
+
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
|
|
364
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
|
|
365
|
+
type: Injectable
|
|
366
|
+
}], ctorParameters: function () {
|
|
367
|
+
return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
368
|
+
type: Inject,
|
|
369
|
+
args: ['CheckoutRepository']
|
|
370
|
+
}] }, { type: undefined, decorators: [{
|
|
371
|
+
type: Inject,
|
|
372
|
+
args: ['OrderRepository']
|
|
373
|
+
}] }, { type: undefined, decorators: [{
|
|
374
|
+
type: Inject,
|
|
375
|
+
args: ['UserRepository']
|
|
376
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
377
|
+
type: Inject,
|
|
378
|
+
args: [DEFAULT_SHOP]
|
|
379
|
+
}] }];
|
|
1430
380
|
} });
|
|
1431
381
|
|
|
1432
|
-
class
|
|
1433
|
-
constructor(
|
|
1434
|
-
this.
|
|
1435
|
-
this.
|
|
1436
|
-
this.
|
|
1437
|
-
this.
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
if (
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
return
|
|
1460
|
-
};
|
|
1461
|
-
this.
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
382
|
+
class CartService {
|
|
383
|
+
constructor(authService, checkoutService, defaultShop, productRepository) {
|
|
384
|
+
this.authService = authService;
|
|
385
|
+
this.checkoutService = checkoutService;
|
|
386
|
+
this.defaultShop = defaultShop;
|
|
387
|
+
this.productRepository = productRepository;
|
|
388
|
+
this.cartSubject = new Subject();
|
|
389
|
+
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
390
|
+
var _a;
|
|
391
|
+
const items = [];
|
|
392
|
+
const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
|
|
393
|
+
if (index > -1) {
|
|
394
|
+
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
395
|
+
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
396
|
+
}
|
|
397
|
+
else
|
|
398
|
+
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
399
|
+
return this.checkoutService
|
|
400
|
+
.updateCheckoutLineItems(checkoutLoaded)
|
|
401
|
+
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
402
|
+
}));
|
|
403
|
+
this.generateCartObject = (items) => {
|
|
404
|
+
const cart = {};
|
|
405
|
+
items === null || items === void 0 ? void 0 : items.forEach((item) => {
|
|
406
|
+
var _a;
|
|
407
|
+
return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
|
|
408
|
+
});
|
|
409
|
+
return cart;
|
|
410
|
+
};
|
|
411
|
+
this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
|
|
412
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
413
|
+
const product = yield this.productRepository.get({ id: item.id });
|
|
414
|
+
item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
415
|
+
if (this.checkMaxStock(item, quantity || 0))
|
|
416
|
+
throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
|
|
417
|
+
const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
|
|
418
|
+
const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
|
|
419
|
+
const isGift = item.isGift || null;
|
|
420
|
+
const pricePaid = this.getProductPrice({
|
|
421
|
+
product: item,
|
|
422
|
+
shop: checkout.shop || this.defaultShop,
|
|
423
|
+
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
424
|
+
});
|
|
425
|
+
return {
|
|
426
|
+
checkout,
|
|
427
|
+
lineItem: LineItem.toInstance({
|
|
428
|
+
id,
|
|
429
|
+
name: name !== null && name !== void 0 ? name : product.name,
|
|
430
|
+
EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
|
|
431
|
+
brand: product.brand,
|
|
432
|
+
slug: slug !== null && slug !== void 0 ? slug : product.slug,
|
|
433
|
+
sku: sku !== null && sku !== void 0 ? sku : product.sku,
|
|
434
|
+
stock,
|
|
435
|
+
price,
|
|
436
|
+
image,
|
|
437
|
+
weight: weight !== null && weight !== void 0 ? weight : product.weight,
|
|
438
|
+
quantity: (item.quantity || 0) + (quantity || 0),
|
|
439
|
+
pricePaid,
|
|
440
|
+
categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
|
|
441
|
+
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
442
|
+
costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
|
|
443
|
+
type,
|
|
444
|
+
}),
|
|
445
|
+
};
|
|
446
|
+
});
|
|
447
|
+
this.getProductPrice = ({ product, isSubscriber, }) => {
|
|
448
|
+
const info = product.price;
|
|
449
|
+
if (product.isGift)
|
|
450
|
+
return 0;
|
|
451
|
+
return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
|
|
452
|
+
};
|
|
453
|
+
this.checkMaxStock = (item, quantity) => {
|
|
454
|
+
var _a;
|
|
455
|
+
const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
|
|
456
|
+
const currentItemAmount = item.quantity || 0;
|
|
457
|
+
return currentItemAmount + quantity > maxStock;
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
addItem(item, quantity = 1) {
|
|
461
|
+
return from(this.checkoutService.getCheckout()).pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.buildLineItem({ checkout, item, quantity: quantity || 1 }); })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
|
|
462
|
+
}
|
|
463
|
+
decreaseItem(item) {
|
|
464
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
465
|
+
var _a;
|
|
466
|
+
const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
|
|
467
|
+
if (!isNil(checkoutItem))
|
|
468
|
+
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
469
|
+
return checkout;
|
|
470
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
471
|
+
}
|
|
472
|
+
getCart(checkout) {
|
|
473
|
+
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
474
|
+
return this.cartSubject;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* @deprecated The method should not be used
|
|
478
|
+
*/
|
|
479
|
+
getVariantPriceDiscount(item) {
|
|
480
|
+
return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
|
|
481
|
+
}
|
|
482
|
+
removeItem(item) {
|
|
483
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
484
|
+
const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
|
|
485
|
+
if (index >= 0)
|
|
486
|
+
checkout.lineItems.splice(index, 1);
|
|
487
|
+
return checkout;
|
|
488
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
489
|
+
}
|
|
490
|
+
updateUserCart(user) {
|
|
491
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
|
|
492
|
+
var _a, _b;
|
|
493
|
+
return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length) ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; }))) : [] }))).toPromise();
|
|
494
|
+
})), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
495
|
+
}
|
|
496
|
+
clearCart() {
|
|
497
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
498
|
+
this.checkoutService.clearCheckoutFromSession();
|
|
499
|
+
return checkout;
|
|
500
|
+
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
501
|
+
}
|
|
502
|
+
buildCartFromCheckout(checkoutData) {
|
|
503
|
+
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
507
|
+
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
508
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
|
|
509
|
+
type: Injectable
|
|
510
|
+
}], ctorParameters: function () {
|
|
511
|
+
return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
|
|
512
|
+
type: Inject,
|
|
513
|
+
args: [DEFAULT_SHOP]
|
|
514
|
+
}] }, { type: undefined, decorators: [{
|
|
515
|
+
type: Inject,
|
|
516
|
+
args: ['ProductRepository']
|
|
517
|
+
}] }];
|
|
1520
518
|
} });
|
|
1521
519
|
|
|
1522
|
-
class
|
|
1523
|
-
constructor(
|
|
1524
|
-
this.
|
|
1525
|
-
this.
|
|
1526
|
-
this.
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
return
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
i0.ɵɵ
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
args: ['CategoryFilterRepository']
|
|
1565
|
-
}] }, { type: undefined, decorators: [{
|
|
1566
|
-
type: Inject,
|
|
1567
|
-
args: [CATEGORY_STRUCTURE]
|
|
1568
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
1569
|
-
type: Inject,
|
|
1570
|
-
args: [DEFAULT_SHOP]
|
|
1571
|
-
}] }];
|
|
520
|
+
class CheckoutSubscriptionService {
|
|
521
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
522
|
+
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
523
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
524
|
+
this.couponService = couponService;
|
|
525
|
+
}
|
|
526
|
+
getCheckoutSubscription(checkoutData) {
|
|
527
|
+
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
528
|
+
if (!isNil(checkoutId))
|
|
529
|
+
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
530
|
+
return from(this.createCheckoutSubscription(checkoutData));
|
|
531
|
+
}
|
|
532
|
+
createCheckoutSubscription(checkoutData) {
|
|
533
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
534
|
+
const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
|
|
535
|
+
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
536
|
+
return checkout;
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
clearCheckoutSubscriptionFromSession() {
|
|
540
|
+
cookie.remove('checkoutSubscriptionId');
|
|
541
|
+
return of();
|
|
542
|
+
}
|
|
543
|
+
checkCoupon(nickname, userEmail) {
|
|
544
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
|
|
545
|
+
}
|
|
546
|
+
calcDiscountSubscription(coupon) {
|
|
547
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
551
|
+
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
|
|
552
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
553
|
+
type: Injectable
|
|
554
|
+
}], ctorParameters: function () {
|
|
555
|
+
return [{ type: undefined, decorators: [{
|
|
556
|
+
type: Inject,
|
|
557
|
+
args: ['CheckoutSubscriptionRepository']
|
|
558
|
+
}] }, { type: undefined, decorators: [{
|
|
559
|
+
type: Inject,
|
|
560
|
+
args: ['SubscriptionRepository']
|
|
561
|
+
}] }, { type: CouponService }];
|
|
1572
562
|
} });
|
|
1573
563
|
|
|
1574
|
-
|
|
1575
|
-
(
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
this.couponService = couponService;
|
|
1597
|
-
}
|
|
1598
|
-
getCheckoutSubscription(checkoutData) {
|
|
1599
|
-
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
1600
|
-
if (!isNil(checkoutId))
|
|
1601
|
-
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
1602
|
-
return from(this.createCheckoutSubscription(checkoutData));
|
|
1603
|
-
}
|
|
1604
|
-
createCheckoutSubscription(checkoutData) {
|
|
1605
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1606
|
-
const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
|
|
1607
|
-
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
1608
|
-
return checkout;
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
clearCheckoutSubscriptionFromSession() {
|
|
1612
|
-
cookie.remove('checkoutSubscriptionId');
|
|
1613
|
-
return of();
|
|
1614
|
-
}
|
|
1615
|
-
checkCoupon(nickname, userEmail) {
|
|
1616
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
1617
|
-
.checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
|
|
1618
|
-
.pipe()));
|
|
1619
|
-
}
|
|
1620
|
-
calcDiscountSubscription(coupon) {
|
|
1621
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1625
|
-
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
|
|
1626
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
1627
|
-
type: Injectable
|
|
1628
|
-
}], ctorParameters: function () {
|
|
1629
|
-
return [{ type: undefined, decorators: [{
|
|
1630
|
-
type: Inject,
|
|
1631
|
-
args: ['CheckoutSubscriptionRepository']
|
|
1632
|
-
}] }, { type: undefined, decorators: [{
|
|
1633
|
-
type: Inject,
|
|
1634
|
-
args: ['SubscriptionRepository']
|
|
1635
|
-
}] }, { type: CouponService }];
|
|
564
|
+
class OrderService {
|
|
565
|
+
constructor(angularFirestore, orderRepository) {
|
|
566
|
+
this.angularFirestore = angularFirestore;
|
|
567
|
+
this.orderRepository = orderRepository;
|
|
568
|
+
this.orderSubject = new Subject();
|
|
569
|
+
}
|
|
570
|
+
getOrder(id) {
|
|
571
|
+
docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
|
|
572
|
+
.pipe(map((doc) => Order.toInstance(doc.data())))
|
|
573
|
+
.subscribe((doc) => this.orderSubject.next(doc));
|
|
574
|
+
return this.orderSubject;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
578
|
+
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
|
|
579
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
|
|
580
|
+
type: Injectable
|
|
581
|
+
}], ctorParameters: function () {
|
|
582
|
+
return [{ type: i1$1.Firestore }, { type: i2.OrderFirestoreRepository, decorators: [{
|
|
583
|
+
type: Inject,
|
|
584
|
+
args: ['OrderRepository']
|
|
585
|
+
}] }];
|
|
1636
586
|
} });
|
|
1637
587
|
|
|
1638
|
-
class HomeShopService {
|
|
1639
|
-
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
1640
|
-
this.categoryRepository = categoryRepository;
|
|
1641
|
-
this.homeRepository = homeRepository;
|
|
1642
|
-
this.productRepository = productRepository;
|
|
1643
|
-
this.defaultShop = defaultShop;
|
|
1644
|
-
this.buildCategoryGroupWithRequiredData = (group) => {
|
|
1645
|
-
var _a, _b;
|
|
1646
|
-
return ({
|
|
1647
|
-
category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
1648
|
-
products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
|
|
1649
|
-
'id',
|
|
1650
|
-
'price',
|
|
1651
|
-
'reviews',
|
|
1652
|
-
'hasVariants',
|
|
1653
|
-
'slug',
|
|
1654
|
-
'sku',
|
|
1655
|
-
'stock',
|
|
1656
|
-
'costPrice',
|
|
1657
|
-
'images',
|
|
1658
|
-
'miniatures',
|
|
1659
|
-
'name',
|
|
1660
|
-
'weight',
|
|
1661
|
-
'rate',
|
|
1662
|
-
'type',
|
|
1663
|
-
])))) || [],
|
|
1664
|
-
});
|
|
1665
|
-
};
|
|
1666
|
-
}
|
|
1667
|
-
get homeId() {
|
|
1668
|
-
if (this.defaultShop === Shops.GLAMSHOP)
|
|
1669
|
-
return 'glamshop';
|
|
1670
|
-
if (this.defaultShop === Shops.MENSMARKET)
|
|
1671
|
-
return 'mens_market';
|
|
1672
|
-
return null;
|
|
1673
|
-
}
|
|
1674
|
-
getHomeData() {
|
|
1675
|
-
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
|
|
1676
|
-
? of(home)
|
|
1677
|
-
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
1678
|
-
discoverProducts,
|
|
1679
|
-
featuredProducts,
|
|
1680
|
-
verticalProducts,
|
|
1681
|
-
})), concatMap((data) => this.saveHomeData(data)))));
|
|
1682
|
-
}
|
|
1683
|
-
getBanners(type) {
|
|
1684
|
-
return this.getHomeConfiguration().pipe(map((home) => {
|
|
1685
|
-
if (type === 'brand')
|
|
1686
|
-
return home.brandsCarousel;
|
|
1687
|
-
if (type === 'buyToWin')
|
|
1688
|
-
return [home.buyToWinBanner];
|
|
1689
|
-
if (type === 'block')
|
|
1690
|
-
return home.blockBanners;
|
|
1691
|
-
if (type === 'blog')
|
|
1692
|
-
return [home.blogBanner];
|
|
1693
|
-
return [];
|
|
1694
|
-
}));
|
|
1695
|
-
}
|
|
1696
|
-
getMinValueForFreeShipping() {
|
|
1697
|
-
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
1698
|
-
}
|
|
1699
|
-
getDiscoverProducts() {
|
|
1700
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
1701
|
-
}
|
|
1702
|
-
getFeaturedProducts() {
|
|
1703
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
1704
|
-
}
|
|
1705
|
-
getVerticalProducts() {
|
|
1706
|
-
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({
|
|
1707
|
-
filters: { categories: { operator: Where.IN, value: [category.id] } },
|
|
1708
|
-
limits: { limit: 12 },
|
|
1709
|
-
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
1710
|
-
}
|
|
1711
|
-
getHomeConfiguration() {
|
|
1712
|
-
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
1713
|
-
? of(home)
|
|
1714
|
-
: !this.homeId
|
|
1715
|
-
? throwError(new RequiredArgumentError(['homeId']))
|
|
1716
|
-
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
1717
|
-
}
|
|
1718
|
-
saveHomeData(homeData) {
|
|
1719
|
-
const data = {
|
|
1720
|
-
createdAt: new Date(),
|
|
1721
|
-
expiresAt: add(new Date(), { hours: 1 }),
|
|
1722
|
-
data: homeData,
|
|
1723
|
-
};
|
|
1724
|
-
return from(this.homeRepository.update({
|
|
1725
|
-
id: this.homeId,
|
|
1726
|
-
data,
|
|
1727
|
-
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
1728
|
-
}
|
|
1729
|
-
}
|
|
1730
|
-
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1731
|
-
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
|
|
1732
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
|
|
1733
|
-
type: Injectable
|
|
1734
|
-
}], ctorParameters: function () {
|
|
1735
|
-
return [{ type: undefined, decorators: [{
|
|
1736
|
-
type: Inject,
|
|
1737
|
-
args: ['CategoryRepository']
|
|
1738
|
-
}] }, { type: undefined, decorators: [{
|
|
1739
|
-
type: Inject,
|
|
1740
|
-
args: ['HomeRepository']
|
|
1741
|
-
}] }, { type: undefined, decorators: [{
|
|
1742
|
-
type: Inject,
|
|
1743
|
-
args: ['ProductRepository']
|
|
1744
|
-
}] }, { type:
|
|
1745
|
-
type: Inject,
|
|
1746
|
-
args: [DEFAULT_SHOP]
|
|
1747
|
-
}] }];
|
|
588
|
+
class HomeShopService {
|
|
589
|
+
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
590
|
+
this.categoryRepository = categoryRepository;
|
|
591
|
+
this.homeRepository = homeRepository;
|
|
592
|
+
this.productRepository = productRepository;
|
|
593
|
+
this.defaultShop = defaultShop;
|
|
594
|
+
this.buildCategoryGroupWithRequiredData = (group) => {
|
|
595
|
+
var _a, _b;
|
|
596
|
+
return ({
|
|
597
|
+
category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
598
|
+
products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
|
|
599
|
+
'id',
|
|
600
|
+
'price',
|
|
601
|
+
'reviews',
|
|
602
|
+
'hasVariants',
|
|
603
|
+
'slug',
|
|
604
|
+
'sku',
|
|
605
|
+
'stock',
|
|
606
|
+
'costPrice',
|
|
607
|
+
'images',
|
|
608
|
+
'miniatures',
|
|
609
|
+
'name',
|
|
610
|
+
'weight',
|
|
611
|
+
'rate',
|
|
612
|
+
'type',
|
|
613
|
+
])))) || [],
|
|
614
|
+
});
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
get homeId() {
|
|
618
|
+
if (this.defaultShop === Shops.GLAMSHOP)
|
|
619
|
+
return 'glamshop';
|
|
620
|
+
if (this.defaultShop === Shops.MENSMARKET)
|
|
621
|
+
return 'mens_market';
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
624
|
+
getHomeData() {
|
|
625
|
+
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
|
|
626
|
+
? of(home)
|
|
627
|
+
: forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
628
|
+
discoverProducts,
|
|
629
|
+
featuredProducts,
|
|
630
|
+
verticalProducts,
|
|
631
|
+
})), concatMap((data) => this.saveHomeData(data)))));
|
|
632
|
+
}
|
|
633
|
+
getBanners(type) {
|
|
634
|
+
return this.getHomeConfiguration().pipe(map((home) => {
|
|
635
|
+
if (type === 'brand')
|
|
636
|
+
return home.brandsCarousel;
|
|
637
|
+
if (type === 'buyToWin')
|
|
638
|
+
return [home.buyToWinBanner];
|
|
639
|
+
if (type === 'block')
|
|
640
|
+
return home.blockBanners;
|
|
641
|
+
if (type === 'blog')
|
|
642
|
+
return [home.blogBanner];
|
|
643
|
+
return [];
|
|
644
|
+
}));
|
|
645
|
+
}
|
|
646
|
+
getMinValueForFreeShipping() {
|
|
647
|
+
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
648
|
+
}
|
|
649
|
+
getDiscoverProducts() {
|
|
650
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
651
|
+
}
|
|
652
|
+
getFeaturedProducts() {
|
|
653
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
654
|
+
}
|
|
655
|
+
getVerticalProducts() {
|
|
656
|
+
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({
|
|
657
|
+
filters: { categories: { operator: Where.IN, value: [category.id] } },
|
|
658
|
+
limits: { limit: 12 },
|
|
659
|
+
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
660
|
+
}
|
|
661
|
+
getHomeConfiguration() {
|
|
662
|
+
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
663
|
+
? of(home)
|
|
664
|
+
: !this.homeId
|
|
665
|
+
? throwError(new RequiredArgumentError(['homeId']))
|
|
666
|
+
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
667
|
+
}
|
|
668
|
+
saveHomeData(homeData) {
|
|
669
|
+
const data = {
|
|
670
|
+
createdAt: new Date(),
|
|
671
|
+
expiresAt: add(new Date(), { hours: 1 }),
|
|
672
|
+
data: homeData,
|
|
673
|
+
};
|
|
674
|
+
return from(this.homeRepository.update({
|
|
675
|
+
id: this.homeId,
|
|
676
|
+
data,
|
|
677
|
+
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
681
|
+
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
|
|
682
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
|
|
683
|
+
type: Injectable
|
|
684
|
+
}], ctorParameters: function () {
|
|
685
|
+
return [{ type: undefined, decorators: [{
|
|
686
|
+
type: Inject,
|
|
687
|
+
args: ['CategoryRepository']
|
|
688
|
+
}] }, { type: undefined, decorators: [{
|
|
689
|
+
type: Inject,
|
|
690
|
+
args: ['HomeRepository']
|
|
691
|
+
}] }, { type: undefined, decorators: [{
|
|
692
|
+
type: Inject,
|
|
693
|
+
args: ['ProductRepository']
|
|
694
|
+
}] }, { type: i2.Shops, decorators: [{
|
|
695
|
+
type: Inject,
|
|
696
|
+
args: [DEFAULT_SHOP]
|
|
697
|
+
}] }];
|
|
1748
698
|
} });
|
|
1749
699
|
|
|
1750
|
-
class
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
700
|
+
class AngularFirebaseAuthModule {
|
|
701
|
+
static initializeApp(options, nameOrConfig) {
|
|
702
|
+
return {
|
|
703
|
+
ngModule: AngularFirebaseAuthModule,
|
|
704
|
+
providers: [
|
|
705
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
706
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
707
|
+
],
|
|
708
|
+
};
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
712
|
+
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1$2.FirebaseAppModule, i1.AuthModule] });
|
|
713
|
+
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
714
|
+
{
|
|
715
|
+
provide: 'Authentication',
|
|
716
|
+
useFactory: (authenticationService, userRepository) => {
|
|
717
|
+
return new Authentication(authenticationService, userRepository);
|
|
718
|
+
},
|
|
719
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
720
|
+
},
|
|
721
|
+
{
|
|
722
|
+
provide: 'AuthenticationService',
|
|
723
|
+
useFactory: (angularFireAuth) => {
|
|
724
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
725
|
+
},
|
|
726
|
+
deps: [Auth],
|
|
727
|
+
},
|
|
728
|
+
{
|
|
729
|
+
provide: 'Register',
|
|
730
|
+
useFactory: (registerService, userRepository) => {
|
|
731
|
+
return new Register(registerService, userRepository);
|
|
732
|
+
},
|
|
733
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
provide: 'RegisterService',
|
|
737
|
+
useFactory: (angularFireAuth) => {
|
|
738
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
739
|
+
},
|
|
740
|
+
deps: [Auth],
|
|
741
|
+
},
|
|
742
|
+
{
|
|
743
|
+
provide: 'SignOut',
|
|
744
|
+
useFactory: (authenticationService) => {
|
|
745
|
+
return new SignOut(authenticationService);
|
|
746
|
+
},
|
|
747
|
+
deps: ['AuthenticationService'],
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
provide: 'RecoveryPassword',
|
|
751
|
+
useFactory: (authenticationService) => {
|
|
752
|
+
return new RecoveryPassword(authenticationService);
|
|
753
|
+
},
|
|
754
|
+
deps: ['AuthenticationService'],
|
|
755
|
+
},
|
|
756
|
+
], imports: [provideFirebaseApp((injector) => {
|
|
757
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
758
|
+
return appName
|
|
759
|
+
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
760
|
+
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
761
|
+
}),
|
|
762
|
+
provideAuth(() => getAuth())] });
|
|
763
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
764
|
+
type: NgModule,
|
|
765
|
+
args: [{
|
|
766
|
+
imports: [
|
|
767
|
+
provideFirebaseApp((injector) => {
|
|
768
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
769
|
+
return appName
|
|
770
|
+
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
771
|
+
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
772
|
+
}),
|
|
773
|
+
provideAuth(() => getAuth()),
|
|
774
|
+
],
|
|
775
|
+
providers: [
|
|
776
|
+
{
|
|
777
|
+
provide: 'Authentication',
|
|
778
|
+
useFactory: (authenticationService, userRepository) => {
|
|
779
|
+
return new Authentication(authenticationService, userRepository);
|
|
780
|
+
},
|
|
781
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
provide: 'AuthenticationService',
|
|
785
|
+
useFactory: (angularFireAuth) => {
|
|
786
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
787
|
+
},
|
|
788
|
+
deps: [Auth],
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
provide: 'Register',
|
|
792
|
+
useFactory: (registerService, userRepository) => {
|
|
793
|
+
return new Register(registerService, userRepository);
|
|
794
|
+
},
|
|
795
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
796
|
+
},
|
|
797
|
+
{
|
|
798
|
+
provide: 'RegisterService',
|
|
799
|
+
useFactory: (angularFireAuth) => {
|
|
800
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
801
|
+
},
|
|
802
|
+
deps: [Auth],
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
provide: 'SignOut',
|
|
806
|
+
useFactory: (authenticationService) => {
|
|
807
|
+
return new SignOut(authenticationService);
|
|
808
|
+
},
|
|
809
|
+
deps: ['AuthenticationService'],
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
provide: 'RecoveryPassword',
|
|
813
|
+
useFactory: (authenticationService) => {
|
|
814
|
+
return new RecoveryPassword(authenticationService);
|
|
815
|
+
},
|
|
816
|
+
deps: ['AuthenticationService'],
|
|
817
|
+
},
|
|
818
|
+
],
|
|
819
|
+
}]
|
|
820
|
+
}] });
|
|
1773
821
|
|
|
1774
|
-
class
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
1808
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
1809
|
-
if (s.serviceName == 'Same Day')
|
|
1810
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
1811
|
-
else
|
|
1812
|
-
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
1813
|
-
});
|
|
1814
|
-
}
|
|
1815
|
-
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
1816
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
1817
|
-
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
1818
|
-
});
|
|
1819
|
-
}
|
|
1820
|
-
return shippingMethods;
|
|
1821
|
-
}));
|
|
1822
|
-
}
|
|
1823
|
-
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
1824
|
-
if (!subscriptionPlan)
|
|
1825
|
-
return false;
|
|
1826
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
|
|
1827
|
-
return true;
|
|
1828
|
-
return false;
|
|
1829
|
-
}
|
|
1830
|
-
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
1831
|
-
if (!subscriptionPlan)
|
|
1832
|
-
return false;
|
|
1833
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
1834
|
-
return true;
|
|
1835
|
-
}
|
|
1836
|
-
return false;
|
|
1837
|
-
}
|
|
1838
|
-
isHolidays(datas) {
|
|
1839
|
-
const today = new Date();
|
|
1840
|
-
for (const key in datas) {
|
|
1841
|
-
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
1842
|
-
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
1843
|
-
if (start > end)
|
|
1844
|
-
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
1845
|
-
if (today >= start && today <= end)
|
|
1846
|
-
return true;
|
|
1847
|
-
}
|
|
1848
|
-
return false;
|
|
1849
|
-
}
|
|
1850
|
-
}
|
|
1851
|
-
ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$4.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1852
|
-
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
|
|
1853
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
|
|
1854
|
-
type: Injectable
|
|
1855
|
-
}], ctorParameters: function () {
|
|
1856
|
-
return [{ type: i1$4.HttpClient }, { type: undefined, decorators: [{
|
|
1857
|
-
type: Inject,
|
|
1858
|
-
args: [BACKEND_URL]
|
|
1859
|
-
}] }, { type: HomeShopService }];
|
|
1860
|
-
} });
|
|
822
|
+
class AngularElasticSeachModule {
|
|
823
|
+
static initializeApp(options) {
|
|
824
|
+
return {
|
|
825
|
+
ngModule: AngularElasticSeachModule,
|
|
826
|
+
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
831
|
+
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
|
|
832
|
+
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
833
|
+
{
|
|
834
|
+
provide: ProductsIndex,
|
|
835
|
+
useFactory: (configuration) => {
|
|
836
|
+
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
837
|
+
},
|
|
838
|
+
deps: [ES_CONFIG],
|
|
839
|
+
},
|
|
840
|
+
] });
|
|
841
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
842
|
+
type: NgModule,
|
|
843
|
+
args: [{
|
|
844
|
+
providers: [
|
|
845
|
+
{
|
|
846
|
+
provide: ProductsIndex,
|
|
847
|
+
useFactory: (configuration) => {
|
|
848
|
+
return new ProductsIndex(new AxiosAdapter(configuration));
|
|
849
|
+
},
|
|
850
|
+
deps: [ES_CONFIG],
|
|
851
|
+
},
|
|
852
|
+
],
|
|
853
|
+
}]
|
|
854
|
+
}] });
|
|
1861
855
|
|
|
1862
|
-
class
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
856
|
+
class AngularFirestoreModule {
|
|
857
|
+
static initializeApp(options, nameOrConfig) {
|
|
858
|
+
return {
|
|
859
|
+
ngModule: AngularFirestoreModule,
|
|
860
|
+
providers: [
|
|
861
|
+
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
862
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
863
|
+
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
864
|
+
],
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
869
|
+
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$2.FirebaseAppModule, i1$1.FirestoreModule] });
|
|
870
|
+
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
871
|
+
{
|
|
872
|
+
provide: 'BeautyProfileRepository',
|
|
873
|
+
useFactory: (firestore, userRepository) => {
|
|
874
|
+
return new UserBeautyProfileFirestoreRepository(firestore, userRepository);
|
|
875
|
+
},
|
|
876
|
+
deps: [Firestore, 'UserRepository'],
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
provide: 'Buy2WinRepository',
|
|
880
|
+
useFactory: (firestore) => {
|
|
881
|
+
return new Buy2WinFirestoreRepository(firestore);
|
|
882
|
+
},
|
|
883
|
+
deps: [Firestore],
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
provide: CategoryFirestoreRepository,
|
|
887
|
+
useFactory: (firestore) => {
|
|
888
|
+
return new CategoryFirestoreRepository(firestore);
|
|
889
|
+
},
|
|
890
|
+
deps: [Firestore],
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
provide: 'CheckoutRepository',
|
|
894
|
+
useFactory: (firestore) => {
|
|
895
|
+
return new CheckoutFirestoreRepository(firestore);
|
|
896
|
+
},
|
|
897
|
+
deps: [Firestore],
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
901
|
+
useFactory: (firestore) => {
|
|
902
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore);
|
|
903
|
+
},
|
|
904
|
+
deps: [Firestore],
|
|
905
|
+
},
|
|
906
|
+
{
|
|
907
|
+
provide: 'CouponRepository',
|
|
908
|
+
useFactory: (firestore) => {
|
|
909
|
+
return new CouponFirestoreRepository(firestore);
|
|
910
|
+
},
|
|
911
|
+
deps: [Firestore],
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
provide: 'EditionRepository',
|
|
915
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
916
|
+
return new SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
|
|
917
|
+
},
|
|
918
|
+
deps: [Firestore, 'SubscriptionRepository'],
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
provide: 'HomeRepository',
|
|
922
|
+
useFactory: (firestore) => {
|
|
923
|
+
return new HomeFirestoreRepository(firestore);
|
|
924
|
+
},
|
|
925
|
+
deps: [Firestore],
|
|
926
|
+
},
|
|
927
|
+
{
|
|
928
|
+
provide: 'LeadRepository',
|
|
929
|
+
useFactory: (firestore) => {
|
|
930
|
+
return new LeadFirestoreRepository(firestore);
|
|
931
|
+
},
|
|
932
|
+
deps: [Firestore],
|
|
933
|
+
},
|
|
934
|
+
{
|
|
935
|
+
provide: 'LegacyOrderRepository',
|
|
936
|
+
useFactory: (firestore) => {
|
|
937
|
+
return new LegacyOrderFirestoreRepository(firestore);
|
|
938
|
+
},
|
|
939
|
+
deps: [Firestore],
|
|
940
|
+
},
|
|
941
|
+
{
|
|
942
|
+
provide: 'ShopMenuRepository',
|
|
943
|
+
useFactory: (firestore) => {
|
|
944
|
+
return new ShopMenuFirestoreRepository(firestore);
|
|
945
|
+
},
|
|
946
|
+
deps: [Firestore],
|
|
947
|
+
},
|
|
948
|
+
{
|
|
949
|
+
provide: 'OrderRepository',
|
|
950
|
+
useFactory: (firestore) => {
|
|
951
|
+
return new OrderFirestoreRepository(firestore);
|
|
952
|
+
},
|
|
953
|
+
deps: [Firestore],
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
provide: 'PaymentRepository',
|
|
957
|
+
useFactory: (firestore) => {
|
|
958
|
+
return new PaymentFirestoreRepository(firestore);
|
|
959
|
+
},
|
|
960
|
+
deps: [Firestore],
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
provide: ProductFirestoreRepository,
|
|
964
|
+
useFactory: (firestore) => {
|
|
965
|
+
return new ProductFirestoreRepository(firestore);
|
|
966
|
+
},
|
|
967
|
+
deps: [Firestore],
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
provide: 'SubscriptionPaymentRepository',
|
|
971
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
972
|
+
return new SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
|
|
973
|
+
},
|
|
974
|
+
deps: [Firestore, 'SubscriptionRepository'],
|
|
975
|
+
},
|
|
976
|
+
{
|
|
977
|
+
provide: 'SubscriptionPlanRepository',
|
|
978
|
+
useFactory: (firestore) => {
|
|
979
|
+
return new SubscriptionPlanFirestoreRepository(firestore);
|
|
980
|
+
},
|
|
981
|
+
deps: [Firestore],
|
|
982
|
+
},
|
|
983
|
+
{
|
|
984
|
+
provide: 'SubscriptionProductRepository',
|
|
985
|
+
useFactory: (firestore) => {
|
|
986
|
+
return new SubscriptionProductFirestoreRepository(firestore);
|
|
987
|
+
},
|
|
988
|
+
deps: [Firestore],
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
provide: 'SubscriptionRepository',
|
|
992
|
+
useFactory: (firestore) => {
|
|
993
|
+
return new SubscriptionFirestoreRepository(firestore);
|
|
994
|
+
},
|
|
995
|
+
deps: [Firestore],
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
provide: 'UserRepository',
|
|
999
|
+
useFactory: (firestore) => {
|
|
1000
|
+
return new UserFirestoreRepository(firestore);
|
|
1001
|
+
},
|
|
1002
|
+
deps: [Firestore],
|
|
1003
|
+
},
|
|
1004
|
+
{
|
|
1005
|
+
provide: 'UserAddressRepository',
|
|
1006
|
+
useFactory: (firestore, userRepository) => {
|
|
1007
|
+
return new UserAddressFirestoreRepository(firestore, userRepository);
|
|
1008
|
+
},
|
|
1009
|
+
deps: [Firestore, 'UserRepository'],
|
|
1010
|
+
},
|
|
1011
|
+
{
|
|
1012
|
+
provide: 'UserPaymentMethodRepository',
|
|
1013
|
+
useFactory: (firestore, userRepository) => {
|
|
1014
|
+
return new UserPaymentMethodFirestoreRepository(firestore, userRepository);
|
|
1015
|
+
},
|
|
1016
|
+
deps: [Firestore, 'UserRepository'],
|
|
1017
|
+
},
|
|
1018
|
+
{
|
|
1019
|
+
provide: ProductVariantFirestoreRepository,
|
|
1020
|
+
useFactory: (firestore, productRepository) => {
|
|
1021
|
+
return new ProductVariantFirestoreRepository(firestore, productRepository);
|
|
1022
|
+
},
|
|
1023
|
+
deps: [Firestore, ProductFirestoreRepository],
|
|
1024
|
+
},
|
|
1025
|
+
], imports: [AngularElasticSeachModule,
|
|
1026
|
+
provideFirebaseApp((injector) => {
|
|
1027
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
1028
|
+
return appName
|
|
1029
|
+
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
1030
|
+
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
1031
|
+
}),
|
|
1032
|
+
provideFirestore(() => getFirestore())] });
|
|
1033
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
1034
|
+
type: NgModule,
|
|
1035
|
+
args: [{
|
|
1036
|
+
imports: [
|
|
1037
|
+
AngularElasticSeachModule,
|
|
1038
|
+
provideFirebaseApp((injector) => {
|
|
1039
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
1040
|
+
return appName
|
|
1041
|
+
? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
|
|
1042
|
+
: initializeApp(injector.get(FIREBASE_OPTIONS));
|
|
1043
|
+
}),
|
|
1044
|
+
provideFirestore(() => getFirestore()),
|
|
1045
|
+
],
|
|
1046
|
+
providers: [
|
|
1047
|
+
{
|
|
1048
|
+
provide: 'BeautyProfileRepository',
|
|
1049
|
+
useFactory: (firestore, userRepository) => {
|
|
1050
|
+
return new UserBeautyProfileFirestoreRepository(firestore, userRepository);
|
|
1051
|
+
},
|
|
1052
|
+
deps: [Firestore, 'UserRepository'],
|
|
1053
|
+
},
|
|
1054
|
+
{
|
|
1055
|
+
provide: 'Buy2WinRepository',
|
|
1056
|
+
useFactory: (firestore) => {
|
|
1057
|
+
return new Buy2WinFirestoreRepository(firestore);
|
|
1058
|
+
},
|
|
1059
|
+
deps: [Firestore],
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
provide: CategoryFirestoreRepository,
|
|
1063
|
+
useFactory: (firestore) => {
|
|
1064
|
+
return new CategoryFirestoreRepository(firestore);
|
|
1065
|
+
},
|
|
1066
|
+
deps: [Firestore],
|
|
1067
|
+
},
|
|
1068
|
+
{
|
|
1069
|
+
provide: 'CheckoutRepository',
|
|
1070
|
+
useFactory: (firestore) => {
|
|
1071
|
+
return new CheckoutFirestoreRepository(firestore);
|
|
1072
|
+
},
|
|
1073
|
+
deps: [Firestore],
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
1077
|
+
useFactory: (firestore) => {
|
|
1078
|
+
return new CheckoutSubscriptionFirestoreRepository(firestore);
|
|
1079
|
+
},
|
|
1080
|
+
deps: [Firestore],
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
provide: 'CouponRepository',
|
|
1084
|
+
useFactory: (firestore) => {
|
|
1085
|
+
return new CouponFirestoreRepository(firestore);
|
|
1086
|
+
},
|
|
1087
|
+
deps: [Firestore],
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
provide: 'EditionRepository',
|
|
1091
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
1092
|
+
return new SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
|
|
1093
|
+
},
|
|
1094
|
+
deps: [Firestore, 'SubscriptionRepository'],
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
provide: 'HomeRepository',
|
|
1098
|
+
useFactory: (firestore) => {
|
|
1099
|
+
return new HomeFirestoreRepository(firestore);
|
|
1100
|
+
},
|
|
1101
|
+
deps: [Firestore],
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
provide: 'LeadRepository',
|
|
1105
|
+
useFactory: (firestore) => {
|
|
1106
|
+
return new LeadFirestoreRepository(firestore);
|
|
1107
|
+
},
|
|
1108
|
+
deps: [Firestore],
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
provide: 'LegacyOrderRepository',
|
|
1112
|
+
useFactory: (firestore) => {
|
|
1113
|
+
return new LegacyOrderFirestoreRepository(firestore);
|
|
1114
|
+
},
|
|
1115
|
+
deps: [Firestore],
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
provide: 'ShopMenuRepository',
|
|
1119
|
+
useFactory: (firestore) => {
|
|
1120
|
+
return new ShopMenuFirestoreRepository(firestore);
|
|
1121
|
+
},
|
|
1122
|
+
deps: [Firestore],
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
provide: 'OrderRepository',
|
|
1126
|
+
useFactory: (firestore) => {
|
|
1127
|
+
return new OrderFirestoreRepository(firestore);
|
|
1128
|
+
},
|
|
1129
|
+
deps: [Firestore],
|
|
1130
|
+
},
|
|
1131
|
+
{
|
|
1132
|
+
provide: 'PaymentRepository',
|
|
1133
|
+
useFactory: (firestore) => {
|
|
1134
|
+
return new PaymentFirestoreRepository(firestore);
|
|
1135
|
+
},
|
|
1136
|
+
deps: [Firestore],
|
|
1137
|
+
},
|
|
1138
|
+
{
|
|
1139
|
+
provide: ProductFirestoreRepository,
|
|
1140
|
+
useFactory: (firestore) => {
|
|
1141
|
+
return new ProductFirestoreRepository(firestore);
|
|
1142
|
+
},
|
|
1143
|
+
deps: [Firestore],
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
provide: 'SubscriptionPaymentRepository',
|
|
1147
|
+
useFactory: (firestore, subscriptionRepository) => {
|
|
1148
|
+
return new SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
|
|
1149
|
+
},
|
|
1150
|
+
deps: [Firestore, 'SubscriptionRepository'],
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
provide: 'SubscriptionPlanRepository',
|
|
1154
|
+
useFactory: (firestore) => {
|
|
1155
|
+
return new SubscriptionPlanFirestoreRepository(firestore);
|
|
1156
|
+
},
|
|
1157
|
+
deps: [Firestore],
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
provide: 'SubscriptionProductRepository',
|
|
1161
|
+
useFactory: (firestore) => {
|
|
1162
|
+
return new SubscriptionProductFirestoreRepository(firestore);
|
|
1163
|
+
},
|
|
1164
|
+
deps: [Firestore],
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
provide: 'SubscriptionRepository',
|
|
1168
|
+
useFactory: (firestore) => {
|
|
1169
|
+
return new SubscriptionFirestoreRepository(firestore);
|
|
1170
|
+
},
|
|
1171
|
+
deps: [Firestore],
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
provide: 'UserRepository',
|
|
1175
|
+
useFactory: (firestore) => {
|
|
1176
|
+
return new UserFirestoreRepository(firestore);
|
|
1177
|
+
},
|
|
1178
|
+
deps: [Firestore],
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
provide: 'UserAddressRepository',
|
|
1182
|
+
useFactory: (firestore, userRepository) => {
|
|
1183
|
+
return new UserAddressFirestoreRepository(firestore, userRepository);
|
|
1184
|
+
},
|
|
1185
|
+
deps: [Firestore, 'UserRepository'],
|
|
1186
|
+
},
|
|
1187
|
+
{
|
|
1188
|
+
provide: 'UserPaymentMethodRepository',
|
|
1189
|
+
useFactory: (firestore, userRepository) => {
|
|
1190
|
+
return new UserPaymentMethodFirestoreRepository(firestore, userRepository);
|
|
1191
|
+
},
|
|
1192
|
+
deps: [Firestore, 'UserRepository'],
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
provide: ProductVariantFirestoreRepository,
|
|
1196
|
+
useFactory: (firestore, productRepository) => {
|
|
1197
|
+
return new ProductVariantFirestoreRepository(firestore, productRepository);
|
|
1198
|
+
},
|
|
1199
|
+
deps: [Firestore, ProductFirestoreRepository],
|
|
1200
|
+
},
|
|
1201
|
+
],
|
|
1202
|
+
}]
|
|
1203
|
+
}] });
|
|
1910
1204
|
|
|
1911
|
-
class
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1205
|
+
class AngularHasuraGraphQLModule {
|
|
1206
|
+
static initializeApp(options) {
|
|
1207
|
+
return {
|
|
1208
|
+
ngModule: AngularHasuraGraphQLModule,
|
|
1209
|
+
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1214
|
+
AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
|
|
1215
|
+
AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
|
|
1216
|
+
{
|
|
1217
|
+
provide: 'HasuraConfig',
|
|
1218
|
+
useFactory: (options, platformId) => ({
|
|
1219
|
+
endpoint: options.endpoint,
|
|
1220
|
+
authOptions: options.credentials,
|
|
1221
|
+
interceptors: {
|
|
1222
|
+
request: (request) => {
|
|
1223
|
+
console.log('request', request);
|
|
1224
|
+
if (isPlatformServer(platformId))
|
|
1225
|
+
console.log('request:server', request);
|
|
1226
|
+
},
|
|
1227
|
+
response: (response) => {
|
|
1228
|
+
console.log('response', response);
|
|
1229
|
+
if (isPlatformServer(platformId))
|
|
1230
|
+
console.log('response:server', response);
|
|
1231
|
+
},
|
|
1232
|
+
},
|
|
1233
|
+
}),
|
|
1234
|
+
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
1235
|
+
},
|
|
1236
|
+
{
|
|
1237
|
+
provide: 'CategoryRepository',
|
|
1238
|
+
useExisting: CategoryHasuraGraphQLRepository,
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
provide: CategoryHasuraGraphQLRepository,
|
|
1242
|
+
useFactory: (hasuraConfig, productRepository) => {
|
|
1243
|
+
return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
|
|
1244
|
+
},
|
|
1245
|
+
deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
|
|
1246
|
+
},
|
|
1247
|
+
{
|
|
1248
|
+
provide: 'ProductRepository',
|
|
1249
|
+
useExisting: ProductHasuraGraphQLRepository,
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
provide: ProductHasuraGraphQLRepository,
|
|
1253
|
+
useFactory: (hasuraConfig) => {
|
|
1254
|
+
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
1255
|
+
},
|
|
1256
|
+
deps: ['HasuraConfig'],
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
provide: 'VariantRepository',
|
|
1260
|
+
useExisting: VariantHasuraGraphQLRepository,
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
provide: VariantHasuraGraphQLRepository,
|
|
1264
|
+
useFactory: (hasuraConfig) => {
|
|
1265
|
+
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
1266
|
+
},
|
|
1267
|
+
deps: ['HasuraConfig'],
|
|
1268
|
+
},
|
|
1269
|
+
] });
|
|
1270
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
1271
|
+
type: NgModule,
|
|
1272
|
+
args: [{
|
|
1273
|
+
providers: [
|
|
1274
|
+
{
|
|
1275
|
+
provide: 'HasuraConfig',
|
|
1276
|
+
useFactory: (options, platformId) => ({
|
|
1277
|
+
endpoint: options.endpoint,
|
|
1278
|
+
authOptions: options.credentials,
|
|
1279
|
+
interceptors: {
|
|
1280
|
+
request: (request) => {
|
|
1281
|
+
console.log('request', request);
|
|
1282
|
+
if (isPlatformServer(platformId))
|
|
1283
|
+
console.log('request:server', request);
|
|
1284
|
+
},
|
|
1285
|
+
response: (response) => {
|
|
1286
|
+
console.log('response', response);
|
|
1287
|
+
if (isPlatformServer(platformId))
|
|
1288
|
+
console.log('response:server', response);
|
|
1289
|
+
},
|
|
1290
|
+
},
|
|
1291
|
+
}),
|
|
1292
|
+
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
1293
|
+
},
|
|
1294
|
+
{
|
|
1295
|
+
provide: 'CategoryRepository',
|
|
1296
|
+
useExisting: CategoryHasuraGraphQLRepository,
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
provide: CategoryHasuraGraphQLRepository,
|
|
1300
|
+
useFactory: (hasuraConfig, productRepository) => {
|
|
1301
|
+
return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
|
|
1302
|
+
},
|
|
1303
|
+
deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
provide: 'ProductRepository',
|
|
1307
|
+
useExisting: ProductHasuraGraphQLRepository,
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
provide: ProductHasuraGraphQLRepository,
|
|
1311
|
+
useFactory: (hasuraConfig) => {
|
|
1312
|
+
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
1313
|
+
},
|
|
1314
|
+
deps: ['HasuraConfig'],
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
provide: 'VariantRepository',
|
|
1318
|
+
useExisting: VariantHasuraGraphQLRepository,
|
|
1319
|
+
},
|
|
1320
|
+
{
|
|
1321
|
+
provide: VariantHasuraGraphQLRepository,
|
|
1322
|
+
useFactory: (hasuraConfig) => {
|
|
1323
|
+
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
1324
|
+
},
|
|
1325
|
+
deps: ['HasuraConfig'],
|
|
1326
|
+
},
|
|
1327
|
+
],
|
|
1328
|
+
}]
|
|
1329
|
+
}] });
|
|
1935
1330
|
|
|
1936
|
-
class AngularConnectModule {
|
|
1937
|
-
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
1938
|
-
return {
|
|
1939
|
-
ngModule: AngularConnectModule,
|
|
1940
|
-
providers: [
|
|
1941
|
-
{
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
providers: [
|
|
1976
|
-
AuthService,
|
|
1977
|
-
CartService,
|
|
1978
|
-
CatalogService,
|
|
1979
|
-
CategoryService,
|
|
1980
|
-
CheckoutService,
|
|
1981
|
-
CheckoutSubscriptionService,
|
|
1982
|
-
CouponService,
|
|
1983
|
-
HomeShopService,
|
|
1984
|
-
OrderService,
|
|
1985
|
-
ShippingService,
|
|
1986
|
-
],
|
|
1987
|
-
}]
|
|
1331
|
+
class AngularConnectModule {
|
|
1332
|
+
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
1333
|
+
return {
|
|
1334
|
+
ngModule: AngularConnectModule,
|
|
1335
|
+
providers: [
|
|
1336
|
+
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
1337
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
|
|
1338
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
1339
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
1340
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
1341
|
+
],
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1346
|
+
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
1347
|
+
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
|
|
1348
|
+
AuthService,
|
|
1349
|
+
CartService,
|
|
1350
|
+
CheckoutService,
|
|
1351
|
+
CheckoutSubscriptionService,
|
|
1352
|
+
CouponService,
|
|
1353
|
+
HomeShopService,
|
|
1354
|
+
OrderService,
|
|
1355
|
+
], imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
1356
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
1357
|
+
type: NgModule,
|
|
1358
|
+
args: [{
|
|
1359
|
+
imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
|
|
1360
|
+
providers: [
|
|
1361
|
+
AuthService,
|
|
1362
|
+
CartService,
|
|
1363
|
+
CheckoutService,
|
|
1364
|
+
CheckoutSubscriptionService,
|
|
1365
|
+
CouponService,
|
|
1366
|
+
HomeShopService,
|
|
1367
|
+
OrderService,
|
|
1368
|
+
],
|
|
1369
|
+
}]
|
|
1988
1370
|
}] });
|
|
1989
1371
|
|
|
1990
|
-
/**
|
|
1991
|
-
* Generated bundle index. Do not edit.
|
|
1372
|
+
/**
|
|
1373
|
+
* Generated bundle index. Do not edit.
|
|
1992
1374
|
*/
|
|
1993
1375
|
|
|
1994
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService,
|
|
1376
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService };
|
|
1995
1377
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|