@daffodil/cart 0.68.1 → 0.70.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.
Files changed (204) hide show
  1. package/driver/in-memory/drivers/cart-address/cart-address.service.d.ts +1 -1
  2. package/driver/in-memory/drivers/cart-billing-address/cart-billing-address.service.d.ts +1 -1
  3. package/driver/in-memory/drivers/cart-item/cart-item.service.d.ts +1 -1
  4. package/driver/in-memory/drivers/cart-shipping-address/cart-shipping-address.service.d.ts +1 -1
  5. package/driver/in-memory/drivers/cart-shipping-information/cart-shipping-information.service.d.ts +1 -1
  6. package/driver/interfaces/cart-address-service.interface.d.ts +4 -4
  7. package/driver/interfaces/cart-billing-address-service.interface.d.ts +5 -5
  8. package/driver/interfaces/cart-coupon-service.interface.d.ts +6 -6
  9. package/driver/interfaces/cart-item-service.interface.d.ts +7 -7
  10. package/driver/interfaces/cart-order-service.interface.d.ts +4 -4
  11. package/driver/interfaces/cart-payment-service.interface.d.ts +7 -7
  12. package/driver/interfaces/cart-shipping-address-service.interface.d.ts +5 -5
  13. package/driver/interfaces/cart-shipping-information-service.interface.d.ts +6 -6
  14. package/driver/magento/cart.service.d.ts +2 -2
  15. package/driver/magento/transforms/outputs/cart.service.d.ts +1 -3
  16. package/driver/magento/transforms/public_api.d.ts +0 -1
  17. package/esm2022/driver/in-memory/backend/cart-shipping-information/cart-shipping-information.service.mjs +1 -1
  18. package/esm2022/driver/in-memory/drivers/cart-address/cart-address.service.mjs +1 -1
  19. package/esm2022/driver/in-memory/drivers/cart-billing-address/cart-billing-address.service.mjs +1 -1
  20. package/esm2022/driver/in-memory/drivers/cart-item/cart-item.service.mjs +1 -1
  21. package/esm2022/driver/in-memory/drivers/cart-shipping-address/cart-shipping-address.service.mjs +1 -1
  22. package/esm2022/driver/in-memory/drivers/cart-shipping-information/cart-shipping-information.service.mjs +1 -1
  23. package/esm2022/driver/interfaces/cart-address-service.interface.mjs +1 -1
  24. package/esm2022/driver/interfaces/cart-billing-address-service.interface.mjs +1 -1
  25. package/esm2022/driver/interfaces/cart-coupon-service.interface.mjs +1 -1
  26. package/esm2022/driver/interfaces/cart-item-service.interface.mjs +1 -1
  27. package/esm2022/driver/interfaces/cart-order-service.interface.mjs +1 -1
  28. package/esm2022/driver/interfaces/cart-payment-service.interface.mjs +1 -1
  29. package/esm2022/driver/interfaces/cart-shipping-address-service.interface.mjs +1 -1
  30. package/esm2022/driver/interfaces/cart-shipping-information-service.interface.mjs +1 -1
  31. package/esm2022/driver/magento/cart-driver.module.mjs +1 -3
  32. package/esm2022/driver/magento/cart.service.mjs +1 -1
  33. package/esm2022/driver/magento/transforms/outputs/cart.service.mjs +6 -9
  34. package/esm2022/driver/magento/transforms/public_api.mjs +1 -2
  35. package/esm2022/helpers/get-affected-item.mjs +13 -0
  36. package/esm2022/helpers/get-item-total-discount.mjs +8 -0
  37. package/esm2022/helpers/input-to-item-transform.mjs +19 -0
  38. package/esm2022/helpers/public_api.mjs +4 -0
  39. package/esm2022/models/cart.mjs +1 -1
  40. package/esm2022/models/public_api.mjs +1 -1
  41. package/esm2022/public_api.mjs +2 -1
  42. package/esm2022/routing/guards/billing-address/billing-address-guard-redirect.token.mjs +2 -2
  43. package/esm2022/routing/guards/cart-items/cart-items-guard-redirect.token.mjs +2 -2
  44. package/esm2022/routing/guards/in-stock-items/in-stock-items-guard-redirect.token.mjs +2 -2
  45. package/esm2022/routing/guards/order-result/order-result-guard-redirect.token.mjs +2 -2
  46. package/esm2022/routing/guards/payment-method/payment-method-guard-redirect.token.mjs +2 -2
  47. package/esm2022/routing/guards/resolve-cart/redirect.token.mjs +2 -2
  48. package/esm2022/routing/guards/shipping-address/shipping-address-guard-redirect.token.mjs +2 -2
  49. package/esm2022/routing/guards/shipping-method/shipping-method-guard-redirect.token.mjs +2 -2
  50. package/esm2022/routing/resolvers/tokens/cart-resolver-redirect.token.mjs +2 -2
  51. package/esm2022/routing/resolvers/tokens/empty-cart-resolver-redirect.token.mjs +2 -2
  52. package/esm2022/state/actions/cart-address.actions.mjs +1 -1
  53. package/esm2022/state/actions/cart-billing-address.actions.mjs +1 -1
  54. package/esm2022/state/actions/cart-coupon.actions.mjs +1 -1
  55. package/esm2022/state/actions/cart-item.actions.mjs +9 -5
  56. package/esm2022/state/actions/cart-order.actions.mjs +1 -1
  57. package/esm2022/state/actions/cart-payment.actions.mjs +1 -1
  58. package/esm2022/state/actions/cart-shipping-address.actions.mjs +1 -1
  59. package/esm2022/state/actions/cart-shipping-information.actions.mjs +1 -1
  60. package/esm2022/state/effects/cart-address.effects.mjs +1 -1
  61. package/esm2022/state/effects/cart-billing-address.effects.mjs +1 -1
  62. package/esm2022/state/effects/cart-coupon.effects.mjs +1 -1
  63. package/esm2022/state/effects/cart-item.effects.mjs +18 -19
  64. package/esm2022/state/effects/cart-order.effects.mjs +1 -1
  65. package/esm2022/state/effects/cart-payment-processor.effects.mjs +35 -15
  66. package/esm2022/state/effects/cart-payment.effects.mjs +2 -2
  67. package/esm2022/state/effects/cart-shipping-address.effects.mjs +1 -1
  68. package/esm2022/state/effects/cart-shipping-information.effects.mjs +1 -1
  69. package/esm2022/state/effects/cart.effects.mjs +1 -1
  70. package/esm2022/state/effects/public_api.mjs +2 -0
  71. package/esm2022/state/facades/cart/cart-facade.interface.mjs +1 -1
  72. package/esm2022/state/facades/cart/cart.facade.mjs +3 -51
  73. package/esm2022/state/helpers/cart-items-entity-transform.mjs +24 -0
  74. package/esm2022/state/helpers/public_api.mjs +2 -0
  75. package/esm2022/state/models/public_api.mjs +1 -4
  76. package/esm2022/state/models/stateful-cart.mjs +1 -1
  77. package/esm2022/state/public_api.mjs +3 -2
  78. package/esm2022/state/reducers/action-types.type.mjs +1 -1
  79. package/esm2022/state/reducers/cart/cart.reducer.mjs +2 -2
  80. package/esm2022/state/reducers/cart-billing-address/cart-billing-address.reducer.mjs +2 -2
  81. package/esm2022/state/reducers/cart-coupon/cart-coupon.reducer.mjs +2 -2
  82. package/esm2022/state/reducers/cart-item/cart-item.reducer.mjs +2 -2
  83. package/esm2022/state/reducers/cart-item-entities/adapter.mjs +10 -0
  84. package/esm2022/state/reducers/cart-item-entities/cart-item-entities.reducer.mjs +17 -30
  85. package/esm2022/state/reducers/cart-item-entities/retrieval-actions.reducer.mjs +3 -7
  86. package/esm2022/state/reducers/cart-item-entities/set-state-meta-reducer.mjs +23 -0
  87. package/esm2022/state/reducers/cart-order/cart-order.reducer.mjs +2 -2
  88. package/esm2022/state/reducers/cart-payment/cart-payment.reducer.mjs +2 -2
  89. package/esm2022/state/reducers/cart-payment-methods/cart-payment-methods.reducer.mjs +1 -1
  90. package/esm2022/state/reducers/cart-reducers-state.interface.mjs +1 -1
  91. package/esm2022/state/reducers/cart-resolve/cart-resolve.reducer.mjs +1 -1
  92. package/esm2022/state/reducers/cart-shipping-address/cart-shipping-address.reducer.mjs +1 -1
  93. package/esm2022/state/reducers/cart-shipping-information/cart-shipping-information.reducer.mjs +3 -4
  94. package/esm2022/state/reducers/cart-shipping-methods/cart-shipping-methods.reducer.mjs +1 -1
  95. package/esm2022/state/reducers/public_api.mjs +2 -2
  96. package/esm2022/state/reducers/token/config.token.mjs +2 -2
  97. package/esm2022/state/reducers/token/extra.token.mjs +1 -1
  98. package/esm2022/state/selectors/cart/cart.selector.mjs +12 -74
  99. package/esm2022/state/selectors/cart-feature.selector.mjs +1 -1
  100. package/esm2022/state/selectors/cart-item-entities/cart-item-entities.selectors.mjs +7 -28
  101. package/esm2022/state/selectors/cart-order/cart-order.selector.mjs +2 -2
  102. package/esm2022/state/selectors/cart.selector.mjs +1 -1
  103. package/esm2022/state/testing/factories/stateful-cart-item.factory.mjs +3 -3
  104. package/esm2022/state/testing/factories/stateful-composite-cart-item.factory.mjs +3 -1
  105. package/esm2022/state/testing/factories/stateful-configurable-cart-item.factory.mjs +3 -1
  106. package/esm2022/state/testing/mock-cart-facade.mjs +2 -42
  107. package/esm2022/testing/factories/cart.factory.mjs +5 -5
  108. package/esm2022/testing/factories/public_api.mjs +1 -2
  109. package/fesm2022/daffodil-cart-driver-in-memory.mjs.map +1 -1
  110. package/fesm2022/daffodil-cart-driver-magento.mjs +5 -36
  111. package/fesm2022/daffodil-cart-driver-magento.mjs.map +1 -1
  112. package/fesm2022/daffodil-cart-driver.mjs.map +1 -1
  113. package/fesm2022/daffodil-cart-routing.mjs +10 -10
  114. package/fesm2022/daffodil-cart-routing.mjs.map +1 -1
  115. package/fesm2022/daffodil-cart-state-testing.mjs +7 -42
  116. package/fesm2022/daffodil-cart-state-testing.mjs.map +1 -1
  117. package/fesm2022/daffodil-cart-state.mjs +281 -419
  118. package/fesm2022/daffodil-cart-state.mjs.map +1 -1
  119. package/fesm2022/daffodil-cart-testing.mjs +3 -23
  120. package/fesm2022/daffodil-cart-testing.mjs.map +1 -1
  121. package/fesm2022/daffodil-cart.mjs +41 -2
  122. package/fesm2022/daffodil-cart.mjs.map +1 -1
  123. package/helpers/get-affected-item.d.ts +5 -0
  124. package/helpers/get-item-total-discount.d.ts +5 -0
  125. package/helpers/input-to-item-transform.d.ts +5 -0
  126. package/helpers/public_api.d.ts +3 -0
  127. package/models/cart.d.ts +1 -2
  128. package/models/public_api.d.ts +0 -1
  129. package/package.json +1 -1
  130. package/public_api.d.ts +1 -0
  131. package/state/actions/cart-address.actions.d.ts +1 -1
  132. package/state/actions/cart-billing-address.actions.d.ts +8 -8
  133. package/state/actions/cart-coupon.actions.d.ts +1 -1
  134. package/state/actions/cart-item.actions.d.ts +27 -23
  135. package/state/actions/cart-order.actions.d.ts +2 -2
  136. package/state/actions/cart-payment.actions.d.ts +15 -15
  137. package/state/actions/cart-shipping-address.actions.d.ts +8 -8
  138. package/state/actions/cart-shipping-information.actions.d.ts +4 -4
  139. package/state/effects/cart-address.effects.d.ts +6 -6
  140. package/state/effects/cart-billing-address.effects.d.ts +6 -6
  141. package/state/effects/cart-coupon.effects.d.ts +6 -6
  142. package/state/effects/cart-item.effects.d.ts +9 -11
  143. package/state/effects/cart-order.effects.d.ts +6 -6
  144. package/state/effects/cart-payment-processor.effects.d.ts +29 -9
  145. package/state/effects/cart-payment.effects.d.ts +6 -6
  146. package/state/effects/cart-shipping-address.effects.d.ts +6 -6
  147. package/state/effects/cart-shipping-information.effects.d.ts +6 -6
  148. package/state/effects/cart.effects.d.ts +1 -1
  149. package/state/effects/public_api.d.ts +1 -0
  150. package/state/facades/cart/cart-facade.interface.d.ts +10 -69
  151. package/state/facades/cart/cart.facade.d.ts +13 -47
  152. package/state/helpers/cart-items-entity-transform.d.ts +12 -0
  153. package/state/helpers/public_api.d.ts +1 -0
  154. package/state/models/public_api.d.ts +0 -3
  155. package/state/models/stateful-cart.d.ts +3 -3
  156. package/state/public_api.d.ts +2 -1
  157. package/state/reducers/action-types.type.d.ts +2 -3
  158. package/state/reducers/cart/cart.reducer.d.ts +1 -1
  159. package/state/reducers/cart-billing-address/cart-billing-address.reducer.d.ts +1 -1
  160. package/state/reducers/cart-coupon/cart-coupon.reducer.d.ts +1 -1
  161. package/state/reducers/cart-item/cart-item.reducer.d.ts +1 -1
  162. package/state/reducers/cart-item-entities/adapter.d.ts +6 -0
  163. package/state/reducers/cart-item-entities/cart-item-entities.reducer.d.ts +2 -3
  164. package/state/reducers/cart-item-entities/retrieval-actions.reducer.d.ts +2 -3
  165. package/state/reducers/cart-item-entities/set-state-meta-reducer.d.ts +10 -0
  166. package/state/reducers/cart-order/cart-order.reducer.d.ts +2 -3
  167. package/state/reducers/cart-payment/cart-payment.reducer.d.ts +1 -1
  168. package/state/reducers/cart-payment-methods/cart-payment-methods.reducer.d.ts +1 -1
  169. package/state/reducers/cart-reducers-state.interface.d.ts +5 -6
  170. package/state/reducers/cart-resolve/cart-resolve.reducer.d.ts +1 -1
  171. package/state/reducers/cart-shipping-information/cart-shipping-information.reducer.d.ts +1 -1
  172. package/state/reducers/cart-shipping-methods/cart-shipping-methods.reducer.d.ts +1 -1
  173. package/state/reducers/public_api.d.ts +1 -1
  174. package/state/reducers/token/config.token.d.ts +1 -1
  175. package/state/reducers/token/extra.token.d.ts +2 -3
  176. package/state/reducers/token/meta.token.d.ts +1 -1
  177. package/state/reducers/token/reducers.token.d.ts +1 -1
  178. package/state/selectors/cart/cart.selector.d.ts +59 -80
  179. package/state/selectors/cart-feature.selector.d.ts +3 -4
  180. package/state/selectors/cart-item-entities/cart-item-entities.selectors.d.ts +17 -52
  181. package/state/selectors/cart-order/cart-order.selector.d.ts +10 -11
  182. package/state/selectors/cart.selector.d.ts +2 -3
  183. package/state/testing/factories/stateful-cart-item.factory.d.ts +6 -4
  184. package/state/testing/factories/stateful-composite-cart-item.factory.d.ts +6 -4
  185. package/state/testing/factories/stateful-configurable-cart-item.factory.d.ts +6 -4
  186. package/state/testing/mock-cart-facade.d.ts +7 -33
  187. package/testing/factories/cart.factory.d.ts +5 -5
  188. package/testing/factories/public_api.d.ts +0 -1
  189. package/driver/magento/transforms/outputs/cart-shipping-information.service.d.ts +0 -19
  190. package/esm2022/driver/magento/transforms/outputs/cart-shipping-information.service.mjs +0 -33
  191. package/esm2022/models/cart-shipping-info.mjs +0 -2
  192. package/esm2022/state/models/stateful-cart-item.mjs +0 -9
  193. package/esm2022/state/models/stateful-composite-cart-item.mjs +0 -2
  194. package/esm2022/state/models/stateful-configurable-cart-item.mjs +0 -2
  195. package/esm2022/state/reducers/cart-item-entities/cart-item-entities-reducer-adapter.mjs +0 -9
  196. package/esm2022/state/reducers/cart-item-entities/set-state.meta-reducer.mjs +0 -56
  197. package/esm2022/testing/factories/cart-shipping-information.factory.mjs +0 -25
  198. package/models/cart-shipping-info.d.ts +0 -5
  199. package/state/models/stateful-cart-item.d.ts +0 -18
  200. package/state/models/stateful-composite-cart-item.d.ts +0 -4
  201. package/state/models/stateful-configurable-cart-item.d.ts +0 -4
  202. package/state/reducers/cart-item-entities/cart-item-entities-reducer-adapter.d.ts +0 -6
  203. package/state/reducers/cart-item-entities/set-state.meta-reducer.d.ts +0 -11
  204. package/testing/factories/cart-shipping-information.factory.d.ts +0 -12
