@infrab4a/connect-angular 4.0.0-beta.31 → 4.0.0-beta.33

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.
Files changed (26) hide show
  1. package/angular-connect.module.d.ts +1 -0
  2. package/consts/category-structure.d.ts +1 -0
  3. package/consts/index.d.ts +1 -0
  4. package/esm2020/angular-connect.module.mjs +9 -2
  5. package/esm2020/angular-hasura-graphql.module.mjs +18 -2
  6. package/esm2020/consts/category-structure.mjs +2 -0
  7. package/esm2020/consts/index.mjs +2 -1
  8. package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +2 -0
  9. package/esm2020/services/catalog/adapters/index.mjs +4 -0
  10. package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +42 -0
  11. package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +23 -0
  12. package/esm2020/services/catalog/catalog.service.mjs +28 -17
  13. package/esm2020/services/catalog/category.service.mjs +18 -17
  14. package/esm2020/services/catalog/enums/product-sorts.enum.mjs +2 -1
  15. package/fesm2015/infrab4a-connect-angular.mjs +155 -47
  16. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
  17. package/fesm2020/infrab4a-connect-angular.mjs +134 -41
  18. package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
  19. package/package.json +2 -2
  20. package/services/catalog/adapters/category-structure.adapter.d.ts +4 -0
  21. package/services/catalog/adapters/index.d.ts +3 -0
  22. package/services/catalog/adapters/new-category-structure.adapter.d.ts +14 -0
  23. package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -0
  24. package/services/catalog/catalog.service.d.ts +8 -3
  25. package/services/catalog/category.service.d.ts +6 -5
  26. package/services/catalog/enums/product-sorts.enum.d.ts +2 -1
@@ -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
- import * as i3 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, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
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, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
5
5
  import * as i1 from '@angular/fire/app';
6
6
  import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
7
7
  import * as i1$1 from '@angular/fire/auth';
@@ -17,10 +17,13 @@ import cookie from 'js-cookie';
17
17
  import { CustomError } from 'ts-custom-error';
18
18
  import { __decorate, __metadata } from 'tslib';
19
19
  import { Type } from 'class-transformer';
20
- import * as i1$3 from '@angular/common/http';
20
+ import * as i1$4 from '@angular/common/http';
21
+ import { Where as Where$1, isNil as isNil$1 } from '@infrab4a/connect/src';
21
22
 
22
23
  const BACKEND_URL = 'BACKEND_URL';
23
24
 
25
+ const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
26
+
24
27
  const DEFAULT_SHOP = 'DEFAULT_SHOP';
25
28
 
26
29
  const ES_CONFIG = 'ES_CONFIG';
@@ -717,6 +720,14 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
717
720
  },
718
721
  deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
719
722
  },
723
+ {
724
+ provide: CategoryCollectionChildrenHasuraGraphQLRepository,
725
+ useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
726
+ },
727
+ {
728
+ provide: 'CategoryCollectionChildrenRepository',
729
+ useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
730
+ },
720
731
  ] });
721
732
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
722
733
  type: NgModule,
@@ -811,6 +822,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
811
822
  },
812
823
  deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
813
824
  },
825
+ {
826
+ provide: CategoryCollectionChildrenHasuraGraphQLRepository,
827
+ useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
828
+ },
829
+ {
830
+ provide: 'CategoryCollectionChildrenRepository',
831
+ useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
832
+ },
814
833
  ],
815
834
  }]
816
835
  }] });
@@ -1050,7 +1069,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1050
1069
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1051
1070
  type: Inject,
1052
1071
  args: ['CouponRepository']
1053
- }] }, { type: i3.Shops, decorators: [{
1072
+ }] }, { type: i1$3.Shops, decorators: [{
1054
1073
  type: Inject,
1055
1074
  args: [DEFAULT_SHOP]
1056
1075
  }] }, { type: undefined, decorators: [{
@@ -1119,7 +1138,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1119
1138
  }] }, { type: undefined, decorators: [{
1120
1139
  type: Inject,
1121
1140
  args: ['UserRepository']
1122
- }] }, { type: i3.Shops, decorators: [{
1141
+ }] }, { type: i1$3.Shops, decorators: [{
1123
1142
  type: Inject,
1124
1143
  args: [DEFAULT_SHOP]
1125
1144
  }] }]; } });
