@daffodil/cart 0.60.0 → 0.62.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
@@ -11,7 +11,7 @@ import { daffBuildFragmentNameSpread, daffBuildFragmentDefinition, DaffQueuedApo
11
11
  import { DaffCartNotFoundError, DaffUnauthorizedForCartError, DaffCartDriverErrorCodes, DaffProductOutOfStockError, DaffCartInvalidAPIResponseError, DaffCartDriverErrorMap, DaffInvalidCouponCodeError, DaffCartItemDriver, DaffCartDriver, DaffCartAddressDriver, DaffCartBillingAddressDriver, DaffCartShippingAddressDriver, DaffCartShippingMethodsDriver, DaffCartShippingInformationDriver, DaffCartPaymentDriver, DaffCartPaymentMethodsDriver, DaffCartOrderDriver, DaffCartCouponDriver, daffCartDriverProvideFreePaymentMethod } from '@daffodil/cart/driver';
12
12
  import { DaffBadInputError } from '@daffodil/driver';
13
13
  import { DaffProductNotFoundError } from '@daffodil/product/driver';
14
- import { forkJoin, throwError, of } from 'rxjs';
14
+ import { of, throwError, forkJoin } from 'rxjs';
15
15
  import { map, switchMap, catchError } from 'rxjs/operators';
16
16
  import { CommonModule } from '@angular/common';
17
17
 
@@ -1496,12 +1496,14 @@ class DaffMagentoCartService {
1496
1496
  response: data ? this.cartTransformer.transform(data.cart) : undefined,
1497
1497
  errors: errors?.map(e => {
1498
1498
  const error = transformMagentoCartGraphQlError(e);
1499
- if (DAFF_MAGENTO_GET_RECOVERABLE_ERRORS.filter(klass => error instanceof klass).length > 0) {
1499
+ if (DAFF_MAGENTO_GET_RECOVERABLE_ERRORS.find(klass => error instanceof klass)) {
1500
1500
  error.recoverable = true;
1501
1501
  }
1502
1502
  return error;
1503
1503
  }) || [],
1504
- })));
1504
+ })), switchMap((resp) => resp.errors.reduce((acc, err) => acc && err.recoverable, true)
1505
+ ? of(resp)
1506
+ : throwError(() => resp.errors.filter((err) => !err.recoverable)[0])));
1505
1507
  }
1506
1508
  create() {
1507
1509
  return this.mutationQueue.mutate({ mutation: createCart }).pipe(map(result => ({ id: result.data.createEmptyCart })));
@@ -1519,6 +1521,8 @@ class DaffMagentoCartService {
1519
1521
  source: guestCart,
1520
1522
  destination: customerCart,
1521
1523
  },
1524
+ errorPolicy: 'all',
1525
+ fetchPolicy: 'network-only',
1522
1526
  }).pipe(map(({ data, errors }) => ({
1523
1527
  response: data ? this.cartTransformer.transform(data.mergeCarts) : undefined,
1524
1528
  errors: errors?.map(e => {
@@ -1528,7 +1532,9 @@ class DaffMagentoCartService {
1528
1532
  }
1529
1533
  return error;
1530
1534
  }) || [],
1531
- })));
1535
+ })), switchMap((resp) => resp.errors.reduce((acc, err) => acc && err.recoverable, true)
1536
+ ? of(resp)
1537
+ : throwError(() => resp.errors.filter((err) => !err.recoverable)[0])));
1532
1538
  }
1533
1539
  ;
1534
1540
  }