@infrab4a/connect-angular 5.0.0-beta.19 → 5.0.0-beta.2
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 -3
- package/consts/index.d.ts +0 -1
- package/esm2022/angular-connect.module.mjs +2 -4
- package/esm2022/angular-firestore.module.mjs +13 -15
- package/esm2022/angular-hasura-graphql.module.mjs +2 -24
- package/esm2022/consts/index.mjs +1 -2
- package/esm2022/index.mjs +1 -2
- package/esm2022/services/cart.service.mjs +2 -3
- package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +4 -6
- package/esm2022/services/catalog/catalog.service.mjs +12 -39
- package/esm2022/services/catalog/category.service.mjs +4 -4
- package/esm2022/services/catalog/wishlist.service.mjs +11 -14
- package/esm2022/services/checkout-subscription.service.mjs +21 -18
- package/esm2022/services/checkout.service.mjs +16 -13
- package/esm2022/services/coupon.service.mjs +10 -35
- package/fesm2022/infrab4a-connect-angular.mjs +87 -185
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/index.d.ts +0 -1
- package/package.json +3 -3
- package/services/catalog/catalog.service.d.ts +4 -9
- package/services/catalog/category.service.d.ts +1 -6
- package/services/catalog/wishlist.service.d.ts +5 -6
- package/services/checkout-subscription.service.d.ts +4 -5
- package/services/checkout.service.d.ts +4 -8
- package/services/coupon.service.d.ts +2 -6
- package/consts/persistence.const.d.ts +0 -1
- package/esm2022/consts/persistence.const.mjs +0 -2
- package/esm2022/persistence/cookie-data-persistence.mjs +0 -22
- package/esm2022/persistence/data-persistence.mjs +0 -2
- package/esm2022/persistence/index.mjs +0 -3
- package/persistence/cookie-data-persistence.d.ts +0 -10
- package/persistence/data-persistence.d.ts +0 -6
- package/persistence/index.d.ts +0 -2
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angular/core';
|
|
3
3
|
import * as i1$4 from '@angular/fire/app';
|
|
4
|
-
import { FirebaseApp,
|
|
4
|
+
import { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';
|
|
5
5
|
import * as i1$2 from '@infrab4a/connect';
|
|
6
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword,
|
|
6
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, FirebaseFileUploaderService, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage } from '@infrab4a/connect';
|
|
7
7
|
import * as i1 from '@angular/fire/auth';
|
|
8
|
-
import { Auth,
|
|
8
|
+
import { Auth, getAuth, provideAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
9
9
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
10
10
|
import * as i1$1 from '@angular/fire/firestore';
|
|
11
|
-
import { Firestore,
|
|
11
|
+
import { Firestore, getFirestore, memoryLocalCache, initializeFirestore, provideFirestore, doc, docSnapshots } from '@angular/fire/firestore';
|
|
12
12
|
import * as i2 from '@angular/fire/storage';
|
|
13
|
-
import { Storage,
|
|
13
|
+
import { Storage, getStorage, provideStorage } from '@angular/fire/storage';
|
|
14
|
+
import { combineLatest, of, from, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
15
|
+
import { map, catchError, mergeMap, concatMap, tap } from 'rxjs/operators';
|
|
14
16
|
import cookie from 'js-cookie';
|
|
15
|
-
import {
|
|
16
|
-
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
17
|
-
import { __decorate, __metadata } from 'tslib';
|
|
17
|
+
import { __metadata, __decorate } from 'tslib';
|
|
18
18
|
import { Type } from 'class-transformer';
|
|
19
19
|
import * as i1$3 from '@angular/common/http';
|
|
20
20
|
|
|
@@ -61,8 +61,6 @@ const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
|
|
|
61
61
|
|
|
62
62
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
63
63
|
|
|
64
|
-
const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
|
|
65
|
-
|
|
66
64
|
class AngularFirebaseAuthModule {
|
|
67
65
|
static initializeApp(options, nameOrConfig) {
|
|
68
66
|
return {
|
|
@@ -197,7 +195,7 @@ class AngularFirestoreModule {
|
|
|
197
195
|
{
|
|
198
196
|
provide: 'FirestoreOptions',
|
|
199
197
|
useFactory: (firestore, platformId) => ({
|
|
200
|
-
firestore
|
|
198
|
+
firestore,
|
|
201
199
|
interceptors: {
|
|
202
200
|
request: (request) => {
|
|
203
201
|
if (isPlatformBrowser(platformId))
|
|
@@ -415,13 +413,12 @@ class AngularFirestoreModule {
|
|
|
415
413
|
], imports: [AngularElasticSeachModule,
|
|
416
414
|
provideFirestore((injector) => {
|
|
417
415
|
const platformId = injector.get(PLATFORM_ID);
|
|
418
|
-
if (isPlatformServer(platformId)
|
|
419
|
-
return
|
|
420
|
-
|
|
421
|
-
|
|
416
|
+
if (isPlatformServer(platformId))
|
|
417
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
418
|
+
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
419
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
422
420
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
423
421
|
experimentalForceLongPolling: true,
|
|
424
|
-
ignoreUndefinedProperties: true,
|
|
425
422
|
localCache: memoryLocalCache(),
|
|
426
423
|
});
|
|
427
424
|
return firestore;
|
|
@@ -435,13 +432,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
435
432
|
AngularElasticSeachModule,
|
|
436
433
|
provideFirestore((injector) => {
|
|
437
434
|
const platformId = injector.get(PLATFORM_ID);
|
|
438
|
-
if (isPlatformServer(platformId)
|
|
439
|
-
return
|
|
440
|
-
|
|
441
|
-
|
|
435
|
+
if (isPlatformServer(platformId))
|
|
436
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
437
|
+
if (!MobileOperationSystemCheckerHelper.isAppleDevice())
|
|
438
|
+
return getFirestore(injector.get(FirebaseApp));
|
|
442
439
|
const firestore = initializeFirestore(injector.get(FirebaseApp), {
|
|
443
440
|
experimentalForceLongPolling: true,
|
|
444
|
-
ignoreUndefinedProperties: true,
|
|
445
441
|
localCache: memoryLocalCache(),
|
|
446
442
|
});
|
|
447
443
|
return firestore;
|
|
@@ -452,7 +448,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
452
448
|
{
|
|
453
449
|
provide: 'FirestoreOptions',
|
|
454
450
|
useFactory: (firestore, platformId) => ({
|
|
455
|
-
firestore
|
|
451
|
+
firestore,
|
|
456
452
|
interceptors: {
|
|
457
453
|
request: (request) => {
|
|
458
454
|
if (isPlatformBrowser(platformId))
|
|
@@ -748,17 +744,6 @@ class AngularHasuraGraphQLModule {
|
|
|
748
744
|
},
|
|
749
745
|
deps: ['HasuraConfig'],
|
|
750
746
|
},
|
|
751
|
-
{
|
|
752
|
-
provide: 'ProductStockNotificationRepository',
|
|
753
|
-
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
757
|
-
useFactory: (hasuraConfig) => {
|
|
758
|
-
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
759
|
-
},
|
|
760
|
-
deps: ['HasuraConfig'],
|
|
761
|
-
},
|
|
762
747
|
{
|
|
763
748
|
provide: 'CategoryFilterRepository',
|
|
764
749
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -885,17 +870,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
885
870
|
},
|
|
886
871
|
deps: ['HasuraConfig'],
|
|
887
872
|
},
|
|
888
|
-
{
|
|
889
|
-
provide: 'ProductStockNotificationRepository',
|
|
890
|
-
useExisting: ProductStockNotificationHasuraGraphQLRepository,
|
|
891
|
-
},
|
|
892
|
-
{
|
|
893
|
-
provide: ProductStockNotificationHasuraGraphQLRepository,
|
|
894
|
-
useFactory: (hasuraConfig) => {
|
|
895
|
-
return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
|
|
896
|
-
},
|
|
897
|
-
deps: ['HasuraConfig'],
|
|
898
|
-
},
|
|
899
873
|
{
|
|
900
874
|
provide: 'CategoryFilterRepository',
|
|
901
875
|
useExisting: CategoryFilterHasuraGraphQLRepository,
|
|
@@ -953,23 +927,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
953
927
|
}]
|
|
954
928
|
}] });
|
|
955
929
|
|
|
956
|
-
class CookieDataPersistence {
|
|
957
|
-
get(key) {
|
|
958
|
-
return of(cookie.get(key));
|
|
959
|
-
}
|
|
960
|
-
remove(key) {
|
|
961
|
-
return of(cookie.remove(key));
|
|
962
|
-
}
|
|
963
|
-
set(key, value) {
|
|
964
|
-
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
965
|
-
}
|
|
966
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
967
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence }); }
|
|
968
|
-
}
|
|
969
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
970
|
-
type: Injectable
|
|
971
|
-
}] });
|
|
972
|
-
|
|
973
930
|
class AuthService {
|
|
974
931
|
constructor(angularFireAuth, userRepository) {
|
|
975
932
|
this.angularFireAuth = angularFireAuth;
|
|
@@ -1076,33 +1033,32 @@ class CouponService {
|
|
|
1076
1033
|
return of(discount);
|
|
1077
1034
|
}
|
|
1078
1035
|
async calcDiscountShopping(coupon, checkout) {
|
|
1079
|
-
let
|
|
1036
|
+
let discount = 0;
|
|
1080
1037
|
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1081
|
-
|
|
1038
|
+
discount = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1082
1039
|
}
|
|
1083
1040
|
else {
|
|
1084
|
-
|
|
1041
|
+
discount = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1085
1042
|
}
|
|
1086
|
-
return
|
|
1043
|
+
return discount;
|
|
1087
1044
|
}
|
|
1088
1045
|
async calcDiscountByType(type, value, categories, checkout) {
|
|
1089
1046
|
let discount = 0;
|
|
1090
|
-
let
|
|
1091
|
-
const subTotal = this.calcCheckoutSubtotal(
|
|
1047
|
+
let lineItensDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1048
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1092
1049
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1093
1050
|
discount = value > subTotal ? subTotal : value;
|
|
1094
1051
|
}
|
|
1095
1052
|
else {
|
|
1096
1053
|
discount = subTotal * (value / 100);
|
|
1097
1054
|
}
|
|
1098
|
-
|
|
1099
|
-
return { discount, lineItems };
|
|
1055
|
+
return discount;
|
|
1100
1056
|
}
|
|
1101
1057
|
async hasMinSubTotal(coupon, checkout) {
|
|
1102
1058
|
if (!coupon.minSubTotalValue)
|
|
1103
1059
|
return true;
|
|
1104
1060
|
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1105
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1061
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1106
1062
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1107
1063
|
return true;
|
|
1108
1064
|
return false;
|
|
@@ -1170,7 +1126,7 @@ class CouponService {
|
|
|
1170
1126
|
}
|
|
1171
1127
|
return lineItensDiscount;
|
|
1172
1128
|
}
|
|
1173
|
-
calcCheckoutSubtotal(lineItens, user) {
|
|
1129
|
+
calcCheckoutSubtotal(lineItens, user, shop) {
|
|
1174
1130
|
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1175
1131
|
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1176
1132
|
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
@@ -1208,30 +1164,6 @@ class CouponService {
|
|
|
1208
1164
|
}
|
|
1209
1165
|
return couponUseLimits;
|
|
1210
1166
|
}
|
|
1211
|
-
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1212
|
-
let lineItemsDiscount = [];
|
|
1213
|
-
if (type === CouponTypes.ABSOLUTE) {
|
|
1214
|
-
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1215
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1216
|
-
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1217
|
-
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1218
|
-
return {
|
|
1219
|
-
...item,
|
|
1220
|
-
discount: Number(discountItem.toFixed(2)),
|
|
1221
|
-
};
|
|
1222
|
-
});
|
|
1223
|
-
}
|
|
1224
|
-
else {
|
|
1225
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1226
|
-
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1227
|
-
return {
|
|
1228
|
-
...item,
|
|
1229
|
-
discount: Number(discountItem.toFixed(2)),
|
|
1230
|
-
};
|
|
1231
|
-
});
|
|
1232
|
-
}
|
|
1233
|
-
return lineItemsDiscount;
|
|
1234
|
-
}
|
|
1235
1167
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1236
1168
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
1237
1169
|
}
|
|
@@ -1255,17 +1187,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1255
1187
|
}] }] });
|
|
1256
1188
|
|
|
1257
1189
|
class CheckoutService {
|
|
1258
|
-
constructor(couponService, checkoutRepository, userRepository, defaultShop
|
|
1190
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
1259
1191
|
this.couponService = couponService;
|
|
1260
1192
|
this.checkoutRepository = checkoutRepository;
|
|
1193
|
+
this.orderRepository = orderRepository;
|
|
1261
1194
|
this.userRepository = userRepository;
|
|
1262
1195
|
this.defaultShop = defaultShop;
|
|
1263
|
-
this.dataPersistence = dataPersistence;
|
|
1264
1196
|
}
|
|
1265
1197
|
getCheckout(checkoutData) {
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1198
|
+
const checkoutId = cookie.get('checkoutId');
|
|
1199
|
+
if (!isNil(checkoutId))
|
|
1200
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
1201
|
+
return from(this.createCheckout(checkoutData));
|
|
1269
1202
|
}
|
|
1270
1203
|
getUserByCheckout(checkoutId) {
|
|
1271
1204
|
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
@@ -1277,7 +1210,8 @@ class CheckoutService {
|
|
|
1277
1210
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1278
1211
|
}
|
|
1279
1212
|
clearCheckoutFromSession() {
|
|
1280
|
-
|
|
1213
|
+
cookie.remove('checkoutId');
|
|
1214
|
+
return of();
|
|
1281
1215
|
}
|
|
1282
1216
|
calcDiscount(coupon) {
|
|
1283
1217
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1291,10 +1225,10 @@ class CheckoutService {
|
|
|
1291
1225
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1292
1226
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1293
1227
|
});
|
|
1294
|
-
|
|
1228
|
+
cookie.set('checkoutId', checkout.id);
|
|
1295
1229
|
return checkout;
|
|
1296
1230
|
}
|
|
1297
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: '
|
|
1231
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1298
1232
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
|
|
1299
1233
|
}
|
|
1300
1234
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
|
|
@@ -1302,15 +1236,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1302
1236
|
}], ctorParameters: () => [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1303
1237
|
type: Inject,
|
|
1304
1238
|
args: ['CheckoutRepository']
|
|
1239
|
+
}] }, { type: undefined, decorators: [{
|
|
1240
|
+
type: Inject,
|
|
1241
|
+
args: ['OrderRepository']
|
|
1305
1242
|
}] }, { type: undefined, decorators: [{
|
|
1306
1243
|
type: Inject,
|
|
1307
1244
|
args: ['UserRepository']
|
|
1308
1245
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1309
1246
|
type: Inject,
|
|
1310
1247
|
args: [DEFAULT_SHOP]
|
|
1311
|
-
}] }, { type: undefined, decorators: [{
|
|
1312
|
-
type: Inject,
|
|
1313
|
-
args: [PERSISTENCE_PROVIDER]
|
|
1314
1248
|
}] }] });
|
|
1315
1249
|
|
|
1316
1250
|
class CartService {
|
|
@@ -1372,7 +1306,6 @@ class CartService {
|
|
|
1372
1306
|
weight: weight ?? product.weight,
|
|
1373
1307
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1374
1308
|
pricePaid,
|
|
1375
|
-
discount: 0,
|
|
1376
1309
|
categories: product.categories ?? [],
|
|
1377
1310
|
isGift: isGift ?? null,
|
|
1378
1311
|
costPrice: product.costPrice ?? 0,
|
|
@@ -1424,7 +1357,7 @@ class CartService {
|
|
|
1424
1357
|
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1425
1358
|
}
|
|
1426
1359
|
updateUserCart(user) {
|
|
1427
|
-
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) =>
|
|
1360
|
+
return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => this.checkoutService
|
|
1428
1361
|
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1429
1362
|
...checkout.toPlain(),
|
|
1430
1363
|
lineItems: checkout.lineItems?.length
|
|
@@ -1608,11 +1541,9 @@ class NewCategoryStructureAdapter {
|
|
|
1608
1541
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1609
1542
|
}
|
|
1610
1543
|
async getCategory(category) {
|
|
1611
|
-
|
|
1612
|
-
(
|
|
1613
|
-
category
|
|
1614
|
-
category.brandCategory;
|
|
1615
|
-
return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
|
|
1544
|
+
return isNil(category.isCollection) || (category.isCollection && !category.products?.length)
|
|
1545
|
+
? this.categoryRepository.get({ id: category.id })
|
|
1546
|
+
: category;
|
|
1616
1547
|
}
|
|
1617
1548
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1618
1549
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
|
|
@@ -1645,10 +1576,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1645
1576
|
}] }] });
|
|
1646
1577
|
|
|
1647
1578
|
class CatalogService {
|
|
1648
|
-
constructor(productRepository,
|
|
1579
|
+
constructor(productRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1649
1580
|
this.productRepository = productRepository;
|
|
1650
|
-
this.productStockNotificationRepository = productStockNotificationRepository;
|
|
1651
|
-
this.categoryRepository = categoryRepository;
|
|
1652
1581
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1653
1582
|
this.shop = shop;
|
|
1654
1583
|
this.productIndex = productIndex;
|
|
@@ -1678,22 +1607,17 @@ class CatalogService {
|
|
|
1678
1607
|
if (!sort || sort === 'most-relevant')
|
|
1679
1608
|
return {};
|
|
1680
1609
|
if (sort === 'best-sellers')
|
|
1681
|
-
return {
|
|
1682
|
-
shoppingCount: 'desc',
|
|
1683
|
-
rate: 'desc',
|
|
1684
|
-
stock: 'desc',
|
|
1685
|
-
name: 'asc',
|
|
1686
|
-
};
|
|
1610
|
+
return { shoppingCount: 'desc' };
|
|
1687
1611
|
if (sort === 'biggest-price')
|
|
1688
|
-
return { subscriberPrice: 'desc'
|
|
1612
|
+
return { subscriberPrice: 'desc' };
|
|
1689
1613
|
if (sort === 'lowest-price')
|
|
1690
|
-
return { subscriberPrice: 'asc'
|
|
1614
|
+
return { subscriberPrice: 'asc' };
|
|
1691
1615
|
if (sort === 'best-rating')
|
|
1692
|
-
return { rate: 'desc'
|
|
1616
|
+
return { rate: 'desc' };
|
|
1693
1617
|
if (sort === 'news')
|
|
1694
1618
|
return { createdAt: 'desc' };
|
|
1695
1619
|
if (sort === 'biggest-discount')
|
|
1696
|
-
return { subscriberDiscountPercentage: 'desc'
|
|
1620
|
+
return { subscriberDiscountPercentage: 'desc' };
|
|
1697
1621
|
};
|
|
1698
1622
|
this.buildLimitQuery = (options) => {
|
|
1699
1623
|
const limit = options?.perPage || 20;
|
|
@@ -1727,24 +1651,9 @@ class CatalogService {
|
|
|
1727
1651
|
brands: distinct?.brand,
|
|
1728
1652
|
}));
|
|
1729
1653
|
}
|
|
1730
|
-
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1731
|
-
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1732
|
-
}
|
|
1733
1654
|
async findCatalog(options, limits) {
|
|
1734
|
-
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1735
|
-
|
|
1736
|
-
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1737
|
-
}
|
|
1738
|
-
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1739
|
-
const productsIds = await this.productRepository
|
|
1740
|
-
.find({
|
|
1741
|
-
filters: {
|
|
1742
|
-
...(await this.buildMainFilter(options)),
|
|
1743
|
-
},
|
|
1744
|
-
})
|
|
1745
|
-
.then((products) => products.data.map((product) => product.id));
|
|
1746
|
-
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1747
|
-
}
|
|
1655
|
+
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1656
|
+
return this.findCatalogByTermAndSortByMostRevelant(options, limits);
|
|
1748
1657
|
const repoParams = {
|
|
1749
1658
|
filters: {
|
|
1750
1659
|
...(await this.buildMainFilter(options)),
|
|
@@ -1772,7 +1681,8 @@ class CatalogService {
|
|
|
1772
1681
|
.search(term, 999, this.shop)
|
|
1773
1682
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1774
1683
|
}
|
|
1775
|
-
async
|
|
1684
|
+
async findCatalogByTermAndSortByMostRevelant(options, limits) {
|
|
1685
|
+
const productIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1776
1686
|
const totalResult = await this.productRepository.findCatalog({
|
|
1777
1687
|
fields: ['id', 'stock'],
|
|
1778
1688
|
filters: {
|
|
@@ -1818,7 +1728,7 @@ class CatalogService {
|
|
|
1818
1728
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1819
1729
|
}));
|
|
1820
1730
|
}
|
|
1821
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token:
|
|
1731
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1822
1732
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1823
1733
|
}
|
|
1824
1734
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1826,12 +1736,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1826
1736
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1827
1737
|
type: Inject,
|
|
1828
1738
|
args: ['ProductRepository']
|
|
1829
|
-
}] }, { type: undefined, decorators: [{
|
|
1830
|
-
type: Inject,
|
|
1831
|
-
args: ['ProductStockNotificationRepository']
|
|
1832
|
-
}] }, { type: undefined, decorators: [{
|
|
1833
|
-
type: Inject,
|
|
1834
|
-
args: ['CategoryRepository']
|
|
1835
1739
|
}] }, { type: undefined, decorators: [{
|
|
1836
1740
|
type: Inject,
|
|
1837
1741
|
args: [CATEGORY_STRUCTURE]
|
|
@@ -1848,15 +1752,15 @@ class CategoryService {
|
|
|
1848
1752
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1849
1753
|
this.shop = shop;
|
|
1850
1754
|
}
|
|
1851
|
-
async fetchBrands(category,
|
|
1755
|
+
async fetchBrands(category, mainGender) {
|
|
1852
1756
|
const brands = await this.productRepository
|
|
1853
1757
|
.findCatalog({
|
|
1854
1758
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1855
1759
|
fields: ['brand'],
|
|
1856
|
-
},
|
|
1760
|
+
}, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1857
1761
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1858
1762
|
return this.categoryRepository
|
|
1859
|
-
.find({ filters: { brandCategory: true, shop:
|
|
1763
|
+
.find({ filters: { brandCategory: true, shop: this.shop }, orderBy: { name: 'asc' } })
|
|
1860
1764
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1861
1765
|
}
|
|
1862
1766
|
async fetchFilterOptions(category) {
|
|
@@ -1905,11 +1809,12 @@ __decorate([
|
|
|
1905
1809
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1906
1810
|
|
|
1907
1811
|
class WishlistService {
|
|
1908
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository,
|
|
1812
|
+
constructor(wishlistRepository, categoryRepository, shop, productRepository, categoryFilterRepository, productIndex) {
|
|
1909
1813
|
this.wishlistRepository = wishlistRepository;
|
|
1814
|
+
this.categoryRepository = categoryRepository;
|
|
1910
1815
|
this.shop = shop;
|
|
1911
1816
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1912
|
-
this.catalogService = new CatalogService(productRepository,
|
|
1817
|
+
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
|
|
1913
1818
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1914
1819
|
}
|
|
1915
1820
|
getCatalogService() {
|
|
@@ -1918,7 +1823,7 @@ class WishlistService {
|
|
|
1918
1823
|
getCategoryService() {
|
|
1919
1824
|
return this.categoryService;
|
|
1920
1825
|
}
|
|
1921
|
-
async create({ personId, title, description,
|
|
1826
|
+
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1922
1827
|
const data = {
|
|
1923
1828
|
slug: '',
|
|
1924
1829
|
name: title,
|
|
@@ -1933,7 +1838,7 @@ class WishlistService {
|
|
|
1933
1838
|
personName: userFullName,
|
|
1934
1839
|
personPhoto: userPhoto,
|
|
1935
1840
|
brandCategory: false,
|
|
1936
|
-
published,
|
|
1841
|
+
published: true,
|
|
1937
1842
|
theme,
|
|
1938
1843
|
bannerUrl,
|
|
1939
1844
|
};
|
|
@@ -1941,12 +1846,11 @@ class WishlistService {
|
|
|
1941
1846
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1942
1847
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1943
1848
|
}
|
|
1944
|
-
update({ id, title, description,
|
|
1849
|
+
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1945
1850
|
const data = {
|
|
1946
1851
|
id,
|
|
1947
1852
|
name: title,
|
|
1948
1853
|
description,
|
|
1949
|
-
published,
|
|
1950
1854
|
metadata: {
|
|
1951
1855
|
title: `${userFullName} - ${title}`,
|
|
1952
1856
|
description: `${userFullName} - ${description}`,
|
|
@@ -1990,7 +1894,7 @@ class WishlistService {
|
|
|
1990
1894
|
}
|
|
1991
1895
|
return wishlist;
|
|
1992
1896
|
}
|
|
1993
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token:
|
|
1897
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: 'CategoryRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1994
1898
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
1995
1899
|
}
|
|
1996
1900
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -1998,6 +1902,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1998
1902
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1999
1903
|
type: Inject,
|
|
2000
1904
|
args: ['WishlistRepository']
|
|
1905
|
+
}] }, { type: undefined, decorators: [{
|
|
1906
|
+
type: Inject,
|
|
1907
|
+
args: ['CategoryRepository']
|
|
2001
1908
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
2002
1909
|
type: Inject,
|
|
2003
1910
|
args: [DEFAULT_SHOP]
|
|
@@ -2007,27 +1914,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2007
1914
|
}] }, { type: undefined, decorators: [{
|
|
2008
1915
|
type: Inject,
|
|
2009
1916
|
args: ['CategoryFilterRepository']
|
|
2010
|
-
}] }, { type: undefined, decorators: [{
|
|
2011
|
-
type: Inject,
|
|
2012
|
-
args: ['CategoryRepository']
|
|
2013
|
-
}] }, { type: undefined, decorators: [{
|
|
2014
|
-
type: Inject,
|
|
2015
|
-
args: ['ProductStockNotificationRepository']
|
|
2016
1917
|
}] }, { type: i1$2.ProductsIndex }] });
|
|
2017
1918
|
|
|
2018
1919
|
class CheckoutSubscriptionService {
|
|
2019
|
-
constructor(checkoutSubscriptionRepository,
|
|
1920
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
2020
1921
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
2021
|
-
this.
|
|
1922
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
2022
1923
|
this.couponService = couponService;
|
|
2023
1924
|
}
|
|
2024
1925
|
getCheckoutSubscription(checkoutData) {
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
1926
|
+
const checkoutId = cookie.get('checkoutSubscriptionId');
|
|
1927
|
+
if (!isNil(checkoutId))
|
|
1928
|
+
return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
|
|
1929
|
+
return from(this.createCheckoutSubscription(checkoutData));
|
|
1930
|
+
}
|
|
1931
|
+
async createCheckoutSubscription(checkoutData) {
|
|
1932
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
1933
|
+
createdAt: new Date(),
|
|
1934
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1935
|
+
});
|
|
1936
|
+
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
1937
|
+
return checkout;
|
|
2028
1938
|
}
|
|
2029
1939
|
clearCheckoutSubscriptionFromSession() {
|
|
2030
|
-
|
|
1940
|
+
cookie.remove('checkoutSubscriptionId');
|
|
1941
|
+
return of();
|
|
2031
1942
|
}
|
|
2032
1943
|
checkCoupon(nickname, userEmail) {
|
|
2033
1944
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -2037,15 +1948,7 @@ class CheckoutSubscriptionService {
|
|
|
2037
1948
|
calcDiscountSubscription(coupon) {
|
|
2038
1949
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2039
1950
|
}
|
|
2040
|
-
|
|
2041
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2042
|
-
createdAt: new Date(),
|
|
2043
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2044
|
-
});
|
|
2045
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2046
|
-
return checkout;
|
|
2047
|
-
}
|
|
2048
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1951
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2049
1952
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
2050
1953
|
}
|
|
2051
1954
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
@@ -2055,7 +1958,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2055
1958
|
args: ['CheckoutSubscriptionRepository']
|
|
2056
1959
|
}] }, { type: undefined, decorators: [{
|
|
2057
1960
|
type: Inject,
|
|
2058
|
-
args: [
|
|
1961
|
+
args: ['SubscriptionRepository']
|
|
2059
1962
|
}] }, { type: CouponService }] });
|
|
2060
1963
|
|
|
2061
1964
|
class UtilHelper {
|
|
@@ -2313,7 +2216,6 @@ class AngularConnectModule {
|
|
|
2313
2216
|
? OldCategoryStructureAdapter
|
|
2314
2217
|
: NewCategoryStructureAdapter,
|
|
2315
2218
|
},
|
|
2316
|
-
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2317
2219
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2318
2220
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2319
2221
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2407,5 +2309,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2407
2309
|
* Generated bundle index. Do not edit.
|
|
2408
2310
|
*/
|
|
2409
2311
|
|
|
2410
|
-
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService,
|
|
2312
|
+
export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
|
|
2411
2313
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|