@infrab4a/connect-angular 3.10.6 → 3.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.
@@ -3,9 +3,10 @@ import { AngularFireModule, FirebaseAppConfig, FirebaseOptions } from '@angular/
3
3
  import { AxiosElasticSearchConfig, Shops } from '@infrab4a/connect';
4
4
  import { HasuraGraphQLOptions } from './angular-hasura-graphql.module';
5
5
  import * as i0 from "@angular/core";
6
- import * as i1 from "@angular/fire";
7
- import * as i2 from "./angular-firestore.module";
8
- import * as i3 from "./angular-hasura-graphql.module";
6
+ import * as i1 from "./angular-elastic-search.module";
7
+ import * as i2 from "@angular/fire";
8
+ import * as i3 from "./angular-firestore.module";
9
+ import * as i4 from "./angular-hasura-graphql.module";
9
10
  export declare class AngularConnectModule {
10
11
  static initializeApp(defaultShop: Shops, options: {
11
12
  firebase: FirebaseOptions;
@@ -15,6 +16,6 @@ export declare class AngularConnectModule {
15
16
  oldCategoryStructure?: boolean;
16
17
  }, nameOrConfig?: string | FirebaseAppConfig): ModuleWithProviders<AngularFireModule>;
17
18
  static ɵfac: i0.ɵɵFactoryDeclaration<AngularConnectModule, never>;
18
- static ɵmod: i0.ɵɵNgModuleDeclaration<AngularConnectModule, never, [typeof i1.AngularFireModule, typeof i2.AngularFirestoreModule, typeof i3.AngularHasuraGraphQLModule], never>;
19
+ static ɵmod: i0.ɵɵNgModuleDeclaration<AngularConnectModule, never, [typeof i1.AngularElasticSeachModule, typeof i2.AngularFireModule, typeof i3.AngularFirestoreModule, typeof i4.AngularHasuraGraphQLModule], never>;
19
20
  static ɵinj: i0.ɵɵInjectorDeclaration<AngularConnectModule>;
20
21
  }
@@ -1861,10 +1861,11 @@
1861
1861
  } });
1862
1862
 
