@infrab4a/connect-angular 4.0.0-beta.32 → 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 { __awaiter, __decorate, __metadata } from 'tslib';
17
17
  import cookie from 'js-cookie';
18
18
  import { CustomError } from 'ts-custom-error';
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
  }] });
@@ -1070,7 +1089,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1070
1089
  return [{ type: undefined, decorators: [{
1071
1090
  type: Inject,
1072
1091
  args: ['CouponRepository']
1073
- }] }, { type: i3.Shops, decorators: [{
1092
+ }] }, { type: i1$3.Shops, decorators: [{
1074
1093
  type: Inject,
1075
1094
  args: [DEFAULT_SHOP]
1076
1095
  }] }, { type: undefined, decorators: [{
@@ -1142,7 +1161,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1142
1161
  }] }, { type: undefined, decorators: [{
1143
1162
  type: Inject,
1144
1163
  args: ['UserRepository']
1145
- }] }, { type: i3.Shops, decorators: [{
1164
+ }] }, { type: i1$3.Shops, decorators: [{
1146
1165
  type: Inject,
1147
1166
  args: [DEFAULT_SHOP]
1148
1167
  }] }];
@@ -1399,7 +1418,7 @@ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version:
1399
1418
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1400
1419
  type: Injectable
1401
1420
  }], ctorParameters: function () {
1402
- return [{ type: AuthService }, { type: CheckoutService }, { type: i3.Shops, decorators: [{
1421
+ return [{ type: AuthService }, { type: CheckoutService }, { type: i1$3.Shops, decorators: [{
1403
1422
  type: Inject,
1404
1423
  args: [DEFAULT_SHOP]
1405
1424
  }] }, { type: undefined, decorators: [{
@@ -1411,17 +1430,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1411
1430
  }] }, { type: undefined, decorators: [{
1412
1431
  type: Inject,
1413
1432
  args: ['VariantRepository']
1414
- }] }, { type: i3.Buy2WinFirestoreRepository, decorators: [{
1433
+ }] }, { type: i1$3.Buy2WinFirestoreRepository, decorators: [{
1415
1434
  type: Inject,
1416
1435
  args: ['Buy2WinRepository']
1417
1436
  }] }];
1418
1437
  } });
1419
1438
 
1420
1439
  class CatalogService {
1421
- constructor(productRepository, categoryRepository) {
1440
+ constructor(productRepository, categoryStructureAdapter, shop) {
1422
1441
  this.productRepository = productRepository;
1423
- this.categoryRepository = categoryRepository;
1424
- this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, }) => {
1442
+ this.categoryStructureAdapter = categoryStructureAdapter;
1443
+ this.shop = shop;
1444
+ this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, }) => {
1425
1445
  const filters = {};
1426
1446
  if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
1427
1447
  set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
@@ -1439,6 +1459,10 @@ class CatalogService {
1439
1459
  ...(prices.min ? [{ operator: Where.GTE, value: prices.min }] : []),
1440
1460
  ...(prices.max ? [{ operator: Where.LTE, value: prices.max }] : []),
1441
1461
  ]);
1462
+ if (rate)
1463
+ filters.rate = { operator: Where.GTE, value: rate };
1464
+ if (tags === null || tags === void 0 ? void 0 : tags.length)
1465
+ filters.tags = { operator: Where.LIKE, value: tags };
1442
1466
  return filters;
1443
1467
  };
1444
1468
  this.buildSortQuery = (sort) => {
@@ -1452,6 +1476,8 @@ class CatalogService {
1452
1476
  return { price: 'asc' };
1453
1477
  if (sort === 'best-rating')
1454
1478
  return { rate: 'desc' };
1479
+ if (sort === 'news')
1480
+ return { createdAt: 'desc' };
1455
1481
  };
1456
1482
  this.buildLimitQuery = (options) => {
1457
1483
  const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
@@ -1462,26 +1488,28 @@ class CatalogService {
1462
1488
  };
1463
1489
  }
1464
1490
  fetchProducts(category, options) {
1465
- var _a;
1466
1491
  return __awaiter(this, void 0, void 0, function* () {
1467
- const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1468
- ? category.products
1469
- : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1470
1492
  const limits = this.buildLimitQuery(options);
1471
1493
  return yield this.productRepository
1472
- .find(Object.assign(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: productsIds }, published: true }, this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: { minimal: ['price'], maximum: ['price'] } }))
1473
- .then(({ data, count: total, maximum, minimal }) => ({
1474
- products: { data, total },
1475
- pages: Math.ceil(total / limits.limit),
1476
- prices: {
1477
- price: { min: minimal.price.price, max: maximum.price.price },
1478
- subscriberPrice: { min: minimal.price.subscriberPrice, max: maximum.price.subscriberPrice },
1479
- },
1480
- }));
1494
+ .findCatalog(Object.assign(Object.assign({ filters: Object.assign(Object.assign({}, (yield this.categoryStructureAdapter.buildProductFilterByCategory(category))), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: { minimal: ['price'], maximum: ['price'] } }), (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1495
+ .then(({ data, count: total, maximum, minimal }) => {
1496
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1497
+ return ({
1498
+ products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1499
+ pages: Math.ceil(total / limits.limit),
1500
+ prices: {
1501
+ price: { min: +((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)), max: +((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) },
1502
+ subscriberPrice: {
1503
+ min: +((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)),
1504
+ max: +((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)),
1505
+ },
1506
+ },
1507
+ });
1508
+ });
1481
1509
  });
1482
1510
  }
1483
1511
  }
1484
- 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 });
1512
+ 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 });
1485
1513
  CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1486