@@ -1,20 +1,20 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Injectable, Inject, PLATFORM_ID, inject, NgModule } from '@angular/core';
3
+ import * as i1 from '@ngrx/effects';
4
+ import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
5
+ import { defer, combineLatest, of, iif, EMPTY } from 'rxjs';
6
+ import { switchMap, map, concatMap, mergeMap, take, debounceTime, tap } from 'rxjs/operators';
7
+ import * as i3 from '@daffodil/cart/driver';
8
+ import { DaffCartPaymentDriver, DaffCartDriverErrorCodes, DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartCouponDriver, daffCartDriverHandleCartNotFound, DaffCartItemDriver, DaffCartOrderDriver, DaffCartPaymentMethodsDriver, DaffCartShippingAddressDriver, DaffCartShippingInformationDriver, DaffCartShippingMethodsDriver, DaffCartDriver } from '@daffodil/cart/driver';
9
+ import { catchAndArrayifyErrors, DAFF_STORAGE_SERVICE_ERROR_CODE, DaffInheritableError, DAFF_SERVER_STORAGE_SERVICE_ERROR_CODE } from '@daffodil/core';
10
+ import { DaffPaymentGenerateTokenFailure, DAFF_PAYMENT_PROCESSOR_COLLECTION, DAFF_PAYMENT_ERROR_MATCHER, DaffPaymentStateReducerAdapter, daffPaymentInitialState, daffPaymentProvideExtraReducers } from '@daffodil/payment/state';
11
+ import { daffTransformErrorToStateError, daffCreateOperationEntityStateAdapter, daffComposeReducers, daffIdentityReducer } from '@daffodil/core/state';
3
12
  import * as i1$1 from '@ngrx/store';
4
13
  import { createFeatureSelector, createSelector, defaultMemoize, select, combineReducers, StoreModule } from '@ngrx/store';
5
- import * as i2 from '@daffodil/cart';
6
- import { DaffCartItemInputType, DaffCartTotalTypeEnum, DaffCartResolutionError, DaffCartStorageResolutionError, DaffCartServerSideResolutionError, DaffCartPaymentMethodIdMap } from '@daffodil/cart';
7
14
  import { daffComparePersonalAddresses } from '@daffodil/geography';
15
+ import * as i2 from '@daffodil/cart';
16
+ import { daffCartItemInputToItemTransform, DaffCartItemInputType, DaffCartPaymentMethodIdMap, daffCartGetAffectedItems, DaffCartResolutionError, DaffCartStorageResolutionError, DaffCartServerSideResolutionError } from '@daffodil/cart';
8
17
  import { createEntityAdapter } from '@ngrx/entity';
9
- import { daffComposeReducers, daffTransformErrorToStateError, daffIdentityReducer } from '@daffodil/core/state';
10
- import * as i4 from '@daffodil/cart/driver';
11
- import { DaffCartDriverErrorCodes, DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartCouponDriver, daffCartDriverHandleCartNotFound, DaffCartItemDriver, DaffCartOrderDriver, DaffCartPaymentMethodsDriver, DaffCartPaymentDriver, DaffCartShippingAddressDriver, DaffCartShippingInformationDriver, DaffCartShippingMethodsDriver, DaffCartDriver } from '@daffodil/cart/driver';
12
- import { daffAdd, catchAndArrayifyErrors, DAFF_STORAGE_SERVICE_ERROR_CODE, DaffInheritableError, DAFF_SERVER_STORAGE_SERVICE_ERROR_CODE } from '@daffodil/core';
13
- import * as i1 from '@ngrx/effects';
14
- import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
15
- import { DaffPaymentGenerateTokenFailure, DAFF_PAYMENT_PROCESSOR_COLLECTION, DAFF_PAYMENT_ERROR_MATCHER, DaffPaymentStateReducerAdapter, daffPaymentInitialState, daffPaymentProvideExtraReducers } from '@daffodil/payment/state';
16
- import { defer, of, combineLatest, iif, EMPTY } from 'rxjs';
17
- import { switchMap, map, concatMap, mergeMap, debounceTime, take, tap } from 'rxjs/operators';
18
18
  import { isPlatformBrowser } from '@angular/common';
19
19
 
20
20
  /**
@@ -327,8 +327,9 @@ class DaffCartItemUpdateFailure {
327
327
  * Triggers the addition of a product to the cart.
328
328
  */
