UNPKG

@shopgate/pwa-common-commerce

Version:

Commerce library for the Shopgate Connect PWA.

10 lines 1.07 kB
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import{MESSAGE_TYPE_ERROR}from"../constants";/** * Checks if the messages array of a pipeline response contains error messages. * @param {Array} [messages=[]] The messages. * @return {boolean} */export var messagesHaveErrors=function messagesHaveErrors(){var messages=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];return messages.some(function(_ref){var type=_ref.type;return type===MESSAGE_TYPE_ERROR;});};/** * Creates an error message list which can be processes by the error system. * @param {string} pipeline The related pipeline. * @param {Array} messages The messages. * @return {Array} */export var createErrorMessageList=function createErrorMessageList(pipeline,messages){return messages.map(function(message){return _extends({},message,{context:pipeline});});};