@infrab4a/connect-angular 4.0.0-beta.54 → 4.0.0-beta.56

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.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, NgModule, PLATFORM_ID, Injectable, Inject } from '@angular/core';
2
+ import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angular/core';
3
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, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
4
+ import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, 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, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
5
5
  import * as i1 from '@angular/fire/app';
6
6
  import { provideFirebaseApp, initializeApp, FirebaseApp } from '@angular/fire/app';
7
7
  import * as i1$1 from '@angular/fire/auth';
@@ -17,14 +17,44 @@ import { __decorate, __metadata } from 'tslib';
17
17
  import { Type } from 'class-transformer';
18
18
  import * as i1$4 from '@angular/common/http';
19
19
 
20
+ const ES_CONFIG = 'ES_CONFIG';
21
+
22
+ class AngularElasticSeachModule {
23
+ static initializeApp(options) {
24
+ return {
25
+ ngModule: AngularElasticSeachModule,
26
+ providers: [{ provide: ES_CONFIG, useValue: options }],
27
+ };
28
+ }
29
+ }
30
+ AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
31
+ AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
32
+ AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
33
+ {
34
+ provide: ProductsIndex,
35
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
36
+ deps: [ES_CONFIG],
37
+ },
38
+ ] });
39
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
40
+ type: NgModule,
41
+ args: [{
42
+ providers: [
43
+ {
44
+ provide: ProductsIndex,
45
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
46
+ deps: [ES_CONFIG],
47
+ },
48
+ ],
49
+ }]
50
+ }] });
51
+
20
52
  const BACKEND_URL = 'BACKEND_URL';
21
53
 
22
54
  const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
23
55
 
24
56
  const DEFAULT_SHOP = 'DEFAULT_SHOP';
25
57
 
26
- const ES_CONFIG = 'ES_CONFIG';
27
-
28
58
  const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
29
59
  const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
30
60
 
@@ -152,36 +182,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
152
182
  }]
153
183
  }] });
154
184
 
155
- class AngularElasticSeachModule {
156
- static initializeApp(options) {
157
- return {
158
- ngModule: AngularElasticSeachModule,
159
- providers: [{ provide: ES_CONFIG, useValue: options }],
160
- };
161
- }
162
- }
163
- AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
164
- AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
165
- AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
166
- {
167
- provide: ProductsIndex,
168
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
169
- deps: [ES_CONFIG],
170
- },
171
- ] });
172
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
173
- type: NgModule,
174
- args: [{
175
- providers: [
176
- {
177
- provide: ProductsIndex,
178
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
179
- deps: [ES_CONFIG],
180
- },
181
- ],
182
- }]
183
- }] });
184
-
185
185
  class MobileOperationSystemCheckerHelper {
186
186
  static isAppleDevice() {
187
187
  return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
@@ -1502,6 +1502,7 @@ class CatalogService {
1502
1502
  };
1503
1503
  this.hasProfile = (options) => 'profile' in options;
1504
1504
  this.hasTerm = (options) => 'term' in options;
1505
+ this.hasCategory = (options) => 'category' in options;
1505
1506
  }
1506
1507
  async fetchProducts(options) {
1507
1508
  const limits = this.buildLimitQuery(options);
@@ -1510,8 +1511,8 @@ class CatalogService {
1510
1511
  if (this.hasProfile(options) && options.filters?.tags)
1511
1512
  throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1512
1513
  if (this.hasTerm(options) && options.filters?.customOptions)
1513
- throw new InvalidArgumentError(`It couldn't filled customOptions when tags is given`);
1514
- return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal }) => ({
1514
+ throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
1515
+ return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
1515
1516
  products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1516
1517
  pages: Math.ceil(total / limits.limit),
1517
1518
  prices: {
@@ -1521,6 +1522,7 @@ class CatalogService {
1521
1522
  max: +maximum?.price?.subscriberPrice?.toFixed(2),
1522
1523
  },
1523
1524
  },
1525
+ brands: distinct?.brand,
1524
1526
  }));
1525
1527
  }
1526
1528
  async findCatalog(options, limits) {
@@ -1531,10 +1533,14 @@ class CatalogService {
1531
1533
  },
1532
1534
  ...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
1533
1535
  limits,
1534
- options: { minimal: ['price'], maximum: ['price'] },
1536
+ options: {
1537
+ minimal: ['price'],
1538
+ maximum: ['price'],
1539
+ ...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
1540
+ },
1535
1541
  };
1536
1542
  if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1537
- return this.productRepository.find(repoParams);
1543
+ return this.productRepository.findCatalog(repoParams);
1538
1544
  return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1539
1545
  }
1540
1546
  async buildMainFilter({ category, profile, term, }) {
@@ -1705,11 +1711,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1705
1711
  }] }]; } });
1706
1712
 
1707
1713
  class WishlistService {
1708
- constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository) {
1714
+ constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository, productIndex) {
1709
1715
  this.wishlistRepository = wishlistRepository;
1710
1716
  this.shop = shop;
1711
1717
  const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository);
1712
- this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, null);
1718
+ this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
1713
1719
  this.categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1714
1720
  }
1715
1721
  getCatalogService() {
@@ -1779,7 +1785,7 @@ class WishlistService {
1779
1785
  return wishlist;
1780
1786
  }
1781
1787
  }
1782
- WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1788
+ WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryCollectionChildrenRepository' }, { token: i1$3.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1783
1789
  WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1784
1790
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1785
1791
  type: Injectable
@@ -1798,7 +1804,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1798
1804
  }] }, { type: undefined, decorators: [{
1799
1805
  type: Inject,
1800
1806
  args: ['CategoryCollectionChildrenRepository']
1801
- }] }]; } });
1807
+ }] }, { type: i1$3.ProductsIndex }]; } });
1802
1808
 
1803
1809
  class CheckoutSubscriptionService {
1804
1810
  constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
@@ -2082,7 +2088,7 @@ class AngularConnectModule {
2082
2088
  }
2083
2089
  }
2084
2090
  AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2085
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2091
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [AngularElasticSeachModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2086
2092
  AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
2087
2093
  AuthService,
2088
2094
  CartService,
@@ -2095,11 +2101,11 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
2095
2101
  OrderService,
2096
2102
  ShippingService,
2097
2103
  WishlistService,
2098
- ], imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2104
+ ], imports: [AngularElasticSeachModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2099
2105
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
2100
2106
  type: NgModule,
2101
2107
  args: [{
2102
- imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
2108
+ imports: [AngularElasticSeachModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
2103
2109
  providers: [
2104
2110
  AuthService,
2105
2111
  CartService,