@infrab4a/connect-angular 3.10.3 → 3.10.4

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.
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
2
2
  import { NgModule, APP_INITIALIZER, Injectable, Inject } from '@angular/core';
3
3
  import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
4
4
  import * as i1$1 from '@infrab4a/connect';
5
- import { 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, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword } from '@infrab4a/connect';
5
+ import { 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, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword } from '@infrab4a/connect';
6
6
  import * as i1$2 from '@angular/fire/firestore';
7
7
  import { AngularFirestore } from '@angular/fire/firestore';
8
8
  import * as i1 from '@angular/fire/auth';
@@ -526,6 +526,10 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
526
526
  provide: 'CategoryCollectionChildrenRepository',
527
527
  useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
528
528
  },
529
+ {
530
+ provide: 'WishlistRepository',
531
+ useExisting: WishlistHasuraGraphQLRepository,
532
+ },
529
533
  ] });
530
534
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
531
535
  type: NgModule,
@@ -605,6 +609,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
605
609
  provide: 'CategoryCollectionChildrenRepository',
606
610
  useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
607
611
  },
612
+ {
613
+ provide: 'WishlistRepository',
614
+ useExisting: WishlistHasuraGraphQLRepository,
615
+ },
608
616
  ],
609
617
  }]
610
618
  }] });
@@ -1367,6 +1375,202 @@ __decorate([
1367
1375
  __metadata("design:type", Array)
1368
1376
  ], CategoryWithTree.prototype, "children", void 0);
1369
1377
 
