@daffodil/cart 0.60.0 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/driver/in-memory/package.json +1 -1
  2. package/driver/magento/package.json +1 -1
  3. package/driver/magento/testing/package.json +1 -1
  4. package/driver/operators/handle-cart-not-found.d.ts +8 -0
  5. package/driver/operators/public_api.d.ts +1 -0
  6. package/driver/package.json +1 -1
  7. package/driver/public_api.d.ts +2 -0
  8. package/driver/services/public_api.d.ts +1 -0
  9. package/driver/services/resolve.service.d.ts +25 -0
  10. package/driver/testing/package.json +1 -1
  11. package/esm2020/driver/magento/cart.service.mjs +11 -5
  12. package/esm2020/driver/operators/handle-cart-not-found.mjs +17 -0
  13. package/esm2020/driver/operators/public_api.mjs +2 -0
  14. package/esm2020/driver/public_api.mjs +3 -1
  15. package/esm2020/driver/services/public_api.mjs +2 -0
  16. package/esm2020/driver/services/resolve.service.mjs +46 -0
  17. package/esm2020/routing/cart-routing.module.mjs +4 -2
  18. package/esm2020/routing/guards/public_api.mjs +3 -1
  19. package/esm2020/routing/guards/resolve-cart/redirect.token.mjs +3 -0
  20. package/esm2020/routing/guards/resolve-cart/resolve-cart.guard.mjs +58 -0
  21. package/esm2020/state/effects/cart-item.effects.mjs +15 -7
  22. package/esm2020/state/effects/cart-resolver.effects.mjs +18 -28
  23. package/esm2020/state/reducers/cart/cart.reducer.mjs +4 -4
  24. package/esm2020/state/reducers/cart-billing-address/cart-billing-address.reducer.mjs +3 -3
  25. package/esm2020/state/reducers/cart-coupon/cart-coupon.reducer.mjs +3 -3
  26. package/esm2020/state/reducers/cart-initial-state.mjs +2 -2
  27. package/esm2020/state/reducers/cart-item/cart-item.reducer.mjs +3 -3
  28. package/esm2020/state/reducers/cart-payment/cart-payment.reducer.mjs +3 -3
  29. package/esm2020/state/reducers/cart-payment-methods/cart-payment-methods.reducer.mjs +3 -3
  30. package/esm2020/state/reducers/cart-resolve/cart-resolve.reducer.mjs +3 -3
  31. package/esm2020/state/reducers/cart-shipping-address/cart-shipping-address.reducer.mjs +3 -3
  32. package/esm2020/state/reducers/cart-shipping-information/cart-shipping-information.reducer.mjs +3 -3
  33. package/esm2020/state/reducers/cart-shipping-methods/cart-shipping-methods.reducer.mjs +3 -3
  34. package/esm2020/state/reducers/cart.reducer.mjs +3 -3
  35. package/esm2020/state/reducers/public_api.mjs +3 -2
  36. package/fesm2015/daffodil-cart-driver-magento.mjs +10 -4
  37. package/fesm2015/daffodil-cart-driver-magento.mjs.map +1 -1
  38. package/fesm2015/daffodil-cart-driver.mjs +61 -2
  39. package/fesm2015/daffodil-cart-driver.mjs.map +1 -1
  40. package/fesm2015/daffodil-cart-routing.mjs +55 -1
  41. package/fesm2015/daffodil-cart-routing.mjs.map +1 -1
  42. package/fesm2015/daffodil-cart-state.mjs +42 -45
  43. package/fesm2015/daffodil-cart-state.mjs.map +1 -1
  44. package/fesm2020/daffodil-cart-driver-magento.mjs +10 -4
  45. package/fesm2020/daffodil-cart-driver-magento.mjs.map +1 -1
  46. package/fesm2020/daffodil-cart-driver.mjs +59 -2
  47. package/fesm2020/daffodil-cart-driver.mjs.map +1 -1
  48. package/fesm2020/daffodil-cart-routing.mjs +53 -1
  49. package/fesm2020/daffodil-cart-routing.mjs.map +1 -1
  50. package/fesm2020/daffodil-cart-state.mjs +42 -45
  51. package/fesm2020/daffodil-cart-state.mjs.map +1 -1
  52. package/package.json +1 -1
  53. package/routing/guards/public_api.d.ts +2 -0
  54. package/routing/guards/resolve-cart/redirect.token.d.ts +2 -0
  55. package/routing/guards/resolve-cart/resolve-cart.guard.d.ts +24 -0
  56. package/routing/package.json +1 -1
  57. package/state/effects/cart-item.effects.d.ts +9 -7
  58. package/state/effects/cart-resolver.effects.d.ts +3 -2
  59. package/state/package.json +1 -1
  60. package/state/reducers/cart-initial-state.d.ts +1 -1
  61. package/state/reducers/public_api.d.ts +2 -1
  62. package/state/testing/package.json +1 -1
  63. package/testing/package.json +1 -1
