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