329
329
  class DaffCartItemAdd {
330
- constructor(input) {
330
+ constructor(input, placeholderId) {
331
331
  this.input = input;
332
+ this.placeholderId = placeholderId;
332
333
  this.type = DaffCartItemActionTypes.CartItemAddAction;
333
334
  }
334
335
  }
@@ -336,8 +337,9 @@ class DaffCartItemAdd {
336
337
  * Indicates the successful addition of a product to the cart.
337
338
  */
338
339
  class DaffCartItemAddSuccess {
339
- constructor(payload) {
340
+ constructor(payload, itemId) {
340
341
  this.payload = payload;
342
+ this.itemId = itemId;
341
343
  this.type = DaffCartItemActionTypes.CartItemAddSuccessAction;
342
344
  }
343
345
  }
@@ -345,8 +347,9 @@ class DaffCartItemAddSuccess {
345
347
  * Indicates the failed addition of a product to the cart.
346
348
  */
347
349
  class DaffCartItemAddFailure {
348
- constructor(payload) {
350
+ constructor(payload, placeholderId) {
349
351
  this.payload = payload;
352
+ this.placeholderId = placeholderId;
350
353
  this.type = DaffCartItemActionTypes.CartItemAddFailureAction;
351
354
  }
352
355
  }
@@ -408,7 +411,8 @@ class DaffCartItemDeleteOutOfStockFailure {
408
411
  * Resets cart item "new" or "updated" states to default.
409
412
  */
410
413
  class DaffCartItemStateReset {
411
- constructor() {
414
+ constructor(itemId) {
415
+ this.itemId = itemId;
412
416
  this.type = DaffCartItemActionTypes.CartItemStateResetAction;
413
417
  }
414
418
  }
@@ -1142,23 +1146,85 @@ function daffCartRetrievalGetResponse(action, retrievalActions) {
1142
1146
  return null;
1143
1147
  }
1144
1148
 
1149
+ /**
1150
+ * An injection token for setting how long (in ms) a cart item remains in a temporary state before
1151
+ * reverting back to a default state. These temporary states are set after mutating or adding a cart item.
1152
+ * Daffodil has a timer that resets the state of all cart items after this debounce time, but the timer will
1153
+ * reset if a new item addition or mutation occurs. The default is 4000.
1154
+ */
1155
+ const DaffCartItemStateDebounceTime = new InjectionToken('DaffCartItemStateDebounceTime');
1156
+
1157
+ /**
1158
+ * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
1159
+ * Can be used to further refine Daffodil errors into more specific app errors.
1160
+ */
1161
+ const DAFF_CART_ERROR_MATCHER = new InjectionToken('DAFF_CART_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
1162
+
1163
+ /**
1164
+ * Performs a payment update on the current cart.
1165
+ *
1166
+ * @param payload The generate token request.
1167
+ * @param deps DI deps.
1168
+ * @param cbs Return the actions and/or perform custom behavior in response to each particular case.
1169
+ */
1170
+ function daffCartPaymentProcessorUpdate(payload, deps, cbs) {
1171
+ return defer(() => combineLatest([
1172
+ deps.paymentDriver.generateToken(payload.request),
1173
+ deps.cartResolver.getCartIdOrFail(),
1174
+ ]).pipe(switchMap(([response, cartId]) => deps.cartDriver.update(cartId, {
1175
+ method: response.method,
1176
+ payment_info: response.data,
1177
+ }, payload.address).pipe(switchMap(cbs.success), catchAndArrayifyErrors(cbs.updateFailure))), catchAndArrayifyErrors(cbs.paymentFailure)));
1178
+ }
1179
+ class DaffCartPaymentProcessorEffects {
1180
+ constructor(actions$, processors, errorMatcher, paymentErrorMatcher, driver, cartResolver, injector) {
1181
+ this.actions$ = actions$;
1182
+ this.processors = processors;
1183
+ this.errorMatcher = errorMatcher;
1184
+ this.paymentErrorMatcher = paymentErrorMatcher;
1185
+ this.driver = driver;
1186
+ this.cartResolver = cartResolver;
1187
+ this.injector = injector;
1188
+ this.update$ = createEffect(() => this.actions$.pipe(ofType(...Object.values(this.processors).map(({ action }) => action)), switchMap((action) =>
1189
+ // create a new inner observable to prevent the effects obs
1190
+ // from completing on outer catch error
1191
+ daffCartPaymentProcessorUpdate(action, {
1192
+ paymentDriver: this.injector.get(this.processors[action.request.kind].driver),
1193
+ cartDriver: this.driver,
1194
+ cartResolver: this.cartResolver,
1195
+ }, {
1196
+ success: (resp) => of(new DaffCartPaymentUpdateSuccess(resp)),
1197
+ paymentFailure: (errors) => of(new DaffPaymentGenerateTokenFailure(this.paymentErrorMatcher(errors[0]))),
1198
+ updateFailure: (errors) => of(new DaffCartPaymentUpdateFailure(errors.map(this.errorMatcher))),
1199
+ }))));
1200
+ }
1201
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartPaymentProcessorEffects, deps: [{ token: i1.Actions }, { token: DAFF_PAYMENT_PROCESSOR_COLLECTION }, { token: DAFF_CART_ERROR_MATCHER }, { token: DAFF_PAYMENT_ERROR_MATCHER }, { token: DaffCartPaymentDriver }, { token: i3.DaffCartDriverResolveService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
1202
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartPaymentProcessorEffects }); }
1203
+ }
1204
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartPaymentProcessorEffects, decorators: [{
1205
+ type: Injectable
1206
+ }], ctorParameters: () => [{ type: i1.Actions }, { type: undefined, decorators: [{
1207
+ type: Inject,
1208
+ args: [DAFF_PAYMENT_PROCESSOR_COLLECTION]
1209
+ }] }, { type: undefined, decorators: [{
1210
+ type: Inject,
1211
+ args: [DAFF_CART_ERROR_MATCHER]
1212
+ }] }, { type: undefined, decorators: [{
1213
+ type: Inject,
1214
+ args: [DAFF_PAYMENT_ERROR_MATCHER]
1215
+ }] }, { type: undefined, decorators: [{
1216
+ type: Inject,
1217
+ args: [DaffCartPaymentDriver]
1218
+ }] }, { type: i3.DaffCartDriverResolveService }, { type: i0.Injector }] });
1219
+
1145
1220
  /**
1146
1221
  * Cart Item Entities Adapter for changing/overwriting entity state.
1147
1222
  */
1148
1223
  const daffCartItemEntitiesAdapter = (() => {
1149
1224
  let cache;
1150
- return () => cache = cache || createEntityAdapter({ selectId: item => item.id });
1225
+ return () => cache = cache ?? daffCreateOperationEntityStateAdapter(createEntityAdapter({ selectId: item => item.id }));
1151
1226
  })();
1152
1227
 
1153
- var DaffCartItemStateEnum;
1154
- (function (DaffCartItemStateEnum) {
1155
- DaffCartItemStateEnum["New"] = "new";
1156
- DaffCartItemStateEnum["Updated"] = "updated";
1157
- DaffCartItemStateEnum["Mutating"] = "mutating";
1158
- DaffCartItemStateEnum["Error"] = "error";
1159
- DaffCartItemStateEnum["Default"] = "default";
1160
- })(DaffCartItemStateEnum || (DaffCartItemStateEnum = {}));
1161
-
1162
1228
  /**
1163
1229
  * Reducer function that catches actions and changes/overwrites product entities state.
1164
1230
  *
@@ -1170,45 +1236,32 @@ function daffCartItemEntitiesReducer(state = daffCartItemEntitiesAdapter().getIn
1170
1236
  const adapter = daffCartItemEntitiesAdapter();
1171
1237
  switch (action.type) {
1172
1238
  case DaffCartItemActionTypes.CartItemListSuccessAction:
1173
- return adapter.setAll(action.payload.map(item => ({
1174
- ...item,
1175
- daffState: getDaffState(state.entities[item.id]) || DaffCartItemStateEnum.Default,
1176
- daffErrors: [],
1177
- })), state);
1239
+ return adapter.list(action.payload, state);
1178
1240
  case DaffCartItemActionTypes.CartItemLoadSuccessAction:
1179
- return adapter.upsertOne({
1180
- ...action.payload,
1181
- daffState: getDaffState(state.entities[action.payload.id]) || DaffCartItemStateEnum.Default,
1182
- daffErrors: [],
1183
- }, state);
1241
+ return adapter.load(action.payload, state);
1184
1242
  case DaffCartItemActionTypes.CartItemDeleteFailureAction:
1185
1243
  case DaffCartItemActionTypes.CartItemLoadFailureAction:
1186
1244
  case DaffCartItemActionTypes.CartItemUpdateFailureAction:
1187
- return adapter.upsertOne({
1188
- ...state.entities[action.itemId],
1189
- daffState: DaffCartItemStateEnum.Error,
1190
- daffErrors: state.entities[action.itemId]?.daffErrors?.concat(action.payload) || action.payload,
1191
- }, state);
1245
+ return adapter.operationFailed(action.itemId, action.payload, state);
1246
+ case DaffCartItemActionTypes.CartItemAddFailureAction:
1247
+ return adapter.operationFailed(action.placeholderId, action.payload, state);
1192
1248
  case DaffCartItemActionTypes.CartItemStateResetAction:
1193
- return adapter.setAll(Object.keys(state.entities).map(key => ({
1194
- ...state.entities[key],
1195
- daffState: DaffCartItemStateEnum.Default,
1196
- })), state);
1249
+ return adapter.resetState(action.itemId, state);
1197
1250
  case DaffCartItemActionTypes.CartItemUpdateAction:
1198
- case DaffCartItemActionTypes.CartItemDeleteAction:
1199
- return adapter.upsertOne({
1200
- ...state.entities[action.itemId],
1201
- daffState: DaffCartItemStateEnum.Mutating,
1251
+ return adapter.preupdate({
1252
+ ...action.changes,
1253
+ id: action.itemId,
1202
1254
  }, state);
1255
+ case DaffCartItemActionTypes.CartItemDeleteAction:
1256
+ return adapter.preremove(action.itemId, state);
1257
+ case DaffCartItemActionTypes.CartItemAddAction:
1258
+ return adapter.preadd(daffCartItemInputToItemTransform(action.input), state, action.placeholderId);
1203
1259
  case DaffCartActionTypes.CartCreateSuccessAction:
1204
- return adapter.removeAll(state);
1260
+ return adapter.list([], state);
1205
1261
  default:
1206
1262
  return state;
1207
1263
  }
1208
1264
  }
1209
- function getDaffState(item) {
1210
- return item?.daffState;
1211
- }
1212
1265
 
1213
1266
  const daffCartOrderInitialState = {
1214
1267
  cartOrderResult: {
@@ -1225,7 +1278,7 @@ function daffCartOrderReducer(state = daffCartOrderInitialState, action) {
1225
1278
  case DaffCartOrderActionTypes.CartPlaceOrderAction:
1226
1279
  return {
1227
1280
  ...state,
1228
- loading: "Mutating" /* DaffState.Mutating */,
1281
+ loading: "Updating" /* DaffState.Mutating */,
1229
1282
  };
1230
1283
  case DaffCartOrderActionTypes.CartPlaceOrderSuccessAction:
1231
1284
  return {
@@ -1371,7 +1424,7 @@ function cartReducer(state = daffCartReducerInitialState, action) {
1371
1424
  case DaffCartActionTypes.CartCreateAction:
1372
1425
  return {
1373
1426
  ...state,
1374
- ...setLoading$8(state.loading, "Mutating" /* DaffState.Mutating */),
1427
+ ...setLoading$8(state.loading, "Updating" /* DaffState.Mutating */),
1375
1428
  };
1376
1429
  case DaffCartActionTypes.CartLoadSuccessAction:
1377
1430
  case DaffCartActionTypes.CartClearSuccessAction:
@@ -1429,7 +1482,7 @@ function cartBillingAddressReducer(state = daffCartReducerInitialState, action)
1429
1482
  case DaffCartAddressActionTypes.CartAddressUpdateAction:
1430
1483
  return {
1431
1484
  ...state,
1432
- ...setLoading$7(state.loading, "Mutating" /* DaffState.Mutating */),
1485
+ ...setLoading$7(state.loading, "Updating" /* DaffState.Mutating */),
1433
1486
  };
1434
1487
  case DaffCartBillingAddressActionTypes.CartBillingAddressLoadSuccessAction:
1435
1488
  return {
@@ -1476,7 +1529,7 @@ function cartCouponReducer(state = daffCartReducerInitialState, action) {
1476
1529
  case DaffCartCouponActionTypes.CartCouponRemoveAllAction:
1477
1530
  return {
1478
1531
  ...state,
1479
- ...setLoading$6(state.loading, "Mutating" /* DaffState.Mutating */),
1532
+ ...setLoading$6(state.loading, "Updating" /* DaffState.Mutating */),
1480
1533
  };
1481
1534
  case DaffCartCouponActionTypes.CartCouponApplySuccessAction:
1482
1535
  case DaffCartCouponActionTypes.CartCouponRemoveSuccessAction:
@@ -1531,7 +1584,7 @@ function cartItemReducer(state = daffCartReducerInitialState, action) {
1531
1584
  case DaffCartItemActionTypes.CartItemDeleteOutOfStockAction:
1532
1585
  return {
1533
1586
  ...state,
1534
- ...setLoading$5(state.loading, "Mutating" /* DaffState.Mutating */),
1587
+ ...setLoading$5(state.loading, "Updating" /* DaffState.Mutating */),
1535
1588
  };
1536
1589
  case DaffCartItemActionTypes.CartItemAddAction:
1537
1590
  return {
@@ -1614,7 +1667,7 @@ function cartPaymentReducer(state = daffCartReducerInitialState, action) {
1614
1667
  case DaffCartPaymentActionTypes.CartPaymentRemoveAction:
1615
1668
  return {
1616
1669
  ...state,
1617
- ...setLoading$4(state.loading, "Mutating" /* DaffState.Mutating */),
1670
+ ...setLoading$4(state.loading, "Updating" /* DaffState.Mutating */),
1618
1671
  };
1619
1672
  case DaffCartPaymentActionTypes.CartPaymentLoadSuccessAction:
1620
1673
  return {
@@ -1747,7 +1800,7 @@ function cartShippingAddressReducer(state = daffCartReducerInitialState, action)
1747
1800
  case DaffCartAddressActionTypes.CartAddressUpdateAction:
1748
1801
  return {
1749
1802
  ...state,
1750
- ...setLoading$2(state.loading, "Mutating" /* DaffState.Mutating */),
1803
+ ...setLoading$2(state.loading, "Updating" /* DaffState.Mutating */),
1751
1804
  };
1752
1805
  case DaffCartShippingAddressActionTypes.CartShippingAddressLoadSuccessAction:
1753
1806
  return {
@@ -1793,7 +1846,7 @@ function cartShippingInformationReducer(state = daffCartReducerInitialState, act
1793
1846
  case DaffCartShippingInformationActionTypes.CartShippingInformationDeleteAction:
1794
1847
  return {
1795
1848
  ...state,
1796
- ...setLoading$1(state.loading, "Mutating" /* DaffState.Mutating */),
1849
+ ...setLoading$1(state.loading, "Updating" /* DaffState.Mutating */),
1797
1850
  };
1798
1851
  case DaffCartShippingInformationActionTypes.CartShippingInformationLoadSuccessAction:
1799
1852
  return {
@@ -1801,8 +1854,7 @@ function cartShippingInformationReducer(state = daffCartReducerInitialState, act
1801
1854
  ...resetErrors$1(state.errors),
1802
1855
  cart: {
1803
1856
  ...state.cart,
1804
- // TODO: remove workaround
1805
- shipping_information: { ...action.payload, address_id: null },
1857
+ shipping_information: action.payload,
1806
1858
  },
1807
1859
  ...setLoading$1(state.loading, "Stable" /* DaffState.Complete */),
1808
1860
  };
@@ -1894,10 +1946,7 @@ function daffCartItemEntitiesRetrievalActionsReducerFactory(retrievalActions) {
1894
1946
  const adapter = daffCartItemEntitiesAdapter();
1895
1947
  const cart = daffCartRetrievalGetResponse(action, retrievalActions);
1896
1948
  return cart?.items
1897
- ? adapter.setAll(cart.items.map((item) => ({
1898
- ...item,
1899
- daffState: item.daffState || state.entities[item.id]?.daffState || DaffCartItemStateEnum.Default,
1900
- })), state)
1949
+ ? adapter.list(cart.items, state)
1901
1950
  : state;
1902
1951
  };
1903
1952
  }
@@ -1984,11 +2033,11 @@ const getDaffCartFeatureSelector = (() => {
1984
2033
 
1985
2034
  const createCartItemEntitiesSelectors = () => {
1986
2035
  const { selectCartFeatureState, } = getDaffCartFeatureSelector();
1987
- const adapterSelectors = daffCartItemEntitiesAdapter().getSelectors();
1988
2036
  /**
1989
2037
  * CartItem Entities State
1990
2038
  */
1991
2039
  const selectCartItemEntitiesState = createSelector(selectCartFeatureState, (state) => state.cartItems);
2040
+ const { selectOptimisticList: selectAllCartItems, selectEntity: selectCartItem, selectIds, selectEntities, selectTotal, } = daffCartItemEntitiesAdapter().getSelectors(selectCartItemEntitiesState);
1992
2041
  /**
1993
2042
  * Adapters created with @ngrx/entity generate
1994
2043
  * commonly used selector functions including
@@ -2000,20 +2049,15 @@ const createCartItemEntitiesSelectors = () => {
2000
2049
  /**
2001
2050
  * Selector for product IDs.
2002
2051
  */
2003
- const selectCartItemIds = createSelector(selectCartItemEntitiesState, adapterSelectors.selectIds);
2052
+ const selectCartItemIds = createSelector((s) => s, selectIds);
2004
2053
  /**
2005
2054
  * Selector for all product entities (see ngrx/entity).
2006
2055
  */
2007
- const selectCartItemEntities = createSelector(selectCartItemEntitiesState, adapterSelectors.selectEntities);
2008
- /**
2009
- * Selector for all products on state.
2010
- */
2011
- const selectAllCartItems = createSelector(selectCartItemEntitiesState, adapterSelectors.selectAll);
2056
+ const selectCartItemEntities = createSelector((s) => s, selectEntities);
2012
2057
  /**
2013
2058
  * Selector for the total number of products.
2014
2059
  */
2015
- const selectCartItemTotal = createSelector(selectCartItemEntitiesState, adapterSelectors.selectTotal);
2016
- const selectCartItem = defaultMemoize((itemId) => createSelector(selectCartItemEntities, cartItems => cartItems[itemId])).memoized;
2060
+ const selectCartItemTotal = createSelector((s) => s, selectTotal);
2017
2061
  /**
2018
2062
  * Selector for the total number of cart items that takes into account the qty on each cart item.
2019
2063
  */
@@ -2033,14 +2077,7 @@ const createCartItemEntitiesSelectors = () => {
2033
2077
  const selectIsCartItemOutOfStock = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => cartItem ? !cartItem.in_stock : null)).memoized;
2034
2078
  const selectOutOfStockCartItems = createSelector(selectAllCartItems, items => items.filter(item => !item.in_stock));
2035
2079
  const selectInStockCartItems = createSelector(selectAllCartItems, items => items.filter(item => item.in_stock));
2036
- const selectCartItemMutating = createSelector(selectAllCartItems, (cartItems) => cartItems?.reduce((acc, item) => acc || item.daffState === DaffCartItemStateEnum.Mutating, false));
2037
- const selectCartItemState = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => cartItem?.daffState || null)).memoized;
2038
- const selectCartItemQuantity = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => cartItem?.qty || 0)).memoized;
2039
- const selectCartItemRowTotal = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => cartItem?.row_total || 0)).memoized;
2040
- const selectCartItemPrice = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => cartItem?.price || 0)).memoized;
2041
- const selectCartItemDiscounts = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => cartItem?.discounts || [])).memoized;
2042
- const selectCartItemTotalDiscount = defaultMemoize((itemId) => createSelector(selectCartItemDiscounts(itemId), (discounts) => discounts?.reduce((acc, { amount }) => daffAdd(acc, amount), 0) || 0)).memoized;
2043
- const selectCartItemErrors = defaultMemoize((itemId) => createSelector(selectCartItem(itemId), (cartItem) => cartItem?.daffErrors || [])).memoized;
2080
+ const selectCartItemMutating = createSelector(selectAllCartItems, (cartItems) => cartItems?.reduce((acc, item) => acc || item.daffState === "Updating" /* DaffState.Mutating */, false));
2044
2081
  return {
2045
2082
  selectCartItemEntitiesState,
2046
2083
  selectCartItemIds,
@@ -2055,13 +2092,6 @@ const createCartItemEntitiesSelectors = () => {
2055
2092
  selectInStockCartItems,
2056
2093
  selectOutOfStockCartItems,
2057
2094
  selectCartItemMutating,
2058
- selectCartItemState,
2059
- selectCartItemPrice,
2060
- selectCartItemRowTotal,
2061
- selectCartItemQuantity,
2062
- selectCartItemDiscounts,
2063
- selectCartItemTotalDiscount,
2064
- selectCartItemErrors,
2065
2095
  };
2066
2096
  };
2067
2097
  const getDaffCartItemEntitiesSelectors = (() => {
@@ -2080,29 +2110,30 @@ const createCartSelectors$1 = () => {
2080
2110
  const selectCartLoadingObject = createSelector(selectCartState, state => state.loading);
2081
2111
  const selectCartLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Cart] !== "Stable" /* DaffState.Complete */);
2082
2112
  const selectCartResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Cart] === "Resolving" /* DaffState.Resolving */);
2083
- const selectCartMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Cart] === "Mutating" /* DaffState.Mutating */);
2113
+ const selectCartMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Cart] === "Updating" /* DaffState.Mutating */);
2084
2114
  const selectBillingAddressLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.BillingAddress] !== "Stable" /* DaffState.Complete */);