@@ -2,18 +2,19 @@ import * as i1$1 from '@ngrx/store';
2
2
  import { createFeatureSelector, createSelector, defaultMemoize, select, combineReducers, StoreModule } from '@ngrx/store';
3
3
  import { createEntityAdapter } from '@ngrx/entity';
4
4
  import { daffComposeReducers } from '@daffodil/core/state';
5
- import { DaffCartDriverErrorCodes, DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartCouponDriver, DaffCartItemDriver, DaffCartOrderDriver, DaffCartPaymentMethodsDriver, DaffCartPaymentDriver, DaffCartNotFoundError, DaffCartDriver, DaffCartShippingAddressDriver, DaffCartShippingInformationDriver, DaffCartShippingMethodsDriver } from '@daffodil/cart/driver';
5
+ import * as i4 from '@daffodil/cart/driver';
6
+ import { DaffCartDriverErrorCodes, DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartCouponDriver, daffCartDriverHandleCartNotFound, DaffCartItemDriver, DaffCartOrderDriver, DaffCartPaymentMethodsDriver, DaffCartPaymentDriver, DaffCartDriver, DaffCartShippingAddressDriver, DaffCartShippingInformationDriver, DaffCartShippingMethodsDriver } from '@daffodil/cart/driver';
6
7
  import * as i0 from '@angular/core';
7
8
  import { InjectionToken, Injectable, Inject, inject, NgModule } from '@angular/core';
8
9
  import * as i2 from '@daffodil/cart';
9
- import { DaffCartItemInputType, DaffCartTotalTypeEnum, DAFF_CART_ERROR_MATCHER, DaffCartNotFoundOrCreatedResolutionError, DaffCartResolutionError, DaffCartStorageResolutionError, DaffCartServerSideResolutionError, DaffCartPaymentMethodIdMap } from '@daffodil/cart';
10
+ import { DaffCartItemInputType, DaffCartTotalTypeEnum, DAFF_CART_ERROR_MATCHER, DaffCartResolutionError, DaffCartStorageResolutionError, DaffCartServerSideResolutionError, DaffCartPaymentMethodIdMap } from '@daffodil/cart';
10
11
  import { daffAdd, DaffStorageServiceError, DaffInheritableError, DaffServerSideStorageError } from '@daffodil/core';
11
12
  import { daffComparePersonalAddresses } from '@daffodil/geography';
12
13
  import * as i1 from '@ngrx/effects';
13
14
  import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
14
15
  import { DaffPaymentGenerateTokenFailure, DAFF_PAYMENT_PROCESSOR_COLLECTION, daffPaymentInitialState, DaffPaymentStateReducerAdapter, daffPaymentProvideExtraReducers } from '@daffodil/payment/state';
15
16
  import { defer, of, combineLatest, iif, EMPTY } from 'rxjs';
16
- import { switchMap, map, catchError, mergeMap, debounceTime, take, tap } from 'rxjs/operators';
17
+ import { switchMap, map, catchError, concatMap, mergeMap, debounceTime, take, tap } from 'rxjs/operators';
17
18
  import { DAFF_PAYMENT_ERROR_MATCHER } from '@daffodil/payment';
18
19
 
