This commit is contained in:
olivermrbl
2020-08-28 11:36:39 +02:00
25 changed files with 136 additions and 94 deletions
+1 -1
View File
@@ -4,5 +4,5 @@
"packages/*"
],
"registry": "https://registry.npmjs.org/",
"version": "1.0.0-alpha.26"
"version": "1.0.0-alpha.29"
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-core-utils",
"version": "1.0.0-alpha.24",
"version": "1.0.0-alpha.27",
"description": "Core utils for Medusa",
"main": "dist/index.js",
"repository": {
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-file-spaces",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "Digital Ocean Spaces file connector for Medusa",
"main": "index.js",
"repository": {
@@ -40,8 +40,8 @@
"aws-sdk": "^2.710.0",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27",
"stripe": "^8.50.0"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
@@ -1,6 +1,6 @@
{
"name": "medusa-fulfillment-manual",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "A manual fulfillment provider for Medusa",
"main": "index.js",
"repository": {
@@ -35,7 +35,7 @@
"@babel/plugin-transform-instanceof": "^7.8.3",
"@babel/runtime": "^7.7.6",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24"
"medusa-core-utils": "^1.0.0-alpha.27"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-interfaces",
"version": "1.0.0-alpha.24",
"version": "1.0.0-alpha.27",
"description": "Core interfaces for Medusa",
"main": "dist/index.js",
"repository": {
@@ -34,7 +34,7 @@
"mongoose": "5.x"
},
"dependencies": {
"medusa-core-utils": "^1.0.0-alpha.24"
"medusa-core-utils": "^1.0.0-alpha.27"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-payment-adyen",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "Adyen Payment provider for Medusa Commerce",
"main": "index.js",
"repository": {
@@ -42,7 +42,7 @@
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24"
"medusa-core-utils": "^1.0.0-alpha.27"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-payment-klarna",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "Klarna Payment provider for Medusa Commerce",
"main": "index.js",
"repository": {
@@ -39,8 +39,8 @@
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24"
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-payment-stripe",
"version": "1.0.0-alpha.25",
"version": "1.0.0-alpha.27",
"description": "Stripe Payment provider for Meduas Commerce",
"main": "index.js",
"repository": {
@@ -39,8 +39,8 @@
"@babel/plugin-transform-classes": "^7.9.5",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27",
"stripe": "^8.50.0"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
@@ -18,38 +18,39 @@ var inventorySync = /*#__PURE__*/function () {
case 0:
brightpearlService = container.resolve("brightpearlService");
eventBus = container.resolve("eventBusService");
_context.prev = 2;
_context.next = 5;
console.log("hi inventory");
_context.prev = 3;
_context.next = 6;
return brightpearlService.getClient();
case 5:
case 6:
client = _context.sent;
pattern = "43 4,10,14,20 * * *"; // nice for tests "*/10 * * * * *"
eventBus.createCronJob("inventory-sync", {}, pattern, brightpearlService.syncInventory());
_context.next = 15;
_context.next = 16;
break;
case 10:
_context.prev = 10;
_context.t0 = _context["catch"](2);
case 11:
_context.prev = 11;
_context.t0 = _context["catch"](3);
if (!(_context.t0.name === "not_allowed")) {
_context.next = 14;
_context.next = 15;
break;
}
return _context.abrupt("return");
case 14:
case 15:
throw _context.t0;
case 15:
case 16:
case "end":
return _context.stop();
}
}
}, _callee, null, [[2, 10]]);
}, _callee, null, [[3, 11]]);
}));
return function inventorySync(_x) {
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-brightpearl",
"version": "1.0.0-alpha.25",
"version": "1.0.0-alpha.29",
"description": "Brightpearl plugin for Medusa Commerce",
"main": "index.js",
"repository": {
@@ -25,7 +25,7 @@
"cross-env": "^5.2.1",
"eslint": "^6.8.0",
"jest": "^25.5.2",
"medusa-test-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.27",
"prettier": "^2.0.5"
},
"scripts": {
@@ -41,7 +41,7 @@
"axios": "^0.19.2",
"axios-rate-limit": "^1.2.1",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"randomatic": "^3.1.1"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
@@ -125,27 +125,51 @@ class BrightpearlService extends BaseService {
async syncInventory() {
const client = await this.getClient()
const variants = await this.productVariantService_.list()
return Promise.all(
variants.map(async (v) => {
const brightpearlProduct = await this.retrieveProductBySKU(v.sku)
if (!brightpearlProduct) {
return
}
const { productId } = brightpearlProduct
const availability = await client.products.retrieveAvailability(
productId
)
const onHand = availability[productId].total.onHand
let search = true
let bpProducts = []
while (search) {
const { products, metadata } = await client.products.search(search)
bpProducts = [...bpProducts, ...products]
if (metadata.morePagesAvailable) {
search = `firstResult=${metadata.lastResult + 1}`
} else {
search = false
}
}
// Only update if the inventory levels have changed
if (parseInt(v.inventory_quantity) !== parseInt(onHand)) {
return this.productVariantService_.update(v._id, {
inventory_quantity: onHand,
})
}
})
)
if (bpProducts.length) {
const productRange = `${bpProducts[0].productId}-${
bpProducts[bpProducts.length - 1].productId
}`
const availabilities = await client.products.retrieveAvailability(
productRange
)
return Promise.all(
variants.map(async (v) => {
const brightpearlProduct = bpProducts.find(
(prod) => prod.SKU === v.sku
)
if (!brightpearlProduct) {
return
}
const { productId } = brightpearlProduct
const availability = availabilities[productId]
if (availability) {
const onHand = availability.total.onHand
// Only update if the inventory levels have changed
if (parseInt(v.inventory_quantity) !== parseInt(onHand)) {
return this.productVariantService_.update(v._id, {
inventory_quantity: onHand,
})
}
}
})
)
}
}
async updateInventory(productId) {
@@ -393,6 +417,7 @@ class BrightpearlService extends BaseService {
externalRef: fromOrder._id,
channelId: this.options.channel_id || `1`,
installedIntegrationInstanceId: authData.installation_instance_id,
statusId: this.options.default_status_id || `3`,
customer: {
id: customer.contactId,
address: {
@@ -289,6 +289,18 @@ class BrightpearlClient {
})
.then(({ data }) => data.response && data.response[0])
},
search: (search) => {
return this.client_
.request({
url: `/product-service/product-search?${search}`,
})
.then(({ data }) => {
return {
products: this.buildSearchResults_(data.response),
metadata: data.response.metaData,
}
})
},
retrieveBySKU: (sku) => {
return this.client_
.request({
@@ -254,11 +254,22 @@ var BrightpearlClient = /*#__PURE__*/function () {
return data.response && data.response[0];
});
},
search: function search(_search) {
return _this.client_.request({
url: "/product-service/product-search?".concat(_search)
}).then(function (_ref15) {
var data = _ref15.data;
return {
products: _this.buildSearchResults_(data.response),
metadata: data.response.metaData
};
});
},
retrieveBySKU: function retrieveBySKU(sku) {
return _this.client_.request({
url: "/product-service/product-search?SKU=".concat(sku)
}).then(function (_ref15) {
var data = _ref15.data;
}).then(function (_ref16) {
var data = _ref16.data;
return _this.buildSearchResults_(data.response);
});
}
@@ -270,8 +281,8 @@ var BrightpearlClient = /*#__PURE__*/function () {
retrieveByEmail: function retrieveByEmail(email) {
return _this.client_.request({
url: "/contact-service/contact-search?primaryEmail=".concat(email)
}).then(function (_ref16) {
var data = _ref16.data;
}).then(function (_ref17) {
var data = _ref17.data;
return _this.buildSearchResults_(data.response);
});
},
@@ -280,8 +291,8 @@ var BrightpearlClient = /*#__PURE__*/function () {
url: "/contact-service/contact",
method: "POST",
data: customerData
}).then(function (_ref17) {
var data = _ref17.data;
}).then(function (_ref18) {
var data = _ref18.data;
return data.response;
});
}
@@ -337,7 +348,7 @@ var BrightpearlClient = /*#__PURE__*/function () {
return request;
});
this.client_.interceptors.response.use(undefined, /*#__PURE__*/function () {
var _ref18 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(error) {
var _ref19 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(error) {
var response;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
@@ -388,7 +399,7 @@ var BrightpearlClient = /*#__PURE__*/function () {
}));
return function (_x) {
return _ref18.apply(this, arguments);
return _ref19.apply(this, arguments);
};
}());
}
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-contentful",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "Contentful plugin for Medusa Commerce",
"main": "index.js",
"repository": {
@@ -39,8 +39,8 @@
"body-parser": "^1.19.0",
"contentful-management": "^5.27.1",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27",
"redis": "^3.0.2"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-economic",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-economic",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "E-conomic financial reporting",
"main": "index.js",
"repository": {
@@ -39,8 +39,8 @@
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27",
"moment": "^2.27.0"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-permissions",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "Role permission for Medusa core",
"main": "dist/index.js",
"repository": {
@@ -32,8 +32,8 @@
"medusa-interfaces": "1.x"
},
"dependencies": {
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27",
"mongoose": "^5.8.0"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-segment",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "Segment Analytics",
"main": "index.js",
"repository": {
@@ -39,8 +39,8 @@
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24"
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
}
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-sendgrid",
"version": "1.0.0-alpha.25",
"version": "1.0.0-alpha.27",
"description": "SendGrid transactional emails",
"main": "index.js",
"repository": {
@@ -39,8 +39,8 @@
"@sendgrid/mail": "^7.1.1",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24"
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-economic",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-slack-notification",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "Slack notifications",
"main": "index.js",
"repository": {
@@ -39,8 +39,8 @@
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27",
"moment": "^2.27.0"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
+3 -3
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-plugin-wishlist",
"version": "1.0.0-alpha.26",
"version": "1.0.0-alpha.27",
"description": "Provides /customers/:id/wishlist to add items to a customr's wishlist",
"main": "index.js",
"repository": {
@@ -37,8 +37,8 @@
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24"
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "medusa-test-utils",
"version": "1.0.0-alpha.24",
"version": "1.0.0-alpha.27",
"description": "Test utils for Medusa",
"main": "dist/index.js",
"repository": {
@@ -28,7 +28,7 @@
},
"dependencies": {
"@babel/plugin-transform-classes": "^7.9.5",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"mongoose": "^5.8.0"
},
"gitHead": "3cc7cbe5124cbcbb75f6e1435db4dcfaa2a60408"
+4 -4
View File
@@ -1,6 +1,6 @@
{
"name": "@medusajs/medusa",
"version": "1.0.0-alpha.24",
"version": "1.0.0-alpha.27",
"description": "E-commerce for JAMstack",
"main": "dist/app.js",
"repository": {
@@ -61,8 +61,8 @@
"glob": "^7.1.6",
"joi-objectid": "^3.0.1",
"jsonwebtoken": "^8.5.1",
"medusa-core-utils": "^1.0.0-alpha.24",
"medusa-test-utils": "^1.0.0-alpha.24",
"medusa-core-utils": "^1.0.0-alpha.27",
"medusa-test-utils": "^1.0.0-alpha.27",
"morgan": "^1.9.1",
"multer": "^1.4.2",
"passport": "^0.4.0",
@@ -75,4 +75,4 @@
"winston": "^3.2.1"
},
"gitHead": "27d4e07c5251e43ba6be2d5fa35f1d5287b11043"
}
}
-7
View File
@@ -651,13 +651,6 @@ class OrderService extends BaseService {
})
.filter(i => !!i)
if (order.fulfillment_status !== "not_fulfilled") {
throw new MedusaError(
MedusaError.Types.INVALID_ARGUMENT,
"Order is already fulfilled"
)
}
const { shipping_methods } = order
// prepare update object