@daffodil/cart 0.39.8 → 0.39.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.
Files changed (34) hide show
  1. package/bundles/daffodil-cart-state-testing.umd.js +10 -2
  2. package/bundles/daffodil-cart-state-testing.umd.js.map +1 -1
  3. package/bundles/daffodil-cart-state-testing.umd.min.js +2 -2
  4. package/bundles/daffodil-cart-state-testing.umd.min.js.map +1 -1
  5. package/bundles/daffodil-cart-state.umd.js +20 -7
  6. package/bundles/daffodil-cart-state.umd.js.map +1 -1
  7. package/bundles/daffodil-cart-state.umd.min.js +1 -1
  8. package/bundles/daffodil-cart-state.umd.min.js.map +1 -1
  9. package/esm2015/state/effects/cart-resolver.effects.js +5 -2
  10. package/esm2015/state/facades/cart/cart-facade.interface.js +1 -1
  11. package/esm2015/state/facades/cart/cart.facade.js +7 -2
  12. package/esm2015/state/models/stateful-cart-item.js +1 -1
  13. package/esm2015/state/reducers/cart-item/cart-item.reducer.js +3 -1
  14. package/esm2015/state/reducers/cart-item-entities/cart-item-entities.reducer.js +8 -7
  15. package/esm2015/state/selectors/cart-item-entities/cart-item-entities.selectors.js +3 -1
  16. package/esm2015/state/testing/factories/stateful-cart-item.factory.js +2 -1
  17. package/esm2015/state/testing/factories/stateful-composite-cart-item.factory.js +5 -1
  18. package/esm2015/state/testing/factories/stateful-configurable-cart-item.factory.js +5 -1
  19. package/esm2015/state/testing/mock-cart-facade.js +4 -1
  20. package/fesm2015/daffodil-cart-state-testing.js +12 -0
  21. package/fesm2015/daffodil-cart-state-testing.js.map +1 -1
  22. package/fesm2015/daffodil-cart-state.js +21 -8
  23. package/fesm2015/daffodil-cart-state.js.map +1 -1
  24. package/package.json +5 -5
  25. package/state/daffodil-cart-state.metadata.json +1 -1
  26. package/state/facades/cart/cart-facade.interface.d.ts +4 -0
  27. package/state/facades/cart/cart.facade.d.ts +2 -0
  28. package/state/models/stateful-cart-item.d.ts +5 -0
  29. package/state/selectors/cart-item-entities/cart-item-entities.selectors.d.ts +5 -0
  30. package/state/testing/daffodil-cart-state-testing.metadata.json +1 -1
  31. package/state/testing/factories/stateful-cart-item.factory.d.ts +1 -0
  32. package/state/testing/factories/stateful-composite-cart-item.factory.d.ts +1 -0
  33. package/state/testing/factories/stateful-configurable-cart-item.factory.d.ts +1 -0
  34. package/state/testing/mock-cart-facade.d.ts +1 -0
@@ -1091,12 +1091,13 @@
1091
1091
  */