1863
1863
  var CatalogService = /** @class */ (function () {
1864
- function CatalogService(productRepository, categoryStructureAdapter, shop) {
1864
+ function CatalogService(productRepository, categoryStructureAdapter, shop, productIndex) {
1865
1865
  this.productRepository = productRepository;
1866
1866
  this.categoryStructureAdapter = categoryStructureAdapter;
1867
1867
  this.shop = shop;
1868
+ this.productIndex = productIndex;
1868
1869
  this.buildFilterQuery = function (_j) {
1869
1870
  var clubDiscount = _j.clubDiscount, brands = _j.brands, prices = _j.prices, gender = _j.gender, tags = _j.tags, rate = _j.rate, customOptions = _j.customOptions;
1870
1871
  var filters = {};
@@ -1910,47 +1911,89 @@
1910
1911
  offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
1911
1912
  };
1912
1913
  };
1914
+ this.hasProfile = function (options) { return 'profile' in options; };
1915
+ this.hasTerm = function (options) { return 'term' in options; };
1916
+ this.hasCategory = function (options) { return 'category' in options; };
1913
1917
  }
1914
- CatalogService.prototype.fetchProducts = function (category, options) {
1918
+ CatalogService.prototype.fetchProducts = function (options) {
1919
+ var _a, _b, _c;
1915
1920
  return __awaiter(this, void 0, void 0, function () {
1916
- var limits, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
1917
- return __generator(this, function (_w) {
1918
- switch (_w.label) {
1921
+ var limits;
1922
+ return __generator(this, function (_j) {
1923
+ switch (_j.label) {
1919
1924
  case 0:
1920
1925
  limits = this.buildLimitQuery(options);
1921
- _k = (_j = this.productRepository)
1922
- .findCatalog;
1926
+ if (this.hasProfile(options) && ((_a = options.filters) === null || _a === void 0 ? void 0 : _a.customOptions))
1927
+ throw new i1.InvalidArgumentError("It couldn't filled customOptions when profile is given");
1928
+ if (this.hasProfile(options) && ((_b = options.filters) === null || _b === void 0 ? void 0 : _b.tags))
1929
+ throw new i1.InvalidArgumentError("It couldn't filled tags when profile is given");
1930
+ if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions))
1931
+ throw new i1.InvalidArgumentError("It couldn't filled customOptions when term is given");
1932
+ return [4 /*yield*/, this.findCatalog(options, limits).then(function (_j) {
1933
+ var data = _j.data, total = _j.count, maximum = _j.maximum, minimal = _j.minimal, distinct = _j.distinct;
1934
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1935
+ return ({
1936
+ products: { data: data.map(function (product) { return i1.RoundProductPricesHelper.roundProductPrices(product); }), total: total },
1937
+ pages: Math.ceil(total / limits.limit),
1938
+ prices: {
1939
+ 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)) },
1940
+ subscriberPrice: {
1941
+ 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)),
1942
+ 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)),
1943
+ },
1944
+ },
1945
+ brands: distinct === null || distinct === void 0 ? void 0 : distinct.brand,
1946
+ });
1947
+ })];
1948
+ case 1: return [2 /*return*/, _j.sent()];
1949
+ }
1950
+ });
1951
+ });
1952
+ };
1953
+ CatalogService.prototype.findCatalog = function (options, limits) {
1954
+ return __awaiter(this, void 0, void 0, function () {
1955
+ var repoParams, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1956
+ return __generator(this, function (_u) {
1957
+ switch (_u.label) {
1958
+ case 0:
1959
+ _k = (_j = Object).assign;
1923
1960
  _m = (_l = Object).assign;
1924
- _p = (_o = Object).assign;
1925
- _q = {};
1961
+ _o = {};
1962
+ _q = (_p = Object).assign;
1926
1963
  _s = (_r = Object).assign;
1927
- _u = (_t = Object).assign;
1928
- _v = [{}];
1929
- return [4 /*yield*/, this.categoryStructureAdapter.buildProductFilterByCategory(category)];
1930
- case 1: return [4 /*yield*/, _k.apply(_j, [_m.apply(_l, [_p.apply(_o, [(_q.filters = _s.apply(_r, [_u.apply(_t, _v.concat([(_w.sent())])), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})]), _q), ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})]), { limits: limits, options: { minimal: ['price'], maximum: ['price'] } }]), (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === i1.Shops.MENSMARKET ? 'male' : 'female'])
1931
- .then(function (_j) {
1932
- var data = _j.data, total = _j.count, maximum = _j.maximum, minimal = _j.minimal;
1933
- var _a, _b, _c, _d, _e, _f, _g, _h;
1934
- return ({
1935
- products: { data: data.map(function (product) { return i1.RoundProductPricesHelper.roundProductPrices(product); }), total: total },
1936
- pages: Math.ceil(total / limits.limit),
1937
- prices: {
1938
- 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)) },
1939
- subscriberPrice: {
1940
- 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)),
1941
- 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)),
1942
- },
1943
- },
1944
- });
1945
- })];
1946
- case 2: return [2 /*return*/, _w.sent()];
1964
+ _t = [{}];
1965
+ return [4 /*yield*/, this.buildMainFilter(options)];
1966
+ case 1:
1967
+ repoParams = _k.apply(_j, [_m.apply(_l, [(_o.filters = _q.apply(_p, [_s.apply(_r, _t.concat([(_u.sent())])), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})]), _o), ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})]), { limits: limits, options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (!this.hasCategory(options) ? { distinct: ['brand'] } : {})) }]);
1968
+ if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1969
+ return [2 /*return*/, this.productRepository.findCatalog(repoParams)];
1970
+ return [2 /*return*/, this.productRepository.findCatalog(repoParams, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === i1.Shops.MENSMARKET ? 'male' : 'female')];
1947
1971
  }
1948
1972
  });