2085
2115
  const selectBillingAddressResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.BillingAddress] === "Resolving" /* DaffState.Resolving */);
2086
- const selectBillingAddressMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.BillingAddress] === "Mutating" /* DaffState.Mutating */);
2116
+ const selectBillingAddressMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.BillingAddress] === "Updating" /* DaffState.Mutating */);
2087
2117
  const selectShippingAddressLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingAddress] !== "Stable" /* DaffState.Complete */);
2088
2118
  const selectShippingAddressResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingAddress] === "Resolving" /* DaffState.Resolving */);
2089
- const selectShippingAddressMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingAddress] === "Mutating" /* DaffState.Mutating */);
2119
+ const selectShippingAddressMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingAddress] === "Updating" /* DaffState.Mutating */);
2090
2120
  const selectShippingInformationLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingInformation] !== "Stable" /* DaffState.Complete */);
2091
2121
  const selectShippingInformationResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingInformation] === "Resolving" /* DaffState.Resolving */);
2092
- const selectShippingInformationMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingInformation] === "Mutating" /* DaffState.Mutating */);
2122
+ const selectShippingInformationMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingInformation] === "Updating" /* DaffState.Mutating */);
2093
2123
  const selectShippingMethodsLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingMethods] !== "Stable" /* DaffState.Complete */);
2094
2124
  const selectShippingMethodsResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.ShippingMethods] === "Resolving" /* DaffState.Resolving */);
2095
2125
  const selectPaymentLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Payment] !== "Stable" /* DaffState.Complete */);
2096
2126
  const selectPaymentResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Payment] === "Resolving" /* DaffState.Resolving */);
2097
- const selectPaymentMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Payment] === "Mutating" /* DaffState.Mutating */);
2127
+ const selectPaymentMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Payment] === "Updating" /* DaffState.Mutating */);
2098
2128
  const selectPaymentMethodsLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.PaymentMethods] !== "Stable" /* DaffState.Complete */);
2099
2129
  const selectPaymentMethodsResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.PaymentMethods] === "Resolving" /* DaffState.Resolving */);
2100
2130
  const selectItemLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Item] !== "Stable" /* DaffState.Complete */);
2101
2131
  const selectItemAdding = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Item] === "Adding" /* DaffState.Adding */);
2102
2132
  const selectItemResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Item] === "Resolving" /* DaffState.Resolving */);
2133
+ const selectItemMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Item] === "Updating" /* DaffState.Mutating */);
2103
2134
  const selectCouponLoading = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Coupon] !== "Stable" /* DaffState.Complete */);
2104
2135
  const selectCouponResolving = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Coupon] === "Resolving" /* DaffState.Resolving */);
