@infrab4a/connect-angular 4.12.2-beta.1 → 4.13.0-beta.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/catalog/wishlist.service.mjs +95 -6
- package/esm2020/services/home-shop.service.mjs +4 -4
- package/fesm2015/infrab4a-connect-angular.mjs +139 -26
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +110 -7
- 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';
|
|
@@ -413,6 +413,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
413
413
|
},
|
|
414
414
|
deps: ['FirestoreOptions'],
|
|
415
415
|
},
|
|
416
|
+
{
|
|
417
|
+
provide: 'LogRepository',
|
|
418
|
+
useFactory: (options) => {
|
|
419
|
+
return new LogFirestoreRepository(options);
|
|
420
|
+
},
|
|
421
|
+
deps: ['FirestoreOptions'],
|
|
422
|
+
},
|
|
416
423
|
], imports: [AngularElasticSeachModule,
|
|
417
424
|
provideFirestore((injector) => {
|
|
418
425
|
const platformId = injector.get(PLATFORM_ID);
|
|
@@ -665,6 +672,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", 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
|
}] });
|
|
@@ -1987,10 +2001,12 @@ __decorate([
|
|
|
1987
2001
|
], CategoryWithTree.prototype, "children", void 0);
|
|
1988
2002
|
|
|
1989
2003
|
class WishlistService {
|
|
1990
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch) {
|
|
2004
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch, logRepository) {
|
|
1991
2005
|
this.wishlistRepository = wishlistRepository;
|
|
1992
2006
|
this.shop = shop;
|
|
2007
|
+
this.productRepository = productRepository;
|
|
1993
2008
|
this.productSearch = productSearch;
|
|
2009
|
+
this.logRepository = logRepository;
|
|
1994
2010
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
1995
2011
|
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch);
|
|
1996
2012
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
@@ -2038,13 +2054,14 @@ class WishlistService {
|
|
|
2038
2054
|
},
|
|
2039
2055
|
})
|
|
2040
2056
|
.then((res) => res.data);
|
|
2057
|
+
await this.createWishlistLog(WishlistLogType.CREATE, data);
|
|
2041
2058
|
if (hasWishlist.length)
|
|
2042
2059
|
return hasWishlist.at(0);
|
|
2043
2060
|
const newWishlist = await this.wishlistRepository.create(data);
|
|
2044
2061
|
await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
|
|
2045
2062
|
return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
|
|
2046
2063
|
}
|
|
2047
|
-
update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2064
|
+
async update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
|
|
2048
2065
|
const data = {
|
|
2049
2066
|
id,
|
|
2050
2067
|
name: title,
|
|
@@ -2064,9 +2081,12 @@ class WishlistService {
|
|
|
2064
2081
|
personType: personType ?? PersonTypes.NONE,
|
|
2065
2082
|
personIsSubscriber: personIsSubscriber ?? false,
|
|
2066
2083
|
};
|
|
2084
|
+
await this.createWishlistLog(WishlistLogType.UPDATE, data);
|
|
2067
2085
|
return this.wishlistRepository.update(data);
|
|
2068
2086
|
}
|
|
2069
|
-
delete(wishlistId) {
|
|
2087
|
+
async delete(wishlistId) {
|
|
2088
|
+
const wishlist = await this.findById(wishlistId);
|
|
2089
|
+
await this.createWishlistLog(WishlistLogType.DELETE, wishlist);
|
|
2070
2090
|
return this.wishlistRepository.delete({ id: wishlistId });
|
|
2071
2091
|
}
|
|
2072
2092
|
getWishlistBySlug(slug) {
|
|
@@ -2081,6 +2101,9 @@ class WishlistService {
|
|
|
2081
2101
|
async addProduct(wishlistId, productId) {
|
|
2082
2102
|
const wishlist = await this.wishlistRepository.get({ id: wishlistId });
|
|
2083
2103
|
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
2104
|
+
const wishlistData = await this.findById(wishlistId);
|
|
2105
|
+
const productData = await this.findProductById(productId);
|
|
2106
|
+
await this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData);
|
|
2084
2107
|
if (!hasProduct) {
|
|
2085
2108
|
wishlist.products = [...wishlist.products, productId];
|
|
2086
2109
|
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
@@ -2092,14 +2115,91 @@ class WishlistService {
|
|
|
2092
2115
|
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
2093
2116
|
if (productIndex != -1) {
|
|
2094
2117
|
wishlist.products.splice(productIndex, 1);
|
|
2118
|
+
const wishlistData = await this.findById(wishlistId);
|
|
2119
|
+
const productData = await this.findProductById(productId);
|
|
2120
|
+
await this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData);
|
|
2095
2121
|
if (!wishlist.products.length)
|
|
2096
2122
|
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
2097
2123
|
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
2098
2124
|
}
|
|
2099
2125
|
return wishlist;
|
|
2100
2126
|
}
|
|
2127
|
+
async findById(id) {
|
|
2128
|
+
return this.wishlistRepository
|
|
2129
|
+
.find({
|
|
2130
|
+
fields: ['id', 'name', 'description', 'personId', 'personIsSubscriber', 'personType', 'personName'],
|
|
2131
|
+
filters: {
|
|
2132
|
+
id,
|
|
2133
|
+
},
|
|
2134
|
+
})
|
|
2135
|
+
.then((res) => res.data.at(0));
|
|
2136
|
+
}
|
|
2137
|
+
async findProductById(id) {
|
|
2138
|
+
return this.productRepository
|
|
2139
|
+
.find({
|
|
2140
|
+
fields: ['id', 'sku', 'EAN', 'name', 'brand'],
|
|
2141
|
+
filters: {
|
|
2142
|
+
id,
|
|
2143
|
+
},
|
|
2144
|
+
})
|
|
2145
|
+
.then((res) => res.data.at(0));
|
|
2146
|
+
}
|
|
2147
|
+
async createWishlistLog(type, wishlist, product) {
|
|
2148
|
+
switch (type) {
|
|
2149
|
+
case WishlistLogType.CREATE:
|
|
2150
|
+
case WishlistLogType.UPDATE:
|
|
2151
|
+
case WishlistLogType.DELETE:
|
|
2152
|
+
await this.logRepository.create({
|
|
2153
|
+
collection: 'wishlist',
|
|
2154
|
+
date: new Date(),
|
|
2155
|
+
operation: WishlistLogType.CREATE ? 'CREATE' : WishlistLogType.UPDATE ? 'UPDATE' : 'DELETE',
|
|
2156
|
+
documentId: wishlist.id,
|
|
2157
|
+
document: {
|
|
2158
|
+
id: wishlist.id,
|
|
2159
|
+
shop: this.shop,
|
|
2160
|
+
name: wishlist.name,
|
|
2161
|
+
description: wishlist.description,
|
|
2162
|
+
published: wishlist.published,
|
|
2163
|
+
type: type,
|
|
2164
|
+
personType: wishlist.personType,
|
|
2165
|
+
personId: wishlist.personId,
|
|
2166
|
+
personName: wishlist.personName,
|
|
2167
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2168
|
+
},
|
|
2169
|
+
});
|
|
2170
|
+
break;
|
|
2171
|
+
case WishlistLogType.ADD_PRODUCT:
|
|
2172
|
+
case WishlistLogType.REMOVE_PRODUCT:
|
|
2173
|
+
await this.logRepository.create({
|
|
2174
|
+
collection: 'wishlist',
|
|
2175
|
+
date: new Date(),
|
|
2176
|
+
operation: 'UPDATE',
|
|
2177
|
+
documentId: wishlist.id,
|
|
2178
|
+
document: {
|
|
2179
|
+
id: wishlist.id,
|
|
2180
|
+
shop: this.shop,
|
|
2181
|
+
name: wishlist.name,
|
|
2182
|
+
description: wishlist.description,
|
|
2183
|
+
published: wishlist.published,
|
|
2184
|
+
type: type,
|
|
2185
|
+
personType: wishlist.personType,
|
|
2186
|
+
personId: wishlist.personId,
|
|
2187
|
+
personName: wishlist.personName,
|
|
2188
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2189
|
+
productId: product.id,
|
|
2190
|
+
productEAN: product.EAN,
|
|
2191
|
+
productSKU: product.sku,
|
|
2192
|
+
productName: product.name,
|
|
2193
|
+
productBrand: product.brand,
|
|
2194
|
+
},
|
|
2195
|
+
});
|
|
2196
|
+
break;
|
|
2197
|
+
default:
|
|
2198
|
+
break;
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2101
2201
|
}
|
|
2102
|
-
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 });
|
|
2202
|
+
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 });
|
|
2103
2203
|
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
|
|
2104
2204
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
|
|
2105
2205
|
type: Injectable
|
|
@@ -2124,6 +2224,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2124
2224
|
}] }, { type: undefined, decorators: [{
|
|
2125
2225
|
type: Inject,
|
|
2126
2226
|
args: ['ProductSearch']
|
|
2227
|
+
}] }, { type: undefined, decorators: [{
|
|
2228
|
+
type: Inject,
|
|
2229
|
+
args: ['LogRepository']
|
|
2127
2230
|
}] }]; } });
|
|
2128
2231
|
|
|
2129
2232
|
class CheckoutSubscriptionService {
|
|
@@ -2251,10 +2354,10 @@ class HomeShopService {
|
|
|
2251
2354
|
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
2252
2355
|
}
|
|
2253
2356
|
getDiscoverProducts(gender) {
|
|
2254
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories,
|
|
2357
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2255
2358
|
}
|
|
2256
2359
|
getFeaturedProducts(gender) {
|
|
2257
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories,
|
|
2360
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2258
2361
|
}
|
|
2259
2362
|
getVerticalProducts(gender) {
|
|
2260
2363
|
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({
|