1092
1092
  function daffCartItemEntitiesReducer(state, action) {
1093
1093
  if (state === void 0) { state = daffCartItemEntitiesAdapter().getInitialState(); }
1094
+ var _a, _b;
1094
1095
  var adapter = daffCartItemEntitiesAdapter();
1095
1096
  switch (action.type) {
1096
1097
  case exports.DaffCartItemActionTypes.CartItemListSuccessAction:
1097
- return adapter.setAll(action.payload.map(function (item) { return (Object.assign(Object.assign({}, item), { daffState: getDaffState(state.entities[item.id]) || exports.DaffCartItemStateEnum.Default })); }), state);
1098
+ return adapter.setAll(action.payload.map(function (item) { return (Object.assign(Object.assign({}, item), { daffState: getDaffState(state.entities[item.id]) || exports.DaffCartItemStateEnum.Default, errors: [] })); }), state);
1098
1099
  case exports.DaffCartItemActionTypes.CartItemLoadSuccessAction:
1099
- return adapter.upsertOne(Object.assign(Object.assign({}, action.payload), { daffState: getDaffState(state.entities[action.payload.id]) || exports.DaffCartItemStateEnum.Default }), state);
1100
+ return adapter.upsertOne(Object.assign(Object.assign({}, action.payload), { daffState: getDaffState(state.entities[action.payload.id]) || exports.DaffCartItemStateEnum.Default, errors: [] }), state);
1100
1101
  case exports.DaffCartItemActionTypes.CartItemAddSuccessAction:
1101
1102
  return adapter.setAll(updateAddedCartItemState(state.entities, action.payload.items), state);
1102
1103
  case exports.DaffCartItemActionTypes.CartItemUpdateSuccessAction:
@@ -1104,7 +1105,7 @@
1104
1105
  case exports.DaffCartItemActionTypes.CartItemDeleteFailureAction:
1105
1106
  case exports.DaffCartItemActionTypes.CartItemLoadFailureAction:
1106
1107
  case exports.DaffCartItemActionTypes.CartItemUpdateFailureAction:
1107
- return adapter.upsertOne(Object.assign(Object.assign({}, state.entities[action.itemId]), { daffState: exports.DaffCartItemStateEnum.Error }), state);
1108
+ return adapter.upsertOne(Object.assign(Object.assign({}, state.entities[action.itemId]), { daffState: exports.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);
1108
1109
  case exports.DaffCartItemActionTypes.CartItemDeleteSuccessAction:
1109
1110
  case exports.DaffCartActionTypes.CartLoadSuccessAction:
1110
1111
  case exports.DaffCartActionTypes.ResolveCartSuccessAction:
@@ -1129,16 +1130,16 @@
1129
1130
  var oldItem = oldCartItems[newItem.id];
1130
1131
  switch (true) {
1131
1132
  case !oldItem:
1132
- return Object.assign(Object.assign({}, newItem), { daffState: exports.DaffCartItemStateEnum.New });
1133
+ return Object.assign(Object.assign({}, newItem), { daffState: exports.DaffCartItemStateEnum.New, errors: [] });
1133
1134
  case (oldItem === null || oldItem === void 0 ? void 0 : oldItem.qty) !== newItem.qty:
1134
- return Object.assign(Object.assign({}, newItem), { daffState: exports.DaffCartItemStateEnum.Updated });
1135
+ return Object.assign(Object.assign({}, newItem), { daffState: exports.DaffCartItemStateEnum.Updated, errors: [] });
1135
1136
  default:
1136
1137
  return newItem;
1137
1138
  }
1138
1139
  });
1139
1140
  }
1140
1141
  function updateMutatedCartItemState(responseItems, stateItems, itemId) {
1141
- return responseItems.map(function (item) { return item.id === itemId ? Object.assign(Object.assign({}, item), { daffState: exports.DaffCartItemStateEnum.Updated }) : Object.assign(Object.assign({}, item), { daffState: getDaffState(stateItems[item.id]) || exports.DaffCartItemStateEnum.Default }); });
1142
+ return responseItems.map(function (item) { return item.id === itemId ? Object.assign(Object.assign({}, item), { daffState: exports.DaffCartItemStateEnum.Updated, errors: [] }) : Object.assign(Object.assign({}, item), { daffState: getDaffState(stateItems[item.id]) || exports.DaffCartItemStateEnum.Default }); });
1142
1143
  }
1143
1144
 
1144
1145
  /*! *****************************************************************************
@@ -1652,6 +1653,8 @@
1652
1653
  case exports.DaffCartItemActionTypes.CartItemAddFailureAction:
1653
1654
  case exports.DaffCartItemActionTypes.CartItemDeleteFailureAction:
1654
1655
  return Object.assign(Object.assign(Object.assign({}, state), addError$2(state.errors, action.payload)), setLoading$2(state.loading, "Stable" /* Complete */));
