@infrab4a/connect-angular 3.11.0-beta.1 → 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.
- package/angular-connect.module.d.ts +5 -4
- package/bundles/infrab4a-connect-angular.umd.js +379 -156
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/esm2015/angular-connect.module.js +8 -5
- package/esm2015/angular-hasura-graphql.module.js +26 -2
- package/esm2015/services/catalog/catalog.service.js +39 -9
- package/esm2015/services/catalog/index.js +2 -1
- package/esm2015/services/catalog/wishlist.service.js +112 -0
- package/esm2015/services/coupon.service.js +11 -7
- package/esm2015/services/helpers/index.js +2 -0
- package/esm2015/services/helpers/util.helper.js +18 -0
- package/esm2015/services/index.js +2 -1
- package/fesm2015/infrab4a-connect-angular.js +268 -88
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +34 -8
- package/services/catalog/index.d.ts +1 -0
- package/services/catalog/wishlist.service.d.ts +22 -0
- package/services/helpers/index.d.ts +1 -0
- package/services/helpers/util.helper.d.ts +3 -0
- package/services/index.d.ts +1 -0
|
@@ -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, InvalidArgumentError, 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,11 +521,23 @@ 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'],
|
|
524
525
|
},
|
|
525
526
|
{
|
|
526
527
|
provide: 'CategoryCollectionChildrenRepository',
|
|
527
528
|
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
528
529
|
},
|
|
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
|
+
},
|
|
529
541
|
] });
|
|
530
542
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
531
543
|
type: NgModule,
|
|
@@ -600,11 +612,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
600
612
|
{
|
|
601
613
|
provide: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
602
614
|
useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
|
|
615
|
+
deps: ['HasuraConfig'],
|
|
603
616
|
},
|
|
604
617
|
{
|
|
605
618
|
provide: 'CategoryCollectionChildrenRepository',
|
|
606
619
|
useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
|
|
607
620
|
},
|
|
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
|
+
},
|
|
608
632
|
],
|
|
609
633
|
}]
|
|
610
634
|
}] });
|
|
@@ -690,13 +714,17 @@ class CouponService {
|
|
|
690
714
|
const validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
|
|
691
715
|
if (!validUser)
|
|
692
716
|
throw 'Usuário não elegível.';
|
|
693
|
-
const orders = yield this.getOrdersWithCoupon(coupon);
|
|
694
|
-
const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
|
|
695
717
|
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
696
|
-
if (couponUseLimits.
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
718
|
+
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
719
|
+
const orders = yield this.getOrdersWithCoupon(coupon);
|
|
720
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
|
|
721
|
+
throw 'Limite de uso atingido.';
|
|
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
|
+
}
|
|
700
728
|
const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
|
|
701
729
|
if (!hasProductCategories)
|
|
702
730
|
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
@@ -1206,10 +1234,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1206
1234
|
}] }]; } });
|
|
1207
1235
|
|
|
1208
1236
|
class CatalogService {
|
|
1209
|
-
constructor(productRepository, categoryStructureAdapter, shop) {
|
|
1237
|
+
constructor(productRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1210
1238
|
this.productRepository = productRepository;
|
|
1211
1239
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1212
1240
|
this.shop = shop;
|
|
1241
|
+
this.productIndex = productIndex;
|
|
1213
1242
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1214
1243
|
const filters = {};
|
|
1215
1244
|
if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
|
|
@@ -1257,13 +1286,21 @@ class CatalogService {
|
|
|
1257
1286
|
offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
|
|
1258
1287
|
};
|
|
1259
1288
|
};
|
|
1289
|
+
this.hasProfile = (options) => 'profile' in options;
|
|
1290
|
+
this.hasTerm = (options) => 'term' in options;
|
|
1291
|
+
this.hasCategory = (options) => 'category' in options;
|
|
1260
1292
|
}
|
|
1261
|
-
fetchProducts(
|
|
1293
|
+
fetchProducts(options) {
|
|
1294
|
+
var _a, _b, _c;
|
|
1262
1295
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1263
1296
|
const limits = this.buildLimitQuery(options);
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1297
|
+
if (this.hasProfile(options) && ((_a = options.filters) === null || _a === void 0 ? void 0 : _a.customOptions))
|
|
1298
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
1299
|
+
if (this.hasProfile(options) && ((_b = options.filters) === null || _b === void 0 ? void 0 : _b.tags))
|
|
1300
|
+
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1301
|
+
if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions))
|
|
1302
|
+
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1303
|
+
return yield this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => {
|
|
1267
1304
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1268
1305
|
return ({
|
|
1269
1306
|
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
@@ -1275,12 +1312,33 @@ class CatalogService {
|
|
|
1275
1312
|
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)),
|
|
1276
1313
|
},
|
|
1277
1314
|
},
|
|
1315
|
+
brands: distinct === null || distinct === void 0 ? void 0 : distinct.brand,
|
|
1278
1316
|
});
|
|
1279
1317
|
});
|
|
1280
1318
|
});
|
|
1281
1319
|
}
|
|
1320
|
+
findCatalog(options, limits) {
|
|
1321
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1322
|
+
const repoParams = Object.assign(Object.assign({ filters: Object.assign(Object.assign({}, (yield this.buildMainFilter(options))), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (!this.hasCategory(options) ? { distinct: ['brand'] } : {})) });
|
|
1323
|
+
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1324
|
+
return this.productRepository.findCatalog(repoParams);
|
|
1325
|
+
return this.productRepository.findCatalog(repoParams, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1326
|
+
});
|
|
1327
|
+
}
|
|
1328
|
+
buildMainFilter({ category, profile, term, }) {
|
|
1329
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1330
|
+
if (category)
|
|
1331
|
+
return this.categoryStructureAdapter.buildProductFilterByCategory(category);
|
|
1332
|
+
if (profile)
|
|
1333
|
+
return { tags: { operator: Where.LIKE, value: profile } };
|
|
1334
|
+
if (term)
|
|
1335
|
+
return this.productIndex
|
|
1336
|
+
.search(term, 9999, this.shop)
|
|
1337
|
+
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1282
1340
|
}
|
|
1283
|
-
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1341
|
+
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$1.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1284
1342
|
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService });
|
|
1285
1343
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService, decorators: [{
|
|
1286
1344
|
type: Injectable
|
|
@@ -1293,7 +1351,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1293
1351
|
}] }, { type: i1$1.Shops, decorators: [{
|
|
1294
1352
|
type: Inject,
|
|
1295
1353
|
args: [DEFAULT_SHOP]
|
|
1296
|
-
}] }]; } });
|
|
1354
|
+
}] }, { type: i1$1.ProductsIndex }]; } });
|
|
1297
1355
|
|
|
1298
1356
|
class CategoryService {
|
|
1299
1357
|
constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
|
|
@@ -1363,6 +1421,196 @@ __decorate([
|
|
|
1363
1421
|
__metadata("design:type", Array)
|
|
1364
1422
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1365
1423
|
|
|
1424
|
+
class UtilHelper {
|
|
1425
|
+
static createSlug(name) {
|
|
1426
|
+
return name
|
|
1427
|
+
.toLowerCase()
|
|
1428
|
+
.replace(/\s+/g, '-') // Replace spaces with -
|
|
1429
|
+
.replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
|
|
1430
|
+
.replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
|
|
1431
|
+
.replace(/[ìíïî]/g, 'i') // Replace spaces with -
|
|
1432
|
+
.replace(/[õòóöô]/g, 'o') // Replace spaces with -
|
|
1433
|
+
.replace(/[ùúüû]/g, 'u') // Replace spaces with -
|
|
1434
|
+
.replace(/[ñ]/g, 'n') // Replace spaces with -
|
|
1435
|
+
.replace(/[ç]/g, 'c') // Replace spaces with -
|
|
1436
|
+
.replace(/[&]/g, 'and') // Replace spaces with -
|
|
1437
|
+
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
|
|
1438
|
+
.replace(/\-\-+/g, '-'); // Replace multiple - with single -
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1442
|
+
class NewCategoryStructureAdapter {
|
|
1443
|
+
constructor(categoryRepository, categoryCollectionChildrenRepository) {
|
|
1444
|
+
this.categoryRepository = categoryRepository;
|
|
1445
|
+
this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
|
|
1446
|
+
}
|
|
1447
|
+
buildProductFilterByCategory(category) {
|
|
1448
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1449
|
+
const categoriesIds = (yield this.isCollection(category))
|
|
1450
|
+
? yield this.getAllCategoriesIdFromCollection(category)
|
|
1451
|
+
: [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
|
|
1452
|
+
return { category: { id: { operator: Where.IN, value: categoriesIds } } };
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
getAllCategoriesIdFromCategory(category) {
|
|
1456
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1457
|
+
return this.categoryRepository
|
|
1458
|
+
.getChildren(+category.id)
|
|
1459
|
+
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
getAllCategoriesIdFromCollection(category) {
|
|
1463
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1464
|
+
return this.categoryCollectionChildrenRepository
|
|
1465
|
+
.find({ filters: { collectionId: +category.id } })
|
|
1466
|
+
.then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
|
|
1467
|
+
});
|
|
1468
|
+
}
|
|
1469
|
+
isCollection(category) {
|
|
1470
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1471
|
+
return !isNil(category.isCollection)
|
|
1472
|
+
? category.isCollection
|
|
1473
|
+
: this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
|
|
1474
|
+
});
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
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 });
|
|
1478
|
+
NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter });
|
|
1479
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
|
|
1480
|
+
type: Injectable
|
|
1481
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1482
|
+
type: Inject,
|
|
1483
|
+
args: ['CategoryRepository']
|
|
1484
|
+
}] }, { type: undefined, decorators: [{
|
|
1485
|
+
type: Inject,
|
|
1486
|
+
args: ['CategoryCollectionChildrenRepository']
|
|
1487
|
+
}] }]; } });
|
|
1488
|
+
|
|
1489
|
+
class OldCategoryStructureAdapter {
|
|
1490
|
+
constructor(categoryRepository) {
|
|
1491
|
+
this.categoryRepository = categoryRepository;
|
|
1492
|
+
}
|
|
1493
|
+
buildProductFilterByCategory(category) {
|
|
1494
|
+
var _a;
|
|
1495
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1496
|
+
const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
|
|
1497
|
+
? category.products
|
|
1498
|
+
: yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
|
|
1499
|
+
return { id: { operator: Where.IN, value: productsIds } };
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1504
|
+
OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter });
|
|
1505
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
|
|
1506
|
+
type: Injectable
|
|
1507
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1508
|
+
type: Inject,
|
|
1509
|
+
args: ['CategoryRepository']
|
|
1510
|
+
}] }]; } });
|
|
1511
|
+
|
|
1512
|
+
class WishlistService {
|
|
1513
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository, productIndex) {
|
|
1514
|
+
this.wishlistRepository = wishlistRepository;
|
|
1515
|
+
this.shop = shop;
|
|
1516
|
+
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository);
|
|
1517
|
+
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
|
|
1518
|
+
this.categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1519
|
+
}
|
|
1520
|
+
getCatalogService() {
|
|
1521
|
+
return this.catalogService;
|
|
1522
|
+
}
|
|
1523
|
+
getCategoryService() {
|
|
1524
|
+
return this.categoryService;
|
|
1525
|
+
}
|
|
1526
|
+
create(personId, title, description, userFullName) {
|
|
1527
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1528
|
+
const data = {
|
|
1529
|
+
slug: UtilHelper.createSlug(`favoritos ${userFullName} ${title}`),
|
|
1530
|
+
name: title,
|
|
1531
|
+
description,
|
|
1532
|
+
metadata: {
|
|
1533
|
+
title: `${userFullName} - ${title}`,
|
|
1534
|
+
description: `${userFullName} - ${description}`,
|
|
1535
|
+
},
|
|
1536
|
+
shop: this.shop,
|
|
1537
|
+
shops: [this.shop],
|
|
1538
|
+
personId,
|
|
1539
|
+
brandCategory: false,
|
|
1540
|
+
published: true,
|
|
1541
|
+
};
|
|
1542
|
+
const newWishlist = yield this.wishlistRepository.create(data);
|
|
1543
|
+
return this.wishlistRepository.update({ id: newWishlist.id, slug: `${newWishlist.id}-${newWishlist.slug}` });
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
update(id, title, description, userFullName) {
|
|
1547
|
+
const data = {
|
|
1548
|
+
id,
|
|
1549
|
+
slug: UtilHelper.createSlug(`${id}-favoritos ${userFullName} ${title}`),
|
|
1550
|
+
name: title,
|
|
1551
|
+
description,
|
|
1552
|
+
metadata: {
|
|
1553
|
+
title: `${userFullName} - ${title}`,
|
|
1554
|
+
description: `${userFullName} - ${description}`,
|
|
1555
|
+
},
|
|
1556
|
+
};
|
|
1557
|
+
return this.wishlistRepository.update(data);
|
|
1558
|
+
}
|
|
1559
|
+
delete(wishlistId) {
|
|
1560
|
+
return this.wishlistRepository.delete({ id: wishlistId });
|
|
1561
|
+
}
|
|
1562
|
+
getWishlistBySlug(slug) {
|
|
1563
|
+
return this.wishlistRepository.getWishlistBySlug(slug);
|
|
1564
|
+
}
|
|
1565
|
+
getWishlistsByPerson(personId) {
|
|
1566
|
+
return this.wishlistRepository.getWishlistByPerson(personId);
|
|
1567
|
+
}
|
|
1568
|
+
addProduct(wishlistId, productId) {
|
|
1569
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1570
|
+
const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
|
|
1571
|
+
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
1572
|
+
if (!hasProduct) {
|
|
1573
|
+
wishlist.products = [...wishlist.products, productId];
|
|
1574
|
+
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1575
|
+
}
|
|
1576
|
+
return wishlist;
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
removeProduct(wishlistId, productId) {
|
|
1580
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1581
|
+
const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
|
|
1582
|
+
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
1583
|
+
if (productIndex != -1) {
|
|
1584
|
+
wishlist.products.splice(productIndex, 1);
|
|
1585
|
+
if (!wishlist.products.length)
|
|
1586
|
+
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
1587
|
+
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
1588
|
+
}
|
|
1589
|
+
return wishlist;
|
|
1590
|
+
});
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
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' }, { token: i1$1.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1594
|
+
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: WishlistService });
|
|
1595
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: WishlistService, decorators: [{
|
|
1596
|
+
type: Injectable
|
|
1597
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1598
|
+
type: Inject,
|
|
1599
|
+
args: ['WishlistRepository']
|
|
1600
|
+
}] }, { type: i1$1.Shops, decorators: [{
|
|
1601
|
+
type: Inject,
|
|
1602
|
+
args: [DEFAULT_SHOP]
|
|
1603
|
+
}] }, { type: undefined, decorators: [{
|
|
1604
|
+
type: Inject,
|
|
1605
|
+
args: ['ProductRepository']
|
|
1606
|
+
}] }, { type: undefined, decorators: [{
|
|
1607
|
+
type: Inject,
|
|
1608
|
+
args: ['CategoryFilterRepository']
|
|
1609
|
+
}] }, { type: undefined, decorators: [{
|
|
1610
|
+
type: Inject,
|
|
1611
|
+
args: ['CategoryCollectionChildrenRepository']
|
|
1612
|
+
}] }, { type: i1$1.ProductsIndex }]; } });
|
|
1613
|
+
|
|
1366
1614
|
class CheckoutSubscriptionService {
|
|
1367
1615
|
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
1368
1616
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
@@ -1628,76 +1876,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1628
1876
|
args: [BACKEND_URL]
|
|
1629
1877
|
}] }, { type: HomeShopService }]; } });
|
|
1630
1878
|
|
|
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
|
-
|
|
1701
1879
|
class AngularConnectModule {
|
|
1702
1880
|
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
1703
1881
|
return {
|
|
@@ -1720,7 +1898,7 @@ class AngularConnectModule {
|
|
|
1720
1898
|
}
|
|
1721
1899
|
}
|
|
1722
1900
|
AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1723
|
-
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
1901
|
+
AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularElasticSeachModule, AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
|
|
1724
1902
|
AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
|
|
1725
1903
|
AuthService,
|
|
1726
1904
|
CartService,
|
|
@@ -1732,11 +1910,12 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
|
|
|
1732
1910
|
HomeShopService,
|
|
1733
1911
|
OrderService,
|
|
1734
1912
|
ShippingService,
|
|
1735
|
-
|
|
1913
|
+
WishlistService,
|
|
1914
|
+
], imports: [[AngularElasticSeachModule, AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
1736
1915
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
1737
1916
|
type: NgModule,
|
|
1738
1917
|
args: [{
|
|
1739
|
-
imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
|
|
1918
|
+
imports: [AngularElasticSeachModule, AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
|
|
1740
1919
|
providers: [
|
|
1741
1920
|
AuthService,
|
|
1742
1921
|
CartService,
|
|
@@ -1748,6 +1927,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1748
1927
|
HomeShopService,
|
|
1749
1928
|
OrderService,
|
|
1750
1929
|
ShippingService,
|
|
1930
|
+
WishlistService,
|
|
1751
1931
|
],
|
|
1752
1932
|
}]
|
|
1753
1933
|
}] });
|
|
@@ -1864,5 +2044,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1864
2044
|
* Generated bundle index. Do not edit.
|
|
1865
2045
|
*/
|
|
1866
2046
|
|
|
1867
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService };
|
|
2047
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
1868
2048
|
//# sourceMappingURL=infrab4a-connect-angular.js.map
|