@infrab4a/connect-angular 4.3.7-beta.8 → 4.3.7-beta.9
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/persistence/cookie-data-persistence.mjs +9 -6
- package/esm2020/persistence/data-persistence.mjs +1 -1
- package/esm2020/services/checkout-subscription.service.mjs +18 -21
- package/esm2020/services/checkout.service.mjs +13 -16
- package/fesm2015/infrab4a-connect-angular.mjs +32 -41
- package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
- package/fesm2020/infrab4a-connect-angular.mjs +34 -37
- package/fesm2020/infrab4a-connect-angular.mjs.map +1 -1
- package/package.json +1 -1
- package/persistence/cookie-data-persistence.d.ts +4 -3
- package/persistence/data-persistence.d.ts +4 -3
- package/services/checkout-subscription.service.d.ts +5 -4
- package/services/checkout.service.d.ts +4 -3
|
@@ -12,7 +12,7 @@ import { Firestore, provideFirestore, getFirestore, initializeFirestore, memoryL
|
|
|
12
12
|
import * as i2 from '@angular/fire/storage';
|
|
13
13
|
import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
|
|
14
14
|
import cookie from 'js-cookie';
|
|
15
|
-
import {
|
|
15
|
+
import { from, combineLatest, of, throwError, Subject, iif, forkJoin } from 'rxjs';
|
|
16
16
|
import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
|
|
17
17
|
import { __decorate, __metadata } from 'tslib';
|
|
18
18
|
import { Type } from 'class-transformer';
|
|
@@ -930,14 +930,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
930
930
|
}] });
|
|
931
931
|
|
|
932
932
|
class CookieDataPersistence {
|
|
933
|
-
|
|
934
|
-
return cookie.get(key);
|
|
933
|
+
get(key) {
|
|
934
|
+
return from(cookie.get(key));
|
|
935
935
|
}
|
|
936
|
-
|
|
936
|
+
remove(key) {
|
|
937
937
|
cookie.remove(key);
|
|
938
|
+
return;
|
|
938
939
|
}
|
|
939
|
-
|
|
940
|
-
|
|
940
|
+
set(key, value) {
|
|
941
|
+
return from(cookie.set(key, value)).pipe(map(() => { }));
|
|
941
942
|
}
|
|
942
943
|
}
|
|
943
944
|
CookieDataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -1206,18 +1207,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1206
1207
|
}] }]; } });
|
|
1207
1208
|
|
|
1208
1209
|
class CheckoutService {
|
|
1209
|
-
constructor(couponService, checkoutRepository,
|
|
1210
|
+
constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
|
|
1210
1211
|
this.couponService = couponService;
|
|
1211
1212
|
this.checkoutRepository = checkoutRepository;
|
|
1212
|
-
this.orderRepository = orderRepository;
|
|
1213
1213
|
this.userRepository = userRepository;
|
|
1214
1214
|
this.defaultShop = defaultShop;
|
|
1215
|
+
this.dataPersistence = dataPersistence;
|
|
1215
1216
|
}
|
|
1216
1217
|
getCheckout(checkoutData) {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
return from(this.createCheckout(checkoutData));
|
|
1218
|
+
return this.dataPersistence
|
|
1219
|
+
.get('checkoutId')
|
|
1220
|
+
.pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
|
|
1221
1221
|
}
|
|
1222
1222
|
getUserByCheckout(checkoutId) {
|
|
1223
1223
|
return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
|
|
@@ -1229,8 +1229,7 @@ class CheckoutService {
|
|
|
1229
1229
|
return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
|
|
1230
1230
|
}
|
|
1231
1231
|
clearCheckoutFromSession() {
|
|
1232
|
-
|
|
1233
|
-
return of();
|
|
1232
|
+
return this.dataPersistence.remove('checkoutId');
|
|
1234
1233
|
}
|
|
1235
1234
|
calcDiscount(coupon) {
|
|
1236
1235
|
return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
|
|
@@ -1244,26 +1243,26 @@ class CheckoutService {
|
|
|
1244
1243
|
...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1245
1244
|
shop: checkoutData?.shop || this.defaultShop,
|
|
1246
1245
|
});
|
|
1247
|
-
|
|
1246
|
+
await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
|
|
1248
1247
|
return checkout;
|
|
1249
1248
|
}
|
|
1250
1249
|
}
|
|
1251
|
-
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: '
|
|
1250
|
+
CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }, { token: PERSISTENCE_PROVIDER }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1252
1251
|
CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
|
|
1253
1252
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
|
|
1254
1253
|
type: Injectable
|
|
1255
1254
|
}], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
|
|
1256
1255
|
type: Inject,
|
|
1257
1256
|
args: ['CheckoutRepository']
|
|
1258
|
-
}] }, { type: undefined, decorators: [{
|
|
1259
|
-
type: Inject,
|
|
1260
|
-
args: ['OrderRepository']
|
|
1261
1257
|
}] }, { type: undefined, decorators: [{
|
|
1262
1258
|
type: Inject,
|
|
1263
1259
|
args: ['UserRepository']
|
|
1264
1260
|
}] }, { type: i1$2.Shops, decorators: [{
|
|
1265
1261
|
type: Inject,
|
|
1266
1262
|
args: [DEFAULT_SHOP]
|
|
1263
|
+
}] }, { type: undefined, decorators: [{
|
|
1264
|
+
type: Inject,
|
|
1265
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1267
1266
|
}] }]; } });
|
|
1268
1267
|
|
|
1269
1268
|
class CartService {
|
|
@@ -1946,28 +1945,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1946
1945
|
}] }, { type: i1$2.ProductsIndex }]; } });
|
|
1947
1946
|
|
|
1948
1947
|
class CheckoutSubscriptionService {
|
|
1949
|
-
constructor(checkoutSubscriptionRepository,
|
|
1948
|
+
constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
|
|
1950
1949
|
this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
|
|
1951
|
-
this.
|
|
1950
|
+
this.dataPersistence = dataPersistence;
|
|
1952
1951
|
this.couponService = couponService;
|
|
1953
1952
|
}
|
|
1954
1953
|
getCheckoutSubscription(checkoutData) {
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
return from(this.createCheckoutSubscription(checkoutData));
|
|
1959
|
-
}
|
|
1960
|
-
async createCheckoutSubscription(checkoutData) {
|
|
1961
|
-
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
1962
|
-
createdAt: new Date(),
|
|
1963
|
-
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1964
|
-
});
|
|
1965
|
-
cookie.set('checkoutSubscriptionId', checkout.id);
|
|
1966
|
-
return checkout;
|
|
1954
|
+
return this.dataPersistence
|
|
1955
|
+
.get('checkoutSubscriptionId')
|
|
1956
|
+
.pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
|
|
1967
1957
|
}
|
|
1968
1958
|
clearCheckoutSubscriptionFromSession() {
|
|
1969
|
-
|
|
1970
|
-
return of();
|
|
1959
|
+
return this.dataPersistence.remove('checkoutSubscriptionId');
|
|
1971
1960
|
}
|
|
1972
1961
|
checkCoupon(nickname, userEmail) {
|
|
1973
1962
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
|
|
@@ -1977,8 +1966,16 @@ class CheckoutSubscriptionService {
|
|
|
1977
1966
|
calcDiscountSubscription(coupon) {
|
|
1978
1967
|
return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
|
|
1979
1968
|
}
|
|
1969
|
+
async createCheckoutSubscription(checkoutData) {
|
|
1970
|
+
const checkout = await this.checkoutSubscriptionRepository.create({
|
|
1971
|
+
createdAt: new Date(),
|
|
1972
|
+
...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
|
|
1973
|
+
});
|
|
1974
|
+
await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
|
|
1975
|
+
return checkout;
|
|
1976
|
+
}
|
|
1980
1977
|
}
|
|
1981
|
-
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token:
|
|
1978
|
+
CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1982
1979
|
CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
|
|
1983
1980
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
|
|
1984
1981
|
type: Injectable
|
|
@@ -1987,7 +1984,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImpor
|
|
|
1987
1984
|
args: ['CheckoutSubscriptionRepository']
|
|
1988
1985
|
}] }, { type: undefined, decorators: [{
|
|
1989
1986
|
type: Inject,
|
|
1990
|
-
args: [
|
|
1987
|
+
args: [PERSISTENCE_PROVIDER]
|
|
1991
1988
|
}] }, { type: CouponService }]; } });
|
|
1992
1989
|
|
|
1993
1990
|
class UtilHelper {
|