@@ -1377,7 +1396,7 @@ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15
1377
1396
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
1378
1397
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1379
1398
  type: Injectable
1380
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i3.Shops, decorators: [{
1399
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$3.Shops, decorators: [{
1381
1400
  type: Inject,
1382
1401
  args: [DEFAULT_SHOP]
1383
1402
  }] }, { type: undefined, decorators: [{
@@ -1389,16 +1408,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1389
1408
  }] }, { type: undefined, decorators: [{
1390
1409
  type: Inject,
1391
1410
  args: ['VariantRepository']
1392
- }] }, { type: i3.Buy2WinFirestoreRepository, decorators: [{
1411
+ }] }, { type: i1$3.Buy2WinFirestoreRepository, decorators: [{
1393
1412
  type: Inject,
1394
1413
  args: ['Buy2WinRepository']
1395
1414
  }] }]; } });
1396
1415
 
1397
1416
  class CatalogService {
1398
- constructor(productRepository, categoryRepository) {
1417
+ constructor(productRepository, categoryStructureAdapter, shop) {
1399
1418
  this.productRepository = productRepository;
1400
- this.categoryRepository = categoryRepository;
1401
- this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, }) => {
1419
+ this.categoryStructureAdapter = categoryStructureAdapter;
1420
+ this.shop = shop;
1421
+ this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, }) => {
1402
1422
  const filters = {};
1403
1423
  if (clubDiscount?.length)
1404
1424
  set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
@@ -1416,6 +1436,10 @@ class CatalogService {
1416
1436
  ...(prices.min ? [{ operator: Where.GTE, value: prices.min }] : []),
1417
1437
  ...(prices.max ? [{ operator: Where.LTE, value: prices.max }] : []),
1418
1438
  ]);
1439
+ if (rate)
1440
+ filters.rate = { operator: Where.GTE, value: rate };
1441
+ if (tags?.length)
1442
+ filters.tags = { operator: Where.LIKE, value: tags };
1419
1443
  return filters;
1420
1444
  };
1421
1445
  this.buildSortQuery = (sort) => {
@@ -1429,6 +1453,8 @@ class CatalogService {
1429
1453
  return { price: 'asc' };
1430
1454
  if (sort === 'best-rating')
1431
1455
  return { rate: 'desc' };
1456
+ if (sort === 'news')
1457
+ return { createdAt: 'desc' };
1432
1458
  };
1433
1459
  this.buildLimitQuery = (options) => {
1434
1460
  const limit = options?.perPage || 20;
@@ -1439,32 +1465,31 @@ class CatalogService {
1439
1465
  };
1440
1466
  }
1441
1467
  async fetchProducts(category, options) {
1442
- const productsIds = category.products?.length
1443
- ? category.products
1444
- : await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1445
1468
  const limits = this.buildLimitQuery(options);
1446
1469
  return await this.productRepository
1447
- .find({
1470
+ .findCatalog({
1448
1471
  filters: {
1449
- id: { operator: Where.IN, value: productsIds },
1450
- published: true,
1472
+ ...(await this.categoryStructureAdapter.buildProductFilterByCategory(category)),
1451
1473
  ...this.buildFilterQuery(options?.filters || {}),
1452
1474
  },
1453
1475
  ...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
1454
1476
  limits,
1455
1477
  options: { minimal: ['price'], maximum: ['price'] },
1456
- })
1478
+ }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1457
1479
  .then(({ data, count: total, maximum, minimal }) => ({
1458
- products: { data, total },
1480
+ products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1459
1481
  pages: Math.ceil(total / limits.limit),
1460
1482
  prices: {
1461
- price: { min: minimal.price.price, max: maximum.price.price },
1462
- subscriberPrice: { min: minimal.price.subscriberPrice, max: maximum.price.subscriberPrice },
1483
+ price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
1484
+ subscriberPrice: {
1485
+ min: +minimal?.price?.subscriberPrice?.toFixed(2),
1486
+ max: +maximum?.price?.subscriberPrice?.toFixed(2),
1487
+ },
1463
1488
  },
1464
1489
  }));
1465
1490
  }
1466
1491
  }
1467
- CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1492
+ 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 });
1468
1493
  CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1469
