@infrab4a/connect-angular 4.19.0-beta.0 → 4.19.0-beta.1
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 +10 -10
- package/esm2020/services/catalog/category.service.mjs +6 -6
- package/fesm2015/infrab4a-connect-angular.mjs +14 -14
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +14 -14
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +4 -2
- package/services/catalog/category.service.d.ts +7 -3
|
@@ -1452,7 +1452,7 @@ class CatalogService {
|
|
|
1452
1452
|
return '';
|
|
1453
1453
|
};
|
|
1454
1454
|
}
|
|
1455
|
-
async fetchProducts(options) {
|
|
1455
|
+
async fetchProducts(options, optionsCache) {
|
|
1456
1456
|
const limits = this.buildLimitQuery(options);
|
|
1457
1457
|
if (this.hasProfile(options) && options.filters?.customOptions)
|
|
1458
1458
|
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
@@ -1460,7 +1460,7 @@ class CatalogService {
|
|
|
1460
1460
|
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1461
1461
|
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1462
1462
|
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1463
|
-
return await this.findCatalog(options, limits).then(async ({ data, count: total, maximum, minimal, distinct }) => {
|
|
1463
|
+
return await this.findCatalog(options, limits, optionsCache).then(async ({ data, count: total, maximum, minimal, distinct }) => {
|
|
1464
1464
|
await this.setBrandsList(options, distinct?.brand);
|
|
1465
1465
|
return {
|
|
1466
1466
|
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
@@ -1479,7 +1479,7 @@ class CatalogService {
|
|
|
1479
1479
|
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1480
1480
|
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1481
1481
|
}
|
|
1482
|
-
async findCatalog(options, limits) {
|
|
1482
|
+
async findCatalog(options, limits, optionsCache) {
|
|
1483
1483
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1484
1484
|
const productsIds = await this.findCatalogIdsBySearch(options.term);
|
|
1485
1485
|
return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
|
|
@@ -1493,9 +1493,9 @@ class CatalogService {
|
|
|
1493
1493
|
...(await this.buildMainFilter(options)),
|
|
1494
1494
|
...this.buildFilterQuery(options?.filters || {}),
|
|
1495
1495
|
},
|
|
1496
|
-
})
|
|
1496
|
+
}, undefined, optionsCache)
|
|
1497
1497
|
.then((products) => products.data.map((product) => product.id));
|
|
1498
|
-
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1498
|
+
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits, optionsCache);
|
|
1499
1499
|
}
|
|
1500
1500
|
const repoParams = {
|
|
1501
1501
|
filters: {
|
|
@@ -1513,8 +1513,8 @@ class CatalogService {
|
|
|
1513
1513
|
},
|
|
1514
1514
|
};
|
|
1515
1515
|
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1516
|
-
return this.productRepository.findCatalog(repoParams);
|
|
1517
|
-
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1516
|
+
return this.productRepository.findCatalog(repoParams, undefined, optionsCache);
|
|
1517
|
+
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
1518
1518
|
}
|
|
1519
1519
|
async buildMainFilter({ category, profile, term, }) {
|
|
1520
1520
|
if (category)
|
|
@@ -1526,7 +1526,7 @@ class CatalogService {
|
|
|
1526
1526
|
.search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
|
|
1527
1527
|
.then((data) => ({ id: { operator: Where.IN, value: data.map((_source) => _source.id) } }));
|
|
1528
1528
|
}
|
|
1529
|
-
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1529
|
+
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits, optionsCache) {
|
|
1530
1530
|
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1531
1531
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1532
1532
|
const totalResult = await this.productRepository.findCatalog({
|
|
@@ -1540,7 +1540,7 @@ class CatalogService {
|
|
|
1540
1540
|
maximum: ['price'],
|
|
1541
1541
|
...(!brandsList && isEmpty(options.filters?.brands) ? { distinct: ['brand'] } : {}),
|
|
1542
1542
|
},
|
|
1543
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1543
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
1544
1544
|
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1545
1545
|
const firstProducts = totalResult.data
|
|
1546
1546
|
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
@@ -1678,20 +1678,20 @@ class CategoryService {
|
|
|
1678
1678
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1679
1679
|
this.shop = shop;
|
|
1680
1680
|
}
|
|
1681
|
-
async fetchBrands(category, options) {
|
|
1681
|
+
async fetchBrands(category, options, optionsCache) {
|
|
1682
1682
|
const brands = await this.productRepository
|
|
1683
1683
|
.findCatalog({
|
|
1684
1684
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1685
1685
|
fields: ['brand'],
|
|
1686
|
-
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1686
|
+
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache)
|
|
1687
1687
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1688
1688
|
return this.categoryRepository
|
|
1689
|
-
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1689
|
+
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } }, optionsCache)
|
|
1690
1690
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1691
1691
|
}
|
|
1692
|
-
async fetchFilterOptions(category) {
|
|
1692
|
+
async fetchFilterOptions(category, optionsCache) {
|
|
1693
1693
|
return await this.categoryFilterRepository
|
|
1694
|
-
.find({ filters: { categoryId: +category.id } })
|
|
1694
|
+
.find({ filters: { categoryId: +category.id } }, optionsCache)
|
|
1695
1695
|
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1696
1696
|
}
|
|
1697
1697
|
}
|