@infrab4a/connect-angular 5.0.0-beta.93 → 5.0.0-beta.94
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-hasura-graphql.module.d.ts +3 -5
- package/esm2022/angular-hasura-graphql.module.mjs +3 -1
- package/esm2022/services/catalog/catalog.service.mjs +37 -10
- package/esm2022/services/catalog/category.service.mjs +6 -6
- package/fesm2022/infrab4a-connect-angular.mjs +43 -14
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +5 -2
- package/services/catalog/category.service.d.ts +7 -3
|
@@ -741,6 +741,7 @@ class AngularHasuraGraphQLModule {
|
|
|
741
741
|
useFactory: (options, platformId) => ({
|
|
742
742
|
endpoint: options.endpoint,
|
|
743
743
|
authOptions: options.credentials,
|
|
744
|
+
cache: options.cache,
|
|
744
745
|
interceptors: {
|
|
745
746
|
request: (request) => {
|
|
746
747
|
if (isPlatformBrowser(platformId))
|
|
@@ -900,6 +901,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
900
901
|
useFactory: (options, platformId) => ({
|
|
901
902
|
endpoint: options.endpoint,
|
|
902
903
|
authOptions: options.credentials,
|
|
904
|
+
cache: options.cache,
|
|
903
905
|
interceptors: {
|
|
904
906
|
request: (request) => {
|
|
905
907
|
if (isPlatformBrowser(platformId))
|
|
@@ -1388,6 +1390,30 @@ class CatalogService {
|
|
|
1388
1390
|
this.productSearch = productSearch;
|
|
1389
1391
|
this.productsByTerm = {};
|
|
1390
1392
|
this.brandsList = {};
|
|
1393
|
+
this.fields = [
|
|
1394
|
+
'id',
|
|
1395
|
+
'name',
|
|
1396
|
+
'slug',
|
|
1397
|
+
'images',
|
|
1398
|
+
'miniatures',
|
|
1399
|
+
'price',
|
|
1400
|
+
'stock',
|
|
1401
|
+
'published',
|
|
1402
|
+
'CEST',
|
|
1403
|
+
'EAN',
|
|
1404
|
+
'NCM',
|
|
1405
|
+
'brand',
|
|
1406
|
+
'costPrice',
|
|
1407
|
+
'hasVariants',
|
|
1408
|
+
'isKit',
|
|
1409
|
+
'sku',
|
|
1410
|
+
'rate',
|
|
1411
|
+
'tags',
|
|
1412
|
+
'type',
|
|
1413
|
+
'shoppingCount',
|
|
1414
|
+
'gender',
|
|
1415
|
+
'createdAt',
|
|
1416
|
+
];
|
|
1391
1417
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1392
1418
|
const filters = {};
|
|
1393
1419
|
if (clubDiscount?.length)
|
|
@@ -1450,7 +1476,7 @@ class CatalogService {
|
|
|
1450
1476
|
return '';
|
|
1451
1477
|
};
|
|
1452
1478
|
}
|
|
1453
|
-
async fetchProducts(options) {
|
|
1479
|
+
async fetchProducts(options, optionsCache) {
|
|
1454
1480
|
const limits = this.buildLimitQuery(options);
|
|
1455
1481
|
if (this.hasProfile(options) && options.filters?.customOptions)
|
|
1456
1482
|
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
@@ -1458,7 +1484,7 @@ class CatalogService {
|
|
|
1458
1484
|
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1459
1485
|
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1460
1486
|
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1461
|
-
return await this.findCatalog(options, limits).then(async ({ data, count: total, maximum, minimal, distinct }) => {
|
|
1487
|
+
return await this.findCatalog(options, limits, optionsCache).then(async ({ data, count: total, maximum, minimal, distinct }) => {
|
|
1462
1488
|
await this.setBrandsList(options, distinct?.brand);
|
|
1463
1489
|
return {
|
|
1464
1490
|
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
@@ -1477,7 +1503,7 @@ class CatalogService {
|
|
|
1477
1503
|
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1478
1504
|
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1479
1505
|
}
|
|
1480
|
-
async findCatalog(options, limits) {
|
|
1506
|
+
async findCatalog(options, limits, optionsCache) {
|
|
1481
1507
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1482
1508
|
const productsIds = await this.findCatalogIdsBySearch(options.term);
|
|
1483
1509
|
return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
|
|
@@ -1491,11 +1517,12 @@ class CatalogService {
|
|
|
1491
1517
|
...(await this.buildMainFilter(options)),
|
|
1492
1518
|
...this.buildFilterQuery(options?.filters || {}),
|
|
1493
1519
|
},
|
|
1494
|
-
})
|
|
1520
|
+
}, undefined, optionsCache)
|
|
1495
1521
|
.then((products) => products.data.map((product) => product.id));
|
|
1496
|
-
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1522
|
+
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits, optionsCache);
|
|
1497
1523
|
}
|
|
1498
1524
|
const repoParams = {
|
|
1525
|
+
fields: this.fields,
|
|
1499
1526
|
filters: {
|
|
1500
1527
|
...(await this.buildMainFilter(options)),
|
|
1501
1528
|
...this.buildFilterQuery(options?.filters || {}),
|
|
@@ -1511,8 +1538,8 @@ class CatalogService {
|
|
|
1511
1538
|
},
|
|
1512
1539
|
};
|
|
1513
1540
|
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1514
|
-
return this.productRepository.findCatalog(repoParams);
|
|
1515
|
-
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1541
|
+
return this.productRepository.findCatalog(repoParams, undefined, optionsCache);
|
|
1542
|
+
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
1516
1543
|
}
|
|
1517
1544
|
async buildMainFilter({ category, profile, term, }) {
|
|
1518
1545
|
if (category)
|
|
@@ -1524,10 +1551,11 @@ class CatalogService {
|
|
|
1524
1551
|
.search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
|
|
1525
1552
|
.then((data) => ({ id: { operator: Where.IN, value: data.map((_source) => _source.id) } }));
|
|
1526
1553
|
}
|
|
1527
|
-
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1554
|
+
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits, optionsCache) {
|
|
1528
1555
|
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1529
1556
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1530
1557
|
const totalResult = await this.productRepository.findCatalog({
|
|
1558
|
+
fields: this.fields,
|
|
1531
1559
|
filters: {
|
|
1532
1560
|
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1533
1561
|
...this.buildFilterQuery(options?.filters || {}),
|
|
@@ -1538,7 +1566,7 @@ class CatalogService {
|
|
|
1538
1566
|
maximum: ['price'],
|
|
1539
1567
|
...(!brandsList && isEmpty(options.filters?.brands) ? { distinct: ['brand'] } : {}),
|
|
1540
1568
|
},
|
|
1541
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1569
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
1542
1570
|
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1543
1571
|
const firstProducts = totalResult.data
|
|
1544
1572
|
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
@@ -1594,6 +1622,7 @@ class CatalogService {
|
|
|
1594
1622
|
filters: {
|
|
1595
1623
|
id: { operator: Where.IN, value: orderedId },
|
|
1596
1624
|
},
|
|
1625
|
+
fields: this.fields,
|
|
1597
1626
|
});
|
|
1598
1627
|
await this.setBrandsList(options, totalResult.distinct?.brand);
|
|
1599
1628
|
return {
|
|
@@ -1676,20 +1705,20 @@ class CategoryService {
|
|
|
1676
1705
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1677
1706
|
this.shop = shop;
|
|
1678
1707
|
}
|
|
1679
|
-
async fetchBrands(category, options) {
|
|
1708
|
+
async fetchBrands(category, options, optionsCache) {
|
|
1680
1709
|
const brands = await this.productRepository
|
|
1681
1710
|
.findCatalog({
|
|
1682
1711
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1683
1712
|
fields: ['brand'],
|
|
1684
|
-
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1713
|
+
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache)
|
|
1685
1714
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1686
1715
|
return this.categoryRepository
|
|
1687
|
-
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1716
|
+
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } }, optionsCache)
|
|
1688
1717
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1689
1718
|
}
|
|
1690
|
-
async fetchFilterOptions(category) {
|
|
1719
|
+
async fetchFilterOptions(category, optionsCache) {
|
|
1691
1720
|
return await this.categoryFilterRepository
|
|
1692
|
-
.find({ filters: { categoryId: +category.id } })
|
|
1721
|
+
.find({ filters: { categoryId: +category.id } }, optionsCache)
|
|
1693
1722
|
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1694
1723
|
}
|
|
1695
1724
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
|