1378
+ class UtilService {
1379
+ constructor() { }
1380
+ createSlug(name) {
1381
+ return name
1382
+ .toLowerCase()
1383
+ .replace(/\s+/g, '-') // Replace spaces with -
1384
+ .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
1385
+ .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
1386
+ .replace(/[ìíïî]/g, 'i') // Replace spaces with -
1387
+ .replace(/[õòóöô]/g, 'o') // Replace spaces with -
1388
+ .replace(/[ùúüû]/g, 'u') // Replace spaces with -
1389
+ .replace(/[ñ]/g, 'n') // Replace spaces with -
1390
+ .replace(/[ç]/g, 'c') // Replace spaces with -
1391
+ .replace(/[&]/g, 'and') // Replace spaces with -
1392
+ .replace(/[^\w\-]+/g, '') // Remove all non-word chars
1393
+ .replace(/\-\-+/g, '-'); // Replace multiple - with single -
1394
+ }
1395
+ }
1396
+ UtilService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: UtilService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1397
+ UtilService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: UtilService, providedIn: 'root' });
1398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: UtilService, decorators: [{
1399
+ type: Injectable,
1400
+ args: [{
1401
+ providedIn: 'root',
1402
+ }]
1403
+ }], ctorParameters: function () { return []; } });
1404
+
1405
+ class NewCategoryStructureAdapter {
1406
+ constructor(categoryRepository, categoryCollectionChildrenRepository) {
1407
+ this.categoryRepository = categoryRepository;
1408
+ this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1409
+ }
1410
+ buildProductFilterByCategory(category) {
1411
+ return __awaiter(this, void 0, void 0, function* () {
1412
+ const categoriesIds = (yield this.isCollection(category))
1413
+ ? yield this.getAllCategoriesIdFromCollection(category)
1414
+ : [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1415
+ return { category: { id: { operator: Where.IN, value: categoriesIds } } };
1416
+ });
1417
+ }
1418
+ getAllCategoriesIdFromCategory(category) {
1419
+ return __awaiter(this, void 0, void 0, function* () {
1420
+ return this.categoryRepository
1421
+ .getChildren(+category.id)
1422
+ .then((categories) => categories.map((category) => category.id.toString()));
1423
+ });
1424
+ }
1425
+ getAllCategoriesIdFromCollection(category) {
1426
+ return __awaiter(this, void 0, void 0, function* () {
1427
+ return this.categoryCollectionChildrenRepository
1428
+ .find({ filters: { collectionId: +category.id } })
1429
+ .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1430
+ });
1431
+ }
1432
+ isCollection(category) {
1433
+ return __awaiter(this, void 0, void 0, function* () {
1434
+ return !isNil(category.isCollection)
1435
+ ? category.isCollection
1436
+ : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1437
+ });
1438
+ }
1439
+ }
1440
+ NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1441
+ NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter });
1442
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1443
+ type: Injectable
1444
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1445
+ type: Inject,
1446
+ args: ['CategoryRepository']
1447
+ }] }, { type: undefined, decorators: [{
1448
+ type: Inject,
1449
+ args: ['CategoryCollectionChildrenRepository']
1450
+ }] }]; } });
1451
+
1452
+ class OldCategoryStructureAdapter {
1453
+ constructor(categoryRepository) {
1454
+ this.categoryRepository = categoryRepository;
1455
+ }
1456
+ buildProductFilterByCategory(category) {
1457
+ var _a;
1458
+ return __awaiter(this, void 0, void 0, function* () {
1459
+ const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1460
+ ? category.products
1461
+ : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1462
+ return { id: { operator: Where.IN, value: productsIds } };
1463
+ });
1464
+ }
1465
+ }
1466
+ OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1467
+ OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter });
1468
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1469
+ type: Injectable
1470
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1471
+ type: Inject,
1472
+ args: ['CategoryRepository']
1473
+ }] }]; } });
1474
+
1475
+ class WishlistService {
1476
+ 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) {
1477
+ this.wishlistRepository = wishlistRepository;
1478
+ this.shop = shop;
1479
+ this.catalogService = catalogService;
1480
+ this.categoryService = categoryService;
1481
+ this.utilService = utilService;
1482
+ }
1483
+ getCatalogService() {
1484
+ return this.catalogService;
1485
+ }
1486
+ getCategoryService() {
1487
+ return this.categoryService;
1488
+ }
1489
+ create(personId, title, description, userFullName) {
1490
+ return __awaiter(this, void 0, void 0, function* () {
1491
+ const data = {
1492
+ slug: this.utilService.createSlug(`favoritos ${userFullName} ${title}`),
1493
+ name: title,
1494
+ description,
1495
+ metadata: {
1496
+ title: `${userFullName} - ${title}`,
1497
+ description: `${userFullName} - ${description}`,
1498
+ },
1499
+ shop: this.shop,
1500
+ shops: [this.shop],
1501
+ personId,
1502
+ brandCategory: false,
1503
+ published: true,
1504
+ };
1505
+ const newWishlist = yield this.wishlistRepository.create(data);
1506
+ return this.wishlistRepository.update({ id: newWishlist.id, slug: `${newWishlist.id}-${newWishlist.slug}` });
1507
+ });
1508
+ }
1509
+ update(id, title, description, userFullName) {
1510
+ const data = {
1511
+ id,
1512
+ slug: this.utilService.createSlug(`${id}-favoritos ${userFullName} ${title}`),
1513
+ name: title,
1514
+ description,
1515
+ metadata: {
1516
+ title: `${userFullName} - ${title}`,
1517
+ description: `${userFullName} - ${description}`,
1518
+ },
1519
+ };
1520
+ return this.wishlistRepository.update(data);
1521
+ }
1522
+ delete(wishlistId) {
1523
+ return this.wishlistRepository.delete({ id: wishlistId });
1524
+ }
1525
+ getWishlistBySlug(slug) {
1526
+ return this.wishlistRepository.getWishlistBySlug(slug);
1527
+ }
1528
+ getWishlistsByPerson(personId) {
1529
+ return this.wishlistRepository.getWishlistByPerson(personId);
1530
+ }
1531
+ addProduct(wishlistId, productId) {
1532
+ return __awaiter(this, void 0, void 0, function* () {
1533
+ const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
1534
+ const hasProduct = wishlist.products.some((p) => p == productId);
1535
+ if (!hasProduct) {
1536
+ wishlist.products = [...wishlist.products, productId];
1537
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1538
+ }
1539
+ return wishlist;
1540
+ });
1541
+ }
1542
+ removeProduct(wishlistId, productId) {
1543
+ return __awaiter(this, void 0, void 0, function* () {
1544
+ const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
1545
+ const productIndex = wishlist.products.findIndex((p) => p == productId);
1546
+ if (productIndex != -1) {
1547
+ wishlist.products.splice(productIndex, 1);
1548
+ if (!wishlist.products.length)
1549
+ return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1550
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1551
+ }
1552
+ return wishlist;
1553
+ });
1554
+ }
1555
+ }
1556
+ WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: WishlistService, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
1557
+ WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: WishlistService });
1558
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: WishlistService, decorators: [{
1559
+ type: Injectable
1560
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1561
+ type: Inject,
1562
+ args: ['WishlistRepository']
1563
+ }] }, { type: undefined, decorators: [{
1564
+ type: Inject,
1565
+ args: ['ProductRepository']
1566
+ }] }, { type: undefined, decorators: [{
1567
+ type: Inject,
1568
+ args: ['CategoryFilterRepository']
1569
+ }] }, { type: undefined }, { type: undefined }, { type: i1$1.Shops, decorators: [{
1570
+ type: Inject,
1571
+ args: [DEFAULT_SHOP]
1572
+ }] }, { type: undefined }, { type: undefined }, { type: UtilService }]; } });
1573
+
1370
1574
  class CheckoutSubscriptionService {
1371
1575
  constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1372
1576
  this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
@@ -1632,76 +1836,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1632
1836
  args: [BACKEND_URL]
1633
1837
  }] }, { type: HomeShopService }]; } });
