@infrab4a/connect-angular 4.10.0 → 4.11.0

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.
@@ -5,7 +5,7 @@ import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular
5
5
  import * as i2 from '@angular/fire/storage';
6
6
  import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
7
7
  import * as i1$2 from '@infrab4a/connect';
8
- import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, PersonTypes, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
8
+ import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, PersonTypes, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
9
9
  import * as i1 from '@angular/fire/auth';
10
10
  import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
11
11
  import { isPlatformBrowser, isPlatformServer } from '@angular/common';
@@ -63,6 +63,8 @@ const HASURA_OPTIONS = 'HASURA_OPTIONS';
63
63
 
64
64
  const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
65
65
 
66
+ const VERTEX_CONFIG = 'VERTEX_CONFIG';
67
+
66
68
  class AngularFirebaseAuthModule {
67
69
  static initializeApp(options, nameOrConfig) {
68
70
  return {
@@ -949,6 +951,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
949
951
  }]
950
952
  }] });
951
953
 
954
+ class AngularVertexSeachModule {
955
+ static initializeApp(options) {
956
+ return {
957
+ ngModule: AngularVertexSeachModule,
958
+ providers: [{ provide: VERTEX_CONFIG, useValue: options }],
959
+ };
960
+ }
961
+ }
962
+ AngularVertexSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularVertexSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
963
+ AngularVertexSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularVertexSeachModule });
964
+ AngularVertexSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularVertexSeachModule, providers: [
965
+ {
966
+ provide: ProductsVertexSearch,
967
+ useFactory: (configuration) => new ProductsVertexSearch(new VertexAxiosAdapter(configuration)),
968
+ deps: [VERTEX_CONFIG],
969
+ },
970
+ ] });
971
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularVertexSeachModule, decorators: [{
972
+ type: NgModule,
973
+ args: [{
974
+ providers: [
975
+ {
976
+ provide: ProductsVertexSearch,
977
+ useFactory: (configuration) => new ProductsVertexSearch(new VertexAxiosAdapter(configuration)),
978
+ deps: [VERTEX_CONFIG],
979
+ },
980
+ ],
981
+ }]
982
+ }] });
983
+
952
984
  const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
953
985
 
954
986
  class CookieDataPersistence {
@@ -1650,13 +1682,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1650
1682
  }] }]; } });
1651
1683
 
1652
1684
  class CatalogService {
1653
- constructor(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
1685
+ constructor(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch) {
1654
1686
  this.productRepository = productRepository;
1655
1687
  this.productStockNotificationRepository = productStockNotificationRepository;
1656
1688
  this.categoryRepository = categoryRepository;
1657
1689
  this.categoryStructureAdapter = categoryStructureAdapter;
1658
1690
  this.shop = shop;
1659
- this.productIndex = productIndex;
1691
+ this.productSearch = productSearch;
1660
1692
  this.productsByTerm = {};
1661
1693
  this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1662
1694
  const filters = {};
@@ -1737,7 +1769,7 @@ class CatalogService {
1737
1769
  }
1738
1770
  async findCatalog(options, limits) {
1739
1771
  if (this.hasTerm(options) && options.sort === 'most-relevant') {
1740
- const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
1772
+ const productsIds = await this.findCatalogIdsBySearch(options.term);
1741
1773
  return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
1742
1774
  }
1743
1775
  if (this.hasCategory(options) && options.sort === 'most-relevant') {
@@ -1776,9 +1808,9 @@ class CatalogService {
1776
1808
  if (profile)
1777
1809
  return { tags: { operator: Where.LIKE, value: profile } };
1778
1810
  if (term)
1779
- return this.productIndex
1780
- .search(term, 999, this.shop)
1781
- .then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
1811
+ return this.productSearch
1812
+ .search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
1813
+ .then((data) => ({ id: { operator: Where.IN, value: data.map((_source) => _source.id) } }));
1782
1814
  }
1783
1815
  async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
1784
1816
  const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
@@ -1813,9 +1845,10 @@ class CatalogService {
1813
1845
  }
1814
1846
  async findCatalogAndSortByMostRevelantByTerm(productIds, options, limits) {
1815
1847
  const totalResult = await this.productRepository.findCatalog({
1816
- fields: ['id', 'stock'],
1848
+ fields: ['id', 'stock', 'gender'],
1817
1849
  filters: {
1818
1850
  id: { operator: Where.IN, value: productIds },
1851
+ published: { operator: Where.EQUALS, value: true },
1819
1852
  ...this.buildFilterQuery(options?.filters || {}),
1820
1853
  },
1821
1854
  options: {
@@ -1824,10 +1857,17 @@ class CatalogService {
1824
1857
  distinct: ['brand'],
1825
1858
  },
1826
1859
  }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1860
+ const defaultGender = options?.filters?.gender
1861
+ ? options?.filters?.gender.at(0)
1862
+ : this.shop === Shops.GLAMSHOP
1863
+ ? 'female'
1864
+ : 'male';
1827
1865
  const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1828
1866
  const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1829
- const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
1830
- const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
1867
+ const productIdsStockGender = productIds.filter((product) => stockData.some((result) => result.id === product && (result.gender?.includes(defaultGender) || result.gender?.includes('unisex'))));
1868
+ const productIdsStockNotGender = productIds.filter((product) => stockData.some((result) => result.id === product && !result.gender?.includes(defaultGender) && !result.gender?.includes('unisex')));
1869
+ const productIdsStock = productIdsStockGender.concat(productIdsStockNotGender);
1870
+ const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id === product));
1831
1871
  const limitedProductId = productIdsStock
1832
1872
  .concat(productIdsStockOut)
1833
1873
  .slice(limits.offset, limits.offset + limits.limit);
@@ -1845,20 +1885,15 @@ class CatalogService {
1845
1885
  distinct: totalResult.distinct,
1846
1886
  };
1847
1887
  }
1848
- async findCatalogIdsByElasticSearch(term) {
1888
+ async findCatalogIdsBySearch(term, preview = false) {
1849
1889
  if (this.productsByTerm[term])
1850
1890
  return this.productsByTerm[term];
1851
- return (this.productsByTerm[term] = await this.productIndex
1852
- .search(term, 999, this.shop)
1853
- .then(({ hits: products }) => {
1854
- const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1855
- const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1856
- const sorted = [...withStock, ...withOutStock];
1857
- return [...new Set(sorted.map(({ _source }) => _source.id))];
1858
- }));
1891
+ return (this.productsByTerm[term] = await this.productSearch
1892
+ .search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
1893
+ .then((products) => [...new Set(products.map((product) => product.id))]));
1859
1894
  }
1860
1895
  }
1861
- CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'ProductStockNotificationRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1896
+ CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'ProductStockNotificationRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable });
1862
1897
  CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1863
1898
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1864
1899
  type: Injectable
@@ -1877,7 +1912,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1877
1912
  }] }, { type: i1$2.Shops, decorators: [{
1878
1913
  type: Inject,
1879
1914
  args: [DEFAULT_SHOP]
1880
- }] }, { type: i1$2.ProductsIndex }]; } });
1915
+ }] }, { type: undefined, decorators: [{
1916
+ type: Inject,
1917
+ args: ['ProductSearch']
1918
+ }] }]; } });
1881
1919
 