1514
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1487
1515
  type: Injectable
@@ -1491,41 +1519,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1491
1519
  args: ['ProductRepository']
1492
1520
  }] }, { type: undefined, decorators: [{
1493
1521
  type: Inject,
1494
- args: ['CategoryRepository']
1522
+ args: [CATEGORY_STRUCTURE]
1523
+ }] }, { type: i1$3.Shops, decorators: [{
1524
+ type: Inject,
1525
+ args: [DEFAULT_SHOP]
1495
1526
  }] }];
1496
1527
  } });
1497
1528
 
1498
1529
  class CategoryService {
1499
- constructor(productRepository, categoryRepository, categoryFilterRepository) {
1530
+ constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1500
1531
  this.productRepository = productRepository;
1501
1532
  this.categoryRepository = categoryRepository;
1502
1533
  this.categoryFilterRepository = categoryFilterRepository;
1534
+ this.categoryStructureAdapter = categoryStructureAdapter;
1535
+ this.shop = shop;
1503
1536
  }
1504
- fetchBrands(category) {
1505
- var _a;
1537
+ fetchBrands(category, mainGender) {
1506
1538
  return __awaiter(this, void 0, void 0, function* () {
1507
- const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1508
- ? category.products
1509
- : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1510
1539
  const brands = yield this.productRepository
1511
- .find({
1512
- filters: {
1513
- id: { operator: Where.IN, value: productsIds },
1514
- published: true,
1515
- },
1540
+ .findCatalog({
1541
+ filters: yield this.categoryStructureAdapter.buildProductFilterByCategory(category),
1516
1542
  fields: ['brand'],
1517
- })
1543
+ }, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1518
1544
  .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => (Object.assign(Object.assign({}, brands), { [brand]: true })), {})));
1519
1545
  return this.categoryRepository
1520
1546
  .find({ filters: { brandCategory: true }, orderBy: { name: 'asc' } })
1521
1547
  .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1522
1548
  });
1523
1549
  }
1524
- fetchSubCategories(category) {
1525
- return __awaiter(this, void 0, void 0, function* () {
1526
- return [];
1527
- });
1528
- }
1529
1550
  fetchFilterOptions(category, filters) {
1530
1551
  return __awaiter(this, void 0, void 0, function* () {
1531
1552
  const categoryFilters = category.filters && category.filters.length
@@ -1539,7 +1560,7 @@ class CategoryService {
1539
1560
  });
1540
1561
  }
1541
1562
  }
1542
- 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 });
1563
+ 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 });
1543
1564
  CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1544
1565
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1545
1566
  type: Injectable
@@ -1553,6 +1574,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1553
1574
  }] }, { type: undefined, decorators: [{
1554
1575
  type: Inject,
1555
1576
  args: ['CategoryFilterRepository']
1577
+ }] }, { type: undefined, decorators: [{
1578
+ type: Inject,
1579
+ args: [CATEGORY_STRUCTURE]
1580
+ }] }, { type: i1$3.Shops, decorators: [{
1581
+ type: Inject,
1582
+ args: [DEFAULT_SHOP]
1556
1583
  }] }];
1557
1584
  } });
1558
1585
 
@@ -1564,6 +1591,7 @@ var ProductSorts;
1564
1591
  ProductSorts["LOWEST_PRICE"] = "lowest-price";
1565
1592
  ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1566
1593
  ProductSorts["BEST_RATING"] = "best-rating";
1594
+ ProductSorts["NEWS"] = "news";
1567
1595
  })(ProductSorts || (ProductSorts = {}));
1568
1596
 