1656
+ case exports.DaffCartItemActionTypes.CartItemUpdateFailureAction:
1657
+ return Object.assign(Object.assign({}, state), setLoading$2(state.loading, "Stable" /* Complete */));
1655
1658
  default:
1656
1659
  return state;
1657
1660
  }
@@ -1962,6 +1965,7 @@
1962
1965
  var amount = _a.amount;
1963
1966
  return core.daffAdd(acc, amount);
1964
1967
  }, 0)) || 0; }); }).memoized;
1968
+ var selectCartItemErrors = i1.defaultMemoize(function (itemId) { return i1.createSelector(selectCartItem(itemId), function (cartItem) { return (cartItem === null || cartItem === void 0 ? void 0 : cartItem.errors) || []; }); }).memoized;
1965
1969
  return {
1966
1970
  selectCartItemEntitiesState: selectCartItemEntitiesState,
1967
1971
  selectCartItemIds: selectCartItemIds,
@@ -1980,6 +1984,7 @@
1980
1984
  selectCartItemQuantity: selectCartItemQuantity,
1981
1985
  selectCartItemDiscounts: selectCartItemDiscounts,
1982
1986
  selectCartItemTotalDiscount: selectCartItemTotalDiscount,
1987
+ selectCartItemErrors: selectCartItemErrors,
1983
1988
  };
1984
1989
  };
1985
1990
  var ɵ0$2 = createCartItemEntitiesSelectors;
@@ -2547,6 +2552,9 @@
2547
2552
  var id = _a.id;
2548
2553
  return _this.driver.get(id);
2549
2554
  }), operators.map(function (resp) { return new DaffResolveCartSuccess(resp); }), operators.catchError(function (innerError) { return rxjs.of(new DaffResolveCartFailure(_this.errorMatcher(new i2.DaffCartNotFoundOrCreatedResolutionError(innerError.message)))); }));
2555
+ // I wish there was a better way to check this
2556
+ case error instanceof core.DaffInheritableError || !!error.code:
2557
+ return rxjs.of(new DaffResolveCartFailure(_this.errorMatcher(error)));
2550
2558
  default:
2551
2559
  return rxjs.of(new DaffResolveCartFailure(_this.errorMatcher(new i2.DaffCartResolutionError(error.message))));
2552
2560
  }
@@ -2771,7 +2779,7 @@
2771
2779
  var _this = this;
2772
2780
  this.store = store;
2773
2781
  this.paymentMethodMap = paymentMethodMap;