2105
- const selectCouponMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Coupon] === "Mutating" /* DaffState.Mutating */);
2136
+ const selectCouponMutating = createSelector(selectCartLoadingObject, loadingObject => loadingObject[DaffCartOperationType.Coupon] === "Updating" /* DaffState.Mutating */);
2106
2137
  const selectCartFeatureLoading = createSelector(selectCartLoadingObject, loadingObject => [
2107
2138
  selectCartLoading,
2108
2139
  selectBillingAddressLoading,
@@ -2125,7 +2156,7 @@ const createCartSelectors$1 = () => {
2125
2156
  selectCouponResolving,
2126
2157
  selectItemResolving,
2127
2158
  ].map(selector => selector.projector(loadingObject)).reduce((acc, resolving) => acc || resolving, false));
2128
- const selectCartFeatureMutating = createSelector(selectCartLoadingObject, selectCartItemMutating, (loadingObject, cartItemMutating) => [
2159
+ const selectCartFeatureMutating = createSelector(selectCartLoadingObject, (loadingObject) => [
2129
2160
  selectCartMutating,
2130
2161
  selectBillingAddressMutating,
2131
2162
  selectShippingAddressMutating,
@@ -2133,7 +2164,8 @@ const createCartSelectors$1 = () => {
2133
2164
  selectPaymentMutating,
2134
2165
  selectCouponMutating,
2135
2166
  selectItemAdding,
2136
- ].map(selector => selector.projector(loadingObject)).reduce((acc, mutating) => acc || mutating, false) || cartItemMutating);
2167
+ selectItemMutating,
2168
+ ].map(selector => selector.projector(loadingObject)).reduce((acc, mutating) => acc || mutating, false));
2137
2169
  const selectCartErrorsObject = createSelector(selectCartState, (state) => state.errors);
2138
2170
  const selectCartErrors = createSelector(selectCartErrorsObject, (state) => state[DaffCartOperationType.Cart]);
2139
2171
  const selectBillingAddressErrors = createSelector(selectCartErrorsObject, (state) => state[DaffCartOperationType.BillingAddress]);
@@ -2144,56 +2176,11 @@ const createCartSelectors$1 = () => {
2144
2176
  const selectPaymentMethodsErrors = createSelector(selectCartErrorsObject, (state) => state[DaffCartOperationType.PaymentMethods]);
2145
2177
  const selectItemErrors = createSelector(selectCartErrorsObject, (state) => state[DaffCartOperationType.Item]);
2146
2178
  const selectCouponErrors = createSelector(selectCartErrorsObject, (state) => state[DaffCartOperationType.Coupon]);
2147
- const selectCartId = createSelector(selectCartValue, (state) => state.id);
2148
- /**
2149
- * @deprecated use selectCartSubtotalExcludingTax selector instead.
2150
- */
2151
- const selectCartSubtotal = createSelector(selectCartValue, (state) => {
2152
- const subtotalObject = state.totals[DaffCartTotalTypeEnum.subtotalExcludingTax];
2153
- return subtotalObject ? subtotalObject.value : null;
2154
- });
2155
- const selectCartGrandTotal = createSelector(selectCartValue, (state) => {
2156
- const grandTotalObject = state.totals[DaffCartTotalTypeEnum.grandTotal];
2157
- return grandTotalObject ? grandTotalObject.value : null;
2158
- });
2159
- const selectCartSubtotalExcludingTax = createSelector(selectCartValue, (state) => {
2160
- const subtotalExcludingTaxObject = state.totals[DaffCartTotalTypeEnum.subtotalExcludingTax];
2161
- return subtotalExcludingTaxObject ? subtotalExcludingTaxObject.value : null;
2162
- });
2163
- const selectCartSubtotalIncludingTax = createSelector(selectCartValue, (state) => {
2164
- const subtotalIncludingTaxObject = state.totals[DaffCartTotalTypeEnum.subtotalIncludingTax];
2165
- return subtotalIncludingTaxObject ? subtotalIncludingTaxObject.value : null;
2166
- });
2167
- const selectCartSubtotalWithDiscountExcludingTax = createSelector(selectCartValue, (state) => {
2168
- const subtotalWithDiscountExcludingTaxObject = state.totals[DaffCartTotalTypeEnum.subtotalWithDiscountExcludingTax];
2169
- return subtotalWithDiscountExcludingTaxObject ? subtotalWithDiscountExcludingTaxObject.value : null;
2170
- });
2171
- const selectCartSubtotalWithDiscountIncludingTax = createSelector(selectCartValue, (state) => {
2172
- const subtotalWithDiscountIncludingTaxObject = state.totals[DaffCartTotalTypeEnum.subtotalWithDiscountIncludingTax];
2173
- return subtotalWithDiscountIncludingTaxObject ? subtotalWithDiscountIncludingTaxObject.value : null;
2174
- });
2175
- const selectCartTotalTax = createSelector(selectCartValue, (state) => {
2176
- const taxObject = state.totals[DaffCartTotalTypeEnum.tax];
2177
- return taxObject ? taxObject.value : null;
2178
- });
2179
- const selectCartDiscountTotals = createSelector(selectCartValue, (state) => {
2180
- const discount = state.totals[DaffCartTotalTypeEnum.discount];
2181
- return discount ? [discount] : [];
2182
- });
2183
- const selectCartShippingTotal = createSelector(selectCartValue, (state) => {
2184
- const shippingTotalObject = state.totals[DaffCartTotalTypeEnum.shipping];
2185
- return shippingTotalObject ? shippingTotalObject.value : null;
2186
- });
2187
- const selectCartCoupons = createSelector(selectCartValue, (state) => state.coupons);
2188
- const selectCartItems = createSelector(selectCartValue, (state) => state.items);
2189
2179
  const selectCartHasOutOfStockItems = createSelector(selectCartValue, (state) => state.items.reduce((acc, item) => (acc || !item.in_stock), false));
2190
2180
  const selectCartBillingAddress = createSelector(selectCartValue, (state) => state.billing_address);
2191
2181
  const selectCartShippingAddress = createSelector(selectCartValue, (state) => state.shipping_address);
2192
2182
  const selectCartPayment = createSelector(selectCartValue, (state) => state.payment);
2193
- const selectCartTotals = createSelector(selectCartValue, (state) => state.totals);
2194
2183
  const selectCartShippingInformation = createSelector(selectCartValue, (state) => state.shipping_information);
2195
- const selectCartAvailableShippingMethods = createSelector(selectCartValue, (state) => state.available_shipping_methods);
2196
- const selectCartAvailablePaymentMethods = createSelector(selectCartValue, (state) => state.available_payment_methods);
2197
2184
  const selectIsCartEmpty = createSelector(selectCartValue, cart => !cart || !cart.items || cart.items.length === 0);
2198
2185
  const selectIsBillingSameAsShipping = createSelector(selectCartShippingAddress, selectCartBillingAddress, (shippingAddress, billingAddress) => shippingAddress?.id || billingAddress?.id
2199
2186
  ? shippingAddress?.id === billingAddress?.id
@@ -2240,6 +2227,7 @@ const createCartSelectors$1 = () => {
2240
2227
  selectItemLoading,
2241
2228
  selectItemAdding,
2242
2229
  selectItemResolving,
2230
+ selectItemMutating,
2243
2231
  selectCartErrorsObject,
2244
2232
  selectCartErrors,
2245
2233
  selectBillingAddressErrors,
@@ -2250,26 +2238,7 @@ const createCartSelectors$1 = () => {
2250
2238
  selectPaymentMethodsErrors,
2251
2239
  selectItemErrors,
2252
2240
  selectCouponErrors,
2253
- selectCartId,
2254
- selectCartSubtotal,
2255
- selectCartGrandTotal,
2256
- selectCartSubtotalExcludingTax,
2257
- selectCartSubtotalIncludingTax,
2258
- selectCartSubtotalWithDiscountExcludingTax,
2259
- selectCartSubtotalWithDiscountIncludingTax,
2260
- selectCartDiscountTotals,
2261
- selectCartTotalTax,
2262
- selectCartShippingTotal,
2263
- selectCartCoupons,
2264
- selectCartItems,
2265
2241
  selectCartHasOutOfStockItems,
2266
- selectCartBillingAddress,
2267
- selectCartShippingAddress,
2268
- selectCartPayment,
2269
- selectCartTotals,
2270
- selectCartShippingInformation,
2271
- selectCartAvailableShippingMethods,
2272
- selectCartAvailablePaymentMethods,
2273
2242
  selectIsCartEmpty,
2274
2243
  selectIsBillingSameAsShipping,
2275
2244
  selectHasBillingAddress,
@@ -2293,7 +2262,7 @@ const createCartOrderSelectors = () => {
2293
2262
  const selectCartOrderId = createSelector(selectCartOrderValue, (state) => state.orderId);
2294
2263
  const selectCartOrderCartId = createSelector(selectCartOrderValue, (state) => state.cartId);
2295
2264
  const selectCartOrderLoading = createSelector(selectCartOrderState, (state) => state.loading !== "Stable" /* DaffState.Complete */);
2296
- const selectCartOrderMutating = createSelector(selectCartOrderState, (state) => state.loading === "Mutating" /* DaffState.Mutating */);
2265
+ const selectCartOrderMutating = createSelector(selectCartOrderState, (state) => state.loading === "Updating" /* DaffState.Mutating */);
2297
2266
  const selectCartOrderErrors = createSelector(selectCartOrderState, (state) => state.errors);
2298
2267
  const selectHasOrderResult = createSelector(selectCartOrderValue, orderResult => !!(orderResult && orderResult.orderId && orderResult.cartId));
2299
2268
  return {
@@ -2327,20 +2296,6 @@ const getDaffCartSelectors = (() => {
2327
2296
  : createCartSelectors();
2328
2297
  })();
2329
2298
 
2330
- /**
2331
- * An injection token for setting how long (in ms) a cart item remains in a temporary state before
2332
- * reverting back to a default state. These temporary states are set after mutating or adding a cart item.
2333
- * Daffodil has a timer that resets the state of all cart items after this debounce time, but the timer will
2334
- * reset if a new item addition or mutation occurs. The default is 4000.
2335
- */
2336
- const DaffCartItemStateDebounceTime = new InjectionToken('DaffCartItemStateDebounceTime');
2337
-
2338
- /**
2339
- * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
2340
- * Can be used to further refine Daffodil errors into more specific app errors.
2341
- */
2342
- const DAFF_CART_ERROR_MATCHER = new InjectionToken('DAFF_CART_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
2343
-
2344
2299
  class DaffCartAddressEffects {
2345
2300
  constructor(actions$, errorMatcher, driver, storage) {
2346
2301
  this.actions$ = actions$;
@@ -2418,36 +2373,143 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImpor
2418
2373
  args: [DaffCartCouponDriver]
2419
2374
  }] }, { type: i2.DaffCartStorageService }] });
2420
2375
 
2376
+ /**
2377
+ * @inheritdoc
2378
+ */
2379
+ class DaffCartFacade {
2380
+ constructor(store,
2381
+ // typing this as `Record<string, any>` or `object` fails the build
2382
+ // because Angular explicitly types this as `Object`
2383
+ // eslint-disable-next-line @typescript-eslint/ban-types
2384
+ paymentMethodMap) {
2385
+ this.store = store;
2386
+ this.paymentMethodMap = paymentMethodMap;
2387
+ 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, selectAllCartItems, selectCartHasOutOfStockItems, selectOutOfStockCartItems, selectInStockCartItems, selectCartItemEntities, selectTotalNumberOfCartItems, selectCartItemConfiguredAttributes, selectCartItemCompositeOptions, selectIsCartEmpty, selectIsBillingSameAsShipping, selectCartOrderLoading, selectCartOrderErrors, selectCartOrderValue, selectCartOrderId, selectCartOrderCartId, selectHasOrderResult, selectIsCartItemOutOfStock, selectHasBillingAddress, selectHasShippingAddress, selectHasShippingMethod, selectHasPaymentMethod, selectCanPlaceOrder, } = getDaffCartSelectors();
2388
+ this._selectCartItemConfiguredAttributes = selectCartItemConfiguredAttributes;
2389
+ this._selectCartItemCompositeOptions = selectCartItemCompositeOptions;
2390
+ this._selectIsCartItemOutOfStock = selectIsCartItemOutOfStock;
2391
+ this.cart$ = this.store.pipe(select(selectCartValue));
2392
+ this.resolved$ = this.store.pipe(select(selectCartResolved));
2393
+ this.loadingObject$ = this.store.pipe(select(selectCartLoadingObject));
2394
+ this.featureLoading$ = this.store.pipe(select(selectCartFeatureLoading));
2395
+ this.featureResolving$ = this.store.pipe(select(selectCartFeatureResolving));
2396
+ this.featureMutating$ = this.store.pipe(select(selectCartFeatureMutating));
2397
+ this.loading$ = this.store.pipe(select(selectCartLoading));
2398
+ this.resolving$ = this.store.pipe(select(selectCartResolving));
2399
+ this.mutating$ = this.store.pipe(select(selectCartMutating));
2400
+ this.billingAddressLoading$ = this.store.pipe(select(selectBillingAddressLoading));
2401
+ this.billingAddressResolving$ = this.store.pipe(select(selectBillingAddressResolving));
2402
+ this.billingAddressMutating$ = this.store.pipe(select(selectBillingAddressMutating));
2403
+ this.shippingAddressLoading$ = this.store.pipe(select(selectShippingAddressLoading));
2404
+ this.shippingAddressResolving$ = this.store.pipe(select(selectShippingAddressResolving));
2405
+ this.shippingAddressMutating$ = this.store.pipe(select(selectShippingAddressMutating));
2406
+ this.shippingInformationLoading$ = this.store.pipe(select(selectShippingInformationLoading));
2407
+ this.shippingInformationResolving$ = this.store.pipe(select(selectShippingInformationResolving));
2408
+ this.shippingInformationMutating$ = this.store.pipe(select(selectShippingInformationMutating));
2409
+ this.shippingMethodsLoading$ = this.store.pipe(select(selectShippingMethodsLoading));
2410
+ this.shippingMethodsResolving$ = this.store.pipe(select(selectShippingMethodsResolving));
2411
+ this.paymentLoading$ = this.store.pipe(select(selectPaymentLoading));
2412
+ this.paymentResolving$ = this.store.pipe(select(selectPaymentResolving));
2413
+ this.paymentMutating$ = this.store.pipe(select(selectPaymentMutating));
2414
+ this.paymentMethodsLoading$ = this.store.pipe(select(selectPaymentMethodsLoading));
2415
+ this.paymentMethodsResolving$ = this.store.pipe(select(selectPaymentMethodsResolving));
2416
+ this.couponLoading$ = this.store.pipe(select(selectCouponLoading));
2417
+ this.couponResolving$ = this.store.pipe(select(selectCouponResolving));
2418
+ this.couponMutating$ = this.store.pipe(select(selectCouponMutating));
2419
+ this.itemLoading$ = this.store.pipe(select(selectItemLoading));
2420
+ this.itemAdding$ = this.store.pipe(select(selectItemAdding));
2421
+ this.itemResolving$ = this.store.pipe(select(selectItemResolving));
2422
+ this.itemMutating$ = this.store.pipe(select(selectCartItemMutating));
2423
+ this.errors$ = this.store.pipe(select(selectCartErrorsObject));
2424
+ this.cartErrors$ = this.store.pipe(select(selectCartErrors));
2425
+ this.itemErrors$ = this.store.pipe(select(selectItemErrors));
2426
+ this.billingAddressErrors$ = this.store.pipe(select(selectBillingAddressErrors));
2427
+ this.shippingAddressErrors$ = this.store.pipe(select(selectShippingAddressErrors));
2428
+ this.shippingInformationErrors$ = this.store.pipe(select(selectShippingInformationErrors));
2429
+ this.shippingMethodsErrors$ = this.store.pipe(select(selectShippingMethodsErrors));
2430
+ this.paymentErrors$ = this.store.pipe(select(selectPaymentErrors));
2431
+ this.paymentMethodsErrors$ = this.store.pipe(select(selectPaymentMethodsErrors));
2432
+ this.couponErrors$ = this.store.pipe(select(selectCouponErrors));
2433
+ this.itemEntities$ = this.store.pipe(select(selectAllCartItems));
2434
+ this.totalItems$ = this.store.pipe(select(selectTotalNumberOfCartItems));
2435
+ this.hasOutOfStockItems$ = this.store.pipe(select(selectCartHasOutOfStockItems));
2436
+ this.outOfStockItems$ = this.store.pipe(select(selectOutOfStockCartItems));
2437
+ this.inStockItems$ = this.store.pipe(select(selectInStockCartItems));
2438
+ this.itemDictionary$ = this.store.pipe(select(selectCartItemEntities));
2439
+ this.paymentId$ = this.cart$.pipe(map((cart) => cart?.payment), map(payment => payment && payment.method
2440
+ ? this.paymentMethodMap[payment.method]
2441
+ : null));
2442
+ this.isCartEmpty$ = this.store.pipe(select(selectIsCartEmpty));
2443
+ this.isBillingSameAsShipping$ = this.store.pipe(select(selectIsBillingSameAsShipping));
2444
+ this.hasBillingAddress$ = this.store.pipe(select(selectHasBillingAddress));
2445
+ this.hasShippingAddress$ = this.store.pipe(select(selectHasShippingAddress));
2446
+ this.hasShippingMethod$ = this.store.pipe(select(selectHasShippingMethod));
2447
+ this.hasPaymentMethod$ = this.store.pipe(select(selectHasPaymentMethod));
2448
+ this.canPlaceOrder$ = this.store.pipe(select(selectCanPlaceOrder));
2449
+ this.orderResultLoading$ = this.store.pipe(select(selectCartOrderLoading));
2450
+ this.orderResultErrors$ = this.store.pipe(select(selectCartOrderErrors));
2451
+ this.orderResult$ = this.store.pipe(select(selectCartOrderValue));
2452
+ this.orderResultId$ = this.store.pipe(select(selectCartOrderId));
2453
+ this.orderResultCartId$ = this.store.pipe(select(selectCartOrderCartId));
2454
+ this.hasOrderResult$ = this.store.pipe(select(selectHasOrderResult));
2455
+ }
2456
+ getConfiguredCartItemAttributes(itemId) {
2457
+ return this.store.pipe(select(this._selectCartItemConfiguredAttributes(itemId)));
2458
+ }
2459
+ ;
2460
+ getCompositeCartItemOptions(itemId) {
2461
+ return this.store.pipe(select(this._selectCartItemCompositeOptions(itemId)));
2462
+ }
2463
+ ;
2464
+ isCartItemOutOfStock(itemId) {
2465
+ return this.store.pipe(select(this._selectIsCartItemOutOfStock(itemId)));
2466
+ }
2467
+ dispatch(action) {
2468
+ this.store.dispatch(action);
2469
+ }
2470
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartFacade, deps: [{ token: i1$1.Store }, { token: DaffCartPaymentMethodIdMap }], target: i0.ɵɵFactoryTarget.Injectable }); }
2471
+ /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartFacade, providedIn: 'root' }); }
2472
+ }
2473
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartFacade, decorators: [{
2474
+ type: Injectable,
2475
+ args: [{
2476
+ providedIn: 'root',
2477
+ }]
2478
+ }], ctorParameters: () => [{ type: i1$1.Store }, { type: Object, decorators: [{
2479
+ type: Inject,
2480
+ args: [DaffCartPaymentMethodIdMap]
2481
+ }] }] });
2482
+
2421
2483
  class DaffCartItemEffects {
2422
- constructor(actions$, errorMatcher, driver, storage, cartItemStateDebounceTime, store, cartResolver) {
2484
+ constructor(actions$, errorMatcher, driver, storage, cartItemStateDebounceTime, cartResolver, cartFacade) {
2423
2485
  this.actions$ = actions$;
2424
2486
  this.errorMatcher = errorMatcher;
2425
2487
  this.driver = driver;
2426
2488
  this.storage = storage;
2427
2489
  this.cartItemStateDebounceTime = cartItemStateDebounceTime;
2428
- this.store = store;
2429
2490
  this.cartResolver = cartResolver;
2491
+ this.cartFacade = cartFacade;
2430
2492
  this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemListAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartItemListSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartItemListFailure(error.map(this.errorMatcher))))))));
