@infrab4a/connect-angular 4.18.4 → 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.
@@ -742,6 +742,7 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
742
742
  useFactory: (options, platformId) => ({
743
743
  endpoint: options.endpoint,
744
744
  authOptions: options.credentials,
745
+ cache: options.cache,
745
746
  interceptors: {
746
747
  request: (request) => {
747
748
  if (isPlatformBrowser(platformId))
@@ -900,6 +901,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", 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))
@@ -1450,7 +1452,7 @@ class CatalogService {
1450
1452
  return '';
1451
1453
  };
1452
1454
  }
1453
- async fetchProducts(options) {
1455
+ async fetchProducts(options, optionsCache) {
1454
1456
  const limits = this.buildLimitQuery(options);
1455
1457
  if (this.hasProfile(options) && options.filters?.customOptions)
1456
1458
  throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
@@ -1458,7 +1460,7 @@ class CatalogService {
1458
1460
  throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1459
1461
  if (this.hasTerm(options) && options.filters?.customOptions)
1460
1462
  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 }) => {
1463
+ return await this.findCatalog(options, limits, optionsCache).then(async ({ data, count: total, maximum, minimal, distinct }) => {
1462
1464
  await this.setBrandsList(options, distinct?.brand);
1463
1465
  return {
1464
1466
  products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
@@ -1477,7 +1479,7 @@ class CatalogService {
1477
1479
  async addCustomerToStockNotification(shop, productId, name, email) {
1478
1480
  return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
1479
1481
  }
1480
- async findCatalog(options, limits) {
1482
+ async findCatalog(options, limits, optionsCache) {
1481
1483
  if (this.hasTerm(options) && options.sort === 'most-relevant') {
1482
1484
  const productsIds = await this.findCatalogIdsBySearch(options.term);
1483
1485
  return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
@@ -1491,9 +1493,9 @@ class CatalogService {
1491
1493
  ...(await this.buildMainFilter(options)),
1492
1494
  ...this.buildFilterQuery(options?.filters || {}),
1493
1495
  },
1494
- })
1496
+ }, undefined, optionsCache)
1495
1497
  .then((products) => products.data.map((product) => product.id));
1496
- return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
1498
+ return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits, optionsCache);
1497
1499
  }
1498
1500
  const repoParams = {
1499
1501
  filters: {
@@ -1511,8 +1513,8 @@ class CatalogService {
1511
1513
  },
1512
1514
  };
1513
1515
  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');
1516
+ return this.productRepository.findCatalog(repoParams, undefined, optionsCache);
1517
+ return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
1516
1518
  }
1517
1519
  async buildMainFilter({ category, profile, term, }) {
1518
1520
  if (category)
@@ -1524,7 +1526,7 @@ class CatalogService {
1524
1526
  .search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
1525
1527
  .then((data) => ({ id: { operator: Where.IN, value: data.map((_source) => _source.id) } }));
1526
1528
  }
1527
- async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
1529
+ async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits, optionsCache) {
1528
1530
  const brandsList = this.brandsList[this.buildIndexBrands(options)];
1529
1531
  const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
1530
1532
  const totalResult = await this.productRepository.findCatalog({
@@ -1538,7 +1540,7 @@ class CatalogService {
1538
1540
  maximum: ['price'],
1539
1541
  ...(!brandsList && isEmpty(options.filters?.brands) ? { distinct: ['brand'] } : {}),
1540
1542
  },
1541
- }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1543
+ }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
1542
1544
  const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
1543
1545
  const firstProducts = totalResult.data
1544
1546
  .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
@@ -1676,20 +1678,20 @@ class CategoryService {
1676
1678
  this.categoryStructureAdapter = categoryStructureAdapter;
1677
1679
  this.shop = shop;
1678
1680
  }
1679
- async fetchBrands(category, options) {
1681
+ async fetchBrands(category, options, optionsCache) {
1680
1682
  const brands = await this.productRepository
1681
1683
  .findCatalog({
1682
1684
  filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
1683
1685
  fields: ['brand'],
1684
- }, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
1686
+ }, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache)
1685
1687
  .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
1686
1688
  return this.categoryRepository
1687
- .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)
1688
1690
  .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1689
1691
  }
1690
- async fetchFilterOptions(category) {
1692
+ async fetchFilterOptions(category, optionsCache) {
1691
1693
  return await this.categoryFilterRepository
1692
- .find({ filters: { categoryId: +category.id } })
1694
+ .find({ filters: { categoryId: +category.id } }, optionsCache)
1693
1695
  .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1694
1696
  }
1695
1697
  }