@infrab4a/connect-angular 4.20.0 → 4.21.1-alpha.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 +4 -0
- package/esm2020/angular-connect.module.mjs +119 -17
- package/esm2020/angular-firestore.module.mjs +16 -2
- package/esm2020/angular-hasura-graphql.module.mjs +1 -1
- package/esm2020/consts/backend-url.const.mjs +1 -1
- package/esm2020/interfaces/catalog-strategies.interface.mjs +2 -0
- package/esm2020/interfaces/category-facades.interface.mjs +2 -0
- package/esm2020/interfaces/index.mjs +3 -0
- package/esm2020/persistence/cookie-data-persistence.mjs +1 -1
- package/esm2020/services/cart/cart-services.facade.mjs +21 -0
- package/esm2020/services/cart/index.mjs +2 -0
- package/esm2020/services/cart.service.mjs +25 -38
- package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +1 -1
- package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +1 -1
- package/esm2020/services/catalog/catalog.service.mjs +80 -294
- package/esm2020/services/catalog/category.service.mjs +15 -27
- package/esm2020/services/catalog/context/catalog-search.context.mjs +40 -0
- package/esm2020/services/catalog/facades/catalog-service.facade.mjs +32 -0
- package/esm2020/services/catalog/facades/catalog-strategies.facade.mjs +17 -0
- package/esm2020/services/catalog/facades/category-repository.facade.mjs +20 -0
- package/esm2020/services/catalog/facades/category-service.facade.mjs +30 -0
- package/esm2020/services/catalog/facades/index.mjs +6 -0
- package/esm2020/services/catalog/facades/product-catalog.facade.mjs +21 -0
- package/esm2020/services/catalog/helpers/brand-manager.helper.mjs +57 -0
- package/esm2020/services/catalog/helpers/catalog-filter.helper.mjs +44 -0
- package/esm2020/services/catalog/helpers/catalog-sort.helper.mjs +52 -0
- package/esm2020/services/catalog/helpers/index.mjs +5 -0
- package/esm2020/services/catalog/helpers/product-fields.helper.mjs +39 -0
- package/esm2020/services/catalog/models/category-with-tree.model.mjs +1 -1
- package/esm2020/services/catalog/services/catalog-helpers.service.mjs +33 -0
- package/esm2020/services/catalog/services/catalog-operations.facade.mjs +26 -0
- package/esm2020/services/catalog/services/catalog-repository.service.mjs +25 -0
- package/esm2020/services/catalog/services/index.mjs +5 -0
- package/esm2020/services/catalog/services/product-management.facade.mjs +25 -0
- package/esm2020/services/catalog/strategies/category-search.strategy.mjs +133 -0
- package/esm2020/services/catalog/strategies/index.mjs +4 -0
- package/esm2020/services/catalog/strategies/profile-search.strategy.mjs +42 -0
- package/esm2020/services/catalog/strategies/term-search.strategy.mjs +126 -0
- package/esm2020/services/catalog/strategies/types/strategy-params.type.mjs +2 -0
- package/esm2020/services/catalog/types/fetch-products-options.type.mjs +2 -0
- package/esm2020/services/catalog/types/fetch-products-params.type.mjs +2 -0
- package/esm2020/services/catalog/types/fetch-products-response.type.mjs +2 -0
- package/esm2020/services/catalog/types/index.mjs +5 -1
- package/esm2020/services/catalog/types/method-params.type.mjs +2 -0
- package/esm2020/services/catalog/wishlist.service.mjs +92 -72
- package/esm2020/services/checkout/checkout-dependencies.facade.mjs +20 -0
- package/esm2020/services/checkout/checkout-repositories.facade.mjs +20 -0
- package/esm2020/services/checkout/index.mjs +3 -0
- package/esm2020/services/checkout-subscription.service.mjs +8 -3
- package/esm2020/services/checkout.service.mjs +34 -50
- package/esm2020/services/coupon/coupon-repositories.facade.mjs +24 -0
- package/esm2020/services/coupon/index.mjs +2 -0
- package/esm2020/services/coupon/types/coupon-params.type.mjs +2 -0
- package/esm2020/services/coupon.service.mjs +79 -59
- package/esm2020/services/helpers/util.helper.mjs +12 -12
- package/esm2020/services/home-shop/home-shop-repositories.facade.mjs +24 -0
- package/esm2020/services/home-shop/index.mjs +2 -0
- package/esm2020/services/home-shop.service.mjs +27 -33
- package/esm2020/services/shared/configuration.facade.mjs +29 -0
- package/esm2020/services/shared/index.mjs +2 -0
- package/fesm2015/infrab4a-connect-angular.mjs +1286 -551
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +1198 -510
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/interfaces/catalog-strategies.interface.d.ts +31 -0
- package/interfaces/category-facades.interface.d.ts +6 -0
- package/interfaces/index.d.ts +2 -0
- package/package.json +5 -3
- package/services/cart/cart-services.facade.d.ts +12 -0
- package/services/cart/index.d.ts +1 -0
- package/services/cart.service.d.ts +6 -11
- package/services/catalog/catalog.service.d.ts +11 -83
- package/services/catalog/category.service.d.ts +5 -7
- package/services/catalog/context/catalog-search.context.d.ts +14 -0
- package/services/catalog/facades/catalog-service.facade.d.ts +15 -0
- package/services/catalog/facades/catalog-strategies.facade.d.ts +10 -0
- package/services/catalog/facades/category-repository.facade.d.ts +9 -0
- package/services/catalog/facades/category-service.facade.d.ts +15 -0
- package/services/catalog/facades/index.d.ts +5 -0
- package/services/catalog/facades/product-catalog.facade.d.ts +10 -0
- package/services/catalog/helpers/brand-manager.helper.d.ts +14 -0
- package/services/catalog/helpers/catalog-filter.helper.d.ts +8 -0
- package/services/catalog/helpers/catalog-sort.helper.d.ts +7 -0
- package/services/catalog/helpers/index.d.ts +4 -0
- package/services/catalog/helpers/product-fields.helper.d.ts +7 -0
- package/services/catalog/services/catalog-helpers.service.d.ts +17 -0
- package/services/catalog/services/catalog-operations.facade.d.ts +13 -0
- package/services/catalog/services/catalog-repository.service.d.ts +12 -0
- package/services/catalog/services/index.d.ts +4 -0
- package/services/catalog/services/product-management.facade.d.ts +12 -0
- package/services/catalog/strategies/category-search.strategy.d.ts +19 -0
- package/services/catalog/strategies/index.d.ts +3 -0
- package/services/catalog/strategies/profile-search.strategy.d.ts +14 -0
- package/services/catalog/strategies/term-search.strategy.d.ts +20 -0
- package/services/catalog/strategies/types/strategy-params.type.d.ts +58 -0
- package/services/catalog/types/fetch-products-options.type.d.ts +8 -0
- package/services/catalog/types/fetch-products-params.type.d.ts +25 -0
- package/services/catalog/types/fetch-products-response.type.d.ts +19 -0
- package/services/catalog/types/index.d.ts +4 -0
- package/services/catalog/types/method-params.type.d.ts +17 -0
- package/services/catalog/wishlist.service.d.ts +12 -4
- package/services/checkout/checkout-dependencies.facade.d.ts +10 -0
- package/services/checkout/checkout-repositories.facade.d.ts +9 -0
- package/services/checkout/index.d.ts +2 -0
- package/services/checkout-subscription.service.d.ts +2 -2
- package/services/checkout.service.d.ts +7 -11
- package/services/coupon/coupon-repositories.facade.d.ts +10 -0
- package/services/coupon/index.d.ts +1 -0
- package/services/coupon/types/coupon-params.type.d.ts +13 -0
- package/services/coupon.service.d.ts +16 -7
- package/services/home-shop/home-shop-repositories.facade.d.ts +10 -0
- package/services/home-shop/index.d.ts +1 -0
- package/services/home-shop.service.d.ts +6 -6
- package/services/shared/configuration.facade.d.ts +12 -0
- package/services/shared/index.d.ts +1 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angular/core';
|
|
3
|
-
import * as i1$
|
|
3
|
+
import * as i1$3 from '@angular/fire/app';
|
|
4
4
|
import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
|
|
5
5
|
import * as i2 from '@angular/fire/app-check';
|
|
6
6
|
import { provideAppCheck, initializeAppCheck } from '@angular/fire/app-check';
|
|
7
|
-
import * as i3 from '@angular/fire/storage';
|
|
7
|
+
import * as i3$1 from '@angular/fire/storage';
|
|
8
8
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
9
|
-
import * as
|
|
10
|
-
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, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductErrorsHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where,
|
|
9
|
+
import * as i3 from '@infrab4a/connect';
|
|
10
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, GroupFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductErrorsHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where, Shops, isEmpty, set, InvalidArgumentError, RoundProductPricesHelper, Category, WishlistLogType, PersonTypes, Wishlist, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
11
11
|
import * as i1 from '@angular/fire/auth';
|
|
12
12
|
import { Auth, provideAuth, initializeAuth, indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
13
13
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
@@ -310,6 +310,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
310
310
|
},
|
|
311
311
|
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
312
312
|
},
|
|
313
|
+
{
|
|
314
|
+
provide: 'GroupRepository',
|
|
315
|
+
useFactory: (options) => {
|
|
316
|
+
return new GroupFirestoreRepository(options);
|
|
317
|
+
},
|
|
318
|
+
deps: ['FirestoreOptions'],
|
|
319
|
+
},
|
|
313
320
|
{
|
|
314
321
|
provide: 'HomeRepository',
|
|
315
322
|
useFactory: (options) => {
|
|
@@ -576,6 +583,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
576
583
|
},
|
|
577
584
|
deps: ['FirestoreOptions', 'SubscriptionRepository'],
|
|
578
585
|
},
|
|
586
|
+
{
|
|
587
|
+
provide: 'GroupRepository',
|
|
588
|
+
useFactory: (options) => {
|
|
589
|
+
return new GroupFirestoreRepository(options);
|
|
590
|
+
},
|
|
591
|
+
deps: ['FirestoreOptions'],
|
|
592
|
+
},
|
|
579
593
|
{
|
|
580
594
|
provide: 'HomeRepository',
|
|
581
595
|
useFactory: (options) => {
|
|
@@ -1137,157 +1151,215 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1137
1151
|
}] }];
|
|
1138
1152
|
} });
|
|
1139
1153
|
|
|
1140
|
-
class
|
|
1141
|
-
constructor(checkoutRepository, userRepository
|
|
1154
|
+
class CheckoutRepositoriesFacade {
|
|
1155
|
+
constructor(checkoutRepository, userRepository) {
|
|
1142
1156
|
this.checkoutRepository = checkoutRepository;
|
|
1143
1157
|
this.userRepository = userRepository;
|
|
1144
|
-
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
CheckoutRepositoriesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutRepositoriesFacade, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1161
|
+
CheckoutRepositoriesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutRepositoriesFacade });
|
|
1162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutRepositoriesFacade, decorators: [{
|
|
1163
|
+
type: Injectable
|
|
1164
|
+
}], ctorParameters: function () {
|
|
1165
|
+
return [{ type: undefined, decorators: [{
|
|
1166
|
+
type: Inject,
|
|
1167
|
+
args: ['CheckoutRepository']
|
|
1168
|
+
}] }, { type: undefined, decorators: [{
|
|
1169
|
+
type: Inject,
|
|
1170
|
+
args: ['UserRepository']
|
|
1171
|
+
}] }];
|
|
1172
|
+
} });
|
|
1173
|
+
|
|
1174
|
+
class CheckoutDependenciesFacade {
|
|
1175
|
+
constructor(dataPersistence, httpClient) {
|
|
1145
1176
|
this.dataPersistence = dataPersistence;
|
|
1177
|
+
this.httpClient = httpClient;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
CheckoutDependenciesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutDependenciesFacade, deps: [{ token: PERSISTENCE_PROVIDER }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1181
|
+
CheckoutDependenciesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutDependenciesFacade });
|
|
1182
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutDependenciesFacade, decorators: [{
|
|
1183
|
+
type: Injectable
|
|
1184
|
+
}], ctorParameters: function () {
|
|
1185
|
+
return [{ type: undefined, decorators: [{
|
|
1186
|
+
type: Inject,
|
|
1187
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1188
|
+
}] }, { type: i1$2.HttpClient }];
|
|
1189
|
+
} });
|
|
1190
|
+
|
|
1191
|
+
class ConfigurationFacade {
|
|
1192
|
+
constructor(defaultShop, firebaseOptions) {
|
|
1193
|
+
this.defaultShop = defaultShop;
|
|
1146
1194
|
this.firebaseOptions = firebaseOptions;
|
|
1147
|
-
|
|
1195
|
+
}
|
|
1196
|
+
getCheckoutUrl() {
|
|
1197
|
+
return `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`;
|
|
1198
|
+
}
|
|
1199
|
+
getProjectId() {
|
|
1200
|
+
return this.firebaseOptions.projectId;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
ConfigurationFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ConfigurationFacade, deps: [{ token: DEFAULT_SHOP }, { token: FIREBASE_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1204
|
+
ConfigurationFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ConfigurationFacade });
|
|
1205
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ConfigurationFacade, decorators: [{
|
|
1206
|
+
type: Injectable
|
|
1207
|
+
}], ctorParameters: function () {
|
|
1208
|
+
return [{ type: i3.Shops, decorators: [{
|
|
1209
|
+
type: Inject,
|
|
1210
|
+
args: [DEFAULT_SHOP]
|
|
1211
|
+
}] }, { type: undefined, decorators: [{
|
|
1212
|
+
type: Inject,
|
|
1213
|
+
args: [FIREBASE_OPTIONS]
|
|
1214
|
+
}] }];
|
|
1215
|
+
} });
|
|
1216
|
+
|
|
1217
|
+
class CheckoutService {
|
|
1218
|
+
constructor(repositoriesFacade, dependenciesFacade, configurationFacade) {
|
|
1219
|
+
this.repositoriesFacade = repositoriesFacade;
|
|
1220
|
+
this.dependenciesFacade = dependenciesFacade;
|
|
1221
|
+
this.configurationFacade = configurationFacade;
|
|
1148
1222
|
this.checkoutUrl = null;
|
|
1149
|
-
this.checkoutUrl =
|
|
1223
|
+
this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
|
|
1150
1224
|
}
|
|
1151
1225
|
getCheckout(checkoutData) {
|
|
1152
|
-
return this.dataPersistence
|
|
1226
|
+
return this.dependenciesFacade.dataPersistence
|
|
1153
1227
|
.get('checkoutId')
|
|
1154
|
-
.pipe(concatMap((id) =>
|
|
1228
|
+
.pipe(concatMap((id) => !isNil(id) ? this.repositoriesFacade.checkoutRepository.get({ id }) : this.createCheckout(checkoutData)));
|
|
1155
1229
|
}
|
|
1156
1230
|
getUserByCheckout(checkoutId) {
|
|
1157
|
-
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => {
|
|
1231
|
+
return from(this.repositoriesFacade.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => {
|
|
1232
|
+
var _a;
|
|
1233
|
+
return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id)
|
|
1234
|
+
? of(checkout.user)
|
|
1235
|
+
: from(this.repositoriesFacade.userRepository.get({ id: checkout.user.id }));
|
|
1236
|
+
}), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
1158
1237
|
}
|
|
1159
1238
|
updateCheckoutLineItems(checkout) {
|
|
1160
|
-
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
1239
|
+
return from(this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
|
|
1161
1240
|
}
|
|
1162
1241
|
updateCheckoutUser(checkout) {
|
|
1163
|
-
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1242
|
+
return from(this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1164
1243
|
}
|
|
1165
1244
|
clearCheckoutFromSession() {
|
|
1166
|
-
return this.dataPersistence.remove('checkoutId');
|
|
1245
|
+
return this.dependenciesFacade.dataPersistence.remove('checkoutId');
|
|
1167
1246
|
}
|
|
1168
1247
|
resetCheckoutValues() {
|
|
1169
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.
|
|
1248
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutResetValues`, {
|
|
1170
1249
|
checkoutId: checkout.id,
|
|
1171
1250
|
})), concatMap(() => this.getCheckout()));
|
|
1172
1251
|
}
|
|
1173
1252
|
applyCouponDiscount(nickname, checkoutType) {
|
|
1174
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.
|
|
1253
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutApplyDiscount`, {
|
|
1175
1254
|
checkoutId: checkout.id,
|
|
1176
1255
|
coupon: nickname,
|
|
1177
1256
|
checkoutType,
|
|
1178
1257
|
})), concatMap(() => this.getCheckout()), map((checkout) => checkout.coupon));
|
|
1179
1258
|
}
|
|
1180
1259
|
removeCouponDiscount() {
|
|
1181
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.
|
|
1260
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemoveDiscount`, {
|
|
1182
1261
|
checkoutId: checkout.id,
|
|
1183
1262
|
})), concatMap(() => this.getCheckout()));
|
|
1184
1263
|
}
|
|
1185
1264
|
validateStockProducts() {
|
|
1186
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.
|
|
1265
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutValidateProductStock`, {
|
|
1187
1266
|
checkoutId: checkout.id,
|
|
1188
1267
|
})));
|
|
1189
1268
|
}
|
|
1190
1269
|
selectShippingAddress(address) {
|
|
1191
1270
|
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
1192
|
-
return this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, shippingAddress: address, billingAddress: address }));
|
|
1271
|
+
return this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, shippingAddress: address, billingAddress: address }));
|
|
1193
1272
|
}));
|
|
1194
1273
|
}
|
|
1195
1274
|
getAvailableShippingForProduct(productShipping) {
|
|
1196
|
-
return this.
|
|
1275
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
|
|
1197
1276
|
checkoutId: null,
|
|
1198
1277
|
productShipping,
|
|
1199
1278
|
});
|
|
1200
1279
|
}
|
|
1201
1280
|
getAvailableShippingForCheckout() {
|
|
1202
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.
|
|
1281
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
|
|
1203
1282
|
checkoutId: checkout.id,
|
|
1204
1283
|
productShipping: null,
|
|
1205
1284
|
})));
|
|
1206
1285
|
}
|
|
1207
1286
|
selectShipping(option) {
|
|
1208
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.
|
|
1287
|
+
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutSelectShipping`, {
|
|
1209
1288
|
checkoutId: checkout.id,
|
|
1210
1289
|
shippingOption: option,
|
|
1211
1290
|
})), concatMap(() => this.getCheckout()));
|
|
1212
1291
|
}
|
|
1213
1292
|
createOrder(checkoutPayload, paymentProvider, applicationVersion) {
|
|
1214
|
-
return this.
|
|
1293
|
+
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkout`, {
|
|
1215
1294
|
data: Object.assign(Object.assign({}, checkoutPayload), { applicationVersion,
|
|
1216
1295
|
paymentProvider }),
|
|
1217
1296
|
});
|
|
1218
1297
|
}
|
|
1219
1298
|
createCheckout(checkoutData) {
|
|
1220
1299
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1221
|
-
const checkout = yield this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }));
|
|
1222
|
-
yield this.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1300
|
+
const checkout = yield this.repositoriesFacade.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.configurationFacade.defaultShop }));
|
|
1301
|
+
yield this.dependenciesFacade.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1223
1302
|
return checkout;
|
|
1224
1303
|
});
|
|
1225
1304
|
}
|
|
1226
1305
|
}
|
|
1227
|
-
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token:
|
|
1306
|
+
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CheckoutRepositoriesFacade }, { token: CheckoutDependenciesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1228
1307
|
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
|
|
1229
1308
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
|
|
1230
1309
|
type: Injectable
|
|
1231
|
-
}], ctorParameters: function () {
|
|
1232
|
-
return [{ type: undefined, decorators: [{
|
|
1233
|
-
type: Inject,
|
|
1234
|
-
args: ['CheckoutRepository']
|
|
1235
|
-
}] }, { type: undefined, decorators: [{
|
|
1236
|
-
type: Inject,
|
|
1237
|
-
args: ['UserRepository']
|
|
1238
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
1239
|
-
type: Inject,
|
|
1240
|
-
args: [DEFAULT_SHOP]
|
|
1241
|
-
}] }, { type: undefined, decorators: [{
|
|
1242
|
-
type: Inject,
|
|
1243
|
-
args: [PERSISTENCE_PROVIDER]
|
|
1244
|
-
}] }, { type: undefined, decorators: [{
|
|
1245
|
-
type: Inject,
|
|
1246
|
-
args: [FIREBASE_OPTIONS]
|
|
1247
|
-
}] }, { type: i1$2.HttpClient }];
|
|
1248
|
-
} });
|
|
1310
|
+
}], ctorParameters: function () { return [{ type: CheckoutRepositoriesFacade }, { type: CheckoutDependenciesFacade }, { type: ConfigurationFacade }]; } });
|
|
1249
1311
|
|
|
1250
|
-
class
|
|
1251
|
-
constructor(authService, checkoutService,
|
|
1312
|
+
class CartServicesFacade {
|
|
1313
|
+
constructor(authService, checkoutService, httpClient) {
|
|
1252
1314
|
this.authService = authService;
|
|
1253
1315
|
this.checkoutService = checkoutService;
|
|
1254
|
-
this.
|
|
1255
|
-
|
|
1256
|
-
|
|
1316
|
+
this.httpClient = httpClient;
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
CartServicesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartServicesFacade, deps: [{ token: AuthService }, { token: CheckoutService }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1320
|
+
CartServicesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartServicesFacade });
|
|
1321
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartServicesFacade, decorators: [{
|
|
1322
|
+
type: Injectable
|
|
1323
|
+
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.HttpClient }]; } });
|
|
1324
|
+
|
|
1325
|
+
class CartService {
|
|
1326
|
+
constructor(servicesFacade, configurationFacade) {
|
|
1327
|
+
this.servicesFacade = servicesFacade;
|
|
1328
|
+
this.configurationFacade = configurationFacade;
|
|
1257
1329
|
this.cartSubject = new Subject();
|
|
1258
1330
|
this.checkoutUrl = null;
|
|
1259
1331
|
this.generateCartObject = (items) => (items === null || items === void 0 ? void 0 : items.reduce((cart, item) => {
|
|
1260
1332
|
var _a;
|
|
1261
1333
|
return (Object.assign(Object.assign({}, cart), { [item.id]: LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })) }));
|
|
1262
1334
|
}, {})) || {};
|
|
1263
|
-
this.checkoutUrl =
|
|
1335
|
+
this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
|
|
1264
1336
|
}
|
|
1265
1337
|
addItem(item, quantity = 1) {
|
|
1266
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.
|
|
1338
|
+
return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutAddItemToCart`, {
|
|
1267
1339
|
checkoutId: checkout.id,
|
|
1268
1340
|
productId: item.id,
|
|
1269
1341
|
quantity,
|
|
1270
|
-
})), concatMap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1342
|
+
})), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1271
1343
|
}
|
|
1272
1344
|
decreaseItem(item) {
|
|
1273
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.
|
|
1345
|
+
return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutDecreaseProductFromCart`, {
|
|
1274
1346
|
checkoutId: checkout.id,
|
|
1275
1347
|
productId: item.id,
|
|
1276
1348
|
quantity: 1,
|
|
1277
|
-
})), concatMap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1349
|
+
})), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1278
1350
|
}
|
|
1279
1351
|
removeItem(item) {
|
|
1280
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.
|
|
1352
|
+
return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemoveProductFromCart`, {
|
|
1281
1353
|
checkoutId: checkout.id,
|
|
1282
1354
|
productId: item.id,
|
|
1283
|
-
})), concatMap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1355
|
+
})), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1284
1356
|
}
|
|
1285
1357
|
updateUserCart(user) {
|
|
1286
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
|
|
1287
|
-
return this.
|
|
1358
|
+
return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
|
|
1359
|
+
return this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutUpdateUserCart`, {
|
|
1288
1360
|
checkoutId: checkout.id,
|
|
1289
1361
|
});
|
|
1290
|
-
}), concatMap(() => this.checkoutService.getCheckout()), map((updatedCheckout) => {
|
|
1362
|
+
}), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => {
|
|
1291
1363
|
return this.generateCartObject(updatedCheckout.lineItems);
|
|
1292
1364
|
}), tap((cart) => this.cartSubject.next(cart)));
|
|
1293
1365
|
}
|
|
@@ -1296,28 +1368,20 @@ class CartService {
|
|
|
1296
1368
|
return this.cartSubject;
|
|
1297
1369
|
}
|
|
1298
1370
|
clearCart() {
|
|
1299
|
-
return this.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1300
|
-
this.checkoutService.clearCheckoutFromSession();
|
|
1371
|
+
return this.servicesFacade.checkoutService.getCheckout().pipe(map((checkout) => {
|
|
1372
|
+
this.servicesFacade.checkoutService.clearCheckoutFromSession();
|
|
1301
1373
|
return checkout;
|
|
1302
1374
|
}), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
|
|
1303
1375
|
}
|
|
1304
1376
|
buildCartFromCheckout(checkoutData) {
|
|
1305
|
-
return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1377
|
+
return this.servicesFacade.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
|
|
1306
1378
|
}
|
|
1307
1379
|
}
|
|
1308
|
-
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token:
|
|
1380
|
+
CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: CartServicesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1309
1381
|
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
|
|
1310
1382
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
|
|
1311
1383
|
type: Injectable
|
|
1312
|
-
}], ctorParameters: function () {
|
|
1313
|
-
return [{ type: AuthService }, { type: CheckoutService }, { type: i1$3.Shops, decorators: [{
|
|
1314
|
-
type: Inject,
|
|
1315
|
-
args: [DEFAULT_SHOP]
|
|
1316
|
-
}] }, { type: undefined, decorators: [{
|
|
1317
|
-
type: Inject,
|
|
1318
|
-
args: [FIREBASE_OPTIONS]
|
|
1319
|
-
}] }, { type: i1$2.HttpClient }];
|
|
1320
|
-
} });
|
|
1384
|
+
}], ctorParameters: function () { return [{ type: CartServicesFacade }, { type: ConfigurationFacade }]; } });
|
|
1321
1385
|
|
|
1322
1386
|
class NewCategoryStructureAdapter {
|
|
1323
1387
|
constructor(categoryRepository) {
|
|
@@ -1393,355 +1457,837 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1393
1457
|
}] }];
|
|
1394
1458
|
} });
|
|
1395
1459
|
|
|
1396
|
-
class
|
|
1397
|
-
constructor(
|
|
1398
|
-
this.
|
|
1399
|
-
this.
|
|
1400
|
-
this.
|
|
1401
|
-
this.
|
|
1402
|
-
this.
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
this.brandsList = {};
|
|
1406
|
-
this.fields = [
|
|
1407
|
-
'id',
|
|
1408
|
-
'name',
|
|
1409
|
-
'slug',
|
|
1410
|
-
'images',
|
|
1411
|
-
'miniatures',
|
|
1412
|
-
'price',
|
|
1413
|
-
'stock',
|
|
1414
|
-
'published',
|
|
1415
|
-
'CEST',
|
|
1416
|
-
'EAN',
|
|
1417
|
-
'NCM',
|
|
1418
|
-
'brand',
|
|
1419
|
-
'costPrice',
|
|
1420
|
-
'hasVariants',
|
|
1421
|
-
'isKit',
|
|
1422
|
-
'sku',
|
|
1423
|
-
'rate',
|
|
1424
|
-
'tags',
|
|
1425
|
-
'type',
|
|
1426
|
-
'shoppingCount',
|
|
1427
|
-
'gender',
|
|
1428
|
-
'createdAt',
|
|
1429
|
-
'label',
|
|
1430
|
-
'outlet',
|
|
1431
|
-
'group',
|
|
1432
|
-
];
|
|
1433
|
-
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1434
|
-
const filters = {};
|
|
1435
|
-
if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
|
|
1436
|
-
set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
|
|
1437
|
-
if (brands === null || brands === void 0 ? void 0 : brands.length)
|
|
1438
|
-
filters.brand = { operator: Where.IN, value: brands };
|
|
1439
|
-
if (gender === null || gender === void 0 ? void 0 : gender.length)
|
|
1440
|
-
filters.gender = { operator: Where.IN, value: gender };
|
|
1441
|
-
if ((prices === null || prices === void 0 ? void 0 : prices.min) || (prices === null || prices === void 0 ? void 0 : prices.max))
|
|
1442
|
-
set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
|
|
1443
|
-
...(prices.min ? [{ operator: Where.GTE, value: Math.floor(prices.min) }] : []),
|
|
1444
|
-
...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
|
|
1445
|
-
]);
|
|
1446
|
-
if (rate)
|
|
1447
|
-
filters.rate = { operator: Where.GTE, value: rate };
|
|
1448
|
-
if (tags === null || tags === void 0 ? void 0 : tags.length)
|
|
1449
|
-
filters.tags = { operator: Where.LIKE, value: tags };
|
|
1450
|
-
if (customOptions === null || customOptions === void 0 ? void 0 : customOptions.length)
|
|
1451
|
-
filters.filters = { operator: Where.LIKE, value: customOptions };
|
|
1452
|
-
return filters;
|
|
1453
|
-
};
|
|
1454
|
-
this.buildSortQuery = (sort) => {
|
|
1455
|
-
if (!sort || sort === 'most-relevant')
|
|
1456
|
-
return {};
|
|
1457
|
-
if (sort === 'best-sellers')
|
|
1458
|
-
return {
|
|
1459
|
-
shoppingCount: 'desc',
|
|
1460
|
-
rate: 'desc',
|
|
1461
|
-
stock: 'desc',
|
|
1462
|
-
name: 'asc',
|
|
1463
|
-
};
|
|
1464
|
-
if (sort === 'biggest-price')
|
|
1465
|
-
return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1466
|
-
if (sort === 'lowest-price')
|
|
1467
|
-
return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
|
|
1468
|
-
if (sort === 'best-rating')
|
|
1469
|
-
return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
|
|
1470
|
-
if (sort === 'news')
|
|
1471
|
-
return { createdAt: 'desc' };
|
|
1472
|
-
if (sort === 'biggest-discount')
|
|
1473
|
-
return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
|
|
1474
|
-
};
|
|
1475
|
-
this.buildLimitQuery = (options) => {
|
|
1476
|
-
const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
|
|
1477
|
-
return {
|
|
1478
|
-
limit,
|
|
1479
|
-
offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
|
|
1480
|
-
};
|
|
1481
|
-
};
|
|
1482
|
-
this.hasProfile = (options) => 'profile' in options;
|
|
1483
|
-
this.hasTerm = (options) => 'term' in options;
|
|
1484
|
-
this.hasCategory = (options) => 'category' in options;
|
|
1485
|
-
this.buildIndexBrands = (options) => {
|
|
1486
|
-
if (this.hasCategory(options))
|
|
1487
|
-
return `category-${options.category.id}`;
|
|
1488
|
-
if (this.hasTerm(options))
|
|
1489
|
-
return `term-${options.term}`;
|
|
1490
|
-
if (this.hasProfile(options))
|
|
1491
|
-
return `profile-${options.profile.join(',')}`;
|
|
1492
|
-
return '';
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
fetchProducts(options, optionsCache) {
|
|
1496
|
-
var _a, _b, _c;
|
|
1460
|
+
class CatalogSearchContext {
|
|
1461
|
+
constructor(categoryStrategy, termStrategy, profileStrategy) {
|
|
1462
|
+
this.categoryStrategy = categoryStrategy;
|
|
1463
|
+
this.termStrategy = termStrategy;
|
|
1464
|
+
this.profileStrategy = profileStrategy;
|
|
1465
|
+
this.strategies = new Map();
|
|
1466
|
+
this.initializeStrategies();
|
|
1467
|
+
}
|
|
1468
|
+
executeSearch(params, shop, optionsCache) {
|
|
1497
1469
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1498
|
-
const
|
|
1499
|
-
|
|
1500
|
-
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
1501
|
-
if (this.hasProfile(options) && ((_b = options.filters) === null || _b === void 0 ? void 0 : _b.tags))
|
|
1502
|
-
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1503
|
-
if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions))
|
|
1504
|
-
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1505
|
-
return yield this.findCatalog(options, limits, optionsCache).then(({ data, count: total, maximum, minimal, distinct }) => __awaiter(this, void 0, void 0, function* () {
|
|
1506
|
-
var _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1507
|
-
yield this.setBrandsList(options, distinct === null || distinct === void 0 ? void 0 : distinct.brand);
|
|
1508
|
-
return {
|
|
1509
|
-
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1510
|
-
pages: Math.ceil(total / limits.limit),
|
|
1511
|
-
prices: {
|
|
1512
|
-
price: { min: +((_e = (_d = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _d === void 0 ? void 0 : _d.price) === null || _e === void 0 ? void 0 : _e.toFixed(2)), max: +((_g = (_f = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _f === void 0 ? void 0 : _f.price) === null || _g === void 0 ? void 0 : _g.toFixed(2)) },
|
|
1513
|
-
subscriberPrice: {
|
|
1514
|
-
min: +((_j = (_h = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _h === void 0 ? void 0 : _h.subscriberPrice) === null || _j === void 0 ? void 0 : _j.toFixed(2)),
|
|
1515
|
-
max: +((_l = (_k = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _k === void 0 ? void 0 : _k.subscriberPrice) === null || _l === void 0 ? void 0 : _l.toFixed(2)),
|
|
1516
|
-
},
|
|
1517
|
-
},
|
|
1518
|
-
brands: this.brandsList[this.buildIndexBrands(options)],
|
|
1519
|
-
};
|
|
1520
|
-
}));
|
|
1470
|
+
const strategy = this.selectStrategy(params);
|
|
1471
|
+
return strategy.search(params, shop, optionsCache);
|
|
1521
1472
|
});
|
|
1522
1473
|
}
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1474
|
+
initializeStrategies() {
|
|
1475
|
+
this.strategies.set('category', this.categoryStrategy);
|
|
1476
|
+
this.strategies.set('term', this.termStrategy);
|
|
1477
|
+
this.strategies.set('profile', this.profileStrategy);
|
|
1527
1478
|
}
|
|
1528
|
-
|
|
1479
|
+
selectStrategy(params) {
|
|
1529
1480
|
var _a;
|
|
1481
|
+
if (params.category) {
|
|
1482
|
+
const strategy = this.strategies.get('category');
|
|
1483
|
+
if (!strategy)
|
|
1484
|
+
throw new Error('Category strategy not found');
|
|
1485
|
+
return strategy;
|
|
1486
|
+
}
|
|
1487
|
+
if (params.term) {
|
|
1488
|
+
const strategy = this.strategies.get('term');
|
|
1489
|
+
if (!strategy)
|
|
1490
|
+
throw new Error('Term strategy not found');
|
|
1491
|
+
return strategy;
|
|
1492
|
+
}
|
|
1493
|
+
if ((_a = params.profile) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1494
|
+
const strategy = this.strategies.get('profile');
|
|
1495
|
+
if (!strategy)
|
|
1496
|
+
throw new Error('Profile strategy not found');
|
|
1497
|
+
return strategy;
|
|
1498
|
+
}
|
|
1499
|
+
throw new Error('No valid search strategy found for the given parameters');
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
class CategorySearchStrategy {
|
|
1504
|
+
constructor(repositoryService, helpersService) {
|
|
1505
|
+
this.repositoryService = repositoryService;
|
|
1506
|
+
this.helpersService = helpersService;
|
|
1507
|
+
}
|
|
1508
|
+
search(params, shop, optionsCache) {
|
|
1530
1509
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1510
|
+
const { category, filters, limits, sort, mainGender } = params;
|
|
1511
|
+
if (!category) {
|
|
1512
|
+
throw new Error('Category is required for CategorySearchStrategy');
|
|
1534
1513
|
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1514
|
+
const fields = this.helpersService.getFieldsHelper().getStandardFields();
|
|
1515
|
+
if (sort === 'most-relevant') {
|
|
1516
|
+
return this.searchWithMostRelevant({
|
|
1517
|
+
category,
|
|
1518
|
+
filters,
|
|
1519
|
+
limits,
|
|
1520
|
+
shop,
|
|
1521
|
+
mainGender,
|
|
1522
|
+
optionsCache,
|
|
1523
|
+
fields,
|
|
1524
|
+
});
|
|
1544
1525
|
}
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1526
|
+
return this.searchDefault({
|
|
1527
|
+
category,
|
|
1528
|
+
filters,
|
|
1529
|
+
limits,
|
|
1530
|
+
shop,
|
|
1531
|
+
mainGender,
|
|
1532
|
+
sort,
|
|
1533
|
+
optionsCache,
|
|
1534
|
+
fields,
|
|
1535
|
+
});
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
searchWithMostRelevant(params) {
|
|
1539
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1540
|
+
const { category, filters, shop, optionsCache } = params;
|
|
1541
|
+
const mostRelevant = category.isWishlist ? [] : category.getMostRelevantByShop(shop);
|
|
1542
|
+
const productsIds = yield this.getProductIds(category, filters, optionsCache);
|
|
1543
|
+
return this.findAndSortByMostRelevant({
|
|
1544
|
+
mostRelevants: mostRelevant,
|
|
1545
|
+
productIds: productsIds,
|
|
1546
|
+
filters: params.filters,
|
|
1547
|
+
limits: params.limits,
|
|
1548
|
+
shop: params.shop,
|
|
1549
|
+
mainGender: params.mainGender,
|
|
1550
|
+
optionsCache: params.optionsCache,
|
|
1551
|
+
fields: params.fields,
|
|
1552
|
+
});
|
|
1551
1553
|
});
|
|
1552
1554
|
}
|
|
1553
|
-
|
|
1555
|
+
searchDefault(params) {
|
|
1554
1556
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1557
|
+
const { category, filters, limits, shop, mainGender, sort, optionsCache, fields } = params;
|
|
1558
|
+
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1559
|
+
const filterHelper = this.helpersService.getFilterHelper();
|
|
1560
|
+
const sortHelper = this.helpersService.getSortHelper();
|
|
1561
|
+
const repoParams = Object.assign(Object.assign({ fields, filters: Object.assign(Object.assign({}, (yield productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category))), filterHelper.buildFilterQuery(filters || {})) }, (sort ? { orderBy: sortHelper.buildSortQuery(sort) } : {})), { limits, options: {
|
|
1562
|
+
minimal: ['price'],
|
|
1563
|
+
maximum: ['price'],
|
|
1564
|
+
distinct: ['brand'],
|
|
1565
|
+
} });
|
|
1566
|
+
return productCatalog.productRepository.findCatalog(repoParams, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'), optionsCache);
|
|
1563
1567
|
});
|
|
1564
1568
|
}
|
|
1565
|
-
|
|
1566
|
-
|
|
1569
|
+
getProductIds(category, filters, optionsCache) {
|
|
1570
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1571
|
+
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1572
|
+
const filterHelper = this.helpersService.getFilterHelper();
|
|
1573
|
+
return productCatalog.productRepository
|
|
1574
|
+
.findCatalog({
|
|
1575
|
+
fields: ['id'],
|
|
1576
|
+
filters: Object.assign(Object.assign({}, (yield productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category))), filterHelper.buildFilterQuery(filters || {})),
|
|
1577
|
+
}, undefined, optionsCache)
|
|
1578
|
+
.then((products) => products.data.map((product) => product.id));
|
|
1579
|
+
});
|
|
1580
|
+
}
|
|
1581
|
+
findAndSortByMostRelevant(params) {
|
|
1567
1582
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1568
|
-
const
|
|
1583
|
+
const { mostRelevants, productIds, filters, shop, mainGender, optionsCache, fields, limits } = params;
|
|
1584
|
+
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1585
|
+
const filterHelper = this.helpersService.getFilterHelper();
|
|
1586
|
+
const sortHelper = this.helpersService.getSortHelper();
|
|
1569
1587
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1570
|
-
const totalResult = yield
|
|
1571
|
-
fields
|
|
1572
|
-
filters: Object.assign({ id: { operator: Where.IN, value: mostRelevantProductsIds } },
|
|
1573
|
-
orderBy:
|
|
1574
|
-
options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (
|
|
1575
|
-
},
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1588
|
+
const totalResult = yield productCatalog.productRepository.findCatalog({
|
|
1589
|
+
fields,
|
|
1590
|
+
filters: Object.assign({ id: { operator: Where.IN, value: mostRelevantProductsIds } }, filterHelper.buildFilterQuery(filters || {})),
|
|
1591
|
+
orderBy: sortHelper.buildSortQuery('best-sellers'),
|
|
1592
|
+
options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (isEmpty(filters === null || filters === void 0 ? void 0 : filters.brands) ? { distinct: ['brand'] } : {})),
|
|
1593
|
+
}, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'), optionsCache);
|
|
1594
|
+
return this.sortProductsByRelevance(totalResult, mostRelevants, limits);
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
sortProductsByRelevance(totalResult, mostRelevants, limits) {
|
|
1598
|
+
const mostRelevantWithoutStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1599
|
+
const firstProducts = totalResult.data
|
|
1600
|
+
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
1601
|
+
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
1602
|
+
const lastProducts = totalResult.data
|
|
1603
|
+
.filter((product) => !mostRelevants.includes(product.id))
|
|
1604
|
+
.concat(mostRelevantWithoutStock);
|
|
1605
|
+
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1606
|
+
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1607
|
+
return {
|
|
1608
|
+
data: resultFinal,
|
|
1609
|
+
count: totalResult.count,
|
|
1610
|
+
maximum: totalResult.maximum,
|
|
1611
|
+
minimal: totalResult.minimal,
|
|
1612
|
+
distinct: totalResult.distinct,
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
CategorySearchStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategorySearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1617
|
+
CategorySearchStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategorySearchStrategy });
|
|
1618
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategorySearchStrategy, decorators: [{
|
|
1619
|
+
type: Injectable
|
|
1620
|
+
}], ctorParameters: function () { return [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }]; } });
|
|
1621
|
+
|
|
1622
|
+
class ProfileSearchStrategy {
|
|
1623
|
+
constructor(repositoryService, helpersService) {
|
|
1624
|
+
this.repositoryService = repositoryService;
|
|
1625
|
+
this.helpersService = helpersService;
|
|
1626
|
+
}
|
|
1627
|
+
search(params, shop, optionsCache) {
|
|
1628
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1629
|
+
const { profile, filters, limits, sort, mainGender } = params;
|
|
1630
|
+
if (!profile) {
|
|
1631
|
+
throw new Error('Profile is required for ProfileSearchStrategy');
|
|
1632
|
+
}
|
|
1633
|
+
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1634
|
+
const filterHelper = this.helpersService.getFilterHelper();
|
|
1635
|
+
const sortHelper = this.helpersService.getSortHelper();
|
|
1636
|
+
const fieldsHelper = this.helpersService.getFieldsHelper();
|
|
1637
|
+
const repoParams = Object.assign(Object.assign({ fields: fieldsHelper.getStandardFields(), filters: Object.assign({ tags: { operator: Where.LIKE, value: profile } }, filterHelper.buildFilterQuery(filters || {})) }, (sort ? { orderBy: sortHelper.buildSortQuery(sort) } : {})), { limits, options: {
|
|
1638
|
+
minimal: ['price'],
|
|
1639
|
+
maximum: ['price'],
|
|
1640
|
+
distinct: ['brand'],
|
|
1641
|
+
} });
|
|
1642
|
+
return productCatalog.productRepository.findCatalog(repoParams, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'), optionsCache);
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
ProfileSearchStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProfileSearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1647
|
+
ProfileSearchStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProfileSearchStrategy });
|
|
1648
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProfileSearchStrategy, decorators: [{
|
|
1649
|
+
type: Injectable
|
|
1650
|
+
}], ctorParameters: function () { return [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }]; } });
|
|
1651
|
+
|
|
1652
|
+
class TermSearchStrategy {
|
|
1653
|
+
constructor(repositoryService, helpersService) {
|
|
1654
|
+
this.repositoryService = repositoryService;
|
|
1655
|
+
this.helpersService = helpersService;
|
|
1656
|
+
this.productsByTerm = {};
|
|
1657
|
+
}
|
|
1658
|
+
search(params, shop, _optionsCache) {
|
|
1659
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1660
|
+
const { term, filters, limits, sort, mainGender } = params;
|
|
1661
|
+
if (!term) {
|
|
1662
|
+
throw new Error('Term is required for TermSearchStrategy');
|
|
1663
|
+
}
|
|
1664
|
+
const productIds = yield this.findCatalogIdsBySearch(term, shop);
|
|
1665
|
+
if (sort === 'most-relevant') {
|
|
1666
|
+
return this.searchWithMostRelevant({
|
|
1667
|
+
productIds,
|
|
1668
|
+
filters,
|
|
1669
|
+
limits,
|
|
1670
|
+
shop,
|
|
1671
|
+
mainGender,
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
return this.searchDefault({
|
|
1675
|
+
productIds,
|
|
1676
|
+
filters,
|
|
1677
|
+
limits,
|
|
1678
|
+
shop,
|
|
1679
|
+
mainGender,
|
|
1680
|
+
fields: this.helpersService.getFieldsHelper().getStandardFields(),
|
|
1681
|
+
});
|
|
1593
1682
|
});
|
|
1594
1683
|
}
|
|
1595
|
-
|
|
1596
|
-
var _a, _b, _c, _d;
|
|
1684
|
+
searchWithMostRelevant(params) {
|
|
1597
1685
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1598
|
-
const
|
|
1599
|
-
const
|
|
1686
|
+
const { productIds, filters, shop, mainGender } = params;
|
|
1687
|
+
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1688
|
+
const filterHelper = this.helpersService.getFilterHelper();
|
|
1689
|
+
const totalResult = yield productCatalog.productRepository.findCatalog({
|
|
1600
1690
|
fields: ['id', 'stock', 'gender'],
|
|
1601
|
-
filters: Object.assign({ id: { operator: Where.IN, value: productIds }, published: { operator: Where.EQUALS, value: true } },
|
|
1602
|
-
options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (
|
|
1603
|
-
},
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
const
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1691
|
+
filters: Object.assign({ id: { operator: Where.IN, value: productIds }, published: { operator: Where.EQUALS, value: true } }, filterHelper.buildFilterQuery(filters || {})),
|
|
1692
|
+
options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (isEmpty(filters === null || filters === void 0 ? void 0 : filters.brands) ? { distinct: ['brand'] } : {})),
|
|
1693
|
+
}, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'));
|
|
1694
|
+
return this.sortByTermRelevance({
|
|
1695
|
+
productIds,
|
|
1696
|
+
totalResult,
|
|
1697
|
+
limits: params.limits,
|
|
1698
|
+
filters,
|
|
1699
|
+
fieldsHelper: this.helpersService.getFieldsHelper(),
|
|
1700
|
+
});
|
|
1701
|
+
});
|
|
1702
|
+
}
|
|
1703
|
+
searchDefault(params) {
|
|
1704
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1705
|
+
const { productIds, filters, limits, shop, mainGender, fields } = params;
|
|
1706
|
+
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1707
|
+
const filterHelper = this.helpersService.getFilterHelper();
|
|
1708
|
+
return productCatalog.productRepository.findCatalog({
|
|
1709
|
+
fields,
|
|
1710
|
+
filters: Object.assign({ id: { operator: Where.IN, value: productIds }, published: { operator: Where.EQUALS, value: true } }, filterHelper.buildFilterQuery(filters || {})),
|
|
1711
|
+
limits,
|
|
1712
|
+
options: {
|
|
1713
|
+
minimal: ['price'],
|
|
1714
|
+
maximum: ['price'],
|
|
1715
|
+
distinct: ['brand'],
|
|
1716
|
+
},
|
|
1717
|
+
}, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'));
|
|
1718
|
+
});
|
|
1719
|
+
}
|
|
1720
|
+
sortByTermRelevance(params) {
|
|
1721
|
+
var _a;
|
|
1722
|
+
const { productIds, totalResult, limits, filters, fieldsHelper } = params;
|
|
1723
|
+
const defaultGender = ((_a = filters === null || filters === void 0 ? void 0 : filters.gender) === null || _a === void 0 ? void 0 : _a.at(0)) || 'male';
|
|
1724
|
+
const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
|
|
1725
|
+
const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
|
|
1726
|
+
const productIdsStockGender = productIds.filter((product) => stockData.some((result) => { var _a, _b; return result.id === product && (((_a = result.gender) === null || _a === void 0 ? void 0 : _a.includes(defaultGender)) || ((_b = result.gender) === null || _b === void 0 ? void 0 : _b.includes('unisex'))); }));
|
|
1727
|
+
const productIdsStockNotGender = productIds.filter((product) => stockData.some((result) => { var _a, _b; return result.id === product && !((_a = result.gender) === null || _a === void 0 ? void 0 : _a.includes(defaultGender)) && !((_b = result.gender) === null || _b === void 0 ? void 0 : _b.includes('unisex')); }));
|
|
1728
|
+
const productIdsStock = productIdsStockGender.concat(productIdsStockNotGender);
|
|
1729
|
+
const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id === product));
|
|
1730
|
+
const limitedProductId = productIdsStock
|
|
1731
|
+
.concat(productIdsStockOut)
|
|
1732
|
+
.slice(limits.offset, limits.offset + limits.limit);
|
|
1733
|
+
const orderedId = productIds.filter((product) => limitedProductId.includes(product));
|
|
1734
|
+
return this.getDetailedProducts(orderedId, totalResult, fieldsHelper);
|
|
1735
|
+
}
|
|
1736
|
+
getDetailedProducts(orderedId, totalResult, fieldsHelper) {
|
|
1737
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1738
|
+
const productCatalog = this.repositoryService.getProductCatalog();
|
|
1739
|
+
const fields = fieldsHelper.getStandardFields();
|
|
1740
|
+
const productResult = yield productCatalog.productRepository.findCatalog({
|
|
1620
1741
|
filters: {
|
|
1621
1742
|
id: { operator: Where.IN, value: orderedId },
|
|
1622
1743
|
},
|
|
1623
|
-
fields
|
|
1744
|
+
fields,
|
|
1624
1745
|
});
|
|
1625
|
-
yield this.setBrandsList(options, (_d = totalResult.distinct) === null || _d === void 0 ? void 0 : _d.brand);
|
|
1626
1746
|
return {
|
|
1627
|
-
data:
|
|
1747
|
+
data: orderedId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1628
1748
|
count: totalResult.count,
|
|
1629
1749
|
maximum: totalResult.maximum,
|
|
1630
1750
|
minimal: totalResult.minimal,
|
|
1631
|
-
distinct:
|
|
1751
|
+
distinct: totalResult.distinct,
|
|
1632
1752
|
};
|
|
1633
1753
|
});
|
|
1634
1754
|
}
|
|
1635
|
-
findCatalogIdsBySearch(term,
|
|
1755
|
+
findCatalogIdsBySearch(term, shop) {
|
|
1636
1756
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1637
1757
|
if (this.productsByTerm[term])
|
|
1638
1758
|
return this.productsByTerm[term];
|
|
1639
|
-
|
|
1640
|
-
|
|
1759
|
+
const productServices = this.repositoryService.getProductServices();
|
|
1760
|
+
return (this.productsByTerm[term] = yield productServices.productSearch
|
|
1761
|
+
.search(term, 999, shop === Shops.GLAMSHOP ? 'female' : 'male')
|
|
1641
1762
|
.then((products) => [...new Set(products.map((product) => product.id))]));
|
|
1642
1763
|
});
|
|
1643
1764
|
}
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
});
|
|
1657
|
-
});
|
|
1765
|
+
}
|
|
1766
|
+
TermSearchStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: TermSearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1767
|
+
TermSearchStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: TermSearchStrategy });
|
|
1768
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: TermSearchStrategy, decorators: [{
|
|
1769
|
+
type: Injectable
|
|
1770
|
+
}], ctorParameters: function () { return [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }]; } });
|
|
1771
|
+
|
|
1772
|
+
class CatalogStrategiesFacade {
|
|
1773
|
+
constructor(categoryStrategy, termStrategy, profileStrategy) {
|
|
1774
|
+
this.categoryStrategy = categoryStrategy;
|
|
1775
|
+
this.termStrategy = termStrategy;
|
|
1776
|
+
this.profileStrategy = profileStrategy;
|
|
1658
1777
|
}
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1778
|
+
}
|
|
1779
|
+
CatalogStrategiesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogStrategiesFacade, deps: [{ token: CategorySearchStrategy }, { token: TermSearchStrategy }, { token: ProfileSearchStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1780
|
+
CatalogStrategiesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogStrategiesFacade });
|
|
1781
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogStrategiesFacade, decorators: [{
|
|
1782
|
+
type: Injectable
|
|
1783
|
+
}], ctorParameters: function () { return [{ type: CategorySearchStrategy }, { type: TermSearchStrategy }, { type: ProfileSearchStrategy }]; } });
|
|
1784
|
+
|
|
1785
|
+
class CatalogServiceFacade {
|
|
1786
|
+
constructor(helpersService, strategiesFacade, shop) {
|
|
1787
|
+
this.helpersService = helpersService;
|
|
1788
|
+
this.strategiesFacade = strategiesFacade;
|
|
1789
|
+
this.shop = shop;
|
|
1790
|
+
const searchContext = new CatalogSearchContext(this.strategiesFacade.categoryStrategy, this.strategiesFacade.termStrategy, this.strategiesFacade.profileStrategy);
|
|
1791
|
+
this.catalogService = new CatalogService(searchContext, this.helpersService, this.shop);
|
|
1792
|
+
}
|
|
1793
|
+
getCatalogService() {
|
|
1794
|
+
return this.catalogService;
|
|
1670
1795
|
}
|
|
1671
1796
|
}
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type:
|
|
1797
|
+
CatalogServiceFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogServiceFacade, deps: [{ token: CatalogHelpersService }, { token: CatalogStrategiesFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1798
|
+
CatalogServiceFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogServiceFacade });
|
|
1799
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogServiceFacade, decorators: [{
|
|
1675
1800
|
type: Injectable
|
|
1676
1801
|
}], ctorParameters: function () {
|
|
1677
|
-
return [{ type:
|
|
1802
|
+
return [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type: i3.Shops, decorators: [{
|
|
1678
1803
|
type: Inject,
|
|
1679
|
-
args: [
|
|
1680
|
-
}] }
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1804
|
+
args: [DEFAULT_SHOP]
|
|
1805
|
+
}] }];
|
|
1806
|
+
} });
|
|
1807
|
+
|
|
1808
|
+
class CategoryRepositoryFacade {
|
|
1809
|
+
constructor(categoryRepository, categoryFilterRepository) {
|
|
1810
|
+
this.categoryRepository = categoryRepository;
|
|
1811
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
CategoryRepositoryFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryRepositoryFacade, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1815
|
+
CategoryRepositoryFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryRepositoryFacade });
|
|
1816
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryRepositoryFacade, decorators: [{
|
|
1817
|
+
type: Injectable
|
|
1818
|
+
}], ctorParameters: function () {
|
|
1819
|
+
return [{ type: undefined, decorators: [{
|
|
1684
1820
|
type: Inject,
|
|
1685
1821
|
args: ['CategoryRepository']
|
|
1686
1822
|
}] }, { type: undefined, decorators: [{
|
|
1687
1823
|
type: Inject,
|
|
1688
|
-
args: [
|
|
1689
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
1690
|
-
type: Inject,
|
|
1691
|
-
args: [DEFAULT_SHOP]
|
|
1692
|
-
}] }, { type: undefined, decorators: [{
|
|
1693
|
-
type: Inject,
|
|
1694
|
-
args: ['ProductSearch']
|
|
1824
|
+
args: ['CategoryFilterRepository']
|
|
1695
1825
|
}] }];
|
|
1696
1826
|
} });
|
|
1697
1827
|
|
|
1698
1828
|
class CategoryService {
|
|
1699
|
-
constructor(
|
|
1700
|
-
this.
|
|
1701
|
-
this.
|
|
1702
|
-
this.categoryFilterRepository = categoryFilterRepository;
|
|
1703
|
-
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1829
|
+
constructor(categoryFacade, productCatalog, shop) {
|
|
1830
|
+
this.categoryFacade = categoryFacade;
|
|
1831
|
+
this.productCatalog = productCatalog;
|
|
1704
1832
|
this.shop = shop;
|
|
1705
1833
|
}
|
|
1706
1834
|
fetchBrands(category, options, optionsCache) {
|
|
1707
1835
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1708
|
-
const brands = yield this.productRepository
|
|
1836
|
+
const brands = yield this.productCatalog.productRepository
|
|
1709
1837
|
.findCatalog({
|
|
1710
|
-
filters: yield this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1838
|
+
filters: yield this.productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1711
1839
|
fields: ['brand'],
|
|
1712
1840
|
}, (options === null || options === void 0 ? void 0 : options.mainGender) ? options === null || options === void 0 ? void 0 : options.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache)
|
|
1713
1841
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => (Object.assign(Object.assign({}, brands), { [brand]: true })), {})));
|
|
1714
|
-
return this.categoryRepository
|
|
1842
|
+
return this.categoryFacade.categoryRepository
|
|
1715
1843
|
.find({ filters: { brandCategory: true, shop: (options === null || options === void 0 ? void 0 : options.shop) || this.shop }, orderBy: { name: 'asc' } }, optionsCache)
|
|
1716
1844
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1717
1845
|
});
|
|
1718
1846
|
}
|
|
1719
1847
|
fetchFilterOptions(category, optionsCache) {
|
|
1720
1848
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1721
|
-
return yield this.categoryFilterRepository
|
|
1849
|
+
return yield this.categoryFacade.categoryFilterRepository
|
|
1722
1850
|
.find({ filters: { categoryId: +category.id } }, optionsCache)
|
|
1723
1851
|
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1724
1852
|
});
|
|
1725
1853
|
}
|
|
1726
1854
|
}
|
|
1727
|
-
CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token:
|
|
1855
|
+
CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: CategoryRepositoryFacade }, { token: ProductCatalogFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1728
1856
|
CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
|
|
1729
1857
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
|
|
1730
1858
|
type: Injectable
|
|
1731
1859
|
}], ctorParameters: function () {
|
|
1732
|
-
return [{ type:
|
|
1860
|
+
return [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
|
|
1733
1861
|
type: Inject,
|
|
1734
|
-
args: [
|
|
1735
|
-
}] }
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1862
|
+
args: [DEFAULT_SHOP]
|
|
1863
|
+
}] }];
|
|
1864
|
+
} });
|
|
1865
|
+
|
|
1866
|
+
class ProductCatalogFacade {
|
|
1867
|
+
constructor(productRepository, categoryStructureAdapter) {
|
|
1868
|
+
this.productRepository = productRepository;
|
|
1869
|
+
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1870
|
+
}
|
|
1871
|
+
}
|
|
1872
|
+
ProductCatalogFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductCatalogFacade, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1873
|
+
ProductCatalogFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductCatalogFacade });
|
|
1874
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductCatalogFacade, decorators: [{
|
|
1875
|
+
type: Injectable
|
|
1876
|
+
}], ctorParameters: function () {
|
|
1877
|
+
return [{ type: undefined, decorators: [{
|
|
1739
1878
|
type: Inject,
|
|
1740
|
-
args: ['
|
|
1879
|
+
args: ['ProductRepository']
|
|
1741
1880
|
}] }, { type: undefined, decorators: [{
|
|
1742
1881
|
type: Inject,
|
|
1743
1882
|
args: [CATEGORY_STRUCTURE]
|
|
1744
|
-
}] }
|
|
1883
|
+
}] }];
|
|
1884
|
+
} });
|
|
1885
|
+
|
|
1886
|
+
class CategoryServiceFacade {
|
|
1887
|
+
constructor(categoryRepositoryFacade, productCatalogFacade, shop) {
|
|
1888
|
+
this.categoryRepositoryFacade = categoryRepositoryFacade;
|
|
1889
|
+
this.productCatalogFacade = productCatalogFacade;
|
|
1890
|
+
this.shop = shop;
|
|
1891
|
+
this.categoryService = new CategoryService(this.categoryRepositoryFacade, this.productCatalogFacade, this.shop);
|
|
1892
|
+
}
|
|
1893
|
+
getCategoryService() {
|
|
1894
|
+
return this.categoryService;
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
CategoryServiceFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryServiceFacade, deps: [{ token: CategoryRepositoryFacade }, { token: ProductCatalogFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1898
|
+
CategoryServiceFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryServiceFacade });
|
|
1899
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryServiceFacade, decorators: [{
|
|
1900
|
+
type: Injectable
|
|
1901
|
+
}], ctorParameters: function () {
|
|
1902
|
+
return [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
|
|
1903
|
+
type: Inject,
|
|
1904
|
+
args: [DEFAULT_SHOP]
|
|
1905
|
+
}] }];
|
|
1906
|
+
} });
|
|
1907
|
+
|
|
1908
|
+
class BrandManagerHelper {
|
|
1909
|
+
constructor(productCatalog) {
|
|
1910
|
+
this.productCatalog = productCatalog;
|
|
1911
|
+
this.brandsList = {};
|
|
1912
|
+
}
|
|
1913
|
+
setBrandsList(options, brands) {
|
|
1914
|
+
var _a;
|
|
1915
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1916
|
+
const filterBrands = (_a = options.filters) === null || _a === void 0 ? void 0 : _a.brands;
|
|
1917
|
+
const indexKey = this.buildIndexBrands(options);
|
|
1918
|
+
if (isEmpty(brands) && options.filters) {
|
|
1919
|
+
delete options.filters.brands;
|
|
1920
|
+
}
|
|
1921
|
+
this.brandsList[indexKey] = this.brandsList[indexKey] || brands || (yield this.fetchBrandsOnly(options));
|
|
1922
|
+
this.brandsList[indexKey] = this.brandsList[indexKey].filter(Boolean);
|
|
1923
|
+
if (options.filters) {
|
|
1924
|
+
options.filters = Object.assign(Object.assign({}, options.filters), { brands: filterBrands });
|
|
1925
|
+
}
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
getBrandsList(indexKey) {
|
|
1929
|
+
return this.brandsList[indexKey];
|
|
1930
|
+
}
|
|
1931
|
+
buildIndexBrands(options) {
|
|
1932
|
+
if (options.category)
|
|
1933
|
+
return `category-${options.category.id}`;
|
|
1934
|
+
if (options.term)
|
|
1935
|
+
return `term-${options.term}`;
|
|
1936
|
+
if (options.profile)
|
|
1937
|
+
return `profile-${options.profile.join(',')}`;
|
|
1938
|
+
return '';
|
|
1939
|
+
}
|
|
1940
|
+
fetchBrandsOnly(options) {
|
|
1941
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1942
|
+
return this.productCatalog.productRepository
|
|
1943
|
+
.findCatalog({
|
|
1944
|
+
fields: ['id'],
|
|
1945
|
+
filters: {
|
|
1946
|
+
published: { operator: Where.EQUALS, value: true },
|
|
1947
|
+
},
|
|
1948
|
+
options: {
|
|
1949
|
+
distinct: ['brand'],
|
|
1950
|
+
},
|
|
1951
|
+
}, options.mainGender)
|
|
1952
|
+
.then((result) => result.distinct.brand);
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
}
|
|
1956
|
+
BrandManagerHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BrandManagerHelper, deps: [{ token: ProductCatalogFacade }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1957
|
+
BrandManagerHelper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BrandManagerHelper });
|
|
1958
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BrandManagerHelper, decorators: [{
|
|
1959
|
+
type: Injectable
|
|
1960
|
+
}], ctorParameters: function () { return [{ type: ProductCatalogFacade }]; } });
|
|
1961
|
+
|
|
1962
|
+
class CatalogFilterHelper {
|
|
1963
|
+
buildFilterQuery(filters) {
|
|
1964
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1965
|
+
const filterQuery = {};
|
|
1966
|
+
if ((_a = filters.clubDiscount) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1967
|
+
set(filterQuery, 'price.subscriberDiscountPercentage', {
|
|
1968
|
+
operator: Where.IN,
|
|
1969
|
+
value: filters.clubDiscount,
|
|
1970
|
+
});
|
|
1971
|
+
}
|
|
1972
|
+
if ((_b = filters.brands) === null || _b === void 0 ? void 0 : _b.length) {
|
|
1973
|
+
filterQuery.brand = { operator: Where.IN, value: filters.brands };
|
|
1974
|
+
}
|
|
1975
|
+
if ((_c = filters.gender) === null || _c === void 0 ? void 0 : _c.length) {
|
|
1976
|
+
filterQuery.gender = { operator: Where.IN, value: filters.gender };
|
|
1977
|
+
}
|
|
1978
|
+
if (((_d = filters.prices) === null || _d === void 0 ? void 0 : _d.min) || ((_e = filters.prices) === null || _e === void 0 ? void 0 : _e.max)) {
|
|
1979
|
+
const priceField = filters.prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price';
|
|
1980
|
+
const priceFilters = [
|
|
1981
|
+
...(filters.prices.min ? [{ operator: Where.GTE, value: Math.floor(filters.prices.min) }] : []),
|
|
1982
|
+
...(filters.prices.max ? [{ operator: Where.LTE, value: Math.ceil(filters.prices.max) }] : []),
|
|
1983
|
+
];
|
|
1984
|
+
set(filterQuery, priceField, priceFilters);
|
|
1985
|
+
}
|
|
1986
|
+
if (filters.rate) {
|
|
1987
|
+
filterQuery.rate = { operator: Where.GTE, value: filters.rate };
|
|
1988
|
+
}
|
|
1989
|
+
if ((_f = filters.tags) === null || _f === void 0 ? void 0 : _f.length) {
|
|
1990
|
+
filterQuery.tags = { operator: Where.LIKE, value: filters.tags };
|
|
1991
|
+
}
|
|
1992
|
+
if ((_g = filters.customOptions) === null || _g === void 0 ? void 0 : _g.length) {
|
|
1993
|
+
filterQuery.filters = { operator: Where.LIKE, value: filters.customOptions };
|
|
1994
|
+
}
|
|
1995
|
+
return filterQuery;
|
|
1996
|
+
}
|
|
1997
|
+
}
|
|
1998
|
+
CatalogFilterHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogFilterHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1999
|
+
CatalogFilterHelper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogFilterHelper });
|
|
2000
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogFilterHelper, decorators: [{
|
|
2001
|
+
type: Injectable
|
|
2002
|
+
}] });
|
|
2003
|
+
|
|
2004
|
+
class CatalogSortHelper {
|
|
2005
|
+
buildSortQuery(sort) {
|
|
2006
|
+
if (!sort || sort === 'most-relevant')
|
|
2007
|
+
return {};
|
|
2008
|
+
switch (sort) {
|
|
2009
|
+
case 'best-sellers':
|
|
2010
|
+
return {
|
|
2011
|
+
shoppingCount: 'desc',
|
|
2012
|
+
rate: 'desc',
|
|
2013
|
+
stock: 'desc',
|
|
2014
|
+
name: 'asc',
|
|
2015
|
+
};
|
|
2016
|
+
case 'biggest-price':
|
|
2017
|
+
return {
|
|
2018
|
+
subscriberPrice: 'desc',
|
|
2019
|
+
rate: 'desc',
|
|
2020
|
+
shoppingCount: 'desc',
|
|
2021
|
+
};
|
|
2022
|
+
case 'lowest-price':
|
|
2023
|
+
return {
|
|
2024
|
+
subscriberPrice: 'asc',
|
|
2025
|
+
rate: 'desc',
|
|
2026
|
+
shoppingCount: 'desc',
|
|
2027
|
+
};
|
|
2028
|
+
case 'best-rating':
|
|
2029
|
+
return {
|
|
2030
|
+
rate: 'desc',
|
|
2031
|
+
shoppingCount: 'desc',
|
|
2032
|
+
stock: 'desc',
|
|
2033
|
+
name: 'asc',
|
|
2034
|
+
};
|
|
2035
|
+
case 'news':
|
|
2036
|
+
return { createdAt: 'desc' };
|
|
2037
|
+
case 'biggest-discount':
|
|
2038
|
+
return {
|
|
2039
|
+
subscriberDiscountPercentage: 'desc',
|
|
2040
|
+
rate: 'desc',
|
|
2041
|
+
shoppingCount: 'desc',
|
|
2042
|
+
};
|
|
2043
|
+
default:
|
|
2044
|
+
return {};
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
}
|
|
2048
|
+
CatalogSortHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogSortHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2049
|
+
CatalogSortHelper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogSortHelper });
|
|
2050
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogSortHelper, decorators: [{
|
|
2051
|
+
type: Injectable
|
|
2052
|
+
}] });
|
|
2053
|
+
|
|
2054
|
+
class ProductFieldsHelper {
|
|
2055
|
+
getStandardFields() {
|
|
2056
|
+
return [
|
|
2057
|
+
'id',
|
|
2058
|
+
'name',
|
|
2059
|
+
'slug',
|
|
2060
|
+
'images',
|
|
2061
|
+
'miniatures',
|
|
2062
|
+
'price',
|
|
2063
|
+
'stock',
|
|
2064
|
+
'published',
|
|
2065
|
+
'CEST',
|
|
2066
|
+
'EAN',
|
|
2067
|
+
'NCM',
|
|
2068
|
+
'brand',
|
|
2069
|
+
'costPrice',
|
|
2070
|
+
'hasVariants',
|
|
2071
|
+
'isKit',
|
|
2072
|
+
'sku',
|
|
2073
|
+
'rate',
|
|
2074
|
+
'tags',
|
|
2075
|
+
'type',
|
|
2076
|
+
'shoppingCount',
|
|
2077
|
+
'gender',
|
|
2078
|
+
'createdAt',
|
|
2079
|
+
'label',
|
|
2080
|
+
'outlet',
|
|
2081
|
+
'group',
|
|
2082
|
+
];
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
ProductFieldsHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductFieldsHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2086
|
+
ProductFieldsHelper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductFieldsHelper });
|
|
2087
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductFieldsHelper, decorators: [{
|
|
2088
|
+
type: Injectable
|
|
2089
|
+
}] });
|
|
2090
|
+
|
|
2091
|
+
class CatalogOperationsFacade {
|
|
2092
|
+
constructor(filterHelper, sortHelper, fieldsHelper) {
|
|
2093
|
+
this.filterHelper = filterHelper;
|
|
2094
|
+
this.sortHelper = sortHelper;
|
|
2095
|
+
this.fieldsHelper = fieldsHelper;
|
|
2096
|
+
}
|
|
2097
|
+
getFilterHelper() {
|
|
2098
|
+
return this.filterHelper;
|
|
2099
|
+
}
|
|
2100
|
+
getSortHelper() {
|
|
2101
|
+
return this.sortHelper;
|
|
2102
|
+
}
|
|
2103
|
+
getFieldsHelper() {
|
|
2104
|
+
return this.fieldsHelper;
|
|
2105
|
+
}
|
|
2106
|
+
}
|
|
2107
|
+
CatalogOperationsFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogOperationsFacade, deps: [{ token: CatalogFilterHelper }, { token: CatalogSortHelper }, { token: ProductFieldsHelper }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2108
|
+
CatalogOperationsFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogOperationsFacade });
|
|
2109
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogOperationsFacade, decorators: [{
|
|
2110
|
+
type: Injectable
|
|
2111
|
+
}], ctorParameters: function () { return [{ type: CatalogFilterHelper }, { type: CatalogSortHelper }, { type: ProductFieldsHelper }]; } });
|
|
2112
|
+
|
|
2113
|
+
class ProductManagementFacade {
|
|
2114
|
+
constructor(brandManager, productServices) {
|
|
2115
|
+
this.brandManager = brandManager;
|
|
2116
|
+
this.productServices = productServices;
|
|
2117
|
+
}
|
|
2118
|
+
getBrandManager() {
|
|
2119
|
+
return this.brandManager;
|
|
2120
|
+
}
|
|
2121
|
+
getProductServices() {
|
|
2122
|
+
return this.productServices;
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
ProductManagementFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductManagementFacade, deps: [{ token: BrandManagerHelper }, { token: 'ProductServicesFacade' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2126
|
+
ProductManagementFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductManagementFacade });
|
|
2127
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductManagementFacade, decorators: [{
|
|
2128
|
+
type: Injectable
|
|
2129
|
+
}], ctorParameters: function () {
|
|
2130
|
+
return [{ type: BrandManagerHelper }, { type: undefined, decorators: [{
|
|
2131
|
+
type: Inject,
|
|
2132
|
+
args: ['ProductServicesFacade']
|
|
2133
|
+
}] }];
|
|
2134
|
+
} });
|
|
2135
|
+
|
|
2136
|
+
class CatalogHelpersService {
|
|
2137
|
+
constructor(catalogOperations, productManagement) {
|
|
2138
|
+
this.catalogOperations = catalogOperations;
|
|
2139
|
+
this.productManagement = productManagement;
|
|
2140
|
+
}
|
|
2141
|
+
getFilterHelper() {
|
|
2142
|
+
return this.catalogOperations.getFilterHelper();
|
|
2143
|
+
}
|
|
2144
|
+
getSortHelper() {
|
|
2145
|
+
return this.catalogOperations.getSortHelper();
|
|
2146
|
+
}
|
|
2147
|
+
getFieldsHelper() {
|
|
2148
|
+
return this.catalogOperations.getFieldsHelper();
|
|
2149
|
+
}
|
|
2150
|
+
getBrandManager() {
|
|
2151
|
+
return this.productManagement.getBrandManager();
|
|
2152
|
+
}
|
|
2153
|
+
getProductServices() {
|
|
2154
|
+
return this.productManagement.getProductServices();
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
CatalogHelpersService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogHelpersService, deps: [{ token: CatalogOperationsFacade }, { token: ProductManagementFacade }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2158
|
+
CatalogHelpersService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogHelpersService });
|
|
2159
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogHelpersService, decorators: [{
|
|
2160
|
+
type: Injectable
|
|
2161
|
+
}], ctorParameters: function () { return [{ type: CatalogOperationsFacade }, { type: ProductManagementFacade }]; } });
|
|
2162
|
+
|
|
2163
|
+
class CatalogRepositoryService {
|
|
2164
|
+
constructor(productCatalog, productServices) {
|
|
2165
|
+
this.productCatalog = productCatalog;
|
|
2166
|
+
this.productServices = productServices;
|
|
2167
|
+
}
|
|
2168
|
+
getProductCatalog() {
|
|
2169
|
+
return this.productCatalog;
|
|
2170
|
+
}
|
|
2171
|
+
getProductServices() {
|
|
2172
|
+
return this.productServices;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
CatalogRepositoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogRepositoryService, deps: [{ token: ProductCatalogFacade }, { token: 'ProductServicesFacade' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2176
|
+
CatalogRepositoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogRepositoryService });
|
|
2177
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogRepositoryService, decorators: [{
|
|
2178
|
+
type: Injectable
|
|
2179
|
+
}], ctorParameters: function () {
|
|
2180
|
+
return [{ type: ProductCatalogFacade }, { type: undefined, decorators: [{
|
|
2181
|
+
type: Inject,
|
|
2182
|
+
args: ['ProductServicesFacade']
|
|
2183
|
+
}] }];
|
|
2184
|
+
} });
|
|
2185
|
+
|
|
2186
|
+
class CatalogService {
|
|
2187
|
+
constructor(searchContext, helpersService, shop) {
|
|
2188
|
+
this.searchContext = searchContext;
|
|
2189
|
+
this.helpersService = helpersService;
|
|
2190
|
+
this.shop = shop;
|
|
2191
|
+
}
|
|
2192
|
+
fetchProducts(options, optionsCache) {
|
|
2193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2194
|
+
this.validateRequest(options);
|
|
2195
|
+
const searchParams = this.buildSearchParams(options);
|
|
2196
|
+
const { data, count: total, maximum, minimal, distinct, } = yield this.searchContext.executeSearch(searchParams, this.shop, optionsCache);
|
|
2197
|
+
yield this.helpersService.getBrandManager().setBrandsList(searchParams, distinct === null || distinct === void 0 ? void 0 : distinct.brand);
|
|
2198
|
+
return this.buildResponse({
|
|
2199
|
+
data,
|
|
2200
|
+
total,
|
|
2201
|
+
maximum,
|
|
2202
|
+
minimal,
|
|
2203
|
+
searchParams,
|
|
2204
|
+
options,
|
|
2205
|
+
});
|
|
2206
|
+
});
|
|
2207
|
+
}
|
|
2208
|
+
addCustomerToStockNotification(params) {
|
|
2209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2210
|
+
const { shop, productId, name, email } = params;
|
|
2211
|
+
const productServices = this.helpersService.getProductServices();
|
|
2212
|
+
return productServices.productStockNotificationRepository.addCustomerEmail({
|
|
2213
|
+
shop,
|
|
2214
|
+
productId,
|
|
2215
|
+
name,
|
|
2216
|
+
email,
|
|
2217
|
+
});
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
validateRequest(options) {
|
|
2221
|
+
var _a, _b, _c;
|
|
2222
|
+
if (this.hasProfile(options) && ((_a = options.filters) === null || _a === void 0 ? void 0 : _a.customOptions)) {
|
|
2223
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
2224
|
+
}
|
|
2225
|
+
if (this.hasProfile(options) && ((_b = options.filters) === null || _b === void 0 ? void 0 : _b.tags)) {
|
|
2226
|
+
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
2227
|
+
}
|
|
2228
|
+
if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions)) {
|
|
2229
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
buildSearchParams(options) {
|
|
2233
|
+
const limits = this.buildLimitQuery(options);
|
|
2234
|
+
return {
|
|
2235
|
+
category: this.hasCategory(options) ? options.category : undefined,
|
|
2236
|
+
profile: this.hasProfile(options) ? options.profile : undefined,
|
|
2237
|
+
term: this.hasTerm(options) ? options.term : undefined,
|
|
2238
|
+
filters: options.filters,
|
|
2239
|
+
mainGender: options.mainGender,
|
|
2240
|
+
sort: options.sort,
|
|
2241
|
+
limits,
|
|
2242
|
+
};
|
|
2243
|
+
}
|
|
2244
|
+
buildResponse(params) {
|
|
2245
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2246
|
+
const { data, total, maximum, minimal, searchParams } = params;
|
|
2247
|
+
const limits = searchParams.limits;
|
|
2248
|
+
const indexKey = this.helpersService.getBrandManager().buildIndexBrands(searchParams);
|
|
2249
|
+
return {
|
|
2250
|
+
products: {
|
|
2251
|
+
data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)),
|
|
2252
|
+
total,
|
|
2253
|
+
},
|
|
2254
|
+
pages: Math.ceil(total / limits.limit),
|
|
2255
|
+
prices: {
|
|
2256
|
+
price: {
|
|
2257
|
+
min: +(((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)) || 0),
|
|
2258
|
+
max: +(((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) || 0),
|
|
2259
|
+
},
|
|
2260
|
+
subscriberPrice: {
|
|
2261
|
+
min: +(((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)) || 0),
|
|
2262
|
+
max: +(((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)) || 0),
|
|
2263
|
+
},
|
|
2264
|
+
},
|
|
2265
|
+
brands: this.helpersService.getBrandManager().getBrandsList(indexKey),
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2268
|
+
buildLimitQuery(options) {
|
|
2269
|
+
const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
|
|
2270
|
+
return {
|
|
2271
|
+
limit,
|
|
2272
|
+
offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
|
|
2273
|
+
};
|
|
2274
|
+
}
|
|
2275
|
+
hasProfile(options) {
|
|
2276
|
+
return 'profile' in options;
|
|
2277
|
+
}
|
|
2278
|
+
hasTerm(options) {
|
|
2279
|
+
return 'term' in options;
|
|
2280
|
+
}
|
|
2281
|
+
hasCategory(options) {
|
|
2282
|
+
return 'category' in options;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: CatalogSearchContext }, { token: CatalogHelpersService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2286
|
+
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|
|
2287
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
|
|
2288
|
+
type: Injectable
|
|
2289
|
+
}], ctorParameters: function () {
|
|
2290
|
+
return [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type: i3.Shops, decorators: [{
|
|
1745
2291
|
type: Inject,
|
|
1746
2292
|
args: [DEFAULT_SHOP]
|
|
1747
2293
|
}] }];
|
|
@@ -1766,15 +2312,14 @@ __decorate([
|
|
|
1766
2312
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1767
2313
|
|
|
1768
2314
|
class WishlistService {
|
|
1769
|
-
constructor(wishlistRepository, shop,
|
|
2315
|
+
constructor(wishlistRepository, shop, logRepository) {
|
|
1770
2316
|
this.wishlistRepository = wishlistRepository;
|
|
1771
2317
|
this.shop = shop;
|
|
1772
|
-
this.productRepository = productRepository;
|
|
1773
|
-
this.productSearch = productSearch;
|
|
1774
2318
|
this.logRepository = logRepository;
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
this.
|
|
2319
|
+
}
|
|
2320
|
+
initializeServices(catalogServiceFacade, categoryServiceFacade) {
|
|
2321
|
+
this.catalogService = catalogServiceFacade.getCatalogService();
|
|
2322
|
+
this.categoryService = categoryServiceFacade.getCategoryService();
|
|
1778
2323
|
}
|
|
1779
2324
|
getCatalogService() {
|
|
1780
2325
|
return this.catalogService;
|
|
@@ -1784,29 +2329,52 @@ class WishlistService {
|
|
|
1784
2329
|
}
|
|
1785
2330
|
create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
1786
2331
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1789
|
-
name: title,
|
|
2332
|
+
const wishlistData = this.buildWishlistData({
|
|
2333
|
+
title,
|
|
1790
2334
|
description,
|
|
1791
|
-
metadatas: [
|
|
1792
|
-
{
|
|
1793
|
-
shop: this.shop,
|
|
1794
|
-
title: `${userFullName} - ${title}`,
|
|
1795
|
-
description: `${userFullName} - ${description}`,
|
|
1796
|
-
},
|
|
1797
|
-
],
|
|
1798
|
-
shop: this.shop,
|
|
1799
|
-
shops: [this.shop],
|
|
1800
|
-
personId,
|
|
1801
|
-
personName: userFullName,
|
|
1802
|
-
personPhoto: userPhoto,
|
|
1803
|
-
brandCategory: false,
|
|
1804
2335
|
published,
|
|
2336
|
+
userFullName,
|
|
2337
|
+
userPhoto,
|
|
1805
2338
|
theme,
|
|
1806
2339
|
bannerUrl,
|
|
1807
|
-
personType
|
|
1808
|
-
personIsSubscriber
|
|
1809
|
-
|
|
2340
|
+
personType,
|
|
2341
|
+
personIsSubscriber,
|
|
2342
|
+
personId,
|
|
2343
|
+
});
|
|
2344
|
+
const existingWishlist = yield this.findExistingWishlistByPersonId(personId);
|
|
2345
|
+
yield this.createWishlistLog(WishlistLogType.CREATE, wishlistData);
|
|
2346
|
+
if (existingWishlist)
|
|
2347
|
+
return existingWishlist;
|
|
2348
|
+
return this.createNewWishlist(wishlistData);
|
|
2349
|
+
});
|
|
2350
|
+
}
|
|
2351
|
+
buildWishlistData({ title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, personId, }) {
|
|
2352
|
+
return {
|
|
2353
|
+
slug: '',
|
|
2354
|
+
name: title,
|
|
2355
|
+
description,
|
|
2356
|
+
metadatas: [
|
|
2357
|
+
{
|
|
2358
|
+
shop: this.shop,
|
|
2359
|
+
title: `${userFullName} - ${title}`,
|
|
2360
|
+
description: `${userFullName} - ${description}`,
|
|
2361
|
+
},
|
|
2362
|
+
],
|
|
2363
|
+
shop: this.shop,
|
|
2364
|
+
shops: [this.shop],
|
|
2365
|
+
personId,
|
|
2366
|
+
personName: userFullName,
|
|
2367
|
+
personPhoto: userPhoto,
|
|
2368
|
+
brandCategory: false,
|
|
2369
|
+
published,
|
|
2370
|
+
theme,
|
|
2371
|
+
bannerUrl,
|
|
2372
|
+
personType: personType !== null && personType !== void 0 ? personType : PersonTypes.NONE,
|
|
2373
|
+
personIsSubscriber: personIsSubscriber !== null && personIsSubscriber !== void 0 ? personIsSubscriber : false,
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
findExistingWishlistByPersonId(personId) {
|
|
2377
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1810
2378
|
const hasWishlist = yield this.wishlistRepository
|
|
1811
2379
|
.find({
|
|
1812
2380
|
filters: {
|
|
@@ -1820,9 +2388,11 @@ class WishlistService {
|
|
|
1820
2388
|
},
|
|
1821
2389
|
})
|
|
1822
2390
|
.then((res) => res.data);
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
2391
|
+
return hasWishlist.length ? hasWishlist.at(0) : null;
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
createNewWishlist(data) {
|
|
2395
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1826
2396
|
const newWishlist = yield this.wishlistRepository.create(data);
|
|
1827
2397
|
yield this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1828
2398
|
return Wishlist.toInstance(Object.assign(Object.assign({}, newWishlist.toPlain()), { slug: newWishlist.id }));
|
|
@@ -1911,7 +2481,12 @@ class WishlistService {
|
|
|
1911
2481
|
}
|
|
1912
2482
|
findProductById(id) {
|
|
1913
2483
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1914
|
-
|
|
2484
|
+
if (!this.catalogService) {
|
|
2485
|
+
throw new Error('CatalogService not initialized. Call initializeServices first.');
|
|
2486
|
+
}
|
|
2487
|
+
const helpersService = this.catalogService['helpersService'];
|
|
2488
|
+
const productServices = helpersService.getProductServices();
|
|
2489
|
+
return productServices.productRepository
|
|
1915
2490
|
.find({
|
|
1916
2491
|
fields: ['id', 'sku', 'EAN', 'name', 'brand'],
|
|
1917
2492
|
filters: {
|
|
@@ -1927,58 +2502,72 @@ class WishlistService {
|
|
|
1927
2502
|
case WishlistLogType.CREATE:
|
|
1928
2503
|
case WishlistLogType.UPDATE:
|
|
1929
2504
|
case WishlistLogType.DELETE:
|
|
1930
|
-
yield this.
|
|
1931
|
-
collection: 'wishlist',
|
|
1932
|
-
date: new Date(),
|
|
1933
|
-
operation: WishlistLogType.CREATE ? 'CREATE' : WishlistLogType.UPDATE ? 'UPDATE' : 'DELETE',
|
|
1934
|
-
documentId: wishlist.id,
|
|
1935
|
-
document: {
|
|
1936
|
-
id: wishlist.id,
|
|
1937
|
-
shop: this.shop,
|
|
1938
|
-
name: wishlist.name,
|
|
1939
|
-
description: wishlist.description,
|
|
1940
|
-
published: wishlist.published,
|
|
1941
|
-
type: type,
|
|
1942
|
-
personType: wishlist.personType,
|
|
1943
|
-
personId: wishlist.personId,
|
|
1944
|
-
personName: wishlist.personName,
|
|
1945
|
-
personIsSubscriber: wishlist.personIsSubscriber,
|
|
1946
|
-
},
|
|
1947
|
-
});
|
|
2505
|
+
yield this.createWishlistOperationLog(type, wishlist);
|
|
1948
2506
|
break;
|
|
1949
2507
|
case WishlistLogType.ADD_PRODUCT:
|
|
1950
2508
|
case WishlistLogType.REMOVE_PRODUCT:
|
|
1951
|
-
yield this.
|
|
1952
|
-
collection: 'wishlist',
|
|
1953
|
-
date: new Date(),
|
|
1954
|
-
operation: 'UPDATE',
|
|
1955
|
-
documentId: wishlist.id,
|
|
1956
|
-
document: {
|
|
1957
|
-
id: wishlist.id,
|
|
1958
|
-
shop: this.shop,
|
|
1959
|
-
name: wishlist.name,
|
|
1960
|
-
description: wishlist.description,
|
|
1961
|
-
published: wishlist.published,
|
|
1962
|
-
type: type,
|
|
1963
|
-
personType: wishlist.personType,
|
|
1964
|
-
personId: wishlist.personId,
|
|
1965
|
-
personName: wishlist.personName,
|
|
1966
|
-
personIsSubscriber: wishlist.personIsSubscriber,
|
|
1967
|
-
productId: product.id,
|
|
1968
|
-
productEAN: product.EAN,
|
|
1969
|
-
productSKU: product.sku,
|
|
1970
|
-
productName: product.name,
|
|
1971
|
-
productBrand: product.brand,
|
|
1972
|
-
},
|
|
1973
|
-
});
|
|
2509
|
+
yield this.createWishlistProductLog(type, wishlist, product);
|
|
1974
2510
|
break;
|
|
1975
2511
|
default:
|
|
1976
2512
|
break;
|
|
1977
2513
|
}
|
|
1978
2514
|
});
|
|
1979
2515
|
}
|
|
2516
|
+
createWishlistOperationLog(type, wishlist) {
|
|
2517
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2518
|
+
const operation = this.getOperationTypeFromWishlistLogType(type);
|
|
2519
|
+
yield this.logRepository.create({
|
|
2520
|
+
collection: 'wishlist',
|
|
2521
|
+
date: new Date(),
|
|
2522
|
+
operation,
|
|
2523
|
+
documentId: wishlist.id,
|
|
2524
|
+
document: this.buildWishlistLogDocument(wishlist, type),
|
|
2525
|
+
});
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
createWishlistProductLog(type, wishlist, product) {
|
|
2529
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2530
|
+
yield this.logRepository.create({
|
|
2531
|
+
collection: 'wishlist',
|
|
2532
|
+
date: new Date(),
|
|
2533
|
+
operation: 'UPDATE',
|
|
2534
|
+
documentId: wishlist.id,
|
|
2535
|
+
document: Object.assign(Object.assign({}, this.buildWishlistLogDocument(wishlist, type)), this.buildProductLogData(product)),
|
|
2536
|
+
});
|
|
2537
|
+
});
|
|
2538
|
+
}
|
|
2539
|
+
getOperationTypeFromWishlistLogType(type) {
|
|
2540
|
+
if (type === WishlistLogType.CREATE)
|
|
2541
|
+
return 'CREATE';
|
|
2542
|
+
if (type === WishlistLogType.UPDATE)
|
|
2543
|
+
return 'UPDATE';
|
|
2544
|
+
return 'DELETE';
|
|
2545
|
+
}
|
|
2546
|
+
buildWishlistLogDocument(wishlist, type) {
|
|
2547
|
+
return {
|
|
2548
|
+
id: wishlist.id,
|
|
2549
|
+
shop: this.shop,
|
|
2550
|
+
name: wishlist.name,
|
|
2551
|
+
description: wishlist.description,
|
|
2552
|
+
published: wishlist.published,
|
|
2553
|
+
type: type,
|
|
2554
|
+
personType: wishlist.personType,
|
|
2555
|
+
personId: wishlist.personId,
|
|
2556
|
+
personName: wishlist.personName,
|
|
2557
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2558
|
+
};
|
|
2559
|
+
}
|
|
2560
|
+
buildProductLogData(product) {
|
|
2561
|
+
return {
|
|
2562
|
+
productId: product.id,
|
|
2563
|
+
productEAN: product.EAN,
|
|
2564
|
+
productSKU: product.sku,
|
|
2565
|
+
productName: product.name,
|
|
2566
|
+
productBrand: product.brand,
|
|
2567
|
+
};
|
|
2568
|
+
}
|
|
1980
2569
|
}
|
|
1981
|
-
WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: '
|
|
2570
|
+
WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'LogRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1982
2571
|
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
|
|
1983
2572
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
|
|
1984
2573
|
type: Injectable
|
|
@@ -1986,47 +2575,55 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1986
2575
|
return [{ type: undefined, decorators: [{
|
|
1987
2576
|
type: Inject,
|
|
1988
2577
|
args: ['WishlistRepository']
|
|
1989
|
-
}] }, { type:
|
|
2578
|
+
}] }, { type: i3.Shops, decorators: [{
|
|
1990
2579
|
type: Inject,
|
|
1991
2580
|
args: [DEFAULT_SHOP]
|
|
1992
2581
|
}] }, { type: undefined, decorators: [{
|
|
1993
2582
|
type: Inject,
|
|
1994
|
-
args: ['
|
|
1995
|
-
}] }
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2583
|
+
args: ['LogRepository']
|
|
2584
|
+
}] }];
|
|
2585
|
+
} });
|
|
2586
|
+
|
|
2587
|
+
class CouponRepositoriesFacade {
|
|
2588
|
+
constructor(couponRepository, orderRepository, categoryRepository) {
|
|
2589
|
+
this.couponRepository = couponRepository;
|
|
2590
|
+
this.orderRepository = orderRepository;
|
|
2591
|
+
this.categoryRepository = categoryRepository;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
CouponRepositoriesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponRepositoriesFacade, deps: [{ token: 'CouponRepository' }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2595
|
+
CouponRepositoriesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponRepositoriesFacade });
|
|
2596
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
|
|
2597
|
+
type: Injectable
|
|
2598
|
+
}], ctorParameters: function () {
|
|
2599
|
+
return [{ type: undefined, decorators: [{
|
|
2002
2600
|
type: Inject,
|
|
2003
|
-
args: ['
|
|
2601
|
+
args: ['CouponRepository']
|
|
2004
2602
|
}] }, { type: undefined, decorators: [{
|
|
2005
2603
|
type: Inject,
|
|
2006
|
-
args: ['
|
|
2604
|
+
args: ['OrderRepository']
|
|
2007
2605
|
}] }, { type: undefined, decorators: [{
|
|
2008
2606
|
type: Inject,
|
|
2009
|
-
args: ['
|
|
2607
|
+
args: ['CategoryRepository']
|
|
2010
2608
|
}] }];
|
|
2011
2609
|
} });
|
|
2012
2610
|
|
|
2013
2611
|
class CouponService {
|
|
2014
|
-
constructor(
|
|
2015
|
-
this.
|
|
2016
|
-
this.
|
|
2017
|
-
this.orderRepository = orderRepository;
|
|
2018
|
-
this.categoryRepository = categoryRepository;
|
|
2612
|
+
constructor(repositoriesFacade, configurationFacade) {
|
|
2613
|
+
this.repositoriesFacade = repositoriesFacade;
|
|
2614
|
+
this.configurationFacade = configurationFacade;
|
|
2019
2615
|
this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
|
|
2020
2616
|
}
|
|
2021
|
-
checkCoupon(
|
|
2022
|
-
|
|
2617
|
+
checkCoupon(params) {
|
|
2618
|
+
const { nickname, checkoutType, checkout, plan } = params;
|
|
2619
|
+
return from(this.repositoriesFacade.couponRepository
|
|
2023
2620
|
.find({
|
|
2024
2621
|
filters: {
|
|
2025
2622
|
nickname: { operator: Where.EQUALS, value: nickname },
|
|
2026
2623
|
active: { operator: Where.EQUALS, value: true },
|
|
2027
2624
|
},
|
|
2028
2625
|
})
|
|
2029
|
-
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
|
|
2626
|
+
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation({ coupon: couponValid, checkoutType, checkout, plan })), map((couponValidated) => couponValidated));
|
|
2030
2627
|
}
|
|
2031
2628
|
couponValidation(coupon, checkoutType) {
|
|
2032
2629
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -2036,7 +2633,7 @@ class CouponService {
|
|
|
2036
2633
|
throw 'Cupom inválido.';
|
|
2037
2634
|
if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn).getTime() < new Date().getTime())
|
|
2038
2635
|
throw 'Cupom expirado.';
|
|
2039
|
-
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
|
|
2636
|
+
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.configurationFacade.defaultShop;
|
|
2040
2637
|
if (!isInShop)
|
|
2041
2638
|
throw 'Cupom inválido para loja.';
|
|
2042
2639
|
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
@@ -2045,46 +2642,87 @@ class CouponService {
|
|
|
2045
2642
|
return coupon;
|
|
2046
2643
|
});
|
|
2047
2644
|
}
|
|
2048
|
-
couponRulesValidation(
|
|
2049
|
-
var _a;
|
|
2645
|
+
couponRulesValidation(params) {
|
|
2050
2646
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2647
|
+
const { coupon, checkoutType, checkout, plan } = params;
|
|
2051
2648
|
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
2052
|
-
|
|
2053
|
-
throw 'Cupom inválido para sua assinatura.';
|
|
2054
|
-
return coupon;
|
|
2649
|
+
return this.validateSubscriptionCoupon(coupon, plan);
|
|
2055
2650
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2651
|
+
return this.validateEcommerceCoupon(coupon, checkoutType, checkout);
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2654
|
+
validateSubscriptionCoupon(coupon, plan) {
|
|
2655
|
+
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase()) {
|
|
2656
|
+
throw 'Cupom inválido para sua assinatura.';
|
|
2657
|
+
}
|
|
2658
|
+
return coupon;
|
|
2659
|
+
}
|
|
2660
|
+
validateEcommerceCoupon(coupon, checkoutType, checkout) {
|
|
2661
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2662
|
+
this.validateUserEligibility(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
2663
|
+
yield this.validateUsageLimits(coupon, checkoutType, checkout);
|
|
2664
|
+
yield this.validateProductEligibility(coupon, checkout);
|
|
2665
|
+
return coupon;
|
|
2666
|
+
});
|
|
2667
|
+
}
|
|
2668
|
+
validateUserEligibility(coupon, user) {
|
|
2669
|
+
const validUser = this.coupomUserValidation(coupon, user);
|
|
2670
|
+
if (!validUser)
|
|
2671
|
+
throw 'Usuário não elegível.';
|
|
2672
|
+
}
|
|
2673
|
+
validateUsageLimits(coupon, checkoutType, checkout) {
|
|
2674
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2059
2675
|
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
2060
2676
|
if (couponUseLimits.firstOrder) {
|
|
2061
|
-
|
|
2062
|
-
if (couponUseLimits.firstOrder && ordersUser.length >= 1)
|
|
2063
|
-
throw 'Limite de uso atingido';
|
|
2677
|
+
yield this.validateFirstOrderLimit(checkout.user.email);
|
|
2064
2678
|
}
|
|
2065
2679
|
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2680
|
+
yield this.validateCouponUsageLimits(coupon, couponUseLimits, checkout.user.email);
|
|
2681
|
+
}
|
|
2682
|
+
});
|
|
2683
|
+
}
|
|
2684
|
+
validateFirstOrderLimit(userEmail) {
|
|
2685
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2686
|
+
const ordersUser = yield this.getOrdersFromUser(userEmail.toLocaleLowerCase());
|
|
2687
|
+
if (ordersUser.length >= 1)
|
|
2688
|
+
throw 'Limite de uso atingido';
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
validateCouponUsageLimits(coupon, couponUseLimits, userEmail) {
|
|
2692
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2693
|
+
const ordersCoupon = yield this.getOrdersWithCoupon(coupon);
|
|
2694
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total) {
|
|
2695
|
+
throw 'Limite de uso atingido.';
|
|
2696
|
+
}
|
|
2697
|
+
if (couponUseLimits.limitedPerUser) {
|
|
2698
|
+
const ordersWithUser = this.countOrdersWithUser(ordersCoupon, userEmail);
|
|
2699
|
+
if (ordersWithUser > 0)
|
|
2700
|
+
throw 'Limite de uso por usuário atingido.';
|
|
2074
2701
|
}
|
|
2702
|
+
});
|
|
2703
|
+
}
|
|
2704
|
+
validateProductEligibility(coupon, checkout) {
|
|
2705
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2075
2706
|
const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
|
|
2076
2707
|
if (!hasProductCategories)
|
|
2077
2708
|
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
2078
2709
|
const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
|
|
2079
2710
|
if (!hasMinSubTotal) {
|
|
2080
|
-
|
|
2081
|
-
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido na(s) categoria(s) elegíveis para o desconto.`;
|
|
2082
|
-
}
|
|
2083
|
-
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido.`;
|
|
2711
|
+
this.throwMinSubTotalError(coupon);
|
|
2084
2712
|
}
|
|
2085
|
-
return coupon;
|
|
2086
2713
|
});
|
|
2087
2714
|
}
|
|
2715
|
+
throwMinSubTotalError(coupon) {
|
|
2716
|
+
var _a;
|
|
2717
|
+
const formattedValue = Intl.NumberFormat('pt-BR', {
|
|
2718
|
+
style: 'currency',
|
|
2719
|
+
currency: 'BRL',
|
|
2720
|
+
}).format(coupon.minSubTotalValue);
|
|
2721
|
+
if ((_a = coupon.productsCategories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
2722
|
+
throw `Valor mínimo de ${formattedValue} não atingido na(s) categoria(s) elegíveis para o desconto.`;
|
|
2723
|
+
}
|
|
2724
|
+
throw `Valor mínimo de ${formattedValue} não atingido.`;
|
|
2725
|
+
}
|
|
2088
2726
|
calcDiscountSubscription(coupon, checkout) {
|
|
2089
2727
|
let discount = 0;
|
|
2090
2728
|
if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
|
|
@@ -2107,7 +2745,7 @@ class CouponService {
|
|
|
2107
2745
|
hasProductCategories(coupon, checkout) {
|
|
2108
2746
|
var _a, _b;
|
|
2109
2747
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2110
|
-
if (!
|
|
2748
|
+
if (!((_a = coupon.productsCategories) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
2111
2749
|
return true;
|
|
2112
2750
|
}
|
|
2113
2751
|
const couponCategories = yield this.getCouponCategoriesId(coupon.productsCategories);
|
|
@@ -2115,17 +2753,17 @@ class CouponService {
|
|
|
2115
2753
|
var _a;
|
|
2116
2754
|
if (item.isGift)
|
|
2117
2755
|
return false;
|
|
2118
|
-
if (!
|
|
2756
|
+
if (!((_a = item.categories) === null || _a === void 0 ? void 0 : _a.length))
|
|
2119
2757
|
return true;
|
|
2120
2758
|
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
2121
2759
|
});
|
|
2122
|
-
return hasCategories.length ? true : false;
|
|
2760
|
+
return (hasCategories === null || hasCategories === void 0 ? void 0 : hasCategories.length) ? true : false;
|
|
2123
2761
|
});
|
|
2124
2762
|
}
|
|
2125
2763
|
coupomUserValidation(coupon, user) {
|
|
2126
2764
|
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
2127
2765
|
return true;
|
|
2128
|
-
|
|
2766
|
+
const userTypes = [];
|
|
2129
2767
|
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
|
|
2130
2768
|
this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
|
|
2131
2769
|
userTypes.push(Exclusivities.COLLABORATORS);
|
|
@@ -2148,11 +2786,11 @@ class CouponService {
|
|
|
2148
2786
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2149
2787
|
const couponCategories = [];
|
|
2150
2788
|
for (let index = 0; index < productsCategories.length; index++) {
|
|
2151
|
-
const category = yield this.categoryRepository.get({
|
|
2789
|
+
const category = yield this.repositoriesFacade.categoryRepository.get({
|
|
2152
2790
|
id: productsCategories[index],
|
|
2153
2791
|
});
|
|
2154
2792
|
if (category) {
|
|
2155
|
-
const children = yield this.categoryRepository.getChildren(parseInt(productsCategories[index]));
|
|
2793
|
+
const children = yield this.repositoriesFacade.categoryRepository.getChildren(parseInt(productsCategories[index]));
|
|
2156
2794
|
couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
|
|
2157
2795
|
}
|
|
2158
2796
|
}
|
|
@@ -2164,7 +2802,7 @@ class CouponService {
|
|
|
2164
2802
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2165
2803
|
let lineItensDiscount = [];
|
|
2166
2804
|
const couponCategories = yield this.getCouponCategoriesId(productsCategories);
|
|
2167
|
-
if (productsCategories
|
|
2805
|
+
if (productsCategories === null || productsCategories === void 0 ? void 0 : productsCategories.length) {
|
|
2168
2806
|
lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((item) => {
|
|
2169
2807
|
var _a;
|
|
2170
2808
|
if (item.isGift)
|
|
@@ -2183,15 +2821,15 @@ class CouponService {
|
|
|
2183
2821
|
}
|
|
2184
2822
|
calcCheckoutSubtotal(lineItens, user) {
|
|
2185
2823
|
return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.filter((item) => !item.isGift).reduce((acc, curr) => {
|
|
2186
|
-
var _a;
|
|
2187
|
-
return (user === null || user === void 0 ? void 0 : user.isSubscriber) && curr.price.subscriberPrice
|
|
2188
|
-
? acc + ((
|
|
2824
|
+
var _a, _b;
|
|
2825
|
+
return (user === null || user === void 0 ? void 0 : user.isSubscriber) && ((_a = curr.price) === null || _a === void 0 ? void 0 : _a.subscriberPrice)
|
|
2826
|
+
? acc + ((_b = curr.price) === null || _b === void 0 ? void 0 : _b.subscriberPrice) * curr.quantity
|
|
2189
2827
|
: acc + curr.pricePaid * curr.quantity;
|
|
2190
2828
|
}, 0)) || 0);
|
|
2191
2829
|
}
|
|
2192
2830
|
getOrdersWithCoupon(coupon) {
|
|
2193
2831
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2194
|
-
return yield this.orderRepository
|
|
2832
|
+
return yield this.repositoriesFacade.orderRepository
|
|
2195
2833
|
.find({
|
|
2196
2834
|
filters: {
|
|
2197
2835
|
coupon: { id: coupon.id },
|
|
@@ -2203,7 +2841,7 @@ class CouponService {
|
|
|
2203
2841
|
}
|
|
2204
2842
|
getOrdersFromUser(email) {
|
|
2205
2843
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2206
|
-
return yield this.orderRepository
|
|
2844
|
+
return yield this.repositoriesFacade.orderRepository
|
|
2207
2845
|
.find({
|
|
2208
2846
|
filters: {
|
|
2209
2847
|
user: { email: { operator: Where.EQUALS, value: email } },
|
|
@@ -2224,7 +2862,7 @@ class CouponService {
|
|
|
2224
2862
|
coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
|
|
2225
2863
|
couponUseLimits = coupon.useLimits.non_subscriber;
|
|
2226
2864
|
else
|
|
2227
|
-
couponUseLimits = user
|
|
2865
|
+
couponUseLimits = (user === null || user === void 0 ? void 0 : user.isSubscriber) ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
2228
2866
|
}
|
|
2229
2867
|
else {
|
|
2230
2868
|
couponUseLimits = coupon.useLimits.subscription;
|
|
@@ -2232,28 +2870,14 @@ class CouponService {
|
|
|
2232
2870
|
return couponUseLimits;
|
|
2233
2871
|
}
|
|
2234
2872
|
}
|
|
2235
|
-
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token:
|
|
2873
|
+
CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: CouponRepositoriesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2236
2874
|
CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
|
|
2237
2875
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
|
|
2238
2876
|
type: Injectable,
|
|
2239
2877
|
args: [{
|
|
2240
2878
|
providedIn: 'root',
|
|
2241
2879
|
}]
|
|
2242
|
-
}], ctorParameters: function () {
|
|
2243
|
-
return [{ type: undefined, decorators: [{
|
|
2244
|
-
type: Inject,
|
|
2245
|
-
args: ['CouponRepository']
|
|
2246
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
2247
|
-
type: Inject,
|
|
2248
|
-
args: [DEFAULT_SHOP]
|
|
2249
|
-
}] }, { type: undefined, decorators: [{
|
|
2250
|
-
type: Inject,
|
|
2251
|
-
args: ['OrderRepository']
|
|
2252
|
-
}] }, { type: undefined, decorators: [{
|
|
2253
|
-
type: Inject,
|
|
2254
|
-
args: ['CategoryRepository']
|
|
2255
|
-
}] }];
|
|
2256
|
-
} });
|
|
2880
|
+
}], ctorParameters: function () { return [{ type: CouponRepositoriesFacade }, { type: ConfigurationFacade }]; } });
|
|
2257
2881
|
|
|
2258
2882
|
class CheckoutSubscriptionService {
|
|
2259
2883
|
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
@@ -2269,9 +2893,14 @@ class CheckoutSubscriptionService {
|
|
|
2269
2893
|
clearCheckoutSubscriptionFromSession() {
|
|
2270
2894
|
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
2271
2895
|
}
|
|
2272
|
-
checkCoupon(nickname,
|
|
2896
|
+
checkCoupon(nickname, _userEmail) {
|
|
2273
2897
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
2274
|
-
.checkCoupon(
|
|
2898
|
+
.checkCoupon({
|
|
2899
|
+
nickname,
|
|
2900
|
+
checkoutType: CheckoutTypes.SUBSCRIPTION,
|
|
2901
|
+
checkout,
|
|
2902
|
+
plan: checkout.subscriptionPlan.name,
|
|
2903
|
+
})
|
|
2275
2904
|
.pipe()));
|
|
2276
2905
|
}
|
|
2277
2906
|
calcDiscountSubscription(coupon) {
|
|
@@ -2303,33 +2932,55 @@ class UtilHelper {
|
|
|
2303
2932
|
static createSlug(name) {
|
|
2304
2933
|
return name
|
|
2305
2934
|
.toLowerCase()
|
|
2306
|
-
.replace(/\s+/g, '-')
|
|
2307
|
-
.replace(/[ãàáäâ]/g, 'a')
|
|
2308
|
-
.replace(/[ẽèéëê]/g, 'e')
|
|
2309
|
-
.replace(/[ìíïî]/g, 'i')
|
|
2310
|
-
.replace(/[õòóöô]/g, 'o')
|
|
2311
|
-
.replace(/[ùúüû]/g, 'u')
|
|
2312
|
-
.replace(/[ñ]/g, 'n')
|
|
2313
|
-
.replace(/[ç]/g, 'c')
|
|
2314
|
-
.replace(/[&]/g, 'and')
|
|
2315
|
-
.replace(/[^\w
|
|
2316
|
-
.replace(
|
|
2935
|
+
.replace(/\s+/g, '-')
|
|
2936
|
+
.replace(/[ãàáäâ]/g, 'a')
|
|
2937
|
+
.replace(/[ẽèéëê]/g, 'e')
|
|
2938
|
+
.replace(/[ìíïî]/g, 'i')
|
|
2939
|
+
.replace(/[õòóöô]/g, 'o')
|
|
2940
|
+
.replace(/[ùúüû]/g, 'u')
|
|
2941
|
+
.replace(/[ñ]/g, 'n')
|
|
2942
|
+
.replace(/[ç]/g, 'c')
|
|
2943
|
+
.replace(/[&]/g, 'and')
|
|
2944
|
+
.replace(/[^\w-]+/g, '')
|
|
2945
|
+
.replace(/--+/g, '-');
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
|
|
2949
|
+
class HomeShopRepositoriesFacade {
|
|
2950
|
+
constructor(categoryRepository, homeRepository, productRepository) {
|
|
2951
|
+
this.categoryRepository = categoryRepository;
|
|
2952
|
+
this.homeRepository = homeRepository;
|
|
2953
|
+
this.productRepository = productRepository;
|
|
2317
2954
|
}
|
|
2318
2955
|
}
|
|
2956
|
+
HomeShopRepositoriesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopRepositoriesFacade, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2957
|
+
HomeShopRepositoriesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopRepositoriesFacade });
|
|
2958
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopRepositoriesFacade, decorators: [{
|
|
2959
|
+
type: Injectable
|
|
2960
|
+
}], ctorParameters: function () {
|
|
2961
|
+
return [{ type: undefined, decorators: [{
|
|
2962
|
+
type: Inject,
|
|
2963
|
+
args: ['CategoryRepository']
|
|
2964
|
+
}] }, { type: undefined, decorators: [{
|
|
2965
|
+
type: Inject,
|
|
2966
|
+
args: ['HomeRepository']
|
|
2967
|
+
}] }, { type: undefined, decorators: [{
|
|
2968
|
+
type: Inject,
|
|
2969
|
+
args: ['ProductRepository']
|
|
2970
|
+
}] }];
|
|
2971
|
+
} });
|
|
2319
2972
|
|
|
2320
2973
|
class HomeShopService {
|
|
2321
2974
|
get homeId() {
|
|
2322
|
-
if (this.defaultShop === Shops.GLAMSHOP)
|
|
2975
|
+
if (this.configurationFacade.defaultShop === Shops.GLAMSHOP)
|
|
2323
2976
|
return 'glamshop';
|
|
2324
|
-
if (this.defaultShop === Shops.MENSMARKET)
|
|
2977
|
+
if (this.configurationFacade.defaultShop === Shops.MENSMARKET)
|
|
2325
2978
|
return 'mens_market';
|
|
2326
2979
|
return null;
|
|
2327
2980
|
}
|
|
2328
|
-
constructor(
|
|
2329
|
-
this.
|
|
2330
|
-
this.
|
|
2331
|
-
this.productRepository = productRepository;
|
|
2332
|
-
this.defaultShop = defaultShop;
|
|
2981
|
+
constructor(repositoriesFacade, configurationFacade) {
|
|
2982
|
+
this.repositoriesFacade = repositoriesFacade;
|
|
2983
|
+
this.configurationFacade = configurationFacade;
|
|
2333
2984
|
this.buildCategoryGroupWithRequiredData = (group) => {
|
|
2334
2985
|
var _a, _b;
|
|
2335
2986
|
return ({
|
|
@@ -2383,14 +3034,20 @@ class HomeShopService {
|
|
|
2383
3034
|
getMinValueForFreeShipping() {
|
|
2384
3035
|
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
2385
3036
|
}
|
|
2386
|
-
getDiscoverProducts(
|
|
2387
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(
|
|
3037
|
+
getDiscoverProducts(_gender) {
|
|
3038
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
|
|
3039
|
+
categoryIds: home.discoverCategories,
|
|
3040
|
+
shop: this.configurationFacade.defaultShop,
|
|
3041
|
+
})).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2388
3042
|
}
|
|
2389
|
-
getFeaturedProducts(
|
|
2390
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(
|
|
3043
|
+
getFeaturedProducts(_gender) {
|
|
3044
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
|
|
3045
|
+
categoryIds: home.featuredCategories,
|
|
3046
|
+
shop: this.configurationFacade.defaultShop,
|
|
3047
|
+
})).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2391
3048
|
}
|
|
2392
3049
|
getVerticalProducts(gender) {
|
|
2393
|
-
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({
|
|
3050
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.repositoriesFacade.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.repositoriesFacade.productRepository.find({
|
|
2394
3051
|
filters: Object.assign({ categories: { operator: Where.IN, value: [category.id] } }, (gender ? { tags: { operator: Where.IN, value: [gender] } } : {})),
|
|
2395
3052
|
limits: { limit: 12 },
|
|
2396
3053
|
})).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
|
|
@@ -2399,8 +3056,8 @@ class HomeShopService {
|
|
|
2399
3056
|
return of(this.homeConfiguration).pipe(concatMap((home) => home
|
|
2400
3057
|
? of(home)
|
|
2401
3058
|
: !this.homeId
|
|
2402
|
-
? throwError(new RequiredArgumentError(['homeId']))
|
|
2403
|
-
: from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
3059
|
+
? throwError(() => new RequiredArgumentError(['homeId']))
|
|
3060
|
+
: from(this.repositoriesFacade.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
|
|
2404
3061
|
}
|
|
2405
3062
|
saveHomeData(homeData) {
|
|
2406
3063
|
const data = {
|
|
@@ -2408,7 +3065,7 @@ class HomeShopService {
|
|
|
2408
3065
|
expiresAt: add(new Date(), { hours: 1 }),
|
|
2409
3066
|
data: homeData,
|
|
2410
3067
|
};
|
|
2411
|
-
return from(this.homeRepository.update({
|
|
3068
|
+
return from(this.repositoriesFacade.homeRepository.update({
|
|
2412
3069
|
id: this.homeId,
|
|
2413
3070
|
data,
|
|
2414
3071
|
})).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
|
|
@@ -2417,25 +3074,11 @@ class HomeShopService {
|
|
|
2417
3074
|
return this.homeId === 'mens_market' ? 'masculino' : undefined;
|
|
2418
3075
|
}
|
|
2419
3076
|
}
|
|
2420
|
-
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token:
|
|
3077
|
+
HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: HomeShopRepositoriesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2421
3078
|
HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
|
|
2422
3079
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
|
|
2423
3080
|
type: Injectable
|
|
2424
|
-
}], ctorParameters: function () {
|
|
2425
|
-
return [{ type: undefined, decorators: [{
|
|
2426
|
-
type: Inject,
|
|
2427
|
-
args: ['CategoryRepository']
|
|
2428
|
-
}] }, { type: undefined, decorators: [{
|
|
2429
|
-
type: Inject,
|
|
2430
|
-
args: ['HomeRepository']
|
|
2431
|
-
}] }, { type: undefined, decorators: [{
|
|
2432
|
-
type: Inject,
|
|
2433
|
-
args: ['ProductRepository']
|
|
2434
|
-
}] }, { type: i1$3.Shops, decorators: [{
|
|
2435
|
-
type: Inject,
|
|
2436
|
-
args: [DEFAULT_SHOP]
|
|
2437
|
-
}] }];
|
|
2438
|
-
} });
|
|
3081
|
+
}], ctorParameters: function () { return [{ type: HomeShopRepositoriesFacade }, { type: ConfigurationFacade }]; } });
|
|
2439
3082
|
|
|
2440
3083
|
class OrderService {
|
|
2441
3084
|
constructor(angularFirestore, orderRepository) {
|
|
@@ -2455,7 +3098,7 @@ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version
|
|
|
2455
3098
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
|
|
2456
3099
|
type: Injectable
|
|
2457
3100
|
}], ctorParameters: function () {
|
|
2458
|
-
return [{ type: i1$1.Firestore }, { type:
|
|
3101
|
+
return [{ type: i1$1.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
|
|
2459
3102
|
type: Inject,
|
|
2460
3103
|
args: ['OrderRepository']
|
|
2461
3104
|
}] }];
|
|
@@ -2466,28 +3109,44 @@ class AngularConnectModule {
|
|
|
2466
3109
|
return {
|
|
2467
3110
|
ngModule: AngularConnectModule,
|
|
2468
3111
|
providers: [
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
{
|
|
2472
|
-
provide: CATEGORY_STRUCTURE,
|
|
2473
|
-
useClass: isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
|
|
2474
|
-
? OldCategoryStructureAdapter
|
|
2475
|
-
: NewCategoryStructureAdapter,
|
|
2476
|
-
},
|
|
2477
|
-
{ provide: PERSISTENCE_PROVIDER, useClass: (options === null || options === void 0 ? void 0 : options.persistenceProvider) || CookieDataPersistence },
|
|
2478
|
-
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2479
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
|
|
2480
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
2481
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.vertexConfig) ? [] : [{ provide: VERTEX_CONFIG, useValue: options.vertexConfig }]),
|
|
2482
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
2483
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
2484
|
-
...(isNil(options === null || options === void 0 ? void 0 : options.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
|
|
3112
|
+
...this.buildCoreProviders(nameOrConfig, options),
|
|
3113
|
+
...this.buildConditionalProviders(defaultShop, options),
|
|
2485
3114
|
],
|
|
2486
3115
|
};
|
|
2487
3116
|
}
|
|
3117
|
+
static buildCoreProviders(nameOrConfig, options) {
|
|
3118
|
+
return [
|
|
3119
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
3120
|
+
{ provide: APP_CHECK_PROVIDER, useValue: options.appCheckProvider },
|
|
3121
|
+
{
|
|
3122
|
+
provide: CATEGORY_STRUCTURE,
|
|
3123
|
+
useClass: this.selectCategoryStructureAdapter(options.oldCategoryStructure),
|
|
3124
|
+
},
|
|
3125
|
+
{ provide: PERSISTENCE_PROVIDER, useClass: (options === null || options === void 0 ? void 0 : options.persistenceProvider) || CookieDataPersistence },
|
|
3126
|
+
];
|
|
3127
|
+
}
|
|
3128
|
+
static buildConditionalProviders(defaultShop, options) {
|
|
3129
|
+
return [
|
|
3130
|
+
...this.createProviderIfExists(DEFAULT_SHOP, defaultShop),
|
|
3131
|
+
...this.createProviderIfExists(FIREBASE_OPTIONS, options.firebase),
|
|
3132
|
+
...this.createProviderIfExists(ES_CONFIG, options.elasticSearch),
|
|
3133
|
+
...this.createProviderIfExists(VERTEX_CONFIG, options.vertexConfig),
|
|
3134
|
+
...this.createProviderIfExists(HASURA_OPTIONS, options.hasura),
|
|
3135
|
+
...this.createProviderIfExists(BACKEND_URL, options.backendUrl),
|
|
3136
|
+
...this.createProviderIfExists(STORAGE_BASE_URL, options.storageBaseUrl),
|
|
3137
|
+
];
|
|
3138
|
+
}
|
|
3139
|
+
static selectCategoryStructureAdapter(oldCategoryStructure) {
|
|
3140
|
+
return isNil(oldCategoryStructure) || oldCategoryStructure
|
|
3141
|
+
? OldCategoryStructureAdapter
|
|
3142
|
+
: NewCategoryStructureAdapter;
|
|
3143
|
+
}
|
|
3144
|
+
static createProviderIfExists(token, value) {
|
|
3145
|
+
return isNil(value) ? [] : [{ provide: token, useValue: value }];
|
|
3146
|
+
}
|
|
2488
3147
|
}
|
|
2489
3148
|
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2490
|
-
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$
|
|
3149
|
+
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$3.FirebaseAppModule, i2.AppCheckModule, i3$1.StorageModule, AngularElasticSeachModule,
|
|
2491
3150
|
AngularVertexSeachModule,
|
|
2492
3151
|
AngularFirebaseAuthModule,
|
|
2493
3152
|
AngularFirestoreModule,
|
|
@@ -2503,6 +3162,42 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
|
|
|
2503
3162
|
HomeShopService,
|
|
2504
3163
|
OrderService,
|
|
2505
3164
|
WishlistService,
|
|
3165
|
+
ConfigurationFacade,
|
|
3166
|
+
CartServicesFacade,
|
|
3167
|
+
CheckoutRepositoriesFacade,
|
|
3168
|
+
CheckoutDependenciesFacade,
|
|
3169
|
+
CategoryRepositoryFacade,
|
|
3170
|
+
ProductCatalogFacade,
|
|
3171
|
+
CatalogServiceFacade,
|
|
3172
|
+
CategoryServiceFacade,
|
|
3173
|
+
CatalogStrategiesFacade,
|
|
3174
|
+
CatalogOperationsFacade,
|
|
3175
|
+
ProductManagementFacade,
|
|
3176
|
+
{
|
|
3177
|
+
provide: 'ProductServicesFacade',
|
|
3178
|
+
useFactory: (productStockNotificationRepository, categoryRepository, productSearch) => ({
|
|
3179
|
+
productStockNotificationRepository,
|
|
3180
|
+
categoryRepository,
|
|
3181
|
+
productSearch,
|
|
3182
|
+
}),
|
|
3183
|
+
deps: ['ProductStockNotificationRepository', 'CategoryRepository', 'ProductSearch'],
|
|
3184
|
+
},
|
|
3185
|
+
CatalogFilterHelper,
|
|
3186
|
+
CatalogSortHelper,
|
|
3187
|
+
ProductFieldsHelper,
|
|
3188
|
+
BrandManagerHelper,
|
|
3189
|
+
CatalogRepositoryService,
|
|
3190
|
+
CatalogHelpersService,
|
|
3191
|
+
CategorySearchStrategy,
|
|
3192
|
+
TermSearchStrategy,
|
|
3193
|
+
ProfileSearchStrategy,
|
|
3194
|
+
{
|
|
3195
|
+
provide: CatalogSearchContext,
|
|
3196
|
+
useFactory: (categoryStrategy, termStrategy, profileStrategy) => {
|
|
3197
|
+
return new CatalogSearchContext(categoryStrategy, termStrategy, profileStrategy);
|
|
3198
|
+
},
|
|
3199
|
+
deps: [CategorySearchStrategy, TermSearchStrategy, ProfileSearchStrategy],
|
|
3200
|
+
},
|
|
2506
3201
|
{
|
|
2507
3202
|
provide: UpdateUserImage,
|
|
2508
3203
|
useFactory: (userRepository, fileUploader) => {
|
|
@@ -2521,6 +3216,8 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
|
|
|
2521
3216
|
provide: 'ProductSearch',
|
|
2522
3217
|
useExisting: ProductsVertexSearch,
|
|
2523
3218
|
},
|
|
3219
|
+
CouponRepositoriesFacade,
|
|
3220
|
+
HomeShopRepositoriesFacade,
|
|
2524
3221
|
], imports: [provideFirebaseApp((injector) => {
|
|
2525
3222
|
const appName = injector.get(FIREBASE_APP_NAME);
|
|
2526
3223
|
try {
|
|
@@ -2607,6 +3304,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2607
3304
|
HomeShopService,
|
|
2608
3305
|
OrderService,
|
|
2609
3306
|
WishlistService,
|
|
3307
|
+
ConfigurationFacade,
|
|
3308
|
+
CartServicesFacade,
|
|
3309
|
+
CheckoutRepositoriesFacade,
|
|
3310
|
+
CheckoutDependenciesFacade,
|
|
3311
|
+
CategoryRepositoryFacade,
|
|
3312
|
+
ProductCatalogFacade,
|
|
3313
|
+
CatalogServiceFacade,
|
|
3314
|
+
CategoryServiceFacade,
|
|
3315
|
+
CatalogStrategiesFacade,
|
|
3316
|
+
CatalogOperationsFacade,
|
|
3317
|
+
ProductManagementFacade,
|
|
3318
|
+
{
|
|
3319
|
+
provide: 'ProductServicesFacade',
|
|
3320
|
+
useFactory: (productStockNotificationRepository, categoryRepository, productSearch) => ({
|
|
3321
|
+
productStockNotificationRepository,
|
|
3322
|
+
categoryRepository,
|
|
3323
|
+
productSearch,
|
|
3324
|
+
}),
|
|
3325
|
+
deps: ['ProductStockNotificationRepository', 'CategoryRepository', 'ProductSearch'],
|
|
3326
|
+
},
|
|
3327
|
+
CatalogFilterHelper,
|
|
3328
|
+
CatalogSortHelper,
|
|
3329
|
+
ProductFieldsHelper,
|
|
3330
|
+
BrandManagerHelper,
|
|
3331
|
+
CatalogRepositoryService,
|
|
3332
|
+
CatalogHelpersService,
|
|
3333
|
+
CategorySearchStrategy,
|
|
3334
|
+
TermSearchStrategy,
|
|
3335
|
+
ProfileSearchStrategy,
|
|
3336
|
+
{
|
|
3337
|
+
provide: CatalogSearchContext,
|
|
3338
|
+
useFactory: (categoryStrategy, termStrategy, profileStrategy) => {
|
|
3339
|
+
return new CatalogSearchContext(categoryStrategy, termStrategy, profileStrategy);
|
|
3340
|
+
},
|
|
3341
|
+
deps: [CategorySearchStrategy, TermSearchStrategy, ProfileSearchStrategy],
|
|
3342
|
+
},
|
|
2610
3343
|
{
|
|
2611
3344
|
provide: UpdateUserImage,
|
|
2612
3345
|
useFactory: (userRepository, fileUploader) => {
|
|
@@ -2625,6 +3358,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2625
3358
|
provide: 'ProductSearch',
|
|
2626
3359
|
useExisting: ProductsVertexSearch,
|
|
2627
3360
|
},
|
|
3361
|
+
CouponRepositoriesFacade,
|
|
3362
|
+
HomeShopRepositoriesFacade,
|
|
2628
3363
|
],
|
|
2629
3364
|
}]
|
|
2630
3365
|
}] });
|