2431
2493
  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)), catchAndArrayifyErrors(error => of(new DaffCartItemLoadFailure(error.map(this.errorMatcher), action.itemId)))))));
2432
2494
  this.add$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemAddAction), concatMap((action) => combineLatest([
2433
2495
  of(action),
2434
2496
  this.cartResolver.getCartIdOrFail(),
2435
- ])), mergeMap(([action, id]) => this.addCartItem$(id, action.input)), daffCartDriverHandleCartNotFound(this.storage), catchAndArrayifyErrors(error => of(new DaffCartItemAddFailure(error.map(this.errorMatcher))))));
2497
+ ])), mergeMap(([action, id]) => combineLatest([
2498
+ this.driver.add(id, action.input),
2499
+ this.cartFacade.cart$.pipe(take(1)),
2500
+ ]).pipe(map(([newCart, oldCart]) => new DaffCartItemAddSuccess(newCart, daffCartGetAffectedItems(oldCart.items, newCart.items)[0])), catchAndArrayifyErrors(error => of(new DaffCartItemAddFailure(error.map(this.errorMatcher), action.placeholderId))))), daffCartDriverHandleCartNotFound(this.storage),
2501
+ // TODO: figure out how to get placeholder ID here
2502
+ catchAndArrayifyErrors(error => of(new DaffCartItemAddFailure(error.map(this.errorMatcher))))));
2436
2503
  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)), catchAndArrayifyErrors(error => of(new DaffCartItemUpdateFailure(error.map(this.errorMatcher), action.itemId)))))));
2437
2504
  this.resetCartItemStateAfterChange$ = createEffect(() => this.actions$.pipe(ofType(
2438
- // these actions will reset the debounce interval
2439
- DaffCartItemActionTypes.CartItemAddSuccessAction, DaffCartItemActionTypes.CartItemUpdateSuccessAction, DaffCartItemActionTypes.CartItemUpdateAction), debounceTime(this.cartItemStateDebounceTime), ofType(
2440
2505
  // these actions will cause the cart item state reset
2441
- DaffCartItemActionTypes.CartItemAddSuccessAction, DaffCartItemActionTypes.CartItemUpdateSuccessAction), map(() => new DaffCartItemStateReset())));
2506
+ DaffCartItemActionTypes.CartItemAddSuccessAction, DaffCartItemActionTypes.CartItemUpdateSuccessAction), debounceTime(this.cartItemStateDebounceTime), map((action) => new DaffCartItemStateReset(action.itemId))));
2442
2507
  this.delete$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemDeleteAction), mergeMap((action) => this.driver.delete(this.storage.getCartId(), action.itemId).pipe(map((resp) => new DaffCartItemDeleteSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartItemDeleteFailure(error.map(this.errorMatcher), action.itemId)))))));
2443
- this.removeOutOfStock$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemDeleteOutOfStockAction), switchMap((action) => this.store.pipe(select(getDaffCartSelectors().selectOutOfStockCartItems), take(1))), switchMap(items => items.length > 0
2508
+ this.removeOutOfStock$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemDeleteOutOfStockAction), switchMap((action) => this.cartFacade.outOfStockItems$.pipe(take(1))), switchMap(items => items.length > 0
2444
2509
  ? combineLatest(items.map(item => this.driver.delete(this.storage.getCartId(), item.id))).pipe(map(partialCarts => Object.assign({}, ...partialCarts)))
2445
- : this.store.pipe(select(getDaffCartSelectors().selectCartValue), take(1))), map(cart => new DaffCartItemDeleteOutOfStockSuccess(cart)), catchAndArrayifyErrors(error => of(new DaffCartItemDeleteOutOfStockFailure(error.map(this.errorMatcher))))));
2510
+ : this.cartFacade.cart$.pipe(take(1))), map((cart) => new DaffCartItemDeleteOutOfStockSuccess(cart)), catchAndArrayifyErrors(error => of(new DaffCartItemDeleteOutOfStockFailure(error.map(this.errorMatcher))))));
2446
2511
  }
