@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';
|
|
@@ -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
|
}] });
|
|
@@ -2030,10 +2044,12 @@ __decorate([
|
|
|
2030
2044
|
], CategoryWithTree.prototype, "children", void 0);
|
|
2031
2045
|
|
|
2032
2046
|
class WishlistService {
|
|
2033
|
-
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch) {
|
|
2047
|
+
constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productStockNotificationRepository, productSearch, logRepository) {
|
|
2034
2048
|
this.wishlistRepository = wishlistRepository;
|
|
2035
2049
|
this.shop = shop;
|
|
2050
|
+
this.productRepository = productRepository;
|
|
2036
2051
|
this.productSearch = productSearch;
|
|
2052
|
+
this.logRepository = logRepository;
|
|
2037
2053
|
const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
|
|
2038
2054
|
this.catalogService = new CatalogService(productRepository, productStockNotificationRepository, categoryRepository, categoryStructureAdapter, shop, productSearch);
|
|
2039
2055
|
this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
|
|
@@ -2082,6 +2098,7 @@ class WishlistService {
|
|
|
2082
2098
|
},
|
|
2083
2099
|
})
|
|
2084
2100
|
.then((res) => res.data);
|
|
2101
|
+
yield this.createWishlistLog(WishlistLogType.CREATE, data);
|
|
2085
2102
|
if (hasWishlist.length)
|
|
2086
2103
|
return hasWishlist.at(0);
|
|
2087
2104
|
const newWishlist = yield this.wishlistRepository.create(data);
|
|
@@ -2090,29 +2107,36 @@ class WishlistService {
|
|
|
2090
2107
|
});
|
|
2091
2108
|
}
|
|
2092
2109
|
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
|
-
|
|
2110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2111
|
+
const data = {
|
|
2112
|
+
id,
|
|
2113
|
+
name: title,
|
|
2114
|
+
description,
|
|
2115
|
+
published,
|
|
2116
|
+
metadatas: [
|
|
2117
|
+
{
|
|
2118
|
+
shop: this.shop,
|
|
2119
|
+
title: `${userFullName} - ${title}`,
|
|
2120
|
+
description: `${userFullName} - ${description}`,
|
|
2121
|
+
},
|
|
2122
|
+
],
|
|
2123
|
+
personName: userFullName,
|
|
2124
|
+
personPhoto: userPhoto,
|
|
2125
|
+
theme,
|
|
2126
|
+
bannerUrl,
|
|
2127
|
+
personType: personType !== null && personType !== void 0 ? personType : PersonTypes.NONE,
|
|
2128
|
+
personIsSubscriber: personIsSubscriber !== null && personIsSubscriber !== void 0 ? personIsSubscriber : false,
|
|
2129
|
+
};
|
|
2130
|
+
yield this.createWishlistLog(WishlistLogType.UPDATE, data);
|
|
2131
|
+
return this.wishlistRepository.update(data);
|
|
2132
|
+
});
|
|
2113
2133
|
}
|
|
2114
2134
|
delete(wishlistId) {
|
|
2115
|
-
return this
|
|
2135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2136
|
+
const wishlist = yield this.findById(wishlistId);
|
|
2137
|
+
yield this.createWishlistLog(WishlistLogType.DELETE, wishlist);
|
|
2138
|
+
return this.wishlistRepository.delete({ id: wishlistId });
|
|
2139
|
+
});
|
|
2116
2140
|
}
|
|
2117
2141
|
getWishlistBySlug(slug) {
|
|
2118
2142
|
const [id] = slug.split('-');
|
|
@@ -2127,6 +2151,9 @@ class WishlistService {
|
|
|
2127
2151
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2128
2152
|
const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
|
|
2129
2153
|
const hasProduct = wishlist.products.some((p) => p == productId);
|
|
2154
|
+
const wishlistData = yield this.findById(wishlistId);
|
|
2155
|
+
const productData = yield this.findProductById(productId);
|
|
2156
|
+
yield this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData);
|
|
2130
2157
|
if (!hasProduct) {
|
|
2131
2158
|
wishlist.products = [...wishlist.products, productId];
|
|
2132
2159
|
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
@@ -2140,6 +2167,9 @@ class WishlistService {
|
|
|
2140
2167
|
const productIndex = wishlist.products.findIndex((p) => p == productId);
|
|
2141
2168
|
if (productIndex != -1) {
|
|
2142
2169
|
wishlist.products.splice(productIndex, 1);
|
|
2170
|
+
const wishlistData = yield this.findById(wishlistId);
|
|
2171
|
+
const productData = yield this.findProductById(productId);
|
|
2172
|
+
yield this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData);
|
|
2143
2173
|
if (!wishlist.products.length)
|
|
2144
2174
|
return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
|
|
2145
2175
|
return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
|
|
@@ -2147,8 +2177,88 @@ class WishlistService {
|
|
|
2147
2177
|
return wishlist;
|
|
2148
2178
|
});
|
|
2149
2179
|
}
|
|
2180
|
+
findById(id) {
|
|
2181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2182
|
+
return this.wishlistRepository
|
|
2183
|
+
.find({
|
|
2184
|
+
fields: ['id', 'name', 'description', 'personId', 'personIsSubscriber', 'personType', 'personName'],
|
|
2185
|
+
filters: {
|
|
2186
|
+
id,
|
|
2187
|
+
},
|
|
2188
|
+
})
|
|
2189
|
+
.then((res) => res.data.at(0));
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
2192
|
+
findProductById(id) {
|
|
2193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2194
|
+
return this.productRepository
|
|
2195
|
+
.find({
|
|
2196
|
+
fields: ['id', 'sku', 'EAN', 'name', 'brand'],
|
|
2197
|
+
filters: {
|
|
2198
|
+
id,
|
|
2199
|
+
},
|
|
2200
|
+
})
|
|
2201
|
+
.then((res) => res.data.at(0));
|
|
2202
|
+
});
|
|
2203
|
+
}
|
|
2204
|
+
createWishlistLog(type, wishlist, product) {
|
|
2205
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2206
|
+
switch (type) {
|
|
2207
|
+
case WishlistLogType.CREATE:
|
|
2208
|
+
case WishlistLogType.UPDATE:
|
|
2209
|
+
case WishlistLogType.DELETE:
|
|
2210
|
+
yield this.logRepository.create({
|
|
2211
|
+
collection: 'wishlist',
|
|
2212
|
+
date: new Date(),
|
|
2213
|
+
operation: WishlistLogType.CREATE ? 'CREATE' : WishlistLogType.UPDATE ? 'UPDATE' : 'DELETE',
|
|
2214
|
+
documentId: wishlist.id,
|
|
2215
|
+
document: {
|
|
2216
|
+
id: wishlist.id,
|
|
2217
|
+
shop: this.shop,
|
|
2218
|
+
name: wishlist.name,
|
|
2219
|
+
description: wishlist.description,
|
|
2220
|
+
published: wishlist.published,
|
|
2221
|
+
type: type,
|
|
2222
|
+
personType: wishlist.personType,
|
|
2223
|
+
personId: wishlist.personId,
|
|
2224
|
+
personName: wishlist.personName,
|
|
2225
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2226
|
+
},
|
|
2227
|
+
});
|
|
2228
|
+
break;
|
|
2229
|
+
case WishlistLogType.ADD_PRODUCT:
|
|
2230
|
+
case WishlistLogType.REMOVE_PRODUCT:
|
|
2231
|
+
yield this.logRepository.create({
|
|
2232
|
+
collection: 'wishlist',
|
|
2233
|
+
date: new Date(),
|
|
2234
|
+
operation: 'UPDATE',
|
|
2235
|
+
documentId: wishlist.id,
|
|
2236
|
+
document: {
|
|
2237
|
+
id: wishlist.id,
|
|
2238
|
+
shop: this.shop,
|
|
2239
|
+
name: wishlist.name,
|
|
2240
|
+
description: wishlist.description,
|
|
2241
|
+
published: wishlist.published,
|
|
2242
|
+
type: type,
|
|
2243
|
+
personType: wishlist.personType,
|
|
2244
|
+
personId: wishlist.personId,
|
|
2245
|
+
personName: wishlist.personName,
|
|
2246
|
+
personIsSubscriber: wishlist.personIsSubscriber,
|
|
2247
|
+
productId: product.id,
|
|
2248
|
+
productEAN: product.EAN,
|
|
2249
|
+
productSKU: product.sku,
|
|
2250
|
+
productName: product.name,
|
|
2251
|
+
productBrand: product.brand,
|
|
2252
|
+
},
|
|
2253
|
+
});
|
|
2254
|
+
break;
|
|
2255
|
+
default:
|
|
2256
|
+
break;
|
|
2257
|
+
}
|
|
2258
|
+
});
|
|
2259
|
+
}
|
|
2150
2260
|
}
|
|
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 });
|
|
2261
|
+
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
2262
|
WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
|
|
2153
2263
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
|
|
2154
2264
|
type: Injectable
|
|
@@ -2174,6 +2284,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2174
2284
|
}] }, { type: undefined, decorators: [{
|
|
2175
2285
|
type: Inject,
|
|
2176
2286
|
args: ['ProductSearch']
|
|
2287
|
+
}] }, { type: undefined, decorators: [{
|
|
2288
|
+
type: Inject,
|
|
2289
|
+
args: ['LogRepository']
|
|
2177
2290
|
}] }];
|
|
2178
2291
|
} });
|
|
2179
2292
|
|
|
@@ -2306,10 +2419,10 @@ class HomeShopService {
|
|
|
2306
2419
|
return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
|
|
2307
2420
|
}
|
|
2308
2421
|
getDiscoverProducts(gender) {
|
|
2309
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories,
|
|
2422
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2310
2423
|
}
|
|
2311
2424
|
getFeaturedProducts(gender) {
|
|
2312
|
-
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories,
|
|
2425
|
+
return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
|
|
2313
2426
|
}
|
|
2314
2427
|
getVerticalProducts(gender) {
|
|
2315
2428
|
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({
|