@infrab4a/connect-angular 3.3.3-beta.2 → 3.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 i2 from '@infrab4a/connect';
9
- import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, Status, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Order, Category, Product, RequiredArgumentError, add, 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';
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$1 from '@angular/fire/firestore';
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: i2.Shops, decorators: [{
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: i2.Shops, decorators: [{
391
+ }] }, { type: i1$1.Shops, decorators: [{
389
392
  type: Inject,
390
393
  args: [DEFAULT_SHOP]
391
394
  }] }]; } });
@@ -433,8 +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 pricePaid', pricePaid);
437
- console.log('checkout buildLineItem', checkout);
438
439
  return {
439
440
  checkout,
440
441
  lineItem: LineItem.toInstance({
@@ -461,8 +462,7 @@ class CartService {
461
462
  const info = product.price;
462
463
  if (product.isGift)
463
464
  return 0;
464
- console.log('getProductPrice', isSubscriber, info.subscriberPrice, info.price, (isSubscriber && info.subscriberPrice > 0));
465
- return (isSubscriber && info.subscriberPrice > 0) ? info.subscriberPrice : info.price;
465
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
466
466
  };
467
467
  this.checkMaxStock = (item, quantity) => {
468
468
  var _a;
@@ -521,7 +521,7 @@ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12
521
521
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
522
522
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
523
523
  type: Injectable
524
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
524
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
525
525
  type: Inject,
526
526
  args: [DEFAULT_SHOP]
527
527
  }] }, { type: undefined, decorators: [{
@@ -571,55 +571,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
571
571
  args: ['SubscriptionRepository']
572
572
  }] }, { type: CouponService }]; } });
573
573
 
574
- class OrderService {
575
- constructor(angularFirestore, orderRepository) {
576
- this.angularFirestore = angularFirestore;
577
- this.orderRepository = orderRepository;
578
- this.orderSubject = new Subject();
579
- }
580
- getOrder(id) {
581
- this.angularFirestore
582
- .doc(`${this.orderRepository.collectionName}/${id}`)
583
- .valueChanges()
584
- .pipe(map((doc) => Order.toInstance(doc)))
585
- .subscribe((doc) => this.orderSubject.next(doc));
586
- return this.orderSubject;
587
- }
588
- }
589
- 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 });
590
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
591
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
592
- type: Injectable
593
- }], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i2.OrderFirestoreRepository, decorators: [{
594
- type: Inject,
595
- args: ['OrderRepository']
596
- }] }]; } });
597
-
598
574
  class HomeShopService {
599
575
  constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
600
576
  this.categoryRepository = categoryRepository;
601
577
  this.homeRepository = homeRepository;
602
578
  this.productRepository = productRepository;
603
579
  this.defaultShop = defaultShop;
604
- this.buildCategoryGroupWithRequiredData = (group) => ({
605
- category: Category.toInstance(pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
606
- products: group.products.map((product) => Product.toInstance(pick(product.toPlain(), [
607
- 'id',
608
- 'price',
609
- 'reviews',
610
- 'hasVariants',
611
- 'slug',
612
- 'sku',
613
- 'stock',
614
- 'costPrice',
615
- 'images',
616
- 'miniatures',
617
- 'name',
618
- 'weight',
619
- 'rate',
620
- 'type'
621
- ]))),
622
- });
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
+ };
623
602
  }
624
603
  get homeId() {
625
604
  if (this.defaultShop === Shops.GLAMSHOP)
@@ -650,7 +629,7 @@ class HomeShopService {
650
629
  }));
651
630
  }
652
631
  getMinValueForFreeShipping() {
653
- return this.getHomeConfiguration().pipe(map(home => home.minValueForFreeShipping));
632
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
654
633
  }
655
634
  getDiscoverProducts() {
656
635
  return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
@@ -696,11 +675,79 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
696
675
  }] }, { type: undefined, decorators: [{
697
676
  type: Inject,
698
677
  args: ['ProductRepository']
699
- }] }, { type: i2.Shops, decorators: [{
678
+ }] }, { type: i1$1.Shops, decorators: [{
700
679
  type: Inject,
701
680
  args: [DEFAULT_SHOP]
702
681
  }] }]; } });
703
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
+
704
751
  class AngularFirebaseAuthModule {
705
752
  static initializeApp(options, nameOrConfig) {
706
753
  return {
@@ -1284,6 +1331,7 @@ class AngularConnectModule {
1284
1331
  ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1285
1332
  ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1286
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 }]),
1287
1335
  ],
1288
1336
  };
1289
1337
  }
@@ -1298,6 +1346,7 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
1298
1346
  CouponService,
1299
1347
  HomeShopService,
1300
1348
  OrderService,
1349
+ ShippingService
1301
1350
  ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1302
1351
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1303
1352
  type: NgModule,
@@ -1311,6 +1360,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1311
1360
  CouponService,
1312
1361
  HomeShopService,
1313
1362
  OrderService,
1363
+ ShippingService
1314
1364
  ],
1315
1365
  }]
1316
1366
  }] });
@@ -1319,5 +1369,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1319
1369
  * Generated bundle index. Do not edit.
1320
1370
  */
1321
1371
 
1322
- 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 };
1323
1373
  //# sourceMappingURL=infrab4a-connect-angular.js.map