2774
- var _a = getDaffCartSelectors(), selectCartValue = _a.selectCartValue, selectCartResolved = _a.selectCartResolved, selectCartLoadingObject = _a.selectCartLoadingObject, selectCartFeatureLoading = _a.selectCartFeatureLoading, selectCartFeatureResolving = _a.selectCartFeatureResolving, selectCartFeatureMutating = _a.selectCartFeatureMutating, selectCartLoading = _a.selectCartLoading, selectCartResolving = _a.selectCartResolving, selectCartMutating = _a.selectCartMutating, selectBillingAddressLoading = _a.selectBillingAddressLoading, selectBillingAddressResolving = _a.selectBillingAddressResolving, selectBillingAddressMutating = _a.selectBillingAddressMutating, selectShippingAddressLoading = _a.selectShippingAddressLoading, selectShippingAddressResolving = _a.selectShippingAddressResolving, selectShippingAddressMutating = _a.selectShippingAddressMutating, selectShippingInformationLoading = _a.selectShippingInformationLoading, selectShippingInformationResolving = _a.selectShippingInformationResolving, selectShippingInformationMutating = _a.selectShippingInformationMutating, selectShippingMethodsLoading = _a.selectShippingMethodsLoading, selectShippingMethodsResolving = _a.selectShippingMethodsResolving, selectPaymentLoading = _a.selectPaymentLoading, selectPaymentResolving = _a.selectPaymentResolving, selectPaymentMutating = _a.selectPaymentMutating, selectPaymentMethodsLoading = _a.selectPaymentMethodsLoading, selectPaymentMethodsResolving = _a.selectPaymentMethodsResolving, selectCouponLoading = _a.selectCouponLoading, selectCouponResolving = _a.selectCouponResolving, selectCouponMutating = _a.selectCouponMutating, selectItemLoading = _a.selectItemLoading, selectItemAdding = _a.selectItemAdding, selectItemResolving = _a.selectItemResolving, selectCartItemMutating = _a.selectCartItemMutating, selectCartErrorsObject = _a.selectCartErrorsObject, selectCartErrors = _a.selectCartErrors, selectItemErrors = _a.selectItemErrors, selectBillingAddressErrors = _a.selectBillingAddressErrors, selectShippingAddressErrors = _a.selectShippingAddressErrors, selectShippingInformationErrors = _a.selectShippingInformationErrors, selectShippingMethodsErrors = _a.selectShippingMethodsErrors, selectPaymentErrors = _a.selectPaymentErrors, selectPaymentMethodsErrors = _a.selectPaymentMethodsErrors, selectCouponErrors = _a.selectCouponErrors, selectCartId = _a.selectCartId, selectCartSubtotal = _a.selectCartSubtotal, selectCartGrandTotal = _a.selectCartGrandTotal, selectCartSubtotalExcludingTax = _a.selectCartSubtotalExcludingTax, selectCartSubtotalIncludingTax = _a.selectCartSubtotalIncludingTax, selectCartSubtotalWithDiscountExcludingTax = _a.selectCartSubtotalWithDiscountExcludingTax, selectCartSubtotalWithDiscountIncludingTax = _a.selectCartSubtotalWithDiscountIncludingTax, selectCartDiscountTotals = _a.selectCartDiscountTotals, selectCartTotalTax = _a.selectCartTotalTax, selectCartShippingTotal = _a.selectCartShippingTotal, selectCartCoupons = _a.selectCartCoupons, selectCartItems = _a.selectCartItems, selectCartHasOutOfStockItems = _a.selectCartHasOutOfStockItems, selectCartItemEntities = _a.selectCartItemEntities, selectTotalNumberOfCartItems = _a.selectTotalNumberOfCartItems, selectCartItemConfiguredAttributes = _a.selectCartItemConfiguredAttributes, selectCartItemCompositeOptions = _a.selectCartItemCompositeOptions, selectCartBillingAddress = _a.selectCartBillingAddress, selectCartShippingAddress = _a.selectCartShippingAddress, selectCartPayment = _a.selectCartPayment, selectCartTotals = _a.selectCartTotals, selectCartShippingInformation = _a.selectCartShippingInformation, selectCartAvailableShippingMethods = _a.selectCartAvailableShippingMethods, selectCartAvailablePaymentMethods = _a.selectCartAvailablePaymentMethods, selectIsCartEmpty = _a.selectIsCartEmpty, selectIsBillingSameAsShipping = _a.selectIsBillingSameAsShipping, selectCartOrderLoading = _a.selectCartOrderLoading, selectCartOrderErrors = _a.selectCartOrderErrors, selectCartOrderValue = _a.selectCartOrderValue, selectCartOrderId = _a.selectCartOrderId, selectCartOrderCartId = _a.selectCartOrderCartId, selectHasOrderResult = _a.selectHasOrderResult, selectIsCartItemOutOfStock = _a.selectIsCartItemOutOfStock, selectCartItemState = _a.selectCartItemState, selectHasBillingAddress = _a.selectHasBillingAddress, selectHasShippingAddress = _a.selectHasShippingAddress, selectHasShippingMethod = _a.selectHasShippingMethod, selectHasPaymentMethod = _a.selectHasPaymentMethod, selectCanPlaceOrder = _a.selectCanPlaceOrder, selectCartItemPrice = _a.selectCartItemPrice, selectCartItemRowTotal = _a.selectCartItemRowTotal, selectCartItemQuantity = _a.selectCartItemQuantity, selectCartItemDiscounts = _a.selectCartItemDiscounts, selectCartItemTotalDiscount = _a.selectCartItemTotalDiscount;
2782
+ var _a = getDaffCartSelectors(), selectCartValue = _a.selectCartValue, selectCartResolved = _a.selectCartResolved, selectCartLoadingObject = _a.selectCartLoadingObject, selectCartFeatureLoading = _a.selectCartFeatureLoading, selectCartFeatureResolving = _a.selectCartFeatureResolving, selectCartFeatureMutating = _a.selectCartFeatureMutating, selectCartLoading = _a.selectCartLoading, selectCartResolving = _a.selectCartResolving, selectCartMutating = _a.selectCartMutating, selectBillingAddressLoading = _a.selectBillingAddressLoading, selectBillingAddressResolving = _a.selectBillingAddressResolving, selectBillingAddressMutating = _a.selectBillingAddressMutating, selectShippingAddressLoading = _a.selectShippingAddressLoading, selectShippingAddressResolving = _a.selectShippingAddressResolving, selectShippingAddressMutating = _a.selectShippingAddressMutating, selectShippingInformationLoading = _a.selectShippingInformationLoading, selectShippingInformationResolving = _a.selectShippingInformationResolving, selectShippingInformationMutating = _a.selectShippingInformationMutating, selectShippingMethodsLoading = _a.selectShippingMethodsLoading, selectShippingMethodsResolving = _a.selectShippingMethodsResolving, selectPaymentLoading = _a.selectPaymentLoading, selectPaymentResolving = _a.selectPaymentResolving, selectPaymentMutating = _a.selectPaymentMutating, selectPaymentMethodsLoading = _a.selectPaymentMethodsLoading, selectPaymentMethodsResolving = _a.selectPaymentMethodsResolving, selectCouponLoading = _a.selectCouponLoading, selectCouponResolving = _a.selectCouponResolving, selectCouponMutating = _a.selectCouponMutating, selectItemLoading = _a.selectItemLoading, selectItemAdding = _a.selectItemAdding, selectItemResolving = _a.selectItemResolving, selectCartItemMutating = _a.selectCartItemMutating, selectCartErrorsObject = _a.selectCartErrorsObject, selectCartErrors = _a.selectCartErrors, selectItemErrors = _a.selectItemErrors, selectBillingAddressErrors = _a.selectBillingAddressErrors, selectShippingAddressErrors = _a.selectShippingAddressErrors, selectShippingInformationErrors = _a.selectShippingInformationErrors, selectShippingMethodsErrors = _a.selectShippingMethodsErrors, selectPaymentErrors = _a.selectPaymentErrors, selectPaymentMethodsErrors = _a.selectPaymentMethodsErrors, selectCouponErrors = _a.selectCouponErrors, selectCartId = _a.selectCartId, selectCartSubtotal = _a.selectCartSubtotal, selectCartGrandTotal = _a.selectCartGrandTotal, selectCartSubtotalExcludingTax = _a.selectCartSubtotalExcludingTax, selectCartSubtotalIncludingTax = _a.selectCartSubtotalIncludingTax, selectCartSubtotalWithDiscountExcludingTax = _a.selectCartSubtotalWithDiscountExcludingTax, selectCartSubtotalWithDiscountIncludingTax = _a.selectCartSubtotalWithDiscountIncludingTax, selectCartDiscountTotals = _a.selectCartDiscountTotals, selectCartTotalTax = _a.selectCartTotalTax, selectCartShippingTotal = _a.selectCartShippingTotal, selectCartCoupons = _a.selectCartCoupons, selectCartItems = _a.selectCartItems, selectCartHasOutOfStockItems = _a.selectCartHasOutOfStockItems, selectCartItemEntities = _a.selectCartItemEntities, selectTotalNumberOfCartItems = _a.selectTotalNumberOfCartItems, selectCartItemConfiguredAttributes = _a.selectCartItemConfiguredAttributes, selectCartItemCompositeOptions = _a.selectCartItemCompositeOptions, selectCartBillingAddress = _a.selectCartBillingAddress, selectCartShippingAddress = _a.selectCartShippingAddress, selectCartPayment = _a.selectCartPayment, selectCartTotals = _a.selectCartTotals, selectCartShippingInformation = _a.selectCartShippingInformation, selectCartAvailableShippingMethods = _a.selectCartAvailableShippingMethods, selectCartAvailablePaymentMethods = _a.selectCartAvailablePaymentMethods, selectIsCartEmpty = _a.selectIsCartEmpty, selectIsBillingSameAsShipping = _a.selectIsBillingSameAsShipping, selectCartOrderLoading = _a.selectCartOrderLoading, selectCartOrderErrors = _a.selectCartOrderErrors, selectCartOrderValue = _a.selectCartOrderValue, selectCartOrderId = _a.selectCartOrderId, selectCartOrderCartId = _a.selectCartOrderCartId, selectHasOrderResult = _a.selectHasOrderResult, selectIsCartItemOutOfStock = _a.selectIsCartItemOutOfStock, selectCartItemState = _a.selectCartItemState, selectHasBillingAddress = _a.selectHasBillingAddress, selectHasShippingAddress = _a.selectHasShippingAddress, selectHasShippingMethod = _a.selectHasShippingMethod, selectHasPaymentMethod = _a.selectHasPaymentMethod, selectCanPlaceOrder = _a.selectCanPlaceOrder, selectCartItemPrice = _a.selectCartItemPrice, selectCartItemRowTotal = _a.selectCartItemRowTotal, selectCartItemQuantity = _a.selectCartItemQuantity, selectCartItemDiscounts = _a.selectCartItemDiscounts, selectCartItemTotalDiscount = _a.selectCartItemTotalDiscount, selectCartItemErrors = _a.selectCartItemErrors;
2775
2783
  this._selectCartItemConfiguredAttributes = selectCartItemConfiguredAttributes;
