@infrab4a/connect-angular 5.7.5-beta.11 → 5.7.5-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,12 +3,12 @@ import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angu
|
|
|
3
3
|
import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
|
|
4
4
|
import { provideAppCheck, initializeAppCheck } from '@angular/fire/app-check';
|
|
5
5
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
6
|
-
import * as
|
|
7
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, CategoryFirestoreRepository, ProductFirestoreRepository, ProductVariantFirestoreRepository, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository,
|
|
6
|
+
import * as i1$2 from '@infrab4a/connect';
|
|
7
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, CategoryFirestoreRepository, ProductFirestoreRepository, ProductVariantFirestoreRepository, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, GroupFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, BrandCategoryFirestoreRepository, ShopConfigsFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductErrorsHasuraGraphQLRepository, ProductCatalogHasuraGraphQLRepository, ProductStockEntryHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where, isEmpty, Shops, set, InvalidArgumentError, RoundProductPricesHelper, Category, WishlistLogType, PersonTypes, Wishlist, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, CheckoutSubscription, Product, RequiredArgumentError, add, ProductReview, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
8
8
|
import * as i1 from '@angular/fire/auth';
|
|
9
9
|
import { Auth, provideAuth, initializeAuth, indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
10
10
|
import { isPlatformServer, isPlatformBrowser } from '@angular/common';
|
|
11
|
-
import * as i1$
|
|
11
|
+
import * as i1$3 from '@angular/fire/firestore';
|
|
12
12
|
import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
13
13
|
import cookie from 'js-cookie';
|
|
14
14
|
import { of, from, combineLatest, throwError, Subject, forkJoin } from 'rxjs';
|
|
@@ -304,13 +304,6 @@ class AngularFirestoreModule {
|
|
|
304
304
|
},
|
|
305
305
|
deps: ['FirestoreOptions'],
|
|
306
306
|
},
|
|
307
|
-
{
|
|
308
|
-
provide: 'CampaignHashtagPostsRepository',
|
|
309
|
-
useFactory: (options) => {
|
|
310
|
-
return new CampaignHashtagPostsFirestoreRepository(options);
|
|
311
|
-
},
|
|
312
|
-
deps: ['FirestoreOptions'],
|
|
313
|
-
},
|
|
314
307
|
{
|
|
315
308
|
provide: 'CampaignDashboardRepository',
|
|
316
309
|
useFactory: (options) => {
|
|
@@ -318,13 +311,6 @@ class AngularFirestoreModule {
|
|
|
318
311
|
},
|
|
319
312
|
deps: ['FirestoreOptions'],
|
|
320
313
|
},
|
|
321
|
-
{
|
|
322
|
-
provide: 'CampaignSettingsRepository',
|
|
323
|
-
useFactory: (options) => {
|
|
324
|
-
return new CampaignSettingsFirestoreRepository(options);
|
|
325
|
-
},
|
|
326
|
-
deps: ['FirestoreOptions'],
|
|
327
|
-
},
|
|
328
314
|
{
|
|
329
315
|
provide: 'EditionRepository',
|
|
330
316
|
useFactory: (options, subscriptionRepository) => {
|
|
@@ -374,13 +360,6 @@ class AngularFirestoreModule {
|
|
|
374
360
|
},
|
|
375
361
|
deps: ['FirestoreOptions'],
|
|
376
362
|
},
|
|
377
|
-
{
|
|
378
|
-
provide: 'PendingOrderRepository',
|
|
379
|
-
useFactory: (options) => {
|
|
380
|
-
return new PendingOrderFirestoreRepository(options);
|
|
381
|
-
},
|
|
382
|
-
deps: ['FirestoreOptions'],
|
|
383
|
-
},
|
|
384
363
|
{
|
|
385
364
|
provide: 'PaymentRepository',
|
|
386
365
|
useFactory: (options) => {
|
|
@@ -388,27 +367,6 @@ class AngularFirestoreModule {
|
|
|
388
367
|
},
|
|
389
368
|
deps: ['FirestoreOptions'],
|
|
390
369
|
},
|
|
391
|
-
{
|
|
392
|
-
provide: 'ShoppingRecurrenceRepository',
|
|
393
|
-
useFactory: (options) => {
|
|
394
|
-
return new ShoppingRecurrenceFirestoreRepository(options);
|
|
395
|
-
},
|
|
396
|
-
deps: ['FirestoreOptions'],
|
|
397
|
-
},
|
|
398
|
-
{
|
|
399
|
-
provide: 'ShoppingRecurrenceEditionRepository',
|
|
400
|
-
useFactory: (options) => {
|
|
401
|
-
return new ShoppingRecurrenceEditionFirestoreRepository(options);
|
|
402
|
-
},
|
|
403
|
-
deps: ['FirestoreOptions'],
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
provide: 'ShoppingRecurrenceErrorLogRepository',
|
|
407
|
-
useFactory: (options) => {
|
|
408
|
-
return new ShoppingRecurrenceErrorLogFirestoreRepository(options);
|
|
409
|
-
},
|
|
410
|
-
deps: ['FirestoreOptions'],
|
|
411
|
-
},
|
|
412
370
|
{
|
|
413
371
|
provide: ProductFirestoreRepository,
|
|
414
372
|
useFactory: (options) => {
|
|
@@ -619,13 +577,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
619
577
|
},
|
|
620
578
|
deps: ['FirestoreOptions'],
|
|
621
579
|
},
|
|
622
|
-
{
|
|
623
|
-
provide: 'CampaignHashtagPostsRepository',
|
|
624
|
-
useFactory: (options) => {
|
|
625
|
-
return new CampaignHashtagPostsFirestoreRepository(options);
|
|
626
|
-
},
|
|
627
|
-
deps: ['FirestoreOptions'],
|
|
628
|
-
},
|
|
629
580
|
{
|
|
630
581
|
provide: 'CampaignDashboardRepository',
|
|
631
582
|
useFactory: (options) => {
|
|
@@ -633,13 +584,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
633
584
|
},
|
|
634
585
|
deps: ['FirestoreOptions'],
|
|
635
586
|
},
|
|
636
|
-
{
|
|
637
|
-
provide: 'CampaignSettingsRepository',
|
|
638
|
-
useFactory: (options) => {
|
|
639
|
-
return new CampaignSettingsFirestoreRepository(options);
|
|
640
|
-
},
|
|
641
|
-
deps: ['FirestoreOptions'],
|
|
642
|
-
},
|
|
643
587
|
{
|
|
644
588
|
provide: 'EditionRepository',
|
|
645
589
|
useFactory: (options, subscriptionRepository) => {
|
|
@@ -689,13 +633,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
689
633
|
},
|
|
690
634
|
deps: ['FirestoreOptions'],
|
|
691
635
|
},
|
|
692
|
-
{
|
|
693
|
-
provide: 'PendingOrderRepository',
|
|
694
|
-
useFactory: (options) => {
|
|
695
|
-
return new PendingOrderFirestoreRepository(options);
|
|
696
|
-
},
|
|
697
|
-
deps: ['FirestoreOptions'],
|
|
698
|
-
},
|
|
699
636
|
{
|
|
700
637
|
provide: 'PaymentRepository',
|
|
701
638
|
useFactory: (options) => {
|
|
@@ -703,27 +640,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
703
640
|
},
|
|
704
641
|
deps: ['FirestoreOptions'],
|
|
705
642
|
},
|
|
706
|
-
{
|
|
707
|
-
provide: 'ShoppingRecurrenceRepository',
|
|
708
|
-
useFactory: (options) => {
|
|
709
|
-
return new ShoppingRecurrenceFirestoreRepository(options);
|
|
710
|
-
},
|
|
711
|
-
deps: ['FirestoreOptions'],
|
|
712
|
-
},
|
|
713
|
-
{
|
|
714
|
-
provide: 'ShoppingRecurrenceEditionRepository',
|
|
715
|
-
useFactory: (options) => {
|
|
716
|
-
return new ShoppingRecurrenceEditionFirestoreRepository(options);
|
|
717
|
-
},
|
|
718
|
-
deps: ['FirestoreOptions'],
|
|
719
|
-
},
|
|
720
|
-
{
|
|
721
|
-
provide: 'ShoppingRecurrenceErrorLogRepository',
|
|
722
|
-
useFactory: (options) => {
|
|
723
|
-
return new ShoppingRecurrenceErrorLogFirestoreRepository(options);
|
|
724
|
-
},
|
|
725
|
-
deps: ['FirestoreOptions'],
|
|
726
|
-
},
|
|
727
643
|
{
|
|
728
644
|
provide: ProductFirestoreRepository,
|
|
729
645
|
useFactory: (options) => {
|
|
@@ -862,7 +778,7 @@ class AngularHasuraGraphQLModule {
|
|
|
862
778
|
useFactory: (options, platformId) => ({
|
|
863
779
|
endpoint: options.endpoint,
|
|
864
780
|
authOptions: options.credentials,
|
|
865
|
-
cache:
|
|
781
|
+
cache: options.cache,
|
|
866
782
|
interceptors: {
|
|
867
783
|
request: (request) => {
|
|
868
784
|
if (isPlatformBrowser(platformId))
|
|
@@ -1033,28 +949,6 @@ class AngularHasuraGraphQLModule {
|
|
|
1033
949
|
provide: 'ProductStockEntryRepository',
|
|
1034
950
|
useExisting: ProductStockEntryHasuraGraphQLRepository,
|
|
1035
951
|
},
|
|
1036
|
-
{
|
|
1037
|
-
provide: ProductGroupHasuraGraphQLRepository,
|
|
1038
|
-
useFactory: (options) => {
|
|
1039
|
-
return new ProductGroupHasuraGraphQLRepository(options);
|
|
1040
|
-
},
|
|
1041
|
-
deps: ['HasuraConfig'],
|
|
1042
|
-
},
|
|
1043
|
-
{
|
|
1044
|
-
provide: 'ProductGroupRepository',
|
|
1045
|
-
useExisting: ProductGroupHasuraGraphQLRepository,
|
|
1046
|
-
},
|
|
1047
|
-
{
|
|
1048
|
-
provide: ProductPriceLogHasuraGraphQLRepository,
|
|
1049
|
-
useFactory: (options) => {
|
|
1050
|
-
return new ProductPriceLogHasuraGraphQLRepository(options);
|
|
1051
|
-
},
|
|
1052
|
-
deps: ['HasuraConfig'],
|
|
1053
|
-
},
|
|
1054
|
-
{
|
|
1055
|
-
provide: 'ProductPriceLogRepository',
|
|
1056
|
-
useExisting: ProductPriceLogHasuraGraphQLRepository,
|
|
1057
|
-
},
|
|
1058
952
|
] }); }
|
|
1059
953
|
}
|
|
1060
954
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
|
|
@@ -1066,7 +960,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
1066
960
|
useFactory: (options, platformId) => ({
|
|
1067
961
|
endpoint: options.endpoint,
|
|
1068
962
|
authOptions: options.credentials,
|
|
1069
|
-
cache:
|
|
963
|
+
cache: options.cache,
|
|
1070
964
|
interceptors: {
|
|
1071
965
|
request: (request) => {
|
|
1072
966
|
if (isPlatformBrowser(platformId))
|
|
@@ -1237,28 +1131,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
1237
1131
|
provide: 'ProductStockEntryRepository',
|
|
1238
1132
|
useExisting: ProductStockEntryHasuraGraphQLRepository,
|
|
1239
1133
|
},
|
|
1240
|
-
{
|
|
1241
|
-
provide: ProductGroupHasuraGraphQLRepository,
|
|
1242
|
-
useFactory: (options) => {
|
|
1243
|
-
return new ProductGroupHasuraGraphQLRepository(options);
|
|
1244
|
-
},
|
|
1245
|
-
deps: ['HasuraConfig'],
|
|
1246
|
-
},
|
|
1247
|
-
{
|
|
1248
|
-
provide: 'ProductGroupRepository',
|
|
1249
|
-
useExisting: ProductGroupHasuraGraphQLRepository,
|
|
1250
|
-
},
|
|
1251
|
-
{
|
|
1252
|
-
provide: ProductPriceLogHasuraGraphQLRepository,
|
|
1253
|
-
useFactory: (options) => {
|
|
1254
|
-
return new ProductPriceLogHasuraGraphQLRepository(options);
|
|
1255
|
-
},
|
|
1256
|
-
deps: ['HasuraConfig'],
|
|
1257
|
-
},
|
|
1258
|
-
{
|
|
1259
|
-
provide: 'ProductPriceLogRepository',
|
|
1260
|
-
useExisting: ProductPriceLogHasuraGraphQLRepository,
|
|
1261
|
-
},
|
|
1262
1134
|
],
|
|
1263
1135
|
}]
|
|
1264
1136
|
}] });
|
|
@@ -1392,7 +1264,7 @@ class ConfigurationFacade {
|
|
|
1392
1264
|
}
|
|
1393
1265
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: ConfigurationFacade, decorators: [{
|
|
1394
1266
|
type: Injectable
|
|
1395
|
-
}], ctorParameters: () => [{ type:
|
|
1267
|
+
}], ctorParameters: () => [{ type: i1$2.Shops, decorators: [{
|
|
1396
1268
|
type: Inject,
|
|
1397
1269
|
args: [DEFAULT_SHOP]
|
|
1398
1270
|
}] }, { type: undefined, decorators: [{
|
|
@@ -1444,41 +1316,16 @@ class CheckoutService {
|
|
|
1444
1316
|
checkoutId: checkout.id,
|
|
1445
1317
|
})), concatMap(() => this.getCheckout()));
|
|
1446
1318
|
}
|
|
1447
|
-
applyPointsDiscount(points) {
|
|
1448
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutApplyPointsDiscount`, {
|
|
1449
|
-
checkoutId: checkout.id,
|
|
1450
|
-
points,
|
|
1451
|
-
})), concatMap(() => this.getCheckout()));
|
|
1452
|
-
}
|
|
1453
|
-
removePointsDiscount() {
|
|
1454
|
-
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemovePointsDiscount`, {
|
|
1455
|
-
checkoutId: checkout.id,
|
|
1456
|
-
})), concatMap(() => this.getCheckout()));
|
|
1457
|
-
}
|
|
1458
1319
|
validateStockProducts() {
|
|
1459
1320
|
return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutValidateProductStock`, {
|
|
1460
1321
|
checkoutId: checkout.id,
|
|
1461
1322
|
})));
|
|
1462
1323
|
}
|
|
1463
1324
|
selectShippingAddress(address) {
|
|
1464
|
-
const formattedAddress = {
|
|
1465
|
-
...address,
|
|
1466
|
-
zip: this.formatZip(address.zip),
|
|
1467
|
-
};
|
|
1468
1325
|
return this.getCheckout().pipe(concatMap((checkout) => {
|
|
1469
|
-
return this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({
|
|
1470
|
-
id: checkout.id,
|
|
1471
|
-
shippingAddress: formattedAddress,
|
|
1472
|
-
billingAddress: formattedAddress,
|
|
1473
|
-
}));
|
|
1326
|
+
return this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, shippingAddress: address, billingAddress: address }));
|
|
1474
1327
|
}));
|
|
1475
1328
|
}
|
|
1476
|
-
formatZip(zip) {
|
|
1477
|
-
if (!zip)
|
|
1478
|
-
return zip;
|
|
1479
|
-
const digits = zip.replace(/\D/g, '');
|
|
1480
|
-
return digits;
|
|
1481
|
-
}
|
|
1482
1329
|
getAvailableShippingForProduct(productShipping) {
|
|
1483
1330
|
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
|
|
1484
1331
|
checkoutId: null,
|
|
@@ -1535,7 +1382,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
1535
1382
|
type: Injectable
|
|
1536
1383
|
}], ctorParameters: () => [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.HttpClient }] });
|
|
1537
1384
|
|
|
1538
|
-
/* eslint-disable max-params */
|
|
1539
1385
|
class CartService {
|
|
1540
1386
|
constructor(servicesFacade, configurationFacade) {
|
|
1541
1387
|
this.servicesFacade = servicesFacade;
|
|
@@ -1551,21 +1397,11 @@ class CartService {
|
|
|
1551
1397
|
}), {}) || {};
|
|
1552
1398
|
this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
|
|
1553
1399
|
}
|
|
1554
|
-
addItem(item, quantity = 1
|
|
1400
|
+
addItem(item, quantity = 1) {
|
|
1555
1401
|
return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutAddItemToCart`, {
|
|
1556
1402
|
checkoutId: checkout.id,
|
|
1557
1403
|
productId: item.id,
|
|
1558
1404
|
quantity,
|
|
1559
|
-
recurrence,
|
|
1560
|
-
recurrenceCycle,
|
|
1561
|
-
})), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1562
|
-
}
|
|
1563
|
-
updateItemRecurrence(item, recurrence = false, recurrenceCycle = null) {
|
|
1564
|
-
return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutUpdateItemRecurrence`, {
|
|
1565
|
-
checkoutId: checkout.id,
|
|
1566
|
-
productId: item.id,
|
|
1567
|
-
recurrence,
|
|
1568
|
-
recurrenceCycle,
|
|
1569
1405
|
})), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1570
1406
|
}
|
|
1571
1407
|
decreaseItem(item) {
|
|
@@ -1634,9 +1470,6 @@ class NewCategoryStructureAdapter {
|
|
|
1634
1470
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1635
1471
|
}
|
|
1636
1472
|
async getCategory(category) {
|
|
1637
|
-
if ((category.isWishlist || category.isCollection) && Array.isArray(category.products)) {
|
|
1638
|
-
return category;
|
|
1639
|
-
}
|
|
1640
1473
|
const collectionCategory = category.isCollection ||
|
|
1641
1474
|
(isNil(category.isCollection) && !category.products?.length) ||
|
|
1642
1475
|
category.isWishlist ||
|
|
@@ -1724,18 +1557,6 @@ class CategorySearchStrategy {
|
|
|
1724
1557
|
throw new Error('Category is required for CategorySearchStrategy');
|
|
1725
1558
|
}
|
|
1726
1559
|
const fields = this.helpersService.getFieldsHelper().getStandardFields();
|
|
1727
|
-
if (category.isWishlist) {
|
|
1728
|
-
return this.searchDefault({
|
|
1729
|
-
category,
|
|
1730
|
-
filters,
|
|
1731
|
-
limits,
|
|
1732
|
-
shop,
|
|
1733
|
-
mainGender,
|
|
1734
|
-
sort: sort === 'most-relevant' ? 'best-sellers' : sort,
|
|
1735
|
-
optionsCache,
|
|
1736
|
-
fields,
|
|
1737
|
-
});
|
|
1738
|
-
}
|
|
1739
1560
|
if (sort === 'most-relevant') {
|
|
1740
1561
|
return this.searchWithMostRelevant({
|
|
1741
1562
|
category,
|
|
@@ -1833,9 +1654,12 @@ class CategorySearchStrategy {
|
|
|
1833
1654
|
const firstProducts = totalResult.data
|
|
1834
1655
|
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
1835
1656
|
.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
|
|
1836
|
-
const
|
|
1837
|
-
|
|
1838
|
-
.
|
|
1657
|
+
const nonPinnedProducts = totalResult.data.filter((product) => !mostRelevants.includes(product.id));
|
|
1658
|
+
const novoProducts = nonPinnedProducts
|
|
1659
|
+
.filter((product) => product.stock?.quantity > 0 && this.isCreatedWithinLastDays(product.createdAt, 30))
|
|
1660
|
+
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
1661
|
+
const restProducts = nonPinnedProducts.filter((product) => !(product.stock?.quantity > 0 && this.isCreatedWithinLastDays(product.createdAt, 30)));
|
|
1662
|
+
const lastProducts = novoProducts.concat(restProducts).concat(mostRelevantWithoutStock);
|
|
1839
1663
|
const categoryMostRelevants = firstProducts.concat(lastProducts);
|
|
1840
1664
|
const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
|
|
1841
1665
|
return {
|
|
@@ -1846,6 +1670,17 @@ class CategorySearchStrategy {
|
|
|
1846
1670
|
distinct: totalResult.distinct,
|
|
1847
1671
|
};
|
|
1848
1672
|
}
|
|
1673
|
+
isCreatedWithinLastDays(createdAt, days) {
|
|
1674
|
+
if (!createdAt || days <= 0) {
|
|
1675
|
+
return false;
|
|
1676
|
+
}
|
|
1677
|
+
const createdDate = createdAt instanceof Date ? createdAt : new Date(createdAt);
|
|
1678
|
+
if (Number.isNaN(createdDate.getTime())) {
|
|
1679
|
+
return false;
|
|
1680
|
+
}
|
|
1681
|
+
const cutoff = Date.now() - days * 24 * 60 * 60 * 1000;
|
|
1682
|
+
return createdDate.getTime() >= cutoff;
|
|
1683
|
+
}
|
|
1849
1684
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategorySearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1850
1685
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategorySearchStrategy }); }
|
|
1851
1686
|
}
|
|
@@ -2040,7 +1875,7 @@ class CatalogServiceFacade {
|
|
|
2040
1875
|
}
|
|
2041
1876
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CatalogServiceFacade, decorators: [{
|
|
2042
1877
|
type: Injectable
|
|
2043
|
-
}], ctorParameters: () => [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type:
|
|
1878
|
+
}], ctorParameters: () => [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type: i1$2.Shops, decorators: [{
|
|
2044
1879
|
type: Inject,
|
|
2045
1880
|
args: [DEFAULT_SHOP]
|
|
2046
1881
|
}] }] });
|
|
@@ -2093,7 +1928,7 @@ class CategoryService {
|
|
|
2093
1928
|
}
|
|
2094
1929
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategoryService, decorators: [{
|
|
2095
1930
|
type: Injectable
|
|
2096
|
-
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type:
|
|
1931
|
+
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i1$2.Shops, decorators: [{
|
|
2097
1932
|
type: Inject,
|
|
2098
1933
|
args: [DEFAULT_SHOP]
|
|
2099
1934
|
}] }] });
|
|
@@ -2131,7 +1966,7 @@ class CategoryServiceFacade {
|
|
|
2131
1966
|
}
|
|
2132
1967
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CategoryServiceFacade, decorators: [{
|
|
2133
1968
|
type: Injectable
|
|
2134
|
-
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type:
|
|
1969
|
+
}], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i1$2.Shops, decorators: [{
|
|
2135
1970
|
type: Inject,
|
|
2136
1971
|
args: [DEFAULT_SHOP]
|
|
2137
1972
|
}] }] });
|
|
@@ -2513,7 +2348,7 @@ class CatalogService {
|
|
|
2513
2348
|
}
|
|
2514
2349
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CatalogService, decorators: [{
|
|
2515
2350
|
type: Injectable
|
|
2516
|
-
}], ctorParameters: () => [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type:
|
|
2351
|
+
}], ctorParameters: () => [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type: i1$2.Shops, decorators: [{
|
|
2517
2352
|
type: Inject,
|
|
2518
2353
|
args: [DEFAULT_SHOP]
|
|
2519
2354
|
}] }] });
|
|
@@ -2784,11 +2619,320 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
2784
2619
|
}] }, { type: undefined, decorators: [{
|
|
2785
2620
|
type: Inject,
|
|
2786
2621
|
args: ['LogRepository']
|
|
2787
|
-
}] }, { type:
|
|
2622
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
2788
2623
|
type: Inject,
|
|
2789
2624
|
args: [DEFAULT_SHOP]
|
|
2790
2625
|
}] }] });
|
|
2791
2626
|
|
|
2627
|
+
class CouponRepositoriesFacade {
|
|
2628
|
+
constructor(couponRepository, orderRepository, categoryRepository) {
|
|
2629
|
+
this.couponRepository = couponRepository;
|
|
2630
|
+
this.orderRepository = orderRepository;
|
|
2631
|
+
this.categoryRepository = categoryRepository;
|
|
2632
|
+
}
|
|
2633
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, deps: [{ token: 'CouponRepository' }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2634
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade }); }
|
|
2635
|
+
}
|
|
2636
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
|
|
2637
|
+
type: Injectable
|
|
2638
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2639
|
+
type: Inject,
|
|
2640
|
+
args: ['CouponRepository']
|
|
2641
|
+
}] }, { type: undefined, decorators: [{
|
|
2642
|
+
type: Inject,
|
|
2643
|
+
args: ['OrderRepository']
|
|
2644
|
+
}] }, { type: undefined, decorators: [{
|
|
2645
|
+
type: Inject,
|
|
2646
|
+
args: ['CategoryRepository']
|
|
2647
|
+
}] }] });
|
|
2648
|
+
|
|
2649
|
+
class CouponService {
|
|
2650
|
+
constructor(repositoriesFacade, configurationFacade) {
|
|
2651
|
+
this.repositoriesFacade = repositoriesFacade;
|
|
2652
|
+
this.configurationFacade = configurationFacade;
|
|
2653
|
+
this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
|
|
2654
|
+
}
|
|
2655
|
+
checkCoupon(params) {
|
|
2656
|
+
const { nickname, checkoutType, checkout, plan } = params;
|
|
2657
|
+
return from(this.repositoriesFacade.couponRepository
|
|
2658
|
+
.find({
|
|
2659
|
+
filters: {
|
|
2660
|
+
nickname: { operator: Where.EQUALS, value: nickname },
|
|
2661
|
+
active: { operator: Where.EQUALS, value: true },
|
|
2662
|
+
},
|
|
2663
|
+
})
|
|
2664
|
+
.then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation({ coupon: couponValid, checkoutType, checkout, plan })), map((couponValidated) => couponValidated));
|
|
2665
|
+
}
|
|
2666
|
+
async couponValidation(coupon, checkoutType) {
|
|
2667
|
+
if (!coupon)
|
|
2668
|
+
throw 'Cupom inválido.';
|
|
2669
|
+
if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
|
|
2670
|
+
throw 'Cupom inválido.';
|
|
2671
|
+
if (coupon?.expiresIn && (coupon?.expiresIn).getTime() < new Date().getTime())
|
|
2672
|
+
throw 'Cupom expirado.';
|
|
2673
|
+
const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.configurationFacade.defaultShop;
|
|
2674
|
+
if (!isInShop)
|
|
2675
|
+
throw 'Cupom inválido para loja.';
|
|
2676
|
+
const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
|
|
2677
|
+
if (!isCheckoutType)
|
|
2678
|
+
throw 'Cupom inválido. Erro de checkout.';
|
|
2679
|
+
return coupon;
|
|
2680
|
+
}
|
|
2681
|
+
async couponRulesValidation(params) {
|
|
2682
|
+
const { coupon, checkoutType, checkout, plan } = params;
|
|
2683
|
+
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
2684
|
+
return this.validateSubscriptionCoupon(coupon, plan);
|
|
2685
|
+
}
|
|
2686
|
+
return this.validateEcommerceCoupon(coupon, checkoutType, checkout);
|
|
2687
|
+
}
|
|
2688
|
+
validateSubscriptionCoupon(coupon, plan) {
|
|
2689
|
+
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase()) {
|
|
2690
|
+
throw 'Cupom inválido para sua assinatura.';
|
|
2691
|
+
}
|
|
2692
|
+
return coupon;
|
|
2693
|
+
}
|
|
2694
|
+
async validateEcommerceCoupon(coupon, checkoutType, checkout) {
|
|
2695
|
+
this.validateUserEligibility(coupon, checkout?.user);
|
|
2696
|
+
await this.validateUsageLimits(coupon, checkoutType, checkout);
|
|
2697
|
+
await this.validateProductEligibility(coupon, checkout);
|
|
2698
|
+
return coupon;
|
|
2699
|
+
}
|
|
2700
|
+
validateUserEligibility(coupon, user) {
|
|
2701
|
+
const validUser = this.coupomUserValidation(coupon, user);
|
|
2702
|
+
if (!validUser)
|
|
2703
|
+
throw 'Usuário não elegível.';
|
|
2704
|
+
}
|
|
2705
|
+
async validateUsageLimits(coupon, checkoutType, checkout) {
|
|
2706
|
+
const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
|
|
2707
|
+
if (couponUseLimits.firstOrder) {
|
|
2708
|
+
await this.validateFirstOrderLimit(checkout.user.email);
|
|
2709
|
+
}
|
|
2710
|
+
if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
|
|
2711
|
+
await this.validateCouponUsageLimits(coupon, couponUseLimits, checkout.user.email);
|
|
2712
|
+
}
|
|
2713
|
+
}
|
|
2714
|
+
async validateFirstOrderLimit(userEmail) {
|
|
2715
|
+
const ordersUser = await this.getOrdersFromUser(userEmail.toLocaleLowerCase());
|
|
2716
|
+
if (ordersUser.length >= 1)
|
|
2717
|
+
throw 'Limite de uso atingido';
|
|
2718
|
+
}
|
|
2719
|
+
async validateCouponUsageLimits(coupon, couponUseLimits, userEmail) {
|
|
2720
|
+
const ordersCoupon = await this.getOrdersWithCoupon(coupon);
|
|
2721
|
+
if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total) {
|
|
2722
|
+
throw 'Limite de uso atingido.';
|
|
2723
|
+
}
|
|
2724
|
+
if (couponUseLimits.limitedPerUser) {
|
|
2725
|
+
const ordersWithUser = this.countOrdersWithUser(ordersCoupon, userEmail);
|
|
2726
|
+
if (ordersWithUser > 0)
|
|
2727
|
+
throw 'Limite de uso por usuário atingido.';
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
async validateProductEligibility(coupon, checkout) {
|
|
2731
|
+
const hasProductCategories = await this.hasProductCategories(coupon, checkout);
|
|
2732
|
+
if (!hasProductCategories)
|
|
2733
|
+
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
2734
|
+
const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
|
|
2735
|
+
if (!hasMinSubTotal) {
|
|
2736
|
+
this.throwMinSubTotalError(coupon);
|
|
2737
|
+
}
|
|
2738
|
+
}
|
|
2739
|
+
throwMinSubTotalError(coupon) {
|
|
2740
|
+
const formattedValue = Intl.NumberFormat('pt-BR', {
|
|
2741
|
+
style: 'currency',
|
|
2742
|
+
currency: 'BRL',
|
|
2743
|
+
}).format(coupon.minSubTotalValue);
|
|
2744
|
+
if (coupon.productsCategories?.length) {
|
|
2745
|
+
throw `Valor mínimo de ${formattedValue} não atingido na(s) categoria(s) elegíveis para o desconto.`;
|
|
2746
|
+
}
|
|
2747
|
+
throw `Valor mínimo de ${formattedValue} não atingido.`;
|
|
2748
|
+
}
|
|
2749
|
+
calcDiscountSubscription(coupon, checkout) {
|
|
2750
|
+
let discount = 0;
|
|
2751
|
+
if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
|
|
2752
|
+
discount = coupon.discount.subscription.value;
|
|
2753
|
+
else
|
|
2754
|
+
discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
|
|
2755
|
+
return of(discount);
|
|
2756
|
+
}
|
|
2757
|
+
async hasMinSubTotal(coupon, checkout) {
|
|
2758
|
+
if (!coupon.minSubTotalValue)
|
|
2759
|
+
return true;
|
|
2760
|
+
const lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
2761
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
2762
|
+
if (coupon.minSubTotalValue <= subTotal)
|
|
2763
|
+
return true;
|
|
2764
|
+
return false;
|
|
2765
|
+
}
|
|
2766
|
+
async hasProductCategories(coupon, checkout) {
|
|
2767
|
+
if (!coupon.productsCategories?.length) {
|
|
2768
|
+
return true;
|
|
2769
|
+
}
|
|
2770
|
+
const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
|
|
2771
|
+
const hasCategories = checkout.lineItems?.filter((item) => {
|
|
2772
|
+
if (item.isGift)
|
|
2773
|
+
return false;
|
|
2774
|
+
if (!item.categories?.length)
|
|
2775
|
+
return true;
|
|
2776
|
+
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
2777
|
+
});
|
|
2778
|
+
return hasCategories?.length ? true : false;
|
|
2779
|
+
}
|
|
2780
|
+
coupomUserValidation(coupon, user) {
|
|
2781
|
+
if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
|
|
2782
|
+
return true;
|
|
2783
|
+
const userTypes = [];
|
|
2784
|
+
if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
|
|
2785
|
+
this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
|
|
2786
|
+
userTypes.push(Exclusivities.COLLABORATORS);
|
|
2787
|
+
if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
|
|
2788
|
+
coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
|
|
2789
|
+
userTypes.push(Exclusivities.SPECIFIC_USER);
|
|
2790
|
+
if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
|
|
2791
|
+
user.isSubscriber &&
|
|
2792
|
+
user.subscriptionPlan != '')
|
|
2793
|
+
userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
|
|
2794
|
+
if (user.isSubscriber &&
|
|
2795
|
+
user.subscriptionPlan == '' &&
|
|
2796
|
+
coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
|
|
2797
|
+
userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
|
|
2798
|
+
if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
|
|
2799
|
+
userTypes.push(Exclusivities.NON_SUBSCRIBER);
|
|
2800
|
+
return coupon.exclusivityType.some((r) => userTypes.includes(r));
|
|
2801
|
+
}
|
|
2802
|
+
async getCouponCategoriesId(productsCategories) {
|
|
2803
|
+
const couponCategories = [];
|
|
2804
|
+
for (let index = 0; index < productsCategories.length; index++) {
|
|
2805
|
+
const category = await this.repositoriesFacade.categoryRepository.get({
|
|
2806
|
+
id: productsCategories[index],
|
|
2807
|
+
});
|
|
2808
|
+
if (category) {
|
|
2809
|
+
const children = await this.repositoriesFacade.categoryRepository.getChildren(parseInt(productsCategories[index]));
|
|
2810
|
+
couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
|
|
2811
|
+
}
|
|
2812
|
+
}
|
|
2813
|
+
return [...new Set(couponCategories)];
|
|
2814
|
+
}
|
|
2815
|
+
async getLineItensEligebleForDiscount(productsCategories, checkout) {
|
|
2816
|
+
let lineItensDiscount = [];
|
|
2817
|
+
const couponCategories = await this.getCouponCategoriesId(productsCategories);
|
|
2818
|
+
if (productsCategories?.length) {
|
|
2819
|
+
lineItensDiscount = checkout.lineItems?.filter((item) => {
|
|
2820
|
+
if (item.isGift)
|
|
2821
|
+
return false;
|
|
2822
|
+
if (item.categories?.length) {
|
|
2823
|
+
return item.categories.some((c) => couponCategories.some((cat) => cat == c));
|
|
2824
|
+
}
|
|
2825
|
+
return true;
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
else {
|
|
2829
|
+
lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
|
|
2830
|
+
}
|
|
2831
|
+
return lineItensDiscount;
|
|
2832
|
+
}
|
|
2833
|
+
calcCheckoutSubtotal(lineItens, user) {
|
|
2834
|
+
return (lineItens
|
|
2835
|
+
?.filter((item) => !item.isGift)
|
|
2836
|
+
.reduce((acc, curr) => user?.isSubscriber && curr.price?.subscriberPrice
|
|
2837
|
+
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
2838
|
+
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
2839
|
+
}
|
|
2840
|
+
async getOrdersWithCoupon(coupon) {
|
|
2841
|
+
return await this.repositoriesFacade.orderRepository
|
|
2842
|
+
.find({
|
|
2843
|
+
filters: {
|
|
2844
|
+
coupon: { id: coupon.id },
|
|
2845
|
+
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
2846
|
+
},
|
|
2847
|
+
})
|
|
2848
|
+
.then((result) => result.data);
|
|
2849
|
+
}
|
|
2850
|
+
async getOrdersFromUser(email) {
|
|
2851
|
+
return await this.repositoriesFacade.orderRepository
|
|
2852
|
+
.find({
|
|
2853
|
+
filters: {
|
|
2854
|
+
user: { email: { operator: Where.EQUALS, value: email } },
|
|
2855
|
+
status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
|
|
2856
|
+
},
|
|
2857
|
+
})
|
|
2858
|
+
.then((result) => result.data);
|
|
2859
|
+
}
|
|
2860
|
+
countOrdersWithUser(orders, email) {
|
|
2861
|
+
return orders.filter((o) => o.user.email == email).length;
|
|
2862
|
+
}
|
|
2863
|
+
getCouponUseLimits(coupon, checkoutType, user) {
|
|
2864
|
+
let couponUseLimits;
|
|
2865
|
+
if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
|
|
2866
|
+
if (coupon.exclusivityType.length === 1 &&
|
|
2867
|
+
(coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
|
|
2868
|
+
coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
|
|
2869
|
+
couponUseLimits = coupon.useLimits.non_subscriber;
|
|
2870
|
+
else
|
|
2871
|
+
couponUseLimits = user?.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
|
|
2872
|
+
}
|
|
2873
|
+
else {
|
|
2874
|
+
couponUseLimits = coupon.useLimits.subscription;
|
|
2875
|
+
}
|
|
2876
|
+
return couponUseLimits;
|
|
2877
|
+
}
|
|
2878
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponService, deps: [{ token: CouponRepositoriesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2879
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
2880
|
+
}
|
|
2881
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponService, decorators: [{
|
|
2882
|
+
type: Injectable,
|
|
2883
|
+
args: [{
|
|
2884
|
+
providedIn: 'root',
|
|
2885
|
+
}]
|
|
2886
|
+
}], ctorParameters: () => [{ type: CouponRepositoriesFacade }, { type: ConfigurationFacade }] });
|
|
2887
|
+
|
|
2888
|
+
class CheckoutSubscriptionService {
|
|
2889
|
+
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
2890
|
+
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2891
|
+
this.dataPersistence = dataPersistence;
|
|
2892
|
+
this.couponService = couponService;
|
|
2893
|
+
}
|
|
2894
|
+
getCheckoutSubscription(checkoutData) {
|
|
2895
|
+
return this.dataPersistence
|
|
2896
|
+
.get('checkoutSubscriptionId')
|
|
2897
|
+
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
2898
|
+
}
|
|
2899
|
+
clearCheckoutSubscriptionFromSession() {
|
|
2900
|
+
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
2901
|
+
}
|
|
2902
|
+
checkCoupon(nickname, _userEmail) {
|
|
2903
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
2904
|
+
.checkCoupon({
|
|
2905
|
+
nickname,
|
|
2906
|
+
checkoutType: CheckoutTypes.SUBSCRIPTION,
|
|
2907
|
+
checkout,
|
|
2908
|
+
plan: checkout.subscriptionPlan.name,
|
|
2909
|
+
})
|
|
2910
|
+
.pipe()));
|
|
2911
|
+
}
|
|
2912
|
+
calcDiscountSubscription(coupon) {
|
|
2913
|
+
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2914
|
+
}
|
|
2915
|
+
async createCheckoutSubscription(checkoutData) {
|
|
2916
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2917
|
+
createdAt: new Date(),
|
|
2918
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2919
|
+
});
|
|
2920
|
+
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2921
|
+
return checkout;
|
|
2922
|
+
}
|
|
2923
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2924
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
2925
|
+
}
|
|
2926
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
2927
|
+
type: Injectable
|
|
2928
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2929
|
+
type: Inject,
|
|
2930
|
+
args: ['CheckoutSubscriptionRepository']
|
|
2931
|
+
}] }, { type: undefined, decorators: [{
|
|
2932
|
+
type: Inject,
|
|
2933
|
+
args: [PERSISTENCE_PROVIDER]
|
|
2934
|
+
}] }, { type: CouponService }] });
|
|
2935
|
+
|
|
2792
2936
|
class UtilHelper {
|
|
2793
2937
|
static createSlug(name) {
|
|
2794
2938
|
return name
|
|
@@ -2890,17 +3034,6 @@ class HomeShopService {
|
|
|
2890
3034
|
getMinValueForFreeShipping() {
|
|
2891
3035
|
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
2892
3036
|
}
|
|
2893
|
-
/**
|
|
2894
|
-
* Retorna os thresholds de frete grátis estruturados configurados no documento
|
|
2895
|
-
* Home (`shippingThresholds`). Quando o documento ainda não possui essa
|
|
2896
|
-
* estrutura, retorna um default conservador equivalente à regra legada
|
|
2897
|
-
* (edition: 50, avulsoSp: 99, avulsoOutro: null) para que consumidores não
|
|
2898
|
-
* quebrem durante a migração.
|
|
2899
|
-
*/
|
|
2900
|
-
getShippingThresholds() {
|
|
2901
|
-
const conservativeDefault = { edition: 50, avulsoSp: 99, avulsoOutro: null };
|
|
2902
|
-
return this.getHomeConfiguration().pipe(map((home) => home.shippingThresholds ?? conservativeDefault));
|
|
2903
|
-
}
|
|
2904
3037
|
getDiscoverProducts(_gender) {
|
|
2905
3038
|
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
|
|
2906
3039
|
categoryIds: home.discoverCategories,
|
|
@@ -3057,7 +3190,7 @@ class OrderProductReviewService {
|
|
|
3057
3190
|
}
|
|
3058
3191
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderProductReviewService, decorators: [{
|
|
3059
3192
|
type: Injectable
|
|
3060
|
-
}], ctorParameters: () => [{ type:
|
|
3193
|
+
}], ctorParameters: () => [{ type: i1$2.OrderFirestoreRepository, decorators: [{
|
|
3061
3194
|
type: Inject,
|
|
3062
3195
|
args: ['OrderRepository']
|
|
3063
3196
|
}] }, { type: undefined, decorators: [{
|
|
@@ -3066,77 +3199,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3066
3199
|
}] }, { type: undefined, decorators: [{
|
|
3067
3200
|
type: Inject,
|
|
3068
3201
|
args: ['VariantRepository']
|
|
3069
|
-
}] }, { type:
|
|
3202
|
+
}] }, { type: i1$2.Shops, decorators: [{
|
|
3070
3203
|
type: Inject,
|
|
3071
3204
|
args: [DEFAULT_SHOP]
|
|
3072
3205
|
}] }] });
|
|
3073
3206
|
|
|
3074
|
-
class OrderRecurrenceService {
|
|
3075
|
-
constructor(shoppingRecurrenceRepository, defaultShop, dependenciesFacade, configurationFacade) {
|
|
3076
|
-
this.shoppingRecurrenceRepository = shoppingRecurrenceRepository;
|
|
3077
|
-
this.defaultShop = defaultShop;
|
|
3078
|
-
this.dependenciesFacade = dependenciesFacade;
|
|
3079
|
-
this.configurationFacade = configurationFacade;
|
|
3080
|
-
this.checkoutUrl = null;
|
|
3081
|
-
this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
|
|
3082
|
-
}
|
|
3083
|
-
getRecurrenceOrder(recurrenceId) {
|
|
3084
|
-
return from(this.shoppingRecurrenceRepository.get({ id: recurrenceId }));
|
|
3085
|
-
}
|
|
3086
|
-
createRecurrenceOrder(recurrencePayload) {
|
|
3087
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/createShoppingRecurrence`, {
|
|
3088
|
-
data: recurrencePayload,
|
|
3089
|
-
});
|
|
3090
|
-
}
|
|
3091
|
-
updatePaymentMethod(data) {
|
|
3092
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrencePaymentMethod`, {
|
|
3093
|
-
data,
|
|
3094
|
-
});
|
|
3095
|
-
}
|
|
3096
|
-
getRecurrenceAvailableShipping(data) {
|
|
3097
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/getShoppingRecurrenceAvailableShipping`, {
|
|
3098
|
-
data,
|
|
3099
|
-
});
|
|
3100
|
-
}
|
|
3101
|
-
updateShippingAddress(data) {
|
|
3102
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceShippingAddress`, {
|
|
3103
|
-
data,
|
|
3104
|
-
});
|
|
3105
|
-
}
|
|
3106
|
-
cancelRecurrenceOrder(data) {
|
|
3107
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/cancelShoppingRecurrence`, {
|
|
3108
|
-
data,
|
|
3109
|
-
});
|
|
3110
|
-
}
|
|
3111
|
-
enableOrDisableRecurrenceOrder(recurrenceId, active) {
|
|
3112
|
-
const payload = { recurrenceId, active };
|
|
3113
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/enableOrDisableShoppingRecurrence`, payload);
|
|
3114
|
-
}
|
|
3115
|
-
skipRecurrenceOrder(recurrenceEditionId) {
|
|
3116
|
-
const payload = { recurrenceEditionId };
|
|
3117
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/skipShoppingRecurrenceEdition`, payload);
|
|
3118
|
-
}
|
|
3119
|
-
updateFrequency(recurrenceId, frequency) {
|
|
3120
|
-
const payload = { recurrenceId, frequency };
|
|
3121
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceFrequency`, payload);
|
|
3122
|
-
}
|
|
3123
|
-
updateLineItems(recurrenceId, lineItems) {
|
|
3124
|
-
const payload = { recurrenceId, lineItems };
|
|
3125
|
-
return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/updateShoppingRecurrenceLineItems`, payload);
|
|
3126
|
-
}
|
|
3127
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderRecurrenceService, deps: [{ token: 'ShoppingRecurrenceRepository' }, { token: DEFAULT_SHOP }, { token: CheckoutDependenciesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3128
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderRecurrenceService }); }
|
|
3129
|
-
}
|
|
3130
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderRecurrenceService, decorators: [{
|
|
3131
|
-
type: Injectable
|
|
3132
|
-
}], ctorParameters: () => [{ type: i3.ShoppingRecurrenceFirestoreRepository, decorators: [{
|
|
3133
|
-
type: Inject,
|
|
3134
|
-
args: ['ShoppingRecurrenceRepository']
|
|
3135
|
-
}] }, { type: i3.Shops, decorators: [{
|
|
3136
|
-
type: Inject,
|
|
3137
|
-
args: [DEFAULT_SHOP]
|
|
3138
|
-
}] }, { type: CheckoutDependenciesFacade }, { type: ConfigurationFacade }] });
|
|
3139
|
-
|
|
3140
3207
|
class OrderService {
|
|
3141
3208
|
constructor(angularFirestore, orderRepository) {
|
|
3142
3209
|
this.angularFirestore = angularFirestore;
|
|
@@ -3149,38 +3216,16 @@ class OrderService {
|
|
|
3149
3216
|
.subscribe((doc) => this.orderSubject.next(doc));
|
|
3150
3217
|
return this.orderSubject;
|
|
3151
3218
|
}
|
|
3152
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService, deps: [{ token: i1$
|
|
3219
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService, deps: [{ token: i1$3.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3153
3220
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService }); }
|
|
3154
3221
|
}
|
|
3155
3222
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: OrderService, decorators: [{
|
|
3156
3223
|
type: Injectable
|
|
3157
|
-
}], ctorParameters: () => [{ type: i1$
|
|
3224
|
+
}], ctorParameters: () => [{ type: i1$3.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
|
|
3158
3225
|
type: Inject,
|
|
3159
3226
|
args: ['OrderRepository']
|
|
3160
3227
|
}] }] });
|
|
3161
3228
|
|
|
3162
|
-
class CouponRepositoriesFacade {
|
|
3163
|
-
constructor(couponRepository, orderRepository, categoryRepository) {
|
|
3164
|
-
this.couponRepository = couponRepository;
|
|
3165
|
-
this.orderRepository = orderRepository;
|
|
3166
|
-
this.categoryRepository = categoryRepository;
|
|
3167
|
-
}
|
|
3168
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, deps: [{ token: 'CouponRepository' }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3169
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade }); }
|
|
3170
|
-
}
|
|
3171
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
|
|
3172
|
-
type: Injectable
|
|
3173
|
-
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3174
|
-
type: Inject,
|
|
3175
|
-
args: ['CouponRepository']
|
|
3176
|
-
}] }, { type: undefined, decorators: [{
|
|
3177
|
-
type: Inject,
|
|
3178
|
-
args: ['OrderRepository']
|
|
3179
|
-
}] }, { type: undefined, decorators: [{
|
|
3180
|
-
type: Inject,
|
|
3181
|
-
args: ['CategoryRepository']
|
|
3182
|
-
}] }] });
|
|
3183
|
-
|
|
3184
3229
|
class AngularConnectModule {
|
|
3185
3230
|
static initializeApp(defaultShop, options, nameOrConfig) {
|
|
3186
3231
|
return {
|
|
@@ -3263,6 +3308,8 @@ class AngularConnectModule {
|
|
|
3263
3308
|
CatalogService,
|
|
3264
3309
|
CategoryService,
|
|
3265
3310
|
CheckoutService,
|
|
3311
|
+
CheckoutSubscriptionService,
|
|
3312
|
+
CouponService,
|
|
3266
3313
|
HomeShopService,
|
|
3267
3314
|
OrderService,
|
|
3268
3315
|
WishlistService,
|
|
@@ -3323,7 +3370,6 @@ class AngularConnectModule {
|
|
|
3323
3370
|
CouponRepositoriesFacade,
|
|
3324
3371
|
HomeShopRepositoriesFacade,
|
|
3325
3372
|
OrderProductReviewService,
|
|
3326
|
-
OrderRecurrenceService,
|
|
3327
3373
|
], imports: [AngularElasticSeachModule,
|
|
3328
3374
|
AngularVertexSeachModule,
|
|
3329
3375
|
AngularFirebaseAuthModule,
|
|
@@ -3376,6 +3422,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3376
3422
|
CatalogService,
|
|
3377
3423
|
CategoryService,
|
|
3378
3424
|
CheckoutService,
|
|
3425
|
+
CheckoutSubscriptionService,
|
|
3426
|
+
CouponService,
|
|
3379
3427
|
HomeShopService,
|
|
3380
3428
|
OrderService,
|
|
3381
3429
|
WishlistService,
|
|
@@ -3436,7 +3484,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3436
3484
|
CouponRepositoriesFacade,
|
|
3437
3485
|
HomeShopRepositoriesFacade,
|
|
3438
3486
|
OrderProductReviewService,
|
|
3439
|
-
OrderRecurrenceService,
|
|
3440
3487
|
],
|
|
3441
3488
|
}]
|
|
3442
3489
|
}] });
|
|
@@ -3445,5 +3492,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.14", ngImpo
|
|
|
3445
3492
|
* Generated bundle index. Do not edit.
|
|
3446
3493
|
*/
|
|
3447
3494
|
|
|
3448
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CookieDataPersistence, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderProductReviewService,
|
|
3495
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderProductReviewService, OrderService, ProductSorts, UtilHelper, WishlistService };
|
|
3449
3496
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|