19
20
  /**
@@ -1241,7 +1242,7 @@ var DaffCartResolveState;
1241
1242
  DaffCartResolveState["ServerSide"] = "server";
1242
1243
  })(DaffCartResolveState || (DaffCartResolveState = {}));
1243
1244
 
1244
- const initialState = Object.freeze({
1245
+ const daffCartReducerInitialState = Object.freeze({
1245
1246
  cart: {
1246
1247
  id: null,
1247
1248
  subtotal: null,
@@ -1304,7 +1305,7 @@ const initializeLoadingSetter = (loadingSpace) => (loadingObj, loading) => ({
1304
1305
  const addError$8 = initializeErrorAdder(DaffCartOperationType.BillingAddress);
1305
1306
  const resetErrors$8 = initializeErrorResetter(DaffCartOperationType.BillingAddress);
1306
1307
  const setLoading$8 = initializeLoadingSetter(DaffCartOperationType.BillingAddress);
1307
- function cartBillingAddressReducer(state = initialState, action) {
1308
+ function cartBillingAddressReducer(state = daffCartReducerInitialState, action) {
1308
1309
  switch (action.type) {
1309
1310
  case DaffCartBillingAddressActionTypes.CartBillingAddressLoadAction:
1310
1311
  return {
@@ -1354,7 +1355,7 @@ function cartBillingAddressReducer(state = initialState, action) {
1354
1355
  const addError$7 = initializeErrorAdder(DaffCartOperationType.Coupon);
1355
1356
  const resetErrors$7 = initializeErrorResetter(DaffCartOperationType.Coupon);
1356
1357
  const setLoading$7 = initializeLoadingSetter(DaffCartOperationType.Coupon);
1357
- function cartCouponReducer(state = initialState, action) {
1358
+ function cartCouponReducer(state = daffCartReducerInitialState, action) {
1358
1359
  switch (action.type) {
1359
1360
  case DaffCartCouponActionTypes.CartCouponListAction:
1360
1361
  return {
@@ -1412,7 +1413,7 @@ function cartCouponReducer(state = initialState, action) {
1412
1413
  const addError$6 = initializeErrorAdder(DaffCartOperationType.Item);
1413
1414
  const resetErrors$6 = initializeErrorResetter(DaffCartOperationType.Item);
1414
1415
  const setLoading$6 = initializeLoadingSetter(DaffCartOperationType.Item);
1415
- function cartItemReducer(state = initialState, action) {
1416
+ function cartItemReducer(state = daffCartReducerInitialState, action) {
1416
1417
  switch (action.type) {
1417
1418
  case DaffCartItemActionTypes.CartItemListAction:
1418
1419
  case DaffCartItemActionTypes.CartItemLoadAction:
@@ -1504,7 +1505,7 @@ function cartItemReducer(state = initialState, action) {
1504
1505
  const addError$5 = initializeErrorAdder(DaffCartOperationType.PaymentMethods);
1505
1506
  const resetErrors$5 = initializeErrorResetter(DaffCartOperationType.PaymentMethods);
1506
1507
  const setLoading$5 = initializeLoadingSetter(DaffCartOperationType.PaymentMethods);
1507
- function cartPaymentMethodsReducer(state = initialState, action) {
1508
+ function cartPaymentMethodsReducer(state = daffCartReducerInitialState, action) {
1508
1509
  switch (action.type) {
1509
1510
  case DaffCartPaymentMethodsActionTypes.CartPaymentMethodsLoadAction:
1510
1511
  return {
@@ -1535,7 +1536,7 @@ function cartPaymentMethodsReducer(state = initialState, action) {
1535
1536
  const addError$4 = initializeErrorAdder(DaffCartOperationType.Payment);
1536
1537
  const resetErrors$4 = initializeErrorResetter(DaffCartOperationType.Payment);
1537
1538
  const setLoading$4 = initializeLoadingSetter(DaffCartOperationType.Payment);
1538
- function cartPaymentReducer(state = initialState, action) {
1539
+ function cartPaymentReducer(state = daffCartReducerInitialState, action) {
1539
1540
  switch (action.type) {
1540
1541
  case DaffCartPaymentActionTypes.CartPaymentLoadAction:
1541
1542
  return {
@@ -1610,7 +1611,7 @@ function cartPaymentReducer(state = initialState, action) {
1610
1611
  }
1611
1612
  }
1612
1613
 
1613
- function cartResolveReducer(state = initialState, action) {
1614
+ function cartResolveReducer(state = daffCartReducerInitialState, action) {
1614
1615
  switch (action.type) {
1615
1616
  case DaffCartActionTypes.ResolveCartAction:
1616
1617
  return {
@@ -1642,7 +1643,7 @@ function cartResolveReducer(state = initialState, action) {
1642
1643
  const addError$3 = initializeErrorAdder(DaffCartOperationType.ShippingAddress);
1643
1644
  const resetErrors$3 = initializeErrorResetter(DaffCartOperationType.ShippingAddress);
1644
1645
  const setLoading$3 = initializeLoadingSetter(DaffCartOperationType.ShippingAddress);
1645
- function cartShippingAddressReducer(state = initialState, action) {
1646
+ function cartShippingAddressReducer(state = daffCartReducerInitialState, action) {
1646
1647
  switch (action.type) {
1647
1648
  case DaffCartShippingAddressActionTypes.CartShippingAddressLoadAction:
1648
1649
  return {
@@ -1692,7 +1693,7 @@ function cartShippingAddressReducer(state = initialState, action) {
1692
1693
  const addError$2 = initializeErrorAdder(DaffCartOperationType.ShippingInformation);
1693
1694
  const resetErrors$2 = initializeErrorResetter(DaffCartOperationType.ShippingInformation);
1694
1695
  const setLoading$2 = initializeLoadingSetter(DaffCartOperationType.ShippingInformation);
1695
- function cartShippingInformationReducer(state = initialState, action) {
1696
+ function cartShippingInformationReducer(state = daffCartReducerInitialState, action) {
1696
1697
  switch (action.type) {
1697
1698
  case DaffCartShippingInformationActionTypes.CartShippingInformationLoadAction:
1698
1699
  return {
@@ -1745,7 +1746,7 @@ function cartShippingInformationReducer(state = initialState, action) {
1745
1746
  const addError$1 = initializeErrorAdder(DaffCartOperationType.ShippingMethods);
1746
1747
  const resetErrors$1 = initializeErrorResetter(DaffCartOperationType.ShippingMethods);
1747
1748
  const setLoading$1 = initializeLoadingSetter(DaffCartOperationType.ShippingMethods);
1748
- function cartShippingMethodsReducer(state = initialState, action) {
1749
+ function cartShippingMethodsReducer(state = daffCartReducerInitialState, action) {
1749
1750
  switch (action.type) {
1750
1751
  case DaffCartShippingMethodsActionTypes.CartShippingMethodsLoadAction:
1751
1752
  return {
@@ -1776,7 +1777,7 @@ function cartShippingMethodsReducer(state = initialState, action) {
1776
1777
  const addError = initializeErrorAdder(DaffCartOperationType.Cart);
1777
1778
  const resetErrors = initializeErrorResetter(DaffCartOperationType.Cart);
1778
1779
  const setLoading = initializeLoadingSetter(DaffCartOperationType.Cart);
1779
- function cartReducer(state = initialState, action) {
1780
+ function cartReducer(state = daffCartReducerInitialState, action) {
1780
1781
  switch (action.type) {
1781
1782
  case DaffCartActionTypes.ResolveCartAction:
1782
1783
  case DaffCartActionTypes.CartLoadAction:
@@ -1809,7 +1810,7 @@ function cartReducer(state = initialState, action) {
1809
1810
  ...state,
1810
1811
  ...resetErrors(state.errors),
1811
1812
  cart: {
1812
- ...initialState.cart,
1813
+ ...daffCartReducerInitialState.cart,
1813
1814
  ...action.payload,
1814
1815
  },
1815
1816
  ...setLoading(state.loading, "Stable" /* Complete */),
