@infrab4a/connect-angular 4.0.0-beta.53 → 4.0.0-beta.54
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/esm2020/services/catalog/catalog.service.mjs +40 -17
- package/esm2020/services/catalog/wishlist.service.mjs +2 -2
- package/fesm2015/infrab4a-connect-angular.mjs +37 -9
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +40 -17
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +29 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, NgModule, PLATFORM_ID, Injectable, Inject } from '@angular/core';
|
|
3
3
|
import * as i1$3 from '@infrab4a/connect';
|
|
4
|
-
import { Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
|
|
4
|
+
import { Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
|
|
5
5
|
import * as i1 from '@angular/fire/app';
|
|
6
6
|
import { provideFirebaseApp, initializeApp, FirebaseApp } from '@angular/fire/app';
|
|
7
7
|
import * as i1$1 from '@angular/fire/auth';
|
|
@@ -1448,10 +1448,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1448
1448
|
}] }]; } });
|
|
1449
1449
|
|
|
1450
1450
|
class CatalogService {
|
|
1451
|
-
constructor(productRepository, categoryStructureAdapter, shop) {
|
|
1451
|
+
constructor(productRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1452
1452
|
this.productRepository = productRepository;
|
|
1453
1453
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1454
1454
|
this.shop = shop;
|
|
1455
|
+
this.productIndex = productIndex;
|
|
1455
1456
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1456
1457
|
const filters = {};
|
|
1457
1458
|
if (clubDiscount?.length)
|
|
@@ -1499,20 +1500,18 @@ class CatalogService {
|
|
|
1499
1500
|
offset: ((options?.page || 1) - 1) * limit,
|
|
1500
1501
|
};
|
|
1501
1502
|
};
|
|
1503
|
+
this.hasProfile = (options) => 'profile' in options;
|
|
1504
|
+
this.hasTerm = (options) => 'term' in options;
|
|
1502
1505
|
}
|
|
1503
|
-
async fetchProducts(
|
|
1506
|
+
async fetchProducts(options) {
|
|
1504
1507
|
const limits = this.buildLimitQuery(options);
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
limits,
|
|
1513
|
-
options: { minimal: ['price'], maximum: ['price'] },
|
|
1514
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1515
|
-
.then(({ data, count: total, maximum, minimal }) => ({
|
|
1508
|
+
if (this.hasProfile(options) && options.filters?.customOptions)
|
|
1509
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
1510
|
+
if (this.hasProfile(options) && options.filters?.tags)
|
|
1511
|
+
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1512
|
+
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1513
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when tags is given`);
|
|
1514
|
+
return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal }) => ({
|
|
1516
1515
|
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
1517
1516
|
pages: Math.ceil(total / limits.limit),
|
|
1518
1517
|
prices: {
|
|
@@ -1524,8 +1523,32 @@ class CatalogService {
|
|
|
1524
1523
|
},
|
|
1525
1524
|
}));
|
|
1526
1525
|
}
|
|
1526
|
+
async findCatalog(options, limits) {
|
|
1527
|
+
const repoParams = {
|
|
1528
|
+
filters: {
|
|
1529
|
+
...(await this.buildMainFilter(options)),
|
|
1530
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1531
|
+
},
|
|
1532
|
+
...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
|
|
1533
|
+
limits,
|
|
1534
|
+
options: { minimal: ['price'], maximum: ['price'] },
|
|
1535
|
+
};
|
|
1536
|
+
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1537
|
+
return this.productRepository.find(repoParams);
|
|
1538
|
+
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1539
|
+
}
|
|
1540
|
+
async buildMainFilter({ category, profile, term, }) {
|
|
1541
|
+
if (category)
|
|
1542
|
+
return this.categoryStructureAdapter.buildProductFilterByCategory(category);
|
|
1543
|
+
if (profile)
|
|
1544
|
+
return { tags: { operator: Where.LIKE, value: profile } };
|
|
1545
|
+
if (term)
|
|
1546
|
+
return this.productIndex
|
|
1547
|
+
.search(term, 9999, this.shop)
|
|
1548
|
+
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1549
|
+
}
|
|
1527
1550
|
}
|
|
1528
|
-
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1551
|
+
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$3.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1529
1552
|
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|
|
1530
1553
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
|
|
1531
1554
|
type: Injectable
|
|
@@ -1538,7 +1561,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1538
1561
|
}] }, { type: i1$3.Shops, decorators: [{
|
|
1539
1562
|
type: Inject,
|
|
1540
1563
|
args: [DEFAULT_SHOP]
|
|
1541
|
-
}] }]; } });
|
|
1564
|
+
}] }, { type: i1$3.ProductsIndex }]; } });
|
|
1542
1565
|
|
|
1543
1566
|
class CategoryService {
|
|
1544
1567
|
constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
@@ -1686,7 +1709,7 @@ class WishlistService {
|
|
|
1686
1709
|
this.wishlistRepository = wishlistRepository;
|
|
1687
1710
|
this.shop = shop;
|
|
1688
1711
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository);
|
|
1689
|
-
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop);
|
|
1712
|
+
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, null);
|
|
1690
1713
|
this.categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1691
1714
|
}
|
|
1692
1715
|
getCatalogService() {
|