@infrab4a/connect-angular 4.10.0-beta.9 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/angular-connect.module.d.ts +29 -29
- 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 -9
- 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 -8
- 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 -1
- package/esm2020/angular-connect.module.mjs +146 -146
- 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 -34
- 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 -9
- 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 -2
- package/esm2020/helpers/index.mjs +2 -2
- package/esm2020/helpers/mobile-operation-system-checker.helper.mjs +7 -7
- package/esm2020/index.mjs +7 -7
- package/esm2020/infrab4a-connect-angular.mjs +4 -4
- package/esm2020/persistence/cookie-data-persistence.mjs +22 -22
- package/esm2020/persistence/data-persistence.mjs +2 -2
- package/esm2020/persistence/index.mjs +3 -3
- package/esm2020/services/auth.service.mjs +37 -37
- package/esm2020/services/cart.service.mjs +284 -282
- package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +2 -2
- package/esm2020/services/catalog/adapters/index.mjs +4 -4
- package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +43 -43
- package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +23 -23
- package/esm2020/services/catalog/catalog.service.mjs +241 -275
- 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 +133 -133
- package/esm2020/services/checkout-subscription.service.mjs +50 -50
- package/esm2020/services/checkout.service.mjs +68 -68
- package/esm2020/services/coupon.service.mjs +265 -260
- package/esm2020/services/helpers/index.mjs +2 -2
- package/esm2020/services/helpers/util.helper.mjs +18 -18
- package/esm2020/services/home-shop.service.mjs +125 -125
- package/esm2020/services/index.mjs +11 -11
- package/esm2020/services/order.service.mjs +30 -30
- package/esm2020/services/shipping.service.mjs +96 -96
- package/esm2020/services/types/index.mjs +3 -3
- package/esm2020/services/types/required-checkout-data.type.mjs +2 -2
- package/esm2020/services/types/required-checkout-subscription-data.type.mjs +2 -2
- package/esm2020/services/types/shipping-methods.type.mjs +2 -2
- package/esm2020/types/firebase-app-config.type.mjs +2 -2
- package/esm2020/types/index.mjs +2 -2
- package/fesm2015/infrab4a-connect-angular.mjs +2499 -2527
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +2441 -2468
- 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 +45 -45
- 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, 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';
|
|
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, OrderStatus, 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,7 +56,7 @@ 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';
|
|
@@ -65,2492 +65,2465 @@ const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
|
|
|
65
65
|
|
|
66
66
|
const VERTEX_CONFIG = 'VERTEX_CONFIG';
|
|
67
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
|
-
}]
|
|
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
|
+
}]
|
|
174
174
|
}] });
|
|
175
175
|
|
|
176
|
-
class MobileOperationSystemCheckerHelper {
|
|
177
|
-
static isAppleDevice() {
|
|
178
|
-
return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
|
|
179
|
-
(navigator?.userAgent?.includes?.('Mac') && 'ontouchend' in (document || {})));
|
|
180
|
-
}
|
|
176
|
+
class MobileOperationSystemCheckerHelper {
|
|
177
|
+
static isAppleDevice() {
|
|
178
|
+
return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
|
|
179
|
+
(navigator?.userAgent?.includes?.('Mac') && 'ontouchend' in (document || {})));
|
|
180
|
+
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
class AngularFirestoreModule {
|
|
184
|
-
static initializeApp(options, nameOrConfig) {
|
|
185
|
-
return {
|
|
186
|
-
ngModule: AngularFirestoreModule,
|
|
187
|
-
providers: [
|
|
188
|
-
{ provide: FIREBASE_OPTIONS, useValue: options.firebase },
|
|
189
|
-
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
190
|
-
{ provide: ES_CONFIG, useValue: options.elasticSearch },
|
|
191
|
-
],
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
196
|
-
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule] });
|
|
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
|
-
}]
|
|
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
|
+
}]
|
|
670
670
|
}] });
|
|
671
671
|
|
|
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
|
-
}]
|
|
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
952
|
}] });
|
|
953
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
|
-
}]
|
|
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
|
+
}]
|
|
982
982
|
}] });
|
|
983
983
|
|
|
984
984
|
const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
|
|
985
985
|
|
|
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
|
|
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
|
|
1001
1001
|
}] });
|
|
1002
1002
|
|
|
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']
|
|
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']
|
|
1032
1032
|
}] }]; } });
|
|
1033
1033
|
|
|
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
|
|
1084
|
-
if (!couponUseLimits.unlimited && couponUseLimits.total &&
|
|
1085
|
-
throw 'Limite de uso atingido.';
|
|
1086
|
-
if (couponUseLimits.limitedPerUser) {
|
|
1087
|
-
const ordersWithUser = this.countOrdersWithUser(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
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 ordersCoupon = await this.getOrdersWithCoupon(coupon);
|
|
1084
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total)
|
|
1085
|
+
throw 'Limite de uso atingido.';
|
|
1086
|
+
if (couponUseLimits.limitedPerUser) {
|
|
1087
|
+
const ordersWithUser = this.countOrdersWithUser(ordersCoupon, 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
|
+
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
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
|
+
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
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
|
+
if (coupon.exclusivityType.length === 1 &&
|
|
1235
|
+
(coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
|
|
1236
|
+
coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
|
|
1237
|
+
couponUseLimits = coupon.useLimits.non_subscriber;
|
|
1238
|
+
else
|
|
1239
|
+
couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
1240
|
+
}
|
|
1241
|
+
else {
|
|
1242
|
+
couponUseLimits = coupon.useLimits.subscription;
|
|
1243
|
+
}
|
|
1244
|
+
return couponUseLimits;
|
|
1245
|
+
}
|
|
1246
|
+
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1247
|
+
let lineItemsDiscount = [];
|
|
1248
|
+
if (type === CouponTypes.ABSOLUTE) {
|
|
1249
|
+
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1250
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1251
|
+
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1252
|
+
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1253
|
+
return {
|
|
1254
|
+
...item,
|
|
1255
|
+
discount: Number(discountItem.toFixed(2)),
|
|
1256
|
+
};
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
else {
|
|
1260
|
+
lineItemsDiscount = lineItems.map((item) => {
|
|
1261
|
+
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1262
|
+
return {
|
|
1263
|
+
...item,
|
|
1264
|
+
discount: Number(discountItem.toFixed(2)),
|
|
1265
|
+
};
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
return lineItemsDiscount;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
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 });
|
|
1272
|
+
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
1273
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
|
|
1274
|
+
type: Injectable,
|
|
1275
|
+
args: [{
|
|
1276
|
+
providedIn: 'root',
|
|
1277
|
+
}]
|
|
1278
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1279
|
+
type: Inject,
|
|
1280
|
+
args: ['CouponRepository']
|
|
1281
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1282
|
+
type: Inject,
|
|
1283
|
+
args: [DEFAULT_SHOP]
|
|
1284
|
+
}] }, { type: undefined, decorators: [{
|
|
1285
|
+
type: Inject,
|
|
1286
|
+
args: ['OrderRepository']
|
|
1287
|
+
}] }, { type: undefined, decorators: [{
|
|
1288
|
+
type: Inject,
|
|
1289
|
+
args: ['CategoryRepository']
|
|
1285
1290
|
}] }]; } });
|
|
1286
1291
|
|
|
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]
|
|
1292
|
+
class CheckoutService {
|
|
1293
|
+
constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
|
|
1294
|
+
this.couponService = couponService;
|
|
1295
|
+
this.checkoutRepository = checkoutRepository;
|
|
1296
|
+
this.userRepository = userRepository;
|
|
1297
|
+
this.defaultShop = defaultShop;
|
|
1298
|
+
this.dataPersistence = dataPersistence;
|
|
1299
|
+
}
|
|
1300
|
+
getCheckout(checkoutData) {
|
|
1301
|
+
return this.dataPersistence
|
|
1302
|
+
.get('checkoutId')
|
|
1303
|
+
.pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
|
|
1304
|
+
}
|
|
1305
|
+
getUserByCheckout(checkoutId) {
|
|
1306
|
+
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'))));
|
|
1307
|
+
}
|
|
1308
|
+
updateCheckoutLineItems(checkout) {
|
|
1309
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
1310
|
+
}
|
|
1311
|
+
updateCheckoutUser(checkout) {
|
|
1312
|
+
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1313
|
+
}
|
|
1314
|
+
clearCheckoutFromSession() {
|
|
1315
|
+
return this.dataPersistence.remove('checkoutId');
|
|
1316
|
+
}
|
|
1317
|
+
calcDiscount(coupon) {
|
|
1318
|
+
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
1319
|
+
}
|
|
1320
|
+
checkCoupon(nickname, checkoutType) {
|
|
1321
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
|
|
1322
|
+
}
|
|
1323
|
+
async createCheckout(checkoutData) {
|
|
1324
|
+
const checkout = await this.checkoutRepository.create({
|
|
1325
|
+
createdAt: new Date(),
|
|
1326
|
+
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1327
|
+
shop: checkoutData?.shop || this.defaultShop,
|
|
1328
|
+
});
|
|
1329
|
+
await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1330
|
+
return checkout;
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1333
|
+
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 });
|
|
1334
|
+
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
|
|
1335
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
|
|
1336
|
+
type: Injectable
|
|
1337
|
+
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1338
|
+
type: Inject,
|
|
1339
|
+
args: ['CheckoutRepository']
|
|
1340
|
+
}] }, { type: undefined, decorators: [{
|
|
1341
|
+
type: Inject,
|
|
1342
|
+
args: ['UserRepository']
|
|
1343
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1344
|
+
type: Inject,
|
|
1345
|
+
args: [DEFAULT_SHOP]
|
|
1346
|
+
}] }, { type: undefined, decorators: [{
|
|
1347
|
+
type: Inject,
|
|
1348
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1344
1349
|
}] }]; } });
|
|
1345
1350
|
|
|
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
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
.
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
const
|
|
1383
|
-
const
|
|
1384
|
-
const
|
|
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
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
if (campaign.
|
|
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
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
i0.ɵɵ
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1351
|
+
class CartService {
|
|
1352
|
+
constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
|
|
1353
|
+
this.authService = authService;
|
|
1354
|
+
this.checkoutService = checkoutService;
|
|
1355
|
+
this.defaultShop = defaultShop;
|
|
1356
|
+
this.productRepository = productRepository;
|
|
1357
|
+
this.categoryRepository = categoryRepository;
|
|
1358
|
+
this.variantRepository = variantRepository;
|
|
1359
|
+
this.buy2WinRepository = buy2WinRepository;
|
|
1360
|
+
this.cartSubject = new Subject();
|
|
1361
|
+
this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
|
|
1362
|
+
const items = [];
|
|
1363
|
+
const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
|
|
1364
|
+
if (index > -1) {
|
|
1365
|
+
checkoutLoaded.lineItems[index].quantity += quantity;
|
|
1366
|
+
checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
|
|
1367
|
+
checkoutLoaded.lineItems[index].price = lineItem.price;
|
|
1368
|
+
}
|
|
1369
|
+
else
|
|
1370
|
+
checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
|
|
1371
|
+
return this.checkoutService
|
|
1372
|
+
.updateCheckoutLineItems(checkoutLoaded)
|
|
1373
|
+
.pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
|
|
1374
|
+
}));
|
|
1375
|
+
this.generateCartObject = (items) => items?.reduce((cart, item) => ({
|
|
1376
|
+
...cart,
|
|
1377
|
+
[item.id]: LineItem.toInstance({
|
|
1378
|
+
...(cart[item.id] || item),
|
|
1379
|
+
quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
|
|
1380
|
+
}),
|
|
1381
|
+
}), {}) || {};
|
|
1382
|
+
this.buildLineItem = async ({ checkout, item, quantity, }) => {
|
|
1383
|
+
const product = await this.getProductData(item.id);
|
|
1384
|
+
item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
|
|
1385
|
+
if (this.checkMaxStock(product.stock.quantity, item.quantity || 0, quantity || 0))
|
|
1386
|
+
throw new Error('Desculpe! Temos apenas ' + product.stock?.quantity + ' em estoque.');
|
|
1387
|
+
const image = item.image || item.images?.shift();
|
|
1388
|
+
const { id, name, EAN, slug, weight, sku, type } = item;
|
|
1389
|
+
const isGift = item.isGift || null;
|
|
1390
|
+
const pricePaid = this.getProductPrice({
|
|
1391
|
+
product: LineItem.toInstance(product),
|
|
1392
|
+
shop: checkout.shop || this.defaultShop,
|
|
1393
|
+
isSubscriber: checkout.user?.isSubscriber,
|
|
1394
|
+
});
|
|
1395
|
+
RoundProductPricesHelper.roundProductPrices(item);
|
|
1396
|
+
RoundProductPricesHelper.roundProductPrices(product);
|
|
1397
|
+
return {
|
|
1398
|
+
checkout,
|
|
1399
|
+
lineItem: LineItem.toInstance({
|
|
1400
|
+
id,
|
|
1401
|
+
name: name ?? product.name,
|
|
1402
|
+
EAN: EAN ?? product.EAN,
|
|
1403
|
+
brand: product.brand,
|
|
1404
|
+
slug: slug ?? product.slug,
|
|
1405
|
+
sku: sku ?? product.sku,
|
|
1406
|
+
stock: product.stock,
|
|
1407
|
+
price: this.roundPrice(product.price),
|
|
1408
|
+
image,
|
|
1409
|
+
weight: weight ?? product.weight,
|
|
1410
|
+
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1411
|
+
pricePaid,
|
|
1412
|
+
discount: 0,
|
|
1413
|
+
categories: product.categories ?? [],
|
|
1414
|
+
isGift: isGift ?? null,
|
|
1415
|
+
costPrice: product.costPrice ?? 0,
|
|
1416
|
+
type,
|
|
1417
|
+
}),
|
|
1418
|
+
};
|
|
1419
|
+
};
|
|
1420
|
+
this.getProductPrice = ({ product, isSubscriber, }) => {
|
|
1421
|
+
const info = product.price;
|
|
1422
|
+
if (product.isGift)
|
|
1423
|
+
return 0;
|
|
1424
|
+
return isSubscriber && info.subscriberPrice > 0
|
|
1425
|
+
? Number(info.subscriberPrice.toFixed(2))
|
|
1426
|
+
: Number(info.price.toFixed(2));
|
|
1427
|
+
};
|
|
1428
|
+
this.checkMaxStock = (currentStock, currentItemQtd, quantityToAdd) => {
|
|
1429
|
+
const maxStock = currentStock || 0;
|
|
1430
|
+
const currentItemAmount = currentItemQtd || 0;
|
|
1431
|
+
return currentItemAmount + quantityToAdd > maxStock;
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
addItem(item, quantity = 1) {
|
|
1435
|
+
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)));
|
|
1436
|
+
}
|
|
1437
|
+
decreaseItem(item) {
|
|
1438
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1439
|
+
const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id);
|
|
1440
|
+
if (!isNil(checkoutItem))
|
|
1441
|
+
checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
|
|
1442
|
+
return checkout;
|
|
1443
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1444
|
+
}
|
|
1445
|
+
getCart(checkout) {
|
|
1446
|
+
this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
|
|
1447
|
+
return this.cartSubject;
|
|
1448
|
+
}
|
|
1449
|
+
/**
|
|
1450
|
+
* @deprecated The method should not be used
|
|
1451
|
+
*/
|
|
1452
|
+
getVariantPriceDiscount(item) {
|
|
1453
|
+
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)));
|
|
1454
|
+
}
|
|
1455
|
+
removeItem(item) {
|
|
1456
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1457
|
+
const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
|
|
1458
|
+
if (index >= 0)
|
|
1459
|
+
checkout.lineItems.splice(index, 1);
|
|
1460
|
+
return checkout;
|
|
1461
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1462
|
+
}
|
|
1463
|
+
updateUserCart(user) {
|
|
1464
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => await this.checkoutService
|
|
1465
|
+
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1466
|
+
...checkout.toPlain(),
|
|
1467
|
+
lineItems: checkout.lineItems?.length
|
|
1468
|
+
? await Promise.all(checkout.lineItems?.map(async (item) => (await this.buildLineItem({ checkout, item })).lineItem))
|
|
1469
|
+
: [],
|
|
1470
|
+
}))
|
|
1471
|
+
.toPromise()), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1472
|
+
}
|
|
1473
|
+
clearCart() {
|
|
1474
|
+
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1475
|
+
this.checkoutService.clearCheckoutFromSession();
|
|
1476
|
+
return checkout;
|
|
1477
|
+
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
1478
|
+
}
|
|
1479
|
+
buildCartFromCheckout(checkoutData) {
|
|
1480
|
+
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1481
|
+
}
|
|
1482
|
+
roundPrice(productPrice) {
|
|
1483
|
+
const { price, fullPrice, subscriberPrice } = productPrice;
|
|
1484
|
+
return {
|
|
1485
|
+
...productPrice,
|
|
1486
|
+
price: Number(price.toFixed(2)),
|
|
1487
|
+
fullPrice: Number(fullPrice.toFixed(2)),
|
|
1488
|
+
...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
async getProductData(productId) {
|
|
1492
|
+
let product;
|
|
1493
|
+
let variant;
|
|
1494
|
+
try {
|
|
1495
|
+
product = await this.productRepository.get({ id: productId });
|
|
1496
|
+
}
|
|
1497
|
+
catch (error) {
|
|
1498
|
+
if (!(error instanceof NotFoundError))
|
|
1499
|
+
throw error;
|
|
1500
|
+
const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
|
|
1501
|
+
variant = variants.shift();
|
|
1502
|
+
if (!variant)
|
|
1503
|
+
throw error;
|
|
1504
|
+
product = await this.productRepository.get({ id: variant.productId });
|
|
1505
|
+
}
|
|
1506
|
+
return {
|
|
1507
|
+
...product.toPlain(),
|
|
1508
|
+
...(variant && { ...variant.toPlain() }),
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1511
|
+
getGifts() {
|
|
1512
|
+
return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
|
|
1513
|
+
const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
|
|
1514
|
+
if (!notGiftItems.length)
|
|
1515
|
+
return { ...checkout, lineItems: [] };
|
|
1516
|
+
const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1517
|
+
const campaigns = await this.buy2WinRepository
|
|
1518
|
+
.find({
|
|
1519
|
+
filters: {
|
|
1520
|
+
active: { operator: Where.EQUALS, value: true },
|
|
1521
|
+
shop: { operator: Where.EQUALS, value: this.defaultShop },
|
|
1522
|
+
},
|
|
1523
|
+
})
|
|
1524
|
+
.then((data) => data.data);
|
|
1525
|
+
if (!campaigns.length)
|
|
1526
|
+
return { ...checkout, lineItems: notGiftItems };
|
|
1527
|
+
const elegibleCampaigns = [];
|
|
1528
|
+
for (const campaign of campaigns) {
|
|
1529
|
+
const today = new Date().getTime();
|
|
1530
|
+
if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
|
|
1531
|
+
continue;
|
|
1532
|
+
if (campaign.activeCategory) {
|
|
1533
|
+
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
1534
|
+
const categoriesCampaingFullTree = [];
|
|
1535
|
+
for (const id of categoriesCampaing) {
|
|
1536
|
+
const children = await this.categoryRepository.getChildren(parseInt(id));
|
|
1537
|
+
categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
|
|
1538
|
+
}
|
|
1539
|
+
const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
|
|
1540
|
+
const filterProductsCategories = checkout.lineItems.filter((l) => {
|
|
1541
|
+
if (!l.categories || !l.categories?.length)
|
|
1542
|
+
return true;
|
|
1543
|
+
return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
|
|
1544
|
+
});
|
|
1545
|
+
if (filterProductsCategories.length) {
|
|
1546
|
+
const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
|
|
1547
|
+
if (cartTotalCategories >= campaign.cartValueMin)
|
|
1548
|
+
elegibleCampaigns.push(campaign);
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
else {
|
|
1552
|
+
if (campaign.cartValue && campaign.cartValue > 0) {
|
|
1553
|
+
if (campaign.cartValue <= cartTotal)
|
|
1554
|
+
elegibleCampaigns.push(campaign);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
if (!elegibleCampaigns.length)
|
|
1559
|
+
return { ...checkout, lineItems: notGiftItems };
|
|
1560
|
+
const campaingnProducts = [];
|
|
1561
|
+
for (const campaign of elegibleCampaigns) {
|
|
1562
|
+
let elegibleProducts = [];
|
|
1563
|
+
for (const product of campaign.products) {
|
|
1564
|
+
const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
|
|
1565
|
+
if (!productData.length)
|
|
1566
|
+
continue;
|
|
1567
|
+
const gift = productData.shift();
|
|
1568
|
+
if (gift.stock.quantity < 1)
|
|
1569
|
+
continue;
|
|
1570
|
+
elegibleProducts.push(gift);
|
|
1571
|
+
}
|
|
1572
|
+
campaingnProducts.push(elegibleProducts);
|
|
1573
|
+
}
|
|
1574
|
+
if (!campaingnProducts.length)
|
|
1575
|
+
return { ...checkout, lineItems: notGiftItems };
|
|
1576
|
+
const gifts = this.giftToLineItems([].concat(...campaingnProducts));
|
|
1577
|
+
return { ...checkout, lineItems: notGiftItems.concat(gifts) };
|
|
1578
|
+
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1579
|
+
}
|
|
1580
|
+
giftToLineItems(items) {
|
|
1581
|
+
return items.map((item) => {
|
|
1582
|
+
const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
|
|
1583
|
+
const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
|
|
1584
|
+
return LineItem.toInstance({
|
|
1585
|
+
brand,
|
|
1586
|
+
categories,
|
|
1587
|
+
id: id.toString(),
|
|
1588
|
+
name,
|
|
1589
|
+
price,
|
|
1590
|
+
sku,
|
|
1591
|
+
slug,
|
|
1592
|
+
stock,
|
|
1593
|
+
weight,
|
|
1594
|
+
EAN,
|
|
1595
|
+
image,
|
|
1596
|
+
pricePaid: 0,
|
|
1597
|
+
quantity: 1,
|
|
1598
|
+
isGift: true,
|
|
1599
|
+
});
|
|
1600
|
+
});
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
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 });
|
|
1604
|
+
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
1605
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
|
|
1606
|
+
type: Injectable
|
|
1607
|
+
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
|
|
1608
|
+
type: Inject,
|
|
1609
|
+
args: [DEFAULT_SHOP]
|
|
1610
|
+
}] }, { type: undefined, decorators: [{
|
|
1611
|
+
type: Inject,
|
|
1612
|
+
args: ['ProductRepository']
|
|
1613
|
+
}] }, { type: undefined, decorators: [{
|
|
1614
|
+
type: Inject,
|
|
1615
|
+
args: ['CategoryRepository']
|
|
1616
|
+
}] }, { type: undefined, decorators: [{
|
|
1617
|
+
type: Inject,
|
|
1618
|
+
args: ['VariantRepository']
|
|
1619
|
+
}] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
|
|
1620
|
+
type: Inject,
|
|
1621
|
+
args: ['Buy2WinRepository']
|
|
1615
1622
|
}] }]; } });
|
|
1616
1623
|
|
|
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']
|
|
1624
|
+
class NewCategoryStructureAdapter {
|
|
1625
|
+
constructor(categoryRepository) {
|
|
1626
|
+
this.categoryRepository = categoryRepository;
|
|
1627
|
+
}
|
|
1628
|
+
async buildProductFilterByCategory(category) {
|
|
1629
|
+
const loadedCategory = await this.getCategory(category);
|
|
1630
|
+
if (loadedCategory.isCollection)
|
|
1631
|
+
return { id: { operator: Where.IN, value: loadedCategory.products } };
|
|
1632
|
+
const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
|
|
1633
|
+
return {
|
|
1634
|
+
category: {
|
|
1635
|
+
id: {
|
|
1636
|
+
operator: Where.IN,
|
|
1637
|
+
value: categoryIds,
|
|
1638
|
+
},
|
|
1639
|
+
},
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
async getAllCategoriesIdFromCategory(category) {
|
|
1643
|
+
return this.categoryRepository
|
|
1644
|
+
.getChildren(+category.id)
|
|
1645
|
+
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1646
|
+
}
|
|
1647
|
+
async getCategory(category) {
|
|
1648
|
+
const collectionCategory = category.isCollection ||
|
|
1649
|
+
(isNil(category.isCollection) && !category.products?.length) ||
|
|
1650
|
+
category.isWishlist ||
|
|
1651
|
+
category.brandCategory;
|
|
1652
|
+
return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1656
|
+
NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
|
|
1657
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
|
|
1658
|
+
type: Injectable
|
|
1659
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1660
|
+
type: Inject,
|
|
1661
|
+
args: ['CategoryRepository']
|
|
1655
1662
|
}] }]; } });
|
|
1656
1663
|
|
|
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']
|
|
1664
|
+
class OldCategoryStructureAdapter {
|
|
1665
|
+
constructor(categoryRepository) {
|
|
1666
|
+
this.categoryRepository = categoryRepository;
|
|
1667
|
+
}
|
|
1668
|
+
async buildProductFilterByCategory(category) {
|
|
1669
|
+
const productsIds = category.products?.length
|
|
1670
|
+
? category.products
|
|
1671
|
+
: await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
|
|
1672
|
+
return { id: { operator: Where.IN, value: productsIds } };
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1676
|
+
OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
|
|
1677
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
|
|
1678
|
+
type: Injectable
|
|
1679
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1680
|
+
type: Inject,
|
|
1681
|
+
args: ['CategoryRepository']
|
|
1675
1682
|
}] }]; } });
|
|
1676
1683
|
|
|
1677
|
-
class CatalogService {
|
|
1678
|
-
constructor(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch) {
|
|
1679
|
-
this.productRepository = productRepository;
|
|
1680
|
-
this.productStockNotificationRepository = productStockNotificationRepository;
|
|
1681
|
-
this.categoryRepository = categoryRepository;
|
|
1682
|
-
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1683
|
-
this.shop = shop;
|
|
1684
|
-
this.productSearch = productSearch;
|
|
1685
|
-
this.productsByTerm = {};
|
|
1686
|
-
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1687
|
-
const filters = {};
|
|
1688
|
-
if (clubDiscount?.length)
|
|
1689
|
-
set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
|
|
1690
|
-
if (brands?.length)
|
|
1691
|
-
filters.brand = { operator: Where.IN, value: brands };
|
|
1692
|
-
if (gender?.length)
|
|
1693
|
-
filters.gender = { operator: Where.IN, value: gender };
|
|
1694
|
-
if (prices?.min || prices?.max)
|
|
1695
|
-
set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
|
|
1696
|
-
...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
|
|
1697
|
-
...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
|
|
1698
|
-
]);
|
|
1699
|
-
if (rate)
|
|
1700
|
-
filters.rate = { operator: Where.GTE, value: rate };
|
|
1701
|
-
if (tags?.length)
|
|
1702
|
-
filters.tags = { operator: Where.LIKE, value: tags };
|
|
1703
|
-
if (customOptions?.length)
|
|
1704
|
-
filters.filters = { operator: Where.LIKE, value: customOptions };
|
|
1705
|
-
return filters;
|
|
1706
|
-
};
|
|
1707
|
-
this.buildSortQuery = (sort) => {
|
|
1708
|
-
if (!sort || sort === 'most-relevant')
|
|
1709
|
-
return {};
|
|
1710
|
-
if (sort === 'best-sellers')
|
|
1711
|
-
return {
|
|
1712
|
-
shoppingCount: 'desc',
|
|
1713
|
-
rate: 'desc',
|
|
1714
|
-
stock: 'desc',
|
|
1715
|
-
name: 'asc',
|
|
1716
|
-
};
|
|
1717
|
-
if (sort === 'biggest-price')
|
|
1718
|
-
return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1719
|
-
if (sort === 'lowest-price')
|
|
1720
|
-
return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
|
|
1721
|
-
if (sort === 'best-rating')
|
|
1722
|
-
return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
|
|
1723
|
-
if (sort === 'news')
|
|
1724
|
-
return { createdAt: 'desc' };
|
|
1725
|
-
if (sort === 'biggest-discount')
|
|
1726
|
-
return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1727
|
-
};
|
|
1728
|
-
this.buildLimitQuery = (options) => {
|
|
1729
|
-
const limit = options?.perPage || 20;
|
|
1730
|
-
return {
|
|
1731
|
-
limit,
|
|
1732
|
-
offset: ((options?.page || 1) - 1) * limit,
|
|
1733
|
-
};
|
|
1734
|
-
};
|
|
1735
|
-
this.hasProfile = (options) => 'profile' in options;
|
|
1736
|
-
this.hasTerm = (options) => 'term' in options;
|
|
1737
|
-
this.hasCategory = (options) => 'category' in options;
|
|
1738
|
-
}
|
|
1739
|
-
async fetchProducts(options) {
|
|
1740
|
-
const limits = this.buildLimitQuery(options);
|
|
1741
|
-
if (this.hasProfile(options) && options.filters?.customOptions)
|
|
1742
|
-
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
1743
|
-
if (this.hasProfile(options) && options.filters?.tags)
|
|
1744
|
-
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1745
|
-
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1746
|
-
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
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
|
-
if (
|
|
1802
|
-
return
|
|
1803
|
-
if (
|
|
1804
|
-
return
|
|
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
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
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
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
.
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
distinct: totalResult.distinct,
|
|
1912
|
-
};
|
|
1913
|
-
}
|
|
1914
|
-
async findCatalogIdsBySearch(term, preview = false) {
|
|
1915
|
-
console.log('this.productsByTerm[term]', this.productsByTerm[term]?.length);
|
|
1916
|
-
if (this.productsByTerm[term])
|
|
1917
|
-
return this.productsByTerm[term];
|
|
1918
|
-
return (this.productsByTerm[term] = await this.productSearch
|
|
1919
|
-
.search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
|
|
1920
|
-
.then((products) => [...new Set(products.map((product) => product.id))]));
|
|
1921
|
-
}
|
|
1922
|
-
}
|
|
1923
|
-
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: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1924
|
-
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|
|
1925
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
|
|
1926
|
-
type: Injectable
|
|
1927
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1928
|
-
type: Inject,
|
|
1929
|
-
args: ['ProductRepository']
|
|
1930
|
-
}] }, { type: undefined, decorators: [{
|
|
1931
|
-
type: Inject,
|
|
1932
|
-
args: ['ProductStockNotificationRepository']
|
|
1933
|
-
}] }, { type: undefined, decorators: [{
|
|
1934
|
-
type: Inject,
|
|
1935
|
-
args: ['CategoryRepository']
|
|
1936
|
-
}] }, { type: undefined, decorators: [{
|
|
1937
|
-
type: Inject,
|
|
1938
|
-
args: [CATEGORY_STRUCTURE]
|
|
1939
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
1940
|
-
type: Inject,
|
|
1941
|
-
args: [DEFAULT_SHOP]
|
|
1942
|
-
}] }, { type: undefined, decorators: [{
|
|
1943
|
-
type: Inject,
|
|
1944
|
-
args: ['ProductSearch']
|
|
1684
|
+
class CatalogService {
|
|
1685
|
+
constructor(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch) {
|
|
1686
|
+
this.productRepository = productRepository;
|
|
1687
|
+
this.productStockNotificationRepository = productStockNotificationRepository;
|
|
1688
|
+
this.categoryRepository = categoryRepository;
|
|
1689
|
+
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1690
|
+
this.shop = shop;
|
|
1691
|
+
this.productSearch = productSearch;
|
|
1692
|
+
this.productsByTerm = {};
|
|
1693
|
+
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1694
|
+
const filters = {};
|
|
1695
|
+
if (clubDiscount?.length)
|
|
1696
|
+
set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
|
|
1697
|
+
if (brands?.length)
|
|
1698
|
+
filters.brand = { operator: Where.IN, value: brands };
|
|
1699
|
+
if (gender?.length)
|
|
1700
|
+
filters.gender = { operator: Where.IN, value: gender };
|
|
1701
|
+
if (prices?.min || prices?.max)
|
|
1702
|
+
set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
|
|
1703
|
+
...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
|
|
1704
|
+
...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
|
|
1705
|
+
]);
|
|
1706
|
+
if (rate)
|
|
1707
|
+
filters.rate = { operator: Where.GTE, value: rate };
|
|
1708
|
+
if (tags?.length)
|
|
1709
|
+
filters.tags = { operator: Where.LIKE, value: tags };
|
|
1710
|
+
if (customOptions?.length)
|
|
1711
|
+
filters.filters = { operator: Where.LIKE, value: customOptions };
|
|
1712
|
+
return filters;
|
|
1713
|
+
};
|
|
1714
|
+
this.buildSortQuery = (sort) => {
|
|
1715
|
+
if (!sort || sort === 'most-relevant')
|
|
1716
|
+
return {};
|
|
1717
|
+
if (sort === 'best-sellers')
|
|
1718
|
+
return {
|
|
1719
|
+
shoppingCount: 'desc',
|
|
1720
|
+
rate: 'desc',
|
|
1721
|
+
stock: 'desc',
|
|
1722
|
+
name: 'asc',
|
|
1723
|
+
};
|
|
1724
|
+
if (sort === 'biggest-price')
|
|
1725
|
+
return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1726
|
+
if (sort === 'lowest-price')
|
|
1727
|
+
return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
|
|
1728
|
+
if (sort === 'best-rating')
|
|
1729
|
+
return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
|
|
1730
|
+
if (sort === 'news')
|
|
1731
|
+
return { createdAt: 'desc' };
|
|
1732
|
+
if (sort === 'biggest-discount')
|
|
1733
|
+
return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1734
|
+
};
|
|
1735
|
+
this.buildLimitQuery = (options) => {
|
|
1736
|
+
const limit = options?.perPage || 20;
|
|
1737
|
+
return {
|
|
1738
|
+
limit,
|
|
1739
|
+
offset: ((options?.page || 1) - 1) * limit,
|
|
1740
|
+
};
|
|
1741
|
+
};
|
|
1742
|
+
this.hasProfile = (options) => 'profile' in options;
|
|
1743
|
+
this.hasTerm = (options) => 'term' in options;
|
|
1744
|
+
this.hasCategory = (options) => 'category' in options;
|
|
1745
|
+
}
|
|
1746
|
+
async fetchProducts(options) {
|
|
1747
|
+
const limits = this.buildLimitQuery(options);
|
|
1748
|
+
if (this.hasProfile(options) && options.filters?.customOptions)
|
|
1749
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
1750
|
+
if (this.hasProfile(options) && options.filters?.tags)
|
|
1751
|
+
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1752
|
+
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1753
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1754
|
+
return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
|
|
1755
|
+
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1756
|
+
pages: Math.ceil(total / limits.limit),
|
|
1757
|
+
prices: {
|
|
1758
|
+
price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
|
|
1759
|
+
subscriberPrice: {
|
|
1760
|
+
min: +minimal?.price?.subscriberPrice?.toFixed(2),
|
|
1761
|
+
max: +maximum?.price?.subscriberPrice?.toFixed(2),
|
|
1762
|
+
},
|
|
1763
|
+
},
|
|
1764
|
+
brands: distinct?.brand,
|
|
1765
|
+
}));
|
|
1766
|
+
}
|
|
1767
|
+
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1768
|
+
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1769
|
+
}
|
|
1770
|
+
async findCatalog(options, limits) {
|
|
1771
|
+
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1772
|
+
const productsIds = await this.findCatalogIdsBySearch(options.term);
|
|
1773
|
+
return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
|
|
1774
|
+
}
|
|
1775
|
+
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1776
|
+
const mostRelevant = options.category.isWishlist ? [] : options.category.getMostRelevantByShop(this.shop);
|
|
1777
|
+
const productsIds = await this.productRepository
|
|
1778
|
+
.findCatalog({
|
|
1779
|
+
fields: ['id'],
|
|
1780
|
+
filters: {
|
|
1781
|
+
...(await this.buildMainFilter(options)),
|
|
1782
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1783
|
+
},
|
|
1784
|
+
})
|
|
1785
|
+
.then((products) => products.data.map((product) => product.id));
|
|
1786
|
+
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1787
|
+
}
|
|
1788
|
+
const repoParams = {
|
|
1789
|
+
filters: {
|
|
1790
|
+
...(await this.buildMainFilter(options)),
|
|
1791
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1792
|
+
},
|
|
1793
|
+
...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
|
|
1794
|
+
limits,
|
|
1795
|
+
options: {
|
|
1796
|
+
minimal: ['price'],
|
|
1797
|
+
maximum: ['price'],
|
|
1798
|
+
...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
|
|
1799
|
+
},
|
|
1800
|
+
};
|
|
1801
|
+
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1802
|
+
return this.productRepository.findCatalog(repoParams);
|
|
1803
|
+
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1804
|
+
}
|
|
1805
|
+
async buildMainFilter({ category, profile, term, }) {
|
|
1806
|
+
if (category)
|
|
1807
|
+
return this.categoryStructureAdapter.buildProductFilterByCategory(category);
|
|
1808
|
+
if (profile)
|
|
1809
|
+
return { tags: { operator: Where.LIKE, value: profile } };
|
|
1810
|
+
if (term)
|
|
1811
|
+
return this.productSearch
|
|
1812
|
+
.search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
|
|
1813
|
+
.then((data) => ({ id: { operator: Where.IN, value: data.map((_source) => _source.id) } }));
|
|
1814
|
+
}
|
|
1815
|
+
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1816
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1817
|
+
const totalResult = await this.productRepository.findCatalog({
|
|
1818
|
+
filters: {
|
|
1819
|
+
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1820
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1821
|
+
},
|
|
1822
|
+
orderBy: this.buildSortQuery('best-sellers'),
|
|
1823
|
+
options: {
|
|
1824
|
+
minimal: ['price'],
|
|
1825
|
+
maximum: ['price'],
|
|
1826
|
+
distinct: ['brand'],
|
|
1827
|
+
},
|
|
1828
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1829
|
+
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1830
|
+
const firstProducts = totalResult.data
|
|
1831
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
1832
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
1833
|
+
const lastProducts = totalResult.data
|
|
1834
|
+
.filter((product) => !mostRelevants.includes(product.id))
|
|
1835
|
+
.concat(mostRelevantWithouyStock);
|
|
1836
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1837
|
+
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1838
|
+
return {
|
|
1839
|
+
data: resultFinal,
|
|
1840
|
+
count: totalResult.count,
|
|
1841
|
+
maximum: totalResult.maximum,
|
|
1842
|
+
minimal: totalResult.minimal,
|
|
1843
|
+
distinct: totalResult.distinct,
|
|
1844
|
+
};
|
|
1845
|
+
}
|
|
1846
|
+
async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
|
|
1847
|
+
const totalResult = await this.productRepository.findCatalog({
|
|
1848
|
+
fields: ['id', 'stock', 'gender'],
|
|
1849
|
+
filters: {
|
|
1850
|
+
id: { operator: Where.IN, value: productIds },
|
|
1851
|
+
published: { operator: Where.EQUALS, value: true },
|
|
1852
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1853
|
+
},
|
|
1854
|
+
options: {
|
|
1855
|
+
minimal: ['price'],
|
|
1856
|
+
maximum: ['price'],
|
|
1857
|
+
distinct: ['brand'],
|
|
1858
|
+
},
|
|
1859
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1860
|
+
const defaultGender = options?.filters?.gender
|
|
1861
|
+
? options?.filters?.gender.at(0)
|
|
1862
|
+
: this.shop === Shops.GLAMSHOP
|
|
1863
|
+
? 'female'
|
|
1864
|
+
: 'male';
|
|
1865
|
+
const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
|
|
1866
|
+
const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
|
|
1867
|
+
const productIdsStockGender = productIds.filter((product) => stockData.some((result) => result.id === product && (result.gender?.includes(defaultGender) || result.gender?.includes('unisex'))));
|
|
1868
|
+
const productIdsStockNotGender = productIds.filter((product) => stockData.some((result) => result.id === product && !result.gender?.includes(defaultGender) && !result.gender?.includes('unisex')));
|
|
1869
|
+
const productIdsStock = productIdsStockGender.concat(productIdsStockNotGender);
|
|
1870
|
+
const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id === product));
|
|
1871
|
+
const limitedProductId = productIdsStock
|
|
1872
|
+
.concat(productIdsStockOut)
|
|
1873
|
+
.slice(limits.offset, limits.offset + limits.limit);
|
|
1874
|
+
const orderedId = productIds.filter((product) => limitedProductId.includes(product));
|
|
1875
|
+
const productResult = await this.productRepository.findCatalog({
|
|
1876
|
+
filters: {
|
|
1877
|
+
id: { operator: Where.IN, value: orderedId },
|
|
1878
|
+
},
|
|
1879
|
+
});
|
|
1880
|
+
return {
|
|
1881
|
+
data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1882
|
+
count: totalResult.count,
|
|
1883
|
+
maximum: totalResult.maximum,
|
|
1884
|
+
minimal: totalResult.minimal,
|
|
1885
|
+
distinct: totalResult.distinct,
|
|
1886
|
+
};
|
|
1887
|
+
}
|
|
1888
|
+
async findCatalogIdsBySearch(term, preview = false) {
|
|
1889
|
+
if (this.productsByTerm[term])
|
|
1890
|
+
return this.productsByTerm[term];
|
|
1891
|
+
return (this.productsByTerm[term] = await this.productSearch
|
|
1892
|
+
.search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
|
|
1893
|
+
.then((products) => [...new Set(products.map((product) => product.id))]));
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
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: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1897
|
+
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|
|
1898
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
|
|
1899
|
+
type: Injectable
|
|
1900
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1901
|
+
type: Inject,
|
|
1902
|
+
args: ['ProductRepository']
|
|
1903
|
+
}] }, { type: undefined, decorators: [{
|
|
1904
|
+
type: Inject,
|
|
1905
|
+
args: ['ProductStockNotificationRepository']
|
|
1906
|
+
}] }, { type: undefined, decorators: [{
|
|
1907
|
+
type: Inject,
|
|
1908
|
+
args: ['CategoryRepository']
|
|
1909
|
+
}] }, { type: undefined, decorators: [{
|
|
1910
|
+
type: Inject,
|
|
1911
|
+
args: [CATEGORY_STRUCTURE]
|
|
1912
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1913
|
+
type: Inject,
|
|
1914
|
+
args: [DEFAULT_SHOP]
|
|
1915
|
+
}] }, { type: undefined, decorators: [{
|
|
1916
|
+
type: Inject,
|
|
1917
|
+
args: ['ProductSearch']
|
|
1945
1918
|
}] }]; } });
|
|
1946
1919
|
|
|
1947
|
-
class CategoryService {
|
|
1948
|
-
constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
1949
|
-
this.productRepository = productRepository;
|
|
1950
|
-
this.categoryRepository = categoryRepository;
|
|
1951
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
1952
|
-
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1953
|
-
this.shop = shop;
|
|
1954
|
-
}
|
|
1955
|
-
async fetchBrands(category, options) {
|
|
1956
|
-
const brands = await this.productRepository
|
|
1957
|
-
.findCatalog({
|
|
1958
|
-
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1959
|
-
fields: ['brand'],
|
|
1960
|
-
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1961
|
-
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1962
|
-
return this.categoryRepository
|
|
1963
|
-
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1964
|
-
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1965
|
-
}
|
|
1966
|
-
async fetchFilterOptions(category) {
|
|
1967
|
-
return await this.categoryFilterRepository
|
|
1968
|
-
.find({ filters: { categoryId: +category.id } })
|
|
1969
|
-
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
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 });
|
|
1973
|
-
CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
|
|
1974
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
|
|
1975
|
-
type: Injectable
|
|
1976
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1977
|
-
type: Inject,
|
|
1978
|
-
args: ['ProductRepository']
|
|
1979
|
-
}] }, { type: undefined, decorators: [{
|
|
1980
|
-
type: Inject,
|
|
1981
|
-
args: ['CategoryRepository']
|
|
1982
|
-
}] }, { type: undefined, decorators: [{
|
|
1983
|
-
type: Inject,
|
|
1984
|
-
args: ['CategoryFilterRepository']
|
|
1985
|
-
}] }, { type: undefined, decorators: [{
|
|
1986
|
-
type: Inject,
|
|
1987
|
-
args: [CATEGORY_STRUCTURE]
|
|
1988
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
1989
|
-
type: Inject,
|
|
1990
|
-
args: [DEFAULT_SHOP]
|
|
1920
|
+
class CategoryService {
|
|
1921
|
+
constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
1922
|
+
this.productRepository = productRepository;
|
|
1923
|
+
this.categoryRepository = categoryRepository;
|
|
1924
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
1925
|
+
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1926
|
+
this.shop = shop;
|
|
1927
|
+
}
|
|
1928
|
+
async fetchBrands(category, options) {
|
|
1929
|
+
const brands = await this.productRepository
|
|
1930
|
+
.findCatalog({
|
|
1931
|
+
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1932
|
+
fields: ['brand'],
|
|
1933
|
+
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1934
|
+
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1935
|
+
return this.categoryRepository
|
|
1936
|
+
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1937
|
+
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1938
|
+
}
|
|
1939
|
+
async fetchFilterOptions(category) {
|
|
1940
|
+
return await this.categoryFilterRepository
|
|
1941
|
+
.find({ filters: { categoryId: +category.id } })
|
|
1942
|
+
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
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 });
|
|
1946
|
+
CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
|
|
1947
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
|
|
1948
|
+
type: Injectable
|
|
1949
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1950
|
+
type: Inject,
|
|
1951
|
+
args: ['ProductRepository']
|
|
1952
|
+
}] }, { type: undefined, decorators: [{
|
|
1953
|
+
type: Inject,
|
|
1954
|
+
args: ['CategoryRepository']
|
|
1955
|
+
}] }, { type: undefined, decorators: [{
|
|
1956
|
+
type: Inject,
|
|
1957
|
+
args: ['CategoryFilterRepository']
|
|
1958
|
+
}] }, { type: undefined, decorators: [{
|
|
1959
|
+
type: Inject,
|
|
1960
|
+
args: [CATEGORY_STRUCTURE]
|
|
1961
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
1962
|
+
type: Inject,
|
|
1963
|
+
args: [DEFAULT_SHOP]
|
|
1991
1964
|
}] }]; } });
|
|
1992
1965
|
|
|
1993
|
-
var ProductSorts;
|
|
1994
|
-
(function (ProductSorts) {
|
|
1995
|
-
ProductSorts["MOST_RELEVANT"] = "most-relevant";
|
|
1996
|
-
ProductSorts["BEST_SELLER"] = "best-sellers";
|
|
1997
|
-
ProductSorts["BIGGEST_PRICE"] = "biggest-price";
|
|
1998
|
-
ProductSorts["LOWEST_PRICE"] = "lowest-price";
|
|
1999
|
-
ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
|
|
2000
|
-
ProductSorts["BEST_RATING"] = "best-rating";
|
|
2001
|
-
ProductSorts["NEWS"] = "news";
|
|
1966
|
+
var ProductSorts;
|
|
1967
|
+
(function (ProductSorts) {
|
|
1968
|
+
ProductSorts["MOST_RELEVANT"] = "most-relevant";
|
|
1969
|
+
ProductSorts["BEST_SELLER"] = "best-sellers";
|
|
1970
|
+
ProductSorts["BIGGEST_PRICE"] = "biggest-price";
|
|
1971
|
+
ProductSorts["LOWEST_PRICE"] = "lowest-price";
|
|
1972
|
+
ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
|
|
1973
|
+
ProductSorts["BEST_RATING"] = "best-rating";
|
|
1974
|
+
ProductSorts["NEWS"] = "news";
|
|
2002
1975
|
})(ProductSorts || (ProductSorts = {}));
|
|
2003
1976
|
|
|
2004
|
-
class CategoryWithTree extends Category {
|
|
2005
|
-
}
|
|
2006
|
-
__decorate([
|
|
2007
|
-
Type(() => CategoryWithTree),
|
|
2008
|
-
__metadata("design:type", Array)
|
|
1977
|
+
class CategoryWithTree extends Category {
|
|
1978
|
+
}
|
|
1979
|
+
__decorate([
|
|
1980
|
+
Type(() => CategoryWithTree),
|
|
1981
|
+
__metadata("design:type", Array)
|
|
2009
1982
|
], CategoryWithTree.prototype, "children", void 0);
|
|
2010
1983
|
|
|
2011
|
-
class WishlistService {
|
|
2012
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch) {
|
|
2013
|
-
this.wishlistRepository = wishlistRepository;
|
|
2014
|
-
this.shop = shop;
|
|
2015
|
-
this.productSearch = productSearch;
|
|
2016
|
-
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
2017
|
-
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch);
|
|
2018
|
-
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
2019
|
-
}
|
|
2020
|
-
getCatalogService() {
|
|
2021
|
-
return this.catalogService;
|
|
2022
|
-
}
|
|
2023
|
-
getCategoryService() {
|
|
2024
|
-
return this.categoryService;
|
|
2025
|
-
}
|
|
2026
|
-
async create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2027
|
-
const data = {
|
|
2028
|
-
slug: '',
|
|
2029
|
-
name: title,
|
|
2030
|
-
description,
|
|
2031
|
-
metadatas: [
|
|
2032
|
-
{
|
|
2033
|
-
shop: this.shop,
|
|
2034
|
-
title: `${userFullName} - ${title}`,
|
|
2035
|
-
description: `${userFullName} - ${description}`,
|
|
2036
|
-
},
|
|
2037
|
-
],
|
|
2038
|
-
shop: this.shop,
|
|
2039
|
-
shops: [this.shop],
|
|
2040
|
-
personId,
|
|
2041
|
-
personName: userFullName,
|
|
2042
|
-
personPhoto: userPhoto,
|
|
2043
|
-
brandCategory: false,
|
|
2044
|
-
published,
|
|
2045
|
-
theme,
|
|
2046
|
-
bannerUrl,
|
|
2047
|
-
personType: personType ?? PersonTypes.NONE,
|
|
2048
|
-
personIsSubscriber: personIsSubscriber ?? false,
|
|
2049
|
-
};
|
|
2050
|
-
const newWishlist = await this.wishlistRepository.create(data);
|
|
2051
|
-
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
2052
|
-
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
2053
|
-
}
|
|
2054
|
-
update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2055
|
-
const data = {
|
|
2056
|
-
id,
|
|
2057
|
-
name: title,
|
|
2058
|
-
description,
|
|
2059
|
-
published,
|
|
2060
|
-
metadatas: [
|
|
2061
|
-
{
|
|
2062
|
-
shop: this.shop,
|
|
2063
|
-
title: `${userFullName} - ${title}`,
|
|
2064
|
-
description: `${userFullName} - ${description}`,
|
|
2065
|
-
},
|
|
2066
|
-
],
|
|
2067
|
-
personName: userFullName,
|
|
2068
|
-
personPhoto: userPhoto,
|
|
2069
|
-
theme,
|
|
2070
|
-
bannerUrl,
|
|
2071
|
-
personType: personType ?? PersonTypes.NONE,
|
|
2072
|
-
personIsSubscriber: personIsSubscriber ?? false,
|
|
2073
|
-
};
|
|
2074
|
-
return this.wishlistRepository.update(data);
|
|
2075
|
-
}
|
|
2076
|
-
delete(wishlistId) {
|
|
2077
|
-
return this.wishlistRepository.delete({ id: wishlistId });
|
|
2078
|
-
}
|
|
2079
|
-
getWishlistBySlug(slug) {
|
|
2080
|
-
const [id] = slug.split('-');
|
|
2081
|
-
if (+id)
|
|
2082
|
-
return this.wishlistRepository.get({ id });
|
|
2083
|
-
return this.wishlistRepository.getWishlistBySlug(slug);
|
|
2084
|
-
}
|
|
2085
|
-
getWishlistsByPerson(personId) {
|
|
2086
|
-
return this.wishlistRepository.getWishlistByPerson(personId);
|
|
2087
|
-
}
|
|
2088
|
-
async addProduct(wishlistId, productId) {
|
|
2089
|
-
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
2090
|
-
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
2091
|
-
if (!hasProduct) {
|
|
2092
|
-
wishlist.products = [...wishlist.products, productId];
|
|
2093
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
2094
|
-
}
|
|
2095
|
-
return wishlist;
|
|
2096
|
-
}
|
|
2097
|
-
async removeProduct(wishlistId, productId) {
|
|
2098
|
-
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
2099
|
-
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
2100
|
-
if (productIndex != -1) {
|
|
2101
|
-
wishlist.products.splice(productIndex, 1);
|
|
2102
|
-
if (!wishlist.products.length)
|
|
2103
|
-
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
2104
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
2105
|
-
}
|
|
2106
|
-
return wishlist;
|
|
2107
|
-
}
|
|
2108
|
-
}
|
|
2109
|
-
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: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2110
|
-
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
|
|
2111
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
|
|
2112
|
-
type: Injectable
|
|
2113
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2114
|
-
type: Inject,
|
|
2115
|
-
args: ['WishlistRepository']
|
|
2116
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
2117
|
-
type: Inject,
|
|
2118
|
-
args: [DEFAULT_SHOP]
|
|
2119
|
-
}] }, { type: undefined, decorators: [{
|
|
2120
|
-
type: Inject,
|
|
2121
|
-
args: ['ProductRepository']
|
|
2122
|
-
}] }, { type: undefined, decorators: [{
|
|
2123
|
-
type: Inject,
|
|
2124
|
-
args: ['CategoryFilterRepository']
|
|
2125
|
-
}] }, { type: undefined, decorators: [{
|
|
2126
|
-
type: Inject,
|
|
2127
|
-
args: ['CategoryRepository']
|
|
2128
|
-
}] }, { type: undefined, decorators: [{
|
|
2129
|
-
type: Inject,
|
|
2130
|
-
args: ['ProductStockNotificationRepository']
|
|
2131
|
-
}] }, { type: undefined, decorators: [{
|
|
2132
|
-
type: Inject,
|
|
2133
|
-
args: ['ProductSearch']
|
|
1984
|
+
class WishlistService {
|
|
1985
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch) {
|
|
1986
|
+
this.wishlistRepository = wishlistRepository;
|
|
1987
|
+
this.shop = shop;
|
|
1988
|
+
this.productSearch = productSearch;
|
|
1989
|
+
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1990
|
+
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch);
|
|
1991
|
+
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1992
|
+
}
|
|
1993
|
+
getCatalogService() {
|
|
1994
|
+
return this.catalogService;
|
|
1995
|
+
}
|
|
1996
|
+
getCategoryService() {
|
|
1997
|
+
return this.categoryService;
|
|
1998
|
+
}
|
|
1999
|
+
async create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2000
|
+
const data = {
|
|
2001
|
+
slug: '',
|
|
2002
|
+
name: title,
|
|
2003
|
+
description,
|
|
2004
|
+
metadatas: [
|
|
2005
|
+
{
|
|
2006
|
+
shop: this.shop,
|
|
2007
|
+
title: `${userFullName} - ${title}`,
|
|
2008
|
+
description: `${userFullName} - ${description}`,
|
|
2009
|
+
},
|
|
2010
|
+
],
|
|
2011
|
+
shop: this.shop,
|
|
2012
|
+
shops: [this.shop],
|
|
2013
|
+
personId,
|
|
2014
|
+
personName: userFullName,
|
|
2015
|
+
personPhoto: userPhoto,
|
|
2016
|
+
brandCategory: false,
|
|
2017
|
+
published,
|
|
2018
|
+
theme,
|
|
2019
|
+
bannerUrl,
|
|
2020
|
+
personType: personType ?? PersonTypes.NONE,
|
|
2021
|
+
personIsSubscriber: personIsSubscriber ?? false,
|
|
2022
|
+
};
|
|
2023
|
+
const newWishlist = await this.wishlistRepository.create(data);
|
|
2024
|
+
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
2025
|
+
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
2026
|
+
}
|
|
2027
|
+
update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2028
|
+
const data = {
|
|
2029
|
+
id,
|
|
2030
|
+
name: title,
|
|
2031
|
+
description,
|
|
2032
|
+
published,
|
|
2033
|
+
metadatas: [
|
|
2034
|
+
{
|
|
2035
|
+
shop: this.shop,
|
|
2036
|
+
title: `${userFullName} - ${title}`,
|
|
2037
|
+
description: `${userFullName} - ${description}`,
|
|
2038
|
+
},
|
|
2039
|
+
],
|
|
2040
|
+
personName: userFullName,
|
|
2041
|
+
personPhoto: userPhoto,
|
|
2042
|
+
theme,
|
|
2043
|
+
bannerUrl,
|
|
2044
|
+
personType: personType ?? PersonTypes.NONE,
|
|
2045
|
+
personIsSubscriber: personIsSubscriber ?? false,
|
|
2046
|
+
};
|
|
2047
|
+
return this.wishlistRepository.update(data);
|
|
2048
|
+
}
|
|
2049
|
+
delete(wishlistId) {
|
|
2050
|
+
return this.wishlistRepository.delete({ id: wishlistId });
|
|
2051
|
+
}
|
|
2052
|
+
getWishlistBySlug(slug) {
|
|
2053
|
+
const [id] = slug.split('-');
|
|
2054
|
+
if (+id)
|
|
2055
|
+
return this.wishlistRepository.get({ id });
|
|
2056
|
+
return this.wishlistRepository.getWishlistBySlug(slug);
|
|
2057
|
+
}
|
|
2058
|
+
getWishlistsByPerson(personId) {
|
|
2059
|
+
return this.wishlistRepository.getWishlistByPerson(personId);
|
|
2060
|
+
}
|
|
2061
|
+
async addProduct(wishlistId, productId) {
|
|
2062
|
+
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
2063
|
+
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
2064
|
+
if (!hasProduct) {
|
|
2065
|
+
wishlist.products = [...wishlist.products, productId];
|
|
2066
|
+
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
2067
|
+
}
|
|
2068
|
+
return wishlist;
|
|
2069
|
+
}
|
|
2070
|
+
async removeProduct(wishlistId, productId) {
|
|
2071
|
+
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
2072
|
+
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
2073
|
+
if (productIndex != -1) {
|
|
2074
|
+
wishlist.products.splice(productIndex, 1);
|
|
2075
|
+
if (!wishlist.products.length)
|
|
2076
|
+
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
2077
|
+
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
2078
|
+
}
|
|
2079
|
+
return wishlist;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
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: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2083
|
+
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
|
|
2084
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
|
|
2085
|
+
type: Injectable
|
|
2086
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2087
|
+
type: Inject,
|
|
2088
|
+
args: ['WishlistRepository']
|
|
2089
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
2090
|
+
type: Inject,
|
|
2091
|
+
args: [DEFAULT_SHOP]
|
|
2092
|
+
}] }, { type: undefined, decorators: [{
|
|
2093
|
+
type: Inject,
|
|
2094
|
+
args: ['ProductRepository']
|
|
2095
|
+
}] }, { type: undefined, decorators: [{
|
|
2096
|
+
type: Inject,
|
|
2097
|
+
args: ['CategoryFilterRepository']
|
|
2098
|
+
}] }, { type: undefined, decorators: [{
|
|
2099
|
+
type: Inject,
|
|
2100
|
+
args: ['CategoryRepository']
|
|
2101
|
+
}] }, { type: undefined, decorators: [{
|
|
2102
|
+
type: Inject,
|
|
2103
|
+
args: ['ProductStockNotificationRepository']
|
|
2104
|
+
}] }, { type: undefined, decorators: [{
|
|
2105
|
+
type: Inject,
|
|
2106
|
+
args: ['ProductSearch']
|
|
2134
2107
|
}] }]; } });
|
|
2135
2108
|
|
|
2136
|
-
class CheckoutSubscriptionService {
|
|
2137
|
-
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
2138
|
-
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2139
|
-
this.dataPersistence = dataPersistence;
|
|
2140
|
-
this.couponService = couponService;
|
|
2141
|
-
}
|
|
2142
|
-
getCheckoutSubscription(checkoutData) {
|
|
2143
|
-
return this.dataPersistence
|
|
2144
|
-
.get('checkoutSubscriptionId')
|
|
2145
|
-
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
2146
|
-
}
|
|
2147
|
-
clearCheckoutSubscriptionFromSession() {
|
|
2148
|
-
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
2149
|
-
}
|
|
2150
|
-
checkCoupon(nickname, userEmail) {
|
|
2151
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
2152
|
-
.checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
|
|
2153
|
-
.pipe()));
|
|
2154
|
-
}
|
|
2155
|
-
calcDiscountSubscription(coupon) {
|
|
2156
|
-
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2157
|
-
}
|
|
2158
|
-
async createCheckoutSubscription(checkoutData) {
|
|
2159
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2160
|
-
createdAt: new Date(),
|
|
2161
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2162
|
-
});
|
|
2163
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2164
|
-
return checkout;
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
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 });
|
|
2168
|
-
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
|
|
2169
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
2170
|
-
type: Injectable
|
|
2171
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2172
|
-
type: Inject,
|
|
2173
|
-
args: ['CheckoutSubscriptionRepository']
|
|
2174
|
-
}] }, { type: undefined, decorators: [{
|
|
2175
|
-
type: Inject,
|
|
2176
|
-
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]
|
|
2177
2150
|
}] }, { type: CouponService }]; } });
|
|
2178
2151
|
|
|
2179
|
-
class UtilHelper {
|
|
2180
|
-
static createSlug(name) {
|
|
2181
|
-
return name
|
|
2182
|
-
.toLowerCase()
|
|
2183
|
-
.replace(/\s+/g, '-') // Replace spaces with -
|
|
2184
|
-
.replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
|
|
2185
|
-
.replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
|
|
2186
|
-
.replace(/[ìíïî]/g, 'i') // Replace spaces with -
|
|
2187
|
-
.replace(/[õòóöô]/g, 'o') // Replace spaces with -
|
|
2188
|
-
.replace(/[ùúüû]/g, 'u') // Replace spaces with -
|
|
2189
|
-
.replace(/[ñ]/g, 'n') // Replace spaces with -
|
|
2190
|
-
.replace(/[ç]/g, 'c') // Replace spaces with -
|
|
2191
|
-
.replace(/[&]/g, 'and') // Replace spaces with -
|
|
2192
|
-
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
2193
|
-
.replace(/\-\-+/g, '-'); // Replace multiple - with single -
|
|
2194
|
-
}
|
|
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
|
+
}
|
|
2195
2168
|
}
|
|
2196
2169
|
|
|
2197
|
-
class HomeShopService {
|
|
2198
|
-
get homeId() {
|
|
2199
|
-
if (this.defaultShop === Shops.GLAMSHOP)
|
|
2200
|
-
return 'glamshop';
|
|
2201
|
-
if (this.defaultShop === Shops.MENSMARKET)
|
|
2202
|
-
return 'mens_market';
|
|
2203
|
-
return null;
|
|
2204
|
-
}
|
|
2205
|
-
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
2206
|
-
this.categoryRepository = categoryRepository;
|
|
2207
|
-
this.homeRepository = homeRepository;
|
|
2208
|
-
this.productRepository = productRepository;
|
|
2209
|
-
this.defaultShop = defaultShop;
|
|
2210
|
-
this.buildCategoryGroupWithRequiredData = (group) => ({
|
|
2211
|
-
category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
2212
|
-
products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
|
|
2213
|
-
'id',
|
|
2214
|
-
'price',
|
|
2215
|
-
'reviews',
|
|
2216
|
-
'hasVariants',
|
|
2217
|
-
'slug',
|
|
2218
|
-
'sku',
|
|
2219
|
-
'stock',
|
|
2220
|
-
'costPrice',
|
|
2221
|
-
'images',
|
|
2222
|
-
'miniatures',
|
|
2223
|
-
'name',
|
|
2224
|
-
'weight',
|
|
2225
|
-
'rate',
|
|
2226
|
-
'type',
|
|
2227
|
-
'brand',
|
|
2228
|
-
]))) || [],
|
|
2229
|
-
});
|
|
2230
|
-
}
|
|
2231
|
-
getHomeData() {
|
|
2232
|
-
return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
|
|
2233
|
-
? of(home)
|
|
2234
|
-
: forkJoin([
|
|
2235
|
-
this.getDiscoverProducts(this.gender),
|
|
2236
|
-
this.getFeaturedProducts(this.gender),
|
|
2237
|
-
this.getVerticalProducts(this.gender),
|
|
2238
|
-
]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
|
|
2239
|
-
discoverProducts,
|
|
2240
|
-
featuredProducts,
|
|
2241
|
-
verticalProducts,
|
|
2242
|
-
})), concatMap((data) => this.saveHomeData(data)))));
|
|
2243
|
-
}
|
|
2244
|
-
getBanners(type) {
|
|
2245
|
-
return this.getHomeConfiguration().pipe(map((home) => {
|
|
2246
|
-
if (type === 'brand')
|
|
2247
|
-
return home.brandsCarousel;
|
|
2248
|
-
if (type === 'buyToWin')
|
|
2249
|
-
return [home.buyToWinBanner];
|
|
2250
|
-
if (type === 'block')
|
|
2251
|
-
return home.blockBanners;
|
|
2252
|
-
if (type === 'blog')
|
|
2253
|
-
return [home.blogBanner];
|
|
2254
|
-
return [];
|
|
2255
|
-
}));
|
|
2256
|
-
}
|
|
2257
|
-
getMinValueForFreeShipping() {
|
|
2258
|
-
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
2259
|
-
}
|
|
2260
|
-
getDiscoverProducts(gender) {
|
|
2261
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2262
|
-
}
|
|
2263
|
-
getFeaturedProducts(gender) {
|
|
2264
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2265
|
-
}
|
|
2266
|
-
getVerticalProducts(gender) {
|
|
2267
|
-
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({
|
|
2268
|
-
filters: {
|
|
2269
|
-
categories: { operator: Where.IN, value: [category.id] },
|
|
2270
|
-
...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
|
|
2271
|
-
},
|
|
2272
|
-
limits: { limit: 12 },
|
|
2273
|
-
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
2274
|
-
}
|
|
2275
|
-
getHomeConfiguration() {
|
|
2276
|
-
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
2277
|
-
? of(home)
|
|
2278
|
-
: !this.homeId
|
|
2279
|
-
? throwError(new RequiredArgumentError(['homeId']))
|
|
2280
|
-
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
2281
|
-
}
|
|
2282
|
-
saveHomeData(homeData) {
|
|
2283
|
-
const data = {
|
|
2284
|
-
createdAt: new Date(),
|
|
2285
|
-
expiresAt: add(new Date(), { hours: 1 }),
|
|
2286
|
-
data: homeData,
|
|
2287
|
-
};
|
|
2288
|
-
return from(this.homeRepository.update({
|
|
2289
|
-
id: this.homeId,
|
|
2290
|
-
data,
|
|
2291
|
-
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
2292
|
-
}
|
|
2293
|
-
get gender() {
|
|
2294
|
-
return this.homeId === 'mens_market' ? 'masculino' : undefined;
|
|
2295
|
-
}
|
|
2296
|
-
}
|
|
2297
|
-
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 });
|
|
2298
|
-
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
|
|
2299
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
|
|
2300
|
-
type: Injectable
|
|
2301
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2302
|
-
type: Inject,
|
|
2303
|
-
args: ['CategoryRepository']
|
|
2304
|
-
}] }, { type: undefined, decorators: [{
|
|
2305
|
-
type: Inject,
|
|
2306
|
-
args: ['HomeRepository']
|
|
2307
|
-
}] }, { type: undefined, decorators: [{
|
|
2308
|
-
type: Inject,
|
|
2309
|
-
args: ['ProductRepository']
|
|
2310
|
-
}] }, { type: i1$2.Shops, decorators: [{
|
|
2311
|
-
type: Inject,
|
|
2312
|
-
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]
|
|
2313
2286
|
}] }]; } });
|
|
2314
2287
|
|
|
2315
|
-
class OrderService {
|
|
2316
|
-
constructor(angularFirestore, orderRepository) {
|
|
2317
|
-
this.angularFirestore = angularFirestore;
|
|
2318
|
-
this.orderRepository = orderRepository;
|
|
2319
|
-
this.orderSubject = new Subject();
|
|
2320
|
-
}
|
|
2321
|
-
getOrder(id) {
|
|
2322
|
-
docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
|
|
2323
|
-
.pipe(map((doc) => Order.toInstance(doc.data())))
|
|
2324
|
-
.subscribe((doc) => this.orderSubject.next(doc));
|
|
2325
|
-
return this.orderSubject;
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
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 });
|
|
2329
|
-
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
|
|
2330
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
|
|
2331
|
-
type: Injectable
|
|
2332
|
-
}], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
|
|
2333
|
-
type: Inject,
|
|
2334
|
-
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']
|
|
2335
2308
|
}] }]; } });
|
|
2336
2309
|
|
|
2337
|
-
class ShippingService {
|
|
2338
|
-
constructor(http, apiUrl, homeService) {
|
|
2339
|
-
this.http = http;
|
|
2340
|
-
this.apiUrl = apiUrl;
|
|
2341
|
-
this.homeService = homeService;
|
|
2342
|
-
}
|
|
2343
|
-
getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
2344
|
-
return combineLatest([
|
|
2345
|
-
this.homeService.getHomeData(),
|
|
2346
|
-
this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
|
|
2347
|
-
]).pipe(map(([datas, shippingMethodsResponse]) => {
|
|
2348
|
-
let shippingMethods = shippingMethodsResponse.result;
|
|
2349
|
-
if (!shippingMethods.length)
|
|
2350
|
-
return [];
|
|
2351
|
-
shippingMethods = shippingMethods.map((shippingMethod) => {
|
|
2352
|
-
if (shippingMethod.ShippingCompanyName == 'Same Day EG')
|
|
2353
|
-
shippingMethod.ShippingCompanyName = 'Same Day';
|
|
2354
|
-
return shippingMethod;
|
|
2355
|
-
});
|
|
2356
|
-
const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
|
|
2357
|
-
if (this.isHolidays(datasSameDayNotAvaliable)) {
|
|
2358
|
-
shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
|
|
2359
|
-
}
|
|
2360
|
-
if (totalPrice >= 200) {
|
|
2361
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2362
|
-
if (s.serviceName !== 'Same Day')
|
|
2363
|
-
return { ...s, totalPrice: 0 };
|
|
2364
|
-
else
|
|
2365
|
-
return s;
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2368
|
-
if (shop == Shops.GLAMSHOP)
|
|
2369
|
-
return shippingMethods;
|
|
2370
|
-
if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
|
|
2371
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2372
|
-
if (s.serviceName == 'Same Day')
|
|
2373
|
-
return { ...s, totalPrice: s.totalPrice / 2 };
|
|
2374
|
-
else
|
|
2375
|
-
return { ...s, totalPrice: 0 };
|
|
2376
|
-
});
|
|
2377
|
-
}
|
|
2378
|
-
if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
|
|
2379
|
-
shippingMethods = shippingMethods.map((s) => {
|
|
2380
|
-
return { ...s, totalPrice: s.totalPrice / 2 };
|
|
2381
|
-
});
|
|
2382
|
-
}
|
|
2383
|
-
return shippingMethods;
|
|
2384
|
-
}));
|
|
2385
|
-
}
|
|
2386
|
-
isFreeShippingBySubscription(shop, subscriptionPlan) {
|
|
2387
|
-
if (!subscriptionPlan)
|
|
2388
|
-
return false;
|
|
2389
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
|
|
2390
|
-
return true;
|
|
2391
|
-
return false;
|
|
2392
|
-
}
|
|
2393
|
-
isHalfShippingBySubscription(shop, subscriptionPlan) {
|
|
2394
|
-
if (!subscriptionPlan)
|
|
2395
|
-
return false;
|
|
2396
|
-
if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
|
|
2397
|
-
return true;
|
|
2398
|
-
}
|
|
2399
|
-
return false;
|
|
2400
|
-
}
|
|
2401
|
-
isHolidays(datas) {
|
|
2402
|
-
const today = new Date();
|
|
2403
|
-
for (const key in datas) {
|
|
2404
|
-
let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
|
|
2405
|
-
let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
|
|
2406
|
-
if (start > end)
|
|
2407
|
-
end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
|
|
2408
|
-
if (today >= start && today <= end)
|
|
2409
|
-
return true;
|
|
2410
|
-
}
|
|
2411
|
-
return false;
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
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 });
|
|
2415
|
-
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
|
|
2416
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
|
|
2417
|
-
type: Injectable
|
|
2418
|
-
}], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
|
|
2419
|
-
type: Inject,
|
|
2420
|
-
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]
|
|
2421
2394
|
}] }, { type: HomeShopService }]; } });
|
|
2422
2395
|
|
|
2423
|
-
class AngularConnectModule {
|
|
2424
|
-
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
2425
|
-
return {
|
|
2426
|
-
ngModule: AngularConnectModule,
|
|
2427
|
-
providers: [
|
|
2428
|
-
{
|
|
2429
|
-
provide: CATEGORY_STRUCTURE,
|
|
2430
|
-
useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
|
|
2431
|
-
? OldCategoryStructureAdapter
|
|
2432
|
-
: NewCategoryStructureAdapter,
|
|
2433
|
-
},
|
|
2434
|
-
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2435
|
-
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2436
|
-
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2437
|
-
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
2438
|
-
...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
2439
|
-
...(isNil(options?.vertexConfig) ? [] : [{ provide: VERTEX_CONFIG, useValue: options.vertexConfig }]),
|
|
2440
|
-
...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
2441
|
-
...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
2442
|
-
...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
|
|
2443
|
-
],
|
|
2444
|
-
};
|
|
2445
|
-
}
|
|
2446
|
-
}
|
|
2447
|
-
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2448
|
-
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, i2.StorageModule, AngularElasticSeachModule,
|
|
2449
|
-
AngularVertexSeachModule,
|
|
2450
|
-
AngularFirebaseAuthModule,
|
|
2451
|
-
AngularFirestoreModule,
|
|
2452
|
-
AngularHasuraGraphQLModule] });
|
|
2453
|
-
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
|
|
2454
|
-
AuthService,
|
|
2455
|
-
CartService,
|
|
2456
|
-
CatalogService,
|
|
2457
|
-
CategoryService,
|
|
2458
|
-
CheckoutService,
|
|
2459
|
-
CheckoutSubscriptionService,
|
|
2460
|
-
CouponService,
|
|
2461
|
-
HomeShopService,
|
|
2462
|
-
OrderService,
|
|
2463
|
-
ShippingService,
|
|
2464
|
-
WishlistService,
|
|
2465
|
-
{
|
|
2466
|
-
provide: UpdateUserImage,
|
|
2467
|
-
useFactory: (userRepository, fileUploader) => {
|
|
2468
|
-
return new UpdateUserImage(userRepository, fileUploader);
|
|
2469
|
-
},
|
|
2470
|
-
deps: ['UserRepository', 'FileUploaderService'],
|
|
2471
|
-
},
|
|
2472
|
-
{
|
|
2473
|
-
provide: 'FileUploaderService',
|
|
2474
|
-
useFactory: (storage, baseUrl) => {
|
|
2475
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2476
|
-
},
|
|
2477
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
2478
|
-
},
|
|
2479
|
-
{
|
|
2480
|
-
provide: 'ProductSearch',
|
|
2481
|
-
useExisting: ProductsVertexSearch,
|
|
2482
|
-
},
|
|
2483
|
-
], imports: [provideFirebaseApp((injector) => {
|
|
2484
|
-
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2485
|
-
try {
|
|
2486
|
-
return getApp(appName);
|
|
2487
|
-
}
|
|
2488
|
-
catch (error) {
|
|
2489
|
-
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2490
|
-
}
|
|
2491
|
-
}),
|
|
2492
|
-
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2493
|
-
AngularElasticSeachModule,
|
|
2494
|
-
AngularVertexSeachModule,
|
|
2495
|
-
AngularFirebaseAuthModule,
|
|
2496
|
-
AngularFirestoreModule,
|
|
2497
|
-
AngularHasuraGraphQLModule] });
|
|
2498
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
2499
|
-
type: NgModule,
|
|
2500
|
-
args: [{
|
|
2501
|
-
imports: [
|
|
2502
|
-
provideFirebaseApp((injector) => {
|
|
2503
|
-
const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
|
|
2504
|
-
try {
|
|
2505
|
-
return getApp(appName);
|
|
2506
|
-
}
|
|
2507
|
-
catch (error) {
|
|
2508
|
-
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2509
|
-
}
|
|
2510
|
-
}),
|
|
2511
|
-
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2512
|
-
AngularElasticSeachModule,
|
|
2513
|
-
AngularVertexSeachModule,
|
|
2514
|
-
AngularFirebaseAuthModule,
|
|
2515
|
-
AngularFirestoreModule,
|
|
2516
|
-
AngularHasuraGraphQLModule,
|
|
2517
|
-
],
|
|
2518
|
-
providers: [
|
|
2519
|
-
AuthService,
|
|
2520
|
-
CartService,
|
|
2521
|
-
CatalogService,
|
|
2522
|
-
CategoryService,
|
|
2523
|
-
CheckoutService,
|
|
2524
|
-
CheckoutSubscriptionService,
|
|
2525
|
-
CouponService,
|
|
2526
|
-
HomeShopService,
|
|
2527
|
-
OrderService,
|
|
2528
|
-
ShippingService,
|
|
2529
|
-
WishlistService,
|
|
2530
|
-
{
|
|
2531
|
-
provide: UpdateUserImage,
|
|
2532
|
-
useFactory: (userRepository, fileUploader) => {
|
|
2533
|
-
return new UpdateUserImage(userRepository, fileUploader);
|
|
2534
|
-
},
|
|
2535
|
-
deps: ['UserRepository', 'FileUploaderService'],
|
|
2536
|
-
},
|
|
2537
|
-
{
|
|
2538
|
-
provide: 'FileUploaderService',
|
|
2539
|
-
useFactory: (storage, baseUrl) => {
|
|
2540
|
-
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
2541
|
-
},
|
|
2542
|
-
deps: [Storage, STORAGE_BASE_URL],
|
|
2543
|
-
},
|
|
2544
|
-
{
|
|
2545
|
-
provide: 'ProductSearch',
|
|
2546
|
-
useExisting: ProductsVertexSearch,
|
|
2547
|
-
},
|
|
2548
|
-
],
|
|
2549
|
-
}]
|
|
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
|
+
}]
|
|
2550
2523
|
}] });
|
|
2551
2524
|
|
|
2552
|
-
/**
|
|
2553
|
-
* Generated bundle index. Do not edit.
|
|
2525
|
+
/**
|
|
2526
|
+
* Generated bundle index. Do not edit.
|
|
2554
2527
|
*/
|
|
2555
2528
|
|
|
2556
2529
|
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|