@@ -1862,7 +1863,7 @@ const composedReducers = daffComposeReducers([
1862
1863
  * Calls each of the individual cart reducers in turn,
1863
1864
  * passing the returned state into the next.
1864
1865
  */
1865
- function daffCartReducer(state = initialState, action) {
1866
+ function daffCartReducer(state = daffCartReducerInitialState, action) {
1866
1867
  return composedReducers(state, action);
1867
1868
  }
1868
1869
 
@@ -2338,16 +2339,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
2338
2339
  }] }, { type: i2.DaffCartStorageService }]; } });
2339
2340
 
2340
2341
  class DaffCartItemEffects {
2341
- constructor(actions$, errorMatcher, driver, storage, cartItemStateDebounceTime, store) {
2342
+ constructor(actions$, errorMatcher, driver, storage, cartItemStateDebounceTime, store, cartResolver) {
2342
2343
  this.actions$ = actions$;
2343
2344
  this.errorMatcher = errorMatcher;
2344
2345
  this.driver = driver;
2345
2346
  this.storage = storage;
2346
2347
  this.cartItemStateDebounceTime = cartItemStateDebounceTime;
2347
2348
  this.store = store;
2349
+ this.cartResolver = cartResolver;
2348
2350
  this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemListAction), switchMap((action) => this.driver.list(this.storage.getCartId()).pipe(map((resp) => new DaffCartItemListSuccess(resp)), catchError(error => of(new DaffCartItemListFailure(this.errorMatcher(error))))))));
2349
2351
  this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemLoadAction), switchMap((action) => this.driver.get(this.storage.getCartId(), action.itemId).pipe(map((resp) => new DaffCartItemLoadSuccess(resp)), catchError(error => of(new DaffCartItemLoadFailure(this.errorMatcher(error), action.itemId)))))));
