@daffodil/cart 0.58.6 → 0.58.7
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/driver/magento/cart-coupon.service.d.ts +2 -2
- package/driver/magento/queries/responses/apply-coupon.d.ts +1 -7
- package/driver/magento/queries/responses/remove-all-coupons.d.ts +1 -7
- package/esm2020/driver/magento/cart-coupon.service.mjs +5 -5
- package/esm2020/driver/magento/queries/apply-coupon.mjs +4 -15
- package/esm2020/driver/magento/queries/remove-all-coupons.mjs +5 -16
- package/esm2020/driver/magento/queries/responses/apply-coupon.mjs +1 -1
- package/esm2020/driver/magento/queries/responses/remove-all-coupons.mjs +1 -1
- package/fesm2015/daffodil-cart-driver-magento.mjs +55 -93
- package/fesm2015/daffodil-cart-driver-magento.mjs.map +1 -1
- package/fesm2020/daffodil-cart-driver-magento.mjs +59 -97
- package/fesm2020/daffodil-cart-driver-magento.mjs.map +1 -1
- package/package.json +5 -5
- package/driver/magento/queries/fragments/cart-totals.d.ts +0 -1
- package/esm2020/driver/magento/queries/fragments/cart-totals.mjs +0 -24
|
@@ -1340,26 +1340,6 @@ const placeOrder = gql `
|
|
|
1340
1340
|
}
|
|
1341
1341
|
`;
|
|
1342
1342
|
|
|
1343
|
-
const cartTotalsFragment = gql `
|
|
1344
|
-
fragment cartTotals on Cart {
|
|
1345
|
-
id
|
|
1346
|
-
shipping_addresses {
|
|
1347
|
-
...cartAddress
|
|
1348
|
-
... on ShippingCartAddress {
|
|
1349
|
-
selected_shipping_method {
|
|
1350
|
-
...selectedShippingMethod
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
prices {
|
|
1355
|
-
...prices
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
${cartAddressFragment}
|
|
1359
|
-
${selectedShippingMethodFragment}
|
|
1360
|
-
${pricesFragment}
|
|
1361
|
-
`;
|
|
1362
|
-
|
|
1363
1343
|
const applyCoupon = (extraCartFragments = []) => gql `
|
|
1364
1344
|
mutation MagentoApplyCoupon($cartId: String!, $couponCode: String!) {
|
|
1365
1345
|
applyCouponToCart(
|
|
@@ -1369,21 +1349,12 @@ const applyCoupon = (extraCartFragments = []) => gql `
|
|
|
1369
1349
|
}
|
|
1370
1350
|
) {
|
|
1371
1351
|
cart {
|
|
1372
|
-
|
|
1373
|
-
items {
|
|
1374
|
-
...cartItem
|
|
1375
|
-
}
|
|
1376
|
-
applied_coupons {
|
|
1377
|
-
...cartCoupon
|
|
1378
|
-
}
|
|
1379
|
-
...cartTotals
|
|
1352
|
+
...cart
|
|
1380
1353
|
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1381
1354
|
}
|
|
1382
1355
|
}
|
|
1383
1356
|
}
|
|
1384
|
-
${
|
|
1385
|
-
${cartCouponFragment}
|
|
1386
|
-
${cartTotalsFragment}
|
|
1357
|
+
${cartFragment}
|
|
1387
1358
|
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1388
1359
|
`;
|
|
1389
1360
|
|
|
@@ -1408,21 +1379,12 @@ const removeAllCoupons = (extraCartFragments = []) => gql `
|
|
|
1408
1379
|
}
|
|
1409
1380
|
) {
|
|
1410
1381
|
cart {
|
|
1411
|
-
|
|
1412
|
-
items {
|
|
1413
|
-
...cartItem
|
|
1414
|
-
}
|
|
1415
|
-
applied_coupons {
|
|
1416
|
-
...cartCoupon
|
|
1417
|
-
}
|
|
1418
|
-
...cartTotals
|
|
1382
|
+
...cart
|
|
1419
1383
|
${daffBuildFragmentNameSpread(...extraCartFragments)}
|
|
1420
1384
|
}
|
|
1421
1385
|
}
|
|
1422
1386
|
}
|
|
1423
|
-
${
|
|
1424
|
-
${cartCouponFragment}
|
|
1425
|
-
${cartTotalsFragment}
|
|
1387
|
+
${cartFragment}
|
|
1426
1388
|
${daffBuildFragmentDefinition(...extraCartFragments)}
|
|
1427
1389
|
`;
|
|
1428
1390
|
|
|
@@ -2117,59 +2079,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
2117
2079
|
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
2118
2080
|
}] }, { type: DaffMagentoCartTransformer }, { type: DaffMagentoCartShippingRateTransformer }, { type: DaffMagentoShippingMethodInputTransformer }]; } });
|
|
2119
2081
|
|
|
2120
|
-
/**
|
|
2121
|
-
* Transforms magento carts into an object usable by daffodil.
|
|
2122
|
-
*/
|
|
2123
|
-
class DaffMagentoCartCouponResponseTransformer {
|
|
2124
|
-
constructor(cartItemTransforms) {
|
|
2125
|
-
this.cartItemTransforms = cartItemTransforms;
|
|
2126
|
-
}
|
|
2127
|
-
transformCartItems(cart) {
|
|
2128
|
-
return {
|
|
2129
|
-
// TODO: extract into own transforms
|
|
2130
|
-
items: cart.items.filter(item => !!item).map(item => transformMagentoCartItem(daffTransformMagentoCartItem(item), item, this.cartItemTransforms)),
|
|
2131
|
-
};
|
|
2132
|
-
}
|
|
2133
|
-
transformTotals(cart) {
|
|
2134
|
-
return {
|
|
2135
|
-
grand_total: cart.prices.grand_total.value,
|
|
2136
|
-
subtotal: cart.prices.subtotal_excluding_tax.value,
|
|
2137
|
-
};
|
|
2138
|
-
}
|
|
2139
|
-
transformCoupons(cart) {
|
|
2140
|
-
return {
|
|
2141
|
-
coupons: cart.applied_coupons
|
|
2142
|
-
? cart.applied_coupons.map(daffMagentoCouponTransform)
|
|
2143
|
-
: [],
|
|
2144
|
-
};
|
|
2145
|
-
}
|
|
2146
|
-
/**
|
|
2147
|
-
* Transforms the MagentoCart from the cart coupon operations into a DaffCart partial.
|
|
2148
|
-
*
|
|
2149
|
-
* @param cart the cart from a magento cart query.
|
|
2150
|
-
*/
|
|
2151
|
-
transform(cart) {
|
|
2152
|
-
return cart ? {
|
|
2153
|
-
...this.transformCartItems(cart),
|
|
2154
|
-
...this.transformCoupons(cart),
|
|
2155
|
-
...this.transformTotals(cart),
|
|
2156
|
-
...transformCartTotals(cart),
|
|
2157
|
-
id: cart.id,
|
|
2158
|
-
} : null;
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
/** @nocollapse */ DaffMagentoCartCouponResponseTransformer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, deps: [{ token: DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2162
|
-
/** @nocollapse */ DaffMagentoCartCouponResponseTransformer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, providedIn: 'root' });
|
|
2163
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, decorators: [{
|
|
2164
|
-
type: Injectable,
|
|
2165
|
-
args: [{
|
|
2166
|
-
providedIn: 'root',
|
|
2167
|
-
}]
|
|
2168
|
-
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2169
|
-
type: Inject,
|
|
2170
|
-
args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS]
|
|
2171
|
-
}] }]; } });
|
|
2172
|
-
|
|
2173
2082
|
/**
|
|
2174
2083
|
* A service for making Magento GraphQL queries for carts.
|
|
2175
2084
|
*
|
|
@@ -2213,7 +2122,7 @@ class DaffMagentoCartCouponService {
|
|
|
2213
2122
|
}).pipe(map(result => this.cartTransformer.transform(result.data.removeCouponFromCart.cart)), catchError(err => throwError(() => transformCartMagentoError(err))));
|
|
2214
2123
|
}
|
|
2215
2124
|
}
|
|
2216
|
-
/** @nocollapse */ DaffMagentoCartCouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponService, deps: [{ token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token:
|
|
2125
|
+
/** @nocollapse */ DaffMagentoCartCouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponService, deps: [{ token: DAFF_MAGENTO_CART_MUTATION_QUEUE }, { token: DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS }, { token: DaffMagentoCartTransformer }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2217
2126
|
/** @nocollapse */ DaffMagentoCartCouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponService, providedIn: 'root' });
|
|
2218
2127
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponService, decorators: [{
|
|
2219
2128
|
type: Injectable,
|
|
@@ -2226,7 +2135,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
2226
2135
|
}] }, { type: undefined, decorators: [{
|
|
2227
2136
|
type: Inject,
|
|
2228
2137
|
args: [DAFF_CART_MAGENTO_EXTRA_CART_FRAGMENTS]
|
|
2229
|
-
}] }, { type:
|
|
2138
|
+
}] }, { type: DaffMagentoCartTransformer }]; } });
|
|
2230
2139
|
|
|
2231
2140
|
/**
|
|
2232
2141
|
* A service for making Magento GraphQL queries for carts.
|
|
@@ -2263,6 +2172,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImpor
|
|
|
2263
2172
|
args: [DAFF_MAGENTO_CART_MUTATION_QUEUE]
|
|
2264
2173
|
}] }]; } });
|
|
2265
2174
|
|
|
2175
|
+
/**
|
|
2176
|
+
* Transforms magento carts into an object usable by daffodil.
|
|
2177
|
+
*/
|
|
2178
|
+
class DaffMagentoCartCouponResponseTransformer {
|
|
2179
|
+
constructor(cartItemTransforms) {
|
|
2180
|
+
this.cartItemTransforms = cartItemTransforms;
|
|
2181
|
+
}
|
|
2182
|
+
transformCartItems(cart) {
|
|
2183
|
+
return {
|
|
2184
|
+
// TODO: extract into own transforms
|
|
2185
|
+
items: cart.items.filter(item => !!item).map(item => transformMagentoCartItem(daffTransformMagentoCartItem(item), item, this.cartItemTransforms)),
|
|
2186
|
+
};
|
|
2187
|
+
}
|
|
2188
|
+
transformTotals(cart) {
|
|
2189
|
+
return {
|
|
2190
|
+
grand_total: cart.prices.grand_total.value,
|
|
2191
|
+
subtotal: cart.prices.subtotal_excluding_tax.value,
|
|
2192
|
+
};
|
|
2193
|
+
}
|
|
2194
|
+
transformCoupons(cart) {
|
|
2195
|
+
return {
|
|
2196
|
+
coupons: cart.applied_coupons
|
|
2197
|
+
? cart.applied_coupons.map(daffMagentoCouponTransform)
|
|
2198
|
+
: [],
|
|
2199
|
+
};
|
|
2200
|
+
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Transforms the MagentoCart from the cart coupon operations into a DaffCart partial.
|
|
2203
|
+
*
|
|
2204
|
+
* @param cart the cart from a magento cart query.
|
|
2205
|
+
*/
|
|
2206
|
+
transform(cart) {
|
|
2207
|
+
return cart ? {
|
|
2208
|
+
...this.transformCartItems(cart),
|
|
2209
|
+
...this.transformCoupons(cart),
|
|
2210
|
+
...this.transformTotals(cart),
|
|
2211
|
+
...transformCartTotals(cart),
|
|
2212
|
+
id: cart.id,
|
|
2213
|
+
} : null;
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
/** @nocollapse */ DaffMagentoCartCouponResponseTransformer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, deps: [{ token: DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2217
|
+
/** @nocollapse */ DaffMagentoCartCouponResponseTransformer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, providedIn: 'root' });
|
|
2218
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.0", ngImport: i0, type: DaffMagentoCartCouponResponseTransformer, decorators: [{
|
|
2219
|
+
type: Injectable,
|
|
2220
|
+
args: [{
|
|
2221
|
+
providedIn: 'root',
|
|
2222
|
+
}]
|
|
2223
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
2224
|
+
type: Inject,
|
|
2225
|
+
args: [DAFF_CART_MAGENTO_CART_ITEM_TRANSFORMS]
|
|
2226
|
+
}] }]; } });
|
|
2227
|
+
|
|
2266
2228
|
class DaffCartMagentoDriverModule {
|
|
2267
2229
|
static forRoot() {
|
|
2268
2230
|
return {
|