@infrab4a/connect-angular 4.3.0-beta.2 → 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/consts/storage-base-url.const.mjs +2 -0
- package/esm2020/services/cart.service.mjs +3 -3
- package/esm2020/services/catalog/catalog.service.mjs +15 -8
- package/fesm2015/infrab4a-connect-angular.mjs +36 -11
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +39 -11
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -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, 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';
|
|
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
|
}] });
|
|
@@ -1385,8 +1405,8 @@ class CartService {
|
|
|
1385
1405
|
return { ...checkout, lineItems: notGiftItems };
|
|
1386
1406
|
const elegibleCampaigns = [];
|
|
1387
1407
|
for (const campaign of campaigns) {
|
|
1388
|
-
const today = new Date().
|
|
1389
|
-
if (!(campaign.startDate.
|
|
1408
|
+
const today = new Date().getTime();
|
|
1409
|
+
if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
|
|
1390
1410
|
continue;
|
|
1391
1411
|
if (campaign.activeCategory) {
|
|
1392
1412
|
const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
|
|
@@ -1588,20 +1608,27 @@ class CatalogService {
|
|
|
1588
1608
|
}
|
|
1589
1609
|
async findCatalogByTermAndSortByMostRevelant(options, limits) {
|
|
1590
1610
|
const productIds = await this.findCatalogIdsByElasticSearch(options.term);
|
|
1591
|
-
const limitedProductId = productIds.slice(limits.offset, limits.offset + limits.limit);
|
|
1592
|
-
const productResult = await this.productRepository.findCatalog({
|
|
1593
|
-
filters: { id: { operator: Where.IN, value: limitedProductId } },
|
|
1594
|
-
}, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
1595
1611
|
const totalResult = await this.productRepository.findCatalog({
|
|
1596
1612
|
fields: ['id'],
|
|
1597
|
-
filters: {
|
|
1598
|
-
|
|
1613
|
+
filters: {
|
|
1614
|
+
id: { operator: Where.IN, value: productIds },
|
|
1615
|
+
...this.buildFilterQuery(options?.filters || {}),
|
|
1616
|
+
},
|
|
1599
1617
|
options: {
|
|
1600
1618
|
minimal: ['price'],
|
|
1601
1619
|
maximum: ['price'],
|
|
1602
1620
|
distinct: ['brand'],
|
|
1603
1621
|
},
|
|
1604
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
|
+
});
|
|
1605
1632
|
return {
|
|
1606
1633
|
data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
|
|
1607
1634
|
count: totalResult.count,
|
|
@@ -2154,6 +2181,7 @@ class AngularConnectModule {
|
|
|
2154
2181
|
...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
2155
2182
|
...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
2156
2183
|
...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
2184
|
+
...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
|
|
2157
2185
|
],
|
|
2158
2186
|
};
|
|
2159
2187
|
}
|