2350
- this.add$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemAddAction), switchMap((action) => this.driver.add(this.storage.getCartId(), action.input).pipe(map((resp) => new DaffCartItemAddSuccess(resp)), catchError(error => of(new DaffCartItemAddFailure(this.errorMatcher(error))))))));
2352
+ this.add$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemAddAction), concatMap((action) => combineLatest([
2353
+ of(action),
2354
+ this.cartResolver.getCartIdOrFail(),
2355
+ ])), mergeMap(([action, id]) => this.addCartItem$(id, action.input)), daffCartDriverHandleCartNotFound(this.storage), catchError(error => of(new DaffCartItemAddFailure(this.errorMatcher(error))))));
2351
2356
  this.update$ = createEffect(() => this.actions$.pipe(ofType(DaffCartItemActionTypes.CartItemUpdateAction), mergeMap((action) => this.driver.update(this.storage.getCartId(), action.itemId, action.changes).pipe(map((resp) => new DaffCartItemUpdateSuccess(resp, action.itemId)), catchError(error => of(new DaffCartItemUpdateFailure(this.errorMatcher(error), action.itemId)))))));
2352
2357
  this.resetCartItemStateAfterChange$ = createEffect(() => this.actions$.pipe(ofType(
2353
2358
  // these actions will reset the debounce interval
@@ -2359,8 +2364,11 @@ class DaffCartItemEffects {
2359
2364
  ? combineLatest(items.map(item => this.driver.delete(this.storage.getCartId(), item.id))).pipe(map(partialCarts => Object.assign({}, ...partialCarts)))
2360
2365
  : this.store.pipe(select(getDaffCartSelectors().selectCartValue), take(1))), map(cart => new DaffCartItemDeleteOutOfStockSuccess(cart)), catchError(error => of(new DaffCartItemDeleteOutOfStockFailure(this.errorMatcher(error))))));
2361
2366
  }
2367
+ addCartItem$(cartId, input) {
2368
+ return this.driver.add(cartId, input).pipe(map((resp) => new DaffCartItemAddSuccess(resp)), catchError(error => of(new DaffCartItemAddFailure(this.errorMatcher(error)))));
2369
+ }
2362
2370
  }
2363
- /** @nocollapse */ DaffCartItemEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartItemEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartItemDriver }, { token: i2.DaffCartStorageService }, { token: DaffCartItemStateDebounceTime }, { token: i1$1.Store }], target: i0.ɵɵFactoryTarget.Injectable });
2371
+ /** @nocollapse */ DaffCartItemEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartItemEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: DaffCartItemDriver }, { token: i2.DaffCartStorageService }, { token: DaffCartItemStateDebounceTime }, { token: i1$1.Store }, { token: i4.DaffCartDriverResolveService }], target: i0.ɵɵFactoryTarget.Injectable });
2364
2372
  /** @nocollapse */ DaffCartItemEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartItemEffects });
2365
2373
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartItemEffects, decorators: [{
2366
2374
  type: Injectable
@@ -2373,7 +2381,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
2373
2381
  }] }, { type: i2.DaffCartStorageService }, { type: undefined, decorators: [{
2374
2382
  type: Inject,
2375
2383
  args: [DaffCartItemStateDebounceTime]
2376
- }] }, { type: i1$1.Store }]; } });
2384
+ }] }, { type: i1$1.Store }, { type: i4.DaffCartDriverResolveService }]; } });
2377
2385
 