1494
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1470
1495
  type: Injectable
@@ -1473,35 +1498,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1473
1498
  args: ['ProductRepository']
1474
1499
  }] }, { type: undefined, decorators: [{
1475
1500
  type: Inject,
1476
- args: ['CategoryRepository']
1501
+ args: [CATEGORY_STRUCTURE]
1502
+ }] }, { type: i1$3.Shops, decorators: [{
1503
+ type: Inject,
1504
+ args: [DEFAULT_SHOP]
1477
1505
  }] }]; } });
1478
1506
 
1479
1507
  class CategoryService {
1480
- constructor(productRepository, categoryRepository, categoryFilterRepository) {
1508
+ constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1481
1509
  this.productRepository = productRepository;
1482
1510
  this.categoryRepository = categoryRepository;
1483
1511
  this.categoryFilterRepository = categoryFilterRepository;
1512
+ this.categoryStructureAdapter = categoryStructureAdapter;
1513
+ this.shop = shop;
1484
1514
  }
1485
- async fetchBrands(category) {
1486
- const productsIds = category.products?.length
1487
- ? category.products
1488
- : await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1515
+ async fetchBrands(category, mainGender) {
1489
1516
  const brands = await this.productRepository
1490
- .find({
1491
- filters: {
1492
- id: { operator: Where.IN, value: productsIds },
1493
- published: true,
1494
- },
1517
+ .findCatalog({
1518
+ filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
1495
1519
  fields: ['brand'],
1496
- })
1520
+ }, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1497
1521
  .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
1498
1522
  return this.categoryRepository
1499
1523
  .find({ filters: { brandCategory: true }, orderBy: { name: 'asc' } })
1500
1524
  .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1501
1525
  }
1502
- async fetchSubCategories(category) {
1503
- return [];
1504
- }
1505
1526
  async fetchFilterOptions(category, filters) {
1506
1527
  const categoryFilters = category.filters && category.filters.length
1507
1528
  ? category.filters
@@ -1513,7 +1534,7 @@ class CategoryService {
1513
1534
  : categoryFilters;
1514
1535
  }
1515
1536
  }
1516
- CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1537
+ CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1517
1538
  CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1518
1539
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1519
1540
  type: Injectable
@@ -1526,6 +1547,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1526
1547
  }] }, { type: undefined, decorators: [{
1527
1548
  type: Inject,
1528
1549
  args: ['CategoryFilterRepository']
1550
+ }] }, { type: undefined, decorators: [{
1551
+ type: Inject,
1552
+ args: [CATEGORY_STRUCTURE]
1553
+ }] }, { type: i1$3.Shops, decorators: [{
1554
+ type: Inject,
1555
+ args: [DEFAULT_SHOP]
1529
1556
  }] }]; } });
1530
1557
 
1531
1558
  var ProductSorts;
@@ -1536,6 +1563,7 @@ var ProductSorts;
1536
1563
  ProductSorts["LOWEST_PRICE"] = "lowest-price";
1537
1564
  ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1538
1565
  ProductSorts["BEST_RATING"] = "best-rating";
1566
+ ProductSorts["NEWS"] = "news";
1539
1567
  })(ProductSorts || (ProductSorts = {}));
1540
1568
 
1541
1569
  class CategoryWithTree extends Category {
@@ -1692,7 +1720,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1692
1720
  }] }, { type: undefined, decorators: [{
1693
1721
  type: Inject,
1694
1722
  args: ['ProductRepository']
1695
- }] }, { type: i3.Shops, decorators: [{
1723
+ }] }, { type: i1$3.Shops, decorators: [{
1696
1724
  type: Inject,
1697
1725
  args: [DEFAULT_SHOP]
1698
1726
  }] }]; } });