2447
- addCartItem$(cartId, input) {
2448
- return this.driver.add(cartId, input).pipe(map((resp) => new DaffCartItemAddSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartItemAddFailure(error.map(this.errorMatcher)))));
2449
- }
2450
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", 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 }); }
2512
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartItemEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartItemDriver }, { token: i2.DaffCartStorageService }, { token: DaffCartItemStateDebounceTime }, { token: i3.DaffCartDriverResolveService }, { token: DaffCartFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
2451
2513
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartItemEffects }); }
2452
2514
  }
2453
2515
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartItemEffects, decorators: [{
@@ -2461,7 +2523,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImpor
2461
2523
  }] }, { type: i2.DaffCartStorageService }, { type: undefined, decorators: [{
2462
2524
  type: Inject,
2463
2525
  args: [DaffCartItemStateDebounceTime]
2464
- }] }, { type: i1$1.Store }, { type: i4.DaffCartDriverResolveService }] });
2526
+ }] }, { type: i3.DaffCartDriverResolveService }, { type: DaffCartFacade }] });
2465
2527
 
2466
2528
  class DaffCartOrderEffects {
2467
2529
  constructor(actions$, errorMatcher, driver, storage) {
@@ -2508,42 +2570,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImpor
2508
2570
  args: [DaffCartPaymentMethodsDriver]
2509
2571
  }] }, { type: i2.DaffCartStorageService }] });
2510
2572
 
2511
- class DaffCartPaymentProcessorEffects {
2512
- constructor(actions$, processors, errorMatcher, paymentErrorMatcher, driver, storage, injector) {
2513
- this.actions$ = actions$;
2514
- this.processors = processors;
2515
- this.errorMatcher = errorMatcher;
2516
- this.paymentErrorMatcher = paymentErrorMatcher;
2517
- this.driver = driver;
2518
- this.storage = storage;
2519
- this.injector = injector;
2520
- this.update$ = createEffect(() => this.actions$.pipe(ofType(...Object.values(this.processors).map(({ action }) => action)), switchMap((action) =>
2521
- // create a new inner observable to prevent the effects obs
2522
- // from completing on outer catch error
2523
- defer(() => this.injector.get(this.processors[action.request.kind].driver).generateToken(action.request).pipe(map(e => [e, action]), switchMap(([response, act]) => this.driver.update(this.storage.getCartId(), {
2524
- method: response.method,
2525
- payment_info: response.data,
2526
- }, act.address).pipe(map((resp) => new DaffCartPaymentUpdateSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentUpdateFailure(error.map(this.errorMatcher)))))), catchAndArrayifyErrors(error => of(new DaffPaymentGenerateTokenFailure(this.paymentErrorMatcher(error[0])))))))));
2527
- }
2528
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartPaymentProcessorEffects, deps: [{ token: i1.Actions }, { token: DAFF_PAYMENT_PROCESSOR_COLLECTION }, { token: DAFF_CART_ERROR_MATCHER }, { token: DAFF_PAYMENT_ERROR_MATCHER }, { token: DaffCartPaymentDriver }, { token: i2.DaffCartStorageService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
2529
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartPaymentProcessorEffects }); }
2530
- }
2531
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartPaymentProcessorEffects, decorators: [{
2532
- type: Injectable
2533
- }], ctorParameters: () => [{ type: i1.Actions }, { type: undefined, decorators: [{
2534
- type: Inject,
2535
- args: [DAFF_PAYMENT_PROCESSOR_COLLECTION]
2536
- }] }, { type: undefined, decorators: [{
2537
- type: Inject,
2538
- args: [DAFF_CART_ERROR_MATCHER]
2539
- }] }, { type: undefined, decorators: [{
2540
- type: Inject,
2541
- args: [DAFF_PAYMENT_ERROR_MATCHER]
2542
- }] }, { type: undefined, decorators: [{
2543
- type: Inject,
2544
- args: [DaffCartPaymentDriver]
2545
- }] }, { type: i2.DaffCartStorageService }, { type: i0.Injector }] });
2546
-
2547
2573
  class DaffCartPaymentEffects {
2548
2574
  constructor(actions$, errorMatcher, driver, storage) {
2549
2575
  this.actions$ = actions$;
@@ -2552,7 +2578,7 @@ class DaffCartPaymentEffects {
2552
2578
  this.storage = storage;
2553
2579
  this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId()).pipe(map((resp) => new DaffCartPaymentLoadSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentLoadFailure(error.map(this.errorMatcher))))))));
2554
2580
  this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentUpdateAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payload).pipe(map((resp) => new DaffCartPaymentUpdateSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentUpdateFailure(error.map(this.errorMatcher))))))));
2555
- this.updateWithBilling$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingAction), switchMap((action) => this.driver.updateWithBilling(this.storage.getCartId(), action.payment, action.address).pipe(map(resp => new DaffCartPaymentUpdateWithBillingSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentUpdateWithBillingFailure(error.map(this.errorMatcher))))))));
2581
+ this.updateWithBilling$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingAction), switchMap((action) => this.driver.update(this.storage.getCartId(), action.payment, action.address).pipe(map(resp => new DaffCartPaymentUpdateWithBillingSuccess(resp)), catchAndArrayifyErrors(error => of(new DaffCartPaymentUpdateWithBillingFailure(error.map(this.errorMatcher))))))));
2556
2582
  this.remove$ = createEffect(() => this.actions$.pipe(ofType(DaffCartPaymentActionTypes.CartPaymentRemoveAction), switchMap((action) => this.driver.remove(this.storage.getCartId()).pipe(map(() => new DaffCartPaymentRemoveSuccess()), catchAndArrayifyErrors(error => of(new DaffCartPaymentRemoveFailure(error.map(this.errorMatcher))))))));
2557
2583
  }
2558
2584
  /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartPaymentEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartPaymentDriver }, { token: i2.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable }); }
@@ -2610,7 +2636,7 @@ class DaffCartResolverEffects {
2610
2636
  ngrxOnInitEffects() {
2611
2637
  return isPlatformBrowser(this.platformId) && this.cartStorage.getCartId() ? new DaffResolveCart() : { type: '' };
2612
2638
  }
2613
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartResolverEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: i2.DaffCartStorageService }, { token: i4.DaffCartDriverResolveService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
2639
+ /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartResolverEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: i2.DaffCartStorageService }, { token: i3.DaffCartDriverResolveService }, { token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
2614
2640
  /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartResolverEffects }); }
2615
2641
  }
2616
2642
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartResolverEffects, decorators: [{
@@ -2618,7 +2644,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImpor
2618
2644
  }], ctorParameters: () => [{ type: i1.Actions }, { type: undefined, decorators: [{
2619
2645
  type: Inject,
2620
2646
  args: [DAFF_CART_ERROR_MATCHER]
2621
- }] }, { type: i2.DaffCartStorageService }, { type: i4.DaffCartDriverResolveService }, { type: undefined, decorators: [{
2647
+ }] }, { type: i2.DaffCartStorageService }, { type: i3.DaffCartDriverResolveService }, { type: undefined, decorators: [{
2622
2648
  type: Inject,
2623
2649
  args: [PLATFORM_ID]
2624
2650
  }] }] });
@@ -2743,6 +2769,30 @@ const daffCartPaymentReducer = (state = daffPaymentInitialState, action) => {
2743
2769
  }
2744
2770
  };
2745
2771
 
2772
+ /**
2773
+ * Transforms a list of cart items to item entities.
2774
+ * Uses the list of previous cart items to infer the correct state of each entity.
2775
+ *
2776
+ * @param oldCartItems the dictionary of existing cart items.
2777
+ * @param newCartItems the list of incoming cart items
2778
+ * @returns a list of cart item operation entities
2779
+ */
2780
+ function daffCartItemsEntityTransform(oldCartItems, newCartItems) {
2781
+ return newCartItems.map(newItem => {
2782
+ const oldItem = oldCartItems[newItem.id];
2783
+ return {
2784
+ ...newItem,
2785
+ daffState: !oldItem
2786
+ ? "Added" /* DaffState.Added */
2787
+ : oldItem?.qty !== newItem.qty
2788
+ ? "Updated" /* DaffState.Mutated */
2789
+ : "Stable" /* DaffState.Stable */,
2790
+ daffErrors: [],
2791
+ daffTemp: false,
2792
+ };
2793
+ });
2794
+ }
2795
+
2746
2796
  /**
2747
2797
  * A meta reducer for determining and setting the correct `daffState` values on cart items.
2748
2798
  */