2378
2386
  class DaffCartOrderEffects {
2379
2387
  constructor(actions$, errorMatcher, driver, storage) {
@@ -2488,56 +2496,45 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
2488
2496
  * 3. If the cart resolution fails, it will bailout.
2489
2497
  */
2490
2498
  class DaffCartResolverEffects {
2491
- constructor(actions$, errorMatcher, cartStorage, driver) {
2499
+ constructor(actions$, errorMatcher, cartStorage, cartResolver, driver) {
2492
2500
  this.actions$ = actions$;
2493
2501
  this.errorMatcher = errorMatcher;
2494
2502
  this.cartStorage = cartStorage;
2503
+ this.cartResolver = cartResolver;
2495
2504
  this.driver = driver;
2496
2505
  this.onResolveCart = createEffect(() => () => this.actions$.pipe(ofType(DaffCartActionTypes.ResolveCartAction, DaffCartActionTypes.ResolveCartSuccessAction), switchMap(action => iif(
2497
2506
  // if something else resolves the cart during an outstanding resolve
2498
2507
  () => action.type === DaffCartActionTypes.ResolveCartSuccessAction,
2499
2508
  // then just cancel the outstanding operation
2500
- EMPTY, defer(() => of(this.cartStorage.getCartId())).pipe(switchMap(cartId => cartId ? of({ id: cartId }) : this.driver.create()), switchMap(({ id }) => this.driver.get(id)), switchMap(({ response, errors }) => {
2501
- if (errors.length === 0) {
2502
- return of(new DaffResolveCartSuccess(response));
2503
- }
2504
- const hasOnlyRecoverableErrors = errors.reduce((acc, error) => acc && error.recoverable, true);
2505
- if (hasOnlyRecoverableErrors) {
2506
- return of(new DaffResolveCartPartialSuccess(response, errors.map(error => this.errorMatcher(error))));
2507
- }
2508
- if (errors.find(error => error instanceof DaffCartNotFoundError)) {
2509
- return this.driver.create().pipe(switchMap(({ id }) => this.driver.get(id)), map(resp => new DaffResolveCartSuccess(resp.response)), catchError((innerError) => of(new DaffResolveCartFailure([this.errorMatcher(new DaffCartNotFoundOrCreatedResolutionError(innerError.message))]))));
2510
- }
2511
- // there are no special case errors, DaffResolveCartFailure will suffice
2512
- // just map the errors
2513
- return of(new DaffResolveCartFailure(errors.map(error => this.errorMatcher(
2514
- // I wish there was a better way to check this
2515
- error instanceof DaffInheritableError || !!error.code
2516
- ? error
2517
- : new DaffCartResolutionError(error.message)))));
2518
- }), catchError((error) => {
2509
+ EMPTY, this.cartResolver.getCartOrFail().pipe(map(({ response, errors }) => errors.length > 0
2510
+ ? new DaffResolveCartPartialSuccess(response, errors.map(error => this.errorMatcher(error)))
2511
+ : new DaffResolveCartSuccess(response)), daffCartDriverHandleCartNotFound(this.cartStorage), catchError((error) => {
2519
2512
  switch (true) {
2520
2513
  case error instanceof DaffServerSideStorageError:
2521
2514
  return of(new DaffResolveCartServerSide(this.errorMatcher(new DaffCartServerSideResolutionError(error.message))));
2522
2515
  case error instanceof DaffStorageServiceError:
2523
2516
  return of(new DaffResolveCartFailure([this.errorMatcher(new DaffCartStorageResolutionError(error.message))]));
2524
2517
  default:
2525
- return of(new DaffResolveCartFailure([this.errorMatcher(new DaffCartResolutionError(error.message))]));
2518
+ return of(new DaffResolveCartFailure([this.errorMatcher(
2519
+ // I wish there was a better way to check this
2520
+ error instanceof DaffInheritableError || !!error.code
2521
+ ? error
2522
+ : new DaffCartResolutionError(error.message))]));
2526
2523
  }
2527
2524
  }))))));
2528
2525
  }
2529
2526
  ngrxOnInitEffects() {
2530
- return new DaffResolveCart();
2527
+ return this.cartStorage.getCartId() ? new DaffResolveCart() : { type: '' };
2531
2528
  }
2532
2529
  }
2533
- /** @nocollapse */ DaffCartResolverEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartResolverEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: i2.DaffCartStorageService }, { token: DaffCartDriver }], target: i0.ɵɵFactoryTarget.Injectable });
2530
+ /** @nocollapse */ DaffCartResolverEffects.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartResolverEffects, deps: [{ token: i1.Actions }, { token: DAFF_CART_ERROR_MATCHER }, { token: i2.DaffCartStorageService }, { token: i4.DaffCartDriverResolveService }, { token: DaffCartDriver }], target: i0.ɵɵFactoryTarget.Injectable });
2534
2531
  /** @nocollapse */ DaffCartResolverEffects.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartResolverEffects });
2535
2532
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffCartResolverEffects, decorators: [{
2536
2533
  type: Injectable
2537
2534
  }], ctorParameters: function () { return [{ type: i1.Actions }, { type: undefined, decorators: [{
2538
2535
  type: Inject,
2539
2536
  args: [DAFF_CART_ERROR_MATCHER]
2540
- }] }, { type: i2.DaffCartStorageService }, { type: undefined, decorators: [{
2537
+ }] }, { type: i2.DaffCartStorageService }, { type: i4.DaffCartDriverResolveService }, { type: undefined, decorators: [{
2541
2538
  type: Inject,
2542
2539
  args: [DaffCartDriver]
2543
2540
  }] }]; } });
@@ -2891,5 +2888,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
2891
2888
  * Generated bundle index. Do not edit.
2892
2889
  */
2893
2890
 
