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