@daffodil/cart 0.39.7 → 0.39.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/daffodil-cart-driver-magento-testing.umd.js +12 -2
- package/bundles/daffodil-cart-driver-magento-testing.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver-magento-testing.umd.min.js +2 -2
- package/bundles/daffodil-cart-driver-magento-testing.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-driver-magento.umd.js +88 -34
- package/bundles/daffodil-cart-driver-magento.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver-magento.umd.min.js +1 -1
- package/bundles/daffodil-cart-driver-magento.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-driver-testing.umd.js +2 -2
- package/bundles/daffodil-cart-driver-testing.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver-testing.umd.min.js +1 -1
- package/bundles/daffodil-cart-driver-testing.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-driver.umd.js +34 -1
- package/bundles/daffodil-cart-driver.umd.js.map +1 -1
- package/bundles/daffodil-cart-driver.umd.min.js +2 -2
- package/bundles/daffodil-cart-driver.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-routing.umd.js +43 -0
- package/bundles/daffodil-cart-routing.umd.js.map +1 -1
- package/bundles/daffodil-cart-routing.umd.min.js +1 -1
- package/bundles/daffodil-cart-routing.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-state-testing.umd.js +13 -2
- package/bundles/daffodil-cart-state-testing.umd.js.map +1 -1
- package/bundles/daffodil-cart-state-testing.umd.min.js +2 -2
- package/bundles/daffodil-cart-state-testing.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-state.umd.js +27 -8
- package/bundles/daffodil-cart-state.umd.js.map +1 -1
- package/bundles/daffodil-cart-state.umd.min.js +1 -1
- package/bundles/daffodil-cart-state.umd.min.js.map +1 -1
- package/bundles/daffodil-cart-testing.umd.js +3 -3
- package/bundles/daffodil-cart-testing.umd.js.map +1 -1
- package/bundles/daffodil-cart-testing.umd.min.js +2 -2
- package/bundles/daffodil-cart-testing.umd.min.js.map +1 -1
- package/driver/daffodil-cart-driver.metadata.json +1 -1
- package/driver/errors/codes.enum.d.ts +3 -1
- package/driver/errors/invalid-email.d.ts +8 -0
- package/driver/errors/item-exceeds-max-qty.d.ts +9 -0
- package/driver/errors/map.d.ts +4 -0
- package/driver/errors/product-out-of-stock.d.ts +1 -1
- package/driver/errors/public_api.d.ts +2 -0
- package/driver/magento/cart-item.service.d.ts +3 -1
- package/driver/magento/daffodil-cart-driver-magento.metadata.json +1 -1
- package/driver/magento/errors/map.d.ts +2 -0
- package/driver/magento/injection-tokens/public_api.d.ts +1 -0
- package/driver/magento/injection-tokens/transforms/cart-item/token.d.ts +22 -0
- package/driver/magento/interfaces/cart-item-transform.type.d.ts +3 -0
- package/driver/magento/interfaces/public_api.d.ts +1 -0
- package/driver/magento/public_api.d.ts +1 -0
- package/driver/magento/testing/daffodil-cart-driver-magento-testing.metadata.json +1 -1
- package/driver/magento/testing/factories/public_api.d.ts +10 -10
- package/driver/magento/transforms/outputs/cart-coupon-response.service.d.ts +3 -0
- package/driver/magento/transforms/outputs/cart-item/cart-item-transformer.d.ts +7 -4
- package/driver/magento/transforms/outputs/cart.service.d.ts +3 -1
- package/esm2015/driver/errors/codes.enum.js +3 -1
- package/esm2015/driver/errors/invalid-email.js +12 -0
- package/esm2015/driver/errors/item-exceeds-max-qty.js +13 -0
- package/esm2015/driver/errors/map.js +5 -1
- package/esm2015/driver/errors/product-out-of-stock.js +2 -2
- package/esm2015/driver/errors/public_api.js +3 -1
- package/esm2015/driver/magento/cart-item.service.js +11 -8
- package/esm2015/driver/magento/errors/map.js +4 -2
- package/esm2015/driver/magento/injection-tokens/public_api.js +2 -1
- package/esm2015/driver/magento/injection-tokens/transforms/cart-item/token.js +27 -0
- package/esm2015/driver/magento/interfaces/cart-item-transform.type.js +2 -0
- package/esm2015/driver/magento/interfaces/public_api.js +2 -0
- package/esm2015/driver/magento/public_api.js +2 -1
- package/esm2015/driver/magento/testing/factories/cart-address-input.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-address.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-coupon.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-item/bundle-cart-item.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-item/cart-item.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-item/configurable-cart-item.factory.js +1 -1
- package/esm2015/driver/magento/testing/factories/cart-payment-method.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart-shipping-method.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/cart.factory.js +2 -2
- package/esm2015/driver/magento/testing/factories/public_api.js +11 -11
- package/esm2015/driver/magento/transforms/outputs/cart-coupon-response.service.js +15 -5
- package/esm2015/driver/magento/transforms/outputs/cart-item/bundle-cart-item-transformer.js +2 -2
- package/esm2015/driver/magento/transforms/outputs/cart-item/cart-item-transformer.js +9 -6
- package/esm2015/driver/magento/transforms/outputs/cart-item/configurable-cart-item-transformer.js +2 -2
- package/esm2015/driver/magento/transforms/outputs/cart-item/simple-cart-item-transformer.js +3 -3
- package/esm2015/driver/magento/transforms/outputs/cart.service.js +12 -7
- package/esm2015/driver/testing/drivers/cart-order/cart-order.service.js +2 -2
- package/esm2015/routing/guards/in-stock-items/in-stock-items-guard-redirect.token.js +6 -0
- package/esm2015/routing/guards/in-stock-items/in-stock-items.guard.js +43 -0
- package/esm2015/routing/guards/public_api.js +3 -1
- package/esm2015/state/effects/cart-resolver.effects.js +5 -2
- package/esm2015/state/facades/cart/cart-facade.interface.js +1 -1
- package/esm2015/state/facades/cart/cart.facade.js +10 -2
- package/esm2015/state/models/stateful-cart-item.js +1 -1
- package/esm2015/state/reducers/cart/cart.reducer.js +1 -2
- package/esm2015/state/reducers/cart-item/cart-item.reducer.js +3 -1
- package/esm2015/state/reducers/cart-item-entities/cart-item-entities.reducer.js +8 -7
- package/esm2015/state/selectors/cart-item-entities/cart-item-entities.selectors.js +7 -1
- package/esm2015/state/testing/factories/stateful-cart-item.factory.js +2 -1
- package/esm2015/state/testing/factories/stateful-composite-cart-item.factory.js +5 -1
- package/esm2015/state/testing/factories/stateful-configurable-cart-item.factory.js +5 -1
- package/esm2015/state/testing/mock-cart-facade.js +7 -1
- package/esm2015/testing/factories/cart-address.factory.js +2 -2
- package/esm2015/testing/factories/cart-coupon.factory.js +2 -2
- package/esm2015/testing/factories/cart-item/cart-item.factory.js +3 -3
- package/esm2015/testing/factories/cart-item/composite-cart-item.factory.js +2 -2
- package/esm2015/testing/factories/cart-item/configurable-cart-item.factory.js +1 -1
- package/esm2015/testing/factories/cart-shipping-rate.factory.js +2 -2
- package/esm2015/testing/factories/cart.factory.js +2 -2
- package/fesm2015/daffodil-cart-driver-magento-testing.js +2 -2
- package/fesm2015/daffodil-cart-driver-magento-testing.js.map +1 -1
- package/fesm2015/daffodil-cart-driver-magento.js +79 -35
- package/fesm2015/daffodil-cart-driver-magento.js.map +1 -1
- package/fesm2015/daffodil-cart-driver-testing.js +1 -1
- package/fesm2015/daffodil-cart-driver-testing.js.map +1 -1
- package/fesm2015/daffodil-cart-driver.js +27 -2
- package/fesm2015/daffodil-cart-driver.js.map +1 -1
- package/fesm2015/daffodil-cart-routing.js +40 -1
- package/fesm2015/daffodil-cart-routing.js.map +1 -1
- package/fesm2015/daffodil-cart-state-testing.js +15 -0
- package/fesm2015/daffodil-cart-state-testing.js.map +1 -1
- package/fesm2015/daffodil-cart-state.js +28 -9
- package/fesm2015/daffodil-cart-state.js.map +1 -1
- package/fesm2015/daffodil-cart-testing.js +2 -2
- package/fesm2015/daffodil-cart-testing.js.map +1 -1
- package/package.json +6 -6
- package/routing/daffodil-cart-routing.metadata.json +1 -1
- package/routing/guards/in-stock-items/in-stock-items-guard-redirect.token.d.ts +5 -0
- package/routing/guards/in-stock-items/in-stock-items.guard.d.ts +17 -0
- package/routing/guards/public_api.d.ts +2 -0
- package/state/daffodil-cart-state.metadata.json +1 -1
- package/state/facades/cart/cart-facade.interface.d.ts +19 -0
- package/state/facades/cart/cart.facade.d.ts +5 -0
- package/state/models/stateful-cart-item.d.ts +5 -0
- package/state/selectors/cart-item-entities/cart-item-entities.selectors.d.ts +13 -0
- package/state/testing/daffodil-cart-state-testing.metadata.json +1 -1
- package/state/testing/factories/stateful-cart-item.factory.d.ts +1 -0
- package/state/testing/factories/stateful-composite-cart-item.factory.d.ts +1 -0
- package/state/testing/factories/stateful-configurable-cart-item.factory.d.ts +1 -0
- package/state/testing/mock-cart-facade.d.ts +4 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ɵɵdefineInjectable, Injectable, ɵɵinject,
|
|
1
|
+
import { InjectionToken, ɵɵdefineInjectable, Injectable, ɵɵinject, Inject, inject, NgModule } from '@angular/core';
|
|
2
2
|
import { DaffCartItemInputType, DaffCartTotalTypeEnum } from '@daffodil/cart';
|
|
3
3
|
import { MagentoProductStockStatusEnum } from '@daffodil/product/driver/magento';
|
|
4
4
|
import { daffAdd } from '@daffodil/core';
|
|
@@ -11,6 +11,46 @@ import { daffTransformMagentoError } from '@daffodil/driver/magento';
|
|
|
11
11
|
import { DaffBadInputError } from '@daffodil/driver';
|
|
12
12
|
import { CommonModule } from '@angular/common';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* An multi-provider injection token for providing extra GraphQL fragments that will be spread into cart queries.
|
|
16
|
+
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces.
|
|
17
|
+
* The data will appear in DaffCart#extra_attributes.
|
|
18
|
+
*
|
|
19
|
+
* Fragment structure is platform-specific and this feature should be used with care.
|
|
20
|
+
*
|
|
21
|
+
* This can increase query complexity above the Magento default of 300.
|
|
22
|
+
* Daffodil only guarantees that stock queries don't exceed the limit of 300.
|
|
23
|
+
* Apps using this token should therefore increase the query complexity limit
|
|
24
|
+
* to accommodate the extra complexity contributed by the provided fragments.
|
|
25
|
+
*/
|
|
26
|
+
const DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS = new InjectionToken('DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS', { factory: () => [] });
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A multi-provider injection token for providing cart item transform logic in the Magento driver.
|
|
30
|
+
* It is run after the standard transforms and passed both the current transformed Daffodil cart item and the Magento cart item.
|
|
31
|
+
*/
|
|
32
|
+
const DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS = new InjectionToken('DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS', { factory: () => [] });
|
|
33
|
+
/**
|
|
34
|
+
* Provides cart item transforms for the Magento cart driver.
|
|
35
|
+
*
|
|
36
|
+
* See {@link DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS}.
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* providers: [
|
|
40
|
+
* ...daffProvideCartMagentoCartItemTransforms(
|
|
41
|
+
* myCartItemTransform
|
|
42
|
+
* )
|
|
43
|
+
* ]
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
function daffProvideCartMagentoCartItemTransforms(...transforms) {
|
|
47
|
+
return transforms.map(transform => ({
|
|
48
|
+
provide: DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,
|
|
49
|
+
useValue: transform,
|
|
50
|
+
multi: true,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
|
|
14
54
|
/**
|
|
15
55
|
* Transforms magento addresses into an object usable by daffodil.
|
|
16
56
|
*/
|
|
@@ -98,7 +138,7 @@ var MagentoCartItemTypeEnum;
|
|
|
98
138
|
*/
|
|
99
139
|
function transformMagentoSimpleCartItem(cartItem) {
|
|
100
140
|
var _a;
|
|
101
|
-
return
|
|
141
|
+
return {
|
|
102
142
|
// base
|
|
103
143
|
type: DaffCartItemInputType.Simple,
|
|
104
144
|
item_id: cartItem.id,
|
|
@@ -125,7 +165,7 @@ function transformMagentoSimpleCartItem(cartItem) {
|
|
|
125
165
|
})) || [],
|
|
126
166
|
// TODO: implement
|
|
127
167
|
parent_item_id: null,
|
|
128
|
-
}
|
|
168
|
+
};
|
|
129
169
|
}
|
|
130
170
|
|
|
131
171
|
function transformBundleCartItemOption(option) {
|
|
@@ -142,7 +182,7 @@ function transformBundleCartItemOption(option) {
|
|
|
142
182
|
* @param response the response from a magento cart query.
|
|
143
183
|
*/
|
|
144
184
|
function transformMagentoBundleCartItem(bundleCartItem) {
|
|
145
|
-
return
|
|
185
|
+
return Object.assign(Object.assign({}, transformMagentoSimpleCartItem(bundleCartItem)), { type: DaffCartItemInputType.Composite, options: bundleCartItem.bundle_options.map(transformBundleCartItemOption) });
|
|
146
186
|
}
|
|
147
187
|
|
|
148
188
|
function transformConfigurableCartItemAttribute(option) {
|
|
@@ -157,24 +197,27 @@ function transformConfigurableCartItemAttribute(option) {
|
|
|
157
197
|
* @param response the response from a magento cart query.
|
|
158
198
|
*/
|
|
159
199
|
function transformMagentoConfigurableCartItem(configurableCartItem) {
|
|
160
|
-
return
|
|
200
|
+
return Object.assign(Object.assign({}, transformMagentoSimpleCartItem(configurableCartItem)), { type: DaffCartItemInputType.Configurable, attributes: configurableCartItem.configurable_options.map(transformConfigurableCartItemAttribute) });
|
|
161
201
|
}
|
|
162
202
|
|
|
163
203
|
/**
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
* @param cartItem a MagentoCartItem
|
|
204
|
+
* The standard transform for a magento cart item.
|
|
167
205
|
*/
|
|
168
|
-
|
|
206
|
+
const daffTransformMagentoCartItem = (cartItem) => {
|
|
169
207
|
switch (cartItem.__typename) {
|
|
170
208
|
case MagentoCartItemTypeEnum.Bundle:
|
|
171
209
|
return transformMagentoBundleCartItem(cartItem);
|
|
172
210
|
case MagentoCartItemTypeEnum.Configurable:
|
|
173
211
|
return transformMagentoConfigurableCartItem(cartItem);
|
|
212
|
+
case MagentoCartItemTypeEnum.Simple:
|
|
174
213
|
default:
|
|
175
214
|
return transformMagentoSimpleCartItem(cartItem);
|
|
176
215
|
}
|
|
177
|
-
}
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Transforms the MagentoCartItem into a DaffCartItem using the provided transforms.
|
|
219
|
+
*/
|
|
220
|
+
const transformMagentoCartItem = (daffCartItem, cartItem, transforms = []) => transforms.reduce((item, transform) => transform(item, cartItem), daffCartItem);
|
|
178
221
|
|
|
179
222
|
/**
|
|
180
223
|
* Transforms magento carts into an object usable by daffodil.
|
|
@@ -344,12 +387,13 @@ DaffMagentoShippingAddressTransformer.ctorParameters = () => [
|
|
|
344
387
|
* Transforms magento carts into an object usable by daffodil.
|
|
345
388
|
*/
|
|
346
389
|
class DaffMagentoCartTransformer {
|
|
347
|
-
constructor(shippingAddressTransformer, billingAddressTransformer, paymentTransformer, shippingInformationTransformer, shippingRateTransformer) {
|
|
390
|
+
constructor(shippingAddressTransformer, billingAddressTransformer, paymentTransformer, shippingInformationTransformer, shippingRateTransformer, cartItemTransforms) {
|
|
348
391
|
this.shippingAddressTransformer = shippingAddressTransformer;
|
|
349
392
|
this.billingAddressTransformer = billingAddressTransformer;
|
|
350
393
|
this.paymentTransformer = paymentTransformer;
|
|
351
394
|
this.shippingInformationTransformer = shippingInformationTransformer;
|
|
352
395
|
this.shippingRateTransformer = shippingRateTransformer;
|
|
396
|
+
this.cartItemTransforms = cartItemTransforms;
|
|
353
397
|
}
|
|
354
398
|
transformShippingAddress(cart) {
|
|
355
399
|
return {
|
|
@@ -367,7 +411,8 @@ class DaffMagentoCartTransformer {
|
|
|
367
411
|
}
|
|
368
412
|
transformCartItems(cart) {
|
|
369
413
|
return {
|
|
370
|
-
|
|
414
|
+
// TODO: extract into own transforms
|
|
415
|
+
items: cart.items.filter(item => !!item).map(item => transformMagentoCartItem(daffTransformMagentoCartItem(item), item, this.cartItemTransforms)),
|
|
371
416
|
};
|
|
372
417
|
}
|
|
373
418
|
transformTotals(cart) {
|
|
@@ -416,7 +461,7 @@ class DaffMagentoCartTransformer {
|
|
|
416
461
|
return cart ? Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ extra_attributes: cart }, this.transformCartItems(cart)), this.transformBillingAddress(cart)), this.transformShippingAddress(cart)), this.transformCoupons(cart)), this.transformPayment(cart)), this.transformTotals(cart)), transformCartTotals(cart)), this.transformShippingInformation(cart)), this.transformShippingMethods(cart)), this.transformPaymentMethods(cart)), { id: cart.id }) : null;
|
|
417
462
|
}
|
|
418
463
|
}
|
|
419
|
-
/** @nocollapse */ DaffMagentoCartTransformer.ɵprov = ɵɵdefineInjectable({ factory: function DaffMagentoCartTransformer_Factory() { return new DaffMagentoCartTransformer(ɵɵinject(DaffMagentoShippingAddressTransformer), ɵɵinject(DaffMagentoBillingAddressTransformer), ɵɵinject(DaffMagentoCartPaymentTransformer), ɵɵinject(DaffMagentoCartShippingInformationTransformer), ɵɵinject(DaffMagentoCartShippingRateTransformer)); }, token: DaffMagentoCartTransformer, providedIn: "root" });
|
|
464
|
+
/** @nocollapse */ DaffMagentoCartTransformer.ɵprov = ɵɵdefineInjectable({ factory: function DaffMagentoCartTransformer_Factory() { return new DaffMagentoCartTransformer(ɵɵinject(DaffMagentoShippingAddressTransformer), ɵɵinject(DaffMagentoBillingAddressTransformer), ɵɵinject(DaffMagentoCartPaymentTransformer), ɵɵinject(DaffMagentoCartShippingInformationTransformer), ɵɵinject(DaffMagentoCartShippingRateTransformer), ɵɵinject(DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS)); }, token: DaffMagentoCartTransformer, providedIn: "root" });
|
|
420
465
|
DaffMagentoCartTransformer.decorators = [
|
|
421
466
|
{ type: Injectable, args: [{
|
|
422
467
|
providedIn: 'root',
|
|
@@ -428,7 +473,8 @@ DaffMagentoCartTransformer.ctorParameters = () => [
|
|
|
428
473
|
{ type: DaffMagentoBillingAddressTransformer },
|
|
429
474
|
{ type: DaffMagentoCartPaymentTransformer },
|
|
430
475
|
{ type: DaffMagentoCartShippingInformationTransformer },
|
|
431
|
-
{ type: DaffMagentoCartShippingRateTransformer }
|
|
476
|
+
{ type: DaffMagentoCartShippingRateTransformer },
|
|
477
|
+
{ type: Array, decorators: [{ type: Inject, args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,] }] }
|
|
432
478
|
];
|
|
433
479
|
|
|
434
480
|
class DaffMagentoCartAddressInputTransformer {
|
|
@@ -549,20 +595,6 @@ DaffMagentoShippingMethodInputTransformer.decorators = [
|
|
|
549
595
|
},] }
|
|
550
596
|
];
|
|
551
597
|
|
|
552
|
-
/**
|
|
553
|
-
* An multi-provider injection token for providing extra GraphQL fragments that will be spread into cart queries.
|
|
554
|
-
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces.
|
|
555
|
-
* The data will appear in DaffCart#extra_attributes.
|
|
556
|
-
*
|
|
557
|
-
* Fragment structure is platform-specific and this feature should be used with care.
|
|
558
|
-
*
|
|
559
|
-
* This can increase query complexity above the Magento default of 300.
|
|
560
|
-
* Daffodil only guarantees that stock queries don't exceed the limit of 300.
|
|
561
|
-
* Apps using this token should therefore increase the query complexity limit
|
|
562
|
-
* to accommodate the extra complexity contributed by the provided fragments.
|
|
563
|
-
*/
|
|
564
|
-
const DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS = new InjectionToken('DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS', { factory: () => [] });
|
|
565
|
-
|
|
566
598
|
const moneyFragment = gql `
|
|
567
599
|
fragment money on Money {
|
|
568
600
|
value
|
|
@@ -1311,7 +1343,9 @@ const DaffCartMagentoErrorMap = {
|
|
|
1311
1343
|
};
|
|
1312
1344
|
const DaffCartMagentoErrorMessageRegexMap = {
|
|
1313
1345
|
[DaffCartDriverErrorCodes.INVALID_COUPON_CODE]: /The coupon code isn\'t valid/,
|
|
1314
|
-
[DaffCartDriverErrorCodes.PRODUCT_OUT_OF_STOCK]: /The requested qty is not available/,
|
|
1346
|
+
[DaffCartDriverErrorCodes.PRODUCT_OUT_OF_STOCK]: /(The requested qty is not available)|(This product is out of stock)|(Some of the products are out of stock)|(There are no source items with the in stock status)/,
|
|
1347
|
+
[DaffCartDriverErrorCodes.ITEM_EXCEEDS_MAX_QTY]: /The requested qty exceeds the maximum qty allowed in shopping cart/,
|
|
1348
|
+
[DaffCartDriverErrorCodes.INVALID_EMAIL]: /Invalid email format/,
|
|
1315
1349
|
};
|
|
1316
1350
|
|
|
1317
1351
|
function transformMagentoCartGraphQlError(error, requestPayload) {
|
|
@@ -1414,10 +1448,11 @@ function transformConfigurableCartItem(item) {
|
|
|
1414
1448
|
* @inheritdoc
|
|
1415
1449
|
*/
|
|
1416
1450
|
class DaffMagentoCartItemService {
|
|
1417
|
-
constructor(apollo, mutationQueue, extraCartFragments, cartTransformer, cartItemUpdateInputTransformer) {
|
|
1451
|
+
constructor(apollo, mutationQueue, extraCartFragments, cartItemTransforms, cartTransformer, cartItemUpdateInputTransformer) {
|
|
1418
1452
|
this.apollo = apollo;
|
|
1419
1453
|
this.mutationQueue = mutationQueue;
|
|
1420
1454
|
this.extraCartFragments = extraCartFragments;
|
|
1455
|
+
this.cartItemTransforms = cartItemTransforms;
|
|
1421
1456
|
this.cartTransformer = cartTransformer;
|
|
1422
1457
|
this.cartItemUpdateInputTransformer = cartItemUpdateInputTransformer;
|
|
1423
1458
|
}
|
|
@@ -1425,7 +1460,7 @@ class DaffMagentoCartItemService {
|
|
|
1425
1460
|
return this.apollo.query({
|
|
1426
1461
|
query: listCartItems(this.extraCartFragments),
|
|
1427
1462
|
variables: { cartId },
|
|
1428
|
-
}).pipe(map(result => result.data.cart.items.map(transformMagentoCartItem)));
|
|
1463
|
+
}).pipe(map(result => result.data.cart.items.filter(item => !!item)), map(items => items.map(item => transformMagentoCartItem(daffTransformMagentoCartItem(item), item, this.cartItemTransforms))));
|
|
1429
1464
|
}
|
|
1430
1465
|
get(cartId, itemId) {
|
|
1431
1466
|
return this.list(cartId).pipe(map(items => items.find(item => item.id === itemId)));
|
|
@@ -1477,7 +1512,7 @@ class DaffMagentoCartItemService {
|
|
|
1477
1512
|
}).pipe(map(result => this.cartTransformer.transform(result.data.addProductsToCart.cart)));
|
|
1478
1513
|
}
|
|
1479
1514
|
}
|
|
1480
|
-
/** @nocollapse */ DaffMagentoCartItemService.ɵprov = ɵɵdefineInjectable({ factory: function DaffMagentoCartItemService_Factory() { return new DaffMagentoCartItemService(ɵɵinject(Apollo), ɵɵinject(DAFF_MAGENTO_CART_MUTATION_QUEUE), ɵɵinject(DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS), ɵɵinject(DaffMagentoCartTransformer), ɵɵinject(DaffMagentoCartItemUpdateInputTransformer)); }, token: DaffMagentoCartItemService, providedIn: "root" });
|
|
1515
|
+
/** @nocollapse */ DaffMagentoCartItemService.ɵprov = ɵɵdefineInjectable({ factory: function DaffMagentoCartItemService_Factory() { return new DaffMagentoCartItemService(ɵɵinject(Apollo), ɵɵinject(DAFF_MAGENTO_CART_MUTATION_QUEUE), ɵɵinject(DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS), ɵɵinject(DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS), ɵɵinject(DaffMagentoCartTransformer), ɵɵinject(DaffMagentoCartItemUpdateInputTransformer)); }, token: DaffMagentoCartItemService, providedIn: "root" });
|
|
1481
1516
|
DaffMagentoCartItemService.decorators = [
|
|
1482
1517
|
{ type: Injectable, args: [{
|
|
1483
1518
|
providedIn: 'root',
|
|
@@ -1488,6 +1523,7 @@ DaffMagentoCartItemService.ctorParameters = () => [
|
|
|
1488
1523
|
{ type: Apollo },
|
|
1489
1524
|
{ type: DaffQueuedApollo, decorators: [{ type: Inject, args: [DAFF_MAGENTO_CART_MUTATION_QUEUE,] }] },
|
|
1490
1525
|
{ type: Array, decorators: [{ type: Inject, args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS,] }] },
|
|
1526
|
+
{ type: Array, decorators: [{ type: Inject, args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,] }] },
|
|
1491
1527
|
{ type: DaffMagentoCartTransformer },
|
|
1492
1528
|
{ type: DaffMagentoCartItemUpdateInputTransformer }
|
|
1493
1529
|
];
|
|
@@ -1880,9 +1916,13 @@ DaffMagentoCartAddressService.ctorParameters = () => [
|
|
|
1880
1916
|
* Transforms magento carts into an object usable by daffodil.
|
|
1881
1917
|
*/
|
|
1882
1918
|
class DaffMagentoCartCouponResponseTransformer {
|
|
1919
|
+
constructor(cartItemTransforms) {
|
|
1920
|
+
this.cartItemTransforms = cartItemTransforms;
|
|
1921
|
+
}
|
|
1883
1922
|
transformCartItems(cart) {
|
|
1884
1923
|
return {
|
|
1885
|
-
|
|
1924
|
+
// TODO: extract into own transforms
|
|
1925
|
+
items: cart.items.filter(item => !!item).map(item => transformMagentoCartItem(daffTransformMagentoCartItem(item), item, this.cartItemTransforms)),
|
|
1886
1926
|
};
|
|
1887
1927
|
}
|
|
1888
1928
|
transformTotals(cart) {
|
|
@@ -1907,12 +1947,16 @@ class DaffMagentoCartCouponResponseTransformer {
|
|
|
1907
1947
|
return cart ? Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, this.transformCartItems(cart)), this.transformCoupons(cart)), this.transformTotals(cart)), transformCartTotals(cart)), { id: cart.id }) : null;
|
|
1908
1948
|
}
|
|
1909
1949
|
}
|
|
1910
|
-
/** @nocollapse */ DaffMagentoCartCouponResponseTransformer.ɵprov = ɵɵdefineInjectable({ factory: function DaffMagentoCartCouponResponseTransformer_Factory() { return new DaffMagentoCartCouponResponseTransformer(); }, token: DaffMagentoCartCouponResponseTransformer, providedIn: "root" });
|
|
1950
|
+
/** @nocollapse */ DaffMagentoCartCouponResponseTransformer.ɵprov = ɵɵdefineInjectable({ factory: function DaffMagentoCartCouponResponseTransformer_Factory() { return new DaffMagentoCartCouponResponseTransformer(ɵɵinject(DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS)); }, token: DaffMagentoCartCouponResponseTransformer, providedIn: "root" });
|
|
1911
1951
|
DaffMagentoCartCouponResponseTransformer.decorators = [
|
|
1912
1952
|
{ type: Injectable, args: [{
|
|
1913
1953
|
providedIn: 'root',
|
|
1914
1954
|
},] }
|
|
1915
1955
|
];
|
|
1956
|
+
/** @nocollapse */
|
|
1957
|
+
DaffMagentoCartCouponResponseTransformer.ctorParameters = () => [
|
|
1958
|
+
{ type: Array, decorators: [{ type: Inject, args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,] }] }
|
|
1959
|
+
];
|
|
1916
1960
|
|
|
1917
1961
|
/**
|
|
1918
1962
|
* A service for making Magento GraphQL queries for carts.
|
|
@@ -2081,5 +2125,5 @@ DaffCartMagentoDriverModule.decorators = [
|
|
|
2081
2125
|
* Generated bundle index. Do not edit.
|
|
2082
2126
|
*/
|
|
2083
2127
|
|
|
2084
|
-
export { DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS, DaffCartMagentoDriverModule, DaffMagentoBillingAddressInputTransformer, DaffMagentoBillingAddressTransformer, DaffMagentoCartAddressInputTransformer, DaffMagentoCartAddressTransformer, DaffMagentoCartBillingAddressService, DaffMagentoCartItemService, DaffMagentoCartItemUpdateInputTransformer, DaffMagentoCartPaymentMethodsService, DaffMagentoCartPaymentService, DaffMagentoCartPaymentTransformer, DaffMagentoCartService, DaffMagentoCartShippingAddressService, DaffMagentoCartShippingInformationService, DaffMagentoCartShippingInformationTransformer, DaffMagentoCartShippingMethodsService, DaffMagentoCartShippingRateTransformer, DaffMagentoCartTransformer, DaffMagentoPaymentMethodInputTransformer, DaffMagentoShippingAddressInputTransformer, DaffMagentoShippingAddressTransformer, DaffMagentoShippingMethodInputTransformer, MagentoCartItemTypeEnum, addCartItem, applyCoupon, availablePaymentMethodFragment, availableShippingMethodFragment, cartAddressFragment, cartCouponFragment, cartFragment, cartItemFragment, createCart, getBillingAddress, getCart, getSelectedPaymentMethod, getSelectedShippingMethod, getShippingAddress, listCartCoupons, listCartItems, listPaymentMethods, listShippingMethods, moneyFragment, placeOrder, pricesFragment, removeAllCoupons, removeCartItem, selectedPaymentMethodFragment, selectedShippingMethodFragment, setSelectedPaymentMethod, setSelectedPaymentMethodWithBilling, setSelectedPaymentMethodWithBillingAndEmail, setSelectedShippingMethod, updateAddress, updateAddressWithEmail, updateBillingAddress, updateBillingAddressWithEmail, updateCartItem, updateShippingAddress, updateShippingAddressWithEmail, DAFF_MAGENTO_CART_MUTATION_QUEUE as ɵa, DaffMagentoCartAddressService as ɵb, DaffMagentoCartOrderService as ɵc, DaffMagentoCartCouponService as ɵd, DaffMagentoCartCouponResponseTransformer as ɵe };
|
|
2128
|
+
export { DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS, DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS, DaffCartMagentoDriverModule, DaffMagentoBillingAddressInputTransformer, DaffMagentoBillingAddressTransformer, DaffMagentoCartAddressInputTransformer, DaffMagentoCartAddressTransformer, DaffMagentoCartBillingAddressService, DaffMagentoCartItemService, DaffMagentoCartItemUpdateInputTransformer, DaffMagentoCartPaymentMethodsService, DaffMagentoCartPaymentService, DaffMagentoCartPaymentTransformer, DaffMagentoCartService, DaffMagentoCartShippingAddressService, DaffMagentoCartShippingInformationService, DaffMagentoCartShippingInformationTransformer, DaffMagentoCartShippingMethodsService, DaffMagentoCartShippingRateTransformer, DaffMagentoCartTransformer, DaffMagentoPaymentMethodInputTransformer, DaffMagentoShippingAddressInputTransformer, DaffMagentoShippingAddressTransformer, DaffMagentoShippingMethodInputTransformer, MagentoCartItemTypeEnum, addCartItem, applyCoupon, availablePaymentMethodFragment, availableShippingMethodFragment, cartAddressFragment, cartCouponFragment, cartFragment, cartItemFragment, createCart, daffProvideCartMagentoCartItemTransforms, getBillingAddress, getCart, getSelectedPaymentMethod, getSelectedShippingMethod, getShippingAddress, listCartCoupons, listCartItems, listPaymentMethods, listShippingMethods, moneyFragment, placeOrder, pricesFragment, removeAllCoupons, removeCartItem, selectedPaymentMethodFragment, selectedShippingMethodFragment, setSelectedPaymentMethod, setSelectedPaymentMethodWithBilling, setSelectedPaymentMethodWithBillingAndEmail, setSelectedShippingMethod, updateAddress, updateAddressWithEmail, updateBillingAddress, updateBillingAddressWithEmail, updateCartItem, updateShippingAddress, updateShippingAddressWithEmail, DAFF_MAGENTO_CART_MUTATION_QUEUE as ɵa, DaffMagentoCartAddressService as ɵb, DaffMagentoCartOrderService as ɵc, DaffMagentoCartCouponService as ɵd, DaffMagentoCartCouponResponseTransformer as ɵe };
|
|
2085
2129
|
//# sourceMappingURL=daffodil-cart-driver-magento.js.map
|