2894
- export { DAFF_CART_EXTRA_REDUCERS, DAFF_CART_STORE_FEATURE_KEY, DaffAddToCart, DaffAddToCartFailure, DaffAddToCartSuccess, DaffCartActionTypes, DaffCartAddressActionTypes, DaffCartAddressUpdate, DaffCartAddressUpdateFailure, DaffCartAddressUpdateSuccess, DaffCartBillingAddressActionTypes, DaffCartBillingAddressLoad, DaffCartBillingAddressLoadFailure, DaffCartBillingAddressLoadSuccess, DaffCartBillingAddressUpdate, DaffCartBillingAddressUpdateFailure, DaffCartBillingAddressUpdateSuccess, DaffCartClear, DaffCartClearFailure, DaffCartClearSuccess, DaffCartCouponActionTypes, DaffCartCouponApply, DaffCartCouponApplyFailure, DaffCartCouponApplySuccess, DaffCartCouponClearErrors, DaffCartCouponList, DaffCartCouponListFailure, DaffCartCouponListSuccess, DaffCartCouponRemove, DaffCartCouponRemoveAll, DaffCartCouponRemoveAllFailure, DaffCartCouponRemoveAllSuccess, DaffCartCouponRemoveFailure, DaffCartCouponRemoveSuccess, DaffCartCreate, DaffCartCreateFailure, DaffCartCreateSuccess, DaffCartFacade, DaffCartItemActionTypes, DaffCartItemAdd, DaffCartItemAddFailure, DaffCartItemAddSuccess, DaffCartItemDelete, DaffCartItemDeleteFailure, DaffCartItemDeleteOutOfStock, DaffCartItemDeleteOutOfStockFailure, DaffCartItemDeleteOutOfStockSuccess, DaffCartItemDeleteSuccess, DaffCartItemList, DaffCartItemListFailure, DaffCartItemListSuccess, DaffCartItemLoad, DaffCartItemLoadFailure, DaffCartItemLoadSuccess, DaffCartItemStateDebounceTime, DaffCartItemStateEnum, DaffCartItemStateReset, DaffCartItemUpdate, DaffCartItemUpdateFailure, DaffCartItemUpdateSuccess, DaffCartLoad, DaffCartLoadFailure, DaffCartLoadPartialSuccess, DaffCartLoadSuccess, DaffCartOperationType, DaffCartOrderActionTypes, DaffCartPaymentActionTypes, DaffCartPaymentLoad, DaffCartPaymentLoadFailure, DaffCartPaymentLoadSuccess, DaffCartPaymentMethodAdd, DaffCartPaymentMethodsActionTypes, DaffCartPaymentMethodsLoad, DaffCartPaymentMethodsLoadFailure, DaffCartPaymentMethodsLoadSuccess, DaffCartPaymentRemove, DaffCartPaymentRemoveFailure, DaffCartPaymentRemoveSuccess, DaffCartPaymentUpdate, DaffCartPaymentUpdateFailure, DaffCartPaymentUpdateSuccess, DaffCartPaymentUpdateWithBilling, DaffCartPaymentUpdateWithBillingFailure, DaffCartPaymentUpdateWithBillingSuccess, DaffCartPlaceOrder, DaffCartPlaceOrderFailure, DaffCartPlaceOrderSuccess, DaffCartResolveState, DaffCartShippingAddressActionTypes, DaffCartShippingAddressLoad, DaffCartShippingAddressLoadFailure, DaffCartShippingAddressLoadSuccess, DaffCartShippingAddressUpdate, DaffCartShippingAddressUpdateFailure, DaffCartShippingAddressUpdateSuccess, DaffCartShippingInformationActionTypes, DaffCartShippingInformationDelete, DaffCartShippingInformationDeleteFailure, DaffCartShippingInformationDeleteSuccess, DaffCartShippingInformationLoad, DaffCartShippingInformationLoadFailure, DaffCartShippingInformationLoadSuccess, DaffCartShippingInformationUpdate, DaffCartShippingInformationUpdateFailure, DaffCartShippingInformationUpdateSuccess, DaffCartShippingMethodsActionTypes, DaffCartShippingMethodsLoad, DaffCartShippingMethodsLoadFailure, DaffCartShippingMethodsLoadSuccess, DaffCartStateModule, DaffCartStorageFailure, DaffResolveCart, DaffResolveCartFailure, DaffResolveCartPartialSuccess, DaffResolveCartServerSide, DaffResolveCartSuccess, daffCartOrderInitialState, daffCartOrderReducer, daffCartProvideExtraReducers, daffCartReducer, daffCartReducers, getDaffCartSelectors, initialState, initializeLoadingSetter };
2891
+ export { DAFF_CART_EXTRA_REDUCERS, DAFF_CART_STORE_FEATURE_KEY, DaffAddToCart, DaffAddToCartFailure, DaffAddToCartSuccess, DaffCartActionTypes, DaffCartAddressActionTypes, DaffCartAddressUpdate, DaffCartAddressUpdateFailure, DaffCartAddressUpdateSuccess, DaffCartBillingAddressActionTypes, DaffCartBillingAddressLoad, DaffCartBillingAddressLoadFailure, DaffCartBillingAddressLoadSuccess, DaffCartBillingAddressUpdate, DaffCartBillingAddressUpdateFailure, DaffCartBillingAddressUpdateSuccess, DaffCartClear, DaffCartClearFailure, DaffCartClearSuccess, DaffCartCouponActionTypes, DaffCartCouponApply, DaffCartCouponApplyFailure, DaffCartCouponApplySuccess, DaffCartCouponClearErrors, DaffCartCouponList, DaffCartCouponListFailure, DaffCartCouponListSuccess, DaffCartCouponRemove, DaffCartCouponRemoveAll, DaffCartCouponRemoveAllFailure, DaffCartCouponRemoveAllSuccess, DaffCartCouponRemoveFailure, DaffCartCouponRemoveSuccess, DaffCartCreate, DaffCartCreateFailure, DaffCartCreateSuccess, DaffCartFacade, DaffCartItemActionTypes, DaffCartItemAdd, DaffCartItemAddFailure, DaffCartItemAddSuccess, DaffCartItemDelete, DaffCartItemDeleteFailure, DaffCartItemDeleteOutOfStock, DaffCartItemDeleteOutOfStockFailure, DaffCartItemDeleteOutOfStockSuccess, DaffCartItemDeleteSuccess, DaffCartItemList, DaffCartItemListFailure, DaffCartItemListSuccess, DaffCartItemLoad, DaffCartItemLoadFailure, DaffCartItemLoadSuccess, DaffCartItemStateDebounceTime, DaffCartItemStateEnum, DaffCartItemStateReset, DaffCartItemUpdate, DaffCartItemUpdateFailure, DaffCartItemUpdateSuccess, DaffCartLoad, DaffCartLoadFailure, DaffCartLoadPartialSuccess, DaffCartLoadSuccess, DaffCartOperationType, DaffCartOrderActionTypes, DaffCartPaymentActionTypes, DaffCartPaymentLoad, DaffCartPaymentLoadFailure, DaffCartPaymentLoadSuccess, DaffCartPaymentMethodAdd, DaffCartPaymentMethodsActionTypes, DaffCartPaymentMethodsLoad, DaffCartPaymentMethodsLoadFailure, DaffCartPaymentMethodsLoadSuccess, DaffCartPaymentRemove, DaffCartPaymentRemoveFailure, DaffCartPaymentRemoveSuccess, DaffCartPaymentUpdate, DaffCartPaymentUpdateFailure, DaffCartPaymentUpdateSuccess, DaffCartPaymentUpdateWithBilling, DaffCartPaymentUpdateWithBillingFailure, DaffCartPaymentUpdateWithBillingSuccess, DaffCartPlaceOrder, DaffCartPlaceOrderFailure, DaffCartPlaceOrderSuccess, DaffCartResolveState, DaffCartShippingAddressActionTypes, DaffCartShippingAddressLoad, DaffCartShippingAddressLoadFailure, DaffCartShippingAddressLoadSuccess, DaffCartShippingAddressUpdate, DaffCartShippingAddressUpdateFailure, DaffCartShippingAddressUpdateSuccess, DaffCartShippingInformationActionTypes, DaffCartShippingInformationDelete, DaffCartShippingInformationDeleteFailure, DaffCartShippingInformationDeleteSuccess, DaffCartShippingInformationLoad, DaffCartShippingInformationLoadFailure, DaffCartShippingInformationLoadSuccess, DaffCartShippingInformationUpdate, DaffCartShippingInformationUpdateFailure, DaffCartShippingInformationUpdateSuccess, DaffCartShippingMethodsActionTypes, DaffCartShippingMethodsLoad, DaffCartShippingMethodsLoadFailure, DaffCartShippingMethodsLoadSuccess, DaffCartStateModule, DaffCartStorageFailure, DaffResolveCart, DaffResolveCartFailure, DaffResolveCartPartialSuccess, DaffResolveCartServerSide, DaffResolveCartSuccess, daffCartItemEntitiesAdapter, daffCartOrderInitialState, daffCartOrderReducer, daffCartProvideExtraReducers, daffCartReducer, daffCartReducerInitialState, daffCartReducers, getDaffCartSelectors, initializeLoadingSetter };
2895
2892
  //# sourceMappingURL=daffodil-cart-state.mjs.map