@infrab4a/connect-angular 4.4.1 → 4.4.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/angular-connect.module.d.ts +26 -26
- package/angular-elastic-search.module.d.ts +9 -9
- package/angular-firebase-auth.module.d.ts +11 -11
- package/angular-firestore.module.d.ts +18 -18
- package/angular-hasura-graphql.module.d.ts +16 -16
- package/consts/backend-url.const.d.ts +1 -1
- package/consts/category-structure.d.ts +1 -1
- 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 +7 -7
- package/consts/persistence.const.d.ts +1 -1
- package/consts/storage-base-url.const.d.ts +1 -1
- package/esm2020/angular-connect.module.mjs +115 -115
- package/esm2020/angular-elastic-search.module.mjs +34 -34
- package/esm2020/angular-firebase-auth.module.mjs +115 -115
- package/esm2020/angular-firestore.module.mjs +504 -504
- package/esm2020/angular-hasura-graphql.module.mjs +265 -265
- package/esm2020/consts/backend-url.const.mjs +1 -1
- package/esm2020/consts/category-structure.mjs +2 -2
- 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 +8 -8
- package/esm2020/consts/persistence.const.mjs +2 -2
- package/esm2020/consts/storage-base-url.const.mjs +2 -2
- package/esm2020/helpers/index.mjs +2 -2
- package/esm2020/helpers/mobile-operation-system-checker.helper.mjs +7 -7
- package/esm2020/index.mjs +7 -7
- package/esm2020/infrab4a-connect-angular.mjs +4 -4
- package/esm2020/persistence/cookie-data-persistence.mjs +22 -22
- package/esm2020/persistence/data-persistence.mjs +2 -2
- package/esm2020/persistence/index.mjs +3 -3
- package/esm2020/services/auth.service.mjs +37 -37
- package/esm2020/services/cart.service.mjs +282 -282
- package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +2 -2
- package/esm2020/services/catalog/adapters/index.mjs +4 -4
- package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +43 -43
- package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +23 -23
- package/esm2020/services/catalog/catalog.service.mjs +194 -194
- package/esm2020/services/catalog/category.service.mjs +51 -51
- package/esm2020/services/catalog/enums/index.mjs +2 -2
- package/esm2020/services/catalog/enums/product-sorts.enum.mjs +11 -11
- package/esm2020/services/catalog/index.mjs +8 -8
- package/esm2020/services/catalog/models/category-with-tree.model.mjs +10 -10
- package/esm2020/services/catalog/models/index.mjs +2 -2
- package/esm2020/services/catalog/types/index.mjs +2 -2
- package/esm2020/services/catalog/types/product-sort.type.mjs +2 -2
- package/esm2020/services/catalog/wishlist.service.mjs +115 -115
- package/esm2020/services/checkout-subscription.service.mjs +50 -50
- package/esm2020/services/checkout.service.mjs +68 -68
- package/esm2020/services/coupon.service.mjs +262 -260
- package/esm2020/services/helpers/index.mjs +2 -2
- package/esm2020/services/helpers/util.helper.mjs +18 -18
- package/esm2020/services/home-shop.service.mjs +125 -125
- package/esm2020/services/index.mjs +11 -11
- package/esm2020/services/order.service.mjs +30 -30
- package/esm2020/services/shipping.service.mjs +96 -96
- 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/services/types/shipping-methods.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 +2353 -2351
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +2294 -2292
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/helpers/index.d.ts +1 -1
- package/helpers/mobile-operation-system-checker.helper.d.ts +3 -3
- package/index.d.ts +6 -6
- package/package.json +2 -2
- package/persistence/cookie-data-persistence.d.ts +10 -10
- package/persistence/data-persistence.d.ts +6 -6
- package/persistence/index.d.ts +2 -2
- package/services/auth.service.d.ts +18 -18
- package/services/cart.service.d.ts +42 -42
- package/services/catalog/adapters/category-structure.adapter.d.ts +4 -4
- package/services/catalog/adapters/index.d.ts +3 -3
- package/services/catalog/adapters/new-category-structure.adapter.d.ts +12 -12
- package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -10
- package/services/catalog/catalog.service.d.ts +86 -86
- package/services/catalog/category.service.d.ts +20 -20
- package/services/catalog/enums/index.d.ts +1 -1
- package/services/catalog/enums/product-sorts.enum.d.ts +9 -9
- package/services/catalog/index.d.ts +7 -7
- package/services/catalog/models/category-with-tree.model.d.ts +4 -4
- package/services/catalog/models/index.d.ts +1 -1
- package/services/catalog/types/index.d.ts +1 -1
- package/services/catalog/types/product-sort.type.d.ts +2 -2
- package/services/catalog/wishlist.service.d.ts +38 -38
- package/services/checkout-subscription.service.d.ts +19 -19
- package/services/checkout.service.d.ts +27 -27
- package/services/coupon.service.d.ts +33 -33
- package/services/helpers/index.d.ts +1 -1
- package/services/helpers/util.helper.d.ts +3 -3
- package/services/home-shop.service.d.ts +26 -26
- package/services/index.d.ts +10 -10
- package/services/order.service.d.ts +13 -13
- package/services/shipping.service.d.ts +19 -19
- 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/services/types/shipping-methods.type.d.ts +12 -12
- package/types/firebase-app-config.type.d.ts +1 -1
- package/types/index.d.ts +1 -1
|
@@ -20,34 +20,34 @@ import * as i1$3 from '@angular/common/http';
|
|
|
20
20
|
|
|
21
21
|
const ES_CONFIG = 'ES_CONFIG';
|
|
22
22
|
|
|
23
|
-
class AngularElasticSeachModule {
|
|
24
|
-
static initializeApp(options) {
|
|
25
|
-
return {
|
|
26
|
-
ngModule: AngularElasticSeachModule,
|
|
27
|
-
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
32
|
-
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
|
|
33
|
-
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
34
|
-
{
|
|
35
|
-
provide: ProductsIndex,
|
|
36
|
-
useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
|
|
37
|
-
deps: [ES_CONFIG],
|
|
38
|
-
},
|
|
39
|
-
] });
|
|
40
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
41
|
-
type: NgModule,
|
|
42
|
-
args: [{
|
|
43
|
-
providers: [
|
|
44
|
-
{
|
|
45
|
-
provide: ProductsIndex,
|
|
46
|
-
useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
|
|
47
|
-
deps: [ES_CONFIG],
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
}]
|
|
23
|
+
class AngularElasticSeachModule {
|
|
24
|
+
static initializeApp(options) {
|
|
25
|
+
return {
|
|
26
|
+
ngModule: AngularElasticSeachModule,
|
|
27
|
+
providers: [{ provide: ES_CONFIG, useValue: options }],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
32
|
+
AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
|
|
33
|
+
AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
|
|
34
|
+
{
|
|
35
|
+
provide: ProductsIndex,
|
|
36
|
+
useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
|
|
37
|
+
deps: [ES_CONFIG],
|
|
38
|
+
},
|
|
39
|
+
] });
|
|
40
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
|
|
41
|
+
type: NgModule,
|
|
42
|
+
args: [{
|
|
43
|
+
providers: [
|
|
44
|
+
{
|
|
45
|
+
provide: ProductsIndex,
|
|
46
|
+
useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
|
|
47
|
+
deps: [ES_CONFIG],
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
}]
|
|
51
51
|
}] });
|
|
52
52
|
|
|
53
53
|
const BACKEND_URL = 'BACKEND_URL';
|
|
@@ -56,2322 +56,2324 @@ const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
|
|
|
56
56
|
|
|
57
57
|
const DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
58
58
|
|
|
59
|
-
const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
|
|
59
|
+
const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
|
|
60
60
|
const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
|
|
61
61
|
|
|
62
62
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
63
63
|
|
|
64
64
|
const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
|
|
65
65
|
|
|
66
|
-
class AngularFirebaseAuthModule {
|
|
67
|
-
static initializeApp(options, nameOrConfig) {
|
|
68
|
-
return {
|
|
69
|
-
ngModule: AngularFirebaseAuthModule,
|
|
70
|
-
providers: [
|
|
71
|
-
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
72
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
73
|
-
],
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
78
|
-
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.AuthModule] });
|
|
79
|
-
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
80
|
-
{
|
|
81
|
-
provide: 'Authentication',
|
|
82
|
-
useFactory: (authenticationService, userRepository) => {
|
|
83
|
-
return new Authentication(authenticationService, userRepository);
|
|
84
|
-
},
|
|
85
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
provide: 'AuthenticationService',
|
|
89
|
-
useFactory: (angularFireAuth) => {
|
|
90
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
91
|
-
},
|
|
92
|
-
deps: [Auth],
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
provide: 'Register',
|
|
96
|
-
useFactory: (registerService, userRepository) => {
|
|
97
|
-
return new Register(registerService, userRepository);
|
|
98
|
-
},
|
|
99
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
provide: 'RegisterService',
|
|
103
|
-
useFactory: (angularFireAuth) => {
|
|
104
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
105
|
-
},
|
|
106
|
-
deps: [Auth],
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
provide: 'SignOut',
|
|
110
|
-
useFactory: (authenticationService) => {
|
|
111
|
-
return new SignOut(authenticationService);
|
|
112
|
-
},
|
|
113
|
-
deps: ['AuthenticationService'],
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
provide: 'RecoveryPassword',
|
|
117
|
-
useFactory: (authenticationService) => {
|
|
118
|
-
return new RecoveryPassword(authenticationService);
|
|
119
|
-
},
|
|
120
|
-
deps: ['AuthenticationService'],
|
|
121
|
-
},
|
|
122
|
-
], imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))] });
|
|
123
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
124
|
-
type: NgModule,
|
|
125
|
-
args: [{
|
|
126
|
-
imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))],
|
|
127
|
-
providers: [
|
|
128
|
-
{
|
|
129
|
-
provide: 'Authentication',
|
|
130
|
-
useFactory: (authenticationService, userRepository) => {
|
|
131
|
-
return new Authentication(authenticationService, userRepository);
|
|
132
|
-
},
|
|
133
|
-
deps: ['AuthenticationService', 'UserRepository'],
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
provide: 'AuthenticationService',
|
|
137
|
-
useFactory: (angularFireAuth) => {
|
|
138
|
-
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
139
|
-
},
|
|
140
|
-
deps: [Auth],
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
provide: 'Register',
|
|
144
|
-
useFactory: (registerService, userRepository) => {
|
|
145
|
-
return new Register(registerService, userRepository);
|
|
146
|
-
},
|
|
147
|
-
deps: ['RegisterService', 'UserRepository'],
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
provide: 'RegisterService',
|
|
151
|
-
useFactory: (angularFireAuth) => {
|
|
152
|
-
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
153
|
-
},
|
|
154
|
-
deps: [Auth],
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
provide: 'SignOut',
|
|
158
|
-
useFactory: (authenticationService) => {
|
|
159
|
-
return new SignOut(authenticationService);
|
|
160
|
-
},
|
|
161
|
-
deps: ['AuthenticationService'],
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
provide: 'RecoveryPassword',
|
|
165
|
-
useFactory: (authenticationService) => {
|
|
166
|
-
return new RecoveryPassword(authenticationService);
|
|
167
|
-
},
|
|
168
|
-
deps: ['AuthenticationService'],
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
}]
|
|
66
|
+
class AngularFirebaseAuthModule {
|
|
67
|
+
static initializeApp(options, nameOrConfig) {
|
|
68
|
+
return {
|
|
69
|
+
ngModule: AngularFirebaseAuthModule,
|
|
70
|
+
providers: [
|
|
71
|
+
{ provide: FIREBASE_OPTIONS, useValue: options },
|
|
72
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
73
|
+
],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
78
|
+
AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.AuthModule] });
|
|
79
|
+
AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
|
|
80
|
+
{
|
|
81
|
+
provide: 'Authentication',
|
|
82
|
+
useFactory: (authenticationService, userRepository) => {
|
|
83
|
+
return new Authentication(authenticationService, userRepository);
|
|
84
|
+
},
|
|
85
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
provide: 'AuthenticationService',
|
|
89
|
+
useFactory: (angularFireAuth) => {
|
|
90
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
91
|
+
},
|
|
92
|
+
deps: [Auth],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
provide: 'Register',
|
|
96
|
+
useFactory: (registerService, userRepository) => {
|
|
97
|
+
return new Register(registerService, userRepository);
|
|
98
|
+
},
|
|
99
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
provide: 'RegisterService',
|
|
103
|
+
useFactory: (angularFireAuth) => {
|
|
104
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
105
|
+
},
|
|
106
|
+
deps: [Auth],
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
provide: 'SignOut',
|
|
110
|
+
useFactory: (authenticationService) => {
|
|
111
|
+
return new SignOut(authenticationService);
|
|
112
|
+
},
|
|
113
|
+
deps: ['AuthenticationService'],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
provide: 'RecoveryPassword',
|
|
117
|
+
useFactory: (authenticationService) => {
|
|
118
|
+
return new RecoveryPassword(authenticationService);
|
|
119
|
+
},
|
|
120
|
+
deps: ['AuthenticationService'],
|
|
121
|
+
},
|
|
122
|
+
], imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))] });
|
|
123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
124
|
+
type: NgModule,
|
|
125
|
+
args: [{
|
|
126
|
+
imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))],
|
|
127
|
+
providers: [
|
|
128
|
+
{
|
|
129
|
+
provide: 'Authentication',
|
|
130
|
+
useFactory: (authenticationService, userRepository) => {
|
|
131
|
+
return new Authentication(authenticationService, userRepository);
|
|
132
|
+
},
|
|
133
|
+
deps: ['AuthenticationService', 'UserRepository'],
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
provide: 'AuthenticationService',
|
|
137
|
+
useFactory: (angularFireAuth) => {
|
|
138
|
+
return new AuthenticationFirebaseAuthService(angularFireAuth);
|
|
139
|
+
},
|
|
140
|
+
deps: [Auth],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
provide: 'Register',
|
|
144
|
+
useFactory: (registerService, userRepository) => {
|
|
145
|
+
return new Register(registerService, userRepository);
|
|
146
|
+
},
|
|
147
|
+
deps: ['RegisterService', 'UserRepository'],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
provide: 'RegisterService',
|
|
151
|
+
useFactory: (angularFireAuth) => {
|
|
152
|
+
return new RegisterFirebaseAuthService(angularFireAuth);
|
|
153
|
+
},
|
|
154
|
+
deps: [Auth],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
provide: 'SignOut',
|
|
158
|
+
useFactory: (authenticationService) => {
|
|
159
|
+
return new SignOut(authenticationService);
|
|
160
|
+
},
|
|
161
|
+
deps: ['AuthenticationService'],
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
provide: 'RecoveryPassword',
|
|
165
|
+
useFactory: (authenticationService) => {
|
|
166
|
+
return new RecoveryPassword(authenticationService);
|
|
167
|
+
},
|
|
168
|
+
deps: ['AuthenticationService'],
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
}]
|
|
172
172
|
}] });
|
|
173
173
|
|
|
174
174
|
const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
|
|
175
175
|
|
|
176
|
-
class MobileOperationSystemCheckerHelper {
|
|
177
|
-
static isAppleDevice() {
|
|
178
|
-
return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
|
|
179
|
-
(navigator?.userAgent?.includes?.('Mac') && 'ontouchend' in (document || {})));
|
|
180
|
-
}
|
|
176
|
+
class MobileOperationSystemCheckerHelper {
|
|
177
|
+
static isAppleDevice() {
|
|
178
|
+
return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
|
|
179
|
+
(navigator?.userAgent?.includes?.('Mac') && 'ontouchend' in (document || {})));
|
|
180
|
+
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
class AngularFirestoreModule {
|
|
184
|
-
static initializeApp(options, nameOrConfig) {
|
|
185
|
-
return {
|
|
186
|
-
ngModule: AngularFirestoreModule,
|
|
187
|
-
providers: [
|
|
188
|
-
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
189
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
190
|
-
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
191
|
-
],
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
196
|
-
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule, i2.StorageModule] });
|
|
197
|
-
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
198
|
-
{
|
|
199
|
-
provide: 'FirestoreOptions',
|
|
200
|
-
useFactory: (firestore, platformId) => ({
|
|
201
|
-
firestore: new ConnectFirestoreService(firestore),
|
|
202
|
-
interceptors: {
|
|
203
|
-
request: (request) => {
|
|
204
|
-
if (isPlatformBrowser(platformId))
|
|
205
|
-
return request;
|
|
206
|
-
const interval = setInterval(() => { }, 100);
|
|
207
|
-
request.interval = interval;
|
|
208
|
-
return request;
|
|
209
|
-
},
|
|
210
|
-
response: (response, request) => {
|
|
211
|
-
if (isPlatformBrowser(platformId))
|
|
212
|
-
return response;
|
|
213
|
-
clearInterval(request.interval);
|
|
214
|
-
return response;
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
}),
|
|
218
|
-
deps: [Firestore, PLATFORM_ID],
|
|
219
|
-
},
|
|
220
|
-
{
|
|
221
|
-
provide: 'BeautyProfileRepository',
|
|
222
|
-
useFactory: (config, userRepository) => {
|
|
223
|
-
return new UserBeautyProfileFirestoreRepository(config, userRepository);
|
|
224
|
-
},
|
|
225
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
provide: 'Buy2WinRepository',
|
|
229
|
-
useFactory: (options) => {
|
|
230
|
-
return new Buy2WinFirestoreRepository(options);
|
|
231
|
-
},
|
|
232
|
-
deps: ['FirestoreOptions'],
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
provide: CategoryFirestoreRepository,
|
|
236
|
-
useFactory: (options) => {
|
|
237
|
-
return new CategoryFirestoreRepository(options);
|
|
238
|
-
},
|
|
239
|
-
deps: ['FirestoreOptions'],
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
provide: 'CheckoutRepository',
|
|
243
|
-
useFactory: (options) => {
|
|
244
|
-
return new CheckoutFirestoreRepository(options);
|
|
245
|
-
},
|
|
246
|
-
deps: ['FirestoreOptions'],
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
250
|
-
useFactory: (options) => {
|
|
251
|
-
return new CheckoutSubscriptionFirestoreRepository(options);
|
|
252
|
-
},
|
|
253
|
-
deps: ['FirestoreOptions'],
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
provide: 'CouponRepository',
|
|
257
|
-
useFactory: (options) => {
|
|
258
|
-
return new CouponFirestoreRepository(options);
|
|
259
|
-
},
|
|
260
|
-
deps: ['FirestoreOptions'],
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
provide: 'CampaignHashtagRepository',
|
|
264
|
-
useFactory: (options) => {
|
|
265
|
-
return new CampaignHashtagFirestoreRepository(options);
|
|
266
|
-
},
|
|
267
|
-
deps: ['FirestoreOptions'],
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
provide: 'CampaignDashboardRepository',
|
|
271
|
-
useFactory: (options) => {
|
|
272
|
-
return new CampaignDashboardFirestoreRepository(options);
|
|
273
|
-
},
|
|
274
|
-
deps: ['FirestoreOptions'],
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
provide: 'EditionRepository',
|
|
278
|
-
useFactory: (options, subscriptionRepository) => {
|
|
279
|
-
return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
|
|
280
|
-
},
|
|
281
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
provide: 'HomeRepository',
|
|
285
|
-
useFactory: (options) => {
|
|
286
|
-
return new HomeFirestoreRepository(options);
|
|
287
|
-
},
|
|
288
|
-
deps: ['FirestoreOptions'],
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
provide: 'LeadRepository',
|
|
292
|
-
useFactory: (options) => {
|
|
293
|
-
return new LeadFirestoreRepository(options);
|
|
294
|
-
},
|
|
295
|
-
deps: ['FirestoreOptions'],
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
provide: 'LegacyOrderRepository',
|
|
299
|
-
useFactory: (options) => {
|
|
300
|
-
return new LegacyOrderFirestoreRepository(options);
|
|
301
|
-
},
|
|
302
|
-
deps: ['FirestoreOptions'],
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
provide: 'ShopMenuRepository',
|
|
306
|
-
useFactory: (options) => {
|
|
307
|
-
return new ShopMenuFirestoreRepository(options);
|
|
308
|
-
},
|
|
309
|
-
deps: ['FirestoreOptions'],
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
provide: 'OrderRepository',
|
|
313
|
-
useFactory: (options) => {
|
|
314
|
-
return new OrderFirestoreRepository(options);
|
|
315
|
-
},
|
|
316
|
-
deps: ['FirestoreOptions'],
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
provide: 'PaymentRepository',
|
|
320
|
-
useFactory: (options) => {
|
|
321
|
-
return new PaymentFirestoreRepository(options);
|
|
322
|
-
},
|
|
323
|
-
deps: ['FirestoreOptions'],
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
provide: ProductFirestoreRepository,
|
|
327
|
-
useFactory: (options) => {
|
|
328
|
-
return new ProductFirestoreRepository(options);
|
|
329
|
-
},
|
|
330
|
-
deps: ['FirestoreOptions'],
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
provide: 'ShopSettingsRepository',
|
|
334
|
-
useFactory: (options) => {
|
|
335
|
-
return new ShopSettingsFirestoreRepository(options);
|
|
336
|
-
},
|
|
337
|
-
deps: ['FirestoreOptions'],
|
|
338
|
-
},
|
|
339
|
-
{
|
|
340
|
-
provide: 'SubscriptionPaymentRepository',
|
|
341
|
-
useFactory: (options, subscriptionRepository) => {
|
|
342
|
-
return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
|
|
343
|
-
},
|
|
344
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
provide: 'SubscriptionPlanRepository',
|
|
348
|
-
useFactory: (options) => {
|
|
349
|
-
return new SubscriptionPlanFirestoreRepository(options);
|
|
350
|
-
},
|
|
351
|
-
deps: ['FirestoreOptions'],
|
|
352
|
-
},
|
|
353
|
-
{
|
|
354
|
-
provide: 'SubscriptionProductRepository',
|
|
355
|
-
useFactory: (options) => {
|
|
356
|
-
return new SubscriptionProductFirestoreRepository(options);
|
|
357
|
-
},
|
|
358
|
-
deps: ['FirestoreOptions'],
|
|
359
|
-
},
|
|
360
|
-
{
|
|
361
|
-
provide: 'SubscriptionRepository',
|
|
362
|
-
useFactory: (options) => {
|
|
363
|
-
return new SubscriptionFirestoreRepository(options);
|
|
364
|
-
},
|
|
365
|
-
deps: ['FirestoreOptions'],
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
provide: 'UserRepository',
|
|
369
|
-
useFactory: (options) => {
|
|
370
|
-
return new UserFirestoreRepository(options);
|
|
371
|
-
},
|
|
372
|
-
deps: ['FirestoreOptions'],
|
|
373
|
-
},
|
|
374
|
-
{
|
|
375
|
-
provide: 'UserAddressRepository',
|
|
376
|
-
useFactory: (options, userRepository) => {
|
|
377
|
-
return new UserAddressFirestoreRepository(options, userRepository);
|
|
378
|
-
},
|
|
379
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
provide: 'UserPaymentMethodRepository',
|
|
383
|
-
useFactory: (options, userRepository) => {
|
|
384
|
-
return new UserPaymentMethodFirestoreRepository(options, userRepository);
|
|
385
|
-
},
|
|
386
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
387
|
-
},
|
|
388
|
-
{
|
|
389
|
-
provide: 'SubscriptionMaterializationRepository',
|
|
390
|
-
useFactory: (options) => {
|
|
391
|
-
return new SubscriptionMaterializationFirestoreRepository(options);
|
|
392
|
-
},
|
|
393
|
-
deps: ['FirestoreOptions'],
|
|
394
|
-
},
|
|
395
|
-
{
|
|
396
|
-
provide: 'SubscriptionSummaryRepository',
|
|
397
|
-
useFactory: (options) => {
|
|
398
|
-
return new SubscriptionSummaryFirestoreRepository(options);
|
|
399
|
-
},
|
|
400
|
-
deps: ['FirestoreOptions'],
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
provide: ProductVariantFirestoreRepository,
|
|
404
|
-
useFactory: (options, productRepository) => {
|
|
405
|
-
return new ProductVariantFirestoreRepository(options, productRepository);
|
|
406
|
-
},
|
|
407
|
-
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
408
|
-
},
|
|
409
|
-
{
|
|
410
|
-
provide: 'FileUploaderService',
|
|
411
|
-
useFactory: (storage, baseUrl) => {
|
|
412
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
413
|
-
},
|
|
414
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
415
|
-
},
|
|
416
|
-
], imports: [AngularElasticSeachModule,
|
|
417
|
-
provideFirestore((injector) => {
|
|
418
|
-
const platformId = injector.get(PLATFORM_ID);
|
|
419
|
-
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
420
|
-
return initializeFirestore(injector.get(FirebaseApp), {
|
|
421
|
-
ignoreUndefinedProperties: true,
|
|
422
|
-
});
|
|
423
|
-
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
424
|
-
experimentalForceLongPolling: true,
|
|
425
|
-
ignoreUndefinedProperties: true,
|
|
426
|
-
localCache: memoryLocalCache(),
|
|
427
|
-
});
|
|
428
|
-
return firestore;
|
|
429
|
-
}),
|
|
430
|
-
provideStorage(() => getStorage())] });
|
|
431
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
432
|
-
type: NgModule,
|
|
433
|
-
args: [{
|
|
434
|
-
imports: [
|
|
435
|
-
AngularElasticSeachModule,
|
|
436
|
-
provideFirestore((injector) => {
|
|
437
|
-
const platformId = injector.get(PLATFORM_ID);
|
|
438
|
-
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
439
|
-
return initializeFirestore(injector.get(FirebaseApp), {
|
|
440
|
-
ignoreUndefinedProperties: true,
|
|
441
|
-
});
|
|
442
|
-
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
443
|
-
experimentalForceLongPolling: true,
|
|
444
|
-
ignoreUndefinedProperties: true,
|
|
445
|
-
localCache: memoryLocalCache(),
|
|
446
|
-
});
|
|
447
|
-
return firestore;
|
|
448
|
-
}),
|
|
449
|
-
provideStorage(() => getStorage()),
|
|
450
|
-
],
|
|
451
|
-
providers: [
|
|
452
|
-
{
|
|
453
|
-
provide: 'FirestoreOptions',
|
|
454
|
-
useFactory: (firestore, platformId) => ({
|
|
455
|
-
firestore: new ConnectFirestoreService(firestore),
|
|
456
|
-
interceptors: {
|
|
457
|
-
request: (request) => {
|
|
458
|
-
if (isPlatformBrowser(platformId))
|
|
459
|
-
return request;
|
|
460
|
-
const interval = setInterval(() => { }, 100);
|
|
461
|
-
request.interval = interval;
|
|
462
|
-
return request;
|
|
463
|
-
},
|
|
464
|
-
response: (response, request) => {
|
|
465
|
-
if (isPlatformBrowser(platformId))
|
|
466
|
-
return response;
|
|
467
|
-
clearInterval(request.interval);
|
|
468
|
-
return response;
|
|
469
|
-
},
|
|
470
|
-
},
|
|
471
|
-
}),
|
|
472
|
-
deps: [Firestore, PLATFORM_ID],
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
provide: 'BeautyProfileRepository',
|
|
476
|
-
useFactory: (config, userRepository) => {
|
|
477
|
-
return new UserBeautyProfileFirestoreRepository(config, userRepository);
|
|
478
|
-
},
|
|
479
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
provide: 'Buy2WinRepository',
|
|
483
|
-
useFactory: (options) => {
|
|
484
|
-
return new Buy2WinFirestoreRepository(options);
|
|
485
|
-
},
|
|
486
|
-
deps: ['FirestoreOptions'],
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
provide: CategoryFirestoreRepository,
|
|
490
|
-
useFactory: (options) => {
|
|
491
|
-
return new CategoryFirestoreRepository(options);
|
|
492
|
-
},
|
|
493
|
-
deps: ['FirestoreOptions'],
|
|
494
|
-
},
|
|
495
|
-
{
|
|
496
|
-
provide: 'CheckoutRepository',
|
|
497
|
-
useFactory: (options) => {
|
|
498
|
-
return new CheckoutFirestoreRepository(options);
|
|
499
|
-
},
|
|
500
|
-
deps: ['FirestoreOptions'],
|
|
501
|
-
},
|
|
502
|
-
{
|
|
503
|
-
provide: 'CheckoutSubscriptionRepository',
|
|
504
|
-
useFactory: (options) => {
|
|
505
|
-
return new CheckoutSubscriptionFirestoreRepository(options);
|
|
506
|
-
},
|
|
507
|
-
deps: ['FirestoreOptions'],
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
provide: 'CouponRepository',
|
|
511
|
-
useFactory: (options) => {
|
|
512
|
-
return new CouponFirestoreRepository(options);
|
|
513
|
-
},
|
|
514
|
-
deps: ['FirestoreOptions'],
|
|
515
|
-
},
|
|
516
|
-
{
|
|
517
|
-
provide: 'CampaignHashtagRepository',
|
|
518
|
-
useFactory: (options) => {
|
|
519
|
-
return new CampaignHashtagFirestoreRepository(options);
|
|
520
|
-
},
|
|
521
|
-
deps: ['FirestoreOptions'],
|
|
522
|
-
},
|
|
523
|
-
{
|
|
524
|
-
provide: 'CampaignDashboardRepository',
|
|
525
|
-
useFactory: (options) => {
|
|
526
|
-
return new CampaignDashboardFirestoreRepository(options);
|
|
527
|
-
},
|
|
528
|
-
deps: ['FirestoreOptions'],
|
|
529
|
-
},
|
|
530
|
-
{
|
|
531
|
-
provide: 'EditionRepository',
|
|
532
|
-
useFactory: (options, subscriptionRepository) => {
|
|
533
|
-
return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
|
|
534
|
-
},
|
|
535
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
536
|
-
},
|
|
537
|
-
{
|
|
538
|
-
provide: 'HomeRepository',
|
|
539
|
-
useFactory: (options) => {
|
|
540
|
-
return new HomeFirestoreRepository(options);
|
|
541
|
-
},
|
|
542
|
-
deps: ['FirestoreOptions'],
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
provide: 'LeadRepository',
|
|
546
|
-
useFactory: (options) => {
|
|
547
|
-
return new LeadFirestoreRepository(options);
|
|
548
|
-
},
|
|
549
|
-
deps: ['FirestoreOptions'],
|
|
550
|
-
},
|
|
551
|
-
{
|
|
552
|
-
provide: 'LegacyOrderRepository',
|
|
553
|
-
useFactory: (options) => {
|
|
554
|
-
return new LegacyOrderFirestoreRepository(options);
|
|
555
|
-
},
|
|
556
|
-
deps: ['FirestoreOptions'],
|
|
557
|
-
},
|
|
558
|
-
{
|
|
559
|
-
provide: 'ShopMenuRepository',
|
|
560
|
-
useFactory: (options) => {
|
|
561
|
-
return new ShopMenuFirestoreRepository(options);
|
|
562
|
-
},
|
|
563
|
-
deps: ['FirestoreOptions'],
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
provide: 'OrderRepository',
|
|
567
|
-
useFactory: (options) => {
|
|
568
|
-
return new OrderFirestoreRepository(options);
|
|
569
|
-
},
|
|
570
|
-
deps: ['FirestoreOptions'],
|
|
571
|
-
},
|
|
572
|
-
{
|
|
573
|
-
provide: 'PaymentRepository',
|
|
574
|
-
useFactory: (options) => {
|
|
575
|
-
return new PaymentFirestoreRepository(options);
|
|
576
|
-
},
|
|
577
|
-
deps: ['FirestoreOptions'],
|
|
578
|
-
},
|
|
579
|
-
{
|
|
580
|
-
provide: ProductFirestoreRepository,
|
|
581
|
-
useFactory: (options) => {
|
|
582
|
-
return new ProductFirestoreRepository(options);
|
|
583
|
-
},
|
|
584
|
-
deps: ['FirestoreOptions'],
|
|
585
|
-
},
|
|
586
|
-
{
|
|
587
|
-
provide: 'ShopSettingsRepository',
|
|
588
|
-
useFactory: (options) => {
|
|
589
|
-
return new ShopSettingsFirestoreRepository(options);
|
|
590
|
-
},
|
|
591
|
-
deps: ['FirestoreOptions'],
|
|
592
|
-
},
|
|
593
|
-
{
|
|
594
|
-
provide: 'SubscriptionPaymentRepository',
|
|
595
|
-
useFactory: (options, subscriptionRepository) => {
|
|
596
|
-
return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
|
|
597
|
-
},
|
|
598
|
-
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
599
|
-
},
|
|
600
|
-
{
|
|
601
|
-
provide: 'SubscriptionPlanRepository',
|
|
602
|
-
useFactory: (options) => {
|
|
603
|
-
return new SubscriptionPlanFirestoreRepository(options);
|
|
604
|
-
},
|
|
605
|
-
deps: ['FirestoreOptions'],
|
|
606
|
-
},
|
|
607
|
-
{
|
|
608
|
-
provide: 'SubscriptionProductRepository',
|
|
609
|
-
useFactory: (options) => {
|
|
610
|
-
return new SubscriptionProductFirestoreRepository(options);
|
|
611
|
-
},
|
|
612
|
-
deps: ['FirestoreOptions'],
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
provide: 'SubscriptionRepository',
|
|
616
|
-
useFactory: (options) => {
|
|
617
|
-
return new SubscriptionFirestoreRepository(options);
|
|
618
|
-
},
|
|
619
|
-
deps: ['FirestoreOptions'],
|
|
620
|
-
},
|
|
621
|
-
{
|
|
622
|
-
provide: 'UserRepository',
|
|
623
|
-
useFactory: (options) => {
|
|
624
|
-
return new UserFirestoreRepository(options);
|
|
625
|
-
},
|
|
626
|
-
deps: ['FirestoreOptions'],
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
provide: 'UserAddressRepository',
|
|
630
|
-
useFactory: (options, userRepository) => {
|
|
631
|
-
return new UserAddressFirestoreRepository(options, userRepository);
|
|
632
|
-
},
|
|
633
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
634
|
-
},
|
|
635
|
-
{
|
|
636
|
-
provide: 'UserPaymentMethodRepository',
|
|
637
|
-
useFactory: (options, userRepository) => {
|
|
638
|
-
return new UserPaymentMethodFirestoreRepository(options, userRepository);
|
|
639
|
-
},
|
|
640
|
-
deps: ['FirestoreOptions', 'UserRepository'],
|
|
641
|
-
},
|
|
642
|
-
{
|
|
643
|
-
provide: 'SubscriptionMaterializationRepository',
|
|
644
|
-
useFactory: (options) => {
|
|
645
|
-
return new SubscriptionMaterializationFirestoreRepository(options);
|
|
646
|
-
},
|
|
647
|
-
deps: ['FirestoreOptions'],
|
|
648
|
-
},
|
|
649
|
-
{
|
|
650
|
-
provide: 'SubscriptionSummaryRepository',
|
|
651
|
-
useFactory: (options) => {
|
|
652
|
-
return new SubscriptionSummaryFirestoreRepository(options);
|
|
653
|
-
},
|
|
654
|
-
deps: ['FirestoreOptions'],
|
|
655
|
-
},
|
|
656
|
-
{
|
|
657
|
-
provide: ProductVariantFirestoreRepository,
|
|
658
|
-
useFactory: (options, productRepository) => {
|
|
659
|
-
return new ProductVariantFirestoreRepository(options, productRepository);
|
|
660
|
-
},
|
|
661
|
-
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
662
|
-
},
|
|
663
|
-
{
|
|
664
|
-
provide: 'FileUploaderService',
|
|
665
|
-
useFactory: (storage, baseUrl) => {
|
|
666
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
667
|
-
},
|
|
668
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
669
|
-
},
|
|
670
|
-
],
|
|
671
|
-
}]
|
|
183
|
+
class AngularFirestoreModule {
|
|
184
|
+
static initializeApp(options, nameOrConfig) {
|
|
185
|
+
return {
|
|
186
|
+
ngModule: AngularFirestoreModule,
|
|
187
|
+
providers: [
|
|
188
|
+
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
189
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
190
|
+
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
191
|
+
],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
196
|
+
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule, i2.StorageModule] });
|
|
197
|
+
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
198
|
+
{
|
|
199
|
+
provide: 'FirestoreOptions',
|
|
200
|
+
useFactory: (firestore, platformId) => ({
|
|
201
|
+
firestore: new ConnectFirestoreService(firestore),
|
|
202
|
+
interceptors: {
|
|
203
|
+
request: (request) => {
|
|
204
|
+
if (isPlatformBrowser(platformId))
|
|
205
|
+
return request;
|
|
206
|
+
const interval = setInterval(() => { }, 100);
|
|
207
|
+
request.interval = interval;
|
|
208
|
+
return request;
|
|
209
|
+
},
|
|
210
|
+
response: (response, request) => {
|
|
211
|
+
if (isPlatformBrowser(platformId))
|
|
212
|
+
return response;
|
|
213
|
+
clearInterval(request.interval);
|
|
214
|
+
return response;
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
}),
|
|
218
|
+
deps: [Firestore, PLATFORM_ID],
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
provide: 'BeautyProfileRepository',
|
|
222
|
+
useFactory: (config, userRepository) => {
|
|
223
|
+
return new UserBeautyProfileFirestoreRepository(config, userRepository);
|
|
224
|
+
},
|
|
225
|
+
deps: ['FirestoreOptions', 'UserRepository'],
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
provide: 'Buy2WinRepository',
|
|
229
|
+
useFactory: (options) => {
|
|
230
|
+
return new Buy2WinFirestoreRepository(options);
|
|
231
|
+
},
|
|
232
|
+
deps: ['FirestoreOptions'],
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
provide: CategoryFirestoreRepository,
|
|
236
|
+
useFactory: (options) => {
|
|
237
|
+
return new CategoryFirestoreRepository(options);
|
|
238
|
+
},
|
|
239
|
+
deps: ['FirestoreOptions'],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
provide: 'CheckoutRepository',
|
|
243
|
+
useFactory: (options) => {
|
|
244
|
+
return new CheckoutFirestoreRepository(options);
|
|
245
|
+
},
|
|
246
|
+
deps: ['FirestoreOptions'],
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
250
|
+
useFactory: (options) => {
|
|
251
|
+
return new CheckoutSubscriptionFirestoreRepository(options);
|
|
252
|
+
},
|
|
253
|
+
deps: ['FirestoreOptions'],
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
provide: 'CouponRepository',
|
|
257
|
+
useFactory: (options) => {
|
|
258
|
+
return new CouponFirestoreRepository(options);
|
|
259
|
+
},
|
|
260
|
+
deps: ['FirestoreOptions'],
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
provide: 'CampaignHashtagRepository',
|
|
264
|
+
useFactory: (options) => {
|
|
265
|
+
return new CampaignHashtagFirestoreRepository(options);
|
|
266
|
+
},
|
|
267
|
+
deps: ['FirestoreOptions'],
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
provide: 'CampaignDashboardRepository',
|
|
271
|
+
useFactory: (options) => {
|
|
272
|
+
return new CampaignDashboardFirestoreRepository(options);
|
|
273
|
+
},
|
|
274
|
+
deps: ['FirestoreOptions'],
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
provide: 'EditionRepository',
|
|
278
|
+
useFactory: (options, subscriptionRepository) => {
|
|
279
|
+
return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
|
|
280
|
+
},
|
|
281
|
+
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
provide: 'HomeRepository',
|
|
285
|
+
useFactory: (options) => {
|
|
286
|
+
return new HomeFirestoreRepository(options);
|
|
287
|
+
},
|
|
288
|
+
deps: ['FirestoreOptions'],
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
provide: 'LeadRepository',
|
|
292
|
+
useFactory: (options) => {
|
|
293
|
+
return new LeadFirestoreRepository(options);
|
|
294
|
+
},
|
|
295
|
+
deps: ['FirestoreOptions'],
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
provide: 'LegacyOrderRepository',
|
|
299
|
+
useFactory: (options) => {
|
|
300
|
+
return new LegacyOrderFirestoreRepository(options);
|
|
301
|
+
},
|
|
302
|
+
deps: ['FirestoreOptions'],
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
provide: 'ShopMenuRepository',
|
|
306
|
+
useFactory: (options) => {
|
|
307
|
+
return new ShopMenuFirestoreRepository(options);
|
|
308
|
+
},
|
|
309
|
+
deps: ['FirestoreOptions'],
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
provide: 'OrderRepository',
|
|
313
|
+
useFactory: (options) => {
|
|
314
|
+
return new OrderFirestoreRepository(options);
|
|
315
|
+
},
|
|
316
|
+
deps: ['FirestoreOptions'],
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
provide: 'PaymentRepository',
|
|
320
|
+
useFactory: (options) => {
|
|
321
|
+
return new PaymentFirestoreRepository(options);
|
|
322
|
+
},
|
|
323
|
+
deps: ['FirestoreOptions'],
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
provide: ProductFirestoreRepository,
|
|
327
|
+
useFactory: (options) => {
|
|
328
|
+
return new ProductFirestoreRepository(options);
|
|
329
|
+
},
|
|
330
|
+
deps: ['FirestoreOptions'],
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
provide: 'ShopSettingsRepository',
|
|
334
|
+
useFactory: (options) => {
|
|
335
|
+
return new ShopSettingsFirestoreRepository(options);
|
|
336
|
+
},
|
|
337
|
+
deps: ['FirestoreOptions'],
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
provide: 'SubscriptionPaymentRepository',
|
|
341
|
+
useFactory: (options, subscriptionRepository) => {
|
|
342
|
+
return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
|
|
343
|
+
},
|
|
344
|
+
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
provide: 'SubscriptionPlanRepository',
|
|
348
|
+
useFactory: (options) => {
|
|
349
|
+
return new SubscriptionPlanFirestoreRepository(options);
|
|
350
|
+
},
|
|
351
|
+
deps: ['FirestoreOptions'],
|
|
352
|
+
},
|
|
353
|
+
{
|
|
354
|
+
provide: 'SubscriptionProductRepository',
|
|
355
|
+
useFactory: (options) => {
|
|
356
|
+
return new SubscriptionProductFirestoreRepository(options);
|
|
357
|
+
},
|
|
358
|
+
deps: ['FirestoreOptions'],
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
provide: 'SubscriptionRepository',
|
|
362
|
+
useFactory: (options) => {
|
|
363
|
+
return new SubscriptionFirestoreRepository(options);
|
|
364
|
+
},
|
|
365
|
+
deps: ['FirestoreOptions'],
|
|
366
|
+
},
|
|
367
|
+
{
|
|
368
|
+
provide: 'UserRepository',
|
|
369
|
+
useFactory: (options) => {
|
|
370
|
+
return new UserFirestoreRepository(options);
|
|
371
|
+
},
|
|
372
|
+
deps: ['FirestoreOptions'],
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
provide: 'UserAddressRepository',
|
|
376
|
+
useFactory: (options, userRepository) => {
|
|
377
|
+
return new UserAddressFirestoreRepository(options, userRepository);
|
|
378
|
+
},
|
|
379
|
+
deps: ['FirestoreOptions', 'UserRepository'],
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
provide: 'UserPaymentMethodRepository',
|
|
383
|
+
useFactory: (options, userRepository) => {
|
|
384
|
+
return new UserPaymentMethodFirestoreRepository(options, userRepository);
|
|
385
|
+
},
|
|
386
|
+
deps: ['FirestoreOptions', 'UserRepository'],
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
provide: 'SubscriptionMaterializationRepository',
|
|
390
|
+
useFactory: (options) => {
|
|
391
|
+
return new SubscriptionMaterializationFirestoreRepository(options);
|
|
392
|
+
},
|
|
393
|
+
deps: ['FirestoreOptions'],
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
provide: 'SubscriptionSummaryRepository',
|
|
397
|
+
useFactory: (options) => {
|
|
398
|
+
return new SubscriptionSummaryFirestoreRepository(options);
|
|
399
|
+
},
|
|
400
|
+
deps: ['FirestoreOptions'],
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
provide: ProductVariantFirestoreRepository,
|
|
404
|
+
useFactory: (options, productRepository) => {
|
|
405
|
+
return new ProductVariantFirestoreRepository(options, productRepository);
|
|
406
|
+
},
|
|
407
|
+
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
provide: 'FileUploaderService',
|
|
411
|
+
useFactory: (storage, baseUrl) => {
|
|
412
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
413
|
+
},
|
|
414
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
415
|
+
},
|
|
416
|
+
], imports: [AngularElasticSeachModule,
|
|
417
|
+
provideFirestore((injector) => {
|
|
418
|
+
const platformId = injector.get(PLATFORM_ID);
|
|
419
|
+
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
420
|
+
return initializeFirestore(injector.get(FirebaseApp), {
|
|
421
|
+
ignoreUndefinedProperties: true,
|
|
422
|
+
});
|
|
423
|
+
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
424
|
+
experimentalForceLongPolling: true,
|
|
425
|
+
ignoreUndefinedProperties: true,
|
|
426
|
+
localCache: memoryLocalCache(),
|
|
427
|
+
});
|
|
428
|
+
return firestore;
|
|
429
|
+
}),
|
|
430
|
+
provideStorage(() => getStorage())] });
|
|
431
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
432
|
+
type: NgModule,
|
|
433
|
+
args: [{
|
|
434
|
+
imports: [
|
|
435
|
+
AngularElasticSeachModule,
|
|
436
|
+
provideFirestore((injector) => {
|
|
437
|
+
const platformId = injector.get(PLATFORM_ID);
|
|
438
|
+
if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
439
|
+
return initializeFirestore(injector.get(FirebaseApp), {
|
|
440
|
+
ignoreUndefinedProperties: true,
|
|
441
|
+
});
|
|
442
|
+
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
443
|
+
experimentalForceLongPolling: true,
|
|
444
|
+
ignoreUndefinedProperties: true,
|
|
445
|
+
localCache: memoryLocalCache(),
|
|
446
|
+
});
|
|
447
|
+
return firestore;
|
|
448
|
+
}),
|
|
449
|
+
provideStorage(() => getStorage()),
|
|
450
|
+
],
|
|
451
|
+
providers: [
|
|
452
|
+
{
|
|
453
|
+
provide: 'FirestoreOptions',
|
|
454
|
+
useFactory: (firestore, platformId) => ({
|
|
455
|
+
firestore: new ConnectFirestoreService(firestore),
|
|
456
|
+
interceptors: {
|
|
457
|
+
request: (request) => {
|
|
458
|
+
if (isPlatformBrowser(platformId))
|
|
459
|
+
return request;
|
|
460
|
+
const interval = setInterval(() => { }, 100);
|
|
461
|
+
request.interval = interval;
|
|
462
|
+
return request;
|
|
463
|
+
},
|
|
464
|
+
response: (response, request) => {
|
|
465
|
+
if (isPlatformBrowser(platformId))
|
|
466
|
+
return response;
|
|
467
|
+
clearInterval(request.interval);
|
|
468
|
+
return response;
|
|
469
|
+
},
|
|
470
|
+
},
|
|
471
|
+
}),
|
|
472
|
+
deps: [Firestore, PLATFORM_ID],
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
provide: 'BeautyProfileRepository',
|
|
476
|
+
useFactory: (config, userRepository) => {
|
|
477
|
+
return new UserBeautyProfileFirestoreRepository(config, userRepository);
|
|
478
|
+
},
|
|
479
|
+
deps: ['FirestoreOptions', 'UserRepository'],
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
provide: 'Buy2WinRepository',
|
|
483
|
+
useFactory: (options) => {
|
|
484
|
+
return new Buy2WinFirestoreRepository(options);
|
|
485
|
+
},
|
|
486
|
+
deps: ['FirestoreOptions'],
|
|
487
|
+
},
|
|
488
|
+
{
|
|
489
|
+
provide: CategoryFirestoreRepository,
|
|
490
|
+
useFactory: (options) => {
|
|
491
|
+
return new CategoryFirestoreRepository(options);
|
|
492
|
+
},
|
|
493
|
+
deps: ['FirestoreOptions'],
|
|
494
|
+
},
|
|
495
|
+
{
|
|
496
|
+
provide: 'CheckoutRepository',
|
|
497
|
+
useFactory: (options) => {
|
|
498
|
+
return new CheckoutFirestoreRepository(options);
|
|
499
|
+
},
|
|
500
|
+
deps: ['FirestoreOptions'],
|
|
501
|
+
},
|
|
502
|
+
{
|
|
503
|
+
provide: 'CheckoutSubscriptionRepository',
|
|
504
|
+
useFactory: (options) => {
|
|
505
|
+
return new CheckoutSubscriptionFirestoreRepository(options);
|
|
506
|
+
},
|
|
507
|
+
deps: ['FirestoreOptions'],
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
provide: 'CouponRepository',
|
|
511
|
+
useFactory: (options) => {
|
|
512
|
+
return new CouponFirestoreRepository(options);
|
|
513
|
+
},
|
|
514
|
+
deps: ['FirestoreOptions'],
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
provide: 'CampaignHashtagRepository',
|
|
518
|
+
useFactory: (options) => {
|
|
519
|
+
return new CampaignHashtagFirestoreRepository(options);
|
|
520
|
+
},
|
|
521
|
+
deps: ['FirestoreOptions'],
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
provide: 'CampaignDashboardRepository',
|
|
525
|
+
useFactory: (options) => {
|
|
526
|
+
return new CampaignDashboardFirestoreRepository(options);
|
|
527
|
+
},
|
|
528
|
+
deps: ['FirestoreOptions'],
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
provide: 'EditionRepository',
|
|
532
|
+
useFactory: (options, subscriptionRepository) => {
|
|
533
|
+
return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
|
|
534
|
+
},
|
|
535
|
+
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
provide: 'HomeRepository',
|
|
539
|
+
useFactory: (options) => {
|
|
540
|
+
return new HomeFirestoreRepository(options);
|
|
541
|
+
},
|
|
542
|
+
deps: ['FirestoreOptions'],
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
provide: 'LeadRepository',
|
|
546
|
+
useFactory: (options) => {
|
|
547
|
+
return new LeadFirestoreRepository(options);
|
|
548
|
+
},
|
|
549
|
+
deps: ['FirestoreOptions'],
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
provide: 'LegacyOrderRepository',
|
|
553
|
+
useFactory: (options) => {
|
|
554
|
+
return new LegacyOrderFirestoreRepository(options);
|
|
555
|
+
},
|
|
556
|
+
deps: ['FirestoreOptions'],
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
provide: 'ShopMenuRepository',
|
|
560
|
+
useFactory: (options) => {
|
|
561
|
+
return new ShopMenuFirestoreRepository(options);
|
|
562
|
+
},
|
|
563
|
+
deps: ['FirestoreOptions'],
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
provide: 'OrderRepository',
|
|
567
|
+
useFactory: (options) => {
|
|
568
|
+
return new OrderFirestoreRepository(options);
|
|
569
|
+
},
|
|
570
|
+
deps: ['FirestoreOptions'],
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
provide: 'PaymentRepository',
|
|
574
|
+
useFactory: (options) => {
|
|
575
|
+
return new PaymentFirestoreRepository(options);
|
|
576
|
+
},
|
|
577
|
+
deps: ['FirestoreOptions'],
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
provide: ProductFirestoreRepository,
|
|
581
|
+
useFactory: (options) => {
|
|
582
|
+
return new ProductFirestoreRepository(options);
|
|
583
|
+
},
|
|
584
|
+
deps: ['FirestoreOptions'],
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
provide: 'ShopSettingsRepository',
|
|
588
|
+
useFactory: (options) => {
|
|
589
|
+
return new ShopSettingsFirestoreRepository(options);
|
|
590
|
+
},
|
|
591
|
+
deps: ['FirestoreOptions'],
|
|
592
|
+
},
|
|
593
|
+
{
|
|
594
|
+
provide: 'SubscriptionPaymentRepository',
|
|
595
|
+
useFactory: (options, subscriptionRepository) => {
|
|
596
|
+
return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
|
|
597
|
+
},
|
|
598
|
+
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
provide: 'SubscriptionPlanRepository',
|
|
602
|
+
useFactory: (options) => {
|
|
603
|
+
return new SubscriptionPlanFirestoreRepository(options);
|
|
604
|
+
},
|
|
605
|
+
deps: ['FirestoreOptions'],
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
provide: 'SubscriptionProductRepository',
|
|
609
|
+
useFactory: (options) => {
|
|
610
|
+
return new SubscriptionProductFirestoreRepository(options);
|
|
611
|
+
},
|
|
612
|
+
deps: ['FirestoreOptions'],
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
provide: 'SubscriptionRepository',
|
|
616
|
+
useFactory: (options) => {
|
|
617
|
+
return new SubscriptionFirestoreRepository(options);
|
|
618
|
+
},
|
|
619
|
+
deps: ['FirestoreOptions'],
|
|
620
|
+
},
|
|
621
|
+
{
|
|
622
|
+
provide: 'UserRepository',
|
|
623
|
+
useFactory: (options) => {
|
|
624
|
+
return new UserFirestoreRepository(options);
|
|
625
|
+
},
|
|
626
|
+
deps: ['FirestoreOptions'],
|
|
627
|
+
},
|
|
628
|
+
{
|
|
629
|
+
provide: 'UserAddressRepository',
|
|
630
|
+
useFactory: (options, userRepository) => {
|
|
631
|
+
return new UserAddressFirestoreRepository(options, userRepository);
|
|
632
|
+
},
|
|
633
|
+
deps: ['FirestoreOptions', 'UserRepository'],
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
provide: 'UserPaymentMethodRepository',
|
|
637
|
+
useFactory: (options, userRepository) => {
|
|
638
|
+
return new UserPaymentMethodFirestoreRepository(options, userRepository);
|
|
639
|
+
},
|
|
640
|
+
deps: ['FirestoreOptions', 'UserRepository'],
|
|
641
|
+
},
|
|
642
|
+
{
|
|
643
|
+
provide: 'SubscriptionMaterializationRepository',
|
|
644
|
+
useFactory: (options) => {
|
|
645
|
+
return new SubscriptionMaterializationFirestoreRepository(options);
|
|
646
|
+
},
|
|
647
|
+
deps: ['FirestoreOptions'],
|
|
648
|
+
},
|
|
649
|
+
{
|
|
650
|
+
provide: 'SubscriptionSummaryRepository',
|
|
651
|
+
useFactory: (options) => {
|
|
652
|
+
return new SubscriptionSummaryFirestoreRepository(options);
|
|
653
|
+
},
|
|
654
|
+
deps: ['FirestoreOptions'],
|
|
655
|
+
},
|
|
656
|
+
{
|
|
657
|
+
provide: ProductVariantFirestoreRepository,
|
|
658
|
+
useFactory: (options, productRepository) => {
|
|
659
|
+
return new ProductVariantFirestoreRepository(options, productRepository);
|
|
660
|
+
},
|
|
661
|
+
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
provide: 'FileUploaderService',
|
|
665
|
+
useFactory: (storage, baseUrl) => {
|
|
666
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
667
|
+
},
|
|
668
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
669
|
+
},
|
|
670
|
+
],
|
|
671
|
+
}]
|
|
672
672
|
}] });
|
|
673
673
|
|
|
674
|
-
class AngularHasuraGraphQLModule {
|
|
675
|
-
static initializeApp(options) {
|
|
676
|
-
return {
|
|
677
|
-
ngModule: AngularHasuraGraphQLModule,
|
|
678
|
-
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
683
|
-
AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
|
|
684
|
-
AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
|
|
685
|
-
{
|
|
686
|
-
provide: 'HasuraConfig',
|
|
687
|
-
useFactory: (options, platformId) => ({
|
|
688
|
-
endpoint: options.endpoint,
|
|
689
|
-
authOptions: options.credentials,
|
|
690
|
-
interceptors: {
|
|
691
|
-
request: (request) => {
|
|
692
|
-
if (isPlatformBrowser(platformId))
|
|
693
|
-
return request;
|
|
694
|
-
const interval = setInterval(() => { }, 100);
|
|
695
|
-
request.interval = interval;
|
|
696
|
-
return request;
|
|
697
|
-
},
|
|
698
|
-
response: (response, request) => {
|
|
699
|
-
if (isPlatformBrowser(platformId))
|
|
700
|
-
return response;
|
|
701
|
-
clearInterval(request.interval);
|
|
702
|
-
return response;
|
|
703
|
-
},
|
|
704
|
-
},
|
|
705
|
-
}),
|
|
706
|
-
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
707
|
-
},
|
|
708
|
-
{
|
|
709
|
-
provide: 'CategoryRepository',
|
|
710
|
-
useExisting: CategoryHasuraGraphQLRepository,
|
|
711
|
-
},
|
|
712
|
-
{
|
|
713
|
-
provide: CategoryHasuraGraphQLRepository,
|
|
714
|
-
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
715
|
-
return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
|
|
716
|
-
},
|
|
717
|
-
deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
718
|
-
},
|
|
719
|
-
{
|
|
720
|
-
provide: 'ProductRepository',
|
|
721
|
-
useExisting: ProductHasuraGraphQLRepository,
|
|
722
|
-
},
|
|
723
|
-
{
|
|
724
|
-
provide: ProductHasuraGraphQLRepository,
|
|
725
|
-
useFactory: (hasuraConfig) => {
|
|
726
|
-
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
727
|
-
},
|
|
728
|
-
deps: ['HasuraConfig'],
|
|
729
|
-
},
|
|
730
|
-
{
|
|
731
|
-
provide: 'ProductReviewsRepository',
|
|
732
|
-
useExisting: ProductReviewsHasuraGraphQLRepository,
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
provide: ProductReviewsHasuraGraphQLRepository,
|
|
736
|
-
useFactory: (hasuraConfig) => {
|
|
737
|
-
return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
|
|
738
|
-
},
|
|
739
|
-
deps: ['HasuraConfig'],
|
|
740
|
-
},
|
|
741
|
-
{
|
|
742
|
-
provide: 'VariantRepository',
|
|
743
|
-
useExisting: VariantHasuraGraphQLRepository,
|
|
744
|
-
},
|
|
745
|
-
{
|
|
746
|
-
provide: VariantHasuraGraphQLRepository,
|
|
747
|
-
useFactory: (hasuraConfig) => {
|
|
748
|
-
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
749
|
-
},
|
|
750
|
-
deps: ['HasuraConfig'],
|
|
751
|
-
},
|
|
752
|
-
{
|
|
753
|
-
provide: 'CategoryFilterRepository',
|
|
754
|
-
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
755
|
-
},
|
|
756
|
-
{
|
|
757
|
-
provide: CategoryFilterHasuraGraphQLRepository,
|
|
758
|
-
useFactory: (options) => {
|
|
759
|
-
return new CategoryFilterHasuraGraphQLRepository(options);
|
|
760
|
-
},
|
|
761
|
-
deps: ['HasuraConfig'],
|
|
762
|
-
},
|
|
763
|
-
{
|
|
764
|
-
provide: 'FilterOptionRepository',
|
|
765
|
-
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
766
|
-
},
|
|
767
|
-
{
|
|
768
|
-
provide: FilterOptionHasuraGraphQLRepository,
|
|
769
|
-
useFactory: (options) => {
|
|
770
|
-
return new FilterOptionHasuraGraphQLRepository(options);
|
|
771
|
-
},
|
|
772
|
-
deps: ['HasuraConfig'],
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
provide: 'FilterRepository',
|
|
776
|
-
useExisting: FilterHasuraGraphQLRepository,
|
|
777
|
-
},
|
|
778
|
-
{
|
|
779
|
-
provide: FilterHasuraGraphQLRepository,
|
|
780
|
-
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
781
|
-
return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
|
|
782
|
-
},
|
|
783
|
-
deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
784
|
-
},
|
|
785
|
-
{
|
|
786
|
-
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
787
|
-
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
|
|
788
|
-
deps: ['HasuraConfig'],
|
|
789
|
-
},
|
|
790
|
-
{
|
|
791
|
-
provide: 'CategoryCollectionChildrenRepository',
|
|
792
|
-
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
793
|
-
},
|
|
794
|
-
{
|
|
795
|
-
provide: WishlistHasuraGraphQLRepository,
|
|
796
|
-
useFactory: (options, categoryFilterRepository) => {
|
|
797
|
-
return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
|
|
798
|
-
},
|
|
799
|
-
deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
provide: 'WishlistRepository',
|
|
803
|
-
useExisting: WishlistHasuraGraphQLRepository,
|
|
804
|
-
},
|
|
805
|
-
] });
|
|
806
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
807
|
-
type: NgModule,
|
|
808
|
-
args: [{
|
|
809
|
-
providers: [
|
|
810
|
-
{
|
|
811
|
-
provide: 'HasuraConfig',
|
|
812
|
-
useFactory: (options, platformId) => ({
|
|
813
|
-
endpoint: options.endpoint,
|
|
814
|
-
authOptions: options.credentials,
|
|
815
|
-
interceptors: {
|
|
816
|
-
request: (request) => {
|
|
817
|
-
if (isPlatformBrowser(platformId))
|
|
818
|
-
return request;
|
|
819
|
-
const interval = setInterval(() => { }, 100);
|
|
820
|
-
request.interval = interval;
|
|
821
|
-
return request;
|
|
822
|
-
},
|
|
823
|
-
response: (response, request) => {
|
|
824
|
-
if (isPlatformBrowser(platformId))
|
|
825
|
-
return response;
|
|
826
|
-
clearInterval(request.interval);
|
|
827
|
-
return response;
|
|
828
|
-
},
|
|
829
|
-
},
|
|
830
|
-
}),
|
|
831
|
-
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
832
|
-
},
|
|
833
|
-
{
|
|
834
|
-
provide: 'CategoryRepository',
|
|
835
|
-
useExisting: CategoryHasuraGraphQLRepository,
|
|
836
|
-
},
|
|
837
|
-
{
|
|
838
|
-
provide: CategoryHasuraGraphQLRepository,
|
|
839
|
-
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
840
|
-
return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
|
|
841
|
-
},
|
|
842
|
-
deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
843
|
-
},
|
|
844
|
-
{
|
|
845
|
-
provide: 'ProductRepository',
|
|
846
|
-
useExisting: ProductHasuraGraphQLRepository,
|
|
847
|
-
},
|
|
848
|
-
{
|
|
849
|
-
provide: ProductHasuraGraphQLRepository,
|
|
850
|
-
useFactory: (hasuraConfig) => {
|
|
851
|
-
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
852
|
-
},
|
|
853
|
-
deps: ['HasuraConfig'],
|
|
854
|
-
},
|
|
855
|
-
{
|
|
856
|
-
provide: 'ProductReviewsRepository',
|
|
857
|
-
useExisting: ProductReviewsHasuraGraphQLRepository,
|
|
858
|
-
},
|
|
859
|
-
{
|
|
860
|
-
provide: ProductReviewsHasuraGraphQLRepository,
|
|
861
|
-
useFactory: (hasuraConfig) => {
|
|
862
|
-
return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
|
|
863
|
-
},
|
|
864
|
-
deps: ['HasuraConfig'],
|
|
865
|
-
},
|
|
866
|
-
{
|
|
867
|
-
provide: 'VariantRepository',
|
|
868
|
-
useExisting: VariantHasuraGraphQLRepository,
|
|
869
|
-
},
|
|
870
|
-
{
|
|
871
|
-
provide: VariantHasuraGraphQLRepository,
|
|
872
|
-
useFactory: (hasuraConfig) => {
|
|
873
|
-
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
874
|
-
},
|
|
875
|
-
deps: ['HasuraConfig'],
|
|
876
|
-
},
|
|
877
|
-
{
|
|
878
|
-
provide: 'CategoryFilterRepository',
|
|
879
|
-
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
880
|
-
},
|
|
881
|
-
{
|
|
882
|
-
provide: CategoryFilterHasuraGraphQLRepository,
|
|
883
|
-
useFactory: (options) => {
|
|
884
|
-
return new CategoryFilterHasuraGraphQLRepository(options);
|
|
885
|
-
},
|
|
886
|
-
deps: ['HasuraConfig'],
|
|
887
|
-
},
|
|
888
|
-
{
|
|
889
|
-
provide: 'FilterOptionRepository',
|
|
890
|
-
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
891
|
-
},
|
|
892
|
-
{
|
|
893
|
-
provide: FilterOptionHasuraGraphQLRepository,
|
|
894
|
-
useFactory: (options) => {
|
|
895
|
-
return new FilterOptionHasuraGraphQLRepository(options);
|
|
896
|
-
},
|
|
897
|
-
deps: ['HasuraConfig'],
|
|
898
|
-
},
|
|
899
|
-
{
|
|
900
|
-
provide: 'FilterRepository',
|
|
901
|
-
useExisting: FilterHasuraGraphQLRepository,
|
|
902
|
-
},
|
|
903
|
-
{
|
|
904
|
-
provide: FilterHasuraGraphQLRepository,
|
|
905
|
-
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
906
|
-
return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
|
|
907
|
-
},
|
|
908
|
-
deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
909
|
-
},
|
|
910
|
-
{
|
|
911
|
-
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
912
|
-
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
|
|
913
|
-
deps: ['HasuraConfig'],
|
|
914
|
-
},
|
|
915
|
-
{
|
|
916
|
-
provide: 'CategoryCollectionChildrenRepository',
|
|
917
|
-
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
918
|
-
},
|
|
919
|
-
{
|
|
920
|
-
provide: WishlistHasuraGraphQLRepository,
|
|
921
|
-
useFactory: (options, categoryFilterRepository) => {
|
|
922
|
-
return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
|
|
923
|
-
},
|
|
924
|
-
deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
|
|
925
|
-
},
|
|
926
|
-
{
|
|
927
|
-
provide: 'WishlistRepository',
|
|
928
|
-
useExisting: WishlistHasuraGraphQLRepository,
|
|
929
|
-
},
|
|
930
|
-
],
|
|
931
|
-
}]
|
|
674
|
+
class AngularHasuraGraphQLModule {
|
|
675
|
+
static initializeApp(options) {
|
|
676
|
+
return {
|
|
677
|
+
ngModule: AngularHasuraGraphQLModule,
|
|
678
|
+
providers: [{ provide: HASURA_OPTIONS, useValue: options }],
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
683
|
+
AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
|
|
684
|
+
AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
|
|
685
|
+
{
|
|
686
|
+
provide: 'HasuraConfig',
|
|
687
|
+
useFactory: (options, platformId) => ({
|
|
688
|
+
endpoint: options.endpoint,
|
|
689
|
+
authOptions: options.credentials,
|
|
690
|
+
interceptors: {
|
|
691
|
+
request: (request) => {
|
|
692
|
+
if (isPlatformBrowser(platformId))
|
|
693
|
+
return request;
|
|
694
|
+
const interval = setInterval(() => { }, 100);
|
|
695
|
+
request.interval = interval;
|
|
696
|
+
return request;
|
|
697
|
+
},
|
|
698
|
+
response: (response, request) => {
|
|
699
|
+
if (isPlatformBrowser(platformId))
|
|
700
|
+
return response;
|
|
701
|
+
clearInterval(request.interval);
|
|
702
|
+
return response;
|
|
703
|
+
},
|
|
704
|
+
},
|
|
705
|
+
}),
|
|
706
|
+
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
provide: 'CategoryRepository',
|
|
710
|
+
useExisting: CategoryHasuraGraphQLRepository,
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
provide: CategoryHasuraGraphQLRepository,
|
|
714
|
+
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
715
|
+
return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
|
|
716
|
+
},
|
|
717
|
+
deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
provide: 'ProductRepository',
|
|
721
|
+
useExisting: ProductHasuraGraphQLRepository,
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
provide: ProductHasuraGraphQLRepository,
|
|
725
|
+
useFactory: (hasuraConfig) => {
|
|
726
|
+
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
727
|
+
},
|
|
728
|
+
deps: ['HasuraConfig'],
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
provide: 'ProductReviewsRepository',
|
|
732
|
+
useExisting: ProductReviewsHasuraGraphQLRepository,
|
|
733
|
+
},
|
|
734
|
+
{
|
|
735
|
+
provide: ProductReviewsHasuraGraphQLRepository,
|
|
736
|
+
useFactory: (hasuraConfig) => {
|
|
737
|
+
return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
|
|
738
|
+
},
|
|
739
|
+
deps: ['HasuraConfig'],
|
|
740
|
+
},
|
|
741
|
+
{
|
|
742
|
+
provide: 'VariantRepository',
|
|
743
|
+
useExisting: VariantHasuraGraphQLRepository,
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
provide: VariantHasuraGraphQLRepository,
|
|
747
|
+
useFactory: (hasuraConfig) => {
|
|
748
|
+
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
749
|
+
},
|
|
750
|
+
deps: ['HasuraConfig'],
|
|
751
|
+
},
|
|
752
|
+
{
|
|
753
|
+
provide: 'CategoryFilterRepository',
|
|
754
|
+
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
755
|
+
},
|
|
756
|
+
{
|
|
757
|
+
provide: CategoryFilterHasuraGraphQLRepository,
|
|
758
|
+
useFactory: (options) => {
|
|
759
|
+
return new CategoryFilterHasuraGraphQLRepository(options);
|
|
760
|
+
},
|
|
761
|
+
deps: ['HasuraConfig'],
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
provide: 'FilterOptionRepository',
|
|
765
|
+
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
provide: FilterOptionHasuraGraphQLRepository,
|
|
769
|
+
useFactory: (options) => {
|
|
770
|
+
return new FilterOptionHasuraGraphQLRepository(options);
|
|
771
|
+
},
|
|
772
|
+
deps: ['HasuraConfig'],
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
provide: 'FilterRepository',
|
|
776
|
+
useExisting: FilterHasuraGraphQLRepository,
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
provide: FilterHasuraGraphQLRepository,
|
|
780
|
+
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
781
|
+
return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
|
|
782
|
+
},
|
|
783
|
+
deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
787
|
+
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
|
|
788
|
+
deps: ['HasuraConfig'],
|
|
789
|
+
},
|
|
790
|
+
{
|
|
791
|
+
provide: 'CategoryCollectionChildrenRepository',
|
|
792
|
+
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
provide: WishlistHasuraGraphQLRepository,
|
|
796
|
+
useFactory: (options, categoryFilterRepository) => {
|
|
797
|
+
return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
|
|
798
|
+
},
|
|
799
|
+
deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
|
|
800
|
+
},
|
|
801
|
+
{
|
|
802
|
+
provide: 'WishlistRepository',
|
|
803
|
+
useExisting: WishlistHasuraGraphQLRepository,
|
|
804
|
+
},
|
|
805
|
+
] });
|
|
806
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
807
|
+
type: NgModule,
|
|
808
|
+
args: [{
|
|
809
|
+
providers: [
|
|
810
|
+
{
|
|
811
|
+
provide: 'HasuraConfig',
|
|
812
|
+
useFactory: (options, platformId) => ({
|
|
813
|
+
endpoint: options.endpoint,
|
|
814
|
+
authOptions: options.credentials,
|
|
815
|
+
interceptors: {
|
|
816
|
+
request: (request) => {
|
|
817
|
+
if (isPlatformBrowser(platformId))
|
|
818
|
+
return request;
|
|
819
|
+
const interval = setInterval(() => { }, 100);
|
|
820
|
+
request.interval = interval;
|
|
821
|
+
return request;
|
|
822
|
+
},
|
|
823
|
+
response: (response, request) => {
|
|
824
|
+
if (isPlatformBrowser(platformId))
|
|
825
|
+
return response;
|
|
826
|
+
clearInterval(request.interval);
|
|
827
|
+
return response;
|
|
828
|
+
},
|
|
829
|
+
},
|
|
830
|
+
}),
|
|
831
|
+
deps: [HASURA_OPTIONS, PLATFORM_ID],
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
provide: 'CategoryRepository',
|
|
835
|
+
useExisting: CategoryHasuraGraphQLRepository,
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
provide: CategoryHasuraGraphQLRepository,
|
|
839
|
+
useFactory: (options, productRepository, categoryFilterRepository) => {
|
|
840
|
+
return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
|
|
841
|
+
},
|
|
842
|
+
deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
843
|
+
},
|
|
844
|
+
{
|
|
845
|
+
provide: 'ProductRepository',
|
|
846
|
+
useExisting: ProductHasuraGraphQLRepository,
|
|
847
|
+
},
|
|
848
|
+
{
|
|
849
|
+
provide: ProductHasuraGraphQLRepository,
|
|
850
|
+
useFactory: (hasuraConfig) => {
|
|
851
|
+
return new ProductHasuraGraphQLRepository(hasuraConfig);
|
|
852
|
+
},
|
|
853
|
+
deps: ['HasuraConfig'],
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
provide: 'ProductReviewsRepository',
|
|
857
|
+
useExisting: ProductReviewsHasuraGraphQLRepository,
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
provide: ProductReviewsHasuraGraphQLRepository,
|
|
861
|
+
useFactory: (hasuraConfig) => {
|
|
862
|
+
return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
|
|
863
|
+
},
|
|
864
|
+
deps: ['HasuraConfig'],
|
|
865
|
+
},
|
|
866
|
+
{
|
|
867
|
+
provide: 'VariantRepository',
|
|
868
|
+
useExisting: VariantHasuraGraphQLRepository,
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
provide: VariantHasuraGraphQLRepository,
|
|
872
|
+
useFactory: (hasuraConfig) => {
|
|
873
|
+
return new VariantHasuraGraphQLRepository(hasuraConfig);
|
|
874
|
+
},
|
|
875
|
+
deps: ['HasuraConfig'],
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
provide: 'CategoryFilterRepository',
|
|
879
|
+
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
provide: CategoryFilterHasuraGraphQLRepository,
|
|
883
|
+
useFactory: (options) => {
|
|
884
|
+
return new CategoryFilterHasuraGraphQLRepository(options);
|
|
885
|
+
},
|
|
886
|
+
deps: ['HasuraConfig'],
|
|
887
|
+
},
|
|
888
|
+
{
|
|
889
|
+
provide: 'FilterOptionRepository',
|
|
890
|
+
useExisting: FilterOptionHasuraGraphQLRepository,
|
|
891
|
+
},
|
|
892
|
+
{
|
|
893
|
+
provide: FilterOptionHasuraGraphQLRepository,
|
|
894
|
+
useFactory: (options) => {
|
|
895
|
+
return new FilterOptionHasuraGraphQLRepository(options);
|
|
896
|
+
},
|
|
897
|
+
deps: ['HasuraConfig'],
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
provide: 'FilterRepository',
|
|
901
|
+
useExisting: FilterHasuraGraphQLRepository,
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
provide: FilterHasuraGraphQLRepository,
|
|
905
|
+
useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
|
|
906
|
+
return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
|
|
907
|
+
},
|
|
908
|
+
deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
912
|
+
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
|
|
913
|
+
deps: ['HasuraConfig'],
|
|
914
|
+
},
|
|
915
|
+
{
|
|
916
|
+
provide: 'CategoryCollectionChildrenRepository',
|
|
917
|
+
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
provide: WishlistHasuraGraphQLRepository,
|
|
921
|
+
useFactory: (options, categoryFilterRepository) => {
|
|
922
|
+
return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
|
|
923
|
+
},
|
|
924
|
+
deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
|
|
925
|
+
},
|
|
926
|
+
{
|
|
927
|
+
provide: 'WishlistRepository',
|
|
928
|
+
useExisting: WishlistHasuraGraphQLRepository,
|
|
929
|
+
},
|
|
930
|
+
],
|
|
931
|
+
}]
|
|
932
932
|
}] });
|
|
933
933
|
|
|
934
|
-
class CookieDataPersistence {
|
|
935
|
-
get(key) {
|
|
936
|
-
return of(cookie.get(key));
|
|
937
|
-
}
|
|
938
|
-
remove(key) {
|
|
939
|
-
return of(cookie.remove(key));
|
|
940
|
-
}
|
|
941
|
-
set(key, value) {
|
|
942
|
-
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
CookieDataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
946
|
-
CookieDataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence });
|
|
947
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
948
|
-
type: Injectable
|
|
934
|
+
class CookieDataPersistence {
|
|
935
|
+
get(key) {
|
|
936
|
+
return of(cookie.get(key));
|
|
937
|
+
}
|
|
938
|
+
remove(key) {
|
|
939
|
+
return of(cookie.remove(key));
|
|
940
|
+
}
|
|
941
|
+
set(key, value) {
|
|
942
|
+
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
CookieDataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
946
|
+
CookieDataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence });
|
|
947
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
948
|
+
type: Injectable
|
|
949
949
|
}] });
|
|
950
950
|
|
|
951
|
-
class AuthService {
|
|
952
|
-
constructor(angularFireAuth, userRepository) {
|
|
953
|
-
this.angularFireAuth = angularFireAuth;
|
|
954
|
-
this.userRepository = userRepository;
|
|
955
|
-
}
|
|
956
|
-
getAuthstate() {
|
|
957
|
-
const observables = [this.getFireUser(), this.getUser()];
|
|
958
|
-
return combineLatest(observables).pipe(map(([fireUser, user]) => ({
|
|
959
|
-
user,
|
|
960
|
-
isAnonymous: fireUser?.isAnonymous,
|
|
961
|
-
})));
|
|
962
|
-
}
|
|
963
|
-
getUser() {
|
|
964
|
-
return this.getFireUser().pipe(map((user) => user?.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
|
|
965
|
-
}
|
|
966
|
-
getTokenId() {
|
|
967
|
-
return from(getIdToken(this.angularFireAuth.currentUser));
|
|
968
|
-
}
|
|
969
|
-
getFireUser() {
|
|
970
|
-
return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
|
|
971
|
-
}
|
|
972
|
-
}
|
|
973
|
-
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 });
|
|
974
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
|
|
975
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
|
|
976
|
-
type: Injectable
|
|
977
|
-
}], ctorParameters: function () { return [{ type: i1.Auth }, { type: undefined, decorators: [{
|
|
978
|
-
type: Inject,
|
|
979
|
-
args: ['UserRepository']
|
|
951
|
+
class AuthService {
|
|
952
|
+
constructor(angularFireAuth, userRepository) {
|
|
953
|
+
this.angularFireAuth = angularFireAuth;
|
|
954
|
+
this.userRepository = userRepository;
|
|
955
|
+
}
|
|
956
|
+
getAuthstate() {
|
|
957
|
+
const observables = [this.getFireUser(), this.getUser()];
|
|
958
|
+
return combineLatest(observables).pipe(map(([fireUser, user]) => ({
|
|
959
|
+
user,
|
|
960
|
+
isAnonymous: fireUser?.isAnonymous,
|
|
961
|
+
})));
|
|
962
|
+
}
|
|
963
|
+
getUser() {
|
|
964
|
+
return this.getFireUser().pipe(map((user) => user?.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
|
|
965
|
+
}
|
|
966
|
+
getTokenId() {
|
|
967
|
+
return from(getIdToken(this.angularFireAuth.currentUser));
|
|
968
|
+
}
|
|
969
|
+
getFireUser() {
|
|
970
|
+
return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
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 });
|
|
974
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
|
|
975
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
|
|
976
|
+
type: Injectable
|
|
977
|
+
}], ctorParameters: function () { return [{ type: i1.Auth }, { type: undefined, decorators: [{
|
|
978
|
+
type: Inject,
|
|
979
|
+
args: ['UserRepository']
|
|
980
980
|
}] }]; } });
|
|
981
981
|
|
|
982
|
-
class CouponService {
|
|
983
|
-
constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
|
|
984
|
-
this.couponRepository = couponRepository;
|
|
985
|
-
this.defaultShop = defaultShop;
|
|
986
|
-
this.orderRepository = orderRepository;
|
|
987
|
-
this.categoryRepository = categoryRepository;
|
|
988
|
-
this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
|
|
989
|
-
}
|
|
990
|
-
checkCoupon(nickname, checkoutType, checkout, plan) {
|
|
991
|
-
return from(this.couponRepository
|
|
992
|
-
.find({
|
|
993
|
-
filters: {
|
|
994
|
-
nickname: { operator: Where.EQUALS, value: nickname },
|
|
995
|
-
active: { operator: Where.EQUALS, value: true },
|
|
996
|
-
},
|
|
997
|
-
})
|
|
998
|
-
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
|
|
999
|
-
}
|
|
1000
|
-
async couponValidation(coupon, checkoutType) {
|
|
1001
|
-
if (!coupon)
|
|
1002
|
-
throw 'Cupom inválido.';
|
|
1003
|
-
if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
|
|
1004
|
-
throw 'Cupom inválido.';
|
|
1005
|
-
if (coupon?.expiresIn && coupon?.expiresIn.getTime() < new Date().getTime())
|
|
1006
|
-
throw 'Cupom expirado.';
|
|
1007
|
-
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
1008
|
-
if (!isInShop)
|
|
1009
|
-
throw 'Cupom inválido para loja.';
|
|
1010
|
-
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
1011
|
-
if (!isCheckoutType)
|
|
1012
|
-
throw 'Cupom inválido. Erro de checkout.';
|
|
1013
|
-
return coupon;
|
|
1014
|
-
}
|
|
1015
|
-
async couponRulesValidation(coupon, checkoutType, checkout, plan) {
|
|
1016
|
-
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
1017
|
-
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
1018
|
-
throw 'Cupom inválido para sua assinatura.';
|
|
1019
|
-
return coupon;
|
|
1020
|
-
}
|
|
1021
|
-
const validUser = this.coupomUserValidation(coupon, checkout?.user);
|
|
1022
|
-
if (!validUser)
|
|
1023
|
-
throw 'Usuário não elegível.';
|
|
1024
|
-
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
1025
|
-
if (couponUseLimits.firstOrder) {
|
|
1026
|
-
const ordersUser = await this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
|
|
1027
|
-
if (couponUseLimits.firstOrder && ordersUser.length >= 1)
|
|
1028
|
-
throw 'Limite de uso atingido';
|
|
1029
|
-
}
|
|
1030
|
-
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
1031
|
-
const orders = await this.getOrdersWithCoupon(coupon);
|
|
1032
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
1033
|
-
throw 'Limite de uso atingido.';
|
|
1034
|
-
if (couponUseLimits.limitedPerUser) {
|
|
1035
|
-
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
1036
|
-
if (ordersWithUser > 0)
|
|
1037
|
-
throw 'Limite de uso por usuário atingido.';
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
const hasProductCategories = await this.hasProductCategories(coupon, checkout);
|
|
1041
|
-
if (!hasProductCategories)
|
|
1042
|
-
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
1043
|
-
const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
|
|
1044
|
-
if (!hasMinSubTotal)
|
|
1045
|
-
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
|
|
1046
|
-
return coupon;
|
|
1047
|
-
}
|
|
1048
|
-
calcDiscountSubscription(coupon, checkout) {
|
|
1049
|
-
let discount = 0;
|
|
1050
|
-
if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
|
|
1051
|
-
discount = coupon.discount.subscription.value;
|
|
1052
|
-
else
|
|
1053
|
-
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
|
|
1054
|
-
return of(discount);
|
|
1055
|
-
}
|
|
1056
|
-
async calcDiscountShopping(coupon, checkout) {
|
|
1057
|
-
let discountInfo = null;
|
|
1058
|
-
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1059
|
-
discountInfo = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1060
|
-
}
|
|
1061
|
-
else {
|
|
1062
|
-
discountInfo = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1063
|
-
}
|
|
1064
|
-
return { discount: discountInfo.discount, lineItems: discountInfo.lineItems };
|
|
1065
|
-
}
|
|
1066
|
-
async calcDiscountByType(type, value, categories, checkout) {
|
|
1067
|
-
let discount = 0;
|
|
1068
|
-
let lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1069
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
|
|
1070
|
-
if (type == CouponTypes.ABSOLUTE) {
|
|
1071
|
-
discount = value > subTotal ? subTotal : value;
|
|
1072
|
-
}
|
|
1073
|
-
else {
|
|
1074
|
-
discount = subTotal * (value / 100);
|
|
1075
|
-
}
|
|
1076
|
-
const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
|
|
1077
|
-
return { discount, lineItems };
|
|
1078
|
-
}
|
|
1079
|
-
async hasMinSubTotal(coupon, checkout) {
|
|
1080
|
-
if (!coupon.minSubTotalValue)
|
|
1081
|
-
return true;
|
|
1082
|
-
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1083
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1084
|
-
if (coupon.minSubTotalValue <= subTotal)
|
|
1085
|
-
return true;
|
|
1086
|
-
return false;
|
|
1087
|
-
}
|
|
1088
|
-
async hasProductCategories(coupon, checkout) {
|
|
1089
|
-
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
1090
|
-
return true;
|
|
1091
|
-
}
|
|
1092
|
-
const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
|
|
1093
|
-
const hasCategories = checkout.lineItems?.filter((i) => {
|
|
1094
|
-
if (!i.categories || !i.categories?.length)
|
|
1095
|
-
return true;
|
|
1096
|
-
return i.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
1097
|
-
});
|
|
1098
|
-
return hasCategories.length ? true : false;
|
|
1099
|
-
}
|
|
1100
|
-
coupomUserValidation(coupon, user) {
|
|
1101
|
-
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
1102
|
-
return true;
|
|
1103
|
-
let userTypes = [];
|
|
1104
|
-
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
|
|
1105
|
-
this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
|
|
1106
|
-
userTypes.push(Exclusivities.COLLABORATORS);
|
|
1107
|
-
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
|
|
1108
|
-
coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
|
|
1109
|
-
userTypes.push(Exclusivities.SPECIFIC_USER);
|
|
1110
|
-
if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
1111
|
-
user.isSubscriber &&
|
|
1112
|
-
user.subscriptionPlan != '')
|
|
1113
|
-
userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
|
|
1114
|
-
if (user.isSubscriber &&
|
|
1115
|
-
user.subscriptionPlan == '' &&
|
|
1116
|
-
coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
|
|
1117
|
-
userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
|
|
1118
|
-
if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
1119
|
-
userTypes.push(Exclusivities.NON_SUBSCRIBER);
|
|
1120
|
-
return coupon.exclusivityType.some((r) => userTypes.includes(r));
|
|
1121
|
-
}
|
|
1122
|
-
async getCouponCategoriesId(productsCategories) {
|
|
1123
|
-
const couponCategories = [];
|
|
1124
|
-
for (let index = 0; index < productsCategories.length; index++) {
|
|
1125
|
-
const category = await this.categoryRepository.get({
|
|
1126
|
-
id: productsCategories[index],
|
|
1127
|
-
});
|
|
1128
|
-
if (category) {
|
|
1129
|
-
const children = await this.categoryRepository.getChildren(parseInt(productsCategories[index]));
|
|
1130
|
-
couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
return [...new Set(couponCategories)];
|
|
1134
|
-
}
|
|
1135
|
-
async getLineItensEligebleForDiscount(productsCategories, checkout) {
|
|
1136
|
-
let lineItensDiscount = [];
|
|
1137
|
-
const couponCategories = await this.getCouponCategoriesId(productsCategories);
|
|
1138
|
-
if (productsCategories && productsCategories.length) {
|
|
1139
|
-
lineItensDiscount = checkout.lineItems?.filter((i) => {
|
|
1140
|
-
if (i.categories?.length) {
|
|
1141
|
-
return i.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
1142
|
-
}
|
|
1143
|
-
return true;
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
else {
|
|
1147
|
-
lineItensDiscount = checkout.lineItems;
|
|
1148
|
-
}
|
|
1149
|
-
return lineItensDiscount;
|
|
1150
|
-
}
|
|
1151
|
-
calcCheckoutSubtotal(lineItens, user) {
|
|
1152
|
-
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1153
|
-
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1154
|
-
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
1155
|
-
}
|
|
1156
|
-
async getOrdersWithCoupon(coupon) {
|
|
1157
|
-
return await this.orderRepository
|
|
1158
|
-
.find({
|
|
1159
|
-
filters: {
|
|
1160
|
-
coupon: { id: coupon.id },
|
|
1161
|
-
payment: { status: 'paid' },
|
|
1162
|
-
},
|
|
1163
|
-
})
|
|
1164
|
-
.then((result) => result.data);
|
|
1165
|
-
}
|
|
1166
|
-
async getOrdersFromUser(email) {
|
|
1167
|
-
return await this.orderRepository
|
|
1168
|
-
.find({
|
|
1169
|
-
filters: {
|
|
1170
|
-
user: { email: { operator: Where.EQUALS, value: email } },
|
|
1171
|
-
payment: { status: 'paid' },
|
|
1172
|
-
},
|
|
1173
|
-
})
|
|
1174
|
-
.then((result) => result.data);
|
|
1175
|
-
}
|
|
1176
|
-
countOrdersWithUser(orders, email) {
|
|
1177
|
-
return orders.filter((o) => o.user.email == email).length;
|
|
1178
|
-
}
|
|
1179
|
-
getCouponUseLimits(coupon, checkoutType, user) {
|
|
1180
|
-
let couponUseLimits;
|
|
1181
|
-
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
1182
|
-
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1183
|
-
}
|
|
1184
|
-
else {
|
|
1185
|
-
couponUseLimits = coupon.useLimits.subscription;
|
|
1186
|
-
}
|
|
1187
|
-
return couponUseLimits;
|
|
1188
|
-
}
|
|
1189
|
-
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1190
|
-
let lineItemsDiscount = [];
|
|
1191
|
-
if (type === CouponTypes.ABSOLUTE) {
|
|
1192
|
-
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1193
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1194
|
-
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1195
|
-
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
i0.ɵɵ
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
982
|
+
class CouponService {
|
|
983
|
+
constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
|
|
984
|
+
this.couponRepository = couponRepository;
|
|
985
|
+
this.defaultShop = defaultShop;
|
|
986
|
+
this.orderRepository = orderRepository;
|
|
987
|
+
this.categoryRepository = categoryRepository;
|
|
988
|
+
this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
|
|
989
|
+
}
|
|
990
|
+
checkCoupon(nickname, checkoutType, checkout, plan) {
|
|
991
|
+
return from(this.couponRepository
|
|
992
|
+
.find({
|
|
993
|
+
filters: {
|
|
994
|
+
nickname: { operator: Where.EQUALS, value: nickname },
|
|
995
|
+
active: { operator: Where.EQUALS, value: true },
|
|
996
|
+
},
|
|
997
|
+
})
|
|
998
|
+
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
|
|
999
|
+
}
|
|
1000
|
+
async couponValidation(coupon, checkoutType) {
|
|
1001
|
+
if (!coupon)
|
|
1002
|
+
throw 'Cupom inválido.';
|
|
1003
|
+
if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
|
|
1004
|
+
throw 'Cupom inválido.';
|
|
1005
|
+
if (coupon?.expiresIn && coupon?.expiresIn.getTime() < new Date().getTime())
|
|
1006
|
+
throw 'Cupom expirado.';
|
|
1007
|
+
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
1008
|
+
if (!isInShop)
|
|
1009
|
+
throw 'Cupom inválido para loja.';
|
|
1010
|
+
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
1011
|
+
if (!isCheckoutType)
|
|
1012
|
+
throw 'Cupom inválido. Erro de checkout.';
|
|
1013
|
+
return coupon;
|
|
1014
|
+
}
|
|
1015
|
+
async couponRulesValidation(coupon, checkoutType, checkout, plan) {
|
|
1016
|
+
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
1017
|
+
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
1018
|
+
throw 'Cupom inválido para sua assinatura.';
|
|
1019
|
+
return coupon;
|
|
1020
|
+
}
|
|
1021
|
+
const validUser = this.coupomUserValidation(coupon, checkout?.user);
|
|
1022
|
+
if (!validUser)
|
|
1023
|
+
throw 'Usuário não elegível.';
|
|
1024
|
+
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
1025
|
+
if (couponUseLimits.firstOrder) {
|
|
1026
|
+
const ordersUser = await this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
|
|
1027
|
+
if (couponUseLimits.firstOrder && ordersUser.length >= 1)
|
|
1028
|
+
throw 'Limite de uso atingido';
|
|
1029
|
+
}
|
|
1030
|
+
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
1031
|
+
const orders = await this.getOrdersWithCoupon(coupon);
|
|
1032
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
1033
|
+
throw 'Limite de uso atingido.';
|
|
1034
|
+
if (couponUseLimits.limitedPerUser) {
|
|
1035
|
+
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
1036
|
+
if (ordersWithUser > 0)
|
|
1037
|
+
throw 'Limite de uso por usuário atingido.';
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
const hasProductCategories = await this.hasProductCategories(coupon, checkout);
|
|
1041
|
+
if (!hasProductCategories)
|
|
1042
|
+
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
1043
|
+
const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
|
|
1044
|
+
if (!hasMinSubTotal)
|
|
1045
|
+
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
|
|
1046
|
+
return coupon;
|
|
1047
|
+
}
|
|
1048
|
+
calcDiscountSubscription(coupon, checkout) {
|
|
1049
|
+
let discount = 0;
|
|
1050
|
+
if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
|
|
1051
|
+
discount = coupon.discount.subscription.value;
|
|
1052
|
+
else
|
|
1053
|
+
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
|
|
1054
|
+
return of(discount);
|
|
1055
|
+
}
|
|
1056
|
+
async calcDiscountShopping(coupon, checkout) {
|
|
1057
|
+
let discountInfo = null;
|
|
1058
|
+
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1059
|
+
discountInfo = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1060
|
+
}
|
|
1061
|
+
else {
|
|
1062
|
+
discountInfo = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1063
|
+
}
|
|
1064
|
+
return { discount: discountInfo.discount, lineItems: discountInfo.lineItems };
|
|
1065
|
+
}
|
|
1066
|
+
async calcDiscountByType(type, value, categories, checkout) {
|
|
1067
|
+
let discount = 0;
|
|
1068
|
+
let lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1069
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
|
|
1070
|
+
if (type == CouponTypes.ABSOLUTE) {
|
|
1071
|
+
discount = value > subTotal ? subTotal : value;
|
|
1072
|
+
}
|
|
1073
|
+
else {
|
|
1074
|
+
discount = subTotal * (value / 100);
|
|
1075
|
+
}
|
|
1076
|
+
const lineItems = this.calcLineItenDiscount(type, lineItensElegibleForDiscount, value, subTotal);
|
|
1077
|
+
return { discount, lineItems };
|
|
1078
|
+
}
|
|
1079
|
+
async hasMinSubTotal(coupon, checkout) {
|
|
1080
|
+
if (!coupon.minSubTotalValue)
|
|
1081
|
+
return true;
|
|
1082
|
+
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1083
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1084
|
+
if (coupon.minSubTotalValue <= subTotal)
|
|
1085
|
+
return true;
|
|
1086
|
+
return false;
|
|
1087
|
+
}
|
|
1088
|
+
async hasProductCategories(coupon, checkout) {
|
|
1089
|
+
if (!coupon.productsCategories || !coupon.productsCategories.length) {
|
|
1090
|
+
return true;
|
|
1091
|
+
}
|
|
1092
|
+
const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
|
|
1093
|
+
const hasCategories = checkout.lineItems?.filter((i) => {
|
|
1094
|
+
if (!i.categories || !i.categories?.length)
|
|
1095
|
+
return true;
|
|
1096
|
+
return i.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
1097
|
+
});
|
|
1098
|
+
return hasCategories.length ? true : false;
|
|
1099
|
+
}
|
|
1100
|
+
coupomUserValidation(coupon, user) {
|
|
1101
|
+
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
1102
|
+
return true;
|
|
1103
|
+
let userTypes = [];
|
|
1104
|
+
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
|
|
1105
|
+
this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
|
|
1106
|
+
userTypes.push(Exclusivities.COLLABORATORS);
|
|
1107
|
+
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
|
|
1108
|
+
coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
|
|
1109
|
+
userTypes.push(Exclusivities.SPECIFIC_USER);
|
|
1110
|
+
if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
1111
|
+
user.isSubscriber &&
|
|
1112
|
+
user.subscriptionPlan != '')
|
|
1113
|
+
userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
|
|
1114
|
+
if (user.isSubscriber &&
|
|
1115
|
+
user.subscriptionPlan == '' &&
|
|
1116
|
+
coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
|
|
1117
|
+
userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
|
|
1118
|
+
if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
1119
|
+
userTypes.push(Exclusivities.NON_SUBSCRIBER);
|
|
1120
|
+
return coupon.exclusivityType.some((r) => userTypes.includes(r));
|
|
1121
|
+
}
|
|
1122
|
+
async getCouponCategoriesId(productsCategories) {
|
|
1123
|
+
const couponCategories = [];
|
|
1124
|
+
for (let index = 0; index < productsCategories.length; index++) {
|
|
1125
|
+
const category = await this.categoryRepository.get({
|
|
1126
|
+
id: productsCategories[index],
|
|
1127
|
+
});
|
|
1128
|
+
if (category) {
|
|
1129
|
+
const children = await this.categoryRepository.getChildren(parseInt(productsCategories[index]));
|
|
1130
|
+
couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
return [...new Set(couponCategories)];
|
|
1134
|
+
}
|
|
1135
|
+
async getLineItensEligebleForDiscount(productsCategories, checkout) {
|
|
1136
|
+
let lineItensDiscount = [];
|
|
1137
|
+
const couponCategories = await this.getCouponCategoriesId(productsCategories);
|
|
1138
|
+
if (productsCategories && productsCategories.length) {
|
|
1139
|
+
lineItensDiscount = checkout.lineItems?.filter((i) => {
|
|
1140
|
+
if (i.categories?.length) {
|
|
1141
|
+
return i.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
1142
|
+
}
|
|
1143
|
+
return true;
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
else {
|
|
1147
|
+
lineItensDiscount = checkout.lineItems;
|
|
1148
|
+
}
|
|
1149
|
+
return lineItensDiscount;
|
|
1150
|
+
}
|
|
1151
|
+
calcCheckoutSubtotal(lineItens, user) {
|
|
1152
|
+
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1153
|
+
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1154
|
+
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
1155
|
+
}
|
|
1156
|
+
async getOrdersWithCoupon(coupon) {
|
|
1157
|
+
return await this.orderRepository
|
|
1158
|
+
.find({
|
|
1159
|
+
filters: {
|
|
1160
|
+
coupon: { id: coupon.id },
|
|
1161
|
+
payment: { status: 'paid' },
|
|
1162
|
+
},
|
|
1163
|
+
})
|
|
1164
|
+
.then((result) => result.data);
|
|
1165
|
+
}
|
|
1166
|
+
async getOrdersFromUser(email) {
|
|
1167
|
+
return await this.orderRepository
|
|
1168
|
+
.find({
|
|
1169
|
+
filters: {
|
|
1170
|
+
user: { email: { operator: Where.EQUALS, value: email } },
|
|
1171
|
+
payment: { status: 'paid' },
|
|
1172
|
+
},
|
|
1173
|
+
})
|
|
1174
|
+
.then((result) => result.data);
|
|
1175
|
+
}
|
|
1176
|
+
countOrdersWithUser(orders, email) {
|
|
1177
|
+
return orders.filter((o) => o.user.email == email).length;
|
|
1178
|
+
}
|
|
1179
|
+
getCouponUseLimits(coupon, checkoutType, user) {
|
|
1180
|
+
let couponUseLimits;
|
|
1181
|
+
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
1182
|
+
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1183
|
+
}
|
|
1184
|
+
else {
|
|
1185
|
+
couponUseLimits = coupon.useLimits.subscription;
|
|
1186
|
+
}
|
|
1187
|
+
return couponUseLimits;
|
|
1188
|
+
}
|
|
1189
|
+
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1190
|
+
let lineItemsDiscount = [];
|
|
1191
|
+
if (type === CouponTypes.ABSOLUTE) {
|
|
1192
|
+
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1193
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1194
|
+
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1195
|
+
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1196
|
+
console.log(item.name, item.pricePaid, subTotal, 'absolute', couponDiscountMax, totalItemPercentage, discountItem);
|
|
1197
|
+
return {
|
|
1198
|
+
...item,
|
|
1199
|
+
discount: Number(discountItem.toFixed(2)),
|
|
1200
|
+
};
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
else {
|
|
1204
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1205
|
+
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1206
|
+
console.log(item.name, item.pricePaid, 'percentage', couponDiscount, discountItem);
|
|
1207
|
+
return {
|
|
1208
|
+
...item,
|
|
1209
|
+
discount: Number(discountItem.toFixed(2)),
|
|
1210
|
+
};
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
return lineItemsDiscount;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
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 });
|
|
1217
|
+
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
1218
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
|
|
1219
|
+
type: Injectable,
|
|
1220
|
+
args: [{
|
|
1221
|
+
providedIn: 'root',
|
|
1222
|
+
}]
|
|
1223
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1224
|
+
type: Inject,
|
|
1225
|
+
args: ['CouponRepository']
|
|
1226
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1227
|
+
type: Inject,
|
|
1228
|
+
args: [DEFAULT_SHOP]
|
|
1229
|
+
}] }, { type: undefined, decorators: [{
|
|
1230
|
+
type: Inject,
|
|
1231
|
+
args: ['OrderRepository']
|
|
1232
|
+
}] }, { type: undefined, decorators: [{
|
|
1233
|
+
type: Inject,
|
|
1234
|
+
args: ['CategoryRepository']
|
|
1233
1235
|
}] }]; } });
|
|
1234
1236
|
|
|
1235
|
-
class CheckoutService {
|
|
1236
|
-
constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
|
|
1237
|
-
this.couponService = couponService;
|
|
1238
|
-
this.checkoutRepository = checkoutRepository;
|
|
1239
|
-
this.userRepository = userRepository;
|
|
1240
|
-
this.defaultShop = defaultShop;
|
|
1241
|
-
this.dataPersistence = dataPersistence;
|
|
1242
|
-
}
|
|
1243
|
-
getCheckout(checkoutData) {
|
|
1244
|
-
return this.dataPersistence
|
|
1245
|
-
.get('checkoutId')
|
|
1246
|
-
.pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
|
|
1247
|
-
}
|
|
1248
|
-
getUserByCheckout(checkoutId) {
|
|
1249
|
-
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
1250
|
-
}
|
|
1251
|
-
updateCheckoutLineItems(checkout) {
|
|
1252
|
-
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
1253
|
-
}
|
|
1254
|
-
updateCheckoutUser(checkout) {
|
|
1255
|
-
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1256
|
-
}
|
|
1257
|
-
clearCheckoutFromSession() {
|
|
1258
|
-
return this.dataPersistence.remove('checkoutId');
|
|
1259
|
-
}
|
|
1260
|
-
calcDiscount(coupon) {
|
|
1261
|
-
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
1262
|
-
}
|
|
1263
|
-
checkCoupon(nickname, checkoutType) {
|
|
1264
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
|
|
1265
|
-
}
|
|
1266
|
-
async createCheckout(checkoutData) {
|
|
1267
|
-
const checkout = await this.checkoutRepository.create({
|
|
1268
|
-
createdAt: new Date(),
|
|
1269
|
-
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1270
|
-
shop: checkoutData?.shop || this.defaultShop,
|
|
1271
|
-
});
|
|
1272
|
-
await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1273
|
-
return checkout;
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }, { token: PERSISTENCE_PROVIDER }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1277
|
-
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
|
|
1278
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
|
|
1279
|
-
type: Injectable
|
|
1280
|
-
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1281
|
-
type: Inject,
|
|
1282
|
-
args: ['CheckoutRepository']
|
|
1283
|
-
}] }, { type: undefined, decorators: [{
|
|
1284
|
-
type: Inject,
|
|
1285
|
-
args: ['UserRepository']
|
|
1286
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
1287
|
-
type: Inject,
|
|
1288
|
-
args: [DEFAULT_SHOP]
|
|
1289
|
-
}] }, { type: undefined, decorators: [{
|
|
1290
|
-
type: Inject,
|
|
1291
|
-
args: [PERSISTENCE_PROVIDER]
|
|
1237
|
+
class CheckoutService {
|
|
1238
|
+
constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
|
|
1239
|
+
this.couponService = couponService;
|
|
1240
|
+
this.checkoutRepository = checkoutRepository;
|
|
1241
|
+
this.userRepository = userRepository;
|
|
1242
|
+
this.defaultShop = defaultShop;
|
|
1243
|
+
this.dataPersistence = dataPersistence;
|
|
1244
|
+
}
|
|
1245
|
+
getCheckout(checkoutData) {
|
|
1246
|
+
return this.dataPersistence
|
|
1247
|
+
.get('checkoutId')
|
|
1248
|
+
.pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
|
|
1249
|
+
}
|
|
1250
|
+
getUserByCheckout(checkoutId) {
|
|
1251
|
+
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
1252
|
+
}
|
|
1253
|
+
updateCheckoutLineItems(checkout) {
|
|
1254
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
1255
|
+
}
|
|
1256
|
+
updateCheckoutUser(checkout) {
|
|
1257
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1258
|
+
}
|
|
1259
|
+
clearCheckoutFromSession() {
|
|
1260
|
+
return this.dataPersistence.remove('checkoutId');
|
|
1261
|
+
}
|
|
1262
|
+
calcDiscount(coupon) {
|
|
1263
|
+
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
1264
|
+
}
|
|
1265
|
+
checkCoupon(nickname, checkoutType) {
|
|
1266
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
|
|
1267
|
+
}
|
|
1268
|
+
async createCheckout(checkoutData) {
|
|
1269
|
+
const checkout = await this.checkoutRepository.create({
|
|
1270
|
+
createdAt: new Date(),
|
|
1271
|
+
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1272
|
+
shop: checkoutData?.shop || this.defaultShop,
|
|
1273
|
+
});
|
|
1274
|
+
await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1275
|
+
return checkout;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }, { token: PERSISTENCE_PROVIDER }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1279
|
+
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
|
|
1280
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
|
|
1281
|
+
type: Injectable
|
|
1282
|
+
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1283
|
+
type: Inject,
|
|
1284
|
+
args: ['CheckoutRepository']
|
|
1285
|
+
}] }, { type: undefined, decorators: [{
|
|
1286
|
+
type: Inject,
|
|
1287
|
+
args: ['UserRepository']
|
|
1288
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1289
|
+
type: Inject,
|
|
1290
|
+
args: [DEFAULT_SHOP]
|
|
1291
|
+
}] }, { type: undefined, decorators: [{
|
|
1292
|
+
type: Inject,
|
|
1293
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1292
1294
|
}] }]; } });
|
|
1293
1295
|
|
|
1294
|
-
class CartService {
|
|
1295
|
-
constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
|
|
1296
|
-
this.authService = authService;
|
|
1297
|
-
this.checkoutService = checkoutService;
|
|
1298
|
-
this.defaultShop = defaultShop;
|
|
1299
|
-
this.productRepository = productRepository;
|
|
1300
|
-
this.categoryRepository = categoryRepository;
|
|
1301
|
-
this.variantRepository = variantRepository;
|
|
1302
|
-
this.buy2WinRepository = buy2WinRepository;
|
|
1303
|
-
this.cartSubject = new Subject();
|
|
1304
|
-
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
1305
|
-
const items = [];
|
|
1306
|
-
const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
|
|
1307
|
-
if (index > -1) {
|
|
1308
|
-
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
1309
|
-
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
1310
|
-
}
|
|
1311
|
-
else
|
|
1312
|
-
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
1313
|
-
return this.checkoutService
|
|
1314
|
-
.updateCheckoutLineItems(checkoutLoaded)
|
|
1315
|
-
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
1316
|
-
}));
|
|
1317
|
-
this.generateCartObject = (items) => items?.reduce((cart, item) => ({
|
|
1318
|
-
...cart,
|
|
1319
|
-
[item.id]: LineItem.toInstance({
|
|
1320
|
-
...(cart[item.id] || item),
|
|
1321
|
-
quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
|
|
1322
|
-
}),
|
|
1323
|
-
}), {}) || {};
|
|
1324
|
-
this.buildLineItem = async ({ checkout, item, quantity, }) => {
|
|
1325
|
-
const product = await this.getProductData(item.id);
|
|
1326
|
-
item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
|
|
1327
|
-
if (this.checkMaxStock(item, quantity || 0))
|
|
1328
|
-
throw new Error('Desculpe! Temos apenas ' + item.stock?.quantity + ' em estoque.');
|
|
1329
|
-
const image = item.image || item.images?.shift();
|
|
1330
|
-
const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
|
|
1331
|
-
const isGift = item.isGift || null;
|
|
1332
|
-
const pricePaid = this.getProductPrice({
|
|
1333
|
-
product: item,
|
|
1334
|
-
shop: checkout.shop || this.defaultShop,
|
|
1335
|
-
isSubscriber: checkout.user?.isSubscriber,
|
|
1336
|
-
});
|
|
1337
|
-
RoundProductPricesHelper.roundProductPrices(item);
|
|
1338
|
-
return {
|
|
1339
|
-
checkout,
|
|
1340
|
-
lineItem: LineItem.toInstance({
|
|
1341
|
-
id,
|
|
1342
|
-
name: name ?? product.name,
|
|
1343
|
-
EAN: EAN ?? product.EAN,
|
|
1344
|
-
brand: product.brand,
|
|
1345
|
-
slug: slug ?? product.slug,
|
|
1346
|
-
sku: sku ?? product.sku,
|
|
1347
|
-
stock,
|
|
1348
|
-
price: this.roundPrice(price),
|
|
1349
|
-
image,
|
|
1350
|
-
weight: weight ?? product.weight,
|
|
1351
|
-
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1352
|
-
pricePaid,
|
|
1353
|
-
discount: 0,
|
|
1354
|
-
categories: product.categories ?? [],
|
|
1355
|
-
isGift: isGift ?? null,
|
|
1356
|
-
costPrice: product.costPrice ?? 0,
|
|
1357
|
-
type,
|
|
1358
|
-
}),
|
|
1359
|
-
};
|
|
1360
|
-
};
|
|
1361
|
-
this.getProductPrice = ({ product, isSubscriber, }) => {
|
|
1362
|
-
const info = product.price;
|
|
1363
|
-
if (product.isGift)
|
|
1364
|
-
return 0;
|
|
1365
|
-
return isSubscriber && info.subscriberPrice > 0
|
|
1366
|
-
? Number(info.subscriberPrice.toFixed(2))
|
|
1367
|
-
: Number(info.price.toFixed(2));
|
|
1368
|
-
};
|
|
1369
|
-
this.checkMaxStock = (item, quantity) => {
|
|
1370
|
-
const maxStock = item.stock?.quantity || 0;
|
|
1371
|
-
const currentItemAmount = item.quantity || 0;
|
|
1372
|
-
return currentItemAmount + quantity > maxStock;
|
|
1373
|
-
};
|
|
1374
|
-
}
|
|
1375
|
-
addItem(item, quantity = 1) {
|
|
1376
|
-
return from(this.checkoutService.getCheckout()).pipe(concatMap(async (checkout) => await this.buildLineItem({ checkout, item, quantity: quantity || 1 })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
|
|
1377
|
-
}
|
|
1378
|
-
decreaseItem(item) {
|
|
1379
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1380
|
-
const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id);
|
|
1381
|
-
if (!isNil(checkoutItem))
|
|
1382
|
-
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
1383
|
-
return checkout;
|
|
1384
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1385
|
-
}
|
|
1386
|
-
getCart(checkout) {
|
|
1387
|
-
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
1388
|
-
return this.cartSubject;
|
|
1389
|
-
}
|
|
1390
|
-
/**
|
|
1391
|
-
* @deprecated The method should not be used
|
|
1392
|
-
*/
|
|
1393
|
-
getVariantPriceDiscount(item) {
|
|
1394
|
-
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)));
|
|
1395
|
-
}
|
|
1396
|
-
removeItem(item) {
|
|
1397
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1398
|
-
const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
|
|
1399
|
-
if (index >= 0)
|
|
1400
|
-
checkout.lineItems.splice(index, 1);
|
|
1401
|
-
return checkout;
|
|
1402
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1403
|
-
}
|
|
1404
|
-
updateUserCart(user) {
|
|
1405
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => await this.checkoutService
|
|
1406
|
-
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1407
|
-
...checkout.toPlain(),
|
|
1408
|
-
lineItems: checkout.lineItems?.length
|
|
1409
|
-
? await Promise.all(checkout.lineItems?.map(async (item) => (await this.buildLineItem({ checkout, item })).lineItem))
|
|
1410
|
-
: [],
|
|
1411
|
-
}))
|
|
1412
|
-
.toPromise()), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1413
|
-
}
|
|
1414
|
-
clearCart() {
|
|
1415
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1416
|
-
this.checkoutService.clearCheckoutFromSession();
|
|
1417
|
-
return checkout;
|
|
1418
|
-
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
1419
|
-
}
|
|
1420
|
-
buildCartFromCheckout(checkoutData) {
|
|
1421
|
-
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1422
|
-
}
|
|
1423
|
-
roundPrice(productPrice) {
|
|
1424
|
-
const { price, fullPrice, subscriberPrice } = productPrice;
|
|
1425
|
-
return {
|
|
1426
|
-
...productPrice,
|
|
1427
|
-
price: Number(price.toFixed(2)),
|
|
1428
|
-
fullPrice: Number(fullPrice.toFixed(2)),
|
|
1429
|
-
...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
|
|
1430
|
-
};
|
|
1431
|
-
}
|
|
1432
|
-
async getProductData(productId) {
|
|
1433
|
-
let product;
|
|
1434
|
-
let variant;
|
|
1435
|
-
try {
|
|
1436
|
-
product = await this.productRepository.get({ id: productId });
|
|
1437
|
-
}
|
|
1438
|
-
catch (error) {
|
|
1439
|
-
if (!(error instanceof NotFoundError))
|
|
1440
|
-
throw error;
|
|
1441
|
-
const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
|
|
1442
|
-
variant = variants.shift();
|
|
1443
|
-
if (!variant)
|
|
1444
|
-
throw error;
|
|
1445
|
-
product = await this.productRepository.get({ id: variant.productId });
|
|
1446
|
-
}
|
|
1447
|
-
return {
|
|
1448
|
-
...product.toPlain(),
|
|
1449
|
-
...(variant && { ...variant.toPlain() }),
|
|
1450
|
-
};
|
|
1451
|
-
}
|
|
1452
|
-
getGifts() {
|
|
1453
|
-
return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
|
|
1454
|
-
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1455
|
-
if (!notGiftItems.length)
|
|
1456
|
-
return { ...checkout, lineItems: [] };
|
|
1457
|
-
const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1458
|
-
const campaigns = await this.buy2WinRepository
|
|
1459
|
-
.find({
|
|
1460
|
-
filters: {
|
|
1461
|
-
active: { operator: Where.EQUALS, value: true },
|
|
1462
|
-
shop: { operator: Where.EQUALS, value: this.defaultShop },
|
|
1463
|
-
},
|
|
1464
|
-
})
|
|
1465
|
-
.then((data) => data.data);
|
|
1466
|
-
if (!campaigns.length)
|
|
1467
|
-
return { ...checkout, lineItems: notGiftItems };
|
|
1468
|
-
const elegibleCampaigns = [];
|
|
1469
|
-
for (const campaign of campaigns) {
|
|
1470
|
-
const today = new Date().getTime();
|
|
1471
|
-
if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
|
|
1472
|
-
continue;
|
|
1473
|
-
if (campaign.activeCategory) {
|
|
1474
|
-
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
1475
|
-
const categoriesCampaingFullTree = [];
|
|
1476
|
-
for (const id of categoriesCampaing) {
|
|
1477
|
-
const children = await this.categoryRepository.getChildren(parseInt(id));
|
|
1478
|
-
categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
|
|
1479
|
-
}
|
|
1480
|
-
const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
|
|
1481
|
-
const filterProductsCategories = checkout.lineItems.filter((l) => {
|
|
1482
|
-
if (!l.categories || !l.categories?.length)
|
|
1483
|
-
return true;
|
|
1484
|
-
return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
|
|
1485
|
-
});
|
|
1486
|
-
if (filterProductsCategories.length) {
|
|
1487
|
-
const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1488
|
-
if (cartTotalCategories >= campaign.cartValueMin)
|
|
1489
|
-
elegibleCampaigns.push(campaign);
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
else {
|
|
1493
|
-
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
1494
|
-
if (campaign.cartValue <= cartTotal)
|
|
1495
|
-
elegibleCampaigns.push(campaign);
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
if (!elegibleCampaigns.length)
|
|
1500
|
-
return { ...checkout, lineItems: notGiftItems };
|
|
1501
|
-
const campaingnProducts = [];
|
|
1502
|
-
for (const campaign of elegibleCampaigns) {
|
|
1503
|
-
let elegibleProducts = [];
|
|
1504
|
-
for (const product of campaign.products) {
|
|
1505
|
-
const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
|
|
1506
|
-
if (!productData.length)
|
|
1507
|
-
continue;
|
|
1508
|
-
const gift = productData.shift();
|
|
1509
|
-
if (gift.stock.quantity < 1)
|
|
1510
|
-
continue;
|
|
1511
|
-
elegibleProducts.push(gift);
|
|
1512
|
-
}
|
|
1513
|
-
campaingnProducts.push(elegibleProducts);
|
|
1514
|
-
}
|
|
1515
|
-
if (!campaingnProducts.length)
|
|
1516
|
-
return { ...checkout, lineItems: notGiftItems };
|
|
1517
|
-
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
1518
|
-
return { ...checkout, lineItems: notGiftItems.concat(gifts) };
|
|
1519
|
-
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1520
|
-
}
|
|
1521
|
-
giftToLineItems(items) {
|
|
1522
|
-
return items.map((item) => {
|
|
1523
|
-
const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
|
|
1524
|
-
const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
|
|
1525
|
-
return LineItem.toInstance({
|
|
1526
|
-
brand,
|
|
1527
|
-
categories,
|
|
1528
|
-
id: id.toString(),
|
|
1529
|
-
name,
|
|
1530
|
-
price,
|
|
1531
|
-
sku,
|
|
1532
|
-
slug,
|
|
1533
|
-
stock,
|
|
1534
|
-
weight,
|
|
1535
|
-
EAN,
|
|
1536
|
-
image,
|
|
1537
|
-
pricePaid: 0,
|
|
1538
|
-
quantity: 1,
|
|
1539
|
-
isGift: true,
|
|
1540
|
-
});
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
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 });
|
|
1545
|
-
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
1546
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
|
|
1547
|
-
type: Injectable
|
|
1548
|
-
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
|
|
1549
|
-
type: Inject,
|
|
1550
|
-
args: [DEFAULT_SHOP]
|
|
1551
|
-
}] }, { type: undefined, decorators: [{
|
|
1552
|
-
type: Inject,
|
|
1553
|
-
args: ['ProductRepository']
|
|
1554
|
-
}] }, { type: undefined, decorators: [{
|
|
1555
|
-
type: Inject,
|
|
1556
|
-
args: ['CategoryRepository']
|
|
1557
|
-
}] }, { type: undefined, decorators: [{
|
|
1558
|
-
type: Inject,
|
|
1559
|
-
args: ['VariantRepository']
|
|
1560
|
-
}] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
|
|
1561
|
-
type: Inject,
|
|
1562
|
-
args: ['Buy2WinRepository']
|
|
1296
|
+
class CartService {
|
|
1297
|
+
constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
|
|
1298
|
+
this.authService = authService;
|
|
1299
|
+
this.checkoutService = checkoutService;
|
|
1300
|
+
this.defaultShop = defaultShop;
|
|
1301
|
+
this.productRepository = productRepository;
|
|
1302
|
+
this.categoryRepository = categoryRepository;
|
|
1303
|
+
this.variantRepository = variantRepository;
|
|
1304
|
+
this.buy2WinRepository = buy2WinRepository;
|
|
1305
|
+
this.cartSubject = new Subject();
|
|
1306
|
+
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
1307
|
+
const items = [];
|
|
1308
|
+
const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
|
|
1309
|
+
if (index > -1) {
|
|
1310
|
+
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
1311
|
+
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
1312
|
+
}
|
|
1313
|
+
else
|
|
1314
|
+
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
1315
|
+
return this.checkoutService
|
|
1316
|
+
.updateCheckoutLineItems(checkoutLoaded)
|
|
1317
|
+
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
1318
|
+
}));
|
|
1319
|
+
this.generateCartObject = (items) => items?.reduce((cart, item) => ({
|
|
1320
|
+
...cart,
|
|
1321
|
+
[item.id]: LineItem.toInstance({
|
|
1322
|
+
...(cart[item.id] || item),
|
|
1323
|
+
quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
|
|
1324
|
+
}),
|
|
1325
|
+
}), {}) || {};
|
|
1326
|
+
this.buildLineItem = async ({ checkout, item, quantity, }) => {
|
|
1327
|
+
const product = await this.getProductData(item.id);
|
|
1328
|
+
item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
|
|
1329
|
+
if (this.checkMaxStock(item, quantity || 0))
|
|
1330
|
+
throw new Error('Desculpe! Temos apenas ' + item.stock?.quantity + ' em estoque.');
|
|
1331
|
+
const image = item.image || item.images?.shift();
|
|
1332
|
+
const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
|
|
1333
|
+
const isGift = item.isGift || null;
|
|
1334
|
+
const pricePaid = this.getProductPrice({
|
|
1335
|
+
product: item,
|
|
1336
|
+
shop: checkout.shop || this.defaultShop,
|
|
1337
|
+
isSubscriber: checkout.user?.isSubscriber,
|
|
1338
|
+
});
|
|
1339
|
+
RoundProductPricesHelper.roundProductPrices(item);
|
|
1340
|
+
return {
|
|
1341
|
+
checkout,
|
|
1342
|
+
lineItem: LineItem.toInstance({
|
|
1343
|
+
id,
|
|
1344
|
+
name: name ?? product.name,
|
|
1345
|
+
EAN: EAN ?? product.EAN,
|
|
1346
|
+
brand: product.brand,
|
|
1347
|
+
slug: slug ?? product.slug,
|
|
1348
|
+
sku: sku ?? product.sku,
|
|
1349
|
+
stock,
|
|
1350
|
+
price: this.roundPrice(price),
|
|
1351
|
+
image,
|
|
1352
|
+
weight: weight ?? product.weight,
|
|
1353
|
+
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1354
|
+
pricePaid,
|
|
1355
|
+
discount: 0,
|
|
1356
|
+
categories: product.categories ?? [],
|
|
1357
|
+
isGift: isGift ?? null,
|
|
1358
|
+
costPrice: product.costPrice ?? 0,
|
|
1359
|
+
type,
|
|
1360
|
+
}),
|
|
1361
|
+
};
|
|
1362
|
+
};
|
|
1363
|
+
this.getProductPrice = ({ product, isSubscriber, }) => {
|
|
1364
|
+
const info = product.price;
|
|
1365
|
+
if (product.isGift)
|
|
1366
|
+
return 0;
|
|
1367
|
+
return isSubscriber && info.subscriberPrice > 0
|
|
1368
|
+
? Number(info.subscriberPrice.toFixed(2))
|
|
1369
|
+
: Number(info.price.toFixed(2));
|
|
1370
|
+
};
|
|
1371
|
+
this.checkMaxStock = (item, quantity) => {
|
|
1372
|
+
const maxStock = item.stock?.quantity || 0;
|
|
1373
|
+
const currentItemAmount = item.quantity || 0;
|
|
1374
|
+
return currentItemAmount + quantity > maxStock;
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
addItem(item, quantity = 1) {
|
|
1378
|
+
return from(this.checkoutService.getCheckout()).pipe(concatMap(async (checkout) => await this.buildLineItem({ checkout, item, quantity: quantity || 1 })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
|
|
1379
|
+
}
|
|
1380
|
+
decreaseItem(item) {
|
|
1381
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1382
|
+
const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id);
|
|
1383
|
+
if (!isNil(checkoutItem))
|
|
1384
|
+
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
1385
|
+
return checkout;
|
|
1386
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1387
|
+
}
|
|
1388
|
+
getCart(checkout) {
|
|
1389
|
+
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
1390
|
+
return this.cartSubject;
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* @deprecated The method should not be used
|
|
1394
|
+
*/
|
|
1395
|
+
getVariantPriceDiscount(item) {
|
|
1396
|
+
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)));
|
|
1397
|
+
}
|
|
1398
|
+
removeItem(item) {
|
|
1399
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1400
|
+
const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
|
|
1401
|
+
if (index >= 0)
|
|
1402
|
+
checkout.lineItems.splice(index, 1);
|
|
1403
|
+
return checkout;
|
|
1404
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1405
|
+
}
|
|
1406
|
+
updateUserCart(user) {
|
|
1407
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => await this.checkoutService
|
|
1408
|
+
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1409
|
+
...checkout.toPlain(),
|
|
1410
|
+
lineItems: checkout.lineItems?.length
|
|
1411
|
+
? await Promise.all(checkout.lineItems?.map(async (item) => (await this.buildLineItem({ checkout, item })).lineItem))
|
|
1412
|
+
: [],
|
|
1413
|
+
}))
|
|
1414
|
+
.toPromise()), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1415
|
+
}
|
|
1416
|
+
clearCart() {
|
|
1417
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1418
|
+
this.checkoutService.clearCheckoutFromSession();
|
|
1419
|
+
return checkout;
|
|
1420
|
+
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
1421
|
+
}
|
|
1422
|
+
buildCartFromCheckout(checkoutData) {
|
|
1423
|
+
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1424
|
+
}
|
|
1425
|
+
roundPrice(productPrice) {
|
|
1426
|
+
const { price, fullPrice, subscriberPrice } = productPrice;
|
|
1427
|
+
return {
|
|
1428
|
+
...productPrice,
|
|
1429
|
+
price: Number(price.toFixed(2)),
|
|
1430
|
+
fullPrice: Number(fullPrice.toFixed(2)),
|
|
1431
|
+
...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
async getProductData(productId) {
|
|
1435
|
+
let product;
|
|
1436
|
+
let variant;
|
|
1437
|
+
try {
|
|
1438
|
+
product = await this.productRepository.get({ id: productId });
|
|
1439
|
+
}
|
|
1440
|
+
catch (error) {
|
|
1441
|
+
if (!(error instanceof NotFoundError))
|
|
1442
|
+
throw error;
|
|
1443
|
+
const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
|
|
1444
|
+
variant = variants.shift();
|
|
1445
|
+
if (!variant)
|
|
1446
|
+
throw error;
|
|
1447
|
+
product = await this.productRepository.get({ id: variant.productId });
|
|
1448
|
+
}
|
|
1449
|
+
return {
|
|
1450
|
+
...product.toPlain(),
|
|
1451
|
+
...(variant && { ...variant.toPlain() }),
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
getGifts() {
|
|
1455
|
+
return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
|
|
1456
|
+
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1457
|
+
if (!notGiftItems.length)
|
|
1458
|
+
return { ...checkout, lineItems: [] };
|
|
1459
|
+
const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1460
|
+
const campaigns = await this.buy2WinRepository
|
|
1461
|
+
.find({
|
|
1462
|
+
filters: {
|
|
1463
|
+
active: { operator: Where.EQUALS, value: true },
|
|
1464
|
+
shop: { operator: Where.EQUALS, value: this.defaultShop },
|
|
1465
|
+
},
|
|
1466
|
+
})
|
|
1467
|
+
.then((data) => data.data);
|
|
1468
|
+
if (!campaigns.length)
|
|
1469
|
+
return { ...checkout, lineItems: notGiftItems };
|
|
1470
|
+
const elegibleCampaigns = [];
|
|
1471
|
+
for (const campaign of campaigns) {
|
|
1472
|
+
const today = new Date().getTime();
|
|
1473
|
+
if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
|
|
1474
|
+
continue;
|
|
1475
|
+
if (campaign.activeCategory) {
|
|
1476
|
+
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
1477
|
+
const categoriesCampaingFullTree = [];
|
|
1478
|
+
for (const id of categoriesCampaing) {
|
|
1479
|
+
const children = await this.categoryRepository.getChildren(parseInt(id));
|
|
1480
|
+
categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
|
|
1481
|
+
}
|
|
1482
|
+
const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
|
|
1483
|
+
const filterProductsCategories = checkout.lineItems.filter((l) => {
|
|
1484
|
+
if (!l.categories || !l.categories?.length)
|
|
1485
|
+
return true;
|
|
1486
|
+
return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
|
|
1487
|
+
});
|
|
1488
|
+
if (filterProductsCategories.length) {
|
|
1489
|
+
const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1490
|
+
if (cartTotalCategories >= campaign.cartValueMin)
|
|
1491
|
+
elegibleCampaigns.push(campaign);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
else {
|
|
1495
|
+
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
1496
|
+
if (campaign.cartValue <= cartTotal)
|
|
1497
|
+
elegibleCampaigns.push(campaign);
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
if (!elegibleCampaigns.length)
|
|
1502
|
+
return { ...checkout, lineItems: notGiftItems };
|
|
1503
|
+
const campaingnProducts = [];
|
|
1504
|
+
for (const campaign of elegibleCampaigns) {
|
|
1505
|
+
let elegibleProducts = [];
|
|
1506
|
+
for (const product of campaign.products) {
|
|
1507
|
+
const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
|
|
1508
|
+
if (!productData.length)
|
|
1509
|
+
continue;
|
|
1510
|
+
const gift = productData.shift();
|
|
1511
|
+
if (gift.stock.quantity < 1)
|
|
1512
|
+
continue;
|
|
1513
|
+
elegibleProducts.push(gift);
|
|
1514
|
+
}
|
|
1515
|
+
campaingnProducts.push(elegibleProducts);
|
|
1516
|
+
}
|
|
1517
|
+
if (!campaingnProducts.length)
|
|
1518
|
+
return { ...checkout, lineItems: notGiftItems };
|
|
1519
|
+
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
1520
|
+
return { ...checkout, lineItems: notGiftItems.concat(gifts) };
|
|
1521
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1522
|
+
}
|
|
1523
|
+
giftToLineItems(items) {
|
|
1524
|
+
return items.map((item) => {
|
|
1525
|
+
const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
|
|
1526
|
+
const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
|
|
1527
|
+
return LineItem.toInstance({
|
|
1528
|
+
brand,
|
|
1529
|
+
categories,
|
|
1530
|
+
id: id.toString(),
|
|
1531
|
+
name,
|
|
1532
|
+
price,
|
|
1533
|
+
sku,
|
|
1534
|
+
slug,
|
|
1535
|
+
stock,
|
|
1536
|
+
weight,
|
|
1537
|
+
EAN,
|
|
1538
|
+
image,
|
|
1539
|
+
pricePaid: 0,
|
|
1540
|
+
quantity: 1,
|
|
1541
|
+
isGift: true,
|
|
1542
|
+
});
|
|
1543
|
+
});
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
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 });
|
|
1547
|
+
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
1548
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
|
|
1549
|
+
type: Injectable
|
|
1550
|
+
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
|
|
1551
|
+
type: Inject,
|
|
1552
|
+
args: [DEFAULT_SHOP]
|
|
1553
|
+
}] }, { type: undefined, decorators: [{
|
|
1554
|
+
type: Inject,
|
|
1555
|
+
args: ['ProductRepository']
|
|
1556
|
+
}] }, { type: undefined, decorators: [{
|
|
1557
|
+
type: Inject,
|
|
1558
|
+
args: ['CategoryRepository']
|
|
1559
|
+
}] }, { type: undefined, decorators: [{
|
|
1560
|
+
type: Inject,
|
|
1561
|
+
args: ['VariantRepository']
|
|
1562
|
+
}] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
|
|
1563
|
+
type: Inject,
|
|
1564
|
+
args: ['Buy2WinRepository']
|
|
1563
1565
|
}] }]; } });
|
|
1564
1566
|
|
|
1565
|
-
class NewCategoryStructureAdapter {
|
|
1566
|
-
constructor(categoryRepository) {
|
|
1567
|
-
this.categoryRepository = categoryRepository;
|
|
1568
|
-
}
|
|
1569
|
-
async buildProductFilterByCategory(category) {
|
|
1570
|
-
const loadedCategory = await this.getCategory(category);
|
|
1571
|
-
if (loadedCategory.isCollection)
|
|
1572
|
-
return { id: { operator: Where.IN, value: loadedCategory.products } };
|
|
1573
|
-
const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
|
|
1574
|
-
return {
|
|
1575
|
-
category: {
|
|
1576
|
-
id: {
|
|
1577
|
-
operator: Where.IN,
|
|
1578
|
-
value: categoryIds,
|
|
1579
|
-
},
|
|
1580
|
-
},
|
|
1581
|
-
};
|
|
1582
|
-
}
|
|
1583
|
-
async getAllCategoriesIdFromCategory(category) {
|
|
1584
|
-
return this.categoryRepository
|
|
1585
|
-
.getChildren(+category.id)
|
|
1586
|
-
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1587
|
-
}
|
|
1588
|
-
async getCategory(category) {
|
|
1589
|
-
const collectionCategory = category.isCollection ||
|
|
1590
|
-
(isNil(category.isCollection) && !category.products?.length) ||
|
|
1591
|
-
category.isWishlist ||
|
|
1592
|
-
category.brandCategory;
|
|
1593
|
-
return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1597
|
-
NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
|
|
1598
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
|
|
1599
|
-
type: Injectable
|
|
1600
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1601
|
-
type: Inject,
|
|
1602
|
-
args: ['CategoryRepository']
|
|
1567
|
+
class NewCategoryStructureAdapter {
|
|
1568
|
+
constructor(categoryRepository) {
|
|
1569
|
+
this.categoryRepository = categoryRepository;
|
|
1570
|
+
}
|
|
1571
|
+
async buildProductFilterByCategory(category) {
|
|
1572
|
+
const loadedCategory = await this.getCategory(category);
|
|
1573
|
+
if (loadedCategory.isCollection)
|
|
1574
|
+
return { id: { operator: Where.IN, value: loadedCategory.products } };
|
|
1575
|
+
const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
|
|
1576
|
+
return {
|
|
1577
|
+
category: {
|
|
1578
|
+
id: {
|
|
1579
|
+
operator: Where.IN,
|
|
1580
|
+
value: categoryIds,
|
|
1581
|
+
},
|
|
1582
|
+
},
|
|
1583
|
+
};
|
|
1584
|
+
}
|
|
1585
|
+
async getAllCategoriesIdFromCategory(category) {
|
|
1586
|
+
return this.categoryRepository
|
|
1587
|
+
.getChildren(+category.id)
|
|
1588
|
+
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1589
|
+
}
|
|
1590
|
+
async getCategory(category) {
|
|
1591
|
+
const collectionCategory = category.isCollection ||
|
|
1592
|
+
(isNil(category.isCollection) && !category.products?.length) ||
|
|
1593
|
+
category.isWishlist ||
|
|
1594
|
+
category.brandCategory;
|
|
1595
|
+
return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1599
|
+
NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
|
|
1600
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
|
|
1601
|
+
type: Injectable
|
|
1602
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1603
|
+
type: Inject,
|
|
1604
|
+
args: ['CategoryRepository']
|
|
1603
1605
|
}] }]; } });
|
|
1604
1606
|
|
|
1605
|
-
class OldCategoryStructureAdapter {
|
|
1606
|
-
constructor(categoryRepository) {
|
|
1607
|
-
this.categoryRepository = categoryRepository;
|
|
1608
|
-
}
|
|
1609
|
-
async buildProductFilterByCategory(category) {
|
|
1610
|
-
const productsIds = category.products?.length
|
|
1611
|
-
? category.products
|
|
1612
|
-
: await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
|
|
1613
|
-
return { id: { operator: Where.IN, value: productsIds } };
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1617
|
-
OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
|
|
1618
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
|
|
1619
|
-
type: Injectable
|
|
1620
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1621
|
-
type: Inject,
|
|
1622
|
-
args: ['CategoryRepository']
|
|
1607
|
+
class OldCategoryStructureAdapter {
|
|
1608
|
+
constructor(categoryRepository) {
|
|
1609
|
+
this.categoryRepository = categoryRepository;
|
|
1610
|
+
}
|
|
1611
|
+
async buildProductFilterByCategory(category) {
|
|
1612
|
+
const productsIds = category.products?.length
|
|
1613
|
+
? category.products
|
|
1614
|
+
: await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
|
|
1615
|
+
return { id: { operator: Where.IN, value: productsIds } };
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1619
|
+
OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
|
|
1620
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
|
|
1621
|
+
type: Injectable
|
|
1622
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1623
|
+
type: Inject,
|
|
1624
|
+
args: ['CategoryRepository']
|
|
1623
1625
|
}] }]; } });
|
|
1624
1626
|
|
|
1625
|
-
class CatalogService {
|
|
1626
|
-
constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1627
|
-
this.productRepository = productRepository;
|
|
1628
|
-
this.categoryRepository = categoryRepository;
|
|
1629
|
-
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1630
|
-
this.shop = shop;
|
|
1631
|
-
this.productIndex = productIndex;
|
|
1632
|
-
this.productsByTerm = {};
|
|
1633
|
-
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1634
|
-
const filters = {};
|
|
1635
|
-
if (clubDiscount?.length)
|
|
1636
|
-
set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
|
|
1637
|
-
if (brands?.length)
|
|
1638
|
-
filters.brand = { operator: Where.IN, value: brands };
|
|
1639
|
-
if (gender?.length)
|
|
1640
|
-
filters.gender = { operator: Where.IN, value: gender };
|
|
1641
|
-
if (prices?.min || prices?.max)
|
|
1642
|
-
set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
|
|
1643
|
-
...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
|
|
1644
|
-
...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
|
|
1645
|
-
]);
|
|
1646
|
-
if (rate)
|
|
1647
|
-
filters.rate = { operator: Where.GTE, value: rate };
|
|
1648
|
-
if (tags?.length)
|
|
1649
|
-
filters.tags = { operator: Where.LIKE, value: tags };
|
|
1650
|
-
if (customOptions?.length)
|
|
1651
|
-
filters.filters = { operator: Where.LIKE, value: customOptions };
|
|
1652
|
-
return filters;
|
|
1653
|
-
};
|
|
1654
|
-
this.buildSortQuery = (sort) => {
|
|
1655
|
-
if (!sort || sort === 'most-relevant')
|
|
1656
|
-
return {};
|
|
1657
|
-
if (sort === 'best-sellers')
|
|
1658
|
-
return {
|
|
1659
|
-
shoppingCount: 'desc',
|
|
1660
|
-
rate: 'desc',
|
|
1661
|
-
stock: 'desc',
|
|
1662
|
-
name: 'asc',
|
|
1663
|
-
};
|
|
1664
|
-
if (sort === 'biggest-price')
|
|
1665
|
-
return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1666
|
-
if (sort === 'lowest-price')
|
|
1667
|
-
return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
|
|
1668
|
-
if (sort === 'best-rating')
|
|
1669
|
-
return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
|
|
1670
|
-
if (sort === 'news')
|
|
1671
|
-
return { createdAt: 'desc' };
|
|
1672
|
-
if (sort === 'biggest-discount')
|
|
1673
|
-
return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1674
|
-
};
|
|
1675
|
-
this.buildLimitQuery = (options) => {
|
|
1676
|
-
const limit = options?.perPage || 20;
|
|
1677
|
-
return {
|
|
1678
|
-
limit,
|
|
1679
|
-
offset: ((options?.page || 1) - 1) * limit,
|
|
1680
|
-
};
|
|
1681
|
-
};
|
|
1682
|
-
this.hasProfile = (options) => 'profile' in options;
|
|
1683
|
-
this.hasTerm = (options) => 'term' in options;
|
|
1684
|
-
this.hasCategory = (options) => 'category' in options;
|
|
1685
|
-
}
|
|
1686
|
-
async fetchProducts(options) {
|
|
1687
|
-
const limits = this.buildLimitQuery(options);
|
|
1688
|
-
if (this.hasProfile(options) && options.filters?.customOptions)
|
|
1689
|
-
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
1690
|
-
if (this.hasProfile(options) && options.filters?.tags)
|
|
1691
|
-
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1692
|
-
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1693
|
-
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1694
|
-
return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
|
|
1695
|
-
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1696
|
-
pages: Math.ceil(total / limits.limit),
|
|
1697
|
-
prices: {
|
|
1698
|
-
price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
|
|
1699
|
-
subscriberPrice: {
|
|
1700
|
-
min: +minimal?.price?.subscriberPrice?.toFixed(2),
|
|
1701
|
-
max: +maximum?.price?.subscriberPrice?.toFixed(2),
|
|
1702
|
-
},
|
|
1703
|
-
},
|
|
1704
|
-
brands: distinct?.brand,
|
|
1705
|
-
}));
|
|
1706
|
-
}
|
|
1707
|
-
async findCatalog(options, limits) {
|
|
1708
|
-
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1709
|
-
const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1710
|
-
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1711
|
-
}
|
|
1712
|
-
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1713
|
-
const productsIds = await this.productRepository
|
|
1714
|
-
.find({
|
|
1715
|
-
filters: {
|
|
1716
|
-
...(await this.buildMainFilter(options)),
|
|
1717
|
-
},
|
|
1718
|
-
})
|
|
1719
|
-
.then((products) => products.data.map((product) => product.id));
|
|
1720
|
-
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1721
|
-
}
|
|
1722
|
-
const repoParams = {
|
|
1723
|
-
filters: {
|
|
1724
|
-
...(await this.buildMainFilter(options)),
|
|
1725
|
-
...this.buildFilterQuery(options?.filters || {}),
|
|
1726
|
-
},
|
|
1727
|
-
...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
|
|
1728
|
-
limits,
|
|
1729
|
-
options: {
|
|
1730
|
-
minimal: ['price'],
|
|
1731
|
-
maximum: ['price'],
|
|
1732
|
-
...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
|
|
1733
|
-
},
|
|
1734
|
-
};
|
|
1735
|
-
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1736
|
-
return this.productRepository.findCatalog(repoParams);
|
|
1737
|
-
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1738
|
-
}
|
|
1739
|
-
async buildMainFilter({ category, profile, term, }) {
|
|
1740
|
-
if (category)
|
|
1741
|
-
return this.categoryStructureAdapter.buildProductFilterByCategory(category);
|
|
1742
|
-
if (profile)
|
|
1743
|
-
return { tags: { operator: Where.LIKE, value: profile } };
|
|
1744
|
-
if (term)
|
|
1745
|
-
return this.productIndex
|
|
1746
|
-
.search(term, 999, this.shop)
|
|
1747
|
-
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1748
|
-
}
|
|
1749
|
-
async findCatalogAndSortByMostRevelant(productIds, options, limits) {
|
|
1750
|
-
const totalResult = await this.productRepository.findCatalog({
|
|
1751
|
-
fields: ['id', 'stock'],
|
|
1752
|
-
filters: {
|
|
1753
|
-
id: { operator: Where.IN, value: productIds },
|
|
1754
|
-
...this.buildFilterQuery(options?.filters || {}),
|
|
1755
|
-
},
|
|
1756
|
-
options: {
|
|
1757
|
-
minimal: ['price'],
|
|
1758
|
-
maximum: ['price'],
|
|
1759
|
-
distinct: ['brand'],
|
|
1760
|
-
},
|
|
1761
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1762
|
-
const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
|
|
1763
|
-
const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
|
|
1764
|
-
const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
|
|
1765
|
-
const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
|
|
1766
|
-
const limitedProductId = productIdsStock
|
|
1767
|
-
.concat(productIdsStockOut)
|
|
1768
|
-
.slice(limits.offset, limits.offset + limits.limit);
|
|
1769
|
-
const orderedId = productIds.filter((product) => limitedProductId.includes(product));
|
|
1770
|
-
const productResult = await this.productRepository.findCatalog({
|
|
1771
|
-
filters: {
|
|
1772
|
-
id: { operator: Where.IN, value: orderedId },
|
|
1773
|
-
},
|
|
1774
|
-
});
|
|
1775
|
-
return {
|
|
1776
|
-
data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1777
|
-
count: totalResult.count,
|
|
1778
|
-
maximum: totalResult.maximum,
|
|
1779
|
-
minimal: totalResult.minimal,
|
|
1780
|
-
distinct: totalResult.distinct,
|
|
1781
|
-
};
|
|
1782
|
-
}
|
|
1783
|
-
async findCatalogIdsByElasticSearch(term) {
|
|
1784
|
-
if (this.productsByTerm[term])
|
|
1785
|
-
return this.productsByTerm[term];
|
|
1786
|
-
return (this.productsByTerm[term] = await this.productIndex
|
|
1787
|
-
.search(term, 999, this.shop)
|
|
1788
|
-
.then(({ hits: products }) => {
|
|
1789
|
-
const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
|
|
1790
|
-
const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
|
|
1791
|
-
const sorted = [...withStock, ...withOutStock];
|
|
1792
|
-
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1793
|
-
}));
|
|
1794
|
-
}
|
|
1795
|
-
}
|
|
1796
|
-
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1797
|
-
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|
|
1798
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
|
|
1799
|
-
type: Injectable
|
|
1800
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1801
|
-
type: Inject,
|
|
1802
|
-
args: ['ProductRepository']
|
|
1803
|
-
}] }, { type: undefined, decorators: [{
|
|
1804
|
-
type: Inject,
|
|
1805
|
-
args: ['CategoryRepository']
|
|
1806
|
-
}] }, { type: undefined, decorators: [{
|
|
1807
|
-
type: Inject,
|
|
1808
|
-
args: [CATEGORY_STRUCTURE]
|
|
1809
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
1810
|
-
type: Inject,
|
|
1811
|
-
args: [DEFAULT_SHOP]
|
|
1627
|
+
class CatalogService {
|
|
1628
|
+
constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1629
|
+
this.productRepository = productRepository;
|
|
1630
|
+
this.categoryRepository = categoryRepository;
|
|
1631
|
+
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1632
|
+
this.shop = shop;
|
|
1633
|
+
this.productIndex = productIndex;
|
|
1634
|
+
this.productsByTerm = {};
|
|
1635
|
+
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1636
|
+
const filters = {};
|
|
1637
|
+
if (clubDiscount?.length)
|
|
1638
|
+
set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
|
|
1639
|
+
if (brands?.length)
|
|
1640
|
+
filters.brand = { operator: Where.IN, value: brands };
|
|
1641
|
+
if (gender?.length)
|
|
1642
|
+
filters.gender = { operator: Where.IN, value: gender };
|
|
1643
|
+
if (prices?.min || prices?.max)
|
|
1644
|
+
set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
|
|
1645
|
+
...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
|
|
1646
|
+
...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
|
|
1647
|
+
]);
|
|
1648
|
+
if (rate)
|
|
1649
|
+
filters.rate = { operator: Where.GTE, value: rate };
|
|
1650
|
+
if (tags?.length)
|
|
1651
|
+
filters.tags = { operator: Where.LIKE, value: tags };
|
|
1652
|
+
if (customOptions?.length)
|
|
1653
|
+
filters.filters = { operator: Where.LIKE, value: customOptions };
|
|
1654
|
+
return filters;
|
|
1655
|
+
};
|
|
1656
|
+
this.buildSortQuery = (sort) => {
|
|
1657
|
+
if (!sort || sort === 'most-relevant')
|
|
1658
|
+
return {};
|
|
1659
|
+
if (sort === 'best-sellers')
|
|
1660
|
+
return {
|
|
1661
|
+
shoppingCount: 'desc',
|
|
1662
|
+
rate: 'desc',
|
|
1663
|
+
stock: 'desc',
|
|
1664
|
+
name: 'asc',
|
|
1665
|
+
};
|
|
1666
|
+
if (sort === 'biggest-price')
|
|
1667
|
+
return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1668
|
+
if (sort === 'lowest-price')
|
|
1669
|
+
return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
|
|
1670
|
+
if (sort === 'best-rating')
|
|
1671
|
+
return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
|
|
1672
|
+
if (sort === 'news')
|
|
1673
|
+
return { createdAt: 'desc' };
|
|
1674
|
+
if (sort === 'biggest-discount')
|
|
1675
|
+
return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1676
|
+
};
|
|
1677
|
+
this.buildLimitQuery = (options) => {
|
|
1678
|
+
const limit = options?.perPage || 20;
|
|
1679
|
+
return {
|
|
1680
|
+
limit,
|
|
1681
|
+
offset: ((options?.page || 1) - 1) * limit,
|
|
1682
|
+
};
|
|
1683
|
+
};
|
|
1684
|
+
this.hasProfile = (options) => 'profile' in options;
|
|
1685
|
+
this.hasTerm = (options) => 'term' in options;
|
|
1686
|
+
this.hasCategory = (options) => 'category' in options;
|
|
1687
|
+
}
|
|
1688
|
+
async fetchProducts(options) {
|
|
1689
|
+
const limits = this.buildLimitQuery(options);
|
|
1690
|
+
if (this.hasProfile(options) && options.filters?.customOptions)
|
|
1691
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
1692
|
+
if (this.hasProfile(options) && options.filters?.tags)
|
|
1693
|
+
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1694
|
+
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1695
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1696
|
+
return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
|
|
1697
|
+
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1698
|
+
pages: Math.ceil(total / limits.limit),
|
|
1699
|
+
prices: {
|
|
1700
|
+
price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
|
|
1701
|
+
subscriberPrice: {
|
|
1702
|
+
min: +minimal?.price?.subscriberPrice?.toFixed(2),
|
|
1703
|
+
max: +maximum?.price?.subscriberPrice?.toFixed(2),
|
|
1704
|
+
},
|
|
1705
|
+
},
|
|
1706
|
+
brands: distinct?.brand,
|
|
1707
|
+
}));
|
|
1708
|
+
}
|
|
1709
|
+
async findCatalog(options, limits) {
|
|
1710
|
+
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1711
|
+
const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1712
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1713
|
+
}
|
|
1714
|
+
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1715
|
+
const productsIds = await this.productRepository
|
|
1716
|
+
.find({
|
|
1717
|
+
filters: {
|
|
1718
|
+
...(await this.buildMainFilter(options)),
|
|
1719
|
+
},
|
|
1720
|
+
})
|
|
1721
|
+
.then((products) => products.data.map((product) => product.id));
|
|
1722
|
+
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1723
|
+
}
|
|
1724
|
+
const repoParams = {
|
|
1725
|
+
filters: {
|
|
1726
|
+
...(await this.buildMainFilter(options)),
|
|
1727
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1728
|
+
},
|
|
1729
|
+
...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
|
|
1730
|
+
limits,
|
|
1731
|
+
options: {
|
|
1732
|
+
minimal: ['price'],
|
|
1733
|
+
maximum: ['price'],
|
|
1734
|
+
...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
|
|
1735
|
+
},
|
|
1736
|
+
};
|
|
1737
|
+
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1738
|
+
return this.productRepository.findCatalog(repoParams);
|
|
1739
|
+
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1740
|
+
}
|
|
1741
|
+
async buildMainFilter({ category, profile, term, }) {
|
|
1742
|
+
if (category)
|
|
1743
|
+
return this.categoryStructureAdapter.buildProductFilterByCategory(category);
|
|
1744
|
+
if (profile)
|
|
1745
|
+
return { tags: { operator: Where.LIKE, value: profile } };
|
|
1746
|
+
if (term)
|
|
1747
|
+
return this.productIndex
|
|
1748
|
+
.search(term, 999, this.shop)
|
|
1749
|
+
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1750
|
+
}
|
|
1751
|
+
async findCatalogAndSortByMostRevelant(productIds, options, limits) {
|
|
1752
|
+
const totalResult = await this.productRepository.findCatalog({
|
|
1753
|
+
fields: ['id', 'stock'],
|
|
1754
|
+
filters: {
|
|
1755
|
+
id: { operator: Where.IN, value: productIds },
|
|
1756
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1757
|
+
},
|
|
1758
|
+
options: {
|
|
1759
|
+
minimal: ['price'],
|
|
1760
|
+
maximum: ['price'],
|
|
1761
|
+
distinct: ['brand'],
|
|
1762
|
+
},
|
|
1763
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1764
|
+
const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
|
|
1765
|
+
const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
|
|
1766
|
+
const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
|
|
1767
|
+
const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
|
|
1768
|
+
const limitedProductId = productIdsStock
|
|
1769
|
+
.concat(productIdsStockOut)
|
|
1770
|
+
.slice(limits.offset, limits.offset + limits.limit);
|
|
1771
|
+
const orderedId = productIds.filter((product) => limitedProductId.includes(product));
|
|
1772
|
+
const productResult = await this.productRepository.findCatalog({
|
|
1773
|
+
filters: {
|
|
1774
|
+
id: { operator: Where.IN, value: orderedId },
|
|
1775
|
+
},
|
|
1776
|
+
});
|
|
1777
|
+
return {
|
|
1778
|
+
data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1779
|
+
count: totalResult.count,
|
|
1780
|
+
maximum: totalResult.maximum,
|
|
1781
|
+
minimal: totalResult.minimal,
|
|
1782
|
+
distinct: totalResult.distinct,
|
|
1783
|
+
};
|
|
1784
|
+
}
|
|
1785
|
+
async findCatalogIdsByElasticSearch(term) {
|
|
1786
|
+
if (this.productsByTerm[term])
|
|
1787
|
+
return this.productsByTerm[term];
|
|
1788
|
+
return (this.productsByTerm[term] = await this.productIndex
|
|
1789
|
+
.search(term, 999, this.shop)
|
|
1790
|
+
.then(({ hits: products }) => {
|
|
1791
|
+
const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
|
|
1792
|
+
const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
|
|
1793
|
+
const sorted = [...withStock, ...withOutStock];
|
|
1794
|
+
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1795
|
+
}));
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1799
|
+
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|
|
1800
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
|
|
1801
|
+
type: Injectable
|
|
1802
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1803
|
+
type: Inject,
|
|
1804
|
+
args: ['ProductRepository']
|
|
1805
|
+
}] }, { type: undefined, decorators: [{
|
|
1806
|
+
type: Inject,
|
|
1807
|
+
args: ['CategoryRepository']
|
|
1808
|
+
}] }, { type: undefined, decorators: [{
|
|
1809
|
+
type: Inject,
|
|
1810
|
+
args: [CATEGORY_STRUCTURE]
|
|
1811
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1812
|
+
type: Inject,
|
|
1813
|
+
args: [DEFAULT_SHOP]
|
|
1812
1814
|
}] }, { type: i1$2.ProductsIndex }]; } });
|
|
1813
1815
|
|
|
1814
|
-
class CategoryService {
|
|
1815
|
-
constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
1816
|
-
this.productRepository = productRepository;
|
|
1817
|
-
this.categoryRepository = categoryRepository;
|
|
1818
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
1819
|
-
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1820
|
-
this.shop = shop;
|
|
1821
|
-
}
|
|
1822
|
-
async fetchBrands(category, options) {
|
|
1823
|
-
const brands = await this.productRepository
|
|
1824
|
-
.findCatalog({
|
|
1825
|
-
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1826
|
-
fields: ['brand'],
|
|
1827
|
-
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1828
|
-
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1829
|
-
return this.categoryRepository
|
|
1830
|
-
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1831
|
-
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1832
|
-
}
|
|
1833
|
-
async fetchFilterOptions(category) {
|
|
1834
|
-
return await this.categoryFilterRepository
|
|
1835
|
-
.find({ filters: { categoryId: +category.id } })
|
|
1836
|
-
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1840
|
-
CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
|
|
1841
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
|
|
1842
|
-
type: Injectable
|
|
1843
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1844
|
-
type: Inject,
|
|
1845
|
-
args: ['ProductRepository']
|
|
1846
|
-
}] }, { type: undefined, decorators: [{
|
|
1847
|
-
type: Inject,
|
|
1848
|
-
args: ['CategoryRepository']
|
|
1849
|
-
}] }, { type: undefined, decorators: [{
|
|
1850
|
-
type: Inject,
|
|
1851
|
-
args: ['CategoryFilterRepository']
|
|
1852
|
-
}] }, { type: undefined, decorators: [{
|
|
1853
|
-
type: Inject,
|
|
1854
|
-
args: [CATEGORY_STRUCTURE]
|
|
1855
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
1856
|
-
type: Inject,
|
|
1857
|
-
args: [DEFAULT_SHOP]
|
|
1816
|
+
class CategoryService {
|
|
1817
|
+
constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
1818
|
+
this.productRepository = productRepository;
|
|
1819
|
+
this.categoryRepository = categoryRepository;
|
|
1820
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
1821
|
+
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1822
|
+
this.shop = shop;
|
|
1823
|
+
}
|
|
1824
|
+
async fetchBrands(category, options) {
|
|
1825
|
+
const brands = await this.productRepository
|
|
1826
|
+
.findCatalog({
|
|
1827
|
+
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1828
|
+
fields: ['brand'],
|
|
1829
|
+
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1830
|
+
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1831
|
+
return this.categoryRepository
|
|
1832
|
+
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1833
|
+
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1834
|
+
}
|
|
1835
|
+
async fetchFilterOptions(category) {
|
|
1836
|
+
return await this.categoryFilterRepository
|
|
1837
|
+
.find({ filters: { categoryId: +category.id } })
|
|
1838
|
+
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1842
|
+
CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
|
|
1843
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
|
|
1844
|
+
type: Injectable
|
|
1845
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1846
|
+
type: Inject,
|
|
1847
|
+
args: ['ProductRepository']
|
|
1848
|
+
}] }, { type: undefined, decorators: [{
|
|
1849
|
+
type: Inject,
|
|
1850
|
+
args: ['CategoryRepository']
|
|
1851
|
+
}] }, { type: undefined, decorators: [{
|
|
1852
|
+
type: Inject,
|
|
1853
|
+
args: ['CategoryFilterRepository']
|
|
1854
|
+
}] }, { type: undefined, decorators: [{
|
|
1855
|
+
type: Inject,
|
|
1856
|
+
args: [CATEGORY_STRUCTURE]
|
|
1857
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1858
|
+
type: Inject,
|
|
1859
|
+
args: [DEFAULT_SHOP]
|
|
1858
1860
|
}] }]; } });
|
|
1859
1861
|
|
|
1860
|
-
var ProductSorts;
|
|
1861
|
-
(function (ProductSorts) {
|
|
1862
|
-
ProductSorts["MOST_RELEVANT"] = "most-relevant";
|
|
1863
|
-
ProductSorts["BEST_SELLER"] = "best-sellers";
|
|
1864
|
-
ProductSorts["BIGGEST_PRICE"] = "biggest-price";
|
|
1865
|
-
ProductSorts["LOWEST_PRICE"] = "lowest-price";
|
|
1866
|
-
ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
|
|
1867
|
-
ProductSorts["BEST_RATING"] = "best-rating";
|
|
1868
|
-
ProductSorts["NEWS"] = "news";
|
|
1862
|
+
var ProductSorts;
|
|
1863
|
+
(function (ProductSorts) {
|
|
1864
|
+
ProductSorts["MOST_RELEVANT"] = "most-relevant";
|
|
1865
|
+
ProductSorts["BEST_SELLER"] = "best-sellers";
|
|
1866
|
+
ProductSorts["BIGGEST_PRICE"] = "biggest-price";
|
|
1867
|
+
ProductSorts["LOWEST_PRICE"] = "lowest-price";
|
|
1868
|
+
ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
|
|
1869
|
+
ProductSorts["BEST_RATING"] = "best-rating";
|
|
1870
|
+
ProductSorts["NEWS"] = "news";
|
|
1869
1871
|
})(ProductSorts || (ProductSorts = {}));
|
|
1870
1872
|
|
|
1871
|
-
class CategoryWithTree extends Category {
|
|
1872
|
-
}
|
|
1873
|
-
__decorate([
|
|
1874
|
-
Type(() => CategoryWithTree),
|
|
1875
|
-
__metadata("design:type", Array)
|
|
1873
|
+
class CategoryWithTree extends Category {
|
|
1874
|
+
}
|
|
1875
|
+
__decorate([
|
|
1876
|
+
Type(() => CategoryWithTree),
|
|
1877
|
+
__metadata("design:type", Array)
|
|
1876
1878
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1877
1879
|
|
|
1878
|
-
class WishlistService {
|
|
1879
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
|
|
1880
|
-
this.wishlistRepository = wishlistRepository;
|
|
1881
|
-
this.shop = shop;
|
|
1882
|
-
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1883
|
-
this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
|
|
1884
|
-
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1885
|
-
}
|
|
1886
|
-
getCatalogService() {
|
|
1887
|
-
return this.catalogService;
|
|
1888
|
-
}
|
|
1889
|
-
getCategoryService() {
|
|
1890
|
-
return this.categoryService;
|
|
1891
|
-
}
|
|
1892
|
-
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1893
|
-
const data = {
|
|
1894
|
-
slug: '',
|
|
1895
|
-
name: title,
|
|
1896
|
-
description,
|
|
1897
|
-
metadata: {
|
|
1898
|
-
title: `${userFullName} - ${title}`,
|
|
1899
|
-
description: `${userFullName} - ${description}`,
|
|
1900
|
-
},
|
|
1901
|
-
shop: this.shop,
|
|
1902
|
-
shops: [this.shop],
|
|
1903
|
-
personId,
|
|
1904
|
-
personName: userFullName,
|
|
1905
|
-
personPhoto: userPhoto,
|
|
1906
|
-
brandCategory: false,
|
|
1907
|
-
published: true,
|
|
1908
|
-
theme,
|
|
1909
|
-
bannerUrl,
|
|
1910
|
-
};
|
|
1911
|
-
const newWishlist = await this.wishlistRepository.create(data);
|
|
1912
|
-
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1913
|
-
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1914
|
-
}
|
|
1915
|
-
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1916
|
-
const data = {
|
|
1917
|
-
id,
|
|
1918
|
-
name: title,
|
|
1919
|
-
description,
|
|
1920
|
-
metadata: {
|
|
1921
|
-
title: `${userFullName} - ${title}`,
|
|
1922
|
-
description: `${userFullName} - ${description}`,
|
|
1923
|
-
},
|
|
1924
|
-
personName: userFullName,
|
|
1925
|
-
personPhoto: userPhoto,
|
|
1926
|
-
theme,
|
|
1927
|
-
bannerUrl,
|
|
1928
|
-
};
|
|
1929
|
-
return this.wishlistRepository.update(data);
|
|
1930
|
-
}
|
|
1931
|
-
delete(wishlistId) {
|
|
1932
|
-
return this.wishlistRepository.delete({ id: wishlistId });
|
|
1933
|
-
}
|
|
1934
|
-
getWishlistBySlug(slug) {
|
|
1935
|
-
const [id] = slug.split('-');
|
|
1936
|
-
if (+id)
|
|
1937
|
-
return this.wishlistRepository.get({ id });
|
|
1938
|
-
return this.wishlistRepository.getWishlistBySlug(slug);
|
|
1939
|
-
}
|
|
1940
|
-
getWishlistsByPerson(personId) {
|
|
1941
|
-
return this.wishlistRepository.getWishlistByPerson(personId);
|
|
1942
|
-
}
|
|
1943
|
-
async addProduct(wishlistId, productId) {
|
|
1944
|
-
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
1945
|
-
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
1946
|
-
if (!hasProduct) {
|
|
1947
|
-
wishlist.products = [...wishlist.products, productId];
|
|
1948
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1949
|
-
}
|
|
1950
|
-
return wishlist;
|
|
1951
|
-
}
|
|
1952
|
-
async removeProduct(wishlistId, productId) {
|
|
1953
|
-
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
1954
|
-
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
1955
|
-
if (productIndex != -1) {
|
|
1956
|
-
wishlist.products.splice(productIndex, 1);
|
|
1957
|
-
if (!wishlist.products.length)
|
|
1958
|
-
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
1959
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1960
|
-
}
|
|
1961
|
-
return wishlist;
|
|
1962
|
-
}
|
|
1963
|
-
}
|
|
1964
|
-
WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1965
|
-
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
|
|
1966
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
|
|
1967
|
-
type: Injectable
|
|
1968
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1969
|
-
type: Inject,
|
|
1970
|
-
args: ['WishlistRepository']
|
|
1971
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
1972
|
-
type: Inject,
|
|
1973
|
-
args: [DEFAULT_SHOP]
|
|
1974
|
-
}] }, { type: undefined, decorators: [{
|
|
1975
|
-
type: Inject,
|
|
1976
|
-
args: ['ProductRepository']
|
|
1977
|
-
}] }, { type: undefined, decorators: [{
|
|
1978
|
-
type: Inject,
|
|
1979
|
-
args: ['CategoryFilterRepository']
|
|
1980
|
-
}] }, { type: undefined, decorators: [{
|
|
1981
|
-
type: Inject,
|
|
1982
|
-
args: ['CategoryRepository']
|
|
1880
|
+
class WishlistService {
|
|
1881
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
|
|
1882
|
+
this.wishlistRepository = wishlistRepository;
|
|
1883
|
+
this.shop = shop;
|
|
1884
|
+
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1885
|
+
this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
|
|
1886
|
+
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1887
|
+
}
|
|
1888
|
+
getCatalogService() {
|
|
1889
|
+
return this.catalogService;
|
|
1890
|
+
}
|
|
1891
|
+
getCategoryService() {
|
|
1892
|
+
return this.categoryService;
|
|
1893
|
+
}
|
|
1894
|
+
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1895
|
+
const data = {
|
|
1896
|
+
slug: '',
|
|
1897
|
+
name: title,
|
|
1898
|
+
description,
|
|
1899
|
+
metadata: {
|
|
1900
|
+
title: `${userFullName} - ${title}`,
|
|
1901
|
+
description: `${userFullName} - ${description}`,
|
|
1902
|
+
},
|
|
1903
|
+
shop: this.shop,
|
|
1904
|
+
shops: [this.shop],
|
|
1905
|
+
personId,
|
|
1906
|
+
personName: userFullName,
|
|
1907
|
+
personPhoto: userPhoto,
|
|
1908
|
+
brandCategory: false,
|
|
1909
|
+
published: true,
|
|
1910
|
+
theme,
|
|
1911
|
+
bannerUrl,
|
|
1912
|
+
};
|
|
1913
|
+
const newWishlist = await this.wishlistRepository.create(data);
|
|
1914
|
+
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1915
|
+
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1916
|
+
}
|
|
1917
|
+
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1918
|
+
const data = {
|
|
1919
|
+
id,
|
|
1920
|
+
name: title,
|
|
1921
|
+
description,
|
|
1922
|
+
metadata: {
|
|
1923
|
+
title: `${userFullName} - ${title}`,
|
|
1924
|
+
description: `${userFullName} - ${description}`,
|
|
1925
|
+
},
|
|
1926
|
+
personName: userFullName,
|
|
1927
|
+
personPhoto: userPhoto,
|
|
1928
|
+
theme,
|
|
1929
|
+
bannerUrl,
|
|
1930
|
+
};
|
|
1931
|
+
return this.wishlistRepository.update(data);
|
|
1932
|
+
}
|
|
1933
|
+
delete(wishlistId) {
|
|
1934
|
+
return this.wishlistRepository.delete({ id: wishlistId });
|
|
1935
|
+
}
|
|
1936
|
+
getWishlistBySlug(slug) {
|
|
1937
|
+
const [id] = slug.split('-');
|
|
1938
|
+
if (+id)
|
|
1939
|
+
return this.wishlistRepository.get({ id });
|
|
1940
|
+
return this.wishlistRepository.getWishlistBySlug(slug);
|
|
1941
|
+
}
|
|
1942
|
+
getWishlistsByPerson(personId) {
|
|
1943
|
+
return this.wishlistRepository.getWishlistByPerson(personId);
|
|
1944
|
+
}
|
|
1945
|
+
async addProduct(wishlistId, productId) {
|
|
1946
|
+
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
1947
|
+
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
1948
|
+
if (!hasProduct) {
|
|
1949
|
+
wishlist.products = [...wishlist.products, productId];
|
|
1950
|
+
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1951
|
+
}
|
|
1952
|
+
return wishlist;
|
|
1953
|
+
}
|
|
1954
|
+
async removeProduct(wishlistId, productId) {
|
|
1955
|
+
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
1956
|
+
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
1957
|
+
if (productIndex != -1) {
|
|
1958
|
+
wishlist.products.splice(productIndex, 1);
|
|
1959
|
+
if (!wishlist.products.length)
|
|
1960
|
+
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
1961
|
+
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1962
|
+
}
|
|
1963
|
+
return wishlist;
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1967
|
+
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
|
|
1968
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
|
|
1969
|
+
type: Injectable
|
|
1970
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1971
|
+
type: Inject,
|
|
1972
|
+
args: ['WishlistRepository']
|
|
1973
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1974
|
+
type: Inject,
|
|
1975
|
+
args: [DEFAULT_SHOP]
|
|
1976
|
+
}] }, { type: undefined, decorators: [{
|
|
1977
|
+
type: Inject,
|
|
1978
|
+
args: ['ProductRepository']
|
|
1979
|
+
}] }, { type: undefined, decorators: [{
|
|
1980
|
+
type: Inject,
|
|
1981
|
+
args: ['CategoryFilterRepository']
|
|
1982
|
+
}] }, { type: undefined, decorators: [{
|
|
1983
|
+
type: Inject,
|
|
1984
|
+
args: ['CategoryRepository']
|
|
1983
1985
|
}] }, { type: i1$2.ProductsIndex }]; } });
|
|
1984
1986
|
|
|
1985
|
-
class CheckoutSubscriptionService {
|
|
1986
|
-
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
1987
|
-
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1988
|
-
this.dataPersistence = dataPersistence;
|
|
1989
|
-
this.couponService = couponService;
|
|
1990
|
-
}
|
|
1991
|
-
getCheckoutSubscription(checkoutData) {
|
|
1992
|
-
return this.dataPersistence
|
|
1993
|
-
.get('checkoutSubscriptionId')
|
|
1994
|
-
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
1995
|
-
}
|
|
1996
|
-
clearCheckoutSubscriptionFromSession() {
|
|
1997
|
-
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
1998
|
-
}
|
|
1999
|
-
checkCoupon(nickname, userEmail) {
|
|
2000
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
2001
|
-
.checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
|
|
2002
|
-
.pipe()));
|
|
2003
|
-
}
|
|
2004
|
-
calcDiscountSubscription(coupon) {
|
|
2005
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2006
|
-
}
|
|
2007
|
-
async createCheckoutSubscription(checkoutData) {
|
|
2008
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2009
|
-
createdAt: new Date(),
|
|
2010
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2011
|
-
});
|
|
2012
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2013
|
-
return checkout;
|
|
2014
|
-
}
|
|
2015
|
-
}
|
|
2016
|
-
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2017
|
-
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
|
|
2018
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
2019
|
-
type: Injectable
|
|
2020
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2021
|
-
type: Inject,
|
|
2022
|
-
args: ['CheckoutSubscriptionRepository']
|
|
2023
|
-
}] }, { type: undefined, decorators: [{
|
|
2024
|
-
type: Inject,
|
|
2025
|
-
args: [PERSISTENCE_PROVIDER]
|
|
1987
|
+
class CheckoutSubscriptionService {
|
|
1988
|
+
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
1989
|
+
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1990
|
+
this.dataPersistence = dataPersistence;
|
|
1991
|
+
this.couponService = couponService;
|
|
1992
|
+
}
|
|
1993
|
+
getCheckoutSubscription(checkoutData) {
|
|
1994
|
+
return this.dataPersistence
|
|
1995
|
+
.get('checkoutSubscriptionId')
|
|
1996
|
+
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
1997
|
+
}
|
|
1998
|
+
clearCheckoutSubscriptionFromSession() {
|
|
1999
|
+
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
2000
|
+
}
|
|
2001
|
+
checkCoupon(nickname, userEmail) {
|
|
2002
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
2003
|
+
.checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
|
|
2004
|
+
.pipe()));
|
|
2005
|
+
}
|
|
2006
|
+
calcDiscountSubscription(coupon) {
|
|
2007
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2008
|
+
}
|
|
2009
|
+
async createCheckoutSubscription(checkoutData) {
|
|
2010
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2011
|
+
createdAt: new Date(),
|
|
2012
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2013
|
+
});
|
|
2014
|
+
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2015
|
+
return checkout;
|
|
2016
|
+
}
|
|
2017
|
+
}
|
|
2018
|
+
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2019
|
+
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
|
|
2020
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
2021
|
+
type: Injectable
|
|
2022
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2023
|
+
type: Inject,
|
|
2024
|
+
args: ['CheckoutSubscriptionRepository']
|
|
2025
|
+
}] }, { type: undefined, decorators: [{
|
|
2026
|
+
type: Inject,
|
|
2027
|
+
args: [PERSISTENCE_PROVIDER]
|
|
2026
2028
|
}] }, { type: CouponService }]; } });
|
|
2027
2029
|
|
|
2028
|
-
class UtilHelper {
|
|
2029
|
-
static createSlug(name) {
|
|
2030
|
-
return name
|
|
2031
|
-
.toLowerCase()
|
|
2032
|
-
.replace(/\s+/g, '-') // Replace spaces with -
|
|
2033
|
-
.replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
|
|
2034
|
-
.replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
|
|
2035
|
-
.replace(/[ìíïî]/g, 'i') // Replace spaces with -
|
|
2036
|
-
.replace(/[õòóöô]/g, 'o') // Replace spaces with -
|
|
2037
|
-
.replace(/[ùúüû]/g, 'u') // Replace spaces with -
|
|
2038
|
-
.replace(/[ñ]/g, 'n') // Replace spaces with -
|
|
2039
|
-
.replace(/[ç]/g, 'c') // Replace spaces with -
|
|
2040
|
-
.replace(/[&]/g, 'and') // Replace spaces with -
|
|
2041
|
-
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
2042
|
-
.replace(/\-\-+/g, '-'); // Replace multiple - with single -
|
|
2043
|
-
}
|
|
2030
|
+
class UtilHelper {
|
|
2031
|
+
static createSlug(name) {
|
|
2032
|
+
return name
|
|
2033
|
+
.toLowerCase()
|
|
2034
|
+
.replace(/\s+/g, '-') // Replace spaces with -
|
|
2035
|
+
.replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
|
|
2036
|
+
.replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
|
|
2037
|
+
.replace(/[ìíïî]/g, 'i') // Replace spaces with -
|
|
2038
|
+
.replace(/[õòóöô]/g, 'o') // Replace spaces with -
|
|
2039
|
+
.replace(/[ùúüû]/g, 'u') // Replace spaces with -
|
|
2040
|
+
.replace(/[ñ]/g, 'n') // Replace spaces with -
|
|
2041
|
+
.replace(/[ç]/g, 'c') // Replace spaces with -
|
|
2042
|
+
.replace(/[&]/g, 'and') // Replace spaces with -
|
|
2043
|
+
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
2044
|
+
.replace(/\-\-+/g, '-'); // Replace multiple - with single -
|
|
2045
|
+
}
|
|
2044
2046
|
}
|
|
2045
2047
|
|
|
2046
|
-
class HomeShopService {
|
|
2047
|
-
get homeId() {
|
|
2048
|
-
if (this.defaultShop === Shops.GLAMSHOP)
|
|
2049
|
-
return 'glamshop';
|
|
2050
|
-
if (this.defaultShop === Shops.MENSMARKET)
|
|
2051
|
-
return 'mens_market';
|
|
2052
|
-
return null;
|
|
2053
|
-
}
|
|
2054
|
-
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
2055
|
-
this.categoryRepository = categoryRepository;
|
|
2056
|
-
this.homeRepository = homeRepository;
|
|
2057
|
-
this.productRepository = productRepository;
|
|
2058
|
-
this.defaultShop = defaultShop;
|
|
2059
|
-
this.buildCategoryGroupWithRequiredData = (group) => ({
|
|
2060
|
-
category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
2061
|
-
products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
|
|
2062
|
-
'id',
|
|
2063
|
-
'price',
|
|
2064
|
-
'reviews',
|
|
2065
|
-
'hasVariants',
|
|
2066
|
-
'slug',
|
|
2067
|
-
'sku',
|
|
2068
|
-
'stock',
|
|
2069
|
-
'costPrice',
|
|
2070
|
-
'images',
|
|
2071
|
-
'miniatures',
|
|
2072
|
-
'name',
|
|
2073
|
-
'weight',
|
|
2074
|
-
'rate',
|
|
2075
|
-
'type',
|
|
2076
|
-
'brand',
|
|
2077
|
-
]))) || [],
|
|
2078
|
-
});
|
|
2079
|
-
}
|
|
2080
|
-
getHomeData() {
|
|
2081
|
-
return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
|
|
2082
|
-
? of(home)
|
|
2083
|
-
: forkJoin([
|
|
2084
|
-
this.getDiscoverProducts(this.gender),
|
|
2085
|
-
this.getFeaturedProducts(this.gender),
|
|
2086
|
-
this.getVerticalProducts(this.gender),
|
|
2087
|
-
]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
2088
|
-
discoverProducts,
|
|
2089
|
-
featuredProducts,
|
|
2090
|
-
verticalProducts,
|
|
2091
|
-
})), concatMap((data) => this.saveHomeData(data)))));
|
|
2092
|
-
}
|
|
2093
|
-
getBanners(type) {
|
|
2094
|
-
return this.getHomeConfiguration().pipe(map((home) => {
|
|
2095
|
-
if (type === 'brand')
|
|
2096
|
-
return home.brandsCarousel;
|
|
2097
|
-
if (type === 'buyToWin')
|
|
2098
|
-
return [home.buyToWinBanner];
|
|
2099
|
-
if (type === 'block')
|
|
2100
|
-
return home.blockBanners;
|
|
2101
|
-
if (type === 'blog')
|
|
2102
|
-
return [home.blogBanner];
|
|
2103
|
-
return [];
|
|
2104
|
-
}));
|
|
2105
|
-
}
|
|
2106
|
-
getMinValueForFreeShipping() {
|
|
2107
|
-
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
2108
|
-
}
|
|
2109
|
-
getDiscoverProducts(gender) {
|
|
2110
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2111
|
-
}
|
|
2112
|
-
getFeaturedProducts(gender) {
|
|
2113
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2114
|
-
}
|
|
2115
|
-
getVerticalProducts(gender) {
|
|
2116
|
-
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({
|
|
2117
|
-
filters: {
|
|
2118
|
-
categories: { operator: Where.IN, value: [category.id] },
|
|
2119
|
-
...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
|
|
2120
|
-
},
|
|
2121
|
-
limits: { limit: 12 },
|
|
2122
|
-
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
2123
|
-
}
|
|
2124
|
-
getHomeConfiguration() {
|
|
2125
|
-
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
2126
|
-
? of(home)
|
|
2127
|
-
: !this.homeId
|
|
2128
|
-
? throwError(new RequiredArgumentError(['homeId']))
|
|
2129
|
-
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
2130
|
-
}
|
|
2131
|
-
saveHomeData(homeData) {
|
|
2132
|
-
const data = {
|
|
2133
|
-
createdAt: new Date(),
|
|
2134
|
-
expiresAt: add(new Date(), { hours: 1 }),
|
|
2135
|
-
data: homeData,
|
|
2136
|
-
};
|
|
2137
|
-
return from(this.homeRepository.update({
|
|
2138
|
-
id: this.homeId,
|
|
2139
|
-
data,
|
|
2140
|
-
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
2141
|
-
}
|
|
2142
|
-
get gender() {
|
|
2143
|
-
return this.homeId === 'mens_market' ? 'masculino' : undefined;
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
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 });
|
|
2147
|
-
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
|
|
2148
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
|
|
2149
|
-
type: Injectable
|
|
2150
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2151
|
-
type: Inject,
|
|
2152
|
-
args: ['CategoryRepository']
|
|
2153
|
-
}] }, { type: undefined, decorators: [{
|
|
2154
|
-
type: Inject,
|
|
2155
|
-
args: ['HomeRepository']
|
|
2156
|
-
}] }, { type: undefined, decorators: [{
|
|
2157
|
-
type: Inject,
|
|
2158
|
-
args: ['ProductRepository']
|
|
2159
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
2160
|
-
type: Inject,
|
|
2161
|
-
args: [DEFAULT_SHOP]
|
|
2048
|
+
class HomeShopService {
|
|
2049
|
+
get homeId() {
|
|
2050
|
+
if (this.defaultShop === Shops.GLAMSHOP)
|
|
2051
|
+
return 'glamshop';
|
|
2052
|
+
if (this.defaultShop === Shops.MENSMARKET)
|
|
2053
|
+
return 'mens_market';
|
|
2054
|
+
return null;
|
|
2055
|
+
}
|
|
2056
|
+
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
2057
|
+
this.categoryRepository = categoryRepository;
|
|
2058
|
+
this.homeRepository = homeRepository;
|
|
2059
|
+
this.productRepository = productRepository;
|
|
2060
|
+
this.defaultShop = defaultShop;
|
|
2061
|
+
this.buildCategoryGroupWithRequiredData = (group) => ({
|
|
2062
|
+
category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
2063
|
+
products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
|
|
2064
|
+
'id',
|
|
2065
|
+
'price',
|
|
2066
|
+
'reviews',
|
|
2067
|
+
'hasVariants',
|
|
2068
|
+
'slug',
|
|
2069
|
+
'sku',
|
|
2070
|
+
'stock',
|
|
2071
|
+
'costPrice',
|
|
2072
|
+
'images',
|
|
2073
|
+
'miniatures',
|
|
2074
|
+
'name',
|
|
2075
|
+
'weight',
|
|
2076
|
+
'rate',
|
|
2077
|
+
'type',
|
|
2078
|
+
'brand',
|
|
2079
|
+
]))) || [],
|
|
2080
|
+
});
|
|
2081
|
+
}
|
|
2082
|
+
getHomeData() {
|
|
2083
|
+
return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
|
|
2084
|
+
? of(home)
|
|
2085
|
+
: forkJoin([
|
|
2086
|
+
this.getDiscoverProducts(this.gender),
|
|
2087
|
+
this.getFeaturedProducts(this.gender),
|
|
2088
|
+
this.getVerticalProducts(this.gender),
|
|
2089
|
+
]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
2090
|
+
discoverProducts,
|
|
2091
|
+
featuredProducts,
|
|
2092
|
+
verticalProducts,
|
|
2093
|
+
})), concatMap((data) => this.saveHomeData(data)))));
|
|
2094
|
+
}
|
|
2095
|
+
getBanners(type) {
|
|
2096
|
+
return this.getHomeConfiguration().pipe(map((home) => {
|
|
2097
|
+
if (type === 'brand')
|
|
2098
|
+
return home.brandsCarousel;
|
|
2099
|
+
if (type === 'buyToWin')
|
|
2100
|
+
return [home.buyToWinBanner];
|
|
2101
|
+
if (type === 'block')
|
|
2102
|
+
return home.blockBanners;
|
|
2103
|
+
if (type === 'blog')
|
|
2104
|
+
return [home.blogBanner];
|
|
2105
|
+
return [];
|
|
2106
|
+
}));
|
|
2107
|
+
}
|
|
2108
|
+
getMinValueForFreeShipping() {
|
|
2109
|
+
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
2110
|
+
}
|
|
2111
|
+
getDiscoverProducts(gender) {
|
|
2112
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2113
|
+
}
|
|
2114
|
+
getFeaturedProducts(gender) {
|
|
2115
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2116
|
+
}
|
|
2117
|
+
getVerticalProducts(gender) {
|
|
2118
|
+
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({
|
|
2119
|
+
filters: {
|
|
2120
|
+
categories: { operator: Where.IN, value: [category.id] },
|
|
2121
|
+
...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
|
|
2122
|
+
},
|
|
2123
|
+
limits: { limit: 12 },
|
|
2124
|
+
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
2125
|
+
}
|
|
2126
|
+
getHomeConfiguration() {
|
|
2127
|
+
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
2128
|
+
? of(home)
|
|
2129
|
+
: !this.homeId
|
|
2130
|
+
? throwError(new RequiredArgumentError(['homeId']))
|
|
2131
|
+
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
2132
|
+
}
|
|
2133
|
+
saveHomeData(homeData) {
|
|
2134
|
+
const data = {
|
|
2135
|
+
createdAt: new Date(),
|
|
2136
|
+
expiresAt: add(new Date(), { hours: 1 }),
|
|
2137
|
+
data: homeData,
|
|
2138
|
+
};
|
|
2139
|
+
return from(this.homeRepository.update({
|
|
2140
|
+
id: this.homeId,
|
|
2141
|
+
data,
|
|
2142
|
+
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
2143
|
+
}
|
|
2144
|
+
get gender() {
|
|
2145
|
+
return this.homeId === 'mens_market' ? 'masculino' : undefined;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
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 });
|
|
2149
|
+
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
|
|
2150
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
|
|
2151
|
+
type: Injectable
|
|
2152
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2153
|
+
type: Inject,
|
|
2154
|
+
args: ['CategoryRepository']
|
|
2155
|
+
}] }, { type: undefined, decorators: [{
|
|
2156
|
+
type: Inject,
|
|
2157
|
+
args: ['HomeRepository']
|
|
2158
|
+
}] }, { type: undefined, decorators: [{
|
|
2159
|
+
type: Inject,
|
|
2160
|
+
args: ['ProductRepository']
|
|
2161
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
2162
|
+
type: Inject,
|
|
2163
|
+
args: [DEFAULT_SHOP]
|
|
2162
2164
|
}] }]; } });
|
|
2163
2165
|
|
|
2164
|
-
class OrderService {
|
|
2165
|
-
constructor(angularFirestore, orderRepository) {
|
|
2166
|
-
this.angularFirestore = angularFirestore;
|
|
2167
|
-
this.orderRepository = orderRepository;
|
|
2168
|
-
this.orderSubject = new Subject();
|
|
2169
|
-
}
|
|
2170
|
-
getOrder(id) {
|
|
2171
|
-
docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
|
|
2172
|
-
.pipe(map((doc) => Order.toInstance(doc.data())))
|
|
2173
|
-
.subscribe((doc) => this.orderSubject.next(doc));
|
|
2174
|
-
return this.orderSubject;
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
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 });
|
|
2178
|
-
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
|
|
2179
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
|
|
2180
|
-
type: Injectable
|
|
2181
|
-
}], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
|
|
2182
|
-
type: Inject,
|
|
2183
|
-
args: ['OrderRepository']
|
|
2166
|
+
class OrderService {
|
|
2167
|
+
constructor(angularFirestore, orderRepository) {
|
|
2168
|
+
this.angularFirestore = angularFirestore;
|
|
2169
|
+
this.orderRepository = orderRepository;
|
|
2170
|
+
this.orderSubject = new Subject();
|
|
2171
|
+
}
|
|
2172
|
+
getOrder(id) {
|
|
2173
|
+
docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
|
|
2174
|
+
.pipe(map((doc) => Order.toInstance(doc.data())))
|
|
2175
|
+
.subscribe((doc) => this.orderSubject.next(doc));
|
|
2176
|
+
return this.orderSubject;
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
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 });
|
|
2180
|
+
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
|
|
2181
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
|
|
2182
|
+
type: Injectable
|
|
2183
|
+
}], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
|
|
2184
|
+
type: Inject,
|
|
2185
|
+
args: ['OrderRepository']
|
|
2184
2186
|
}] }]; } });
|
|
2185
2187
|
|
|
2186
|
-
class ShippingService {
|
|
2187
|
-
constructor(http, apiUrl, homeService) {
|
|
2188
|
-
this.http = http;
|
|
2189
|
-
this.apiUrl = apiUrl;
|
|
2190
|
-
this.homeService = homeService;
|
|
2191
|
-
}
|
|
2192
|
-
getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
2193
|
-
return combineLatest([
|
|
2194
|
-
this.homeService.getHomeData(),
|
|
2195
|
-
this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
|
|
2196
|
-
]).pipe(map(([datas, shippingMethodsResponse]) => {
|
|
2197
|
-
let shippingMethods = shippingMethodsResponse.result;
|
|
2198
|
-
if (!shippingMethods.length)
|
|
2199
|
-
return [];
|
|
2200
|
-
shippingMethods = shippingMethods.map((shippingMethod) => {
|
|
2201
|
-
if (shippingMethod.ShippingCompanyName == 'Same Day EG')
|
|
2202
|
-
shippingMethod.ShippingCompanyName = 'Same Day';
|
|
2203
|
-
return shippingMethod;
|
|
2204
|
-
});
|
|
2205
|
-
const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
2206
|
-
if (this.isHolidays(datasSameDayNotAvaliable)) {
|
|
2207
|
-
shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
|
|
2208
|
-
}
|
|
2209
|
-
if (totalPrice >= 200) {
|
|
2210
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2211
|
-
if (s.serviceName !== 'Same Day')
|
|
2212
|
-
return { ...s, totalPrice: 0 };
|
|
2213
|
-
else
|
|
2214
|
-
return s;
|
|
2215
|
-
});
|
|
2216
|
-
}
|
|
2217
|
-
if (shop == Shops.GLAMSHOP)
|
|
2218
|
-
return shippingMethods;
|
|
2219
|
-
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
2220
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2221
|
-
if (s.serviceName == 'Same Day')
|
|
2222
|
-
return { ...s, totalPrice: s.totalPrice / 2 };
|
|
2223
|
-
else
|
|
2224
|
-
return { ...s, totalPrice: 0 };
|
|
2225
|
-
});
|
|
2226
|
-
}
|
|
2227
|
-
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
2228
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2229
|
-
return { ...s, totalPrice: s.totalPrice / 2 };
|
|
2230
|
-
});
|
|
2231
|
-
}
|
|
2232
|
-
return shippingMethods;
|
|
2233
|
-
}));
|
|
2234
|
-
}
|
|
2235
|
-
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
2236
|
-
if (!subscriptionPlan)
|
|
2237
|
-
return false;
|
|
2238
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
|
|
2239
|
-
return true;
|
|
2240
|
-
return false;
|
|
2241
|
-
}
|
|
2242
|
-
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
2243
|
-
if (!subscriptionPlan)
|
|
2244
|
-
return false;
|
|
2245
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
2246
|
-
return true;
|
|
2247
|
-
}
|
|
2248
|
-
return false;
|
|
2249
|
-
}
|
|
2250
|
-
isHolidays(datas) {
|
|
2251
|
-
const today = new Date();
|
|
2252
|
-
for (const key in datas) {
|
|
2253
|
-
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
2254
|
-
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
2255
|
-
if (start > end)
|
|
2256
|
-
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
2257
|
-
if (today >= start && today <= end)
|
|
2258
|
-
return true;
|
|
2259
|
-
}
|
|
2260
|
-
return false;
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2264
|
-
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
|
|
2265
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
|
|
2266
|
-
type: Injectable
|
|
2267
|
-
}], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
|
|
2268
|
-
type: Inject,
|
|
2269
|
-
args: [BACKEND_URL]
|
|
2188
|
+
class ShippingService {
|
|
2189
|
+
constructor(http, apiUrl, homeService) {
|
|
2190
|
+
this.http = http;
|
|
2191
|
+
this.apiUrl = apiUrl;
|
|
2192
|
+
this.homeService = homeService;
|
|
2193
|
+
}
|
|
2194
|
+
getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
2195
|
+
return combineLatest([
|
|
2196
|
+
this.homeService.getHomeData(),
|
|
2197
|
+
this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
|
|
2198
|
+
]).pipe(map(([datas, shippingMethodsResponse]) => {
|
|
2199
|
+
let shippingMethods = shippingMethodsResponse.result;
|
|
2200
|
+
if (!shippingMethods.length)
|
|
2201
|
+
return [];
|
|
2202
|
+
shippingMethods = shippingMethods.map((shippingMethod) => {
|
|
2203
|
+
if (shippingMethod.ShippingCompanyName == 'Same Day EG')
|
|
2204
|
+
shippingMethod.ShippingCompanyName = 'Same Day';
|
|
2205
|
+
return shippingMethod;
|
|
2206
|
+
});
|
|
2207
|
+
const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
2208
|
+
if (this.isHolidays(datasSameDayNotAvaliable)) {
|
|
2209
|
+
shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
|
|
2210
|
+
}
|
|
2211
|
+
if (totalPrice >= 200) {
|
|
2212
|
+
shippingMethods = shippingMethods.map((s) => {
|
|
2213
|
+
if (s.serviceName !== 'Same Day')
|
|
2214
|
+
return { ...s, totalPrice: 0 };
|
|
2215
|
+
else
|
|
2216
|
+
return s;
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
if (shop == Shops.GLAMSHOP)
|
|
2220
|
+
return shippingMethods;
|
|
2221
|
+
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
2222
|
+
shippingMethods = shippingMethods.map((s) => {
|
|
2223
|
+
if (s.serviceName == 'Same Day')
|
|
2224
|
+
return { ...s, totalPrice: s.totalPrice / 2 };
|
|
2225
|
+
else
|
|
2226
|
+
return { ...s, totalPrice: 0 };
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
2230
|
+
shippingMethods = shippingMethods.map((s) => {
|
|
2231
|
+
return { ...s, totalPrice: s.totalPrice / 2 };
|
|
2232
|
+
});
|
|
2233
|
+
}
|
|
2234
|
+
return shippingMethods;
|
|
2235
|
+
}));
|
|
2236
|
+
}
|
|
2237
|
+
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
2238
|
+
if (!subscriptionPlan)
|
|
2239
|
+
return false;
|
|
2240
|
+
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
|
|
2241
|
+
return true;
|
|
2242
|
+
return false;
|
|
2243
|
+
}
|
|
2244
|
+
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
2245
|
+
if (!subscriptionPlan)
|
|
2246
|
+
return false;
|
|
2247
|
+
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
2248
|
+
return true;
|
|
2249
|
+
}
|
|
2250
|
+
return false;
|
|
2251
|
+
}
|
|
2252
|
+
isHolidays(datas) {
|
|
2253
|
+
const today = new Date();
|
|
2254
|
+
for (const key in datas) {
|
|
2255
|
+
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
2256
|
+
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
2257
|
+
if (start > end)
|
|
2258
|
+
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
2259
|
+
if (today >= start && today <= end)
|
|
2260
|
+
return true;
|
|
2261
|
+
}
|
|
2262
|
+
return false;
|
|
2263
|
+
}
|
|
2264
|
+
}
|
|
2265
|
+
ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2266
|
+
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
|
|
2267
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
|
|
2268
|
+
type: Injectable
|
|
2269
|
+
}], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
|
|
2270
|
+
type: Inject,
|
|
2271
|
+
args: [BACKEND_URL]
|
|
2270
2272
|
}] }, { type: HomeShopService }]; } });
|
|
2271
2273
|
|
|
2272
|
-
class AngularConnectModule {
|
|
2273
|
-
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
2274
|
-
return {
|
|
2275
|
-
ngModule: AngularConnectModule,
|
|
2276
|
-
providers: [
|
|
2277
|
-
{
|
|
2278
|
-
provide: CATEGORY_STRUCTURE,
|
|
2279
|
-
useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
|
|
2280
|
-
? OldCategoryStructureAdapter
|
|
2281
|
-
: NewCategoryStructureAdapter,
|
|
2282
|
-
},
|
|
2283
|
-
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2284
|
-
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2285
|
-
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2286
|
-
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
2287
|
-
...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
2288
|
-
...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
2289
|
-
...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
2290
|
-
...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
|
|
2291
|
-
],
|
|
2292
|
-
};
|
|
2293
|
-
}
|
|
2294
|
-
}
|
|
2295
|
-
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2296
|
-
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
|
|
2297
|
-
AngularFirebaseAuthModule,
|
|
2298
|
-
AngularFirestoreModule,
|
|
2299
|
-
AngularHasuraGraphQLModule] });
|
|
2300
|
-
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
|
|
2301
|
-
AuthService,
|
|
2302
|
-
CartService,
|
|
2303
|
-
CatalogService,
|
|
2304
|
-
CategoryService,
|
|
2305
|
-
CheckoutService,
|
|
2306
|
-
CheckoutSubscriptionService,
|
|
2307
|
-
CouponService,
|
|
2308
|
-
HomeShopService,
|
|
2309
|
-
OrderService,
|
|
2310
|
-
ShippingService,
|
|
2311
|
-
WishlistService,
|
|
2312
|
-
{
|
|
2313
|
-
provide: UpdateUserImage,
|
|
2314
|
-
useFactory: (userRepository, fileUploader) => {
|
|
2315
|
-
return new UpdateUserImage(userRepository, fileUploader);
|
|
2316
|
-
},
|
|
2317
|
-
deps: ['UserRepository', 'FileUploaderService'],
|
|
2318
|
-
},
|
|
2319
|
-
], imports: [provideFirebaseApp((injector) => {
|
|
2320
|
-
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2321
|
-
try {
|
|
2322
|
-
return getApp(appName);
|
|
2323
|
-
}
|
|
2324
|
-
catch (error) {
|
|
2325
|
-
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2326
|
-
}
|
|
2327
|
-
}),
|
|
2328
|
-
AngularElasticSeachModule,
|
|
2329
|
-
AngularFirebaseAuthModule,
|
|
2330
|
-
AngularFirestoreModule,
|
|
2331
|
-
AngularHasuraGraphQLModule] });
|
|
2332
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
2333
|
-
type: NgModule,
|
|
2334
|
-
args: [{
|
|
2335
|
-
imports: [
|
|
2336
|
-
provideFirebaseApp((injector) => {
|
|
2337
|
-
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2338
|
-
try {
|
|
2339
|
-
return getApp(appName);
|
|
2340
|
-
}
|
|
2341
|
-
catch (error) {
|
|
2342
|
-
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2343
|
-
}
|
|
2344
|
-
}),
|
|
2345
|
-
AngularElasticSeachModule,
|
|
2346
|
-
AngularFirebaseAuthModule,
|
|
2347
|
-
AngularFirestoreModule,
|
|
2348
|
-
AngularHasuraGraphQLModule,
|
|
2349
|
-
],
|
|
2350
|
-
providers: [
|
|
2351
|
-
AuthService,
|
|
2352
|
-
CartService,
|
|
2353
|
-
CatalogService,
|
|
2354
|
-
CategoryService,
|
|
2355
|
-
CheckoutService,
|
|
2356
|
-
CheckoutSubscriptionService,
|
|
2357
|
-
CouponService,
|
|
2358
|
-
HomeShopService,
|
|
2359
|
-
OrderService,
|
|
2360
|
-
ShippingService,
|
|
2361
|
-
WishlistService,
|
|
2362
|
-
{
|
|
2363
|
-
provide: UpdateUserImage,
|
|
2364
|
-
useFactory: (userRepository, fileUploader) => {
|
|
2365
|
-
return new UpdateUserImage(userRepository, fileUploader);
|
|
2366
|
-
},
|
|
2367
|
-
deps: ['UserRepository', 'FileUploaderService'],
|
|
2368
|
-
},
|
|
2369
|
-
],
|
|
2370
|
-
}]
|
|
2274
|
+
class AngularConnectModule {
|
|
2275
|
+
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
2276
|
+
return {
|
|
2277
|
+
ngModule: AngularConnectModule,
|
|
2278
|
+
providers: [
|
|
2279
|
+
{
|
|
2280
|
+
provide: CATEGORY_STRUCTURE,
|
|
2281
|
+
useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
|
|
2282
|
+
? OldCategoryStructureAdapter
|
|
2283
|
+
: NewCategoryStructureAdapter,
|
|
2284
|
+
},
|
|
2285
|
+
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2286
|
+
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2287
|
+
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2288
|
+
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
2289
|
+
...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
2290
|
+
...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
2291
|
+
...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
2292
|
+
...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
|
|
2293
|
+
],
|
|
2294
|
+
};
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2298
|
+
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
|
|
2299
|
+
AngularFirebaseAuthModule,
|
|
2300
|
+
AngularFirestoreModule,
|
|
2301
|
+
AngularHasuraGraphQLModule] });
|
|
2302
|
+
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
|
|
2303
|
+
AuthService,
|
|
2304
|
+
CartService,
|
|
2305
|
+
CatalogService,
|
|
2306
|
+
CategoryService,
|
|
2307
|
+
CheckoutService,
|
|
2308
|
+
CheckoutSubscriptionService,
|
|
2309
|
+
CouponService,
|
|
2310
|
+
HomeShopService,
|
|
2311
|
+
OrderService,
|
|
2312
|
+
ShippingService,
|
|
2313
|
+
WishlistService,
|
|
2314
|
+
{
|
|
2315
|
+
provide: UpdateUserImage,
|
|
2316
|
+
useFactory: (userRepository, fileUploader) => {
|
|
2317
|
+
return new UpdateUserImage(userRepository, fileUploader);
|
|
2318
|
+
},
|
|
2319
|
+
deps: ['UserRepository', 'FileUploaderService'],
|
|
2320
|
+
},
|
|
2321
|
+
], imports: [provideFirebaseApp((injector) => {
|
|
2322
|
+
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2323
|
+
try {
|
|
2324
|
+
return getApp(appName);
|
|
2325
|
+
}
|
|
2326
|
+
catch (error) {
|
|
2327
|
+
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2328
|
+
}
|
|
2329
|
+
}),
|
|
2330
|
+
AngularElasticSeachModule,
|
|
2331
|
+
AngularFirebaseAuthModule,
|
|
2332
|
+
AngularFirestoreModule,
|
|
2333
|
+
AngularHasuraGraphQLModule] });
|
|
2334
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
2335
|
+
type: NgModule,
|
|
2336
|
+
args: [{
|
|
2337
|
+
imports: [
|
|
2338
|
+
provideFirebaseApp((injector) => {
|
|
2339
|
+
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2340
|
+
try {
|
|
2341
|
+
return getApp(appName);
|
|
2342
|
+
}
|
|
2343
|
+
catch (error) {
|
|
2344
|
+
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2345
|
+
}
|
|
2346
|
+
}),
|
|
2347
|
+
AngularElasticSeachModule,
|
|
2348
|
+
AngularFirebaseAuthModule,
|
|
2349
|
+
AngularFirestoreModule,
|
|
2350
|
+
AngularHasuraGraphQLModule,
|
|
2351
|
+
],
|
|
2352
|
+
providers: [
|
|
2353
|
+
AuthService,
|
|
2354
|
+
CartService,
|
|
2355
|
+
CatalogService,
|
|
2356
|
+
CategoryService,
|
|
2357
|
+
CheckoutService,
|
|
2358
|
+
CheckoutSubscriptionService,
|
|
2359
|
+
CouponService,
|
|
2360
|
+
HomeShopService,
|
|
2361
|
+
OrderService,
|
|
2362
|
+
ShippingService,
|
|
2363
|
+
WishlistService,
|
|
2364
|
+
{
|
|
2365
|
+
provide: UpdateUserImage,
|
|
2366
|
+
useFactory: (userRepository, fileUploader) => {
|
|
2367
|
+
return new UpdateUserImage(userRepository, fileUploader);
|
|
2368
|
+
},
|
|
2369
|
+
deps: ['UserRepository', 'FileUploaderService'],
|
|
2370
|
+
},
|
|
2371
|
+
],
|
|
2372
|
+
}]
|
|
2371
2373
|
}] });
|
|
2372
2374
|
|
|
2373
|
-
/**
|
|
2374
|
-
* Generated bundle index. Do not edit.
|
|
2375
|
+
/**
|
|
2376
|
+
* Generated bundle index. Do not edit.
|
|
2375
2377
|
*/
|
|
2376
2378
|
|
|
2377
2379
|
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|