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