@infrab4a/connect-angular 5.0.0-beta.18 → 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/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 +13 -33
- package/esm2022/services/catalog/category.service.mjs +4 -4
- package/esm2022/services/catalog/wishlist.service.mjs +11 -11
- 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 -153
- 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 -7
- package/services/catalog/category.service.d.ts +1 -6
- package/services/catalog/wishlist.service.d.ts +4 -5
- 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))
|
|
@@ -931,23 +927,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
931
927
|
}]
|
|
932
928
|
}] });
|
|
933
929
|
|
|
934
|
-
class CookieDataPersistence {
|
|
935
|
-
get(key) {
|
|
936
|
-
return of(cookie.get(key));
|
|
937
|
-
}
|
|
938
|
-
remove(key) {
|
|
939
|
-
return of(cookie.remove(key));
|
|
940
|
-
}
|
|
941
|
-
set(key, value) {
|
|
942
|
-
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
943
|
-
}
|
|
944
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
945
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence }); }
|
|
946
|
-
}
|
|
947
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, decorators: [{
|
|
948
|
-
type: Injectable
|
|
949
|
-
}] });
|
|
950
|
-
|
|
951
930
|
class AuthService {
|
|
952
931
|
constructor(angularFireAuth, userRepository) {
|
|
953
932
|
this.angularFireAuth = angularFireAuth;
|
|
@@ -1054,33 +1033,32 @@ class CouponService {
|
|
|
1054
1033
|
return of(discount);
|
|
1055
1034
|
}
|
|
1056
1035
|
async calcDiscountShopping(coupon, checkout) {
|
|
1057
|
-
let
|
|
1036
|
+
let discount = 0;
|
|
1058
1037
|
if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
|
|
1059
|
-
|
|
1038
|
+
discount = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
|
|
1060
1039
|
}
|
|
1061
1040
|
else {
|
|
1062
|
-
|
|
1041
|
+
discount = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
|
|
1063
1042
|
}
|
|
1064
|
-
return
|
|
1043
|
+
return discount;
|
|
1065
1044
|
}
|
|
1066
1045
|
async calcDiscountByType(type, value, categories, checkout) {
|
|
1067
1046
|
let discount = 0;
|
|
1068
|
-
let
|
|
1069
|
-
const subTotal = this.calcCheckoutSubtotal(
|
|
1047
|
+
let lineItensDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1048
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1070
1049
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1071
1050
|
discount = value > subTotal ? subTotal : value;
|
|
1072
1051
|
}
|
|
1073
1052
|
else {
|
|
1074
1053
|
discount = subTotal * (value / 100);
|
|
1075
1054
|
}
|
|
1076
|
-
|
|
1077
|
-
return { discount, lineItems };
|
|
1055
|
+
return discount;
|
|
1078
1056
|
}
|
|
1079
1057
|
async hasMinSubTotal(coupon, checkout) {
|
|
1080
1058
|
if (!coupon.minSubTotalValue)
|
|
1081
1059
|
return true;
|
|
1082
1060
|
let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1083
|
-
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1061
|
+
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
|
|
1084
1062
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1085
1063
|
return true;
|
|
1086
1064
|
return false;
|
|
@@ -1148,7 +1126,7 @@ class CouponService {
|
|
|
1148
1126
|
}
|
|
1149
1127
|
return lineItensDiscount;
|
|
1150
1128
|
}
|
|
1151
|
-
calcCheckoutSubtotal(lineItens, user) {
|
|
1129
|
+
calcCheckoutSubtotal(lineItens, user, shop) {
|
|
1152
1130
|
return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
|
|
1153
1131
|
? acc + curr.price?.subscriberPrice * curr.quantity
|
|
1154
1132
|
: acc + curr.pricePaid * curr.quantity, 0) || 0);
|
|
@@ -1186,30 +1164,6 @@ class CouponService {
|
|
|
1186
1164
|
}
|
|
1187
1165
|
return couponUseLimits;
|
|
1188
1166
|
}
|
|
1189
|
-
calcLineItenDiscount(type, lineItems, couponDiscount, subTotal) {
|
|
1190
|
-
let lineItemsDiscount = [];
|
|
1191
|
-
if (type === CouponTypes.ABSOLUTE) {
|
|
1192
|
-
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1193
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1194
|
-
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1195
|
-
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1196
|
-
return {
|
|
1197
|
-
...item,
|
|
1198
|
-
discount: Number(discountItem.toFixed(2)),
|
|
1199
|
-
};
|
|
1200
|
-
});
|
|
1201
|
-
}
|
|
1202
|
-
else {
|
|
1203
|
-
lineItemsDiscount = lineItems.map((item) => {
|
|
1204
|
-
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1205
|
-
return {
|
|
1206
|
-
...item,
|
|
1207
|
-
discount: Number(discountItem.toFixed(2)),
|
|
1208
|
-
};
|
|
1209
|
-
});
|
|
1210
|
-
}
|
|
1211
|
-
return lineItemsDiscount;
|
|
1212
|
-
}
|
|
1213
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 }); }
|
|
1214
1168
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
|
|
1215
1169
|
}
|
|
@@ -1233,17 +1187,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1233
1187
|
}] }] });
|
|
1234
1188
|
|
|
1235
1189
|
class CheckoutService {
|
|
1236
|
-
constructor(couponService, checkoutRepository, userRepository, defaultShop
|
|
1190
|
+
constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
|
|
1237
1191
|
this.couponService = couponService;
|
|
1238
1192
|
this.checkoutRepository = checkoutRepository;
|
|
1193
|
+
this.orderRepository = orderRepository;
|
|
1239
1194
|
this.userRepository = userRepository;
|
|
1240
1195
|
this.defaultShop = defaultShop;
|
|
1241
|
-
this.dataPersistence = dataPersistence;
|
|
1242
1196
|
}
|
|
1243
1197
|
getCheckout(checkoutData) {
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1198
|
+
const checkoutId = cookie.get('checkoutId');
|
|
1199
|
+
if (!isNil(checkoutId))
|
|
1200
|
+
return from(this.checkoutRepository.get({ id: checkoutId }));
|
|
1201
|
+
return from(this.createCheckout(checkoutData));
|
|
1247
1202
|
}
|
|
1248
1203
|
getUserByCheckout(checkoutId) {
|
|
1249
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'))));
|
|
@@ -1255,7 +1210,8 @@ class CheckoutService {
|
|
|
1255
1210
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1256
1211
|
}
|
|
1257
1212
|
clearCheckoutFromSession() {
|
|
1258
|
-
|
|
1213
|
+
cookie.remove('checkoutId');
|
|
1214
|
+
return of();
|
|
1259
1215
|
}
|
|
1260
1216
|
calcDiscount(coupon) {
|
|
1261
1217
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1269,10 +1225,10 @@ class CheckoutService {
|
|
|
1269
1225
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1270
1226
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1271
1227
|
});
|
|
1272
|
-
|
|
1228
|
+
cookie.set('checkoutId', checkout.id);
|
|
1273
1229
|
return checkout;
|
|
1274
1230
|
}
|
|
1275
|
-
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 }); }
|
|
1276
1232
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
|
|
1277
1233
|
}
|
|
1278
1234
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
|
|
@@ -1280,15 +1236,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1280
1236
|
}], ctorParameters: () => [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1281
1237
|
type: Inject,
|
|
1282
1238
|
args: ['CheckoutRepository']
|
|
1239
|
+
}] }, { type: undefined, decorators: [{
|
|
1240
|
+
type: Inject,
|
|
1241
|
+
args: ['OrderRepository']
|
|
1283
1242
|
}] }, { type: undefined, decorators: [{
|
|
1284
1243
|
type: Inject,
|
|
1285
1244
|
args: ['UserRepository']
|
|
1286
1245
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1287
1246
|
type: Inject,
|
|
1288
1247
|
args: [DEFAULT_SHOP]
|
|
1289
|
-
}] }, { type: undefined, decorators: [{
|
|
1290
|
-
type: Inject,
|
|
1291
|
-
args: [PERSISTENCE_PROVIDER]
|
|
1292
1248
|
}] }] });
|
|
1293
1249
|
|
|
1294
1250
|
class CartService {
|
|
@@ -1350,7 +1306,6 @@ class CartService {
|
|
|
1350
1306
|
weight: weight ?? product.weight,
|
|
1351
1307
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1352
1308
|
pricePaid,
|
|
1353
|
-
discount: 0,
|
|
1354
1309
|
categories: product.categories ?? [],
|
|
1355
1310
|
isGift: isGift ?? null,
|
|
1356
1311
|
costPrice: product.costPrice ?? 0,
|
|
@@ -1402,7 +1357,7 @@ class CartService {
|
|
|
1402
1357
|
}), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
|
|
1403
1358
|
}
|
|
1404
1359
|
updateUserCart(user) {
|
|
1405
|
-
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
|
|
1406
1361
|
.updateCheckoutLineItems(Checkout.toInstance({
|
|
1407
1362
|
...checkout.toPlain(),
|
|
1408
1363
|
lineItems: checkout.lineItems?.length
|
|
@@ -1586,11 +1541,9 @@ class NewCategoryStructureAdapter {
|
|
|
1586
1541
|
.then((categories) => categories.map((category) => category.id.toString()));
|
|
1587
1542
|
}
|
|
1588
1543
|
async getCategory(category) {
|
|
1589
|
-
|
|
1590
|
-
(
|
|
1591
|
-
category
|
|
1592
|
-
category.brandCategory;
|
|
1593
|
-
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;
|
|
1594
1547
|
}
|
|
1595
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 }); }
|
|
1596
1549
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
|
|
@@ -1623,9 +1576,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1623
1576
|
}] }] });
|
|
1624
1577
|
|
|
1625
1578
|
class CatalogService {
|
|
1626
|
-
constructor(productRepository,
|
|
1579
|
+
constructor(productRepository, categoryStructureAdapter, shop, productIndex) {
|
|
1627
1580
|
this.productRepository = productRepository;
|
|
1628
|
-
this.categoryRepository = categoryRepository;
|
|
1629
1581
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1630
1582
|
this.shop = shop;
|
|
1631
1583
|
this.productIndex = productIndex;
|
|
@@ -1655,22 +1607,17 @@ class CatalogService {
|
|
|
1655
1607
|
if (!sort || sort === 'most-relevant')
|
|
1656
1608
|
return {};
|
|
1657
1609
|
if (sort === 'best-sellers')
|
|
1658
|
-
return {
|
|
1659
|
-
shoppingCount: 'desc',
|
|
1660
|
-
rate: 'desc',
|
|
1661
|
-
stock: 'desc',
|
|
1662
|
-
name: 'asc',
|
|
1663
|
-
};
|
|
1610
|
+
return { shoppingCount: 'desc' };
|
|
1664
1611
|
if (sort === 'biggest-price')
|
|
1665
|
-
return { subscriberPrice: 'desc'
|
|
1612
|
+
return { subscriberPrice: 'desc' };
|
|
1666
1613
|
if (sort === 'lowest-price')
|
|
1667
|
-
return { subscriberPrice: 'asc'
|
|
1614
|
+
return { subscriberPrice: 'asc' };
|
|
1668
1615
|
if (sort === 'best-rating')
|
|
1669
|
-
return { rate: 'desc'
|
|
1616
|
+
return { rate: 'desc' };
|
|
1670
1617
|
if (sort === 'news')
|
|
1671
1618
|
return { createdAt: 'desc' };
|
|
1672
1619
|
if (sort === 'biggest-discount')
|
|
1673
|
-
return { subscriberDiscountPercentage: 'desc'
|
|
1620
|
+
return { subscriberDiscountPercentage: 'desc' };
|
|
1674
1621
|
};
|
|
1675
1622
|
this.buildLimitQuery = (options) => {
|
|
1676
1623
|
const limit = options?.perPage || 20;
|
|
@@ -1705,20 +1652,8 @@ class CatalogService {
|
|
|
1705
1652
|
}));
|
|
1706
1653
|
}
|
|
1707
1654
|
async findCatalog(options, limits) {
|
|
1708
|
-
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1709
|
-
|
|
1710
|
-
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1711
|
-
}
|
|
1712
|
-
if (this.hasCategory(options) && options.sort === 'most-relevant') {
|
|
1713
|
-
const productsIds = await this.productRepository
|
|
1714
|
-
.find({
|
|
1715
|
-
filters: {
|
|
1716
|
-
...(await this.buildMainFilter(options)),
|
|
1717
|
-
},
|
|
1718
|
-
})
|
|
1719
|
-
.then((products) => products.data.map((product) => product.id));
|
|
1720
|
-
return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
|
|
1721
|
-
}
|
|
1655
|
+
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1656
|
+
return this.findCatalogByTermAndSortByMostRevelant(options, limits);
|
|
1722
1657
|
const repoParams = {
|
|
1723
1658
|
filters: {
|
|
1724
1659
|
...(await this.buildMainFilter(options)),
|
|
@@ -1746,7 +1681,8 @@ class CatalogService {
|
|
|
1746
1681
|
.search(term, 999, this.shop)
|
|
1747
1682
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1748
1683
|
}
|
|
1749
|
-
async
|
|
1684
|
+
async findCatalogByTermAndSortByMostRevelant(options, limits) {
|
|
1685
|
+
const productIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1750
1686
|
const totalResult = await this.productRepository.findCatalog({
|
|
1751
1687
|
fields: ['id', 'stock'],
|
|
1752
1688
|
filters: {
|
|
@@ -1792,7 +1728,7 @@ class CatalogService {
|
|
|
1792
1728
|
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1793
1729
|
}));
|
|
1794
1730
|
}
|
|
1795
|
-
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 }); }
|
|
1796
1732
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
|
|
1797
1733
|
}
|
|
1798
1734
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
|
|
@@ -1800,9 +1736,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1800
1736
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1801
1737
|
type: Inject,
|
|
1802
1738
|
args: ['ProductRepository']
|
|
1803
|
-
}] }, { type: undefined, decorators: [{
|
|
1804
|
-
type: Inject,
|
|
1805
|
-
args: ['CategoryRepository']
|
|
1806
1739
|
}] }, { type: undefined, decorators: [{
|
|
1807
1740
|
type: Inject,
|
|
1808
1741
|
args: [CATEGORY_STRUCTURE]
|
|
@@ -1819,15 +1752,15 @@ class CategoryService {
|
|
|
1819
1752
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1820
1753
|
this.shop = shop;
|
|
1821
1754
|
}
|
|
1822
|
-
async fetchBrands(category,
|
|
1755
|
+
async fetchBrands(category, mainGender) {
|
|
1823
1756
|
const brands = await this.productRepository
|
|
1824
1757
|
.findCatalog({
|
|
1825
1758
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1826
1759
|
fields: ['brand'],
|
|
1827
|
-
},
|
|
1760
|
+
}, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1828
1761
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1829
1762
|
return this.categoryRepository
|
|
1830
|
-
.find({ filters: { brandCategory: true, shop:
|
|
1763
|
+
.find({ filters: { brandCategory: true, shop: this.shop }, orderBy: { name: 'asc' } })
|
|
1831
1764
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1832
1765
|
}
|
|
1833
1766
|
async fetchFilterOptions(category) {
|
|
@@ -1876,11 +1809,12 @@ __decorate([
|
|
|
1876
1809
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1877
1810
|
|
|
1878
1811
|
class WishlistService {
|
|
1879
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository,
|
|
1812
|
+
constructor(wishlistRepository, categoryRepository, shop, productRepository, categoryFilterRepository, productIndex) {
|
|
1880
1813
|
this.wishlistRepository = wishlistRepository;
|
|
1814
|
+
this.categoryRepository = categoryRepository;
|
|
1881
1815
|
this.shop = shop;
|
|
1882
1816
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1883
|
-
this.catalogService = new CatalogService(productRepository,
|
|
1817
|
+
this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
|
|
1884
1818
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
1885
1819
|
}
|
|
1886
1820
|
getCatalogService() {
|
|
@@ -1889,7 +1823,7 @@ class WishlistService {
|
|
|
1889
1823
|
getCategoryService() {
|
|
1890
1824
|
return this.categoryService;
|
|
1891
1825
|
}
|
|
1892
|
-
async create({ personId, title, description,
|
|
1826
|
+
async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1893
1827
|
const data = {
|
|
1894
1828
|
slug: '',
|
|
1895
1829
|
name: title,
|
|
@@ -1904,7 +1838,7 @@ class WishlistService {
|
|
|
1904
1838
|
personName: userFullName,
|
|
1905
1839
|
personPhoto: userPhoto,
|
|
1906
1840
|
brandCategory: false,
|
|
1907
|
-
published,
|
|
1841
|
+
published: true,
|
|
1908
1842
|
theme,
|
|
1909
1843
|
bannerUrl,
|
|
1910
1844
|
};
|
|
@@ -1912,12 +1846,11 @@ class WishlistService {
|
|
|
1912
1846
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
1913
1847
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
1914
1848
|
}
|
|
1915
|
-
update({ id, title, description,
|
|
1849
|
+
update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
|
|
1916
1850
|
const data = {
|
|
1917
1851
|
id,
|
|
1918
1852
|
name: title,
|
|
1919
1853
|
description,
|
|
1920
|
-
published,
|
|
1921
1854
|
metadata: {
|
|
1922
1855
|
title: `${userFullName} - ${title}`,
|
|
1923
1856
|
description: `${userFullName} - ${description}`,
|
|
@@ -1961,7 +1894,7 @@ class WishlistService {
|
|
|
1961
1894
|
}
|
|
1962
1895
|
return wishlist;
|
|
1963
1896
|
}
|
|
1964
|
-
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 }); }
|
|
1965
1898
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
1966
1899
|
}
|
|
1967
1900
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -1969,6 +1902,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1969
1902
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1970
1903
|
type: Inject,
|
|
1971
1904
|
args: ['WishlistRepository']
|
|
1905
|
+
}] }, { type: undefined, decorators: [{
|
|
1906
|
+
type: Inject,
|
|
1907
|
+
args: ['CategoryRepository']
|
|
1972
1908
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1973
1909
|
type: Inject,
|
|
1974
1910
|
args: [DEFAULT_SHOP]
|
|
@@ -1978,24 +1914,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
1978
1914
|
}] }, { type: undefined, decorators: [{
|
|
1979
1915
|
type: Inject,
|
|
1980
1916
|
args: ['CategoryFilterRepository']
|
|
1981
|
-
}] }, { type: undefined, decorators: [{
|
|
1982
|
-
type: Inject,
|
|
1983
|
-
args: ['CategoryRepository']
|
|
1984
1917
|
}] }, { type: i1$2.ProductsIndex }] });
|
|
1985
1918
|
|
|
1986
1919
|
class CheckoutSubscriptionService {
|
|
1987
|
-
constructor(checkoutSubscriptionRepository,
|
|
1920
|
+
constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
|
|
1988
1921
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1989
|
-
this.
|
|
1922
|
+
this.subscriptionRepository = subscriptionRepository;
|
|
1990
1923
|
this.couponService = couponService;
|
|
1991
1924
|
}
|
|
1992
1925
|
getCheckoutSubscription(checkoutData) {
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
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;
|
|
1996
1938
|
}
|
|
1997
1939
|
clearCheckoutSubscriptionFromSession() {
|
|
1998
|
-
|
|
1940
|
+
cookie.remove('checkoutSubscriptionId');
|
|
1941
|
+
return of();
|
|
1999
1942
|
}
|
|
2000
1943
|
checkCoupon(nickname, userEmail) {
|
|
2001
1944
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -2005,15 +1948,7 @@ class CheckoutSubscriptionService {
|
|
|
2005
1948
|
calcDiscountSubscription(coupon) {
|
|
2006
1949
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
2007
1950
|
}
|
|
2008
|
-
|
|
2009
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
2010
|
-
createdAt: new Date(),
|
|
2011
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
2012
|
-
});
|
|
2013
|
-
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
2014
|
-
return checkout;
|
|
2015
|
-
}
|
|
2016
|
-
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 }); }
|
|
2017
1952
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
|
|
2018
1953
|
}
|
|
2019
1954
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
@@ -2023,7 +1958,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2023
1958
|
args: ['CheckoutSubscriptionRepository']
|
|
2024
1959
|
}] }, { type: undefined, decorators: [{
|
|
2025
1960
|
type: Inject,
|
|
2026
|
-
args: [
|
|
1961
|
+
args: ['SubscriptionRepository']
|
|
2027
1962
|
}] }, { type: CouponService }] });
|
|
2028
1963
|
|
|
2029
1964
|
class UtilHelper {
|
|
@@ -2281,7 +2216,6 @@ class AngularConnectModule {
|
|
|
2281
2216
|
? OldCategoryStructureAdapter
|
|
2282
2217
|
: NewCategoryStructureAdapter,
|
|
2283
2218
|
},
|
|
2284
|
-
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2285
2219
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2286
2220
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2287
2221
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
@@ -2375,5 +2309,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2375
2309
|
* Generated bundle index. Do not edit.
|
|
2376
2310
|
*/
|
|
2377
2311
|
|
|
2378
|
-
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 };
|
|
2379
2313
|
//# sourceMappingURL=infrab4a-connect-angular.mjs.map
|