1949
1973
  });
1950
1974
  };
1975
+ CatalogService.prototype.buildMainFilter = function (_j) {
1976
+ var category = _j.category, profile = _j.profile, term = _j.term;
1977
+ return __awaiter(this, void 0, void 0, function () {
1978
+ return __generator(this, function (_j) {
1979
+ if (category)
1980
+ return [2 /*return*/, this.categoryStructureAdapter.buildProductFilterByCategory(category)];
1981
+ if (profile)
1982
+ return [2 /*return*/, { tags: { operator: i1.Where.LIKE, value: profile } }];
1983
+ if (term)
1984
+ return [2 /*return*/, this.productIndex
1985
+ .search(term, 9999, this.shop)
1986
+ .then(function (data) { return ({ id: { operator: i1.Where.IN, value: data.hits.map(function (_j) {
1987
+ var _source = _j._source;
1988
+ return _source.id;
1989
+ }) } }); })];
1990
+ return [2 /*return*/];
1991
+ });
1992
+ });
1993
+ };
1951
1994
  return CatalogService;
1952
1995
  }());
1953
- CatalogService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1996
+ CatalogService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1__namespace$1.ProductsIndex }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1954
1997
  CatalogService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService });
1955
1998
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService, decorators: [{
1956
1999
  type: i0.Injectable
@@ -1964,7 +2007,7 @@
1964
2007
  }] }, { type: i1__namespace$1.Shops, decorators: [{
1965
2008
  type: i0.Inject,
1966
2009
  args: [DEFAULT_SHOP]
1967
- }] }];
2010
+ }] }, { type: i1__namespace$1.ProductsIndex }];
1968
2011
  } });
1969
2012
 
1970
2013
  var CategoryService = /** @class */ (function () {
@@ -2206,11 +2249,11 @@
2206
2249
  } });
2207
2250
 
2208
2251
  var WishlistService = /** @class */ (function () {
2209
- function WishlistService(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository) {
2252
+ function WishlistService(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository, productIndex) {
2210
2253
  this.wishlistRepository = wishlistRepository;
2211
2254
  this.shop = shop;
2212
2255
  var categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository);
2213
- this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop);
2256
+ this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
2214
2257
  this.categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop);
2215
2258
  }
2216
2259
  WishlistService.prototype.getCatalogService = function () {
@@ -2309,7 +2352,7 @@
2309
2352
  };
2310
2353
  return WishlistService;
2311
2354
  }());
2312
- WishlistService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2355
+ WishlistService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryCollectionChildrenRepository' }, { token: i1__namespace$1.ProductsIndex }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2313
2356
  WishlistService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: WishlistService });
2314
2357
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: WishlistService, decorators: [{
2315
2358
  type: i0.Injectable
@@ -2329,7 +2372,7 @@
2329
2372
  }] }, { type: undefined, decorators: [{
2330
2373
  type: i0.Inject,
2331
2374
  args: ['CategoryCollectionChildrenRepository']
2332
- }] }];
2375
+ }] }, { type: i1__namespace$1.ProductsIndex }];
2333
2376
  } });
2334
2377
 
2335
2378
  var CheckoutSubscriptionService = /** @class */ (function () {
@@ -2656,7 +2699,7 @@
2656
2699
  return AngularConnectModule;
2657
2700
  }());
2658
2701
  AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2659
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2702
+ AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [AngularElasticSeachModule, fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2660
2703
  AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
2661
2704
  AuthService,
2662
2705
  CartService,
@@ -2669,11 +2712,11 @@
2669
2712
  OrderService,
2670
2713
  ShippingService,
2671
2714
  WishlistService,
2672
- ], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
2715
+ ], imports: [[AngularElasticSeachModule, fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
2673
2716
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
2674
2717
  type: i0.NgModule,
2675
2718
  args: [{
2676
- imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
2719
+ imports: [AngularElasticSeachModule, fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
2677
2720
  providers: [
2678
2721
  AuthService,
2679
2722
  CartService,