@infrab4a/connect-angular 4.10.0 → 4.11.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.
@@ -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() {
@@ -1981,6 +2020,21 @@ class WishlistService {
1981
2020
  personType: personType ?? PersonTypes.NONE,
1982
2021
  personIsSubscriber: personIsSubscriber ?? false,
1983
2022
  };
2023
+ const hasWishlist = await this.wishlistRepository
2024
+ .find({
2025
+ filters: {
2026
+ personId,
2027
+ },
2028
+ options: {
2029
+ enableCount: false,
2030
+ },
2031
+ orderBy: {
2032
+ id: 'asc',
2033
+ },
2034
+ })
2035
+ .then((res) => res.data);
2036
+ if (hasWishlist.length)
2037
+ return hasWishlist.at(0);
1984
2038
  const newWishlist = await this.wishlistRepository.create(data);
1985
2039
  await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1986
2040
  return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
@@ -2040,7 +2094,7 @@ class WishlistService {
2040
2094
  return wishlist;
2041
2095
  }
2042
2096
  }
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 });
2097
+ 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
2098
  WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
2045
2099
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
2046
2100
  type: Injectable
@@ -2062,7 +2116,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2062
2116
  }] }, { type: undefined, decorators: [{
2063
2117
  type: Inject,
2064
2118
  args: ['ProductStockNotificationRepository']
2065
- }] }, { type: i1$2.ProductsIndex }]; } });
2119
+ }] }, { type: undefined, decorators: [{
2120
+ type: Inject,
2121
+ args: ['ProductSearch']
2122
+ }] }]; } });
2066
2123
 
2067
2124
  class CheckoutSubscriptionService {
2068
2125
  constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
@@ -2367,6 +2424,7 @@ class AngularConnectModule {
2367
2424
  ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
2368
2425
  ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2369
2426
  ...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2427
+ ...(isNil(options?.vertexConfig) ? [] : [{ provide: VERTEX_CONFIG, useValue: options.vertexConfig }]),
2370
2428
  ...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2371
2429
  ...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2372
2430
  ...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
@@ -2376,6 +2434,7 @@ class AngularConnectModule {
2376
2434
  }
2377
2435
  AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2378
2436
  AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, i2.StorageModule, AngularElasticSeachModule,
2437
+ AngularVertexSeachModule,
2379
2438
  AngularFirebaseAuthModule,
2380
2439
  AngularFirestoreModule,
2381
2440
  AngularHasuraGraphQLModule] });
@@ -2405,6 +2464,10 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
2405
2464
  },
2406
2465
  deps: [Storage, STORAGE_BASE_URL],
2407
2466
  },
2467
+ {
2468
+ provide: 'ProductSearch',
2469
+ useExisting: ProductsVertexSearch,
2470
+ },
2408
2471
  ], imports: [provideFirebaseApp((injector) => {
2409
2472
  const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2410
2473
  try {
@@ -2416,6 +2479,7 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
2416
2479
  }),
2417
2480
  provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
2418
2481
  AngularElasticSeachModule,
2482
+ AngularVertexSeachModule,
2419
2483
  AngularFirebaseAuthModule,
2420
2484
  AngularFirestoreModule,
2421
2485
  AngularHasuraGraphQLModule] });
@@ -2434,6 +2498,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2434
2498
  }),
2435
2499
  provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
2436
2500
  AngularElasticSeachModule,
2501
+ AngularVertexSeachModule,
2437
2502
  AngularFirebaseAuthModule,
2438
2503
  AngularFirestoreModule,
2439
2504
  AngularHasuraGraphQLModule,
@@ -2464,6 +2529,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2464
2529
  },
2465
2530
  deps: [Storage, STORAGE_BASE_URL],
2466
2531
  },
2532
+ {
2533
+ provide: 'ProductSearch',
2534
+ useExisting: ProductsVertexSearch,
2535
+ },
2467
2536
  ],
2468
2537
  }]
2469
2538
  }] });