@infrab4a/connect-angular 3.3.3-beta.1 → 3.4.0-beta.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 +1 -0
- package/bundles/infrab4a-connect-angular.umd.js +290 -238
- package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
- package/consts/api-url.const.d.ts +1 -0
- package/consts/index.d.ts +1 -0
- package/esm2015/angular-connect.module.js +7 -4
- package/esm2015/consts/api-url.const.js +2 -0
- package/esm2015/consts/index.js +2 -1
- package/esm2015/services/cart.service.js +2 -4
- package/esm2015/services/home-shop.service.js +25 -22
- package/esm2015/services/index.js +4 -3
- package/esm2015/services/shipping.service.js +50 -0
- package/esm2015/services/types/shipping-methods.type.js +2 -0
- package/fesm2015/infrab4a-connect-angular.js +106 -55
- package/fesm2015/infrab4a-connect-angular.js.map +1 -1
- package/package.json +2 -2
- package/services/index.d.ts +3 -2
- package/services/shipping.service.d.ts +9 -0
- package/services/types/shipping-methods.type.d.ts +12 -0
|
@@ -5,12 +5,13 @@ import { AngularFireAuth } from '@angular/fire/auth';
|
|
|
5
5
|
import { of, combineLatest, from, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
6
6
|
import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
|
|
7
7
|
import { __awaiter } from 'tslib';
|
|
8
|
-
import * as
|
|
9
|
-
import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, Status, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription,
|
|
8
|
+
import * as i1$1 from '@infrab4a/connect';
|
|
9
|
+
import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, Status, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Category, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, VariantHasuraGraphQLRepository } from '@infrab4a/connect';
|
|
10
10
|
import cookie from 'js-cookie';
|
|
11
11
|
import { CustomError } from 'ts-custom-error';
|
|
12
|
-
import * as i1$
|
|
12
|
+
import * as i1$2 from '@angular/fire/firestore';
|
|
13
13
|
import { AngularFirestore } from '@angular/fire/firestore';
|
|
14
|
+
import * as i1$3 from '@angular/common/http';
|
|
14
15
|
import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
|
|
15
16
|
|
|
16
17
|
class AuthService {
|
|
@@ -49,6 +50,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
49
50
|
args: ['UserRepository']
|
|
50
51
|
}] }]; } });
|
|
51
52
|
|
|
53
|
+
const API_URL = 'API_URL';
|
|
54
|
+
|
|
52
55
|
const DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
53
56
|
|
|
54
57
|
const ES_CONFIG = 'ES_CONFIG';
|
|
@@ -312,7 +315,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
312
315
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
313
316
|
type: Inject,
|
|
314
317
|
args: ['CouponRepository']
|
|
315
|
-
}] }, { type:
|
|
318
|
+
}] }, { type: i1$1.Shops, decorators: [{
|
|
316
319
|
type: Inject,
|
|
317
320
|
args: [DEFAULT_SHOP]
|
|
318
321
|
}] }, { type: undefined, decorators: [{
|
|
@@ -385,7 +388,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
385
388
|
}] }, { type: undefined, decorators: [{
|
|
386
389
|
type: Inject,
|
|
387
390
|
args: ['UserRepository']
|
|
388
|
-
}] }, { type:
|
|
391
|
+
}] }, { type: i1$1.Shops, decorators: [{
|
|
389
392
|
type: Inject,
|
|
390
393
|
args: [DEFAULT_SHOP]
|
|
391
394
|
}] }]; } });
|
|
@@ -433,7 +436,6 @@ class CartService {
|
|
|
433
436
|
shop: checkout.shop || this.defaultShop,
|
|
434
437
|
isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
|
|
435
438
|
});
|
|
436
|
-
console.log('checkout buildLineItem', checkout);
|
|
437
439
|
return {
|
|
438
440
|
checkout,
|
|
439
441
|
lineItem: LineItem.toInstance({
|
|
@@ -460,8 +462,7 @@ class CartService {
|
|
|
460
462
|
const info = product.price;
|
|
461
463
|
if (product.isGift)
|
|
462
464
|
return 0;
|
|
463
|
-
|
|
464
|
-
return (isSubscriber && info.subscriberPrice > 0) ? info.subscriberPrice : info.price;
|
|
465
|
+
return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
|
|
465
466
|
};
|
|
466
467
|
this.checkMaxStock = (item, quantity) => {
|
|
467
468
|
var _a;
|
|
@@ -520,7 +521,7 @@ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12
|
|
|
520
521
|
CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
|
|
521
522
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
|
|
522
523
|
type: Injectable
|
|
523
|
-
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type:
|
|
524
|
+
}], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
|
|
524
525
|
type: Inject,
|
|
525
526
|
args: [DEFAULT_SHOP]
|
|
526
527
|
}] }, { type: undefined, decorators: [{
|
|
@@ -570,55 +571,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
570
571
|
args: ['SubscriptionRepository']
|
|
571
572
|
}] }, { type: CouponService }]; } });
|
|
572
573
|
|
|
573
|
-
class OrderService {
|
|
574
|
-
constructor(angularFirestore, orderRepository) {
|
|
575
|
-
this.angularFirestore = angularFirestore;
|
|
576
|
-
this.orderRepository = orderRepository;
|
|
577
|
-
this.orderSubject = new Subject();
|
|
578
|
-
}
|
|
579
|
-
getOrder(id) {
|
|
580
|
-
this.angularFirestore
|
|
581
|
-
.doc(`${this.orderRepository.collectionName}/${id}`)
|
|
582
|
-
.valueChanges()
|
|
583
|
-
.pipe(map((doc) => Order.toInstance(doc)))
|
|
584
|
-
.subscribe((doc) => this.orderSubject.next(doc));
|
|
585
|
-
return this.orderSubject;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
589
|
-
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
|
|
590
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
|
|
591
|
-
type: Injectable
|
|
592
|
-
}], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i2.OrderFirestoreRepository, decorators: [{
|
|
593
|
-
type: Inject,
|
|
594
|
-
args: ['OrderRepository']
|
|
595
|
-
}] }]; } });
|
|
596
|
-
|
|
597
574
|
class HomeShopService {
|
|
598
575
|
constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
|
|
599
576
|
this.categoryRepository = categoryRepository;
|
|
600
577
|
this.homeRepository = homeRepository;
|
|
601
578
|
this.productRepository = productRepository;
|
|
602
579
|
this.defaultShop = defaultShop;
|
|
603
|
-
this.buildCategoryGroupWithRequiredData = (group) =>
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
'id',
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
580
|
+
this.buildCategoryGroupWithRequiredData = (group) => {
|
|
581
|
+
var _a, _b;
|
|
582
|
+
return ({
|
|
583
|
+
category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
|
|
584
|
+
products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
|
|
585
|
+
'id',
|
|
586
|
+
'price',
|
|
587
|
+
'reviews',
|
|
588
|
+
'hasVariants',
|
|
589
|
+
'slug',
|
|
590
|
+
'sku',
|
|
591
|
+
'stock',
|
|
592
|
+
'costPrice',
|
|
593
|
+
'images',
|
|
594
|
+
'miniatures',
|
|
595
|
+
'name',
|
|
596
|
+
'weight',
|
|
597
|
+
'rate',
|
|
598
|
+
'type',
|
|
599
|
+
])))) || [],
|
|
600
|
+
});
|
|
601
|
+
};
|
|
622
602
|
}
|
|
623
603
|
get homeId() {
|
|
624
604
|
if (this.defaultShop === Shops.GLAMSHOP)
|
|
@@ -649,7 +629,7 @@ class HomeShopService {
|
|
|
649
629
|
}));
|
|
650
630
|
}
|
|
651
631
|
getMinValueForFreeShipping() {
|
|
652
|
-
return this.getHomeConfiguration().pipe(map(home => home.minValueForFreeShipping));
|
|
632
|
+
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
653
633
|
}
|
|
654
634
|
getDiscoverProducts() {
|
|
655
635
|
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
@@ -695,11 +675,79 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
695
675
|
}] }, { type: undefined, decorators: [{
|
|
696
676
|
type: Inject,
|
|
697
677
|
args: ['ProductRepository']
|
|
698
|
-
}] }, { type:
|
|
678
|
+
}] }, { type: i1$1.Shops, decorators: [{
|
|
699
679
|
type: Inject,
|
|
700
680
|
args: [DEFAULT_SHOP]
|
|
701
681
|
}] }]; } });
|
|
702
682
|
|
|
683
|
+
class OrderService {
|
|
684
|
+
constructor(angularFirestore, orderRepository) {
|
|
685
|
+
this.angularFirestore = angularFirestore;
|
|
686
|
+
this.orderRepository = orderRepository;
|
|
687
|
+
this.orderSubject = new Subject();
|
|
688
|
+
}
|
|
689
|
+
getOrder(id) {
|
|
690
|
+
this.angularFirestore
|
|
691
|
+
.doc(`${this.orderRepository.collectionName}/${id}`)
|
|
692
|
+
.valueChanges()
|
|
693
|
+
.pipe(map((doc) => Order.toInstance(doc)))
|
|
694
|
+
.subscribe((doc) => this.orderSubject.next(doc));
|
|
695
|
+
return this.orderSubject;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
699
|
+
OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
|
|
700
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
|
|
701
|
+
type: Injectable
|
|
702
|
+
}], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
|
|
703
|
+
type: Inject,
|
|
704
|
+
args: ['OrderRepository']
|
|
705
|
+
}] }]; } });
|
|
706
|
+
|
|
707
|
+
class ShippingService {
|
|
708
|
+
constructor(http) {
|
|
709
|
+
this.http = http;
|
|
710
|
+
}
|
|
711
|
+
getMensShippingMethods(zip, weightGrams, totalPrice, personId, subscriptionPlan) {
|
|
712
|
+
return this.http.get(`${API_URL}/open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`)
|
|
713
|
+
.pipe(map((data) => data.result), map((shippingMethods) => {
|
|
714
|
+
const shippingMethodsResponse = [];
|
|
715
|
+
if (!shippingMethods.length)
|
|
716
|
+
return [];
|
|
717
|
+
if (totalPrice >= 200) {
|
|
718
|
+
return shippingMethods.map(s => {
|
|
719
|
+
if (s.serviceName !== 'Same Day')
|
|
720
|
+
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
721
|
+
else
|
|
722
|
+
return s;
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
if (subscriptionPlan && subscriptionPlan == 'SELECT') {
|
|
726
|
+
return shippingMethods.map(s => {
|
|
727
|
+
if (s.serviceName !== 'Same Day')
|
|
728
|
+
return Object.assign(Object.assign({}, s), { totalPrice: 0 });
|
|
729
|
+
else
|
|
730
|
+
return s;
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
if (subscriptionPlan && subscriptionPlan == 'PRIME') {
|
|
734
|
+
return shippingMethods.map(s => {
|
|
735
|
+
if (s.serviceName !== 'Same Day')
|
|
736
|
+
return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
|
|
737
|
+
else
|
|
738
|
+
return s;
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
return shippingMethodsResponse;
|
|
742
|
+
}));
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
746
|
+
ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
|
|
747
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
|
|
748
|
+
type: Injectable
|
|
749
|
+
}], ctorParameters: function () { return [{ type: i1$3.HttpClient }]; } });
|
|
750
|
+
|
|
703
751
|
class AngularFirebaseAuthModule {
|
|
704
752
|
static initializeApp(options, nameOrConfig) {
|
|
705
753
|
return {
|
|
@@ -1283,6 +1331,7 @@ class AngularConnectModule {
|
|
|
1283
1331
|
...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
1284
1332
|
...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
1285
1333
|
...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
1334
|
+
...(isNil(options === null || options === void 0 ? void 0 : options.apiUrl) ? [] : [{ provide: API_URL, useValue: options.apiUrl }]),
|
|
1286
1335
|
],
|
|
1287
1336
|
};
|
|
1288
1337
|
}
|
|
@@ -1297,6 +1346,7 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
|
|
|
1297
1346
|
CouponService,
|
|
1298
1347
|
HomeShopService,
|
|
1299
1348
|
OrderService,
|
|
1349
|
+
ShippingService
|
|
1300
1350
|
], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
|
|
1301
1351
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
|
|
1302
1352
|
type: NgModule,
|
|
@@ -1310,6 +1360,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1310
1360
|
CouponService,
|
|
1311
1361
|
HomeShopService,
|
|
1312
1362
|
OrderService,
|
|
1363
|
+
ShippingService
|
|
1313
1364
|
],
|
|
1314
1365
|
}]
|
|
1315
1366
|
}] });
|
|
@@ -1318,5 +1369,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
|
|
|
1318
1369
|
* Generated bundle index. Do not edit.
|
|
1319
1370
|
*/
|
|
1320
1371
|
|
|
1321
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService };
|
|
1372
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ShippingService };
|
|
1322
1373
|
//# sourceMappingURL=infrab4a-connect-angular.js.map
|