1882
1920
  class CategoryService {
1883
1921
  constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
@@ -1944,11 +1982,12 @@ __decorate([
1944
1982
  ], CategoryWithTree.prototype, "children", void 0);
1945
1983
 
1946
1984
  class WishlistService {
1947
- constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productIndex) {
1985
+ constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch) {
1948
1986
  this.wishlistRepository = wishlistRepository;
1949
1987
  this.shop = shop;
1988
+ this.productSearch = productSearch;
1950
1989
  const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1951
- this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
1990
+ this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch);
1952
1991
  this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1953
1992
  }
1954
1993
  getCatalogService() {
@@ -2040,7 +2079,7 @@ class WishlistService {
2040
2079
  return wishlist;
2041
2080
  }
2042
2081
  }
2043
- 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: 'CategoryRepository' }, { token: 'ProductStockNotificationRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
2082
+ 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: 'CategoryRepository' }, { token: 'ProductStockNotificationRepository' }, { token: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable });
2044
2083
  WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
2045
2084
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
2046
2085
  type: Injectable
@@ -2062,7 +2101,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2062
2101
  }] }, { type: undefined, decorators: [{
2063
2102
  type: Inject,
2064
2103
  args: ['ProductStockNotificationRepository']
2065
- }] }, { type: i1$2.ProductsIndex }]; } });
2104
+ }] }, { type: undefined, decorators: [{
2105
+ type: Inject,
2106
+ args: ['ProductSearch']
2107
+ }] }]; } });
2066
2108
 
2067
2109
  class CheckoutSubscriptionService {
2068
2110
  constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
@@ -2367,6 +2409,7 @@ class AngularConnectModule {
2367
2409
  ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
2368
2410
  ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2369
2411
  ...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2412
+ ...(isNil(options?.vertexConfig) ? [] : [{ provide: VERTEX_CONFIG, useValue: options.vertexConfig }]),
2370
2413
  ...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2371
2414
  ...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2372
2415
  ...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
@@ -2376,6 +2419,7 @@ class AngularConnectModule {
2376
2419
  }
2377
2420
  AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2378
2421
  AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, i2.StorageModule, AngularElasticSeachModule,
2422
+ AngularVertexSeachModule,
2379
2423
  AngularFirebaseAuthModule,
2380
2424
  AngularFirestoreModule,
2381
2425
  AngularHasuraGraphQLModule] });
@@ -2405,6 +2449,10 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
2405
2449
  },
2406
2450
  deps: [Storage, STORAGE_BASE_URL],
2407
2451
  },
2452
+ {
2453
+ provide: 'ProductSearch',
2454
+ useExisting: ProductsVertexSearch,
2455
+ },
2408
2456
  ], imports: [provideFirebaseApp((injector) => {
2409
2457
  const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2410
2458
  try {
@@ -2416,6 +2464,7 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
2416
2464
  }),
2417
2465
  provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
2418
2466
  AngularElasticSeachModule,
2467
+ AngularVertexSeachModule,
2419
2468
  AngularFirebaseAuthModule,
2420
2469
  AngularFirestoreModule,
2421
2470
  AngularHasuraGraphQLModule] });
@@ -2434,6 +2483,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2434
2483
  }),
2435
2484
  provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
2436
2485
  AngularElasticSeachModule,
2486
+ AngularVertexSeachModule,
2437
2487
  AngularFirebaseAuthModule,
2438
2488
  AngularFirestoreModule,
2439
2489
  AngularHasuraGraphQLModule,
@@ -2464,6 +2514,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2464
2514
  },
2465
2515
  deps: [Storage, STORAGE_BASE_URL],
2466
2516
  },
2517
+ {
2518
+ provide: 'ProductSearch',
2519
+ useExisting: ProductsVertexSearch,
2520
+ },
2467
2521
  ],
2468
2522
  }]
2469
2523
  }] });