@infrab4a/connect-angular 5.0.0-beta.60 → 5.0.0-beta.61
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/esm2022/angular-firestore.module.mjs +16 -2
- package/esm2022/services/cart.service.mjs +2 -2
- package/esm2022/services/catalog/wishlist.service.mjs +95 -6
- package/esm2022/services/coupon.service.mjs +7 -3
- package/esm2022/services/home-shop.service.mjs +4 -4
- package/fesm2022/infrab4a-connect-angular.mjs +117 -10
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/wishlist.service.d.ts +7 -2
|
@@ -5,7 +5,7 @@ import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular
|
|
|
5
5
|
import * as i2 from '@angular/fire/storage';
|
|
6
6
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
7
7
|
import * as i1$2 from '@infrab4a/connect';
|
|
8
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, 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, OrderBlockedFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, PersonTypes, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
8
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, 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, OrderBlockedFirestoreRepository, LogFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
9
9
|
import * as i1 from '@angular/fire/auth';
|
|
10
10
|
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
11
11
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
@@ -412,6 +412,13 @@ class AngularFirestoreModule {
|
|
|
412
412
|
},
|
|
413
413
|
deps: ['FirestoreOptions'],
|
|
414
414
|
},
|
|
415
|
+
{
|
|
416
|
+
provide: 'LogRepository',
|
|
417
|
+
useFactory: (options) => {
|
|
418
|
+
return new LogFirestoreRepository(options);
|
|
419
|
+
},
|
|
420
|
+
deps: ['FirestoreOptions'],
|
|
421
|
+
},
|
|
415
422
|
], imports: [AngularElasticSeachModule,
|
|
416
423
|
provideFirestore((injector) => {
|
|
417
424
|
const platformId = injector.get(PLATFORM_ID);
|
|
@@ -665,6 +672,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
665
672
|
},
|
|
666
673
|
deps: ['FirestoreOptions'],
|
|
667
674
|
},
|
|
675
|
+
{
|
|
676
|
+
provide: 'LogRepository',
|
|
677
|
+
useFactory: (options) => {
|
|
678
|
+
return new LogFirestoreRepository(options);
|
|
679
|
+
},
|
|
680
|
+
deps: ['FirestoreOptions'],
|
|
681
|
+
},
|
|
668
682
|
],
|
|
669
683
|
}]
|
|
670
684
|
}] });
|
|
@@ -1093,8 +1107,12 @@ class CouponService {
|
|
|
1093
1107
|
if (!hasProductCategories)
|
|
1094
1108
|
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
1095
1109
|
const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
|
|
1096
|
-
if (!hasMinSubTotal)
|
|
1097
|
-
|
|
1110
|
+
if (!hasMinSubTotal) {
|
|
1111
|
+
if (coupon.productsCategories?.length) {
|
|
1112
|
+
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido na(s) categoria(s) elegíveis para o desconto.`;
|
|
1113
|
+
}
|
|
1114
|
+
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido.`;
|
|
1115
|
+
}
|
|
1098
1116
|
return coupon;
|
|
1099
1117
|
}
|
|
1100
1118
|
calcDiscountSubscription(coupon, checkout) {
|
|
@@ -1415,7 +1433,7 @@ class CartService {
|
|
|
1415
1433
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1416
1434
|
pricePaid,
|
|
1417
1435
|
discount: 0,
|
|
1418
|
-
categories: product.categories
|
|
1436
|
+
categories: product.categories || product.category?.id ? [product.category?.id, ...product.categories] : [],
|
|
1419
1437
|
isGift: isGift ?? null,
|
|
1420
1438
|
costPrice: product.costPrice ?? 0,
|
|
1421
1439
|
type,
|
|
@@ -1987,10 +2005,12 @@ __decorate([
|
|
|
1987
2005
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1988
2006
|
|
|
1989
2007
|
class WishlistService {
|
|
1990
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch) {
|
|
2008
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch, logRepository) {
|
|
1991
2009
|
this.wishlistRepository = wishlistRepository;
|
|
1992
2010
|
this.shop = shop;
|
|
2011
|
+
this.productRepository = productRepository;
|
|
1993
2012
|
this.productSearch = productSearch;
|
|
2013
|
+
this.logRepository = logRepository;
|
|
1994
2014
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1995
2015
|
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch);
|
|
1996
2016
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
@@ -2038,13 +2058,14 @@ class WishlistService {
|
|
|
2038
2058
|
},
|
|
2039
2059
|
})
|
|
2040
2060
|
.then((res) => res.data);
|
|
2061
|
+
await this.createWishlistLog(WishlistLogType.CREATE, data);
|
|
2041
2062
|
if (hasWishlist.length)
|
|
2042
2063
|
return hasWishlist.at(0);
|
|
2043
2064
|
const newWishlist = await this.wishlistRepository.create(data);
|
|
2044
2065
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
2045
2066
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
2046
2067
|
}
|
|
2047
|
-
update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2068
|
+
async update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2048
2069
|
const data = {
|
|
2049
2070
|
id,
|
|
2050
2071
|
name: title,
|
|
@@ -2064,9 +2085,12 @@ class WishlistService {
|
|
|
2064
2085
|
personType: personType ?? PersonTypes.NONE,
|
|
2065
2086
|
personIsSubscriber: personIsSubscriber ?? false,
|
|
2066
2087
|
};
|
|
2088
|
+
await this.createWishlistLog(WishlistLogType.UPDATE, data);
|
|
2067
2089
|
return this.wishlistRepository.update(data);
|
|
2068
2090
|
}
|
|
2069
|
-
delete(wishlistId) {
|
|
2091
|
+
async delete(wishlistId) {
|
|
2092
|
+
const wishlist = await this.findById(wishlistId);
|
|
2093
|
+
await this.createWishlistLog(WishlistLogType.DELETE, wishlist);
|
|
2070
2094
|
return this.wishlistRepository.delete({ id: wishlistId });
|
|
2071
2095
|
}
|
|
2072
2096
|
getWishlistBySlug(slug) {
|
|
@@ -2081,6 +2105,9 @@ class WishlistService {
|
|
|
2081
2105
|
async addProduct(wishlistId, productId) {
|
|
2082
2106
|
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
2083
2107
|
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
2108
|
+
const wishlistData = await this.findById(wishlistId);
|
|
2109
|
+
const productData = await this.findProductById(productId);
|
|
2110
|
+
await this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData);
|
|
2084
2111
|
if (!hasProduct) {
|
|
2085
2112
|
wishlist.products = [...wishlist.products, productId];
|
|
2086
2113
|
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
@@ -2092,13 +2119,90 @@ class WishlistService {
|
|
|
2092
2119
|
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
2093
2120
|
if (productIndex != -1) {
|
|
2094
2121
|
wishlist.products.splice(productIndex, 1);
|
|
2122
|
+
const wishlistData = await this.findById(wishlistId);
|
|
2123
|
+
const productData = await this.findProductById(productId);
|
|
2124
|
+
await this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData);
|
|
2095
2125
|
if (!wishlist.products.length)
|
|
2096
2126
|
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
2097
2127
|
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
2098
2128
|
}
|
|
2099
2129
|
return wishlist;
|
|
2100
2130
|
}
|
|
2101
|
-
|
|
2131
|
+
async findById(id) {
|
|
2132
|
+
return this.wishlistRepository
|
|
2133
|
+
.find({
|
|
2134
|
+
fields: ['id', 'name', 'description', 'personId', 'personIsSubscriber', 'personType', 'personName'],
|
|
2135
|
+
filters: {
|
|
2136
|
+
id,
|
|
2137
|
+
},
|
|
2138
|
+
})
|
|
2139
|
+
.then((res) => res.data.at(0));
|
|
2140
|
+
}
|
|
2141
|
+
async findProductById(id) {
|
|
2142
|
+
return this.productRepository
|
|
2143
|
+
.find({
|
|
2144
|
+
fields: ['id', 'sku', 'EAN', 'name', 'brand'],
|
|
2145
|
+
filters: {
|
|
2146
|
+
id,
|
|
2147
|
+
},
|
|
2148
|
+
})
|
|
2149
|
+
.then((res) => res.data.at(0));
|
|
2150
|
+
}
|
|
2151
|
+
async createWishlistLog(type, wishlist, product) {
|
|
2152
|
+
switch (type) {
|
|
2153
|
+
case WishlistLogType.CREATE:
|
|
2154
|
+
case WishlistLogType.UPDATE:
|
|
2155
|
+
case WishlistLogType.DELETE:
|
|
2156
|
+
await this.logRepository.create({
|
|
2157
|
+
collection: 'wishlist',
|
|
2158
|
+
date: new Date(),
|
|
2159
|
+
operation: WishlistLogType.CREATE ? 'CREATE' : WishlistLogType.UPDATE ? 'UPDATE' : 'DELETE',
|
|
2160
|
+
documentId: wishlist.id,
|
|
2161
|
+
document: {
|
|
2162
|
+
id: wishlist.id,
|
|
2163
|
+
shop: this.shop,
|
|
2164
|
+
name: wishlist.name,
|
|
2165
|
+
description: wishlist.description,
|
|
2166
|
+
published: wishlist.published,
|
|
2167
|
+
type: type,
|
|
2168
|
+
personType: wishlist.personType,
|
|
2169
|
+
personId: wishlist.personId,
|
|
2170
|
+
personName: wishlist.personName,
|
|
2171
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2172
|
+
},
|
|
2173
|
+
});
|
|
2174
|
+
break;
|
|
2175
|
+
case WishlistLogType.ADD_PRODUCT:
|
|
2176
|
+
case WishlistLogType.REMOVE_PRODUCT:
|
|
2177
|
+
await this.logRepository.create({
|
|
2178
|
+
collection: 'wishlist',
|
|
2179
|
+
date: new Date(),
|
|
2180
|
+
operation: 'UPDATE',
|
|
2181
|
+
documentId: wishlist.id,
|
|
2182
|
+
document: {
|
|
2183
|
+
id: wishlist.id,
|
|
2184
|
+
shop: this.shop,
|
|
2185
|
+
name: wishlist.name,
|
|
2186
|
+
description: wishlist.description,
|
|
2187
|
+
published: wishlist.published,
|
|
2188
|
+
type: type,
|
|
2189
|
+
personType: wishlist.personType,
|
|
2190
|
+
personId: wishlist.personId,
|
|
2191
|
+
personName: wishlist.personName,
|
|
2192
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2193
|
+
productId: product.id,
|
|
2194
|
+
productEAN: product.EAN,
|
|
2195
|
+
productSKU: product.sku,
|
|
2196
|
+
productName: product.name,
|
|
2197
|
+
productBrand: product.brand,
|
|
2198
|
+
},
|
|
2199
|
+
});
|
|
2200
|
+
break;
|
|
2201
|
+
default:
|
|
2202
|
+
break;
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: 'ProductStockNotificationRepository' }, { token: 'ProductSearch' }, { token: 'LogRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2102
2206
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
|
|
2103
2207
|
}
|
|
2104
2208
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
|
|
@@ -2124,6 +2228,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
2124
2228
|
}] }, { type: undefined, decorators: [{
|
|
2125
2229
|
type: Inject,
|
|
2126
2230
|
args: ['ProductSearch']
|
|
2231
|
+
}] }, { type: undefined, decorators: [{
|
|
2232
|
+
type: Inject,
|
|
2233
|
+
args: ['LogRepository']
|
|
2127
2234
|
}] }] });
|
|
2128
2235
|
|
|
2129
2236
|
class CheckoutSubscriptionService {
|
|
@@ -2251,10 +2358,10 @@ class HomeShopService {
|
|
|
2251
2358
|
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
2252
2359
|
}
|
|
2253
2360
|
getDiscoverProducts(gender) {
|
|
2254
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories,
|
|
2361
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, this.defaultShop)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2255
2362
|
}
|
|
2256
2363
|
getFeaturedProducts(gender) {
|
|
2257
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories,
|
|
2364
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, this.defaultShop)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2258
2365
|
}
|
|
2259
2366
|
getVerticalProducts(gender) {
|
|
2260
2367
|
return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
|