@infrab4a/connect-angular 4.0.0-beta.46 → 4.0.0-beta.48

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
2
  import { InjectionToken, NgModule, 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, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } 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, 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';
@@ -745,6 +745,10 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
745
745
  provide: 'CategoryCollectionChildrenRepository',
746
746
  useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
747
747
  },
748
+ {
749
+ provide: 'WishlistRepository',
750
+ useExisting: WishlistHasuraGraphQLRepository,
751
+ },
748
752
  ] });
749
753
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
750
754
  type: NgModule,
@@ -847,6 +851,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
847
851
  provide: 'CategoryCollectionChildrenRepository',
848
852
  useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
849
853
  },
854
+ {
855
+ provide: 'WishlistRepository',
856
+ useExisting: WishlistHasuraGraphQLRepository,
857
+ },
850
858
  ],
851
859
  }]
852
860
  }] });
@@ -1614,6 +1622,208 @@ __decorate([
1614
1622
  __metadata("design:type", Array)
1615
1623
  ], CategoryWithTree.prototype, "children", void 0);
1616
1624
 
1625
+ class NewCategoryStructureAdapter {
1626
+ constructor(categoryRepository, categoryCollectionChildrenRepository) {
1627
+ this.categoryRepository = categoryRepository;
1628
+ this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1629
+ }
1630
+ buildProductFilterByCategory(category) {
1631
+ return __awaiter(this, void 0, void 0, function* () {
1632
+ const categoriesIds = (yield this.isCollection(category))
1633
+ ? yield this.getAllCategoriesIdFromCollection(category)
1634
+ : [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1635
+ return { category: { id: { operator: Where.IN, value: categoriesIds } } };
1636
+ });
1637
+ }
1638
+ getAllCategoriesIdFromCategory(category) {
1639
+ return __awaiter(this, void 0, void 0, function* () {
1640
+ return this.categoryRepository
1641
+ .getChildren(+category.id)
1642
+ .then((categories) => categories.map((category) => category.id.toString()));
1643
+ });
1644
+ }
1645
+ getAllCategoriesIdFromCollection(category) {
1646
+ return __awaiter(this, void 0, void 0, function* () {
1647
+ return this.categoryCollectionChildrenRepository
1648
+ .find({ filters: { collectionId: +category.id } })
1649
+ .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1650
+ });
1651
+ }
1652
+ isCollection(category) {
1653
+ return __awaiter(this, void 0, void 0, function* () {
1654
+ return !isNil(category.isCollection)
1655
+ ? category.isCollection
1656
+ : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1657
+ });
1658
+ }
1659
+ }
1660
+ 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 });
1661
+ NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1662
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1663
+ type: Injectable
1664
+ }], ctorParameters: function () {
1665
+ return [{ type: undefined, decorators: [{
1666
+ type: Inject,
1667
+ args: ['CategoryRepository']
1668
+ }] }, { type: undefined, decorators: [{
1669
+ type: Inject,
1670
+ args: ['CategoryCollectionChildrenRepository']
1671
+ }] }];
1672
+ } });
1673
+
1674
+ class OldCategoryStructureAdapter {
1675
+ constructor(categoryRepository) {
1676
+ this.categoryRepository = categoryRepository;
1677
+ }
1678
+ buildProductFilterByCategory(category) {
1679
+ var _a;
1680
+ return __awaiter(this, void 0, void 0, function* () {
1681
+ const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1682
+ ? category.products
1683
+ : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1684
+ return { id: { operator: Where.IN, value: productsIds } };
1685
+ });
1686
+ }
1687
+ }
1688
+ OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1689
+ OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1690
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1691
+ type: Injectable
1692
+ }], ctorParameters: function () {
1693
+ return [{ type: undefined, decorators: [{
1694
+ type: Inject,
1695
+ args: ['CategoryRepository']
1696
+ }] }];
1697
+ } });
1698
+
1699
+ class UtilService {
1700
+ constructor() { }
1701
+ createSlug(name) {
1702
+ return name
1703
+ .toLowerCase()
1704
+ .replace(/\s+/g, '-') // Replace spaces with -
1705
+ .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
1706
+ .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
1707
+ .replace(/[ìíïî]/g, 'i') // Replace spaces with -
1708
+ .replace(/[õòóöô]/g, 'o') // Replace spaces with -
1709
+ .replace(/[ùúüû]/g, 'u') // Replace spaces with -
1710
+ .replace(/[ñ]/g, 'n') // Replace spaces with -
1711
+ .replace(/[ç]/g, 'c') // Replace spaces with -
1712
+ .replace(/[&]/g, 'and') // Replace spaces with -
1713
+ .replace(/[^\w\-]+/g, '') // Remove all non-word chars
1714
+ .replace(/\-\-+/g, '-'); // Replace multiple - with single -
1715
+ }
1716
+ }
1717
+ UtilService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: UtilService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1718
+ UtilService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: UtilService, providedIn: 'root' });
1719
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: UtilService, decorators: [{
1720
+ type: Injectable,
1721
+ args: [{
1722
+ providedIn: 'root',
1723
+ }]
1724
+ }], ctorParameters: function () { return []; } });
1725
+
1726
+ class WishlistService {
1727
+ constructor(wishlistRepository, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository, categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository), shop, catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop), categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop), utilService) {
1728
+ this.wishlistRepository = wishlistRepository;
1729
+ this.shop = shop;
1730
+ this.catalogService = catalogService;
1731
+ this.categoryService = categoryService;
1732
+ this.utilService = utilService;
1733
+ }
1734
+ getCatalogService() {
1735
+ return this.catalogService;
1736
+ }
1737
+ getCategoryService() {
1738
+ return this.categoryService;
1739
+ }
1740
+ create(personId, title, description, userFullName) {
1741
+ return __awaiter(this, void 0, void 0, function* () {
1742
+ const data = {
1743
+ slug: this.utilService.createSlug(`favoritos ${userFullName} ${title}`),
1744
+ name: title,
1745
+ description,
1746
+ metadata: {
1747
+ title: `${userFullName} - ${title}`,
1748
+ description: `${userFullName} - ${description}`,
1749
+ },
1750
+ shop: this.shop,
1751
+ shops: [this.shop],
1752
+ personId,
1753
+ brandCategory: false,
1754
+ published: true,
1755
+ };
1756
+ const newWishlist = yield this.wishlistRepository.create(data);
1757
+ return this.wishlistRepository.update({ id: newWishlist.id, slug: `${newWishlist.id}-${newWishlist.slug}` });
1758
+ });
1759
+ }
1760
+ update(id, title, description, userFullName) {
1761
+ const data = {
1762
+ id,
1763
+ slug: this.utilService.createSlug(`${id}-favoritos ${userFullName} ${title}`),
1764
+ name: title,
1765
+ description,
1766
+ metadata: {
1767
+ title: `${userFullName} - ${title}`,
1768
+ description: `${userFullName} - ${description}`,
1769
+ },
1770
+ };
1771
+ return this.wishlistRepository.update(data);
1772
+ }
1773
+ delete(wishlistId) {
1774
+ return this.wishlistRepository.delete({ id: wishlistId });
1775
+ }
1776
+ getWishlistBySlug(slug) {
1777
+ return this.wishlistRepository.getWishlistBySlug(slug);
1778
+ }
1779
+ getWishlistsByPerson(personId) {
1780
+ return this.wishlistRepository.getWishlistByPerson(personId);
1781
+ }
1782
+ addProduct(wishlistId, productId) {
1783
+ return __awaiter(this, void 0, void 0, function* () {
1784
+ const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
1785
+ const hasProduct = wishlist.products.some((p) => p == productId);
1786
+ if (!hasProduct) {
1787
+ wishlist.products = [...wishlist.products, productId];
1788
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1789
+ }
1790
+ return wishlist;
1791
+ });
1792
+ }
1793
+ removeProduct(wishlistId, productId) {
1794
+ return __awaiter(this, void 0, void 0, function* () {
1795
+ const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
1796
+ const productIndex = wishlist.products.findIndex((p) => p == productId);
1797
+ if (productIndex != -1) {
1798
+ wishlist.products.splice(productIndex, 1);
1799
+ if (!wishlist.products.length)
1800
+ return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1801
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1802
+ }
1803
+ return wishlist;
1804
+ });
1805
+ }
1806
+ }
1807
+ WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
1808
+ WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1809
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1810
+ type: Injectable
1811
+ }], ctorParameters: function () {
1812
+ return [{ type: undefined, decorators: [{
1813
+ type: Inject,
1814
+ args: ['WishlistRepository']
1815
+ }] }, { type: undefined, decorators: [{
1816
+ type: Inject,
1817
+ args: ['ProductRepository']
1818
+ }] }, { type: undefined, decorators: [{
1819
+ type: Inject,
1820
+ args: ['CategoryFilterRepository']
1821
+ }] }, { type: undefined }, { type: undefined }, { type: i1$3.Shops, decorators: [{
1822
+ type: Inject,
1823
+ args: [DEFAULT_SHOP]
1824
+ }] }, { type: undefined }, { type: undefined }, { type: UtilService }];
1825
+ } });
1826
+
1617
1827
  class CheckoutSubscriptionService {
1618
1828
  constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1619
1829
  this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
@@ -1884,80 +2094,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
1884
2094
  }] }, { type: HomeShopService }];
