@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
|
@@ -4,6 +4,50 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.daffodil = global.daffodil || {}, global.daffodil.cart = global.daffodil.cart || {}, global.daffodil.cart.driver = global.daffodil.cart.driver || {}, global.daffodil.cart.driver.magento = {}), global.ng.core, global.daffodil.cart, global.magento, global.core, global.i1, global.graphql, global.rxjs, global.rxjs.operators, global.daffodil.cart.driver, global.magento$1, global.driver, global.ng.common));
|
|
5
5
|
}(this, (function (exports, i0, cart, magento, core, i1, graphql, rxjs, operators, i4, magento$1, driver, common) { 'use strict';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* An multi-provider injection token for providing extra GraphQL fragments that will be spread into cart queries.
|
|
9
|
+
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces.
|
|
10
|
+
* The data will appear in DaffCart#extra_attributes.
|
|
11
|
+
*
|
|
12
|
+
* Fragment structure is platform-specific and this feature should be used with care.
|
|
13
|
+
*
|
|
14
|
+
* This can increase query complexity above the Magento default of 300.
|
|
15
|
+
* Daffodil only guarantees that stock queries don't exceed the limit of 300.
|
|
16
|
+
* Apps using this token should therefore increase the query complexity limit
|
|
17
|
+
* to accommodate the extra complexity contributed by the provided fragments.
|
|
18
|
+
*/
|
|
19
|
+
var DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS = new i0.InjectionToken('DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS', { factory: function () { return []; } });
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A multi-provider injection token for providing cart item transform logic in the Magento driver.
|
|
23
|
+
* It is run after the standard transforms and passed both the current transformed Daffodil cart item and the Magento cart item.
|
|
24
|
+
*/
|
|
25
|
+
var DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS = new i0.InjectionToken('DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS', { factory: function () { return []; } });
|
|
26
|
+
/**
|
|
27
|
+
* Provides cart item transforms for the Magento cart driver.
|
|
28
|
+
*
|
|
29
|
+
* See {@link DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS}.
|
|
30
|
+
*
|
|
31
|
+
* ```ts
|
|
32
|
+
* providers: [
|
|
33
|
+
* ...daffProvideCartMagentoCartItemTransforms(
|
|
34
|
+
* myCartItemTransform
|
|
35
|
+
* )
|
|
36
|
+
* ]
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
function daffProvideCartMagentoCartItemTransforms() {
|
|
40
|
+
var transforms = [];
|
|
41
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
42
|
+
transforms[_i] = arguments[_i];
|
|
43
|
+
}
|
|
44
|
+
return transforms.map(function (transform) { return ({
|
|
45
|
+
provide: DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,
|
|
46
|
+
useValue: transform,
|
|
47
|
+
multi: true,
|
|
48
|
+
}); });
|
|
49
|
+
}
|
|
50
|
+
|
|
7
51
|
/**
|
|
8
52
|
* Transforms magento addresses into an object usable by daffodil.
|
|
9
53
|
*/
|
|
@@ -94,7 +138,7 @@
|
|
|
94
138
|
*/
|
|
95
139
|
function transformMagentoSimpleCartItem(cartItem) {
|
|
96
140
|
var _a;
|
|
97
|
-
return
|
|
141
|
+
return {
|
|
98
142
|
// base
|
|
99
143
|
type: cart.DaffCartItemInputType.Simple,
|
|
100
144
|
item_id: cartItem.id,
|
|
@@ -121,7 +165,7 @@
|
|
|
121
165
|
})) || [],
|
|
122
166
|
// TODO: implement
|
|
123
167
|
parent_item_id: null,
|
|
124
|
-
}
|
|
168
|
+
};
|
|
125
169
|
}
|
|
126
170
|
|
|
127
171
|
function transformBundleCartItemOption(option) {
|
|
@@ -138,7 +182,7 @@
|
|
|
138
182
|
* @param response the response from a magento cart query.
|
|
139
183
|
*/
|
|
140
184
|
function transformMagentoBundleCartItem(bundleCartItem) {
|
|
141
|
-
return
|
|
185
|
+
return Object.assign(Object.assign({}, transformMagentoSimpleCartItem(bundleCartItem)), { type: cart.DaffCartItemInputType.Composite, options: bundleCartItem.bundle_options.map(transformBundleCartItemOption) });
|
|
142
186
|
}
|
|
143
187
|
|
|
144
188
|
function transformConfigurableCartItemAttribute(option) {
|
|
@@ -153,24 +197,30 @@
|
|
|
153
197
|
* @param response the response from a magento cart query.
|
|
154
198
|
*/
|
|
155
199
|
function transformMagentoConfigurableCartItem(configurableCartItem) {
|
|
156
|
-
return
|
|
200
|
+
return Object.assign(Object.assign({}, transformMagentoSimpleCartItem(configurableCartItem)), { type: cart.DaffCartItemInputType.Configurable, attributes: configurableCartItem.configurable_options.map(transformConfigurableCartItemAttribute) });
|
|
157
201
|
}
|
|
158
202
|
|
|
159
203
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* @param cartItem a MagentoCartItem
|
|
204
|
+
* The standard transform for a magento cart item.
|
|
163
205
|
*/
|
|
164
|
-
function
|
|
206
|
+
var daffTransformMagentoCartItem = function (cartItem) {
|
|
165
207
|
switch (cartItem.__typename) {
|
|
166
208
|
case exports.MagentoCartItemTypeEnum.Bundle:
|
|
167
209
|
return transformMagentoBundleCartItem(cartItem);
|
|
168
210
|
case exports.MagentoCartItemTypeEnum.Configurable:
|
|
169
211
|
return transformMagentoConfigurableCartItem(cartItem);
|
|
212
|
+
case exports.MagentoCartItemTypeEnum.Simple:
|
|
170
213
|
default:
|
|
171
214
|
return transformMagentoSimpleCartItem(cartItem);
|
|
172
215
|
}
|
|
173
|
-
}
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* Transforms the MagentoCartItem into a DaffCartItem using the provided transforms.
|
|
219
|
+
*/
|
|
220
|
+
var transformMagentoCartItem = function (daffCartItem, cartItem, transforms) {
|
|
221
|
+
if (transforms === void 0) { transforms = []; }
|
|
222
|
+
return transforms.reduce(function (item, transform) { return transform(item, cartItem); }, daffCartItem);
|
|
223
|
+
};
|
|
174
224
|
|
|
175
225
|
/**
|
|
176
226
|
* Transforms magento carts into an object usable by daffodil.
|
|
@@ -667,12 +717,13 @@
|
|
|
667
717
|
* Transforms magento carts into an object usable by daffodil.
|
|
668
718
|
*/
|
|
669
719
|
var DaffMagentoCartTransformer = /** @class */ (function () {
|
|
670
|
-
function DaffMagentoCartTransformer(shippingAddressTransformer, billingAddressTransformer, paymentTransformer, shippingInformationTransformer, shippingRateTransformer) {
|
|
720
|
+
function DaffMagentoCartTransformer(shippingAddressTransformer, billingAddressTransformer, paymentTransformer, shippingInformationTransformer, shippingRateTransformer, cartItemTransforms) {
|
|
671
721
|
this.shippingAddressTransformer = shippingAddressTransformer;
|
|
672
722
|
this.billingAddressTransformer = billingAddressTransformer;
|
|
673
723
|
this.paymentTransformer = paymentTransformer;
|
|
674
724
|
this.shippingInformationTransformer = shippingInformationTransformer;
|
|
675
725
|
this.shippingRateTransformer = shippingRateTransformer;
|
|
726
|
+
this.cartItemTransforms = cartItemTransforms;
|
|
676
727
|
}
|
|
677
728
|
DaffMagentoCartTransformer.prototype.transformShippingAddress = function (cart) {
|
|
678
729
|
return {
|
|
@@ -689,8 +740,10 @@
|
|
|
689
740
|
};
|
|
690
741
|
};
|
|
691
742
|
DaffMagentoCartTransformer.prototype.transformCartItems = function (cart) {
|
|
743
|
+
var _this = this;
|
|
692
744
|
return {
|
|
693
|
-
|
|
745
|
+
// TODO: extract into own transforms
|
|
746
|
+
items: cart.items.filter(function (item) { return !!item; }).map(function (item) { return transformMagentoCartItem(daffTransformMagentoCartItem(item), item, _this.cartItemTransforms); }),
|
|
694
747
|
};
|
|
695
748
|
};
|
|
696
749
|
DaffMagentoCartTransformer.prototype.transformTotals = function (cart) {
|
|
@@ -742,7 +795,7 @@
|
|
|
742
795
|
};
|
|
743
796
|
return DaffMagentoCartTransformer;
|
|
744
797
|
}());
|
|
745
|
-
/** @nocollapse */ DaffMagentoCartTransformer.ɵprov = i0.ɵɵdefineInjectable({ factory: function DaffMagentoCartTransformer_Factory() { return new DaffMagentoCartTransformer(i0.ɵɵinject(DaffMagentoShippingAddressTransformer), i0.ɵɵinject(DaffMagentoBillingAddressTransformer), i0.ɵɵinject(DaffMagentoCartPaymentTransformer), i0.ɵɵinject(DaffMagentoCartShippingInformationTransformer), i0.ɵɵinject(DaffMagentoCartShippingRateTransformer)); }, token: DaffMagentoCartTransformer, providedIn: "root" });
|
|
798
|
+
/** @nocollapse */ DaffMagentoCartTransformer.ɵprov = i0.ɵɵdefineInjectable({ factory: function DaffMagentoCartTransformer_Factory() { return new DaffMagentoCartTransformer(i0.ɵɵinject(DaffMagentoShippingAddressTransformer), i0.ɵɵinject(DaffMagentoBillingAddressTransformer), i0.ɵɵinject(DaffMagentoCartPaymentTransformer), i0.ɵɵinject(DaffMagentoCartShippingInformationTransformer), i0.ɵɵinject(DaffMagentoCartShippingRateTransformer), i0.ɵɵinject(DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS)); }, token: DaffMagentoCartTransformer, providedIn: "root" });
|
|
746
799
|
DaffMagentoCartTransformer.decorators = [
|
|
747
800
|
{ type: i0.Injectable, args: [{
|
|
748
801
|
providedIn: 'root',
|
|
@@ -754,7 +807,8 @@
|
|
|
754
807
|
{ type: DaffMagentoBillingAddressTransformer },
|
|
755
808
|
{ type: DaffMagentoCartPaymentTransformer },
|
|
756
809
|
{ type: DaffMagentoCartShippingInformationTransformer },
|
|
757
|
-
{ type: DaffMagentoCartShippingRateTransformer }
|
|
810
|
+
{ type: DaffMagentoCartShippingRateTransformer },
|
|
811
|
+
{ type: Array, decorators: [{ type: i0.Inject, args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,] }] }
|
|
758
812
|
]; };
|
|
759
813
|
|
|
760
814
|
var DaffMagentoCartAddressInputTransformer = /** @class */ (function () {
|
|
@@ -889,20 +943,6 @@
|
|
|
889
943
|
},] }
|
|
890
944
|
];
|
|
891
945
|
|
|
892
|
-
/**
|
|
893
|
-
* An multi-provider injection token for providing extra GraphQL fragments that will be spread into cart queries.
|
|
894
|
-
* This can be used to retrieve additional data that is not covered by the standard Daffodil interfaces.
|
|
895
|
-
* The data will appear in DaffCart#extra_attributes.
|
|
896
|
-
*
|
|
897
|
-
* Fragment structure is platform-specific and this feature should be used with care.
|
|
898
|
-
*
|
|
899
|
-
* This can increase query complexity above the Magento default of 300.
|
|
900
|
-
* Daffodil only guarantees that stock queries don't exceed the limit of 300.
|
|
901
|
-
* Apps using this token should therefore increase the query complexity limit
|
|
902
|
-
* to accommodate the extra complexity contributed by the provided fragments.
|
|
903
|
-
*/
|
|
904
|
-
var DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS = new i0.InjectionToken('DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS', { factory: function () { return []; } });
|
|
905
|
-
|
|
906
946
|
var moneyFragment = i1.gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n fragment money on Money {\n value\n currency\n }\n"], ["\n fragment money on Money {\n value\n currency\n }\n"])));
|
|
907
947
|
var templateObject_1;
|
|
908
948
|
|
|
@@ -1114,7 +1154,9 @@
|
|
|
1114
1154
|
_a);
|
|
1115
1155
|
var DaffCartMagentoErrorMessageRegexMap = (_b = {},
|
|
1116
1156
|
_b[i4.DaffCartDriverErrorCodes.INVALID_COUPON_CODE] = /The coupon code isn\'t valid/,
|
|
1117
|
-
_b[i4.DaffCartDriverErrorCodes.PRODUCT_OUT_OF_STOCK] = /The requested qty is not available/,
|
|
1157
|
+
_b[i4.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)/,
|
|
1158
|
+
_b[i4.DaffCartDriverErrorCodes.ITEM_EXCEEDS_MAX_QTY] = /The requested qty exceeds the maximum qty allowed in shopping cart/,
|
|
1159
|
+
_b[i4.DaffCartDriverErrorCodes.INVALID_EMAIL] = /Invalid email format/,
|
|
1118
1160
|
_b);
|
|
1119
1161
|
|
|
1120
1162
|
function transformMagentoCartGraphQlError(error, requestPayload) {
|
|
@@ -1220,18 +1262,20 @@
|
|
|
1220
1262
|
* @inheritdoc
|
|
1221
1263
|
*/
|
|
1222
1264
|
var DaffMagentoCartItemService = /** @class */ (function () {
|
|
1223
|
-
function DaffMagentoCartItemService(apollo, mutationQueue, extraCartFragments, cartTransformer, cartItemUpdateInputTransformer) {
|
|
1265
|
+
function DaffMagentoCartItemService(apollo, mutationQueue, extraCartFragments, cartItemTransforms, cartTransformer, cartItemUpdateInputTransformer) {
|
|
1224
1266
|
this.apollo = apollo;
|
|
1225
1267
|
this.mutationQueue = mutationQueue;
|
|
1226
1268
|
this.extraCartFragments = extraCartFragments;
|
|
1269
|
+
this.cartItemTransforms = cartItemTransforms;
|
|
1227
1270
|
this.cartTransformer = cartTransformer;
|
|
1228
1271
|
this.cartItemUpdateInputTransformer = cartItemUpdateInputTransformer;
|
|
1229
1272
|
}
|
|
1230
1273
|
DaffMagentoCartItemService.prototype.list = function (cartId) {
|
|
1274
|
+
var _this = this;
|
|
1231
1275
|
return this.apollo.query({
|
|
1232
1276
|
query: listCartItems(this.extraCartFragments),
|
|
1233
1277
|
variables: { cartId: cartId },
|
|
1234
|
-
}).pipe(operators.map(function (result) { return result.data.cart.items.map(transformMagentoCartItem); }));
|
|
1278
|
+
}).pipe(operators.map(function (result) { return result.data.cart.items.filter(function (item) { return !!item; }); }), operators.map(function (items) { return items.map(function (item) { return transformMagentoCartItem(daffTransformMagentoCartItem(item), item, _this.cartItemTransforms); }); }));
|
|
1235
1279
|
};
|
|
1236
1280
|
DaffMagentoCartItemService.prototype.get = function (cartId, itemId) {
|
|
1237
1281
|
return this.list(cartId).pipe(operators.map(function (items) { return items.find(function (item) { return item.id === itemId; }); }));
|
|
@@ -1287,7 +1331,7 @@
|
|
|
1287
1331
|
};
|
|
1288
1332
|
return DaffMagentoCartItemService;
|
|
1289
1333
|
}());
|
|
1290
|
-
/** @nocollapse */ DaffMagentoCartItemService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DaffMagentoCartItemService_Factory() { return new DaffMagentoCartItemService(i0.ɵɵinject(i1.Apollo), i0.ɵɵinject(DAFF_MAGENTO_CART_MUTATION_QUEUE), i0.ɵɵinject(DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS), i0.ɵɵinject(DaffMagentoCartTransformer), i0.ɵɵinject(DaffMagentoCartItemUpdateInputTransformer)); }, token: DaffMagentoCartItemService, providedIn: "root" });
|
|
1334
|
+
/** @nocollapse */ DaffMagentoCartItemService.ɵprov = i0.ɵɵdefineInjectable({ factory: function DaffMagentoCartItemService_Factory() { return new DaffMagentoCartItemService(i0.ɵɵinject(i1.Apollo), i0.ɵɵinject(DAFF_MAGENTO_CART_MUTATION_QUEUE), i0.ɵɵinject(DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS), i0.ɵɵinject(DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS), i0.ɵɵinject(DaffMagentoCartTransformer), i0.ɵɵinject(DaffMagentoCartItemUpdateInputTransformer)); }, token: DaffMagentoCartItemService, providedIn: "root" });
|
|
1291
1335
|
DaffMagentoCartItemService.decorators = [
|
|
1292
1336
|
{ type: i0.Injectable, args: [{
|
|
1293
1337
|
providedIn: 'root',
|
|
@@ -1298,6 +1342,7 @@
|
|
|
1298
1342
|
{ type: i1.Apollo },
|
|
1299
1343
|
{ type: graphql.DaffQueuedApollo, decorators: [{ type: i0.Inject, args: [DAFF_MAGENTO_CART_MUTATION_QUEUE,] }] },
|
|
1300
1344
|
{ type: Array, decorators: [{ type: i0.Inject, args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS,] }] },
|
|
1345
|
+
{ type: Array, decorators: [{ type: i0.Inject, args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,] }] },
|
|
1301
1346
|
{ type: DaffMagentoCartTransformer },
|
|
1302
1347
|
{ type: DaffMagentoCartItemUpdateInputTransformer }
|
|
1303
1348
|
]; };
|
|
@@ -1715,11 +1760,14 @@
|
|
|
1715
1760
|
* Transforms magento carts into an object usable by daffodil.
|
|
1716
1761
|
*/
|
|
1717
1762
|
var DaffMagentoCartCouponResponseTransformer = /** @class */ (function () {
|
|
1718
|
-
function DaffMagentoCartCouponResponseTransformer() {
|
|
1763
|
+
function DaffMagentoCartCouponResponseTransformer(cartItemTransforms) {
|
|
1764
|
+
this.cartItemTransforms = cartItemTransforms;
|
|
1719
1765
|
}
|
|
1720
1766
|
DaffMagentoCartCouponResponseTransformer.prototype.transformCartItems = function (cart) {
|
|
1767
|
+
var _this = this;
|
|
1721
1768
|
return {
|
|
1722
|
-
|
|
1769
|
+
// TODO: extract into own transforms
|
|
1770
|
+
items: cart.items.filter(function (item) { return !!item; }).map(function (item) { return transformMagentoCartItem(daffTransformMagentoCartItem(item), item, _this.cartItemTransforms); }),
|
|
1723
1771
|
};
|
|
1724
1772
|
};
|
|
1725
1773
|
DaffMagentoCartCouponResponseTransformer.prototype.transformTotals = function (cart) {
|
|
@@ -1745,12 +1793,16 @@
|
|
|
1745
1793
|
};
|
|
1746
1794
|
return DaffMagentoCartCouponResponseTransformer;
|
|
1747
1795
|
}());
|
|
1748
|
-
/** @nocollapse */ DaffMagentoCartCouponResponseTransformer.ɵprov = i0.ɵɵdefineInjectable({ factory: function DaffMagentoCartCouponResponseTransformer_Factory() { return new DaffMagentoCartCouponResponseTransformer(); }, token: DaffMagentoCartCouponResponseTransformer, providedIn: "root" });
|
|
1796
|
+
/** @nocollapse */ DaffMagentoCartCouponResponseTransformer.ɵprov = i0.ɵɵdefineInjectable({ factory: function DaffMagentoCartCouponResponseTransformer_Factory() { return new DaffMagentoCartCouponResponseTransformer(i0.ɵɵinject(DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS)); }, token: DaffMagentoCartCouponResponseTransformer, providedIn: "root" });
|
|
1749
1797
|
DaffMagentoCartCouponResponseTransformer.decorators = [
|
|
1750
1798
|
{ type: i0.Injectable, args: [{
|
|
1751
1799
|
providedIn: 'root',
|
|
1752
1800
|
},] }
|
|
1753
1801
|
];
|
|
1802
|
+
/** @nocollapse */
|
|
1803
|
+
DaffMagentoCartCouponResponseTransformer.ctorParameters = function () { return [
|
|
1804
|
+
{ type: Array, decorators: [{ type: i0.Inject, args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS,] }] }
|
|
1805
|
+
]; };
|
|
1754
1806
|
|
|
1755
1807
|
/**
|
|
1756
1808
|
* A service for making Magento GraphQL queries for carts.
|
|
@@ -1926,6 +1978,7 @@
|
|
|
1926
1978
|
* Generated bundle index. Do not edit.
|
|
1927
1979
|
*/
|
|
1928
1980
|
|
|
1981
|
+
exports.DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS = DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS;
|
|
1929
1982
|
exports.DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS = DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS;
|
|
1930
1983
|
exports.DaffCartMagentoDriverModule = DaffCartMagentoDriverModule;
|
|
1931
1984
|
exports.DaffMagentoBillingAddressInputTransformer = DaffMagentoBillingAddressInputTransformer;
|
|
@@ -1958,6 +2011,7 @@
|
|
|
1958
2011
|
exports.cartFragment = cartFragment;
|
|
1959
2012
|
exports.cartItemFragment = cartItemFragment;
|
|
1960
2013
|
exports.createCart = createCart;
|
|
2014
|
+
exports.daffProvideCartMagentoCartItemTransforms = daffProvideCartMagentoCartItemTransforms;
|
|
1961
2015
|
exports.getBillingAddress = getBillingAddress;
|
|
1962
2016
|
exports.getCart = getCart;
|
|
1963
2017
|
exports.getSelectedPaymentMethod = getSelectedPaymentMethod;
|