@daffodil/cart 0.60.0 → 0.61.0
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/driver/in-memory/package.json +1 -1
- package/driver/magento/package.json +1 -1
- package/driver/magento/testing/package.json +1 -1
- package/driver/operators/handle-cart-not-found.d.ts +8 -0
- package/driver/operators/public_api.d.ts +1 -0
- package/driver/package.json +1 -1
- package/driver/public_api.d.ts +2 -0
- package/driver/services/public_api.d.ts +1 -0
- package/driver/services/resolve.service.d.ts +25 -0
- package/driver/testing/package.json +1 -1
- package/esm2020/driver/magento/cart.service.mjs +11 -5
- package/esm2020/driver/operators/handle-cart-not-found.mjs +17 -0
- package/esm2020/driver/operators/public_api.mjs +2 -0
- package/esm2020/driver/public_api.mjs +3 -1
- package/esm2020/driver/services/public_api.mjs +2 -0
- package/esm2020/driver/services/resolve.service.mjs +46 -0
- package/esm2020/routing/cart-routing.module.mjs +4 -2
- package/esm2020/routing/guards/public_api.mjs +3 -1
- package/esm2020/routing/guards/resolve-cart/redirect.token.mjs +3 -0
- package/esm2020/routing/guards/resolve-cart/resolve-cart.guard.mjs +58 -0
- package/esm2020/state/effects/cart-item.effects.mjs +15 -7
- package/esm2020/state/effects/cart-resolver.effects.mjs +18 -28
- package/esm2020/state/reducers/cart/cart.reducer.mjs +4 -4
- package/esm2020/state/reducers/cart-billing-address/cart-billing-address.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart-coupon/cart-coupon.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart-initial-state.mjs +2 -2
- package/esm2020/state/reducers/cart-item/cart-item.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart-payment/cart-payment.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart-payment-methods/cart-payment-methods.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart-resolve/cart-resolve.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart-shipping-address/cart-shipping-address.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart-shipping-information/cart-shipping-information.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart-shipping-methods/cart-shipping-methods.reducer.mjs +3 -3
- package/esm2020/state/reducers/cart.reducer.mjs +3 -3
- package/esm2020/state/reducers/public_api.mjs +3 -2
- package/fesm2015/daffodil-cart-driver-magento.mjs +10 -4
- package/fesm2015/daffodil-cart-driver-magento.mjs.map +1 -1
- package/fesm2015/daffodil-cart-driver.mjs +61 -2
- package/fesm2015/daffodil-cart-driver.mjs.map +1 -1
- package/fesm2015/daffodil-cart-routing.mjs +55 -1
- package/fesm2015/daffodil-cart-routing.mjs.map +1 -1
- package/fesm2015/daffodil-cart-state.mjs +42 -45
- package/fesm2015/daffodil-cart-state.mjs.map +1 -1
- package/fesm2020/daffodil-cart-driver-magento.mjs +10 -4
- package/fesm2020/daffodil-cart-driver-magento.mjs.map +1 -1
- package/fesm2020/daffodil-cart-driver.mjs +59 -2
- package/fesm2020/daffodil-cart-driver.mjs.map +1 -1
- package/fesm2020/daffodil-cart-routing.mjs +53 -1
- package/fesm2020/daffodil-cart-routing.mjs.map +1 -1
- package/fesm2020/daffodil-cart-state.mjs +42 -45
- package/fesm2020/daffodil-cart-state.mjs.map +1 -1
- package/package.json +1 -1
- package/routing/guards/public_api.d.ts +2 -0
- package/routing/guards/resolve-cart/redirect.token.d.ts +2 -0
- package/routing/guards/resolve-cart/resolve-cart.guard.d.ts +24 -0
- package/routing/package.json +1 -1
- package/state/effects/cart-item.effects.d.ts +9 -7
- package/state/effects/cart-resolver.effects.d.ts +3 -2
- package/state/package.json +1 -1
- package/state/reducers/cart-initial-state.d.ts +1 -1
- package/state/reducers/public_api.d.ts +2 -1
- package/state/testing/package.json +1 -1
- package/testing/package.json +1 -1
|
@@ -2,18 +2,19 @@ import * as i1$1 from '@ngrx/store';
|
|
|
2
2
|
import { createFeatureSelector, createSelector, defaultMemoize, select, combineReducers, StoreModule } from '@ngrx/store';
|
|
3
3
|
import { createEntityAdapter } from '@ngrx/entity';
|
|
4
4
|
import { daffComposeReducers } from '@daffodil/core/state';
|
|
5
|
-
import
|
|
5
|
+
import * as i4 from '@daffodil/cart/driver';
|
|
6
|
+
import { DaffCartDriverErrorCodes, DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartCouponDriver, daffCartDriverHandleCartNotFound, DaffCartItemDriver, DaffCartOrderDriver, DaffCartPaymentMethodsDriver, DaffCartPaymentDriver, DaffCartDriver, DaffCartShippingAddressDriver, DaffCartShippingInformationDriver, DaffCartShippingMethodsDriver } from '@daffodil/cart/driver';
|
|
6
7
|
import * as i0 from '@angular/core';
|
|
7
8
|
import { InjectionToken, Injectable, Inject, inject, NgModule } from '@angular/core';
|
|
8
9
|
import * as i2 from '@daffodil/cart';
|
|
9
|
-
import { DaffCartItemInputType, DaffCartTotalTypeEnum, DAFF_CART_ERROR_MATCHER,
|
|
10
|
+
import { DaffCartItemInputType, DaffCartTotalTypeEnum, DAFF_CART_ERROR_MATCHER, DaffCartResolutionError, DaffCartStorageResolutionError, DaffCartServerSideResolutionError, DaffCartPaymentMethodIdMap } from '@daffodil/cart';
|
|
10
11
|
import { daffAdd, DaffStorageServiceError, DaffInheritableError, DaffServerSideStorageError } from '@daffodil/core';
|
|
11
12
|
import { daffComparePersonalAddresses } from '@daffodil/geography';
|
|
12
13
|
import * as i1 from '@ngrx/effects';
|
|
13
14
|
import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
|
|
14
15
|
import { DaffPaymentGenerateTokenFailure, DAFF_PAYMENT_PROCESSOR_COLLECTION, daffPaymentInitialState, DaffPaymentStateReducerAdapter, daffPaymentProvideExtraReducers } from '@daffodil/payment/state';
|
|
15
16
|
import { defer, of, combineLatest, iif, EMPTY } from 'rxjs';
|
|
16
|
-
import { switchMap, map, catchError, mergeMap, debounceTime, take, tap } from 'rxjs/operators';
|
|
17
|
+
import { switchMap, map, catchError, concatMap, mergeMap, debounceTime, take, tap } from 'rxjs/operators';
|
|
17
18
|
import { DAFF_PAYMENT_ERROR_MATCHER } from '@daffodil/payment';
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -1204,7 +1205,7 @@ var DaffCartResolveState;
|
|
|
1204
1205
|
DaffCartResolveState["ServerSide"] = "server";
|
|
1205
1206
|
})(DaffCartResolveState || (DaffCartResolveState = {}));
|
|
1206
1207
|
|
|
1207
|
-
const
|
|
1208
|
+
const daffCartReducerInitialState = Object.freeze({
|
|
1208
1209
|
cart: {
|
|
1209
1210
|
id: null,
|
|
1210
1211
|
subtotal: null,
|
|
@@ -1258,7 +1259,7 @@ const initializeLoadingSetter = (loadingSpace) => (loadingObj, loading) => ({
|
|
|
1258
1259
|
const addError$8 = initializeErrorAdder(DaffCartOperationType.BillingAddress);
|
|
1259
1260
|
const resetErrors$8 = initializeErrorResetter(DaffCartOperationType.BillingAddress);
|
|
1260
1261
|
const setLoading$8 = initializeLoadingSetter(DaffCartOperationType.BillingAddress);
|
|
1261
|
-
function cartBillingAddressReducer(state =
|
|
1262
|
+
function cartBillingAddressReducer(state = daffCartReducerInitialState, action) {
|
|
1262
1263
|
switch (action.type) {
|
|
1263
1264
|
case DaffCartBillingAddressActionTypes.CartBillingAddressLoadAction:
|
|
1264
1265
|
return Object.assign(Object.assign({}, state), setLoading$8(state.loading, "Resolving" /* Resolving */));
|
|
@@ -1282,7 +1283,7 @@ function cartBillingAddressReducer(state = initialState, action) {
|
|
|
1282
1283
|
const addError$7 = initializeErrorAdder(DaffCartOperationType.Coupon);
|
|
1283
1284
|
const resetErrors$7 = initializeErrorResetter(DaffCartOperationType.Coupon);
|
|
1284
1285
|
const setLoading$7 = initializeLoadingSetter(DaffCartOperationType.Coupon);
|
|
1285
|
-
function cartCouponReducer(state =
|
|
1286
|
+
function cartCouponReducer(state = daffCartReducerInitialState, action) {
|
|
1286
1287
|
switch (action.type) {
|
|
1287
1288
|
case DaffCartCouponActionTypes.CartCouponListAction:
|
|
1288
1289
|
return Object.assign(Object.assign({}, state), setLoading$7(state.loading, "Resolving" /* Resolving */));
|
|
@@ -1311,7 +1312,7 @@ function cartCouponReducer(state = initialState, action) {
|
|
|
1311
1312
|
const addError$6 = initializeErrorAdder(DaffCartOperationType.Item);
|
|
1312
1313
|
const resetErrors$6 = initializeErrorResetter(DaffCartOperationType.Item);
|
|
1313
1314
|
const setLoading$6 = initializeLoadingSetter(DaffCartOperationType.Item);
|
|
1314
|
-
function cartItemReducer(state =
|
|
1315
|
+
function cartItemReducer(state = daffCartReducerInitialState, action) {
|
|
1315
1316
|
switch (action.type) {
|
|
1316
1317
|
case DaffCartItemActionTypes.CartItemListAction:
|
|
1317
1318
|
case DaffCartItemActionTypes.CartItemLoadAction:
|
|
@@ -1352,7 +1353,7 @@ function cartItemReducer(state = initialState, action) {
|
|
|
1352
1353
|
const addError$5 = initializeErrorAdder(DaffCartOperationType.PaymentMethods);
|
|
1353
1354
|
const resetErrors$5 = initializeErrorResetter(DaffCartOperationType.PaymentMethods);
|
|
1354
1355
|
const setLoading$5 = initializeLoadingSetter(DaffCartOperationType.PaymentMethods);
|
|
1355
|
-
function cartPaymentMethodsReducer(state =
|
|
1356
|
+
function cartPaymentMethodsReducer(state = daffCartReducerInitialState, action) {
|
|
1356
1357
|
switch (action.type) {
|
|
1357
1358
|
case DaffCartPaymentMethodsActionTypes.CartPaymentMethodsLoadAction:
|
|
1358
1359
|
return Object.assign(Object.assign({}, state), setLoading$5(state.loading, "Resolving" /* Resolving */));
|
|
@@ -1368,7 +1369,7 @@ function cartPaymentMethodsReducer(state = initialState, action) {
|
|
|
1368
1369
|
const addError$4 = initializeErrorAdder(DaffCartOperationType.Payment);
|
|
1369
1370
|
const resetErrors$4 = initializeErrorResetter(DaffCartOperationType.Payment);
|
|
1370
1371
|
const setLoading$4 = initializeLoadingSetter(DaffCartOperationType.Payment);
|
|
1371
|
-
function cartPaymentReducer(state =
|
|
1372
|
+
function cartPaymentReducer(state = daffCartReducerInitialState, action) {
|
|
1372
1373
|
switch (action.type) {
|
|
1373
1374
|
case DaffCartPaymentActionTypes.CartPaymentLoadAction:
|
|
1374
1375
|
return Object.assign(Object.assign({}, state), setLoading$4(state.loading, "Resolving" /* Resolving */));
|
|
@@ -1401,7 +1402,7 @@ function cartPaymentReducer(state = initialState, action) {
|
|
|
1401
1402
|
}
|
|
1402
1403
|
}
|
|
1403
1404
|
|
|
1404
|
-
function cartResolveReducer(state =
|
|
1405
|
+
function cartResolveReducer(state = daffCartReducerInitialState, action) {
|
|
1405
1406
|
switch (action.type) {
|
|
1406
1407
|
case DaffCartActionTypes.ResolveCartAction:
|
|
1407
1408
|
return Object.assign(Object.assign({}, state), { resolved: DaffCartResolveState.Resolving });
|
|
@@ -1421,7 +1422,7 @@ function cartResolveReducer(state = initialState, action) {
|
|
|
1421
1422
|
const addError$3 = initializeErrorAdder(DaffCartOperationType.ShippingAddress);
|
|
1422
1423
|
const resetErrors$3 = initializeErrorResetter(DaffCartOperationType.ShippingAddress);
|
|
1423
1424
|
const setLoading$3 = initializeLoadingSetter(DaffCartOperationType.ShippingAddress);
|
|
1424
|
-
function cartShippingAddressReducer(state =
|
|
1425
|
+
function cartShippingAddressReducer(state = daffCartReducerInitialState, action) {
|
|
1425
1426
|
switch (action.type) {
|
|
1426
1427
|
case DaffCartShippingAddressActionTypes.CartShippingAddressLoadAction:
|
|
1427
1428
|
return Object.assign(Object.assign({}, state), setLoading$3(state.loading, "Resolving" /* Resolving */));
|
|
@@ -1445,7 +1446,7 @@ function cartShippingAddressReducer(state = initialState, action) {
|
|
|
1445
1446
|
const addError$2 = initializeErrorAdder(DaffCartOperationType.ShippingInformation);
|
|
1446
1447
|
const resetErrors$2 = initializeErrorResetter(DaffCartOperationType.ShippingInformation);
|
|
1447
1448
|
const setLoading$2 = initializeLoadingSetter(DaffCartOperationType.ShippingInformation);
|
|
1448
|
-
function cartShippingInformationReducer(state =
|
|
1449
|
+
function cartShippingInformationReducer(state = daffCartReducerInitialState, action) {
|
|
1449
1450
|
switch (action.type) {
|
|
1450
1451
|
case DaffCartShippingInformationActionTypes.CartShippingInformationLoadAction:
|
|
1451
1452
|
return Object.assign(Object.assign({}, state), setLoading$2(state.loading, "Resolving" /* Resolving */));
|
|
@@ -1473,7 +1474,7 @@ function cartShippingInformationReducer(state = initialState, action) {
|
|
|
1473
1474
|
const addError$1 = initializeErrorAdder(DaffCartOperationType.ShippingMethods);
|
|
1474
1475
|
const resetErrors$1 = initializeErrorResetter(DaffCartOperationType.ShippingMethods);
|
|
1475
1476
|
const setLoading$1 = initializeLoadingSetter(DaffCartOperationType.ShippingMethods);
|
|
1476
|
-
function cartShippingMethodsReducer(state =
|
|
1477
|
+
function cartShippingMethodsReducer(state = daffCartReducerInitialState, action) {
|
|
1477
1478
|
switch (action.type) {
|
|
1478
1479
|
case DaffCartShippingMethodsActionTypes.CartShippingMethodsLoadAction:
|
|
1479
1480
|
return Object.assign(Object.assign({}, state), setLoading$1(state.loading, "Resolving" /* Resolving */));
|
|
@@ -1489,7 +1490,7 @@ function cartShippingMethodsReducer(state = initialState, action) {
|
|
|
1489
1490
|
const addError = initializeErrorAdder(DaffCartOperationType.Cart);
|
|
1490
1491
|
const resetErrors = initializeErrorResetter(DaffCartOperationType.Cart);
|
|
1491
1492
|
const setLoading = initializeLoadingSetter(DaffCartOperationType.Cart);
|
|
1492
|
-
function cartReducer(state =
|
|
1493
|
+
function cartReducer(state = daffCartReducerInitialState, action) {
|
|
1493
1494
|
switch (action.type) {
|
|
1494
1495
|
case DaffCartActionTypes.ResolveCartAction:
|
|
1495
1496
|
case DaffCartActionTypes.CartLoadAction:
|
|
@@ -1504,7 +1505,7 @@ function cartReducer(state = initialState, action) {
|
|
|
1504
1505
|
case DaffCartActionTypes.ResolveCartSuccessAction:
|
|
1505
1506
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors(state.errors)), { cart: Object.assign(Object.assign({}, state.cart), action.payload) }), setLoading(state.loading, "Stable" /* Complete */));
|
|
1506
1507
|
case DaffCartActionTypes.CartCreateSuccessAction:
|
|
1507
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors(state.errors)), { cart: Object.assign(Object.assign({},
|
|
1508
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors(state.errors)), { cart: Object.assign(Object.assign({}, daffCartReducerInitialState.cart), action.payload) }), setLoading(state.loading, "Stable" /* Complete */));
|
|
1508
1509
|
case DaffCartActionTypes.CartClearFailureAction:
|
|
1509
1510
|
case DaffCartActionTypes.AddToCartFailureAction:
|
|
1510
1511
|
case DaffCartActionTypes.CartCreateFailureAction:
|
|
@@ -1537,7 +1538,7 @@ const composedReducers = daffComposeReducers([
|
|
|
1537
1538
|
* Calls each of the individual cart reducers in turn,
|
|
1538
1539
|
* passing the returned state into the next.
|
|
1539
1540
|
*/
|
|
1540
|
-
function daffCartReducer(state =
|
|
1541
|
+
function daffCartReducer(state = daffCartReducerInitialState, action) {
|
|
1541
1542
|
return composedReducers(state, action);
|
|
1542
1543
|
}
|
|
1543
1544
|
|
|
@@ -2014,16 +2015,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
2014
2015
|
} });
|
|
2015
2016
|
|
|
2016
2017
|
class DaffCartItemEffects {
|
|
2017
|
-
constructor(actions$, errorMatcher, driver, storage, cartItemStateDebounceTime, store) {
|
|
2018
|
+
constructor(actions$, errorMatcher, driver, storage, cartItemStateDebounceTime, store, cartResolver) {
|
|
2018
2019
|
this.actions$ = actions$;
|
|
2019
2020
|
this.errorMatcher = errorMatcher;
|
|
2020
2021
|
this.driver = driver;
|
|
2021
2022
|
this.storage = storage;
|
|
2022
2023
|
this.cartItemStateDebounceTime = cartItemStateDebounceTime;
|
|
2023
2024
|
this.store = store;
|
|
2025
|
+
this.cartResolver = cartResolver;
|
|
2024
2026
|
this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemListAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartItemListSuccess(resp)), catchError(error => of(new DaffCartItemListFailure(this.errorMatcher(error))))))));
|
|
2025
2027
|
this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId(), action.itemId).pipe(map((resp) => new DaffCartItemLoadSuccess(resp)), catchError(error => of(new DaffCartItemLoadFailure(this.errorMatcher(error), action.itemId)))))));
|
|
2026
|
-
this.add$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemAddAction),
|
|
2028
|
+
this.add$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemAddAction), concatMap((action) => combineLatest([
|
|
2029
|
+
of(action),
|
|
2030
|
+
this.cartResolver.getCartIdOrFail(),
|
|
2031
|
+
])), mergeMap(([action, id]) => this.addCartItem$(id, action.input)), daffCartDriverHandleCartNotFound(this.storage), catchError(error => of(new DaffCartItemAddFailure(this.errorMatcher(error))))));
|
|
2027
2032
|
this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemUpdateAction), mergeMap((action) => this.driver.update(this.storage.getCartId(), action.itemId, action.changes).pipe(map((resp) => new DaffCartItemUpdateSuccess(resp, action.itemId)), catchError(error => of(new DaffCartItemUpdateFailure(this.errorMatcher(error), action.itemId)))))));
|
|
2028
2033
|
this.resetCartItemStateAfterChange$ = createEffect(() => this.actions$.pipe(ofType(
|
|
2029
2034
|
// these actions will reset the debounce interval
|
|
@@ -2035,8 +2040,11 @@ class DaffCartItemEffects {
|
|
|
2035
2040
|
? combineLatest(items.map(item => this.driver.delete(this.storage.getCartId(), item.id))).pipe(map(partialCarts => Object.assign({}, ...partialCarts)))
|
|
2036
2041
|
: this.store.pipe(select(getDaffCartSelectors().selectCartValue), take(1))), map(cart => new DaffCartItemDeleteOutOfStockSuccess(cart)), catchError(error => of(new DaffCartItemDeleteOutOfStockFailure(this.errorMatcher(error))))));
|
|
2037
2042
|
}
|
|
2043
|
+
addCartItem$(cartId, input) {
|
|
2044
|
+
return this.driver.add(cartId, input).pipe(map((resp) => new DaffCartItemAddSuccess(resp)), catchError(error => of(new DaffCartItemAddFailure(this.errorMatcher(error)))));
|
|
2045
|
+
}
|
|
2038
2046
|
}
|
|
2039
|
-
/** @nocollapse */ DaffCartItemEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartItemEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartItemDriver }, { token: i2.DaffCartStorageService }, { token: DaffCartItemStateDebounceTime }, { token: i1$1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2047
|
+
/** @nocollapse */ DaffCartItemEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartItemEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartItemDriver }, { token: i2.DaffCartStorageService }, { token: DaffCartItemStateDebounceTime }, { token: i1$1.Store }, { token: i4.DaffCartDriverResolveService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2040
2048
|
/** @nocollapse */ DaffCartItemEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartItemEffects });
|
|
2041
2049
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartItemEffects, decorators: [{
|
|
2042
2050
|
type: Injectable
|
|
@@ -2050,7 +2058,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
2050
2058
|
}] }, { type: i2.DaffCartStorageService }, { type: undefined, decorators: [{
|
|
2051
2059
|
type: Inject,
|
|
2052
2060
|
args: [DaffCartItemStateDebounceTime]
|
|
2053
|
-
}] }, { type: i1$1.Store }];
|
|
2061
|
+
}] }, { type: i1$1.Store }, { type: i4.DaffCartDriverResolveService }];
|
|
2054
2062
|
} });
|
|
2055
2063
|
|
|
2056
2064
|
class DaffCartOrderEffects {
|
|
@@ -2174,49 +2182,38 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
2174
2182
|
* 3. If the cart resolution fails, it will bailout.
|
|
2175
2183
|
*/
|
|
2176
2184
|
class DaffCartResolverEffects {
|
|
2177
|
-
constructor(actions$, errorMatcher, cartStorage, driver) {
|
|
2185
|
+
constructor(actions$, errorMatcher, cartStorage, cartResolver, driver) {
|
|
2178
2186
|
this.actions$ = actions$;
|
|
2179
2187
|
this.errorMatcher = errorMatcher;
|
|
2180
2188
|
this.cartStorage = cartStorage;
|
|
2189
|
+
this.cartResolver = cartResolver;
|
|
2181
2190
|
this.driver = driver;
|
|
2182
2191
|
this.onResolveCart = createEffect(() => () => this.actions$.pipe(ofType(DaffCartActionTypes.ResolveCartAction, DaffCartActionTypes.ResolveCartSuccessAction), switchMap(action => iif(
|
|
2183
2192
|
// if something else resolves the cart during an outstanding resolve
|
|
2184
2193
|
() => action.type === DaffCartActionTypes.ResolveCartSuccessAction,
|
|
2185
2194
|
// then just cancel the outstanding operation
|
|
2186
|
-
EMPTY,
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
}
|
|
2190
|
-
const hasOnlyRecoverableErrors = errors.reduce((acc, error) => acc && error.recoverable, true);
|
|
2191
|
-
if (hasOnlyRecoverableErrors) {
|
|
2192
|
-
return of(new DaffResolveCartPartialSuccess(response, errors.map(error => this.errorMatcher(error))));
|
|
2193
|
-
}
|
|
2194
|
-
if (errors.find(error => error instanceof DaffCartNotFoundError)) {
|
|
2195
|
-
return this.driver.create().pipe(switchMap(({ id }) => this.driver.get(id)), map(resp => new DaffResolveCartSuccess(resp.response)), catchError((innerError) => of(new DaffResolveCartFailure([this.errorMatcher(new DaffCartNotFoundOrCreatedResolutionError(innerError.message))]))));
|
|
2196
|
-
}
|
|
2197
|
-
// there are no special case errors, DaffResolveCartFailure will suffice
|
|
2198
|
-
// just map the errors
|
|
2199
|
-
return of(new DaffResolveCartFailure(errors.map(error => this.errorMatcher(
|
|
2200
|
-
// I wish there was a better way to check this
|
|
2201
|
-
error instanceof DaffInheritableError || !!error.code
|
|
2202
|
-
? error
|
|
2203
|
-
: new DaffCartResolutionError(error.message)))));
|
|
2204
|
-
}), catchError((error) => {
|
|
2195
|
+
EMPTY, this.cartResolver.getCartOrFail().pipe(map(({ response, errors }) => errors.length > 0
|
|
2196
|
+
? new DaffResolveCartPartialSuccess(response, errors.map(error => this.errorMatcher(error)))
|
|
2197
|
+
: new DaffResolveCartSuccess(response)), daffCartDriverHandleCartNotFound(this.cartStorage), catchError((error) => {
|
|
2205
2198
|
switch (true) {
|
|
2206
2199
|
case error instanceof DaffServerSideStorageError:
|
|
2207
2200
|
return of(new DaffResolveCartServerSide(this.errorMatcher(new DaffCartServerSideResolutionError(error.message))));
|
|
2208
2201
|
case error instanceof DaffStorageServiceError:
|
|
2209
2202
|
return of(new DaffResolveCartFailure([this.errorMatcher(new DaffCartStorageResolutionError(error.message))]));
|
|
2210
2203
|
default:
|
|
2211
|
-
return of(new DaffResolveCartFailure([this.errorMatcher(
|
|
2204
|
+
return of(new DaffResolveCartFailure([this.errorMatcher(
|
|
2205
|
+
// I wish there was a better way to check this
|
|
2206
|
+
error instanceof DaffInheritableError || !!error.code
|
|
2207
|
+
? error
|
|
2208
|
+
: new DaffCartResolutionError(error.message))]));
|
|
2212
2209
|
}
|
|
2213
2210
|
}))))));
|
|
2214
2211
|
}
|
|
2215
2212
|
ngrxOnInitEffects() {
|
|
2216
|
-
return new DaffResolveCart();
|
|
2213
|
+
return this.cartStorage.getCartId() ? new DaffResolveCart() : { type: '' };
|
|
2217
2214
|
}
|
|
2218
2215
|
}
|
|
2219
|
-
/** @nocollapse */ DaffCartResolverEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartResolverEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: i2.DaffCartStorageService }, { token: DaffCartDriver }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2216
|
+
/** @nocollapse */ DaffCartResolverEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartResolverEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: i2.DaffCartStorageService }, { token: i4.DaffCartDriverResolveService }, { token: DaffCartDriver }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2220
2217
|
/** @nocollapse */ DaffCartResolverEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartResolverEffects });
|
|
2221
2218
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartResolverEffects, decorators: [{
|
|
2222
2219
|
type: Injectable
|
|
@@ -2224,7 +2221,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
2224
2221
|
return [{ type: i1.Actions }, { type: undefined, decorators: [{
|
|
2225
2222
|
type: Inject,
|
|
2226
2223
|
args: [DAFF_CART_ERROR_MATCHER]
|
|
2227
|
-
}] }, { type: i2.DaffCartStorageService }, { type: undefined, decorators: [{
|
|
2224
|
+
}] }, { type: i2.DaffCartStorageService }, { type: i4.DaffCartDriverResolveService }, { type: undefined, decorators: [{
|
|
2228
2225
|
type: Inject,
|
|
2229
2226
|
args: [DaffCartDriver]
|
|
2230
2227
|
}] }];
|
|
@@ -2589,5 +2586,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
2589
2586
|
* Generated bundle index. Do not edit.
|
|
2590
2587
|
*/
|
|
2591
2588
|
|
|
2592
|
-
export { DAFF_CART_EXTRA_REDUCERS, DAFF_CART_STORE_FEATURE_KEY, DaffAddToCart, DaffAddToCartFailure, DaffAddToCartSuccess, DaffCartActionTypes, DaffCartAddressActionTypes, DaffCartAddressUpdate, DaffCartAddressUpdateFailure, DaffCartAddressUpdateSuccess, DaffCartBillingAddressActionTypes, DaffCartBillingAddressLoad, DaffCartBillingAddressLoadFailure, DaffCartBillingAddressLoadSuccess, DaffCartBillingAddressUpdate, DaffCartBillingAddressUpdateFailure, DaffCartBillingAddressUpdateSuccess, DaffCartClear, DaffCartClearFailure, DaffCartClearSuccess, DaffCartCouponActionTypes, DaffCartCouponApply, DaffCartCouponApplyFailure, DaffCartCouponApplySuccess, DaffCartCouponClearErrors, DaffCartCouponList, DaffCartCouponListFailure, DaffCartCouponListSuccess, DaffCartCouponRemove, DaffCartCouponRemoveAll, DaffCartCouponRemoveAllFailure, DaffCartCouponRemoveAllSuccess, DaffCartCouponRemoveFailure, DaffCartCouponRemoveSuccess, DaffCartCreate, DaffCartCreateFailure, DaffCartCreateSuccess, DaffCartFacade, DaffCartItemActionTypes, DaffCartItemAdd, DaffCartItemAddFailure, DaffCartItemAddSuccess, DaffCartItemDelete, DaffCartItemDeleteFailure, DaffCartItemDeleteOutOfStock, DaffCartItemDeleteOutOfStockFailure, DaffCartItemDeleteOutOfStockSuccess, DaffCartItemDeleteSuccess, DaffCartItemList, DaffCartItemListFailure, DaffCartItemListSuccess, DaffCartItemLoad, DaffCartItemLoadFailure, DaffCartItemLoadSuccess, DaffCartItemStateDebounceTime, DaffCartItemStateEnum, DaffCartItemStateReset, DaffCartItemUpdate, DaffCartItemUpdateFailure, DaffCartItemUpdateSuccess, DaffCartLoad, DaffCartLoadFailure, DaffCartLoadPartialSuccess, DaffCartLoadSuccess, DaffCartOperationType, DaffCartOrderActionTypes, DaffCartPaymentActionTypes, DaffCartPaymentLoad, DaffCartPaymentLoadFailure, DaffCartPaymentLoadSuccess, DaffCartPaymentMethodAdd, DaffCartPaymentMethodsActionTypes, DaffCartPaymentMethodsLoad, DaffCartPaymentMethodsLoadFailure, DaffCartPaymentMethodsLoadSuccess, DaffCartPaymentRemove, DaffCartPaymentRemoveFailure, DaffCartPaymentRemoveSuccess, DaffCartPaymentUpdate, DaffCartPaymentUpdateFailure, DaffCartPaymentUpdateSuccess, DaffCartPaymentUpdateWithBilling, DaffCartPaymentUpdateWithBillingFailure, DaffCartPaymentUpdateWithBillingSuccess, DaffCartPlaceOrder, DaffCartPlaceOrderFailure, DaffCartPlaceOrderSuccess, DaffCartResolveState, DaffCartShippingAddressActionTypes, DaffCartShippingAddressLoad, DaffCartShippingAddressLoadFailure, DaffCartShippingAddressLoadSuccess, DaffCartShippingAddressUpdate, DaffCartShippingAddressUpdateFailure, DaffCartShippingAddressUpdateSuccess, DaffCartShippingInformationActionTypes, DaffCartShippingInformationDelete, DaffCartShippingInformationDeleteFailure, DaffCartShippingInformationDeleteSuccess, DaffCartShippingInformationLoad, DaffCartShippingInformationLoadFailure, DaffCartShippingInformationLoadSuccess, DaffCartShippingInformationUpdate, DaffCartShippingInformationUpdateFailure, DaffCartShippingInformationUpdateSuccess, DaffCartShippingMethodsActionTypes, DaffCartShippingMethodsLoad, DaffCartShippingMethodsLoadFailure, DaffCartShippingMethodsLoadSuccess, DaffCartStateModule, DaffCartStorageFailure, DaffResolveCart, DaffResolveCartFailure, DaffResolveCartPartialSuccess, DaffResolveCartServerSide, DaffResolveCartSuccess, daffCartOrderInitialState, daffCartOrderReducer, daffCartProvideExtraReducers, daffCartReducer, daffCartReducers, getDaffCartSelectors,
|
|
2589
|
+
export { DAFF_CART_EXTRA_REDUCERS, DAFF_CART_STORE_FEATURE_KEY, DaffAddToCart, DaffAddToCartFailure, DaffAddToCartSuccess, DaffCartActionTypes, DaffCartAddressActionTypes, DaffCartAddressUpdate, DaffCartAddressUpdateFailure, DaffCartAddressUpdateSuccess, DaffCartBillingAddressActionTypes, DaffCartBillingAddressLoad, DaffCartBillingAddressLoadFailure, DaffCartBillingAddressLoadSuccess, DaffCartBillingAddressUpdate, DaffCartBillingAddressUpdateFailure, DaffCartBillingAddressUpdateSuccess, DaffCartClear, DaffCartClearFailure, DaffCartClearSuccess, DaffCartCouponActionTypes, DaffCartCouponApply, DaffCartCouponApplyFailure, DaffCartCouponApplySuccess, DaffCartCouponClearErrors, DaffCartCouponList, DaffCartCouponListFailure, DaffCartCouponListSuccess, DaffCartCouponRemove, DaffCartCouponRemoveAll, DaffCartCouponRemoveAllFailure, DaffCartCouponRemoveAllSuccess, DaffCartCouponRemoveFailure, DaffCartCouponRemoveSuccess, DaffCartCreate, DaffCartCreateFailure, DaffCartCreateSuccess, DaffCartFacade, DaffCartItemActionTypes, DaffCartItemAdd, DaffCartItemAddFailure, DaffCartItemAddSuccess, DaffCartItemDelete, DaffCartItemDeleteFailure, DaffCartItemDeleteOutOfStock, DaffCartItemDeleteOutOfStockFailure, DaffCartItemDeleteOutOfStockSuccess, DaffCartItemDeleteSuccess, DaffCartItemList, DaffCartItemListFailure, DaffCartItemListSuccess, DaffCartItemLoad, DaffCartItemLoadFailure, DaffCartItemLoadSuccess, DaffCartItemStateDebounceTime, DaffCartItemStateEnum, DaffCartItemStateReset, DaffCartItemUpdate, DaffCartItemUpdateFailure, DaffCartItemUpdateSuccess, DaffCartLoad, DaffCartLoadFailure, DaffCartLoadPartialSuccess, DaffCartLoadSuccess, DaffCartOperationType, DaffCartOrderActionTypes, DaffCartPaymentActionTypes, DaffCartPaymentLoad, DaffCartPaymentLoadFailure, DaffCartPaymentLoadSuccess, DaffCartPaymentMethodAdd, DaffCartPaymentMethodsActionTypes, DaffCartPaymentMethodsLoad, DaffCartPaymentMethodsLoadFailure, DaffCartPaymentMethodsLoadSuccess, DaffCartPaymentRemove, DaffCartPaymentRemoveFailure, DaffCartPaymentRemoveSuccess, DaffCartPaymentUpdate, DaffCartPaymentUpdateFailure, DaffCartPaymentUpdateSuccess, DaffCartPaymentUpdateWithBilling, DaffCartPaymentUpdateWithBillingFailure, DaffCartPaymentUpdateWithBillingSuccess, DaffCartPlaceOrder, DaffCartPlaceOrderFailure, DaffCartPlaceOrderSuccess, DaffCartResolveState, DaffCartShippingAddressActionTypes, DaffCartShippingAddressLoad, DaffCartShippingAddressLoadFailure, DaffCartShippingAddressLoadSuccess, DaffCartShippingAddressUpdate, DaffCartShippingAddressUpdateFailure, DaffCartShippingAddressUpdateSuccess, DaffCartShippingInformationActionTypes, DaffCartShippingInformationDelete, DaffCartShippingInformationDeleteFailure, DaffCartShippingInformationDeleteSuccess, DaffCartShippingInformationLoad, DaffCartShippingInformationLoadFailure, DaffCartShippingInformationLoadSuccess, DaffCartShippingInformationUpdate, DaffCartShippingInformationUpdateFailure, DaffCartShippingInformationUpdateSuccess, DaffCartShippingMethodsActionTypes, DaffCartShippingMethodsLoad, DaffCartShippingMethodsLoadFailure, DaffCartShippingMethodsLoadSuccess, DaffCartStateModule, DaffCartStorageFailure, DaffResolveCart, DaffResolveCartFailure, DaffResolveCartPartialSuccess, DaffResolveCartServerSide, DaffResolveCartSuccess, daffCartItemEntitiesAdapter, daffCartOrderInitialState, daffCartOrderReducer, daffCartProvideExtraReducers, daffCartReducer, daffCartReducerInitialState, daffCartReducers, getDaffCartSelectors, initializeLoadingSetter };
|
|
2593
2590
|
//# sourceMappingURL=daffodil-cart-state.mjs.map
|