@infrab4a/connect-angular 3.10.6 → 3.11.0-beta.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.
- package/bundles/infrab4a-connect-angular.umd.js +122 -302
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/angular-connect.module.js +2 -4
- package/esm2015/angular-hasura-graphql.module.js +2 -26
- package/esm2015/services/catalog/catalog.service.js +1 -1
- package/esm2015/services/catalog/index.js +1 -2
- package/esm2015/services/coupon.service.js +7 -11
- package/esm2015/services/index.js +1 -2
- package/fesm2015/infrab4a-connect-angular.js +78 -228
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +4 -4
- package/services/catalog/index.d.ts +0 -1
- package/services/index.d.ts +0 -1
- package/esm2015/services/catalog/wishlist.service.js +0 -112
- package/esm2015/services/helpers/index.js +0 -2
- package/esm2015/services/helpers/util.helper.js +0 -18
- package/services/catalog/wishlist.service.d.ts +0 -22
- package/services/helpers/index.d.ts +0 -1
- package/services/helpers/util.helper.d.ts +0 -3
|
@@ -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,
|
|
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';
|
|
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';
|
|
@@ -521,23 +521,11 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
|
|
|
521
521
|
{
|
|
522
522
|
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
523
523
|
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
|
|
524
|
-
deps: ['HasuraConfig'],
|
|
525
524
|
},
|
|
526
525
|
{
|
|
527
526
|
provide: 'CategoryCollectionChildrenRepository',
|
|
528
527
|
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
529
528
|
},
|
|
530
|
-
{
|
|
531
|
-
provide: WishlistHasuraGraphQLRepository,
|
|
532
|
-
useFactory: (options, categoryFilterRepository) => {
|
|
533
|
-
return new WishlistHasuraGraphQLRepository(options.endpoint, options.credentials, categoryFilterRepository);
|
|
534
|
-
},
|
|
535
|
-
deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
|
|
536
|
-
},
|
|
537
|
-
{
|
|
538
|
-
provide: 'WishlistRepository',
|
|
539
|
-
useExisting: WishlistHasuraGraphQLRepository,
|
|
540
|
-
},
|
|
541
529
|
] });
|
|
542
530
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
543
531
|
type: NgModule,
|
|
@@ -612,23 +600,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
612
600
|
{
|
|
613
601
|
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
614
602
|
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
|
|
615
|
-
deps: ['HasuraConfig'],
|
|
616
603
|
},
|
|
617
604
|
{
|
|
618
605
|
provide: 'CategoryCollectionChildrenRepository',
|
|
619
606
|
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
620
607
|
},
|
|
621
|
-
{
|
|
622
|
-
provide: WishlistHasuraGraphQLRepository,
|
|
623
|
-
useFactory: (options, categoryFilterRepository) => {
|
|
624
|
-
return new WishlistHasuraGraphQLRepository(options.endpoint, options.credentials, categoryFilterRepository);
|
|
625
|
-
},
|
|
626
|
-
deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
|
|
627
|
-
},
|
|
628
|
-
{
|
|
629
|
-
provide: 'WishlistRepository',
|
|
630
|
-
useExisting: WishlistHasuraGraphQLRepository,
|
|
631
|
-
},
|
|
632
608
|
],
|
|
633
609
|
}]
|
|
634
610
|
}] });
|
|
@@ -714,17 +690,13 @@ class CouponService {
|
|
|
714
690
|
const validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
715
691
|
if (!validUser)
|
|
716
692
|
throw 'Usuário não elegível.';
|
|
693
|
+
const orders = yield this.getOrdersWithCoupon(coupon);
|
|
694
|
+
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
717
695
|
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
718
|
-
if (
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
if (couponUseLimits.limitedPerUser) {
|
|
723
|
-
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
724
|
-
if (ordersWithUser > 0)
|
|
725
|
-
throw 'Limite de uso por usuário atingido.';
|
|
726
|
-
}
|
|
727
|
-
}
|
|
696
|
+
if (couponUseLimits.limitedPerUser && ordersWithUser > 0)
|
|
697
|
+
throw 'Limite de uso por usuário atingido.';
|
|
698
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
699
|
+
throw 'Limite de uso atingido.';
|
|
728
700
|
const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
|
|
729
701
|
if (!hasProductCategories)
|
|
730
702
|
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
@@ -1391,196 +1363,6 @@ __decorate([
|
|
|
1391
1363
|
__metadata("design:type", Array)
|
|
1392
1364
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1393
1365
|
|
|
1394
|
-
class UtilHelper {
|
|
1395
|
-
static createSlug(name) {
|
|
1396
|
-
return name
|
|
1397
|
-
.toLowerCase()
|
|
1398
|
-
.replace(/\s+/g, '-') // Replace spaces with -
|
|
1399
|
-
.replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
|
|
1400
|
-
.replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
|
|
1401
|
-
.replace(/[ìíïî]/g, 'i') // Replace spaces with -
|
|
1402
|
-
.replace(/[õòóöô]/g, 'o') // Replace spaces with -
|
|
1403
|
-
.replace(/[ùúüû]/g, 'u') // Replace spaces with -
|
|
1404
|
-
.replace(/[ñ]/g, 'n') // Replace spaces with -
|
|
1405
|
-
.replace(/[ç]/g, 'c') // Replace spaces with -
|
|
1406
|
-
.replace(/[&]/g, 'and') // Replace spaces with -
|
|
1407
|
-
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
1408
|
-
.replace(/\-\-+/g, '-'); // Replace multiple - with single -
|
|
1409
|
-
}
|
|
1410
|
-
}
|
|
1411
|
-
|
|
1412
|
-
class NewCategoryStructureAdapter {
|
|
1413
|
-
constructor(categoryRepository, categoryCollectionChildrenRepository) {
|
|
1414
|
-
this.categoryRepository = categoryRepository;
|
|
1415
|
-
this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
|
|
1416
|
-
}
|
|
1417
|
-
buildProductFilterByCategory(category) {
|
|
1418
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1419
|
-
const categoriesIds = (yield this.isCollection(category))
|
|
1420
|
-
? yield this.getAllCategoriesIdFromCollection(category)
|
|
1421
|
-
: [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
|
|
1422
|
-
return { category: { id: { operator: Where.IN, value: categoriesIds } } };
|
|
1423
|
-
});
|
|
1424
|
-
}
|
|
1425
|
-
getAllCategoriesIdFromCategory(category) {
|
|
1426
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1427
|
-
return this.categoryRepository
|
|
1428
|
-
.getChildren(+category.id)
|
|
1429
|
-
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1432
|
-
getAllCategoriesIdFromCollection(category) {
|
|
1433
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1434
|
-
return this.categoryCollectionChildrenRepository
|
|
1435
|
-
.find({ filters: { collectionId: +category.id } })
|
|
1436
|
-
.then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
|
|
1437
|
-
});
|
|
1438
|
-
}
|
|
1439
|
-
isCollection(category) {
|
|
1440
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1441
|
-
return !isNil(category.isCollection)
|
|
1442
|
-
? category.isCollection
|
|
1443
|
-
: this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
|
|
1444
|
-
});
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
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 });
|
|
1448
|
-
NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter });
|
|
1449
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
|
|
1450
|
-
type: Injectable
|
|
1451
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1452
|
-
type: Inject,
|
|
1453
|
-
args: ['CategoryRepository']
|
|
1454
|
-
}] }, { type: undefined, decorators: [{
|
|
1455
|
-
type: Inject,
|
|
1456
|
-
args: ['CategoryCollectionChildrenRepository']
|
|
1457
|
-
}] }]; } });
|
|
1458
|
-
|
|
1459
|
-
class OldCategoryStructureAdapter {
|
|
1460
|
-
constructor(categoryRepository) {
|
|
1461
|
-
this.categoryRepository = categoryRepository;
|
|
1462
|
-
}
|
|
1463
|
-
buildProductFilterByCategory(category) {
|
|
1464
|
-
var _a;
|
|
1465
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1466
|
-
const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
|
|
1467
|
-
? category.products
|
|
1468
|
-
: yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
|
|
1469
|
-
return { id: { operator: Where.IN, value: productsIds } };
|
|
1470
|
-
});
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1474
|
-
OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter });
|
|
1475
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
|
|
1476
|
-
type: Injectable
|
|
1477
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1478
|
-
type: Inject,
|
|
1479
|
-
args: ['CategoryRepository']
|
|
1480
|
-
}] }]; } });
|
|
1481
|
-
|
|
1482
|
-
class WishlistService {
|
|
1483
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository) {
|
|
1484
|
-
this.wishlistRepository = wishlistRepository;
|
|
1485
|
-
this.shop = shop;
|
|
1486
|
-
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository);
|
|
1487
|
-
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop);
|
|
1488
|
-
this.categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1489
|
-
}
|
|
1490
|
-
getCatalogService() {
|
|
1491
|
-
return this.catalogService;
|
|
1492
|
-
}
|
|
1493
|
-
getCategoryService() {
|
|
1494
|
-
return this.categoryService;
|
|
1495
|
-
}
|
|
1496
|
-
create(personId, title, description, userFullName) {
|
|
1497
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1498
|
-
const data = {
|
|
1499
|
-
slug: UtilHelper.createSlug(`favoritos ${userFullName} ${title}`),
|
|
1500
|
-
name: title,
|
|
1501
|
-
description,
|
|
1502
|
-
metadata: {
|
|
1503
|
-
title: `${userFullName} - ${title}`,
|
|
1504
|
-
description: `${userFullName} - ${description}`,
|
|
1505
|
-
},
|
|
1506
|
-
shop: this.shop,
|
|
1507
|
-
shops: [this.shop],
|
|
1508
|
-
personId,
|
|
1509
|
-
brandCategory: false,
|
|
1510
|
-
published: true,
|
|
1511
|
-
};
|
|
1512
|
-
const newWishlist = yield this.wishlistRepository.create(data);
|
|
1513
|
-
return this.wishlistRepository.update({ id: newWishlist.id, slug: `${newWishlist.id}-${newWishlist.slug}` });
|
|
1514
|
-
});
|
|
1515
|
-
}
|
|
1516
|
-
update(id, title, description, userFullName) {
|
|
1517
|
-
const data = {
|
|
1518
|
-
id,
|
|
1519
|
-
slug: UtilHelper.createSlug(`${id}-favoritos ${userFullName} ${title}`),
|
|
1520
|
-
name: title,
|
|
1521
|
-
description,
|
|
1522
|
-
metadata: {
|
|
1523
|
-
title: `${userFullName} - ${title}`,
|
|
1524
|
-
description: `${userFullName} - ${description}`,
|
|
1525
|
-
},
|
|
1526
|
-
};
|
|
1527
|
-
return this.wishlistRepository.update(data);
|
|
1528
|
-
}
|
|
1529
|
-
delete(wishlistId) {
|
|
1530
|
-
return this.wishlistRepository.delete({ id: wishlistId });
|
|
1531
|
-
}
|
|
1532
|
-
getWishlistBySlug(slug) {
|
|
1533
|
-
return this.wishlistRepository.getWishlistBySlug(slug);
|
|
1534
|
-
}
|
|
1535
|
-
getWishlistsByPerson(personId) {
|
|
1536
|
-
return this.wishlistRepository.getWishlistByPerson(personId);
|
|
1537
|
-
}
|
|
1538
|
-
addProduct(wishlistId, productId) {
|
|
1539
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1540
|
-
const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
|
|
1541
|
-
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
1542
|
-
if (!hasProduct) {
|
|
1543
|
-
wishlist.products = [...wishlist.products, productId];
|
|
1544
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1545
|
-
}
|
|
1546
|
-
return wishlist;
|
|
1547
|
-
});
|
|
1548
|
-
}
|
|
1549
|
-
removeProduct(wishlistId, productId) {
|
|
1550
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1551
|
-
const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
|
|
1552
|
-
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
1553
|
-
if (productIndex != -1) {
|
|
1554
|
-
wishlist.products.splice(productIndex, 1);
|
|
1555
|
-
if (!wishlist.products.length)
|
|
1556
|
-
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
1557
|
-
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1558
|
-
}
|
|
1559
|
-
return wishlist;
|
|
1560
|
-
});
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1564
|
-
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: WishlistService });
|
|
1565
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: WishlistService, decorators: [{
|
|
1566
|
-
type: Injectable
|
|
1567
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1568
|
-
type: Inject,
|
|
1569
|
-
args: ['WishlistRepository']
|
|
1570
|
-
}] }, { type: i1$1.Shops, decorators: [{
|
|
1571
|
-
type: Inject,
|
|
1572
|
-
args: [DEFAULT_SHOP]
|
|
1573
|
-
}] }, { type: undefined, decorators: [{
|
|
1574
|
-
type: Inject,
|
|
1575
|
-
args: ['ProductRepository']
|
|
1576
|
-
}] }, { type: undefined, decorators: [{
|
|
1577
|
-
type: Inject,
|
|
1578
|
-
args: ['CategoryFilterRepository']
|
|
1579
|
-
}] }, { type: undefined, decorators: [{
|
|
1580
|
-
type: Inject,
|
|
1581
|
-
args: ['CategoryCollectionChildrenRepository']
|
|
1582
|
-
}] }]; } });
|
|
1583
|
-
|
|
1584
1366
|
class CheckoutSubscriptionService {
|
|
1585
1367
|
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
1586
1368
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
@@ -1846,6 +1628,76 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1846
1628
|
args: [BACKEND_URL]
|
|
1847
1629
|
}] }, { type: HomeShopService }]; } });
|
|
1848
1630
|
|
|
1631
|
+
class NewCategoryStructureAdapter {
|
|
1632
|
+
constructor(categoryRepository, categoryCollectionChildrenRepository) {
|
|
1633
|
+
this.categoryRepository = categoryRepository;
|
|
1634
|
+
this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
|
|
1635
|
+
}
|
|
1636
|
+
buildProductFilterByCategory(category) {
|
|
1637
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1638
|
+
const categoriesIds = (yield this.isCollection(category))
|
|
1639
|
+
? yield this.getAllCategoriesIdFromCollection(category)
|
|
1640
|
+
: [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
|
|
1641
|
+
return { category: { id: { operator: Where.IN, value: categoriesIds } } };
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
getAllCategoriesIdFromCategory(category) {
|
|
1645
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1646
|
+
return this.categoryRepository
|
|
1647
|
+
.getChildren(+category.id)
|
|
1648
|
+
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
getAllCategoriesIdFromCollection(category) {
|
|
1652
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1653
|
+
return this.categoryCollectionChildrenRepository
|
|
1654
|
+
.find({ filters: { collectionId: +category.id } })
|
|
1655
|
+
.then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
isCollection(category) {
|
|
1659
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1660
|
+
return !isNil(category.isCollection)
|
|
1661
|
+
? category.isCollection
|
|
1662
|
+
: this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
|
|
1663
|
+
});
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
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 });
|
|
1667
|
+
NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter });
|
|
1668
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
|
|
1669
|
+
type: Injectable
|
|
1670
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1671
|
+
type: Inject,
|
|
1672
|
+
args: ['CategoryRepository']
|
|
1673
|
+
}] }, { type: undefined, decorators: [{
|
|
1674
|
+
type: Inject,
|
|
1675
|
+
args: ['CategoryCollectionChildrenRepository']
|
|
1676
|
+
}] }]; } });
|
|
1677
|
+
|
|
1678
|
+
class OldCategoryStructureAdapter {
|
|
1679
|
+
constructor(categoryRepository) {
|
|
1680
|
+
this.categoryRepository = categoryRepository;
|
|
1681
|
+
}
|
|
1682
|
+
buildProductFilterByCategory(category) {
|
|
1683
|
+
var _a;
|
|
1684
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1685
|
+
const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
|
|
1686
|
+
? category.products
|
|
1687
|
+
: yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
|
|
1688
|
+
return { id: { operator: Where.IN, value: productsIds } };
|
|
1689
|
+
});
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1693
|
+
OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter });
|
|
1694
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
|
|
1695
|
+
type: Injectable
|
|
1696
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1697
|
+
type: Inject,
|
|
1698
|
+
args: ['CategoryRepository']
|
|
1699
|
+
}] }]; } });
|
|
1700
|
+
|
|
1849
1701
|
class AngularConnectModule {
|
|
1850
1702
|
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
1851
1703
|
return {
|
|
@@ -1880,7 +1732,6 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
|
|
|
1880
1732
|
HomeShopService,
|
|
1881
1733
|
OrderService,
|
|
1882
1734
|
ShippingService,
|
|
1883
|
-
WishlistService,
|
|
1884
1735
|
], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
1885
1736
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
1886
1737
|
type: NgModule,
|
|
@@ -1897,7 +1748,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1897
1748
|
HomeShopService,
|
|
1898
1749
|
OrderService,
|
|
1899
1750
|
ShippingService,
|
|
1900
|
-
WishlistService,
|
|
1901
1751
|
],
|
|
1902
1752
|
}]
|
|
1903
1753
|
}] });
|
|
@@ -2014,5 +1864,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
2014
1864
|
* Generated bundle index. Do not edit.
|
|
2015
1865
|
*/
|
|
2016
1866
|
|
|
2017
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService
|
|
1867
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService };
|
|
2018
1868
|
//# sourceMappingURL=infrab4a-connect-angular.js.map
|