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