1885
2095
  } });
1886
2096
 
1887
- class NewCategoryStructureAdapter {
1888
- constructor(categoryRepository, categoryCollectionChildrenRepository) {
1889
- this.categoryRepository = categoryRepository;
1890
- this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1891
- }
1892
- buildProductFilterByCategory(category) {
1893
- return __awaiter(this, void 0, void 0, function* () {
1894
- const categoriesIds = (yield this.isCollection(category))
1895
- ? yield this.getAllCategoriesIdFromCollection(category)
1896
- : [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1897
- return { category: { id: { operator: Where.IN, value: categoriesIds } } };
1898
- });
1899
- }
1900
- getAllCategoriesIdFromCategory(category) {
1901
- return __awaiter(this, void 0, void 0, function* () {
1902
- return this.categoryRepository
1903
- .getChildren(+category.id)
1904
- .then((categories) => categories.map((category) => category.id.toString()));
1905
- });
1906
- }
1907
- getAllCategoriesIdFromCollection(category) {
1908
- return __awaiter(this, void 0, void 0, function* () {
1909
- return this.categoryCollectionChildrenRepository
1910
- .find({ filters: { collectionId: +category.id } })
1911
- .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1912
- });
1913
- }
1914
- isCollection(category) {
1915
- return __awaiter(this, void 0, void 0, function* () {
1916
- return !isNil(category.isCollection)
1917
- ? category.isCollection
1918
- : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1919
- });
1920
- }
1921
- }
1922
- 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 });
1923
- NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1924
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1925
- type: Injectable
1926
- }], ctorParameters: function () {
1927
- return [{ type: undefined, decorators: [{
1928
- type: Inject,
1929
- args: ['CategoryRepository']
1930
- }] }, { type: undefined, decorators: [{
1931
- type: Inject,
1932
- args: ['CategoryCollectionChildrenRepository']
1933
- }] }];
1934
- } });
1935
-
1936
- class OldCategoryStructureAdapter {
1937
- constructor(categoryRepository) {
1938
- this.categoryRepository = categoryRepository;
1939
- }
1940
- buildProductFilterByCategory(category) {
1941
- var _a;
1942
- return __awaiter(this, void 0, void 0, function* () {
1943
- const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1944
- ? category.products
1945
- : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1946
- return { id: { operator: Where.IN, value: productsIds } };
1947
- });
1948
- }
1949
- }
1950
- OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1951
- OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1952
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1953
- type: Injectable
1954
- }], ctorParameters: function () {
1955
- return [{ type: undefined, decorators: [{
1956
- type: Inject,
1957
- args: ['CategoryRepository']
1958
- }] }];
1959
- } });
1960
-
1961
2097
  class AngularConnectModule {
1962
2098
  static initializeApp(defaultShop, options, nameOrConfig) {
1963
2099
  return {
@@ -1992,6 +2128,7 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
1992
2128
  HomeShopService,
1993
2129
  OrderService,
1994
2130
  ShippingService,
2131
+ WishlistService,
1995
2132
  ], imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1996
2133
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
1997
2134
  type: NgModule,
@@ -2008,6 +2145,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2008
2145
  HomeShopService,
2009
2146
  OrderService,
2010
2147
  ShippingService,
2148
+ WishlistService,
2011
2149
  ],
2012
2150
  }]
2013
2151
  }] });
@@ -2016,5 +2154,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
2016
2154
  * Generated bundle index. Do not edit.
2017
2155
  */
2018
2156
 
2019
- export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService };
2157
+ export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService, UtilService, WishlistService };
2020
2158
  //# sourceMappingURL=infrab4a-connect-angular.mjs.map