@daffodil/cart 0.39.8 → 0.39.12
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/bundles/daffodil-cart-driver-in-memory.umd.js +4 -1
- package/bundles/daffodil-cart-driver-in-memory.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver-in-memory.umd.min.js +1 -1
- package/bundles/daffodil-cart-driver-in-memory.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-driver-magento-testing.umd.js +12 -2
- package/bundles/daffodil-cart-driver-magento-testing.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver-magento-testing.umd.min.js +2 -2
- package/bundles/daffodil-cart-driver-magento-testing.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-driver-magento.umd.js +119 -39
- package/bundles/daffodil-cart-driver-magento.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver-magento.umd.min.js +1 -1
- package/bundles/daffodil-cart-driver-magento.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-driver-testing.umd.js +6 -3
- package/bundles/daffodil-cart-driver-testing.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver-testing.umd.min.js +1 -1
- package/bundles/daffodil-cart-driver-testing.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-driver.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-routing.umd.js +43 -0
- package/bundles/daffodil-cart-routing.umd.js.map +1 -1
- package/bundles/daffodil-cart-routing.umd.min.js +1 -1
- package/bundles/daffodil-cart-routing.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-state-testing.umd.js +13 -2
- package/bundles/daffodil-cart-state-testing.umd.js.map +1 -1
- package/bundles/daffodil-cart-state-testing.umd.min.js +2 -2
- package/bundles/daffodil-cart-state-testing.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-state.umd.js +169 -28
- package/bundles/daffodil-cart-state.umd.js.map +1 -1
- package/bundles/daffodil-cart-state.umd.min.js +1 -1
- package/bundles/daffodil-cart-state.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-testing.umd.js +3 -3
- package/bundles/daffodil-cart-testing.umd.js.map +1 -1
- package/bundles/daffodil-cart-testing.umd.min.js +2 -2
- package/bundles/daffodil-cart-testing.umd.min.js.map +1 -1
- package/driver/daffodil-cart-driver.metadata.json +1 -1
- package/driver/in-memory/daffodil-cart-driver-in-memory.metadata.json +1 -1
- package/driver/in-memory/drivers/cart/cart.service.d.ts +3 -2
- package/driver/interfaces/cart-service.interface.d.ts +2 -1
- package/driver/magento/cart-item.service.d.ts +3 -1
- package/driver/magento/cart.service.d.ts +2 -1
- package/driver/magento/daffodil-cart-driver-magento.metadata.json +1 -1
- package/driver/magento/errors/transform.d.ts +13 -1
- package/driver/magento/injection-tokens/public_api.d.ts +1 -0
- package/driver/magento/injection-tokens/transforms/cart-item/token.d.ts +22 -0
- package/driver/magento/interfaces/cart-item-transform.type.d.ts +3 -0
- package/driver/magento/interfaces/public_api.d.ts +1 -0
- package/driver/magento/public_api.d.ts +1 -0
- package/driver/magento/testing/daffodil-cart-driver-magento-testing.metadata.json +1 -1
- package/driver/magento/testing/factories/public_api.d.ts +10 -10
- package/driver/magento/transforms/outputs/cart-coupon-response.service.d.ts +3 -0
- package/driver/magento/transforms/outputs/cart-item/cart-item-transformer.d.ts +7 -4
- package/driver/magento/transforms/outputs/cart.service.d.ts +3 -1
- package/driver/testing/daffodil-cart-driver-testing.metadata.json +1 -1
- package/driver/testing/drivers/cart/cart.service.d.ts +2 -1
- package/esm2015/driver/in-memory/drivers/cart/cart.service.js +5 -2
- package/esm2015/driver/interfaces/cart-service.interface.js +1 -1
- package/esm2015/driver/magento/cart-item.service.js +11 -8
- package/esm2015/driver/magento/cart.service.js +20 -7
- package/esm2015/driver/magento/errors/map.js +2 -2
- package/esm2015/driver/magento/errors/transform.js +15 -6
- package/esm2015/driver/magento/injection-tokens/public_api.js +2 -1
- package/esm2015/driver/magento/injection-tokens/transforms/cart-item/token.js +27 -0
- package/esm2015/driver/magento/interfaces/cart-item-transform.type.js +2 -0
- package/esm2015/driver/magento/interfaces/public_api.js +2 -0
- package/esm2015/driver/magento/public_api.js +2 -1
- package/esm2015/driver/magento/testing/factories/cart-address-input.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-address.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-coupon.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-item/bundle-cart-item.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-item/cart-item.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-item/configurable-cart-item.factory.js +1 -1
- package/esm2015/driver/magento/testing/factories/cart-payment-method.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-shipping-method.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/public_api.js +11 -11
- package/esm2015/driver/magento/transforms/outputs/cart-coupon-response.service.js +15 -5
- package/esm2015/driver/magento/transforms/outputs/cart-item/bundle-cart-item-transformer.js +2 -2
- package/esm2015/driver/magento/transforms/outputs/cart-item/cart-item-transformer.js +9 -6
- package/esm2015/driver/magento/transforms/outputs/cart-item/configurable-cart-item-transformer.js +2 -2
- package/esm2015/driver/magento/transforms/outputs/cart-item/simple-cart-item-transformer.js +3 -3
- package/esm2015/driver/magento/transforms/outputs/cart.service.js +12 -7
- package/esm2015/driver/testing/drivers/cart/cart.service.js +5 -2
- package/esm2015/driver/testing/drivers/cart-order/cart-order.service.js +2 -2
- package/esm2015/routing/guards/in-stock-items/in-stock-items-guard-redirect.token.js +6 -0
- package/esm2015/routing/guards/in-stock-items/in-stock-items.guard.js +43 -0
- package/esm2015/routing/guards/public_api.js +3 -1
- package/esm2015/state/actions/cart-item.actions.js +30 -1
- package/esm2015/state/actions/cart.actions.js +29 -1
- package/esm2015/state/effects/cart-item.effects.js +17 -6
- package/esm2015/state/effects/cart-resolver.effects.js +24 -8
- package/esm2015/state/effects/cart.effects.js +13 -4
- package/esm2015/state/facades/cart/cart-facade.interface.js +1 -1
- package/esm2015/state/facades/cart/cart.facade.js +10 -2
- package/esm2015/state/models/stateful-cart-item.js +1 -1
- package/esm2015/state/reducers/cart/cart.reducer.js +7 -4
- package/esm2015/state/reducers/cart-item/cart-item.reducer.js +11 -1
- package/esm2015/state/reducers/cart-item-entities/cart-item-entities.reducer.js +11 -7
- package/esm2015/state/reducers/errors/error-state-helpers.js +3 -3
- package/esm2015/state/selectors/cart-item-entities/cart-item-entities.selectors.js +7 -1
- package/esm2015/state/testing/factories/stateful-cart-item.factory.js +2 -1
- package/esm2015/state/testing/factories/stateful-composite-cart-item.factory.js +5 -1
- package/esm2015/state/testing/factories/stateful-configurable-cart-item.factory.js +5 -1
- package/esm2015/state/testing/mock-cart-facade.js +7 -1
- package/esm2015/testing/factories/cart-address.factory.js +2 -2
- package/esm2015/testing/factories/cart-coupon.factory.js +2 -2
- package/esm2015/testing/factories/cart-item/cart-item.factory.js +3 -3
- package/esm2015/testing/factories/cart-item/composite-cart-item.factory.js +2 -2
- package/esm2015/testing/factories/cart-item/configurable-cart-item.factory.js +1 -1
- package/esm2015/testing/factories/cart-shipping-rate.factory.js +2 -2
- package/esm2015/testing/factories/cart.factory.js +2 -2
- package/fesm2015/daffodil-cart-driver-in-memory.js +4 -1
- package/fesm2015/daffodil-cart-driver-in-memory.js.map +1 -1
- package/fesm2015/daffodil-cart-driver-magento-testing.js +2 -2
- package/fesm2015/daffodil-cart-driver-magento-testing.js.map +1 -1
- package/fesm2015/daffodil-cart-driver-magento.js +108 -44
- package/fesm2015/daffodil-cart-driver-magento.js.map +1 -1
- package/fesm2015/daffodil-cart-driver-testing.js +5 -2
- package/fesm2015/daffodil-cart-driver-testing.js.map +1 -1
- package/fesm2015/daffodil-cart-driver.js.map +1 -1
- package/fesm2015/daffodil-cart-routing.js +40 -1
- package/fesm2015/daffodil-cart-routing.js.map +1 -1
- package/fesm2015/daffodil-cart-state-testing.js +15 -0
- package/fesm2015/daffodil-cart-state-testing.js.map +1 -1
- package/fesm2015/daffodil-cart-state.js +149 -28
- package/fesm2015/daffodil-cart-state.js.map +1 -1
- package/fesm2015/daffodil-cart-testing.js +2 -2
- package/fesm2015/daffodil-cart-testing.js.map +1 -1
- package/package.json +6 -6
- package/routing/daffodil-cart-routing.metadata.json +1 -1
- package/routing/guards/in-stock-items/in-stock-items-guard-redirect.token.d.ts +5 -0
- package/routing/guards/in-stock-items/in-stock-items.guard.d.ts +17 -0
- package/routing/guards/public_api.d.ts +2 -0
- package/state/actions/cart-item.actions.d.ts +26 -1
- package/state/actions/cart.actions.d.ts +31 -5
- package/state/daffodil-cart-state.metadata.json +1 -1
- package/state/effects/cart-item.effects.d.ts +5 -2
- package/state/effects/cart.effects.d.ts +2 -2
- package/state/facades/cart/cart-facade.interface.d.ts +19 -0
- package/state/facades/cart/cart.facade.d.ts +5 -0
- package/state/models/stateful-cart-item.d.ts +5 -0
- package/state/reducers/errors/error-state-helpers.d.ts +1 -1
- package/state/selectors/cart-item-entities/cart-item-entities.selectors.d.ts +13 -0
- package/state/testing/daffodil-cart-state-testing.metadata.json +1 -1
- package/state/testing/factories/stateful-cart-item.factory.d.ts +1 -0
- package/state/testing/factories/stateful-composite-cart-item.factory.d.ts +1 -0
- package/state/testing/factories/stateful-configurable-cart-item.factory.d.ts +1 -0
- package/state/testing/mock-cart-facade.d.ts +4 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { createFeatureSelector, createSelector, defaultMemoize,
|
|
1
|
+
import { createFeatureSelector, createSelector, defaultMemoize, select, Store, combineReducers, StoreModule } from '@ngrx/store';
|
|
2
2
|
import { createEntityAdapter } from '@ngrx/entity';
|
|
3
3
|
import { daffComposeReducers } from '@daffodil/core/state';
|
|
4
|
+
import { DaffCartDriverErrorCodes, DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartCouponDriver, DaffCartItemDriver, DaffCartOrderDriver, DaffCartPaymentMethodsDriver, DaffCartPaymentDriver, DaffCartNotFoundError, DaffCartDriver, DaffCartShippingAddressDriver, DaffCartShippingInformationDriver, DaffCartShippingMethodsDriver } from '@daffodil/cart/driver';
|
|
4
5
|
import { InjectionToken, Injectable, Inject, inject, NgModule, ɵɵdefineInjectable, ɵɵinject } from '@angular/core';
|
|
5
|
-
import { DaffCartItemInputType, DaffCartTotalTypeEnum, DAFF_CART_ERROR_MATCHER, DaffCartStorageService,
|
|
6
|
-
import { daffAdd, DaffStorageServiceError, DaffServerSideStorageError } from '@daffodil/core';
|
|
6
|
+
import { DaffCartItemInputType, DaffCartTotalTypeEnum, DAFF_CART_ERROR_MATCHER, DaffCartStorageService, DaffCartNotFoundOrCreatedResolutionError, DaffCartResolutionError, DaffCartStorageResolutionError, DaffCartServerSideResolutionError, DaffCartPaymentMethodIdMap } from '@daffodil/cart';
|
|
7
|
+
import { daffAdd, DaffStorageServiceError, DaffInheritableError, DaffServerSideStorageError } from '@daffodil/core';
|
|
7
8
|
import { daffComparePersonalAddresses } from '@daffodil/geography';
|
|
8
9
|
import { ofType, Actions, Effect, EffectsModule } from '@ngrx/effects';
|
|
9
10
|
import { __decorate, __metadata } from 'tslib';
|
|
10
|
-
import { of, EMPTY } from 'rxjs';
|
|
11
|
-
import { switchMap, map, catchError, mergeMap, debounceTime, mapTo, tap, switchMapTo } from 'rxjs/operators';
|
|
12
|
-
import { DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartCouponDriver, DaffCartItemDriver, DaffCartOrderDriver, DaffCartPaymentMethodsDriver, DaffCartPaymentDriver, DaffCartNotFoundError, DaffCartDriver, DaffCartShippingAddressDriver, DaffCartShippingInformationDriver, DaffCartShippingMethodsDriver } from '@daffodil/cart/driver';
|
|
11
|
+
import { of, combineLatest, EMPTY } from 'rxjs';
|
|
12
|
+
import { switchMap, map, catchError, mergeMap, debounceTime, mapTo, take, tap, switchMapTo } from 'rxjs/operators';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* An enum for the cart action types.
|
|
@@ -19,6 +19,7 @@ var DaffCartActionTypes;
|
|
|
19
19
|
DaffCartActionTypes["CartStorageFailureAction"] = "[DaffCart] Cart Storage Failure Action";
|
|
20
20
|
DaffCartActionTypes["CartLoadAction"] = "[DaffCart] Cart Load Action";
|
|
21
21
|
DaffCartActionTypes["CartLoadSuccessAction"] = "[DaffCart] Cart Load Success Action";
|
|
22
|
+
DaffCartActionTypes["CartLoadPartialSuccessAction"] = "[DaffCart] Cart Load Partial Success Action";
|
|
22
23
|
DaffCartActionTypes["CartLoadFailureAction"] = "[DaffCart] Cart Load Failure Action";
|
|
23
24
|
DaffCartActionTypes["CartCreateAction"] = "[DaffCart] Cart Create Action";
|
|
24
25
|
DaffCartActionTypes["CartCreateSuccessAction"] = "[DaffCart] Cart Create Success Action";
|
|
@@ -31,6 +32,7 @@ var DaffCartActionTypes;
|
|
|
31
32
|
DaffCartActionTypes["CartClearFailureAction"] = "[DaffCart] Cart Reset Failure Action";
|
|
32
33
|
DaffCartActionTypes["ResolveCartAction"] = "[DaffCart] Resolve Cart Action";
|
|
33
34
|
DaffCartActionTypes["ResolveCartSuccessAction"] = "[DaffCart] Resolve Cart Success Action";
|
|
35
|
+
DaffCartActionTypes["ResolveCartPartialSuccessAction"] = "[DaffCart] Resolve Cart Partial Success Action";
|
|
34
36
|
DaffCartActionTypes["ResolveCartServerSideAction"] = "[DaffCart] Resolve Cart Server Side Action";
|
|
35
37
|
DaffCartActionTypes["ResolveCartFailureAction"] = "[DaffCart] Resolve Cart Failure Action";
|
|
36
38
|
})(DaffCartActionTypes || (DaffCartActionTypes = {}));
|
|
@@ -60,6 +62,19 @@ class DaffCartLoadSuccess {
|
|
|
60
62
|
this.type = DaffCartActionTypes.CartLoadSuccessAction;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* An action that indicates a user's cart is loaded but recoverable errors occurred.
|
|
67
|
+
* There should be enough data to render the cart
|
|
68
|
+
* but the user should probably be shown error messages as well.
|
|
69
|
+
* A common example is some cart items being out of stock.
|
|
70
|
+
*/
|
|
71
|
+
class DaffCartLoadPartialSuccess {
|
|
72
|
+
constructor(payload, errors) {
|
|
73
|
+
this.payload = payload;
|
|
74
|
+
this.errors = errors;
|
|
75
|
+
this.type = DaffCartActionTypes.CartLoadPartialSuccessAction;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
63
78
|
/**
|
|
64
79
|
* Indicates the failed load of the cart.
|
|
65
80
|
*/
|
|
@@ -160,6 +175,19 @@ class DaffResolveCartSuccess {
|
|
|
160
175
|
this.type = DaffCartActionTypes.ResolveCartSuccessAction;
|
|
161
176
|
}
|
|
162
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* An action that indicates a user's cart is resolved but recoverable errors occurred.
|
|
180
|
+
* There should be enough data to render the cart
|
|
181
|
+
* but the user should probably be shown error messages as well.
|
|
182
|
+
* A common example is some cart items being out of stock.
|
|
183
|
+
*/
|
|
184
|
+
class DaffResolveCartPartialSuccess {
|
|
185
|
+
constructor(payload, errors) {
|
|
186
|
+
this.payload = payload;
|
|
187
|
+
this.errors = errors;
|
|
188
|
+
this.type = DaffCartActionTypes.ResolveCartPartialSuccessAction;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
163
191
|
/**
|
|
164
192
|
* An action that indicates that a cart failed to resolve.
|
|
165
193
|
*/
|
|
@@ -200,6 +228,9 @@ var DaffCartItemActionTypes;
|
|
|
200
228
|
DaffCartItemActionTypes["CartItemDeleteAction"] = "[DaffCart] Cart Item Remove Action";
|
|
201
229
|
DaffCartItemActionTypes["CartItemDeleteSuccessAction"] = "[DaffCart] Cart Item Remove Success Action";
|
|
202
230
|
DaffCartItemActionTypes["CartItemDeleteFailureAction"] = "[DaffCart] Cart Item Remove Failure Action";
|
|
231
|
+
DaffCartItemActionTypes["CartItemDeleteOutOfStockAction"] = "[DaffCart] Cart Item Delete Out Of Stock Action";
|
|
232
|
+
DaffCartItemActionTypes["CartItemDeleteOutOfStockSuccessAction"] = "[DaffCart] Cart Item Delete Out Of Stock Success Action";
|
|
233
|
+
DaffCartItemActionTypes["CartItemDeleteOutOfStockFailureAction"] = "[DaffCart] Cart Item Delete Out Of Stock Failure Action";
|
|
203
234
|
DaffCartItemActionTypes["CartItemStateResetAction"] = "[DaffCart] Cart Item State Reset Action";
|
|
204
235
|
})(DaffCartItemActionTypes || (DaffCartItemActionTypes = {}));
|
|
205
236
|
/**
|
|
@@ -341,6 +372,32 @@ class DaffCartItemDeleteFailure {
|
|
|
341
372
|
this.type = DaffCartItemActionTypes.CartItemDeleteFailureAction;
|
|
342
373
|
}
|
|
343
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* Triggers the deletion of all out of stock cart items.
|
|
377
|
+
*/
|
|
378
|
+
class DaffCartItemDeleteOutOfStock {
|
|
379
|
+
constructor() {
|
|
380
|
+
this.type = DaffCartItemActionTypes.CartItemDeleteOutOfStockAction;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Indicates the successful deletion of all out of stock cart items.
|
|
385
|
+
*/
|
|
386
|
+
class DaffCartItemDeleteOutOfStockSuccess {
|
|
387
|
+
constructor(payload) {
|
|
388
|
+
this.payload = payload;
|
|
389
|
+
this.type = DaffCartItemActionTypes.CartItemDeleteOutOfStockSuccessAction;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Indicates the failed deletion of all out of stock cart items.
|
|
394
|
+
*/
|
|
395
|
+
class DaffCartItemDeleteOutOfStockFailure {
|
|
396
|
+
constructor(payload) {
|
|
397
|
+
this.payload = payload;
|
|
398
|
+
this.type = DaffCartItemActionTypes.CartItemDeleteOutOfStockFailureAction;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
344
401
|
/**
|
|
345
402
|
* Resets cart item "new" or "updated" states to default.
|
|
346
403
|
*/
|
|
@@ -1017,12 +1074,13 @@ const daffCartItemEntitiesAdapter = (ɵ0)();
|
|
|
1017
1074
|
* @returns CartItem entities state
|
|
1018
1075
|
*/
|
|
1019
1076
|
function daffCartItemEntitiesReducer(state = daffCartItemEntitiesAdapter().getInitialState(), action) {
|
|
1077
|
+
var _a, _b;
|
|
1020
1078
|
const adapter = daffCartItemEntitiesAdapter();
|
|
1021
1079
|
switch (action.type) {
|
|
1022
1080
|
case DaffCartItemActionTypes.CartItemListSuccessAction:
|
|
1023
|
-
return adapter.setAll(action.payload.map(item => (Object.assign(Object.assign({}, item), { daffState: getDaffState(state.entities[item.id]) || DaffCartItemStateEnum.Default }))), state);
|
|
1081
|
+
return adapter.setAll(action.payload.map(item => (Object.assign(Object.assign({}, item), { daffState: getDaffState(state.entities[item.id]) || DaffCartItemStateEnum.Default, errors: [] }))), state);
|
|
1024
1082
|
case DaffCartItemActionTypes.CartItemLoadSuccessAction:
|
|
1025
|
-
return adapter.upsertOne(Object.assign(Object.assign({}, action.payload), { daffState: getDaffState(state.entities[action.payload.id]) || DaffCartItemStateEnum.Default }), state);
|
|
1083
|
+
return adapter.upsertOne(Object.assign(Object.assign({}, action.payload), { daffState: getDaffState(state.entities[action.payload.id]) || DaffCartItemStateEnum.Default, errors: [] }), state);
|
|
1026
1084
|
case DaffCartItemActionTypes.CartItemAddSuccessAction:
|
|
1027
1085
|
return adapter.setAll(updateAddedCartItemState(state.entities, action.payload.items), state);
|
|
1028
1086
|
case DaffCartItemActionTypes.CartItemUpdateSuccessAction:
|
|
@@ -1030,10 +1088,13 @@ function daffCartItemEntitiesReducer(state = daffCartItemEntitiesAdapter().getIn
|
|
|
1030
1088
|
case DaffCartItemActionTypes.CartItemDeleteFailureAction:
|
|
1031
1089
|
case DaffCartItemActionTypes.CartItemLoadFailureAction:
|
|
1032
1090
|
case DaffCartItemActionTypes.CartItemUpdateFailureAction:
|
|
1033
|
-
return adapter.upsertOne(Object.assign(Object.assign({}, state.entities[action.itemId]), { daffState: DaffCartItemStateEnum.Error }), state);
|
|
1091
|
+
return adapter.upsertOne(Object.assign(Object.assign({}, state.entities[action.itemId]), { daffState: DaffCartItemStateEnum.Error, errors: ((_b = (_a = state.entities[action.itemId]) === null || _a === void 0 ? void 0 : _a.errors) === null || _b === void 0 ? void 0 : _b.concat(action.payload)) || [action.payload] }), state);
|
|
1034
1092
|
case DaffCartItemActionTypes.CartItemDeleteSuccessAction:
|
|
1093
|
+
case DaffCartItemActionTypes.CartItemDeleteOutOfStockSuccessAction:
|
|
1035
1094
|
case DaffCartActionTypes.CartLoadSuccessAction:
|
|
1036
1095
|
case DaffCartActionTypes.ResolveCartSuccessAction:
|
|
1096
|
+
case DaffCartActionTypes.CartLoadPartialSuccessAction:
|
|
1097
|
+
case DaffCartActionTypes.ResolveCartPartialSuccessAction:
|
|
1037
1098
|
case DaffCartActionTypes.CartClearSuccessAction:
|
|
1038
1099
|
return adapter.setAll(action.payload.items.map(item => (Object.assign(Object.assign({}, item), { daffState: getDaffState(state.entities[item.id]) || DaffCartItemStateEnum.Default }))), state);
|
|
1039
1100
|
case DaffCartItemActionTypes.CartItemStateResetAction:
|
|
@@ -1055,16 +1116,16 @@ function updateAddedCartItemState(oldCartItems, newCartItems) {
|
|
|
1055
1116
|
const oldItem = oldCartItems[newItem.id];
|
|
1056
1117
|
switch (true) {
|
|
1057
1118
|
case !oldItem:
|
|
1058
|
-
return Object.assign(Object.assign({}, newItem), { daffState: DaffCartItemStateEnum.New });
|
|
1119
|
+
return Object.assign(Object.assign({}, newItem), { daffState: DaffCartItemStateEnum.New, errors: [] });
|
|
1059
1120
|
case (oldItem === null || oldItem === void 0 ? void 0 : oldItem.qty) !== newItem.qty:
|
|
1060
|
-
return Object.assign(Object.assign({}, newItem), { daffState: DaffCartItemStateEnum.Updated });
|
|
1121
|
+
return Object.assign(Object.assign({}, newItem), { daffState: DaffCartItemStateEnum.Updated, errors: [] });
|
|
1061
1122
|
default:
|
|
1062
1123
|
return newItem;
|
|
1063
1124
|
}
|
|
1064
1125
|
});
|
|
1065
1126
|
}
|
|
1066
1127
|
function updateMutatedCartItemState(responseItems, stateItems, itemId) {
|
|
1067
|
-
return responseItems.map(item => item.id === itemId ? Object.assign(Object.assign({}, item), { daffState: DaffCartItemStateEnum.Updated }) : Object.assign(Object.assign({}, item), { daffState: getDaffState(stateItems[item.id]) || DaffCartItemStateEnum.Default }));
|
|
1128
|
+
return responseItems.map(item => item.id === itemId ? Object.assign(Object.assign({}, item), { daffState: DaffCartItemStateEnum.Updated, errors: [] }) : Object.assign(Object.assign({}, item), { daffState: getDaffState(stateItems[item.id]) || DaffCartItemStateEnum.Default }));
|
|
1068
1129
|
}
|
|
1069
1130
|
|
|
1070
1131
|
const daffCartOrderInitialState = {
|
|
@@ -1160,8 +1221,8 @@ const initialState = Object.freeze({
|
|
|
1160
1221
|
resolved: DaffCartResolveState.Default,
|
|
1161
1222
|
});
|
|
1162
1223
|
|
|
1163
|
-
const initializeErrorAdder = (errorSpace) => (errors,
|
|
1164
|
-
errors: Object.assign(Object.assign({}, errors), { [errorSpace]: errors[errorSpace].concat(
|
|
1224
|
+
const initializeErrorAdder = (errorSpace) => (errors, ...errorsToAdd) => ({
|
|
1225
|
+
errors: Object.assign(Object.assign({}, errors), { [errorSpace]: errors[errorSpace].concat(errorsToAdd) }),
|
|
1165
1226
|
});
|
|
1166
1227
|
const initializeErrorResetter = (errorSpace) => (errors) => ({
|
|
1167
1228
|
errors: Object.assign(Object.assign({}, errors), { [errorSpace]: [] }),
|
|
@@ -1232,6 +1293,10 @@ function cartItemReducer(state = initialState, action) {
|
|
|
1232
1293
|
case DaffCartItemActionTypes.CartItemListAction:
|
|
1233
1294
|
case DaffCartItemActionTypes.CartItemLoadAction:
|
|
1234
1295
|
return Object.assign(Object.assign({}, state), setLoading$2(state.loading, "Resolving" /* Resolving */));
|
|
1296
|
+
case DaffCartItemActionTypes.CartItemUpdateAction:
|
|
1297
|
+
case DaffCartItemActionTypes.CartItemDeleteAction:
|
|
1298
|
+
case DaffCartItemActionTypes.CartItemDeleteOutOfStockAction:
|
|
1299
|
+
return Object.assign(Object.assign({}, state), setLoading$2(state.loading, "Mutating" /* Mutating */));
|
|
1235
1300
|
case DaffCartItemActionTypes.CartItemAddAction:
|
|
1236
1301
|
return Object.assign(Object.assign({}, state), setLoading$2(state.loading, "Adding" /* Adding */));
|
|
1237
1302
|
case DaffCartItemActionTypes.CartItemListSuccessAction:
|
|
@@ -1244,11 +1309,16 @@ function cartItemReducer(state = initialState, action) {
|
|
|
1244
1309
|
case DaffCartItemActionTypes.CartItemAddSuccessAction:
|
|
1245
1310
|
case DaffCartItemActionTypes.CartItemDeleteSuccessAction:
|
|
1246
1311
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$2(state.errors)), { cart: Object.assign(Object.assign({}, state.cart), action.payload) }), setLoading$2(state.loading, "Stable" /* Complete */));
|
|
1312
|
+
case DaffCartItemActionTypes.CartItemDeleteOutOfStockSuccessAction:
|
|
1313
|
+
return Object.assign(Object.assign(Object.assign({}, state), { errors: Object.assign(Object.assign({}, state.errors), { [DaffCartOperationType.Item]: [],
|
|
1314
|
+
// out of stock errors can be in the main cart, remove them here
|
|
1315
|
+
[DaffCartOperationType.Cart]: state.errors[DaffCartOperationType.Cart].filter(({ code }) => code !== DaffCartDriverErrorCodes.PRODUCT_OUT_OF_STOCK) }), cart: Object.assign(Object.assign({}, state.cart), action.payload) }), setLoading$2(state.loading, "Stable" /* Complete */));
|
|
1247
1316
|
case DaffCartItemActionTypes.CartItemListFailureAction:
|
|
1248
1317
|
case DaffCartItemActionTypes.CartItemLoadFailureAction:
|
|
1249
1318
|
case DaffCartItemActionTypes.CartItemUpdateFailureAction:
|
|
1250
1319
|
case DaffCartItemActionTypes.CartItemAddFailureAction:
|
|
1251
1320
|
case DaffCartItemActionTypes.CartItemDeleteFailureAction:
|
|
1321
|
+
case DaffCartItemActionTypes.CartItemDeleteOutOfStockFailureAction:
|
|
1252
1322
|
return Object.assign(Object.assign(Object.assign({}, state), addError$2(state.errors, action.payload)), setLoading$2(state.loading, "Stable" /* Complete */));
|
|
1253
1323
|
default:
|
|
1254
1324
|
return state;
|
|
@@ -1405,19 +1475,22 @@ function cartReducer(state = initialState, action) {
|
|
|
1405
1475
|
case DaffCartActionTypes.CartLoadSuccessAction:
|
|
1406
1476
|
case DaffCartActionTypes.CartClearSuccessAction:
|
|
1407
1477
|
case DaffCartActionTypes.AddToCartSuccessAction:
|
|
1408
|
-
case DaffCartActionTypes.CartCreateSuccessAction:
|
|
1409
1478
|
case DaffCartActionTypes.ResolveCartSuccessAction:
|
|
1410
1479
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$8(state.errors)), { cart: Object.assign(Object.assign({}, state.cart), action.payload) }), setLoading$8(state.loading, "Stable" /* Complete */));
|
|
1411
1480
|
case DaffCartActionTypes.CartCreateSuccessAction:
|
|
1412
1481
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), resetErrors$8(state.errors)), { cart: Object.assign(Object.assign({}, initialState.cart), action.payload) }), setLoading$8(state.loading, "Stable" /* Complete */));
|
|
1413
|
-
case DaffCartActionTypes.CartLoadFailureAction:
|
|
1414
1482
|
case DaffCartActionTypes.CartClearFailureAction:
|
|
1415
1483
|
case DaffCartActionTypes.AddToCartFailureAction:
|
|
1416
1484
|
case DaffCartActionTypes.CartCreateFailureAction:
|
|
1417
1485
|
case DaffCartActionTypes.CartStorageFailureAction:
|
|
1418
|
-
case DaffCartActionTypes.ResolveCartFailureAction:
|
|
1419
1486
|
case DaffCartActionTypes.ResolveCartServerSideAction:
|
|
1420
1487
|
return Object.assign(Object.assign(Object.assign({}, state), addError$8(state.errors, action.payload)), setLoading$8(state.loading, "Stable" /* Complete */));
|
|
1488
|
+
case DaffCartActionTypes.CartLoadFailureAction:
|
|
1489
|
+
case DaffCartActionTypes.ResolveCartFailureAction:
|
|
1490
|
+
return Object.assign(Object.assign(Object.assign({}, state), addError$8(state.errors, ...action.payload)), setLoading$8(state.loading, "Stable" /* Stable */));
|
|
1491
|
+
case DaffCartActionTypes.ResolveCartPartialSuccessAction:
|
|
1492
|
+
case DaffCartActionTypes.CartLoadPartialSuccessAction:
|
|
1493
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, state), { cart: Object.assign(Object.assign({}, state.cart), action.payload) }), addError$8(state.errors, ...action.errors)), setLoading$8(state.loading, "Stable" /* Stable */));
|
|
1421
1494
|
default:
|
|
1422
1495
|
return state;
|
|
1423
1496
|
}
|
|
@@ -1536,6 +1609,8 @@ const createCartItemEntitiesSelectors = () => {
|
|
|
1536
1609
|
return cartItem.options;
|
|
1537
1610
|
})).memoized;
|
|
1538
1611
|
const selectIsCartItemOutOfStock = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => cartItem ? !cartItem.in_stock : null)).memoized;
|
|
1612
|
+
const selectOutOfStockCartItems = createSelector(selectAllCartItems, items => items.filter(item => !item.in_stock));
|
|
1613
|
+
const selectInStockCartItems = createSelector(selectAllCartItems, items => items.filter(item => item.in_stock));
|
|
1539
1614
|
const selectCartItemMutating = createSelector(selectAllCartItems, (cartItems) => cartItems === null || cartItems === void 0 ? void 0 : cartItems.reduce((acc, item) => acc || item.daffState === DaffCartItemStateEnum.Mutating, false));
|
|
1540
1615
|
const selectCartItemState = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => (cartItem === null || cartItem === void 0 ? void 0 : cartItem.daffState) || null)).memoized;
|
|
1541
1616
|
const selectCartItemQuantity = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => (cartItem === null || cartItem === void 0 ? void 0 : cartItem.qty) || 0)).memoized;
|
|
@@ -1543,6 +1618,7 @@ const createCartItemEntitiesSelectors = () => {
|
|
|
1543
1618
|
const selectCartItemPrice = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => (cartItem === null || cartItem === void 0 ? void 0 : cartItem.price) || 0)).memoized;
|
|
1544
1619
|
const selectCartItemDiscounts = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => (cartItem === null || cartItem === void 0 ? void 0 : cartItem.discounts) || [])).memoized;
|
|
1545
1620
|
const selectCartItemTotalDiscount = defaultMemoize((itemId) => createSelector(selectCartItemDiscounts(itemId), (discounts) => (discounts === null || discounts === void 0 ? void 0 : discounts.reduce((acc, { amount }) => daffAdd(acc, amount), 0)) || 0)).memoized;
|
|
1621
|
+
const selectCartItemErrors = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => (cartItem === null || cartItem === void 0 ? void 0 : cartItem.errors) || [])).memoized;
|
|
1546
1622
|
return {
|
|
1547
1623
|
selectCartItemEntitiesState,
|
|
1548
1624
|
selectCartItemIds,
|
|
@@ -1554,6 +1630,8 @@ const createCartItemEntitiesSelectors = () => {
|
|
|
1554
1630
|
selectCartItemConfiguredAttributes,
|
|
1555
1631
|
selectCartItemCompositeOptions,
|
|
1556
1632
|
selectIsCartItemOutOfStock,
|
|
1633
|
+
selectInStockCartItems,
|
|
1634
|
+
selectOutOfStockCartItems,
|
|
1557
1635
|
selectCartItemMutating,
|
|
1558
1636
|
selectCartItemState,
|
|
1559
1637
|
selectCartItemPrice,
|
|
@@ -1561,6 +1639,7 @@ const createCartItemEntitiesSelectors = () => {
|
|
|
1561
1639
|
selectCartItemQuantity,
|
|
1562
1640
|
selectCartItemDiscounts,
|
|
1563
1641
|
selectCartItemTotalDiscount,
|
|
1642
|
+
selectCartItemErrors,
|
|
1564
1643
|
};
|
|
1565
1644
|
};
|
|
1566
1645
|
const ɵ0$2 = createCartItemEntitiesSelectors;
|
|
@@ -1938,12 +2017,13 @@ __decorate([
|
|
|
1938
2017
|
], DaffCartCouponEffects.prototype, "removeAll$", void 0);
|
|
1939
2018
|
|
|
1940
2019
|
class DaffCartItemEffects {
|
|
1941
|
-
constructor(actions$, errorMatcher, driver, storage, cartItemStateDebounceTime) {
|
|
2020
|
+
constructor(actions$, errorMatcher, driver, storage, cartItemStateDebounceTime, store) {
|
|
1942
2021
|
this.actions$ = actions$;
|
|
1943
2022
|
this.errorMatcher = errorMatcher;
|
|
1944
2023
|
this.driver = driver;
|
|
1945
2024
|
this.storage = storage;
|
|
1946
2025
|
this.cartItemStateDebounceTime = cartItemStateDebounceTime;
|
|
2026
|
+
this.store = store;
|
|
1947
2027
|
this.list$ = 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)))))));
|
|
1948
2028
|
this.get$ = 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))))));
|
|
1949
2029
|
this.add$ = this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemAddAction), switchMap((action) => this.driver.add(this.storage.getCartId(), action.input).pipe(map((resp) => new DaffCartItemAddSuccess(resp)), catchError(error => of(new DaffCartItemAddFailure(this.errorMatcher(error)))))));
|
|
@@ -1954,6 +2034,9 @@ class DaffCartItemEffects {
|
|
|
1954
2034
|
// these actions will cause the cart item state reset
|
|
1955
2035
|
DaffCartItemActionTypes.CartItemAddSuccessAction, DaffCartItemActionTypes.CartItemUpdateSuccessAction), mapTo(new DaffCartItemStateReset()));
|
|
1956
2036
|
this.delete$ = this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemDeleteAction), mergeMap((action) => this.driver.delete(this.storage.getCartId(), action.itemId).pipe(map((resp) => new DaffCartItemDeleteSuccess(resp)), catchError(error => of(new DaffCartItemDeleteFailure(this.errorMatcher(error), action.itemId))))));
|
|
2037
|
+
this.removeOutOfStock$ = this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemDeleteOutOfStockAction), switchMap((action) => this.store.pipe(select(getDaffCartSelectors().selectOutOfStockCartItems), take(1))), switchMap(items => items.length > 0
|
|
2038
|
+
? combineLatest(items.map(item => this.driver.delete(this.storage.getCartId(), item.id))).pipe(map(partialCarts => Object.assign({}, ...partialCarts)))
|
|
2039
|
+
: this.store.pipe(select(getDaffCartSelectors().selectCartValue), take(1))), map(cart => new DaffCartItemDeleteOutOfStockSuccess(cart)), catchError(error => of(new DaffCartItemDeleteOutOfStockFailure(this.errorMatcher(error)))));
|
|
1957
2040
|
}
|
|
1958
2041
|
}
|
|
1959
2042
|
DaffCartItemEffects.decorators = [
|
|
@@ -1965,7 +2048,8 @@ DaffCartItemEffects.ctorParameters = () => [
|
|
|
1965
2048
|
{ type: undefined, decorators: [{ type: Inject, args: [DAFF_CART_ERROR_MATCHER,] }] },
|
|
1966
2049
|
{ type: undefined, decorators: [{ type: Inject, args: [DaffCartItemDriver,] }] },
|
|
1967
2050
|
{ type: DaffCartStorageService },
|
|
1968
|
-
{ type: Number, decorators: [{ type: Inject, args: [DaffCartItemStateDebounceTime,] }] }
|
|
2051
|
+
{ type: Number, decorators: [{ type: Inject, args: [DaffCartItemStateDebounceTime,] }] },
|
|
2052
|
+
{ type: Store }
|
|
1969
2053
|
];
|
|
1970
2054
|
__decorate([
|
|
1971
2055
|
Effect(),
|
|
@@ -1991,6 +2075,10 @@ __decorate([
|
|
|
1991
2075
|
Effect(),
|
|
1992
2076
|
__metadata("design:type", Object)
|
|
1993
2077
|
], DaffCartItemEffects.prototype, "delete$", void 0);
|
|
2078
|
+
__decorate([
|
|
2079
|
+
Effect(),
|
|
2080
|
+
__metadata("design:type", Object)
|
|
2081
|
+
], DaffCartItemEffects.prototype, "removeOutOfStock$", void 0);
|
|
1994
2082
|
|
|
1995
2083
|
class DaffCartOrderEffects {
|
|
1996
2084
|
constructor(actions$, errorMatcher, driver, storage) {
|
|
@@ -2099,16 +2187,32 @@ class DaffCartResolverEffects {
|
|
|
2099
2187
|
this.errorMatcher = errorMatcher;
|
|
2100
2188
|
this.cartStorage = cartStorage;
|
|
2101
2189
|
this.driver = driver;
|
|
2102
|
-
this.onResolveCart = () => this.actions$.pipe(ofType(DaffCartActionTypes.ResolveCartAction), switchMap(() => of(null).pipe(map(() => this.cartStorage.getCartId()), switchMap(cartId => cartId ? of({ id: cartId }) : this.driver.create()), switchMap(({ id }) => this.driver.get(id)),
|
|
2190
|
+
this.onResolveCart = () => this.actions$.pipe(ofType(DaffCartActionTypes.ResolveCartAction), switchMap(() => of(null).pipe(map(() => this.cartStorage.getCartId()), switchMap(cartId => cartId ? of({ id: cartId }) : this.driver.create()), switchMap(({ id }) => this.driver.get(id)), switchMap(({ response, errors }) => {
|
|
2191
|
+
if (errors.length === 0) {
|
|
2192
|
+
return of(new DaffResolveCartSuccess(response));
|
|
2193
|
+
}
|
|
2194
|
+
const hasOnlyRecoverableErrors = errors.reduce((acc, error) => acc && error.recoverable, true);
|
|
2195
|
+
if (hasOnlyRecoverableErrors) {
|
|
2196
|
+
return of(new DaffResolveCartPartialSuccess(response, errors.map(error => this.errorMatcher(error))));
|
|
2197
|
+
}
|
|
2198
|
+
if (errors.filter(error => error instanceof DaffCartNotFoundError).length > 0) {
|
|
2199
|
+
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))]))));
|
|
2200
|
+
}
|
|
2201
|
+
// there are no special case errors, DaffResolveCartFailure will suffice
|
|
2202
|
+
// just map the errors
|
|
2203
|
+
return of(new DaffResolveCartFailure(errors.map(error => this.errorMatcher(
|
|
2204
|
+
// I wish there was a better way to check this
|
|
2205
|
+
error instanceof DaffInheritableError || !!error.code
|
|
2206
|
+
? error
|
|
2207
|
+
: new DaffCartResolutionError(error.message)))));
|
|
2208
|
+
}), catchError((error) => {
|
|
2103
2209
|
switch (true) {
|
|
2104
2210
|
case error instanceof DaffServerSideStorageError:
|
|
2105
2211
|
return of(new DaffResolveCartServerSide(this.errorMatcher(new DaffCartServerSideResolutionError(error.message))));
|
|
2106
2212
|
case error instanceof DaffStorageServiceError:
|
|
2107
|
-
return of(new DaffResolveCartFailure(this.errorMatcher(new DaffCartStorageResolutionError(error.message))));
|
|
2108
|
-
case error instanceof DaffCartNotFoundError:
|
|
2109
|
-
return this.driver.create().pipe(switchMap(({ id }) => this.driver.get(id)), map(resp => new DaffResolveCartSuccess(resp)), catchError((innerError) => of(new DaffResolveCartFailure(this.errorMatcher(new DaffCartNotFoundOrCreatedResolutionError(innerError.message))))));
|
|
2213
|
+
return of(new DaffResolveCartFailure([this.errorMatcher(new DaffCartStorageResolutionError(error.message))]));
|
|
2110
2214
|
default:
|
|
2111
|
-
return of(new DaffResolveCartFailure(this.errorMatcher(new DaffCartResolutionError(error.message))));
|
|
2215
|
+
return of(new DaffResolveCartFailure([this.errorMatcher(new DaffCartResolutionError(error.message))]));
|
|
2112
2216
|
}
|
|
2113
2217
|
}))));
|
|
2114
2218
|
}
|
|
@@ -2228,9 +2332,18 @@ class DaffCartEffects {
|
|
|
2228
2332
|
this.storeId$ = this.actions$.pipe(ofType(DaffCartActionTypes.CartCreateSuccessAction, DaffCartActionTypes.ResolveCartSuccessAction), switchMap((action) => of(null).pipe(tap(() => {
|
|
2229
2333
|
this.storage.setCartId(action.payload.id);
|
|
2230
2334
|
}), switchMapTo(EMPTY), catchError(error => of(new DaffCartStorageFailure(this.errorMatcher(error)))))));
|
|
2231
|
-
this.get$ = this.actions$.pipe(ofType(DaffCartActionTypes.CartLoadAction), switchMap((action) => of(null).pipe(map(() => this.storage.getCartId()), switchMap(cartId => this.driver.get(cartId)), map((
|
|
2335
|
+
this.get$ = this.actions$.pipe(ofType(DaffCartActionTypes.CartLoadAction), switchMap((action) => of(null).pipe(map(() => this.storage.getCartId()), switchMap(cartId => this.driver.get(cartId)), map(({ response, errors }) => {
|
|
2336
|
+
if (errors.length === 0) {
|
|
2337
|
+
return new DaffCartLoadSuccess(response);
|
|
2338
|
+
}
|
|
2339
|
+
const hasOnlyRecoverableErrors = errors.reduce((acc, error) => acc && error.recoverable, true);
|
|
2340
|
+
if (hasOnlyRecoverableErrors) {
|
|
2341
|
+
return new DaffCartLoadPartialSuccess(response, errors.map(error => this.errorMatcher(error)));
|
|
2342
|
+
}
|
|
2343
|
+
return new DaffCartLoadFailure(errors.map(error => this.errorMatcher(error)));
|
|
2344
|
+
}), catchError(error => of(error instanceof DaffStorageServiceError
|
|
2232
2345
|
? new DaffCartStorageFailure(this.errorMatcher(error))
|
|
2233
|
-
: new DaffCartLoadFailure(this.errorMatcher(error)))))));
|
|
2346
|
+
: new DaffCartLoadFailure([this.errorMatcher(error)]))))));
|
|
2234
2347
|
this.addToCart$ = this.actions$.pipe(ofType(DaffCartActionTypes.AddToCartAction), switchMap((action) => this.driver.addToCart(action.payload.productId, action.payload.qty).pipe(map((resp) => new DaffAddToCartSuccess(resp)), catchError(error => of(new DaffAddToCartFailure(this.errorMatcher(error)))))));
|
|
2235
2348
|
this.clear$ = this.actions$.pipe(ofType(DaffCartActionTypes.CartClearAction), switchMap((action) => of(null).pipe(map(() => this.storage.getCartId()), switchMap(cartId => this.driver.clear(cartId)), map((resp) => new DaffCartClearSuccess(resp)), catchError(error => of(error instanceof DaffStorageServiceError
|
|
2236
2349
|
? new DaffCartStorageFailure(this.errorMatcher(error))
|
|
@@ -2319,7 +2432,7 @@ class DaffCartFacade {
|
|
|
2319
2432
|
paymentMethodMap) {
|
|
2320
2433
|
this.store = store;
|
|
2321
2434
|
this.paymentMethodMap = paymentMethodMap;
|
|
2322
|
-
const { selectCartValue, selectCartResolved, selectCartLoadingObject, selectCartFeatureLoading, selectCartFeatureResolving, selectCartFeatureMutating, selectCartLoading, selectCartResolving, selectCartMutating, selectBillingAddressLoading, selectBillingAddressResolving, selectBillingAddressMutating, selectShippingAddressLoading, selectShippingAddressResolving, selectShippingAddressMutating, selectShippingInformationLoading, selectShippingInformationResolving, selectShippingInformationMutating, selectShippingMethodsLoading, selectShippingMethodsResolving, selectPaymentLoading, selectPaymentResolving, selectPaymentMutating, selectPaymentMethodsLoading, selectPaymentMethodsResolving, selectCouponLoading, selectCouponResolving, selectCouponMutating, selectItemLoading, selectItemAdding, selectItemResolving, selectCartItemMutating, selectCartErrorsObject, selectCartErrors, selectItemErrors, selectBillingAddressErrors, selectShippingAddressErrors, selectShippingInformationErrors, selectShippingMethodsErrors, selectPaymentErrors, selectPaymentMethodsErrors, selectCouponErrors, selectCartId, selectCartSubtotal, selectCartGrandTotal, selectCartSubtotalExcludingTax, selectCartSubtotalIncludingTax, selectCartSubtotalWithDiscountExcludingTax, selectCartSubtotalWithDiscountIncludingTax, selectCartDiscountTotals, selectCartTotalTax, selectCartShippingTotal, selectCartCoupons, selectCartItems, selectCartHasOutOfStockItems, selectCartItemEntities, selectTotalNumberOfCartItems, selectCartItemConfiguredAttributes, selectCartItemCompositeOptions, selectCartBillingAddress, selectCartShippingAddress, selectCartPayment, selectCartTotals, selectCartShippingInformation, selectCartAvailableShippingMethods, selectCartAvailablePaymentMethods, selectIsCartEmpty, selectIsBillingSameAsShipping, selectCartOrderLoading, selectCartOrderErrors, selectCartOrderValue, selectCartOrderId, selectCartOrderCartId, selectHasOrderResult, selectIsCartItemOutOfStock, selectCartItemState, selectHasBillingAddress, selectHasShippingAddress, selectHasShippingMethod, selectHasPaymentMethod, selectCanPlaceOrder, selectCartItemPrice, selectCartItemRowTotal, selectCartItemQuantity, selectCartItemDiscounts, selectCartItemTotalDiscount, } = getDaffCartSelectors();
|
|
2435
|
+
const { selectCartValue, selectCartResolved, selectCartLoadingObject, selectCartFeatureLoading, selectCartFeatureResolving, selectCartFeatureMutating, selectCartLoading, selectCartResolving, selectCartMutating, selectBillingAddressLoading, selectBillingAddressResolving, selectBillingAddressMutating, selectShippingAddressLoading, selectShippingAddressResolving, selectShippingAddressMutating, selectShippingInformationLoading, selectShippingInformationResolving, selectShippingInformationMutating, selectShippingMethodsLoading, selectShippingMethodsResolving, selectPaymentLoading, selectPaymentResolving, selectPaymentMutating, selectPaymentMethodsLoading, selectPaymentMethodsResolving, selectCouponLoading, selectCouponResolving, selectCouponMutating, selectItemLoading, selectItemAdding, selectItemResolving, selectCartItemMutating, selectCartErrorsObject, selectCartErrors, selectItemErrors, selectBillingAddressErrors, selectShippingAddressErrors, selectShippingInformationErrors, selectShippingMethodsErrors, selectPaymentErrors, selectPaymentMethodsErrors, selectCouponErrors, selectCartId, selectCartSubtotal, selectCartGrandTotal, selectCartSubtotalExcludingTax, selectCartSubtotalIncludingTax, selectCartSubtotalWithDiscountExcludingTax, selectCartSubtotalWithDiscountIncludingTax, selectCartDiscountTotals, selectCartTotalTax, selectCartShippingTotal, selectCartCoupons, selectCartItems, selectAllCartItems, selectCartHasOutOfStockItems, selectOutOfStockCartItems, selectInStockCartItems, selectCartItemEntities, selectTotalNumberOfCartItems, selectCartItemConfiguredAttributes, selectCartItemCompositeOptions, selectCartBillingAddress, selectCartShippingAddress, selectCartPayment, selectCartTotals, selectCartShippingInformation, selectCartAvailableShippingMethods, selectCartAvailablePaymentMethods, selectIsCartEmpty, selectIsBillingSameAsShipping, selectCartOrderLoading, selectCartOrderErrors, selectCartOrderValue, selectCartOrderId, selectCartOrderCartId, selectHasOrderResult, selectIsCartItemOutOfStock, selectCartItemState, selectHasBillingAddress, selectHasShippingAddress, selectHasShippingMethod, selectHasPaymentMethod, selectCanPlaceOrder, selectCartItemPrice, selectCartItemRowTotal, selectCartItemQuantity, selectCartItemDiscounts, selectCartItemTotalDiscount, selectCartItemErrors, } = getDaffCartSelectors();
|
|
2323
2436
|
this._selectCartItemConfiguredAttributes = selectCartItemConfiguredAttributes;
|
|
2324
2437
|
this._selectCartItemCompositeOptions = selectCartItemCompositeOptions;
|
|
2325
2438
|
this._selectIsCartItemOutOfStock = selectIsCartItemOutOfStock;
|
|
@@ -2329,6 +2442,7 @@ class DaffCartFacade {
|
|
|
2329
2442
|
this._selectCartItemRowTotal = selectCartItemRowTotal;
|
|
2330
2443
|
this._selectCartItemDiscounts = selectCartItemDiscounts;
|
|
2331
2444
|
this._selectCartItemTotalDiscount = selectCartItemTotalDiscount;
|
|
2445
|
+
this._selectCartItemErrors = selectCartItemErrors;
|
|
2332
2446
|
this.cart$ = this.store.pipe(select(selectCartValue));
|
|
2333
2447
|
this.resolved$ = this.store.pipe(select(selectCartResolved));
|
|
2334
2448
|
this.loadingObject$ = this.store.pipe(select(selectCartLoadingObject));
|
|
@@ -2383,8 +2497,11 @@ class DaffCartFacade {
|
|
|
2383
2497
|
this.shippingTotal$ = this.store.pipe(select(selectCartShippingTotal));
|
|
2384
2498
|
this.coupons$ = this.store.pipe(select(selectCartCoupons));
|
|
2385
2499
|
this.items$ = this.store.pipe(select(selectCartItems));
|
|
2500
|
+
this.itemEntities$ = this.store.pipe(select(selectAllCartItems));
|
|
2386
2501
|
this.totalItems$ = this.store.pipe(select(selectTotalNumberOfCartItems));
|
|
2387
2502
|
this.hasOutOfStockItems$ = this.store.pipe(select(selectCartHasOutOfStockItems));
|
|
2503
|
+
this.outOfStockItems$ = this.store.pipe(select(selectOutOfStockCartItems));
|
|
2504
|
+
this.inStockItems$ = this.store.pipe(select(selectInStockCartItems));
|
|
2388
2505
|
this.itemDictionary$ = this.store.pipe(select(selectCartItemEntities));
|
|
2389
2506
|
this.billingAddress$ = this.store.pipe(select(selectCartBillingAddress));
|
|
2390
2507
|
this.shippingAddress$ = this.store.pipe(select(selectCartShippingAddress));
|
|
@@ -2439,6 +2556,10 @@ class DaffCartFacade {
|
|
|
2439
2556
|
getCartItemTotalDiscount(itemId) {
|
|
2440
2557
|
return this.store.pipe(select(this._selectCartItemTotalDiscount(itemId)));
|
|
2441
2558
|
}
|
|
2559
|
+
getCartItemErrors(itemId) {
|
|
2560
|
+
return this.store.pipe(select(this._selectCartItemErrors(itemId)));
|
|
2561
|
+
}
|
|
2562
|
+
;
|
|
2442
2563
|
dispatch(action) {
|
|
2443
2564
|
this.store.dispatch(action);
|
|
2444
2565
|
}
|
|
@@ -2459,5 +2580,5 @@ DaffCartFacade.ctorParameters = () => [
|
|
|
2459
2580
|
* Generated bundle index. Do not edit.
|
|
2460
2581
|
*/
|
|
2461
2582
|
|
|
2462
|
-
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, DaffCartItemDeleteSuccess, DaffCartItemList, DaffCartItemListFailure, DaffCartItemListSuccess, DaffCartItemLoad, DaffCartItemLoadFailure, DaffCartItemLoadSuccess, DaffCartItemStateDebounceTime, DaffCartItemStateEnum, DaffCartItemStateReset, DaffCartItemUpdate, DaffCartItemUpdateFailure, DaffCartItemUpdateSuccess, DaffCartLoad, DaffCartLoadFailure, 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, DaffResolveCartServerSide, DaffResolveCartSuccess, daffCartOrderInitialState, daffCartOrderReducer, daffCartProvideExtraReducers, daffCartReducer, daffCartReducers, getDaffCartSelectors, initialState, initializeLoadingSetter, ɵ0$5 as ɵ0, ɵ1$3 as ɵ1, cartReducer as ɵa, cartItemReducer as ɵb, cartBillingAddressReducer as ɵc, cartShippingAddressReducer as ɵd, cartShippingMethodsReducer as ɵe, cartShippingInformationReducer as ɵf, cartPaymentReducer as ɵg, cartPaymentMethodsReducer as ɵh, cartCouponReducer as ɵi, cartResolveReducer as ɵj, daffCartItemEntitiesReducer as ɵk, DAFF_CART_REDUCERS as ɵl, DaffCartEffects as ɵm, DaffCartItemEffects as ɵn, DaffCartBillingAddressEffects as ɵo, DaffCartShippingAddressEffects as ɵp, DaffCartAddressEffects as ɵq, DaffCartShippingInformationEffects as ɵr, DaffCartShippingMethodsEffects as ɵs, DaffCartPaymentEffects as ɵt, DaffCartPaymentMethodsEffects as ɵu, DaffCartOrderEffects as ɵv, DaffCartCouponEffects as ɵw, DaffCartResolverEffects as ɵx };
|
|
2583
|
+
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, initialState, initializeLoadingSetter, ɵ0$5 as ɵ0, ɵ1$3 as ɵ1, cartReducer as ɵa, cartItemReducer as ɵb, cartBillingAddressReducer as ɵc, cartShippingAddressReducer as ɵd, cartShippingMethodsReducer as ɵe, cartShippingInformationReducer as ɵf, cartPaymentReducer as ɵg, cartPaymentMethodsReducer as ɵh, cartCouponReducer as ɵi, cartResolveReducer as ɵj, daffCartItemEntitiesReducer as ɵk, DAFF_CART_REDUCERS as ɵl, DaffCartEffects as ɵm, DaffCartItemEffects as ɵn, DaffCartBillingAddressEffects as ɵo, DaffCartShippingAddressEffects as ɵp, DaffCartAddressEffects as ɵq, DaffCartShippingInformationEffects as ɵr, DaffCartShippingMethodsEffects as ɵs, DaffCartPaymentEffects as ɵt, DaffCartPaymentMethodsEffects as ɵu, DaffCartOrderEffects as ɵv, DaffCartCouponEffects as ɵw, DaffCartResolverEffects as ɵx };
|
|
2463
2584
|
//# sourceMappingURL=daffodil-cart-state.js.map
|