1634
1838
 
1635
- class NewCategoryStructureAdapter {
1636
- constructor(categoryRepository, categoryCollectionChildrenRepository) {
1637
- this.categoryRepository = categoryRepository;
1638
- this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1639
- }
1640
- buildProductFilterByCategory(category) {
1641
- return __awaiter(this, void 0, void 0, function* () {
1642
- const categoriesIds = (yield this.isCollection(category))
1643
- ? yield this.getAllCategoriesIdFromCollection(category)
1644
- : [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1645
- return { category: { id: { operator: Where.IN, value: categoriesIds } } };
1646
- });
1647
- }
1648
- getAllCategoriesIdFromCategory(category) {
1649
- return __awaiter(this, void 0, void 0, function* () {
1650
- return this.categoryRepository
1651
- .getChildren(+category.id)
1652
- .then((categories) => categories.map((category) => category.id.toString()));
1653
- });
1654
- }
1655
- getAllCategoriesIdFromCollection(category) {
1656
- return __awaiter(this, void 0, void 0, function* () {
1657
- return this.categoryCollectionChildrenRepository
1658
- .find({ filters: { collectionId: +category.id } })
1659
- .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1660
- });
1661
- }
1662
- isCollection(category) {
1663
- return __awaiter(this, void 0, void 0, function* () {
1664
- return !isNil(category.isCollection)
1665
- ? category.isCollection
1666
- : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1667
- });
1668
- }
1669
- }
1670
- NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1671
- NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter });
1672
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1673
- type: Injectable
1674
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1675
- type: Inject,
1676
- args: ['CategoryRepository']
1677
- }] }, { type: undefined, decorators: [{
1678
- type: Inject,
1679
- args: ['CategoryCollectionChildrenRepository']
1680
- }] }]; } });
1681
-
1682
- class OldCategoryStructureAdapter {
1683
- constructor(categoryRepository) {
1684
- this.categoryRepository = categoryRepository;
1685
- }
1686
- buildProductFilterByCategory(category) {
1687
- var _a;
1688
- return __awaiter(this, void 0, void 0, function* () {
1689
- const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1690
- ? category.products
1691
- : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1692
- return { id: { operator: Where.IN, value: productsIds } };
1693
- });
1694
- }
1695
- }
1696
- OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1697
- OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter });
1698
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1699
- type: Injectable
1700
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1701
- type: Inject,
1702
- args: ['CategoryRepository']
1703
- }] }]; } });
1704
-
1705
1839
  class AngularConnectModule {
1706
1840
  static initializeApp(defaultShop, options, nameOrConfig) {
1707
1841
  return {
@@ -1868,5 +2002,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1868
2002
  * Generated bundle index. Do not edit.
1869
2003
  */
1870
2004
 
1871
- export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService };
2005
+ export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService, UtilService, WishlistService };
1872
2006
  //# sourceMappingURL=infrab4a-connect-angular.js.map