@@ -2750,27 +2800,12 @@ function daffCartSetItemStateMetaReducer(reducer) {
2750
2800
  return (state, action) => {
2751
2801
  switch (action.type) {
2752
2802
  case DaffCartItemActionTypes.CartItemAddSuccessAction:
2753
- return reducer(state, {
2754
- ...action,
2755
- payload: {
2756
- ...action.payload,
2757
- items: updateAddedCartItemState(state.cartItems.entities, action.payload.items.map((item) => ({
2758
- ...item,
2759
- daffErrors: [],
2760
- }))),
2761
- },
2762
- });
2763
2803
  case DaffCartItemActionTypes.CartItemUpdateSuccessAction:
2764
2804
  return reducer(state, {
2765
2805
  ...action,
2766
2806
  payload: {
2767
2807
  ...action.payload,
2768
- items: updateMutatedCartItemState(action.payload.items.map((item) => item.id === action.itemId
2769
- ? {
2770
- ...item,
2771
- daffErrors: [],
2772
- }
2773
- : item), state.cartItems.entities, action.itemId),
2808
+ items: daffCartItemsEntityTransform(state.cartItems.entities, action.payload.items),
2774
2809
  },
2775
2810
  });
2776
2811
  default:
@@ -2778,24 +2813,6 @@ function daffCartSetItemStateMetaReducer(reducer) {
2778
2813
  }
2779
2814
  };
2780
2815
  }
2781
- function updateAddedCartItemState(oldCartItems, newCartItems) {
2782
- return newCartItems.map(newItem => {
2783
- const oldItem = oldCartItems[newItem.id];
2784
- switch (true) {
2785
- case !oldItem:
2786
- return { ...newItem, daffState: DaffCartItemStateEnum.New, daffErrors: [] };
2787
- case oldItem?.qty !== newItem.qty:
2788
- return { ...newItem, daffState: DaffCartItemStateEnum.Updated, daffErrors: [] };
2789
- default:
2790
- return newItem;
2791
- }
2792
- });
2793
- }
2794
- function updateMutatedCartItemState(responseItems, stateItems, itemId) {
2795
- return responseItems.map(item => item.id === itemId ?
2796
- { ...item, daffState: DaffCartItemStateEnum.Updated, daffErrors: [] } :
2797
- { ...item, daffState: stateItems[item.id]?.daffState || DaffCartItemStateEnum.Default });
2798
- }
2799
2816
 
2800
2817
  /**
2801
2818
  * An internal token to hold the Daffodil cart feature store config.
@@ -2893,164 +2910,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImpor
2893
2910
  }]
2894
2911
  }] });
2895
2912
 
2896
- /**
2897
- * @inheritdoc
2898
- */
2899
- class DaffCartFacade {
2900
- constructor(store,
2901
- // typing this as `Record<string, any>` or `object` fails the build
2902
- // because Angular explicitly types this as `Object`
2903
- // eslint-disable-next-line @typescript-eslint/ban-types
2904
- paymentMethodMap) {
2905
- this.store = store;
2906
- this.paymentMethodMap = paymentMethodMap;
2907
- 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();
2908
- this._selectCartItemConfiguredAttributes = selectCartItemConfiguredAttributes;
2909
- this._selectCartItemCompositeOptions = selectCartItemCompositeOptions;
2910
- this._selectIsCartItemOutOfStock = selectIsCartItemOutOfStock;
2911
- this._selectCartItemState = selectCartItemState;
2912
- this._selectCartItemPrice = selectCartItemPrice;
2913
- this._selectCartItemQuantity = selectCartItemQuantity;
2914
- this._selectCartItemRowTotal = selectCartItemRowTotal;
2915
- this._selectCartItemDiscounts = selectCartItemDiscounts;
2916
- this._selectCartItemTotalDiscount = selectCartItemTotalDiscount;
2917
- this._selectCartItemErrors = selectCartItemErrors;
2918
- this.cart$ = this.store.pipe(select(selectCartValue));
2919
- this.resolved$ = this.store.pipe(select(selectCartResolved));
2920
- this.loadingObject$ = this.store.pipe(select(selectCartLoadingObject));
2921
- this.featureLoading$ = this.store.pipe(select(selectCartFeatureLoading));
2922
- this.featureResolving$ = this.store.pipe(select(selectCartFeatureResolving));
2923
- this.featureMutating$ = this.store.pipe(select(selectCartFeatureMutating));
2924
- this.loading$ = this.store.pipe(select(selectCartLoading));
2925
- this.resolving$ = this.store.pipe(select(selectCartResolving));
2926
- this.mutating$ = this.store.pipe(select(selectCartMutating));
2927
- this.billingAddressLoading$ = this.store.pipe(select(selectBillingAddressLoading));
2928
- this.billingAddressResolving$ = this.store.pipe(select(selectBillingAddressResolving));
2929
- this.billingAddressMutating$ = this.store.pipe(select(selectBillingAddressMutating));
2930
- this.shippingAddressLoading$ = this.store.pipe(select(selectShippingAddressLoading));
2931
- this.shippingAddressResolving$ = this.store.pipe(select(selectShippingAddressResolving));
2932
- this.shippingAddressMutating$ = this.store.pipe(select(selectShippingAddressMutating));
2933
- this.shippingInformationLoading$ = this.store.pipe(select(selectShippingInformationLoading));
2934
- this.shippingInformationResolving$ = this.store.pipe(select(selectShippingInformationResolving));
2935
- this.shippingInformationMutating$ = this.store.pipe(select(selectShippingInformationMutating));
2936
- this.shippingMethodsLoading$ = this.store.pipe(select(selectShippingMethodsLoading));
2937
- this.shippingMethodsResolving$ = this.store.pipe(select(selectShippingMethodsResolving));
2938
- this.paymentLoading$ = this.store.pipe(select(selectPaymentLoading));
2939
- this.paymentResolving$ = this.store.pipe(select(selectPaymentResolving));
2940
- this.paymentMutating$ = this.store.pipe(select(selectPaymentMutating));
2941
- this.paymentMethodsLoading$ = this.store.pipe(select(selectPaymentMethodsLoading));
2942
- this.paymentMethodsResolving$ = this.store.pipe(select(selectPaymentMethodsResolving));
2943
- this.couponLoading$ = this.store.pipe(select(selectCouponLoading));
2944
- this.couponResolving$ = this.store.pipe(select(selectCouponResolving));
2945
- this.couponMutating$ = this.store.pipe(select(selectCouponMutating));
2946
- this.itemLoading$ = this.store.pipe(select(selectItemLoading));
2947
- this.itemAdding$ = this.store.pipe(select(selectItemAdding));
2948
- this.itemResolving$ = this.store.pipe(select(selectItemResolving));
2949
- this.itemMutating$ = this.store.pipe(select(selectCartItemMutating));
2950
- this.errors$ = this.store.pipe(select(selectCartErrorsObject));
2951
- this.cartErrors$ = this.store.pipe(select(selectCartErrors));
2952
- this.itemErrors$ = this.store.pipe(select(selectItemErrors));
2953
- this.billingAddressErrors$ = this.store.pipe(select(selectBillingAddressErrors));
2954
- this.shippingAddressErrors$ = this.store.pipe(select(selectShippingAddressErrors));
2955
- this.shippingInformationErrors$ = this.store.pipe(select(selectShippingInformationErrors));
2956
- this.shippingMethodsErrors$ = this.store.pipe(select(selectShippingMethodsErrors));
2957
- this.paymentErrors$ = this.store.pipe(select(selectPaymentErrors));
2958
- this.paymentMethodsErrors$ = this.store.pipe(select(selectPaymentMethodsErrors));
2959
- this.couponErrors$ = this.store.pipe(select(selectCouponErrors));
2960
- this.id$ = this.store.pipe(select(selectCartId));
2961
- this.subtotal$ = this.store.pipe(select(selectCartSubtotal));
2962
- this.grandTotal$ = this.store.pipe(select(selectCartGrandTotal));
2963
- this.subtotalExcludingTax$ = this.store.pipe(select(selectCartSubtotalExcludingTax));
2964
- this.subtotalIncludingTax$ = this.store.pipe(select(selectCartSubtotalIncludingTax));
2965
- this.subtotalWithDiscountExcludingTax$ = this.store.pipe(select(selectCartSubtotalWithDiscountExcludingTax));
2966
- this.subtotalWithDiscountIncludingTax$ = this.store.pipe(select(selectCartSubtotalWithDiscountIncludingTax));
2967
- this.discountTotals$ = this.store.pipe(select(selectCartDiscountTotals));
2968
- this.totalTax$ = this.store.pipe(select(selectCartTotalTax));
2969
- this.shippingTotal$ = this.store.pipe(select(selectCartShippingTotal));
2970
- this.coupons$ = this.store.pipe(select(selectCartCoupons));
2971
- this.items$ = this.store.pipe(select(selectCartItems));
2972
- this.itemEntities$ = this.store.pipe(select(selectAllCartItems));
2973
- this.totalItems$ = this.store.pipe(select(selectTotalNumberOfCartItems));
2974
- this.hasOutOfStockItems$ = this.store.pipe(select(selectCartHasOutOfStockItems));
2975
- this.outOfStockItems$ = this.store.pipe(select(selectOutOfStockCartItems));
2976
- this.inStockItems$ = this.store.pipe(select(selectInStockCartItems));
2977
- this.itemDictionary$ = this.store.pipe(select(selectCartItemEntities));
2978
- this.billingAddress$ = this.store.pipe(select(selectCartBillingAddress));
2979
- this.shippingAddress$ = this.store.pipe(select(selectCartShippingAddress));
2980
- this.payment$ = this.store.pipe(select(selectCartPayment));
2981
- this.totals$ = this.store.pipe(select(selectCartTotals));
2982
- this.shippingInformation$ = this.store.pipe(select(selectCartShippingInformation));
2983
- this.availableShippingMethods$ = this.store.pipe(select(selectCartAvailableShippingMethods));
2984
- this.availablePaymentMethods$ = this.store.pipe(select(selectCartAvailablePaymentMethods));
2985
- this.paymentId$ = this.payment$.pipe(map(payment => payment && payment.method
2986
- ? this.paymentMethodMap[payment.method]
2987
- : null));
2988
- this.isCartEmpty$ = this.store.pipe(select(selectIsCartEmpty));
2989
- this.isBillingSameAsShipping$ = this.store.pipe(select(selectIsBillingSameAsShipping));
2990
- this.hasBillingAddress$ = this.store.pipe(select(selectHasBillingAddress));
2991
- this.hasShippingAddress$ = this.store.pipe(select(selectHasShippingAddress));
2992
- this.hasShippingMethod$ = this.store.pipe(select(selectHasShippingMethod));
2993
- this.hasPaymentMethod$ = this.store.pipe(select(selectHasPaymentMethod));
2994
- this.canPlaceOrder$ = this.store.pipe(select(selectCanPlaceOrder));
2995
- this.orderResultLoading$ = this.store.pipe(select(selectCartOrderLoading));
2996
- this.orderResultErrors$ = this.store.pipe(select(selectCartOrderErrors));
2997
- this.orderResult$ = this.store.pipe(select(selectCartOrderValue));
2998
- this.orderResultId$ = this.store.pipe(select(selectCartOrderId));
2999
- this.orderResultCartId$ = this.store.pipe(select(selectCartOrderCartId));
3000
- this.hasOrderResult$ = this.store.pipe(select(selectHasOrderResult));
3001
- }
3002
- getConfiguredCartItemAttributes(itemId) {
3003
- return this.store.pipe(select(this._selectCartItemConfiguredAttributes(itemId)));
3004
- }
3005
- ;
3006
- getCompositeCartItemOptions(itemId) {
3007
- return this.store.pipe(select(this._selectCartItemCompositeOptions(itemId)));
3008
- }
3009
- ;
3010
- isCartItemOutOfStock(itemId) {
3011
- return this.store.pipe(select(this._selectIsCartItemOutOfStock(itemId)));
3012
- }
3013
- getCartItemState(itemId) {
3014
- return this.store.pipe(select(this._selectCartItemState(itemId)));
3015
- }
3016
- getCartItemPrice(itemId) {
3017
- return this.store.pipe(select(this._selectCartItemPrice(itemId)));
3018
- }
3019
- getCartItemQuantity(itemId) {
3020
- return this.store.pipe(select(this._selectCartItemQuantity(itemId)));
3021
- }
3022
- getCartItemRowTotal(itemId) {
3023
- return this.store.pipe(select(this._selectCartItemRowTotal(itemId)));
3024
- }
3025
- getCartItemDiscounts(itemId) {
3026
- return this.store.pipe(select(this._selectCartItemDiscounts(itemId)));
3027
- }
3028
- getCartItemTotalDiscount(itemId) {
3029
- return this.store.pipe(select(this._selectCartItemTotalDiscount(itemId)));
3030
- }
3031
- getCartItemErrors(itemId) {
3032
- return this.store.pipe(select(this._selectCartItemErrors(itemId)));
3033
- }
3034
- ;
3035
- dispatch(action) {
3036
- this.store.dispatch(action);
3037
- }
3038
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartFacade, deps: [{ token: i1$1.Store }, { token: DaffCartPaymentMethodIdMap }], target: i0.ɵɵFactoryTarget.Injectable }); }
3039
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartFacade, providedIn: 'root' }); }
3040
- }
3041
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.1", ngImport: i0, type: DaffCartFacade, decorators: [{
3042
- type: Injectable,
3043
- args: [{
3044
- providedIn: 'root',
3045
- }]
3046
- }], ctorParameters: () => [{ type: i1$1.Store }, { type: Object, decorators: [{
3047
- type: Inject,
3048
- args: [DaffCartPaymentMethodIdMap]
3049
- }] }] });
3050
-
3051
2913
  /**
3052
2914
  * Generated bundle index. Do not edit.
3053
2915
  */
3054
2916
 
3055
- export { DAFF_CART_ERROR_MATCHER, DAFF_CART_EXTRA_REDUCERS, DAFF_CART_META_REDUCERS, DAFF_CART_RETRIEVAL_ACTIONS, 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, daffCartItemEntitiesRetrievalActionsReducerFactory, daffCartOrderInitialState, daffCartOrderReducer, daffCartProvideExtraReducers, daffCartProvideMetaReducers, daffCartProvideRetrievalActions, daffCartReducer, daffCartReducerInitialState, daffCartReducers, daffCartRetrievalActionsReducerFactory, daffCartRetrievalGetResponse, daffCartRetrivalActions, getDaffCartSelectors, initializeLoadingSetter };
2917
+ export { DAFF_CART_ERROR_MATCHER, DAFF_CART_EXTRA_REDUCERS, DAFF_CART_META_REDUCERS, DAFF_CART_RETRIEVAL_ACTIONS, 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, 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, daffCartItemEntitiesRetrievalActionsReducerFactory, daffCartOrderInitialState, daffCartOrderReducer, daffCartPaymentProcessorUpdate, daffCartProvideExtraReducers, daffCartProvideMetaReducers, daffCartProvideRetrievalActions, daffCartReducer, daffCartReducerInitialState, daffCartReducers, daffCartRetrievalActionsReducerFactory, daffCartRetrievalGetResponse, daffCartRetrivalActions, getDaffCartSelectors, initializeLoadingSetter };
3056
2918
  //# sourceMappingURL=daffodil-cart-state.mjs.map