@infrab4a/connect-angular 4.3.0-beta.1 → 4.3.0-beta.4
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-connect.module.d.ts +1 -0
- package/angular-firestore.module.d.ts +2 -1
- package/consts/storage-base-url.const.d.ts +1 -0
- package/esm2020/angular-connect.module.mjs +3 -1
- package/esm2020/angular-firestore.module.mjs +23 -4
- package/esm2020/angular-hasura-graphql.module.mjs +24 -2
- package/esm2020/consts/storage-base-url.const.mjs +2 -0
- package/esm2020/services/cart.service.mjs +3 -3
- package/esm2020/services/catalog/catalog.service.mjs +47 -1
- package/fesm2015/infrab4a-connect-angular.mjs +95 -5
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +94 -5
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
- package/services/catalog/catalog.service.d.ts +3 -0
|
@@ -3,12 +3,14 @@ import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angu
|
|
|
3
3
|
import * as i1$4 from '@angular/fire/app';
|
|
4
4
|
import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
|
|
5
5
|
import * as i1$2 from '@infrab4a/connect';
|
|
6
|
-
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, 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, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
|
|
6
|
+
import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, 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, FirebaseFileUploaderService, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order } from '@infrab4a/connect';
|
|
7
7
|
import * as i1 from '@angular/fire/auth';
|
|
8
8
|
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
9
9
|
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
|
|
10
10
|
import * as i1$1 from '@angular/fire/firestore';
|
|
11
11
|
import { Firestore, provideFirestore, getFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
|
|
12
|
+
import * as i2 from '@angular/fire/storage';
|
|
13
|
+
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
12
14
|
import { combineLatest, from, of, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
13
15
|
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
14
16
|
import cookie from 'js-cookie';
|
|
@@ -167,6 +169,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
167
169
|
}]
|
|
168
170
|
}] });
|
|
169
171
|
|
|
172
|
+
const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
|
|
173
|
+
|
|
170
174
|
class MobileOperationSystemCheckerHelper {
|
|
171
175
|
static isAppleDevice() {
|
|
172
176
|
return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
|
|
@@ -187,7 +191,7 @@ class AngularFirestoreModule {
|
|
|
187
191
|
}
|
|
188
192
|
}
|
|
189
193
|
AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
190
|
-
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule] });
|
|
194
|
+
AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule, i2.StorageModule] });
|
|
191
195
|
AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
|
|
192
196
|
{
|
|
193
197
|
provide: 'FirestoreOptions',
|
|
@@ -400,6 +404,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
400
404
|
},
|
|
401
405
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
402
406
|
},
|
|
407
|
+
{
|
|
408
|
+
provide: 'FileUploaderService',
|
|
409
|
+
useFactory: (storage, baseUrl) => {
|
|
410
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
411
|
+
},
|
|
412
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
413
|
+
},
|
|
403
414
|
], imports: [AngularElasticSeachModule,
|
|
404
415
|
provideFirestore((injector) => {
|
|
405
416
|
const platformId = injector.get(PLATFORM_ID);
|
|
@@ -412,7 +423,8 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
412
423
|
localCache: memoryLocalCache(),
|
|
413
424
|
});
|
|
414
425
|
return firestore;
|
|
415
|
-
})
|
|
426
|
+
}),
|
|
427
|
+
provideStorage(() => getStorage())] });
|
|
416
428
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
|
|
417
429
|
type: NgModule,
|
|
418
430
|
args: [{
|
|
@@ -430,6 +442,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
430
442
|
});
|
|
431
443
|
return firestore;
|
|
432
444
|
}),
|
|
445
|
+
provideStorage(() => getStorage()),
|
|
433
446
|
],
|
|
434
447
|
providers: [
|
|
435
448
|
{
|
|
@@ -643,6 +656,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
643
656
|
},
|
|
644
657
|
deps: ['FirestoreOptions', ProductFirestoreRepository],
|
|
645
658
|
},
|
|
659
|
+
{
|
|
660
|
+
provide: 'FileUploaderService',
|
|
661
|
+
useFactory: (storage, baseUrl) => {
|
|
662
|
+
return new FirebaseFileUploaderService(storage, baseUrl);
|
|
663
|
+
},
|
|
664
|
+
deps: [Storage, STORAGE_BASE_URL],
|
|
665
|
+
},
|
|
646
666
|
],
|
|
647
667
|
}]
|
|
648
668
|
}] });
|
|
@@ -703,6 +723,17 @@ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.
|
|
|
703
723
|
},
|
|
704
724
|
deps: ['HasuraConfig'],
|
|
705
725
|
},
|
|
726
|
+
{
|
|
727
|
+
provide: 'ProductReviewsRepository',
|
|
728
|
+
useExisting: ProductReviewsHasuraGraphQLRepository,
|
|
729
|
+
},
|
|
730
|
+
{
|
|
731
|
+
provide: ProductReviewsHasuraGraphQLRepository,
|
|
732
|
+
useFactory: (hasuraConfig) => {
|
|
733
|
+
return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
|
|
734
|
+
},
|
|
735
|
+
deps: ['HasuraConfig'],
|
|
736
|
+
},
|
|
706
737
|
{
|
|
707
738
|
provide: 'VariantRepository',
|
|
708
739
|
useExisting: VariantHasuraGraphQLRepository,
|
|
@@ -817,6 +848,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
817
848
|
},
|
|
818
849
|
deps: ['HasuraConfig'],
|
|
819
850
|
},
|
|
851
|
+
{
|
|
852
|
+
provide: 'ProductReviewsRepository',
|
|
853
|
+
useExisting: ProductReviewsHasuraGraphQLRepository,
|
|
854
|
+
},
|
|
855
|
+
{
|
|
856
|
+
provide: ProductReviewsHasuraGraphQLRepository,
|
|
857
|
+
useFactory: (hasuraConfig) => {
|
|
858
|
+
return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
|
|
859
|
+
},
|
|
860
|
+
deps: ['HasuraConfig'],
|
|
861
|
+
},
|
|
820
862
|
{
|
|
821
863
|
provide: 'VariantRepository',
|
|
822
864
|
useExisting: VariantHasuraGraphQLRepository,
|
|
@@ -1363,8 +1405,8 @@ class CartService {
|
|
|
1363
1405
|
return { ...checkout, lineItems: notGiftItems };
|
|
1364
1406
|
const elegibleCampaigns = [];
|
|
1365
1407
|
for (const campaign of campaigns) {
|
|
1366
|
-
const today = new Date().
|
|
1367
|
-
if (!(campaign.startDate.
|
|
1408
|
+
const today = new Date().getTime();
|
|
1409
|
+
if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
|
|
1368
1410
|
continue;
|
|
1369
1411
|
if (campaign.activeCategory) {
|
|
1370
1412
|
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
@@ -1464,6 +1506,7 @@ class CatalogService {
|
|
|
1464
1506
|
this.categoryStructureAdapter = categoryStructureAdapter;
|
|
1465
1507
|
this.shop = shop;
|
|
1466
1508
|
this.productIndex = productIndex;
|
|
1509
|
+
this.productsByTerm = {};
|
|
1467
1510
|
this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
|
|
1468
1511
|
const filters = {};
|
|
1469
1512
|
if (clubDiscount?.length)
|
|
@@ -1534,6 +1577,8 @@ class CatalogService {
|
|
|
1534
1577
|
}));
|
|
1535
1578
|
}
|
|
1536
1579
|
async findCatalog(options, limits) {
|
|
1580
|
+
if (this.hasTerm(options) && options.sort === 'most-relevant')
|
|
1581
|
+
return this.findCatalogByTermAndSortByMostRevelant(options, limits);
|
|
1537
1582
|
const repoParams = {
|
|
1538
1583
|
filters: {
|
|
1539
1584
|
...(await this.buildMainFilter(options)),
|
|
@@ -1561,6 +1606,49 @@ class CatalogService {
|
|
|
1561
1606
|
.search(term, 999, this.shop)
|
|
1562
1607
|
.then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
|
|
1563
1608
|
}
|
|
1609
|
+
async findCatalogByTermAndSortByMostRevelant(options, limits) {
|
|
1610
|
+
const productIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1611
|
+
const totalResult = await this.productRepository.findCatalog({
|
|
1612
|
+
fields: ['id'],
|
|
1613
|
+
filters: {
|
|
1614
|
+
id: { operator: Where.IN, value: productIds },
|
|
1615
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1616
|
+
},
|
|
1617
|
+
options: {
|
|
1618
|
+
minimal: ['price'],
|
|
1619
|
+
maximum: ['price'],
|
|
1620
|
+
distinct: ['brand'],
|
|
1621
|
+
},
|
|
1622
|
+
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1623
|
+
const limitedProductId = totalResult.data
|
|
1624
|
+
.slice(limits.offset, limits.offset + limits.limit)
|
|
1625
|
+
.map((product) => product.id);
|
|
1626
|
+
const orderedId = productIds.filter((product) => limitedProductId.includes(product));
|
|
1627
|
+
const productResult = await this.productRepository.findCatalog({
|
|
1628
|
+
filters: {
|
|
1629
|
+
id: { operator: Where.IN, value: orderedId },
|
|
1630
|
+
},
|
|
1631
|
+
});
|
|
1632
|
+
return {
|
|
1633
|
+
data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1634
|
+
count: totalResult.count,
|
|
1635
|
+
maximum: totalResult.maximum,
|
|
1636
|
+
minimal: totalResult.minimal,
|
|
1637
|
+
distinct: totalResult.distinct,
|
|
1638
|
+
};
|
|
1639
|
+
}
|
|
1640
|
+
async findCatalogIdsByElasticSearch(term) {
|
|
1641
|
+
if (this.productsByTerm[term])
|
|
1642
|
+
return this.productsByTerm[term];
|
|
1643
|
+
return (this.productsByTerm[term] = await this.productIndex
|
|
1644
|
+
.search(term, 999, this.shop)
|
|
1645
|
+
.then(({ hits: products }) => {
|
|
1646
|
+
const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
|
|
1647
|
+
const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
|
|
1648
|
+
const sorted = [...withStock, ...withOutStock];
|
|
1649
|
+
return [...new Set(sorted.map(({ _source }) => _source.id))];
|
|
1650
|
+
}));
|
|
1651
|
+
}
|
|
1564
1652
|
}
|
|
1565
1653
|
CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1566
1654
|
CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
|
|
@@ -2093,6 +2181,7 @@ class AngularConnectModule {
|
|
|
2093
2181
|
...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
2094
2182
|
...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
2095
2183
|
...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
2184
|
+
...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
|
|
2096
2185
|
],
|
|
2097
2186
|
};
|
|
2098
2187
|
}
|