@infrab4a/connect-angular 4.12.2-beta.1 → 4.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/angular-firestore.module.mjs +16 -2
- package/esm2020/services/cart.service.mjs +2 -2
- package/esm2020/services/catalog/wishlist.service.mjs +95 -6
- package/esm2020/services/coupon.service.mjs +7 -3
- package/fesm2015/infrab4a-connect-angular.mjs +147 -29
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +115 -8
- package/fesm2020/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';
|
|
@@ -414,6 +414,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
414
414
|
},
|
|
415
415
|
deps: ['FirestoreOptions'],
|
|
416
416
|
},
|
|
417
|
+
{
|
|
418
|
+
provide: 'LogRepository',
|
|
419
|
+
useFactory: (options) => {
|
|
420
|
+
return new LogFirestoreRepository(options);
|
|
421
|
+
},
|
|
422
|
+
deps: ['FirestoreOptions'],
|
|
423
|
+
},
|
|
417
424
|
], imports: [AngularElasticSeachModule,
|
|
418
425
|
provideFirestore((injector) => {
|
|
419
426
|
const platformId = injector.get(PLATFORM_ID);
|
|
@@ -666,6 +673,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
666
673
|
},
|
|
667
674
|
deps: ['FirestoreOptions'],
|
|
668
675
|
},
|
|
676
|
+
{
|
|
677
|
+
provide: 'LogRepository',
|
|
678
|
+
useFactory: (options) => {
|
|
679
|
+
return new LogFirestoreRepository(options);
|
|
680
|
+
},
|
|
681
|
+
deps: ['FirestoreOptions'],
|
|
682
|
+
},
|
|
669
683
|
],
|
|
670
684
|
}]
|
|
671
685
|
}] });
|
|
@@ -1070,6 +1084,7 @@ class CouponService {
|
|
|
1070
1084
|
});
|
|
1071
1085
|
}
|
|
1072
1086
|
couponRulesValidation(coupon, checkoutType, checkout, plan) {
|
|
1087
|
+
var _a;
|
|
1073
1088
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1074
1089
|
if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
|
|
1075
1090
|
if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
|
|
@@ -1099,8 +1114,12 @@ class CouponService {
|
|
|
1099
1114
|
if (!hasProductCategories)
|
|
1100
1115
|
throw 'Seu carrinho não possui produtos elegíveis para desconto.';
|
|
1101
1116
|
const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
|
|
1102
|
-
if (!hasMinSubTotal)
|
|
1103
|
-
|
|
1117
|
+
if (!hasMinSubTotal) {
|
|
1118
|
+
if ((_a = coupon.productsCategories) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1119
|
+
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.`;
|
|
1120
|
+
}
|
|
1121
|
+
throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido.`;
|
|
1122
|
+
}
|
|
1104
1123
|
return coupon;
|
|
1105
1124
|
});
|
|
1106
1125
|
}
|
|
@@ -1409,7 +1428,7 @@ class CartService {
|
|
|
1409
1428
|
return (Object.assign(Object.assign({}, cart), { [item.id]: LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })) }));
|
|
1410
1429
|
}, {})) || {};
|
|
1411
1430
|
this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
|
|
1412
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1431
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1413
1432
|
const product = yield this.getProductData(item.id);
|
|
1414
1433
|
item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
|
|
1415
1434
|
if (this.checkMaxStock(product.stock.quantity, item.quantity || 0, quantity || 0))
|
|
@@ -1440,9 +1459,9 @@ class CartService {
|
|
|
1440
1459
|
quantity: (item.quantity || 0) + (quantity || 0),
|
|
1441
1460
|
pricePaid,
|
|
1442
1461
|
discount: 0,
|
|
1443
|
-
categories: (_f = product.
|
|
1462
|
+
categories: product.categories || ((_f = product.category) === null || _f === void 0 ? void 0 : _f.id) ? [(_g = product.category) === null || _g === void 0 ? void 0 : _g.id, ...product.categories] : [],
|
|
1444
1463
|
isGift: isGift !== null && isGift !== void 0 ? isGift : null,
|
|
1445
|
-
costPrice: (
|
|
1464
|
+
costPrice: (_h = product.costPrice) !== null && _h !== void 0 ? _h : 0,
|
|
1446
1465
|
type,
|
|
1447
1466
|
}),
|
|
1448
1467
|
};
|
|
@@ -2030,10 +2049,12 @@ __decorate([
|
|
|
2030
2049
|
], CategoryWithTree.prototype, "children", void 0);
|
|
2031
2050
|
|
|
2032
2051
|
class WishlistService {
|
|
2033
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch) {
|
|
2052
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch, logRepository) {
|
|
2034
2053
|
this.wishlistRepository = wishlistRepository;
|
|
2035
2054
|
this.shop = shop;
|
|
2055
|
+
this.productRepository = productRepository;
|
|
2036
2056
|
this.productSearch = productSearch;
|
|
2057
|
+
this.logRepository = logRepository;
|
|
2037
2058
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
2038
2059
|
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch);
|
|
2039
2060
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
@@ -2082,6 +2103,7 @@ class WishlistService {
|
|
|
2082
2103
|
},
|
|
2083
2104
|
})
|
|
2084
2105
|
.then((res) => res.data);
|
|
2106
|
+
yield this.createWishlistLog(WishlistLogType.CREATE, data);
|
|
2085
2107
|
if (hasWishlist.length)
|
|
2086
2108
|
return hasWishlist.at(0);
|
|
2087
2109
|
const newWishlist = yield this.wishlistRepository.create(data);
|
|
@@ -2090,29 +2112,36 @@ class WishlistService {
|
|
|
2090
2112
|
});
|
|
2091
2113
|
}
|
|
2092
2114
|
update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2116
|
+
const data = {
|
|
2117
|
+
id,
|
|
2118
|
+
name: title,
|
|
2119
|
+
description,
|
|
2120
|
+
published,
|
|
2121
|
+
metadatas: [
|
|
2122
|
+
{
|
|
2123
|
+
shop: this.shop,
|
|
2124
|
+
title: `${userFullName} - ${title}`,
|
|
2125
|
+
description: `${userFullName} - ${description}`,
|
|
2126
|
+
},
|
|
2127
|
+
],
|
|
2128
|
+
personName: userFullName,
|
|
2129
|
+
personPhoto: userPhoto,
|
|
2130
|
+
theme,
|
|
2131
|
+
bannerUrl,
|
|
2132
|
+
personType: personType !== null && personType !== void 0 ? personType : PersonTypes.NONE,
|
|
2133
|
+
personIsSubscriber: personIsSubscriber !== null && personIsSubscriber !== void 0 ? personIsSubscriber : false,
|
|
2134
|
+
};
|
|
2135
|
+
yield this.createWishlistLog(WishlistLogType.UPDATE, data);
|
|
2136
|
+
return this.wishlistRepository.update(data);
|
|
2137
|
+
});
|
|
2113
2138
|
}
|
|
2114
2139
|
delete(wishlistId) {
|
|
2115
|
-
return this
|
|
2140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2141
|
+
const wishlist = yield this.findById(wishlistId);
|
|
2142
|
+
yield this.createWishlistLog(WishlistLogType.DELETE, wishlist);
|
|
2143
|
+
return this.wishlistRepository.delete({ id: wishlistId });
|
|
2144
|
+
});
|
|
2116
2145
|
}
|
|
2117
2146
|
getWishlistBySlug(slug) {
|
|
2118
2147
|
const [id] = slug.split('-');
|
|
@@ -2127,6 +2156,9 @@ class WishlistService {
|
|
|
2127
2156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2128
2157
|
const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
|
|
2129
2158
|
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
2159
|
+
const wishlistData = yield this.findById(wishlistId);
|
|
2160
|
+
const productData = yield this.findProductById(productId);
|
|
2161
|
+
yield this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData);
|
|
2130
2162
|
if (!hasProduct) {
|
|
2131
2163
|
wishlist.products = [...wishlist.products, productId];
|
|
2132
2164
|
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
@@ -2140,6 +2172,9 @@ class WishlistService {
|
|
|
2140
2172
|
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
2141
2173
|
if (productIndex != -1) {
|
|
2142
2174
|
wishlist.products.splice(productIndex, 1);
|
|
2175
|
+
const wishlistData = yield this.findById(wishlistId);
|
|
2176
|
+
const productData = yield this.findProductById(productId);
|
|
2177
|
+
yield this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData);
|
|
2143
2178
|
if (!wishlist.products.length)
|
|
2144
2179
|
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
2145
2180
|
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
@@ -2147,8 +2182,88 @@ class WishlistService {
|
|
|
2147
2182
|
return wishlist;
|
|
2148
2183
|
});
|
|
2149
2184
|
}
|
|
2185
|
+
findById(id) {
|
|
2186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2187
|
+
return this.wishlistRepository
|
|
2188
|
+
.find({
|
|
2189
|
+
fields: ['id', 'name', 'description', 'personId', 'personIsSubscriber', 'personType', 'personName'],
|
|
2190
|
+
filters: {
|
|
2191
|
+
id,
|
|
2192
|
+
},
|
|
2193
|
+
})
|
|
2194
|
+
.then((res) => res.data.at(0));
|
|
2195
|
+
});
|
|
2196
|
+
}
|
|
2197
|
+
findProductById(id) {
|
|
2198
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2199
|
+
return this.productRepository
|
|
2200
|
+
.find({
|
|
2201
|
+
fields: ['id', 'sku', 'EAN', 'name', 'brand'],
|
|
2202
|
+
filters: {
|
|
2203
|
+
id,
|
|
2204
|
+
},
|
|
2205
|
+
})
|
|
2206
|
+
.then((res) => res.data.at(0));
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
createWishlistLog(type, wishlist, product) {
|
|
2210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2211
|
+
switch (type) {
|
|
2212
|
+
case WishlistLogType.CREATE:
|
|
2213
|
+
case WishlistLogType.UPDATE:
|
|
2214
|
+
case WishlistLogType.DELETE:
|
|
2215
|
+
yield this.logRepository.create({
|
|
2216
|
+
collection: 'wishlist',
|
|
2217
|
+
date: new Date(),
|
|
2218
|
+
operation: WishlistLogType.CREATE ? 'CREATE' : WishlistLogType.UPDATE ? 'UPDATE' : 'DELETE',
|
|
2219
|
+
documentId: wishlist.id,
|
|
2220
|
+
document: {
|
|
2221
|
+
id: wishlist.id,
|
|
2222
|
+
shop: this.shop,
|
|
2223
|
+
name: wishlist.name,
|
|
2224
|
+
description: wishlist.description,
|
|
2225
|
+
published: wishlist.published,
|
|
2226
|
+
type: type,
|
|
2227
|
+
personType: wishlist.personType,
|
|
2228
|
+
personId: wishlist.personId,
|
|
2229
|
+
personName: wishlist.personName,
|
|
2230
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2231
|
+
},
|
|
2232
|
+
});
|
|
2233
|
+
break;
|
|
2234
|
+
case WishlistLogType.ADD_PRODUCT:
|
|
2235
|
+
case WishlistLogType.REMOVE_PRODUCT:
|
|
2236
|
+
yield this.logRepository.create({
|
|
2237
|
+
collection: 'wishlist',
|
|
2238
|
+
date: new Date(),
|
|
2239
|
+
operation: 'UPDATE',
|
|
2240
|
+
documentId: wishlist.id,
|
|
2241
|
+
document: {
|
|
2242
|
+
id: wishlist.id,
|
|
2243
|
+
shop: this.shop,
|
|
2244
|
+
name: wishlist.name,
|
|
2245
|
+
description: wishlist.description,
|
|
2246
|
+
published: wishlist.published,
|
|
2247
|
+
type: type,
|
|
2248
|
+
personType: wishlist.personType,
|
|
2249
|
+
personId: wishlist.personId,
|
|
2250
|
+
personName: wishlist.personName,
|
|
2251
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2252
|
+
productId: product.id,
|
|
2253
|
+
productEAN: product.EAN,
|
|
2254
|
+
productSKU: product.sku,
|
|
2255
|
+
productName: product.name,
|
|
2256
|
+
productBrand: product.brand,
|
|
2257
|
+
},
|
|
2258
|
+
});
|
|
2259
|
+
break;
|
|
2260
|
+
default:
|
|
2261
|
+
break;
|
|
2262
|
+
}
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2150
2265
|
}
|
|
2151
|
-
WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: 'ProductStockNotificationRepository' }, { token: 'ProductSearch' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2266
|
+
WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", 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 });
|
|
2152
2267
|
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
|
|
2153
2268
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
|
|
2154
2269
|
type: Injectable
|
|
@@ -2174,6 +2289,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2174
2289
|
}] }, { type: undefined, decorators: [{
|
|
2175
2290
|
type: Inject,
|
|
2176
2291
|
args: ['ProductSearch']
|
|
2292
|
+
}] }, { type: undefined, decorators: [{
|
|
2293
|
+
type: Inject,
|
|
2294
|
+
args: ['LogRepository']
|
|
2177
2295
|
}] }];
|
|
2178
2296
|
} });
|
|
2179
2297
|
|