1569
1597
  class CategoryWithTree extends Category {
@@ -1725,7 +1753,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1725
1753
  }] }, { type: undefined, decorators: [{
1726
1754
  type: Inject,
1727
1755
  args: ['ProductRepository']
1728
- }] }, { type: i3.Shops, decorators: [{
1756
+ }] }, { type: i1$3.Shops, decorators: [{
1729
1757
  type: Inject,
1730
1758
  args: [DEFAULT_SHOP]
1731
1759
  }] }];
@@ -1749,7 +1777,7 @@ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version
1749
1777
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
1750
1778
  type: Injectable
1751
1779
  }], ctorParameters: function () {
1752
- return [{ type: i1$2.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
1780
+ return [{ type: i1$2.Firestore }, { type: i1$3.OrderFirestoreRepository, decorators: [{
1753
1781
  type: Inject,
1754
1782
  args: ['OrderRepository']
1755
1783
  }] }];
@@ -1832,22 +1860,102 @@ class ShippingService {
1832
1860
  return false;
1833
1861
  }
1834
1862
  }
1835
- 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 });
1863
+ 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 });
1836
1864
  ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
1837
1865
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
1838
1866
  type: Injectable
1839
1867
  }], ctorParameters: function () {
1840
- return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
1868
+ return [{ type: i1$4.HttpClient }, { type: undefined, decorators: [{
1841
1869
  type: Inject,
1842
1870
  args: [BACKEND_URL]
1843
1871
  }] }, { type: HomeShopService }];
1844
1872
  } });
1845
1873
 
1874
+ class NewCategoryStructureAdapter {
1875
+ constructor(categoryRepository, categoryCollectionChildrenRepository) {
1876
+ this.categoryRepository = categoryRepository;
1877
+ this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1878
+ }
1879
+ buildProductFilterByCategory(category) {
1880
+ return __awaiter(this, void 0, void 0, function* () {
1881
+ const categoriesIds = (yield this.isCollection(category))
1882
+ ? yield this.getAllCategoriesIdFromCollection(category)
1883
+ : [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1884
+ return { category: { id: { operator: Where$1.IN, value: categoriesIds } } };
1885
+ });
1886
+ }
1887
+ getAllCategoriesIdFromCategory(category) {
1888
+ return __awaiter(this, void 0, void 0, function* () {
1889
+ return this.categoryRepository
1890
+ .getChildren(+category.id)
1891
+ .then((categories) => categories.map((category) => category.id.toString()));
1892
+ });
1893
+ }
1894
+ getAllCategoriesIdFromCollection(category) {
1895
+ return __awaiter(this, void 0, void 0, function* () {
1896
+ return this.categoryCollectionChildrenRepository
1897
+ .find({ filters: { collectionId: +category.id } })
1898
+ .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1899
+ });
1900
+ }
1901
+ isCollection(category) {
1902
+ return __awaiter(this, void 0, void 0, function* () {
1903
+ return !isNil$1(category.isCollection)
1904
+ ? category.isCollection
1905
+ : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1906
+ });
1907
+ }
1908
+ }
1909
+ 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 });
1910
+ NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1911
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1912
+ type: Injectable
1913
+ }], ctorParameters: function () {
1914
+ return [{ type: undefined, decorators: [{
1915
+ type: Inject,
1916
+ args: ['CategoryRepository']
1917
+ }] }, { type: undefined, decorators: [{
1918
+ type: Inject,
1919
+ args: ['CategoryCollectionChildrenRepository']
1920
+ }] }];
1921
+ } });
1922
+
1923
+ class OldCategoryStructureAdapter {
1924
+ constructor(categoryRepository) {
1925
+ this.categoryRepository = categoryRepository;
1926
+ }
1927
+ buildProductFilterByCategory(category) {
1928
+ var _a;
1929
+ return __awaiter(this, void 0, void 0, function* () {
1930
+ const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1931
+ ? category.products
1932
+ : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1933
+ return { id: { operator: Where$1.IN, value: productsIds } };
1934
+ });
1935
+ }
1936
+ }
1937
+ OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1938
+ OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1939
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1940
+ type: Injectable
1941
+ }], ctorParameters: function () {
1942
+ return [{ type: undefined, decorators: [{
1943
+ type: Inject,
1944
+ args: ['CategoryRepository']
1945
+ }] }];
1946
+ } });
1947
+
1846
1948
  class AngularConnectModule {
1847
1949
  static initializeApp(defaultShop, options, nameOrConfig) {
1848
1950
  return {
1849
1951
  ngModule: AngularConnectModule,
1850
1952
  providers: [
1953
+ {
1954
+ provide: CATEGORY_STRUCTURE,
1955
+ useClass: isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
1956
+ ? OldCategoryStructureAdapter
1957
+ : NewCategoryStructureAdapter,
1958
+ },
1851
1959
  ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1852
1960
  ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1853
1961
  ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),