@infrab4a/connect-angular 4.17.0 → 4.17.2
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 +3 -2
- package/angular-hasura-graphql.module.d.ts +1 -1
- package/consts/firebase-const.d.ts +1 -1
- package/esm2020/angular-connect.module.mjs +29 -21
- package/esm2020/angular-firebase-auth.module.mjs +30 -4
- package/esm2020/angular-firestore.module.mjs +16 -2
- package/esm2020/angular-hasura-graphql.module.mjs +1 -1
- package/esm2020/consts/firebase-const.mjs +2 -2
- package/esm2020/services/coupon.service.mjs +7 -3
- package/fesm2015/infrab4a-connect-angular.mjs +78 -26
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +78 -26
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -3,13 +3,13 @@ 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 i2 from '@angular/fire/app-check';
|
|
6
|
-
import { provideAppCheck, initializeAppCheck
|
|
6
|
+
import { provideAppCheck, initializeAppCheck } from '@angular/fire/app-check';
|
|
7
7
|
import * as i3 from '@angular/fire/storage';
|
|
8
8
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
9
9
|
import * as i1$2 from '@infrab4a/connect';
|
|
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, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, isEmpty, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
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, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, isEmpty, Category, PersonTypes, WishlistLogType, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
|
|
11
11
|
import * as i1 from '@angular/fire/auth';
|
|
12
|
-
import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
|
|
12
|
+
import { Auth, provideAuth, initializeAuth, indexedDBLocalPersistence, browserLocalPersistence, 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';
|
|
@@ -60,7 +60,7 @@ const DEFAULT_SHOP = 'DEFAULT_SHOP';
|
|
|
60
60
|
|
|
61
61
|
const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
|
|
62
62
|
const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
|
|
63
|
-
const
|
|
63
|
+
const APP_CHECK_PROVIDER = new InjectionToken('appCheckProvider');
|
|
64
64
|
|
|
65
65
|
const HASURA_OPTIONS = 'HASURA_OPTIONS';
|
|
66
66
|
|
|
@@ -124,11 +124,37 @@ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0
|
|
|
124
124
|
},
|
|
125
125
|
deps: ['AuthenticationService'],
|
|
126
126
|
},
|
|
127
|
-
], imports: [provideAuth((injector) =>
|
|
127
|
+
], imports: [provideAuth((injector) => {
|
|
128
|
+
const app = injector.get(FirebaseApp);
|
|
129
|
+
try {
|
|
130
|
+
return initializeAuth(app, {
|
|
131
|
+
persistence: [indexedDBLocalPersistence, browserLocalPersistence],
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
if (error instanceof Error)
|
|
136
|
+
console.error('Error initializing auth', error.message);
|
|
137
|
+
return getAuth(app);
|
|
138
|
+
}
|
|
139
|
+
})] });
|
|
128
140
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
|
|
129
141
|
type: NgModule,
|
|
130
142
|
args: [{
|
|
131
|
-
imports: [
|
|
143
|
+
imports: [
|
|
144
|
+
provideAuth((injector) => {
|
|
145
|
+
const app = injector.get(FirebaseApp);
|
|
146
|
+
try {
|
|
147
|
+
return initializeAuth(app, {
|
|
148
|
+
persistence: [indexedDBLocalPersistence, browserLocalPersistence],
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
if (error instanceof Error)
|
|
153
|
+
console.error('Error initializing auth', error.message);
|
|
154
|
+
return getAuth(app);
|
|
155
|
+
}
|
|
156
|
+
}),
|
|
157
|
+
],
|
|
132
158
|
providers: [
|
|
133
159
|
{
|
|
134
160
|
provide: 'Authentication',
|
|
@@ -423,6 +449,13 @@ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0",
|
|
|
423
449
|
},
|
|
424
450
|
deps: ['FirestoreOptions'],
|
|
425
451
|
},
|
|
452
|
+
{
|
|
453
|
+
provide: 'SequenceRepository',
|
|
454
|
+
useFactory: (options) => {
|
|
455
|
+
return new SequenceFirestoreRepository(options);
|
|
456
|
+
},
|
|
457
|
+
deps: ['FirestoreOptions'],
|
|
458
|
+
},
|
|
426
459
|
], imports: [AngularElasticSeachModule,
|
|
427
460
|
provideFirestore((injector) => {
|
|
428
461
|
const platformId = injector.get(PLATFORM_ID);
|
|
@@ -682,6 +715,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
682
715
|
},
|
|
683
716
|
deps: ['FirestoreOptions'],
|
|
684
717
|
},
|
|
718
|
+
{
|
|
719
|
+
provide: 'SequenceRepository',
|
|
720
|
+
useFactory: (options) => {
|
|
721
|
+
return new SequenceFirestoreRepository(options);
|
|
722
|
+
},
|
|
723
|
+
deps: ['FirestoreOptions'],
|
|
724
|
+
},
|
|
685
725
|
],
|
|
686
726
|
}]
|
|
687
727
|
}] });
|
|
@@ -1165,7 +1205,7 @@ class CouponService {
|
|
|
1165
1205
|
const discount = +(subTotal * ((value > 100 ? 100 : value) / 100)).toFixed(2);
|
|
1166
1206
|
return { discount, lineItems: checkout.lineItems };
|
|
1167
1207
|
}
|
|
1168
|
-
|
|
1208
|
+
const lineItensElegibleForDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
|
|
1169
1209
|
const subTotal = this.calcCheckoutSubtotal(lineItensElegibleForDiscount, checkout.user);
|
|
1170
1210
|
if (type == CouponTypes.ABSOLUTE) {
|
|
1171
1211
|
discount = value > subTotal ? subTotal : value;
|
|
@@ -1179,7 +1219,7 @@ class CouponService {
|
|
|
1179
1219
|
async hasMinSubTotal(coupon, checkout) {
|
|
1180
1220
|
if (!coupon.minSubTotalValue)
|
|
1181
1221
|
return true;
|
|
1182
|
-
|
|
1222
|
+
const lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
|
|
1183
1223
|
const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
|
|
1184
1224
|
if (coupon.minSubTotalValue <= subTotal)
|
|
1185
1225
|
return true;
|
|
@@ -1302,6 +1342,8 @@ class CouponService {
|
|
|
1302
1342
|
if (type === CouponTypes.ABSOLUTE) {
|
|
1303
1343
|
const couponDiscountMax = couponDiscount > subTotal ? subTotal : couponDiscount;
|
|
1304
1344
|
lineItemsDiscount = lineItems.map((item) => {
|
|
1345
|
+
if (item.isGift)
|
|
1346
|
+
return item;
|
|
1305
1347
|
const totalItemPercentage = item.pricePaid / subTotal;
|
|
1306
1348
|
const discountItem = couponDiscountMax * totalItemPercentage;
|
|
1307
1349
|
return {
|
|
@@ -1312,6 +1354,8 @@ class CouponService {
|
|
|
1312
1354
|
}
|
|
1313
1355
|
else {
|
|
1314
1356
|
lineItemsDiscount = lineItems.map((item) => {
|
|
1357
|
+
if (item.isGift)
|
|
1358
|
+
return item;
|
|
1315
1359
|
const discountItem = item.pricePaid * (couponDiscount / 100);
|
|
1316
1360
|
return {
|
|
1317
1361
|
...item,
|
|
@@ -2617,6 +2661,8 @@ class AngularConnectModule {
|
|
|
2617
2661
|
return {
|
|
2618
2662
|
ngModule: AngularConnectModule,
|
|
2619
2663
|
providers: [
|
|
2664
|
+
{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
|
|
2665
|
+
{ provide: APP_CHECK_PROVIDER, useValue: options.appCheckProvider },
|
|
2620
2666
|
{
|
|
2621
2667
|
provide: CATEGORY_STRUCTURE,
|
|
2622
2668
|
useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
|
|
@@ -2626,15 +2672,11 @@ class AngularConnectModule {
|
|
|
2626
2672
|
{ provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
|
|
2627
2673
|
...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
|
|
2628
2674
|
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
|
|
2629
|
-
...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
|
|
2630
2675
|
...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
|
|
2631
2676
|
...(isNil(options?.vertexConfig) ? [] : [{ provide: VERTEX_CONFIG, useValue: options.vertexConfig }]),
|
|
2632
2677
|
...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
|
|
2633
2678
|
...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
|
|
2634
2679
|
...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
|
|
2635
|
-
...(isNil(options?.recaptchaSiteKey)
|
|
2636
|
-
? []
|
|
2637
|
-
: [{ provide: RECAPTCHA_SITE_KEY, useValue: options.recaptchaSiteKey }]),
|
|
2638
2680
|
],
|
|
2639
2681
|
};
|
|
2640
2682
|
}
|
|
@@ -2676,28 +2718,33 @@ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ve
|
|
|
2676
2718
|
useExisting: ProductsVertexSearch,
|
|
2677
2719
|
},
|
|
2678
2720
|
], imports: [provideFirebaseApp((injector) => {
|
|
2679
|
-
const appName = injector.get(FIREBASE_APP_NAME)
|
|
2721
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
2680
2722
|
try {
|
|
2681
|
-
|
|
2723
|
+
const app = appName ? getApp(appName) : getApp();
|
|
2724
|
+
return app;
|
|
2682
2725
|
}
|
|
2683
2726
|
catch (error) {
|
|
2727
|
+
console.warn('Firebase app not found, initializing new app');
|
|
2728
|
+
if (error instanceof Error)
|
|
2729
|
+
console.error(error.message);
|
|
2684
2730
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2685
2731
|
}
|
|
2686
2732
|
}),
|
|
2687
2733
|
provideAppCheck((injector) => {
|
|
2688
2734
|
const app = injector.get(FirebaseApp);
|
|
2689
2735
|
try {
|
|
2690
|
-
const
|
|
2691
|
-
if (
|
|
2736
|
+
const provider = injector.get(APP_CHECK_PROVIDER);
|
|
2737
|
+
if (provider)
|
|
2692
2738
|
return initializeAppCheck(app, {
|
|
2693
|
-
provider
|
|
2739
|
+
provider,
|
|
2694
2740
|
isTokenAutoRefreshEnabled: true,
|
|
2695
2741
|
});
|
|
2696
2742
|
}
|
|
2697
2743
|
catch (error) {
|
|
2698
|
-
|
|
2744
|
+
if (error instanceof Error)
|
|
2745
|
+
console.error(error.message);
|
|
2746
|
+
return;
|
|
2699
2747
|
}
|
|
2700
|
-
return;
|
|
2701
2748
|
}),
|
|
2702
2749
|
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2703
2750
|
AngularElasticSeachModule,
|
|
@@ -2710,28 +2757,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
2710
2757
|
args: [{
|
|
2711
2758
|
imports: [
|
|
2712
2759
|
provideFirebaseApp((injector) => {
|
|
2713
|
-
const appName = injector.get(FIREBASE_APP_NAME)
|
|
2760
|
+
const appName = injector.get(FIREBASE_APP_NAME);
|
|
2714
2761
|
try {
|
|
2715
|
-
|
|
2762
|
+
const app = appName ? getApp(appName) : getApp();
|
|
2763
|
+
return app;
|
|
2716
2764
|
}
|
|
2717
2765
|
catch (error) {
|
|
2766
|
+
console.warn('Firebase app not found, initializing new app');
|
|
2767
|
+
if (error instanceof Error)
|
|
2768
|
+
console.error(error.message);
|
|
2718
2769
|
return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
|
|
2719
2770
|
}
|
|
2720
2771
|
}),
|
|
2721
2772
|
provideAppCheck((injector) => {
|
|
2722
2773
|
const app = injector.get(FirebaseApp);
|
|
2723
2774
|
try {
|
|
2724
|
-
const
|
|
2725
|
-
if (
|
|
2775
|
+
const provider = injector.get(APP_CHECK_PROVIDER);
|
|
2776
|
+
if (provider)
|
|
2726
2777
|
return initializeAppCheck(app, {
|
|
2727
|
-
provider
|
|
2778
|
+
provider,
|
|
2728
2779
|
isTokenAutoRefreshEnabled: true,
|
|
2729
2780
|
});
|
|
2730
2781
|
}
|
|
2731
2782
|
catch (error) {
|
|
2732
|
-
|
|
2783
|
+
if (error instanceof Error)
|
|
2784
|
+
console.error(error.message);
|
|
2785
|
+
return;
|
|
2733
2786
|
}
|
|
2734
|
-
return;
|
|
2735
2787
|
}),
|
|
2736
2788
|
provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
|
|
2737
2789
|
AngularElasticSeachModule,
|