@infrab4a/connect-angular 5.0.0-beta.93 → 5.0.0-beta.95
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-hasura-graphql.module.d.ts +3 -5
- package/esm2022/angular-firebase-auth.module.mjs +4 -4
- package/esm2022/angular-hasura-graphql.module.mjs +3 -1
- package/esm2022/services/catalog/catalog.service.mjs +40 -10
- package/esm2022/services/catalog/category.service.mjs +6 -6
- package/fesm2022/infrab4a-connect-angular.mjs +49 -17
- package/fesm2022/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +5 -2
- package/services/catalog/category.service.d.ts +7 -3
|
@@ -9,7 +9,7 @@ import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
|
9
9
|
import * as i1$3 from '@infrab4a/connect';
|
|
10
10
|
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, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductErrorsHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where, set, InvalidArgumentError, RoundProductPricesHelper, isEmpty, Shops, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
11
11
|
import * as i1 from '@angular/fire/auth';
|
|
12
|
-
import { Auth, provideAuth, initializeAuth, indexedDBLocalPersistence, browserLocalPersistence, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
12
|
+
import { Auth, provideAuth, initializeAuth, indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
13
13
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
14
14
|
import * as i1$1 from '@angular/fire/firestore';
|
|
15
15
|
import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
@@ -127,7 +127,7 @@ class AngularFirebaseAuthModule {
|
|
|
127
127
|
const app = injector.get(FirebaseApp);
|
|
128
128
|
try {
|
|
129
129
|
return initializeAuth(app, {
|
|
130
|
-
persistence: [indexedDBLocalPersistence, browserLocalPersistence],
|
|
130
|
+
persistence: [indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence],
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
catch (error) {
|
|
@@ -145,7 +145,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
145
145
|
const app = injector.get(FirebaseApp);
|
|
146
146
|
try {
|
|
147
147
|
return initializeAuth(app, {
|
|
148
|
-
persistence: [indexedDBLocalPersistence, browserLocalPersistence],
|
|
148
|
+
persistence: [indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence],
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
catch (error) {
|
|
@@ -741,6 +741,7 @@ class AngularHasuraGraphQLModule {
|
|
|
741
741
|
useFactory: (options, platformId) => ({
|
|
742
742
|
endpoint: options.endpoint,
|
|
743
743
|
authOptions: options.credentials,
|
|
744
|
+
cache: options.cache,
|
|
744
745
|
interceptors: {
|
|
745
746
|
request: (request) => {
|
|
746
747
|
if (isPlatformBrowser(platformId))
|
|
@@ -900,6 +901,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImpor
|
|
|
900
901
|
useFactory: (options, platformId) => ({
|
|
901
902
|
endpoint: options.endpoint,
|
|
902
903
|
authOptions: options.credentials,
|
|
904
|
+
cache: options.cache,
|
|
903
905
|
interceptors: {
|
|
904
906
|
request: (request) => {
|
|
905
907
|
if (isPlatformBrowser(platformId))
|
|
@@ -1388,6 +1390,33 @@ class CatalogService {
|
|
|
1388
1390
|
this.productSearch = productSearch;
|
|
1389
1391
|
this.productsByTerm = {};
|
|
1390
1392
|
this.brandsList = {};
|
|
1393
|
+
this.fields = [
|
|
1394
|
+
'id',
|
|
1395
|
+
'name',
|
|
1396
|
+
'slug',
|
|
1397
|
+
'images',
|
|
1398
|
+
'miniatures',
|
|
1399
|
+
'price',
|
|
1400
|
+
'stock',
|
|
1401
|
+
'published',
|
|
1402
|
+
'CEST',
|
|
1403
|
+
'EAN',
|
|
1404
|
+
'NCM',
|
|
1405
|
+
'brand',
|
|
1406
|
+
'costPrice',
|
|
1407
|
+
'hasVariants',
|
|
1408
|
+
'isKit',
|
|
1409
|
+
'sku',
|
|
1410
|
+
'rate',
|
|
1411
|
+
'tags',
|
|
1412
|
+
'type',
|
|
1413
|
+
'shoppingCount',
|
|
1414
|
+
'gender',
|
|
1415
|
+
'createdAt',
|
|
1416
|
+
'label',
|
|
1417
|
+
'outlet',
|
|
1418
|
+
'group',
|
|
1419
|
+
];
|
|
1391
1420
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1392
1421
|
const filters = {};
|
|
1393
1422
|
if (clubDiscount?.length)
|
|
@@ -1450,7 +1479,7 @@ class CatalogService {
|
|
|
1450
1479
|
return '';
|
|
1451
1480
|
};
|
|
1452
1481
|
}
|
|
1453
|
-
async fetchProducts(options) {
|
|
1482
|
+
async fetchProducts(options, optionsCache) {
|
|
1454
1483
|
const limits = this.buildLimitQuery(options);
|
|
1455
1484
|
if (this.hasProfile(options) && options.filters?.customOptions)
|
|
1456
1485
|
throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
|
|
@@ -1458,7 +1487,7 @@ class CatalogService {
|
|
|
1458
1487
|
throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
|
|
1459
1488
|
if (this.hasTerm(options) && options.filters?.customOptions)
|
|
1460
1489
|
throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
|
|
1461
|
-
return await this.findCatalog(options, limits).then(async ({ data, count: total, maximum, minimal, distinct }) => {
|
|
1490
|
+
return await this.findCatalog(options, limits, optionsCache).then(async ({ data, count: total, maximum, minimal, distinct }) => {
|
|
1462
1491
|
await this.setBrandsList(options, distinct?.brand);
|
|
1463
1492
|
return {
|
|
1464
1493
|
products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
|
|
@@ -1477,7 +1506,7 @@ class CatalogService {
|
|
|
1477
1506
|
async addCustomerToStockNotification(shop, productId, name, email) {
|
|
1478
1507
|
return this.productStockNotificationRepository.addCustomerEmail(shop, productId, name, email);
|
|
1479
1508
|
}
|
|
1480
|
-
async findCatalog(options, limits) {
|
|
1509
|
+
async findCatalog(options, limits, optionsCache) {
|
|
1481
1510
|
if (this.hasTerm(options) && options.sort === 'most-relevant') {
|
|
1482
1511
|
const productsIds = await this.findCatalogIdsBySearch(options.term);
|
|
1483
1512
|
return this.findCatalogAndSortByMostRevelantByTerm(productsIds, options, limits);
|
|
@@ -1491,11 +1520,12 @@ class CatalogService {
|
|
|
1491
1520
|
...(await this.buildMainFilter(options)),
|
|
1492
1521
|
...this.buildFilterQuery(options?.filters || {}),
|
|
1493
1522
|
},
|
|
1494
|
-
})
|
|
1523
|
+
}, undefined, optionsCache)
|
|
1495
1524
|
.then((products) => products.data.map((product) => product.id));
|
|
1496
|
-
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits);
|
|
1525
|
+
return this.findCatalogAndSortByMostRevelant(mostRelevant, productsIds, options, limits, optionsCache);
|
|
1497
1526
|
}
|
|
1498
1527
|
const repoParams = {
|
|
1528
|
+
fields: this.fields,
|
|
1499
1529
|
filters: {
|
|
1500
1530
|
...(await this.buildMainFilter(options)),
|
|
1501
1531
|
...this.buildFilterQuery(options?.filters || {}),
|
|
@@ -1511,8 +1541,8 @@ class CatalogService {
|
|
|
1511
1541
|
},
|
|
1512
1542
|
};
|
|
1513
1543
|
if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
|
|
1514
|
-
return this.productRepository.findCatalog(repoParams);
|
|
1515
|
-
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1544
|
+
return this.productRepository.findCatalog(repoParams, undefined, optionsCache);
|
|
1545
|
+
return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
1516
1546
|
}
|
|
1517
1547
|
async buildMainFilter({ category, profile, term, }) {
|
|
1518
1548
|
if (category)
|
|
@@ -1524,10 +1554,11 @@ class CatalogService {
|
|
|
1524
1554
|
.search(term, 999, this.shop == Shops.GLAMSHOP ? 'female' : 'male')
|
|
1525
1555
|
.then((data) => ({ id: { operator: Where.IN, value: data.map((_source) => _source.id) } }));
|
|
1526
1556
|
}
|
|
1527
|
-
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits) {
|
|
1557
|
+
async findCatalogAndSortByMostRevelant(mostRelevants, productIds, options, limits, optionsCache) {
|
|
1528
1558
|
const brandsList = this.brandsList[this.buildIndexBrands(options)];
|
|
1529
1559
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
|
|
1530
1560
|
const totalResult = await this.productRepository.findCatalog({
|
|
1561
|
+
fields: this.fields,
|
|
1531
1562
|
filters: {
|
|
1532
1563
|
id: { operator: Where.IN, value: mostRelevantProductsIds },
|
|
1533
1564
|
...this.buildFilterQuery(options?.filters || {}),
|
|
@@ -1538,7 +1569,7 @@ class CatalogService {
|
|
|
1538
1569
|
maximum: ['price'],
|
|
1539
1570
|
...(!brandsList && isEmpty(options.filters?.brands) ? { distinct: ['brand'] } : {}),
|
|
1540
1571
|
},
|
|
1541
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1572
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
1542
1573
|
const mostRelevantWithouyStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
1543
1574
|
const firstProducts = totalResult.data
|
|
1544
1575
|
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
@@ -1594,6 +1625,7 @@ class CatalogService {
|
|
|
1594
1625
|
filters: {
|
|
1595
1626
|
id: { operator: Where.IN, value: orderedId },
|
|
1596
1627
|
},
|
|
1628
|
+
fields: this.fields,
|
|
1597
1629
|
});
|
|
1598
1630
|
await this.setBrandsList(options, totalResult.distinct?.brand);
|
|
1599
1631
|
return {
|
|
@@ -1676,20 +1708,20 @@ class CategoryService {
|
|
|
1676
1708
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1677
1709
|
this.shop = shop;
|
|
1678
1710
|
}
|
|
1679
|
-
async fetchBrands(category, options) {
|
|
1711
|
+
async fetchBrands(category, options, optionsCache) {
|
|
1680
1712
|
const brands = await this.productRepository
|
|
1681
1713
|
.findCatalog({
|
|
1682
1714
|
filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
|
|
1683
1715
|
fields: ['brand'],
|
|
1684
|
-
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
|
|
1716
|
+
}, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache)
|
|
1685
1717
|
.then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
|
|
1686
1718
|
return this.categoryRepository
|
|
1687
|
-
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
|
|
1719
|
+
.find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } }, optionsCache)
|
|
1688
1720
|
.then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
|
|
1689
1721
|
}
|
|
1690
|
-
async fetchFilterOptions(category) {
|
|
1722
|
+
async fetchFilterOptions(category, optionsCache) {
|
|
1691
1723
|
return await this.categoryFilterRepository
|
|
1692
|
-
.find({ filters: { categoryId: +category.id } })
|
|
1724
|
+
.find({ filters: { categoryId: +category.id } }, optionsCache)
|
|
1693
1725
|
.then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
|
|
1694
1726
|
}
|
|
1695
1727
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
|