@@ -1714,7 +1742,7 @@ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "1
1714
1742
  OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
1715
1743
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
1716
1744
  type: Injectable
1717
- }], ctorParameters: function () { return [{ type: i1$2.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
1745
+ }], ctorParameters: function () { return [{ type: i1$2.Firestore }, { type: i1$3.OrderFirestoreRepository, decorators: [{
1718
1746
  type: Inject,
1719
1747
  args: ['OrderRepository']
1720
1748
  }] }]; } });
@@ -1796,20 +1824,85 @@ class ShippingService {
1796
1824
  return false;
1797
1825
  }
1798
1826
  }
1799
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
1827
+ ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$4.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
1800
1828
  ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
1801
1829
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
1802
1830
  type: Injectable
1803
- }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
1831
+ }], ctorParameters: function () { return [{ type: i1$4.HttpClient }, { type: undefined, decorators: [{
1804
1832
  type: Inject,
1805
1833
  args: [BACKEND_URL]
1806
1834
  }] }, { type: HomeShopService }]; } });
1807
1835
 
1836
+ class NewCategoryStructureAdapter {
1837
+ constructor(categoryRepository, categoryCollectionChildrenRepository) {
1838
+ this.categoryRepository = categoryRepository;
1839
+ this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1840
+ }
1841
+ async buildProductFilterByCategory(category) {
1842
+ const categoriesIds = (await this.isCollection(category))
1843
+ ? await this.getAllCategoriesIdFromCollection(category)
1844
+ : [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1845
+ return { category: { id: { operator: Where$1.IN, value: categoriesIds } } };
1846
+ }
1847
+ async getAllCategoriesIdFromCategory(category) {
1848
+ return this.categoryRepository
1849
+ .getChildren(+category.id)
1850
+ .then((categories) => categories.map((category) => category.id.toString()));
1851
+ }
1852
+ async getAllCategoriesIdFromCollection(category) {
1853
+ return this.categoryCollectionChildrenRepository
1854
+ .find({ filters: { collectionId: +category.id } })
1855
+ .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1856
+ }
1857
+ async isCollection(category) {
1858
+ return !isNil$1(category.isCollection)
1859
+ ? category.isCollection
1860
+ : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1861
+ }
1862
+ }
1863
+ NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1864
+ NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1865
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1866
+ type: Injectable
1867
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1868
+ type: Inject,
1869
+ args: ['CategoryRepository']
1870
+ }] }, { type: undefined, decorators: [{
1871
+ type: Inject,
1872
+ args: ['CategoryCollectionChildrenRepository']
1873
+ }] }]; } });
1874
+
1875
+ class OldCategoryStructureAdapter {
1876
+ constructor(categoryRepository) {
1877
+ this.categoryRepository = categoryRepository;
1878
+ }
1879
+ async buildProductFilterByCategory(category) {
1880
+ const productsIds = category.products?.length
1881
+ ? category.products
1882
+ : await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1883
+ return { id: { operator: Where$1.IN, value: productsIds } };
1884
+ }
1885
+ }
1886
+ OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1887
+ OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1888
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1889
+ type: Injectable
1890
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1891
+ type: Inject,
1892
+ args: ['CategoryRepository']
1893
+ }] }]; } });
1894
+
1808
1895
  class AngularConnectModule {
1809
1896
  static initializeApp(defaultShop, options, nameOrConfig) {
1810
1897
  return {
1811
1898
  ngModule: AngularConnectModule,
1812
1899
  providers: [
1900
+ {
1901
+ provide: CATEGORY_STRUCTURE,
1902
+ useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
1903
+ ? OldCategoryStructureAdapter
1904
+ : NewCategoryStructureAdapter,
1905
+ },
1813
1906
  ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1814
1907
  ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
1815
1908
  ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),