@medusajs/medusa 1.1.44-next.1 → 1.1.47
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/CHANGELOG.md +25 -0
- package/dist/api/routes/store/carts/update-cart.js +2 -2
- package/dist/api/routes/store/customers/reset-password.js +14 -24
- package/dist/loaders/search-index.js +1 -1
- package/dist/services/cart.js +72 -37
- package/dist/services/customer.js +3 -1
- package/dist/subscribers/product.js +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.1.47](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.46...@medusajs/medusa@1.1.47) (2021-10-23)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- pull missing fields ([b82b43b](https://github.com/medusajs/medusa/commit/b82b43b4c64dc5bc705a439a214f9d1dc9976e21))
|
|
11
|
+
|
|
12
|
+
## [1.1.46](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.45...@medusajs/medusa@1.1.46) (2021-10-19)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- add integration test ([38813ec](https://github.com/medusajs/medusa/commit/38813ec66f23526054f7e35adf4157ce98703167))
|
|
17
|
+
- allow changing regions safely ([06f5fe2](https://github.com/medusajs/medusa/commit/06f5fe267013d95231d96318fe8a055ad8040174))
|
|
18
|
+
- cleanup ([5441d47](https://github.com/medusajs/medusa/commit/5441d47f88d759742e3d3d29b29bc38feceac583))
|
|
19
|
+
- prettier ([5a67d1e](https://github.com/medusajs/medusa/commit/5a67d1e7fd3d9da9dca0781d0feab60db1f1099a))
|
|
20
|
+
|
|
21
|
+
## [1.1.45](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.44...@medusajs/medusa@1.1.45) (2021-10-18)
|
|
22
|
+
|
|
23
|
+
**Note:** Version bump only for package @medusajs/medusa
|
|
24
|
+
|
|
25
|
+
## [1.1.44](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.43...@medusajs/medusa@1.1.44) (2021-10-18)
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
- undefined references ([5afd0df](https://github.com/medusajs/medusa/commit/5afd0dfbabaebfb6b09f0e2f055386ac76059372))
|
|
30
|
+
|
|
6
31
|
## [1.1.43](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.41...@medusajs/medusa@1.1.43) (2021-10-18)
|
|
7
32
|
|
|
8
33
|
### Bug Fixes
|
|
@@ -93,8 +93,8 @@ var _default = /*#__PURE__*/function () {
|
|
|
93
93
|
region_id: _medusaCoreUtils.Validator.string().optional(),
|
|
94
94
|
country_code: _medusaCoreUtils.Validator.string().optional(),
|
|
95
95
|
email: _medusaCoreUtils.Validator.string().email().optional(),
|
|
96
|
-
billing_address: _medusaCoreUtils.Validator.address().optional(),
|
|
97
|
-
shipping_address: _medusaCoreUtils.Validator.address().optional(),
|
|
96
|
+
billing_address: _medusaCoreUtils.Validator.address().optional().allow(null),
|
|
97
|
+
shipping_address: _medusaCoreUtils.Validator.address().optional().allow(null),
|
|
98
98
|
gift_cards: _medusaCoreUtils.Validator.array().items({
|
|
99
99
|
code: _medusaCoreUtils.Validator.string()
|
|
100
100
|
}).optional(),
|
|
@@ -59,56 +59,46 @@ var _default = /*#__PURE__*/function () {
|
|
|
59
59
|
throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, error.details);
|
|
60
60
|
|
|
61
61
|
case 4:
|
|
62
|
-
_context.prev = 4;
|
|
63
62
|
customerService = req.scope.resolve("customerService");
|
|
64
|
-
_context.next =
|
|
65
|
-
return customerService.retrieveByEmail(value.email
|
|
63
|
+
_context.next = 7;
|
|
64
|
+
return customerService.retrieveByEmail(value.email, {
|
|
65
|
+
select: ["id", "password_hash"]
|
|
66
|
+
});
|
|
66
67
|
|
|
67
|
-
case
|
|
68
|
+
case 7:
|
|
68
69
|
customer = _context.sent;
|
|
69
|
-
|
|
70
|
-
return _jsonwebtoken["default"].verify(value.token, customer.password_hash);
|
|
71
|
-
|
|
72
|
-
case 11:
|
|
73
|
-
decodedToken = _context.sent;
|
|
70
|
+
decodedToken = _jsonwebtoken["default"].verify(value.token, customer.password_hash);
|
|
74
71
|
|
|
75
72
|
if (!(!decodedToken || customer.id !== decodedToken.customer_id)) {
|
|
76
|
-
_context.next =
|
|
73
|
+
_context.next = 12;
|
|
77
74
|
break;
|
|
78
75
|
}
|
|
79
76
|
|
|
80
77
|
res.status(401).send("Invalid or expired password reset token");
|
|
81
78
|
return _context.abrupt("return");
|
|
82
79
|
|
|
83
|
-
case
|
|
84
|
-
_context.next =
|
|
80
|
+
case 12:
|
|
81
|
+
_context.next = 14;
|
|
85
82
|
return customerService.update(customer.id, {
|
|
86
83
|
password: value.password
|
|
87
84
|
});
|
|
88
85
|
|
|
89
|
-
case
|
|
90
|
-
_context.next =
|
|
86
|
+
case 14:
|
|
87
|
+
_context.next = 16;
|
|
91
88
|
return customerService.retrieve(customer.id);
|
|
92
89
|
|
|
93
|
-
case
|
|
90
|
+
case 16:
|
|
94
91
|
customer = _context.sent;
|
|
95
92
|
res.status(200).json({
|
|
96
93
|
customer: customer
|
|
97
94
|
});
|
|
98
|
-
_context.next = 26;
|
|
99
|
-
break;
|
|
100
|
-
|
|
101
|
-
case 23:
|
|
102
|
-
_context.prev = 23;
|
|
103
|
-
_context.t0 = _context["catch"](4);
|
|
104
|
-
throw _context.t0;
|
|
105
95
|
|
|
106
|
-
case
|
|
96
|
+
case 18:
|
|
107
97
|
case "end":
|
|
108
98
|
return _context.stop();
|
|
109
99
|
}
|
|
110
100
|
}
|
|
111
|
-
}, _callee
|
|
101
|
+
}, _callee);
|
|
112
102
|
}));
|
|
113
103
|
|
|
114
104
|
return function (_x, _x2) {
|
|
@@ -44,7 +44,7 @@ function _loadProductsIntoSearchEngine() {
|
|
|
44
44
|
gt: lastSeenId
|
|
45
45
|
}
|
|
46
46
|
}, {
|
|
47
|
-
select: ["id", "title", "subtitle", "description", "handle", "is_giftcard", "discountable", "thumbnail", "profile_id", "collection_id", "type_id", "origin_country", "created_at", "updated_at"],
|
|
47
|
+
select: ["id", "title", "status", "subtitle", "description", "handle", "is_giftcard", "discountable", "thumbnail", "profile_id", "collection_id", "type_id", "origin_country", "created_at", "updated_at"],
|
|
48
48
|
relations: ["variants", "tags", "type", "collection", "variants.prices", "variants.options", "options"],
|
|
49
49
|
take: TAKE,
|
|
50
50
|
order: {
|
package/dist/services/cart.js
CHANGED
|
@@ -1580,7 +1580,7 @@ var CartService = /*#__PURE__*/function (_BaseService) {
|
|
|
1580
1580
|
key: "updateBillingAddress_",
|
|
1581
1581
|
value: function () {
|
|
1582
1582
|
var _updateBillingAddress_ = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee18(cart, addressOrId, addrRepo) {
|
|
1583
|
-
var addr, created;
|
|
1583
|
+
var updated, addr, created;
|
|
1584
1584
|
return _regenerator["default"].wrap(function _callee18$(_context18) {
|
|
1585
1585
|
while (1) {
|
|
1586
1586
|
switch (_context18.prev = _context18.next) {
|
|
@@ -1604,42 +1604,46 @@ var CartService = /*#__PURE__*/function (_BaseService) {
|
|
|
1604
1604
|
addressOrId.country_code = addressOrId.country_code.toLowerCase();
|
|
1605
1605
|
|
|
1606
1606
|
if (!addressOrId.id) {
|
|
1607
|
-
_context18.next =
|
|
1607
|
+
_context18.next = 12;
|
|
1608
1608
|
break;
|
|
1609
1609
|
}
|
|
1610
1610
|
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1611
|
+
_context18.next = 8;
|
|
1612
|
+
return addrRepo.save(addressOrId);
|
|
1613
|
+
|
|
1614
|
+
case 8:
|
|
1615
|
+
updated = _context18.sent;
|
|
1616
|
+
cart.billing_address = updated;
|
|
1617
|
+
_context18.next = 22;
|
|
1614
1618
|
break;
|
|
1615
1619
|
|
|
1616
|
-
case
|
|
1620
|
+
case 12:
|
|
1617
1621
|
if (!cart.billing_address_id) {
|
|
1618
|
-
_context18.next =
|
|
1622
|
+
_context18.next = 20;
|
|
1619
1623
|
break;
|
|
1620
1624
|
}
|
|
1621
1625
|
|
|
1622
|
-
_context18.next =
|
|
1626
|
+
_context18.next = 15;
|
|
1623
1627
|
return addrRepo.findOne({
|
|
1624
1628
|
where: {
|
|
1625
1629
|
id: cart.billing_address_id
|
|
1626
1630
|
}
|
|
1627
1631
|
});
|
|
1628
1632
|
|
|
1629
|
-
case
|
|
1633
|
+
case 15:
|
|
1630
1634
|
addr = _context18.sent;
|
|
1631
|
-
_context18.next =
|
|
1635
|
+
_context18.next = 18;
|
|
1632
1636
|
return addrRepo.save(_objectSpread(_objectSpread({}, addr), addressOrId));
|
|
1633
1637
|
|
|
1634
|
-
case
|
|
1635
|
-
_context18.next =
|
|
1638
|
+
case 18:
|
|
1639
|
+
_context18.next = 22;
|
|
1636
1640
|
break;
|
|
1637
1641
|
|
|
1638
|
-
case
|
|
1642
|
+
case 20:
|
|
1639
1643
|
created = addrRepo.create(_objectSpread({}, addressOrId));
|
|
1640
1644
|
cart.billing_address = created;
|
|
1641
1645
|
|
|
1642
|
-
case
|
|
1646
|
+
case 22:
|
|
1643
1647
|
case "end":
|
|
1644
1648
|
return _context18.stop();
|
|
1645
1649
|
}
|
|
@@ -1664,77 +1668,92 @@ var CartService = /*#__PURE__*/function (_BaseService) {
|
|
|
1664
1668
|
key: "updateShippingAddress_",
|
|
1665
1669
|
value: function () {
|
|
1666
1670
|
var _updateShippingAddress_ = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee19(cart, addressOrId, addrRepo) {
|
|
1667
|
-
var
|
|
1671
|
+
var _addressOrId$country_, _addressOrId$country_2;
|
|
1672
|
+
|
|
1673
|
+
var updated, addr, created;
|
|
1668
1674
|
return _regenerator["default"].wrap(function _callee19$(_context19) {
|
|
1669
1675
|
while (1) {
|
|
1670
1676
|
switch (_context19.prev = _context19.next) {
|
|
1671
1677
|
case 0:
|
|
1678
|
+
if (!(addressOrId === null)) {
|
|
1679
|
+
_context19.next = 3;
|
|
1680
|
+
break;
|
|
1681
|
+
}
|
|
1682
|
+
|
|
1683
|
+
cart.shipping_address = null;
|
|
1684
|
+
return _context19.abrupt("return");
|
|
1685
|
+
|
|
1686
|
+
case 3:
|
|
1672
1687
|
if (!(typeof addressOrId === "string")) {
|
|
1673
|
-
_context19.next =
|
|
1688
|
+
_context19.next = 7;
|
|
1674
1689
|
break;
|
|
1675
1690
|
}
|
|
1676
1691
|
|
|
1677
|
-
_context19.next =
|
|
1692
|
+
_context19.next = 6;
|
|
1678
1693
|
return addrRepo.findOne({
|
|
1679
1694
|
where: {
|
|
1680
1695
|
id: addressOrId
|
|
1681
1696
|
}
|
|
1682
1697
|
});
|
|
1683
1698
|
|
|
1684
|
-
case
|
|
1699
|
+
case 6:
|
|
1685
1700
|
addressOrId = _context19.sent;
|
|
1686
1701
|
|
|
1687
|
-
case
|
|
1688
|
-
addressOrId.country_code = addressOrId.country_code.toLowerCase();
|
|
1702
|
+
case 7:
|
|
1703
|
+
addressOrId.country_code = (_addressOrId$country_ = (_addressOrId$country_2 = addressOrId.country_code) === null || _addressOrId$country_2 === void 0 ? void 0 : _addressOrId$country_2.toLowerCase()) !== null && _addressOrId$country_ !== void 0 ? _addressOrId$country_ : null;
|
|
1689
1704
|
|
|
1690
|
-
if (cart.region.countries.find(function (_ref13) {
|
|
1705
|
+
if (!(addressOrId.country_code && !cart.region.countries.find(function (_ref13) {
|
|
1691
1706
|
var iso_2 = _ref13.iso_2;
|
|
1692
1707
|
return addressOrId.country_code === iso_2;
|
|
1693
|
-
})) {
|
|
1694
|
-
_context19.next =
|
|
1708
|
+
}))) {
|
|
1709
|
+
_context19.next = 10;
|
|
1695
1710
|
break;
|
|
1696
1711
|
}
|
|
1697
1712
|
|
|
1698
1713
|
throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, "Shipping country must be in the cart region");
|
|
1699
1714
|
|
|
1700
|
-
case
|
|
1715
|
+
case 10:
|
|
1701
1716
|
if (!addressOrId.id) {
|
|
1702
|
-
_context19.next =
|
|
1717
|
+
_context19.next = 17;
|
|
1703
1718
|
break;
|
|
1704
1719
|
}
|
|
1705
1720
|
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1721
|
+
_context19.next = 13;
|
|
1722
|
+
return addrRepo.save(addressOrId);
|
|
1723
|
+
|
|
1724
|
+
case 13:
|
|
1725
|
+
updated = _context19.sent;
|
|
1726
|
+
cart.shipping_address = updated;
|
|
1727
|
+
_context19.next = 27;
|
|
1709
1728
|
break;
|
|
1710
1729
|
|
|
1711
|
-
case
|
|
1730
|
+
case 17:
|
|
1712
1731
|
if (!cart.shipping_address_id) {
|
|
1713
|
-
_context19.next =
|
|
1732
|
+
_context19.next = 25;
|
|
1714
1733
|
break;
|
|
1715
1734
|
}
|
|
1716
1735
|
|
|
1717
|
-
_context19.next =
|
|
1736
|
+
_context19.next = 20;
|
|
1718
1737
|
return addrRepo.findOne({
|
|
1719
1738
|
where: {
|
|
1720
1739
|
id: cart.shipping_address_id
|
|
1721
1740
|
}
|
|
1722
1741
|
});
|
|
1723
1742
|
|
|
1724
|
-
case
|
|
1743
|
+
case 20:
|
|
1725
1744
|
addr = _context19.sent;
|
|
1726
|
-
_context19.next =
|
|
1745
|
+
_context19.next = 23;
|
|
1727
1746
|
return addrRepo.save(_objectSpread(_objectSpread({}, addr), addressOrId));
|
|
1728
1747
|
|
|
1729
|
-
case
|
|
1730
|
-
_context19.next =
|
|
1748
|
+
case 23:
|
|
1749
|
+
_context19.next = 27;
|
|
1731
1750
|
break;
|
|
1732
1751
|
|
|
1733
|
-
case
|
|
1752
|
+
case 25:
|
|
1734
1753
|
created = addrRepo.create(_objectSpread({}, addressOrId));
|
|
1735
1754
|
cart.shipping_address = created;
|
|
1736
1755
|
|
|
1737
|
-
case
|
|
1756
|
+
case 27:
|
|
1738
1757
|
case "end":
|
|
1739
1758
|
return _context19.stop();
|
|
1740
1759
|
}
|
|
@@ -3087,6 +3106,14 @@ var CartService = /*#__PURE__*/function (_BaseService) {
|
|
|
3087
3106
|
cart.items = _context40.sent;
|
|
3088
3107
|
|
|
3089
3108
|
case 12:
|
|
3109
|
+
/*
|
|
3110
|
+
* When changing the region you are changing the set of countries that your
|
|
3111
|
+
* cart can be shipped to so we need to make sure that the current shipping
|
|
3112
|
+
* address adheres to the new country set.
|
|
3113
|
+
*
|
|
3114
|
+
* First check if there is an existing shipping address on the cart if so
|
|
3115
|
+
* fetch the entire thing so we can modify the shipping country
|
|
3116
|
+
*/
|
|
3090
3117
|
shippingAddress = {};
|
|
3091
3118
|
|
|
3092
3119
|
if (!cart.shipping_address_id) {
|
|
@@ -3132,6 +3159,14 @@ var CartService = /*#__PURE__*/function (_BaseService) {
|
|
|
3132
3159
|
break;
|
|
3133
3160
|
|
|
3134
3161
|
case 25:
|
|
3162
|
+
/*
|
|
3163
|
+
* In the case where the country code is not specified we need to check
|
|
3164
|
+
*
|
|
3165
|
+
* 1. if the region we are switching to has only one country preselect
|
|
3166
|
+
* that
|
|
3167
|
+
* 2. if the region has multiple countries we need to unset the country
|
|
3168
|
+
* and wait for client to decide which country to use
|
|
3169
|
+
*/
|
|
3135
3170
|
_updated = _objectSpread({}, shippingAddress); // If the country code of a shipping address is set we need to clear it
|
|
3136
3171
|
|
|
3137
3172
|
if (!_lodash["default"].isEmpty(shippingAddress) && shippingAddress.country_code) {
|
|
@@ -152,7 +152,9 @@ var CustomerService = /*#__PURE__*/function (_BaseService) {
|
|
|
152
152
|
switch (_context.prev = _context.next) {
|
|
153
153
|
case 0:
|
|
154
154
|
_context.next = 2;
|
|
155
|
-
return this.retrieve(customerId
|
|
155
|
+
return this.retrieve(customerId, {
|
|
156
|
+
select: ["id", "has_account", "password_hash", "email", "first_name", "last_name"]
|
|
157
|
+
});
|
|
156
158
|
|
|
157
159
|
case 2:
|
|
158
160
|
customer = _context.sent;
|
|
@@ -21,7 +21,7 @@ var _product = _interopRequireDefault(require("../services/product"));
|
|
|
21
21
|
|
|
22
22
|
var _medusaCoreUtils = require("medusa-core-utils");
|
|
23
23
|
|
|
24
|
-
var searchFields = ["id", "title", "subtitle", "description", "handle", "is_giftcard", "discountable", "thumbnail", "profile_id", "collection_id", "type_id", "origin_country", "created_at", "updated_at"];
|
|
24
|
+
var searchFields = ["id", "title", "subtitle", "status", "description", "handle", "is_giftcard", "discountable", "thumbnail", "profile_id", "collection_id", "type_id", "origin_country", "created_at", "updated_at"];
|
|
25
25
|
var searchRelations = ["variants", "tags", "type", "collection", "variants.prices", "variants.options", "options"];
|
|
26
26
|
|
|
27
27
|
var ProductSearchSubscriber = function ProductSearchSubscriber(_ref) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/medusa",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.47",
|
|
4
4
|
"description": "E-commerce for JAMstack",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"@babel/cli": "^7.14.3",
|
|
21
21
|
"@babel/core": "^7.14.3",
|
|
22
22
|
"@babel/preset-typescript": "^7.13.0",
|
|
23
|
-
"babel-preset-medusa-package": "^1.1.
|
|
23
|
+
"babel-preset-medusa-package": "^1.1.17",
|
|
24
24
|
"cross-env": "^5.2.1",
|
|
25
25
|
"eslint": "^6.8.0",
|
|
26
26
|
"jest": "^25.5.2",
|
|
27
|
-
"medusa-interfaces": "^1.1.
|
|
27
|
+
"medusa-interfaces": "^1.1.27",
|
|
28
28
|
"nodemon": "^2.0.1",
|
|
29
29
|
"prettier": "^1.19.1",
|
|
30
30
|
"sqlite3": "^5.0.2",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@hapi/joi": "^16.1.8",
|
|
48
|
-
"@medusajs/medusa-cli": "^1.1.
|
|
48
|
+
"@medusajs/medusa-cli": "^1.1.22",
|
|
49
49
|
"@types/lodash": "^4.14.168",
|
|
50
50
|
"awilix": "^4.2.3",
|
|
51
51
|
"body-parser": "^1.19.0",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"joi": "^17.3.0",
|
|
68
68
|
"joi-objectid": "^3.0.1",
|
|
69
69
|
"jsonwebtoken": "^8.5.1",
|
|
70
|
-
"medusa-core-utils": "^1.1.
|
|
71
|
-
"medusa-test-utils": "^1.1.
|
|
70
|
+
"medusa-core-utils": "^1.1.26",
|
|
71
|
+
"medusa-test-utils": "^1.1.29",
|
|
72
72
|
"morgan": "^1.9.1",
|
|
73
73
|
"multer": "^1.4.2",
|
|
74
74
|
"passport": "^0.4.0",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"uuid": "^8.3.1",
|
|
88
88
|
"winston": "^3.2.1"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "81847456f1b2229d58f0e4e46a7fc079277e4b2b"
|
|
91
91
|
}
|