2776
2784
  this._selectCartItemCompositeOptions = selectCartItemCompositeOptions;
2777
2785
  this._selectIsCartItemOutOfStock = selectIsCartItemOutOfStock;
@@ -2781,6 +2789,7 @@
2781
2789
  this._selectCartItemRowTotal = selectCartItemRowTotal;
2782
2790
  this._selectCartItemDiscounts = selectCartItemDiscounts;
2783
2791
  this._selectCartItemTotalDiscount = selectCartItemTotalDiscount;
2792
+ this._selectCartItemErrors = selectCartItemErrors;
2784
2793
  this.cart$ = this.store.pipe(i1.select(selectCartValue));
2785
2794
  this.resolved$ = this.store.pipe(i1.select(selectCartResolved));
2786
2795
  this.loadingObject$ = this.store.pipe(i1.select(selectCartLoadingObject));
@@ -2891,6 +2900,10 @@
2891
2900
  DaffCartFacade.prototype.getCartItemTotalDiscount = function (itemId) {
2892
2901
  return this.store.pipe(i1.select(this._selectCartItemTotalDiscount(itemId)));
2893
2902
  };
2903
+ DaffCartFacade.prototype.getCartItemErrors = function (itemId) {
2904
+ return this.store.pipe(i1.select(this._selectCartItemErrors(itemId)));
2905
+ };
2906
+ ;
2894
2907
  DaffCartFacade.prototype.dispatch = function (action) {
2895
2908
  this.store.dispatch(action);
2896
2909
  };