From 33e53abd6dac8d7353603dd78b58b88bc0619eec Mon Sep 17 00:00:00 2001 From: lukasz_brainhub Date: Mon, 18 Sep 2017 16:12:19 +0200 Subject: [PATCH] Updated version rollup config and build --- lib/reduxBreeze.js | 153 +++++++++++++++++++++++----------------- lib/reduxBreeze.js.map | 2 +- lib/reduxBreeze.mjs | 153 +++++++++++++++++++++++----------------- lib/reduxBreeze.mjs.map | 2 +- package.json | 2 +- rollup.config.js | 1 + 6 files changed, 180 insertions(+), 133 deletions(-) diff --git a/lib/reduxBreeze.js b/lib/reduxBreeze.js index 894ebe2..10f184d 100644 --- a/lib/reduxBreeze.js +++ b/lib/reduxBreeze.js @@ -223,7 +223,7 @@ babelHelpers; /** * Helper for redux to attach reducers to one field instead of composing them into separate fields - * @param {array} reducers + * @param {array} rawReducers array of unchained, not combined reducers * @return {function} reducer */ var chainReducers = function chainReducers(rawReducers) { @@ -278,7 +278,7 @@ var checkConflicts = function checkConflicts(plugins, adapterType) { * @param {array} plugins array of plugins objects * @param {boolean} strict with strict turned on we throw an error on plugin conflicts * @param {function} mapActionTypes function that changes names of action types - * @returns {{actionAdapter, reducerAdapter, initialStateAdapter}} merged plugin object + * @return {{actionAdapter, reducerAdapter, initialStateAdapter}} merged plugin object */ var mergePlugins = function mergePlugins(plugins) { var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, @@ -343,7 +343,7 @@ var mergePlugins = function mergePlugins(plugins) { * @param {string} actionName camelCase name of the action (e.g. someAction) * @param {string} suffix string that is going to be added at the end of the created action type * @param {string} prefix string that is going to be added at the beginning of the created action type - * @returns {string} upperSnakeCase action type (e.g. SOME_ACTION or with example suffix SOME_ACTION_SUFFIX) + * @return {string} upperSnakeCase action type (e.g. SOME_ACTION or with example suffix SOME_ACTION_SUFFIX) */ var createActionType = function createActionType(actionName) { var suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; @@ -356,10 +356,10 @@ var createActionType = function createActionType(actionName) { /** * Works like lodash _.set() but does not mutate object (doesn't work with array style keys like `someArray[2].anotherField`) * @param {object} object source object - * @param {string|{[string]: any}} path in object to set value in or object with paths as keys and values as values (if path is an object it ignores 'value') + * @param {string|object} path in object to set value in or object with paths as keys and values as values (if path is an object it ignores 'value') * @param {any} value to set in given path * @param {string} delimiter path delimiter; by default: '.' - * @returns {object} new object with value(s) changed + * @return {object} new object with value(s) changed */ var immutableSet = function immutableSet(object, path) { var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; @@ -392,13 +392,23 @@ var immutableSet = function immutableSet(object, path) { return _extends({}, object, defineProperty({}, pathSplit[0], immutableSet(childObject, _.tail(pathSplit).join(delimiter), value, delimiter))); }; +/** + * Copy value from fromPath in fromObject and create new object from toObject with that value saved in toPath + * @param {object} fromObject object which you get the value from + * @param {string} fromPath path in fromObject where you get tha value from + * @param {object} toObject object where you save the value to + * @param {string} toPath path in toObject where you save the value + * @return {object} new object created from values in toObject + */ +var immutablyCopyValue = function immutablyCopyValue(fromObject, fromPath, toObject, toPath) { + return immutableSet(toObject, toPath, _.get(fromObject, fromPath)); +}; + var hasNotBeenDefined = function hasNotBeenDefined() { classCallCheck(this, hasNotBeenDefined); }; - - -var createDefaultPlugin = function createDefaultPlugin(_ref) { +var createDefaultPlugin = function createDefaultPlugin(_ref, config) { var createActionType = _ref.createActionType, immutableSet = _ref.immutableSet; return { @@ -406,7 +416,7 @@ var createDefaultPlugin = function createDefaultPlugin(_ref) { * Object of functions that gets `actionDefinition` and `actionName` as arguments and return action creator */ actionAdapter: { - default: function _default(definition, actionName, config) { + default: function _default(actionDefinition, actionName) { return function (params) { return { type: createActionType(actionName), @@ -425,29 +435,60 @@ var createDefaultPlugin = function createDefaultPlugin(_ref) { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; var action = arguments[1]; - switch (action.type) { - case createActionType(actionName): - var resultsAssignements = {}; - if (Array.isArray(actionDefinition.result)) { - resultsAssignements = actionDefinition.result.reduce(function (accu, _ref2) { - var sourcePath = _ref2.sourcePath, - targetPath = _ref2.targetPath, - _ref2$defaultValue = _ref2.defaultValue, - defaultValue = _ref2$defaultValue === undefined ? new hasNotBeenDefined() : _ref2$defaultValue; - - if (!(defaultValue instanceof hasNotBeenDefined) && _.isUndefined(_.get(action, sourcePath))) { - accu[targetPath] = defaultValue; - } - accu[targetPath] = _.get(action, sourcePath); - return accu; - }, {}); + if (action.type === createActionType(actionName)) { + var resultsAssignments = void 0; + + // result is array of assignments + if (Array.isArray(actionDefinition.result)) { + resultsAssignments = actionDefinition.result.reduce(function (accu, _ref2) { + var sourcePath = _ref2.sourcePath, + targetPath = _ref2.targetPath, + _ref2$defaultValue = _ref2.defaultValue, + defaultValue = _ref2$defaultValue === undefined ? new hasNotBeenDefined() : _ref2$defaultValue, + _ref2$value = _ref2.value, + value = _ref2$value === undefined ? new hasNotBeenDefined() : _ref2$value; + + // setting default value if one has not been provided and defaultValue is defined + if (!(defaultValue instanceof hasNotBeenDefined) && _.isUndefined(_.get(action, sourcePath)) && value instanceof hasNotBeenDefined) { + accu[targetPath] = _.isFunction(defaultValue) ? defaultValue(action) : defaultValue; + + // setting value based on sourcePath + } else if (value instanceof hasNotBeenDefined) { + accu[targetPath] = _.get(action, _.isFunction(sourcePath) ? sourcePath(action) : sourcePath); + + // setting value calculated by a 'value' function + } else if (_.isFunction(value)) { + accu[targetPath] = value(action, _.get(state, targetPath)); + + // setting hardcoded value from 'value' field in the definition + } else { + accu[targetPath] = value; + } + return accu; + }, {}); + + // result is a string ('list', 'entity') or is not provided + } else { + var resultName = actionDefinition.resultName || actionName; + + // setting default value if one has not been provided and defaultValue is defined + if (_.has(actionDefinition, 'defaultValue') && _.isUndefined(action.payload) && _.has()) { + resultsAssignments = defineProperty({}, resultName, actionDefinition.defaultValue); + } else if (!_.has(actionDefinition, 'value')) { + resultsAssignments = defineProperty({}, resultName, action.payload); + + // setting value calculated by a 'value' function + } else if (_.isFunction(actionDefinition.value)) { + resultsAssignments = defineProperty({}, resultName, actionDefinition.value(action, state[resultName])); + + // setting hardcoded value from 'value' field in the definition } else { - resultsAssignements = defineProperty({}, actionDefinition.resultName, action.payload); + resultsAssignments = defineProperty({}, resultName, actionDefinition.value); } - return immutableSet(state, resultsAssignements); - default: - return state; + } + return immutableSet(state, resultsAssignments); } + return state; }; } }, @@ -456,19 +497,19 @@ var createDefaultPlugin = function createDefaultPlugin(_ref) { * Object of functions that gets `actionDefinition` and `actionName` as arguments and return assignment object (with keys = paths, values = values to be saved in those paths) */ initialStateAdapter: { - default: function _default(definition, actionName) { + default: function _default(actionDefinition, actionName) { var resultsAssignements = null; var defaultValue = void 0; - if (_.has(definition, 'initialValue')) { - defaultValue = definition.initialValue; - } else if (definition.result === 'list') { + if (_.has(actionDefinition, 'initialValue')) { + defaultValue = actionDefinition.initialValue; + } else if (actionDefinition.result === 'list') { defaultValue = []; - } else if (definition.result === 'entity') { + } else if (actionDefinition.result === 'entity') { defaultValue = null; } - if (Array.isArray(definition.result)) { - resultsAssignements = definition.result.reduce(function (accu, _ref3) { + if (Array.isArray(actionDefinition.result)) { + resultsAssignements = actionDefinition.result.reduce(function (accu, _ref3) { var targetPath = _ref3.targetPath, result = _ref3.result, _ref3$initialValue = _ref3.initialValue, @@ -482,32 +523,10 @@ var createDefaultPlugin = function createDefaultPlugin(_ref) { return accu; }, {}); } else { - resultsAssignements = defineProperty({}, definition.resultName, defaultValue); + resultsAssignements = defineProperty({}, actionDefinition.resultName, defaultValue); } return resultsAssignements; } - }, - - /** - * Function that gets getActionDefinitions function and return the object of selector functions NOTIMPLEMENTED - * @param {function(array)} getActionDefinitions function that gets array of supported types as argument and returns (still nested in reducerNames) matching definitions - */ - selectorsAdapter: function selectorsAdapter(getActionDefinitions) { - var actionDefinitions = getActionDefinitions(['default']); - }, - - - /** - * Function that gets getActionDefinitions function and return the object of additional reduxBreeze methods NOTIMPLEMENTED - * @param {function(array)} getActionDefinitions function that gets array of supported types as argument and returns (still nested in reducerNames) matching definitions - * @returns {object} object of additional reduxBreeze methods - */ - additionalMethods: function additionalMethods(getActionDefinitions) { - return { - sayHello: function sayHello() { - console.log('hello'); - } - }; } }; }; @@ -520,7 +539,7 @@ var defaultConfig = { * @param {string} actionType action type name (like 'default' in default plugin) * @param {string} pluginName name of the plugin * @param {string} adapterType type of adapter: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter' - * @returns {*} + * @return {string} changed actionType */ mapActionTypes: function mapActionTypes(actionType, pluginName, adapterType) { return actionType; @@ -532,7 +551,8 @@ var tools = { createActionType: createActionType, chainReducers: chainReducers, mergePlugins: mergePlugins, - checkConflicts: checkConflicts + checkConflicts: checkConflicts, + immutablyCopyValue: immutablyCopyValue }; var createReduxBreezeInstance = function createReduxBreezeInstance(actionDefinitions) { @@ -540,11 +560,13 @@ var createReduxBreezeInstance = function createReduxBreezeInstance(actionDefinit plugins[_key - 2] = arguments[_key]; } - var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig; + var userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig; + + var config = _extends({}, defaultConfig, userConfig); // merging plugins deeply var pluginsToMerge = config.useDefaultPlugin ? [createDefaultPlugin(tools)].concat(toConsumableArray(plugins.map(function (plugin) { - return plugin(tools); + return plugin(tools, config); }))) : plugins.map(function (plugin) { return plugin(tools); }); @@ -558,10 +580,10 @@ var createReduxBreezeInstance = function createReduxBreezeInstance(actionDefinit * Function to generate initialState (and immutably deeply merge it with custom initialState) from actions definitions * @param {object} actions object of action definitions * @param {object} initialState optional custom initial state + * @return {object} created initial state (merged with provided initialState) */ var createInitialState = function createInitialState(actions) { var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - return _.reduce(actions, function (actionsState, actionDefinition, actionName) { if (plugin.initialStateAdapter[actionDefinition.type]) { return immutableSet(actionsState, plugin.initialStateAdapter[actionDefinition.type](actionDefinition, actionName)); @@ -576,7 +598,8 @@ var createReduxBreezeInstance = function createReduxBreezeInstance(actionDefinit var reducers = _.reduce(actionDefinitions, function (reducers, actions, reducerName) { // getting final initial state for this combined/chained reducer (triggering custom reducers to get their initial state) - var initialState = createInitialState(actions, reducers[reducerName] ? reducers[reducerName](undefined, {}) : {}); + var initialState = createInitialState(actions, reducers[reducerName] ? reducers[reducerName](undefined, {}) : {} // eslint-disable-line no-undefined + ); // creating array of reducers tha are going to be chained on the `reducerName` field var reducersToChain = _.map(actions, function (actionDefinition, actionName) { diff --git a/lib/reduxBreeze.js.map b/lib/reduxBreeze.js.map index 18fe66b..d16f933 100644 --- a/lib/reduxBreeze.js.map +++ b/lib/reduxBreeze.js.map @@ -1 +1 @@ -{"version":3,"file":"reduxBreeze.js","sources":["../src/tools.js","../src/defaultPlugin.js","../src/index.js"],"sourcesContent":["import _ from 'lodash';\n\n/**\n * Helper for redux to attach reducers to one field instead of composing them into separate fields\n * @param {array} reducers\n * @return {function} reducer\n */\nexport const chainReducers = rawReducers => (state, action) => {\n const reducers = _.filter(rawReducers, reducer => {\n if (_.isNil(reducer)) {\n return false;\n }\n if (_.isFunction(reducer)) {\n return true;\n }\n throw new Error('reducers passed to chain reducers must be either a valida reducer (function) or nil (null or undefined)');\n });\n return reducers.reduce((accuState, reducer) => reducer(accuState, action), state);\n};\n\n/**\n * Checks if there are conflicts in plugins in given adapterType (conflict = two plugins handling same actionType)\n * @param {array} plugins list of plugins\n * @param {string} adapterType name of the adapter type: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter'\n * @param {function(actionType: string, pluginName: string, adapterType: string)} map function that changes actionTypes to a new values\n * @return {string} error text or empty string if no conflicts found\n */\nexport const checkConflicts = (plugins, adapterType, map = actionType => actionType) => {\n // TODO add checking for plugins having the same name\n const foundAdapters = {};\n plugins.forEach(plugin => {\n if (plugin[adapterType]) {\n _.forEach(plugin[adapterType], (adapter, actionType) => {\n const mappedActionType = map(actionType, plugin.name, adapterType);\n if (!foundAdapters[mappedActionType]) {\n foundAdapters[mappedActionType] = [];\n }\n foundAdapters[mappedActionType].push(plugin.name);\n });\n }\n });\n return _(foundAdapters)\n .map((listOfPlugins, actionType) => listOfPlugins.length > 1 ? `${adapterType} '${actionType}' is defined in plugins: ${listOfPlugins.join(',')}` : null)\n .filter()\n .join('; ');\n};\n\n/**\n * Function to merge different plugins into one plugin object\n * @param {array} plugins array of plugins objects\n * @param {boolean} strict with strict turned on we throw an error on plugin conflicts\n * @param {function} mapActionTypes function that changes names of action types\n * @returns {{actionAdapter, reducerAdapter, initialStateAdapter}} merged plugin object\n */\nexport const mergePlugins = (plugins, { strict = true, mapActionTypes = actionType => actionType } = {}) => {\n const actionAdapterConflicts = checkConflicts(plugins, 'actionAdapter', mapActionTypes);\n const reducerAdapterConflicts = checkConflicts(plugins, 'reducerAdapter', mapActionTypes);\n const initialStateAdapterConflicts = checkConflicts(plugins, 'initialStateAdapter', mapActionTypes);\n const conflicts = [];\n const conflictsVerbose = [];\n if (actionAdapterConflicts) {\n conflicts.push('actionAdapters');\n conflictsVerbose.push(actionAdapterConflicts);\n }\n if (reducerAdapterConflicts) {\n conflicts.push('reducerAdapters');\n conflictsVerbose.push(reducerAdapterConflicts);\n }\n if (initialStateAdapterConflicts) {\n conflicts.push('initialStateAdapters');\n conflictsVerbose.push(initialStateAdapterConflicts);\n }\n\n if (conflicts.length) {\n const errorMessage = `Conflicts in adapters: ${conflicts.join(', ')}. ${conflictsVerbose.join('. ')}.`;\n if (strict) {\n throw new Error(errorMessage);\n }\n console.warn(`${errorMessage} Duplicated adapters will be overwritten!`);\n }\n\n return {\n actionAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.actionAdapter, (accu, actionAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'actionAdapter')] = actionAdapter;\n return accu;\n }, {}),\n }), {}),\n reducerAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.reducerAdapter, (accu, reducerAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'reducerAdapter')] = reducerAdapter;\n return accu;\n }, {})\n }), {}),\n initialStateAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.initialStateAdapter, (accu, initialStateAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'initialStateAdapter')] = initialStateAdapter;\n return accu;\n }, {})\n }), {}),\n\n };\n};\n\n/**\n *\n * @param {string} actionName camelCase name of the action (e.g. someAction)\n * @param {string} suffix string that is going to be added at the end of the created action type\n * @param {string} prefix string that is going to be added at the beginning of the created action type\n * @returns {string} upperSnakeCase action type (e.g. SOME_ACTION or with example suffix SOME_ACTION_SUFFIX)\n */\nexport const createActionType = (actionName, suffix = '', prefix = '') => {\n const upperSnakeCase = _.snakeCase(actionName).toUpperCase();\n return `${prefix ? `${prefix.toUpperCase()}_` : ''}${upperSnakeCase}${suffix ? `_${suffix.toUpperCase()}` : ''}`;\n};\n\n/**\n * Works like lodash _.set() but does not mutate object (doesn't work with array style keys like `someArray[2].anotherField`)\n * @param {object} object source object\n * @param {string|{[string]: any}} path in object to set value in or object with paths as keys and values as values (if path is an object it ignores 'value')\n * @param {any} value to set in given path\n * @param {string} delimiter path delimiter; by default: '.'\n * @returns {object} new object with value(s) changed\n */\nexport const immutableSet = (object, path, value = null, delimiter = '.') => {\n // console.log('immutableSet', {object, path, value, delimiter});\n if (!path) {\n return value;\n }\n if (_.isPlainObject(path)) {\n if (_.isEmpty(path)) {\n return object;\n }\n return _.reduce(path, (accu, value, path) => immutableSet(accu, path, value, delimiter), object);\n }\n\n const pathSplit = path.split(delimiter);\n if (pathSplit.length === 1) {\n return {\n ...object,\n [path]: value,\n }\n }\n let childObject = {};\n if (_.has(object, pathSplit[0])) {\n childObject = object[pathSplit[0]];\n if (!_.isPlainObject(childObject)) {\n throw new Error(`Part of 'path' provided is defined in 'object' and is not a plain JS object but ${typeof childObject}. It's most likely an error. Check the path and object provided to immutableSet function`);\n }\n }\n return {\n ...object,\n [pathSplit[0]]: immutableSet(childObject, _.tail(pathSplit).join(delimiter), value, delimiter),\n };\n};\n","import _ from 'lodash';\n\nclass hasNotBeenDefined{};\n\nconst createDefaultPlugin = ({ createActionType, immutableSet }) => ({\n /**\n * Object of functions that gets `actionDefinition` and `actionName` as arguments and return action creator\n */\n actionAdapter: {\n default(definition, actionName, config) {\n return (params) => {\n return {\n type: createActionType(actionName),\n payload: params,\n }\n };\n },\n },\n\n /**\n * Object of functions that gets `actionDefinition`, `actionName`, and `initialState` and returns a reducer\n */\n reducerAdapter: {\n default(actionDefinition, actionName, initialState) {\n return (state = initialState, action) => {\n switch (action.type) {\n case createActionType(actionName):\n let resultsAssignements = {};\n if (Array.isArray(actionDefinition.result)) {\n resultsAssignements = actionDefinition.result.reduce(\n (accu, { sourcePath, targetPath, defaultValue = new hasNotBeenDefined() }) => {\n if (!(defaultValue instanceof hasNotBeenDefined) && _.isUndefined(_.get(action, sourcePath))) {\n accu[targetPath] = defaultValue;\n }\n accu[targetPath] = _.get(action, sourcePath);\n return accu;\n },\n {}\n );\n } else {\n resultsAssignements = {\n [actionDefinition.resultName]: action.payload,\n };\n }\n return immutableSet(state, resultsAssignements);\n default:\n return state;\n }\n };\n },\n },\n\n /**\n * Object of functions that gets `actionDefinition` and `actionName` as arguments and return assignment object (with keys = paths, values = values to be saved in those paths)\n */\n initialStateAdapter: {\n default (definition, actionName) {\n let resultsAssignements = null;\n let defaultValue;\n if (_.has(definition, 'initialValue')) {\n defaultValue = definition.initialValue;\n } else if (definition.result === 'list') {\n defaultValue = [];\n } else if (definition.result === 'entity') {\n defaultValue = null;\n }\n\n if (Array.isArray(definition.result)) {\n resultsAssignements = definition.result.reduce((accu, { targetPath, result, initialValue = new hasNotBeenDefined }) => {\n if (initialValue instanceof hasNotBeenDefined) {\n accu[targetPath] = result === 'list' ? [] : null;\n } else {\n accu[targetPath] = initialValue;\n }\n return accu;\n }, {});\n } else {\n resultsAssignements = { [definition.resultName]: defaultValue };\n }\n return resultsAssignements;\n },\n },\n\n /**\n * Function that gets getActionDefinitions function and return the object of selector functions NOTIMPLEMENTED\n * @param {function(array)} getActionDefinitions function that gets array of supported types as argument and returns (still nested in reducerNames) matching definitions\n */\n selectorsAdapter(getActionDefinitions) {\n const actionDefinitions = getActionDefinitions(['default']);\n\n },\n\n /**\n * Function that gets getActionDefinitions function and return the object of additional reduxBreeze methods NOTIMPLEMENTED\n * @param {function(array)} getActionDefinitions function that gets array of supported types as argument and returns (still nested in reducerNames) matching definitions\n * @returns {object} object of additional reduxBreeze methods\n */\n additionalMethods(getActionDefinitions) {\n return {\n sayHello() {\n console.log('hello');\n }\n };\n }\n});\n\nexport default createDefaultPlugin;\n","import _ from 'lodash';\nimport { combineReducers } from 'redux';\nimport { immutableSet, createActionType, chainReducers, mergePlugins, checkConflicts } from './tools';\nimport createDefaultPlugin from './defaultPlugin';\n\nconst defaultConfig = {\n useDefaultPlugin: true,\n strict: true,\n /**\n *\n * @param {string} actionType action type name (like 'default' in default plugin)\n * @param {string} pluginName name of the plugin\n * @param {string} adapterType type of adapter: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter'\n * @returns {*}\n */\n mapActionTypes(actionType, pluginName, adapterType) {\n return actionType;\n }\n};\n\nexport const tools = {\n immutableSet,\n createActionType,\n chainReducers,\n mergePlugins,\n checkConflicts,\n};\n\nconst createReduxBreezeInstance = (actionDefinitions, config = defaultConfig, ...plugins) => {\n // merging plugins deeply\n const pluginsToMerge = config.useDefaultPlugin\n ? [createDefaultPlugin(tools), ...plugins.map(plugin => plugin(tools))]\n : plugins.map(plugin => plugin(tools));\n\n const plugin = mergePlugins(\n pluginsToMerge,\n {\n strict: config.strict,\n mapActionTypes: config.mapActionTypes,\n }\n );\n\n /**\n * Function to generate initialState (and immutably deeply merge it with custom initialState) from actions definitions\n * @param {object} actions object of action definitions\n * @param {object} initialState optional custom initial state\n */\n const createInitialState = (actions, initialState = {}) => {\n return _.reduce(actions, (actionsState, actionDefinition, actionName) => {\n if (plugin.initialStateAdapter[actionDefinition.type]) {\n return immutableSet(actionsState, plugin.initialStateAdapter[actionDefinition.type](actionDefinition, actionName));\n }\n return actionsState;\n }, initialState);\n };\n\n return {\n combineReducers(customReducers = {}) {\n const reducers = _.reduce(actionDefinitions, (reducers, actions, reducerName) => {\n // getting final initial state for this combined/chained reducer (triggering custom reducers to get their initial state)\n const initialState = createInitialState(actions, reducers[reducerName] ? reducers[reducerName](undefined, {}) : {});\n\n // creating array of reducers tha are going to be chained on the `reducerName` field\n const reducersToChain = _.map(actions, (actionDefinition, actionName) => {\n if (plugin.reducerAdapter[actionDefinition.type]) {\n return plugin.reducerAdapter[actionDefinition.type](actionDefinition, actionName, initialState);\n }\n throw new Error(`Unknown type '${actionDefinition.type}' of action '${actionName}'. It's most likely because you did not install plugin to handle reducer for this type of actions`);\n });\n\n // adding custom reducer (if one has been provided) at the end of the chain for the user to be able to modify default behaviour\n if (reducers[reducerName]) {\n reducersToChain.push(reducers[reducerName]);\n }\n\n reducers[reducerName] = chainReducers(reducersToChain);\n return reducers;\n }, customReducers);\n return combineReducers(reducers);\n },\n getAction(actionName, config) {\n const actionGroup = _.find(actionDefinitions, (actionsList) => _.has(actionsList, actionName));\n if (!actionGroup) {\n throw new Error(`${actionName} action has not been found`);\n }\n if (!plugin.actionAdapter[actionGroup[actionName].type]) {\n throw new Error(`Unknown type '${actionGroup[actionName].type}' of '${actionName}' action. It's most likely because you did not install plugin to handle action creation for this type of actions`);\n }\n return plugin.actionAdapter[actionGroup[actionName].type](actionGroup[actionName], actionName, config);\n },\n getActionDefinitions() {\n return actionDefinitions;\n },\n getMergedPlugin() {\n return plugin;\n },\n };\n};\n\nexport default createReduxBreezeInstance;\n"],"names":["chainReducers","state","action","reducers","_","filter","rawReducers","isNil","reducer","isFunction","Error","reduce","accuState","checkConflicts","plugins","adapterType","map","actionType","foundAdapters","forEach","plugin","adapter","mappedActionType","name","push","listOfPlugins","length","join","mergePlugins","strict","mapActionTypes","actionAdapterConflicts","reducerAdapterConflicts","initialStateAdapterConflicts","conflicts","conflictsVerbose","errorMessage","warn","actionAdapter","accu","reducerAdapter","initialStateAdapter","createActionType","actionName","suffix","prefix","upperSnakeCase","snakeCase","toUpperCase","immutableSet","object","path","value","delimiter","isPlainObject","isEmpty","pathSplit","split","childObject","has","tail","hasNotBeenDefined","createDefaultPlugin","definition","config","params","actionDefinition","initialState","type","resultsAssignements","Array","isArray","result","sourcePath","targetPath","defaultValue","isUndefined","get","resultName","payload","initialValue","getActionDefinitions","actionDefinitions","log","defaultConfig","pluginName","tools","createReduxBreezeInstance","pluginsToMerge","useDefaultPlugin","createInitialState","actions","actionsState","customReducers","reducerName","undefined","reducersToChain","combineReducers","actionGroup","find","actionsList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;AAKA,AAAO,IAAMA,gBAAgB,SAAhBA,aAAgB;SAAe,UAACC,KAAD,EAAQC,MAAR,EAAmB;QACvDC,WAAWC,EAAEC,MAAF,CAASC,WAAT,EAAsB,mBAAW;UAC5CF,EAAEG,KAAF,CAAQC,OAAR,CAAJ,EAAsB;eACb,KAAP;;UAEEJ,EAAEK,UAAF,CAAaD,OAAb,CAAJ,EAA2B;eAClB,IAAP;;YAEI,IAAIE,KAAJ,CAAU,yGAAV,CAAN;KAPe,CAAjB;WASOP,SAASQ,MAAT,CAAgB,UAACC,SAAD,EAAYJ,OAAZ;aAAwBA,QAAQI,SAAR,EAAmBV,MAAnB,CAAxB;KAAhB,EAAoED,KAApE,CAAP;GAV2B;CAAtB;;;;;;;;;AAoBP,AAAO,IAAMY,iBAAiB,SAAjBA,cAAiB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D,EAA4EA,UAA5E,EAAwFqB,MAAxF,CAAP;KAhCG;wBAAA,kCAkCkB;aACdkB,iBAAP;KAnCG;mBAAA,6BAqCa;aACT9D,MAAP;;GAtCJ;CA5BF;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"reduxBreeze.js","sources":["../src/tools.js","../src/defaultPlugin.js","../src/index.js"],"sourcesContent":["import _ from 'lodash';\n\n/**\n * Helper for redux to attach reducers to one field instead of composing them into separate fields\n * @param {array} rawReducers array of unchained, not combined reducers\n * @return {function} reducer\n */\nexport const chainReducers = rawReducers => (state, action) => {\n const reducers = _.filter(rawReducers, reducer => {\n if (_.isNil(reducer)) {\n return false;\n }\n if (_.isFunction(reducer)) {\n return true;\n }\n throw new Error('reducers passed to chain reducers must be either a valida reducer (function) or nil (null or undefined)');\n });\n return reducers.reduce((accuState, reducer) => reducer(accuState, action), state);\n};\n\n/**\n * Checks if there are conflicts in plugins in given adapterType (conflict = two plugins handling same actionType)\n * @param {array} plugins list of plugins\n * @param {string} adapterType name of the adapter type: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter'\n * @param {function(actionType: string, pluginName: string, adapterType: string)} map function that changes actionTypes to a new values\n * @return {string} error text or empty string if no conflicts found\n */\nexport const checkConflicts = (plugins, adapterType, map = actionType => actionType) => {\n // TODO add checking for plugins having the same name\n const foundAdapters = {};\n plugins.forEach(plugin => {\n if (plugin[adapterType]) {\n _.forEach(plugin[adapterType], (adapter, actionType) => {\n const mappedActionType = map(actionType, plugin.name, adapterType);\n if (!foundAdapters[mappedActionType]) {\n foundAdapters[mappedActionType] = [];\n }\n foundAdapters[mappedActionType].push(plugin.name);\n });\n }\n });\n return _(foundAdapters)\n .map((listOfPlugins, actionType) => listOfPlugins.length > 1 ? `${adapterType} '${actionType}' is defined in plugins: ${listOfPlugins.join(',')}` : null)\n .filter()\n .join('; ');\n};\n\n/**\n * Function to merge different plugins into one plugin object\n * @param {array} plugins array of plugins objects\n * @param {boolean} strict with strict turned on we throw an error on plugin conflicts\n * @param {function} mapActionTypes function that changes names of action types\n * @return {{actionAdapter, reducerAdapter, initialStateAdapter}} merged plugin object\n */\nexport const mergePlugins = (plugins, { strict = true, mapActionTypes = actionType => actionType } = {}) => {\n const actionAdapterConflicts = checkConflicts(plugins, 'actionAdapter', mapActionTypes);\n const reducerAdapterConflicts = checkConflicts(plugins, 'reducerAdapter', mapActionTypes);\n const initialStateAdapterConflicts = checkConflicts(plugins, 'initialStateAdapter', mapActionTypes);\n const conflicts = [];\n const conflictsVerbose = [];\n if (actionAdapterConflicts) {\n conflicts.push('actionAdapters');\n conflictsVerbose.push(actionAdapterConflicts);\n }\n if (reducerAdapterConflicts) {\n conflicts.push('reducerAdapters');\n conflictsVerbose.push(reducerAdapterConflicts);\n }\n if (initialStateAdapterConflicts) {\n conflicts.push('initialStateAdapters');\n conflictsVerbose.push(initialStateAdapterConflicts);\n }\n\n if (conflicts.length) {\n const errorMessage = `Conflicts in adapters: ${conflicts.join(', ')}. ${conflictsVerbose.join('. ')}.`;\n if (strict) {\n throw new Error(errorMessage);\n }\n console.warn(`${errorMessage} Duplicated adapters will be overwritten!`);\n }\n\n return {\n actionAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.actionAdapter, (accu, actionAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'actionAdapter')] = actionAdapter;\n return accu;\n }, {}),\n }), {}),\n reducerAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.reducerAdapter, (accu, reducerAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'reducerAdapter')] = reducerAdapter;\n return accu;\n }, {}),\n }), {}),\n initialStateAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.initialStateAdapter, (accu, initialStateAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'initialStateAdapter')] = initialStateAdapter;\n return accu;\n }, {}),\n }), {}),\n\n };\n};\n\n/**\n *\n * @param {string} actionName camelCase name of the action (e.g. someAction)\n * @param {string} suffix string that is going to be added at the end of the created action type\n * @param {string} prefix string that is going to be added at the beginning of the created action type\n * @return {string} upperSnakeCase action type (e.g. SOME_ACTION or with example suffix SOME_ACTION_SUFFIX)\n */\nexport const createActionType = (actionName, suffix = '', prefix = '') => {\n const upperSnakeCase = _.snakeCase(actionName).toUpperCase();\n return `${prefix ? `${prefix.toUpperCase()}_` : ''}${upperSnakeCase}${suffix ? `_${suffix.toUpperCase()}` : ''}`;\n};\n\n/**\n * Works like lodash _.set() but does not mutate object (doesn't work with array style keys like `someArray[2].anotherField`)\n * @param {object} object source object\n * @param {string|object} path in object to set value in or object with paths as keys and values as values (if path is an object it ignores 'value')\n * @param {any} value to set in given path\n * @param {string} delimiter path delimiter; by default: '.'\n * @return {object} new object with value(s) changed\n */\nexport const immutableSet = (object, path, value = null, delimiter = '.') => {\n // console.log('immutableSet', {object, path, value, delimiter});\n if (!path) {\n return value;\n }\n if (_.isPlainObject(path)) {\n if (_.isEmpty(path)) {\n return object;\n }\n return _.reduce(path, (accu, value, path) => immutableSet(accu, path, value, delimiter), object);\n }\n\n const pathSplit = path.split(delimiter);\n if (pathSplit.length === 1) {\n return {\n ...object,\n [path]: value,\n };\n }\n let childObject = {};\n if (_.has(object, pathSplit[0])) {\n childObject = object[pathSplit[0]];\n if (!_.isPlainObject(childObject)) {\n throw new Error(`Part of 'path' provided is defined in 'object' and is not a plain JS object but ${typeof childObject}. It's most likely an error. Check the path and object provided to immutableSet function`);\n }\n }\n return {\n ...object,\n [pathSplit[0]]: immutableSet(childObject, _.tail(pathSplit).join(delimiter), value, delimiter),\n };\n};\n\n/**\n * Copy value from fromPath in fromObject and create new object from toObject with that value saved in toPath\n * @param {object} fromObject object which you get the value from\n * @param {string} fromPath path in fromObject where you get tha value from\n * @param {object} toObject object where you save the value to\n * @param {string} toPath path in toObject where you save the value\n * @return {object} new object created from values in toObject\n */\nexport const immutablyCopyValue = (fromObject, fromPath, toObject, toPath) => {\n return immutableSet(toObject, toPath, _.get(fromObject, fromPath));\n};\n","import _ from 'lodash';\n\nclass hasNotBeenDefined {}\n\nconst createDefaultPlugin = ({ createActionType, immutableSet }, config) => ({\n /**\n * Object of functions that gets `actionDefinition` and `actionName` as arguments and return action creator\n */\n actionAdapter: {\n default(actionDefinition, actionName) {\n return params => ({\n type: createActionType(actionName),\n payload: params,\n });\n },\n },\n\n /**\n * Object of functions that gets `actionDefinition`, `actionName`, and `initialState` and returns a reducer\n */\n reducerAdapter: {\n default(actionDefinition, actionName, initialState) {\n return (state = initialState, action) => {\n if (action.type === createActionType(actionName)) {\n let resultsAssignments;\n\n // result is array of assignments\n if (Array.isArray(actionDefinition.result)) {\n resultsAssignments = actionDefinition.result.reduce(\n (\n accu,\n {\n sourcePath,\n targetPath,\n defaultValue = new hasNotBeenDefined(),\n value = new hasNotBeenDefined(),\n }\n ) => {\n // setting default value if one has not been provided and defaultValue is defined\n if (\n !(defaultValue instanceof hasNotBeenDefined)\n && _.isUndefined(_.get(action, sourcePath))\n && value instanceof hasNotBeenDefined\n ) {\n accu[targetPath] = _.isFunction(defaultValue) ? defaultValue(action) : defaultValue;\n\n // setting value based on sourcePath\n } else if (value instanceof hasNotBeenDefined) {\n accu[targetPath] = _.get(action, _.isFunction(sourcePath) ? sourcePath(action) : sourcePath);\n\n // setting value calculated by a 'value' function\n } else if (_.isFunction(value)) {\n accu[targetPath] = value(action, _.get(state, targetPath));\n\n // setting hardcoded value from 'value' field in the definition\n } else {\n accu[targetPath] = value;\n }\n return accu;\n },\n {}\n );\n\n // result is a string ('list', 'entity') or is not provided\n } else {\n const resultName = actionDefinition.resultName || actionName;\n\n // setting default value if one has not been provided and defaultValue is defined\n if (\n _.has(actionDefinition, 'defaultValue')\n && _.isUndefined(action.payload)\n && _.has()\n ) {\n resultsAssignments = { [resultName]: actionDefinition.defaultValue };\n } else if (!_.has(actionDefinition, 'value')) {\n resultsAssignments = { [resultName]: action.payload };\n\n // setting value calculated by a 'value' function\n } else if (_.isFunction(actionDefinition.value)) {\n resultsAssignments = { [resultName]: actionDefinition.value(action, state[resultName]) };\n\n // setting hardcoded value from 'value' field in the definition\n } else {\n resultsAssignments = { [resultName]: actionDefinition.value };\n }\n }\n return immutableSet(state, resultsAssignments);\n }\n return state;\n };\n },\n },\n\n /**\n * Object of functions that gets `actionDefinition` and `actionName` as arguments and return assignment object (with keys = paths, values = values to be saved in those paths)\n */\n initialStateAdapter: {\n default(actionDefinition, actionName) {\n let resultsAssignements = null;\n let defaultValue;\n if (_.has(actionDefinition, 'initialValue')) {\n defaultValue = actionDefinition.initialValue;\n } else if (actionDefinition.result === 'list') {\n defaultValue = [];\n } else if (actionDefinition.result === 'entity') {\n defaultValue = null;\n }\n\n if (Array.isArray(actionDefinition.result)) {\n resultsAssignements = actionDefinition.result.reduce(\n (accu, { targetPath, result, initialValue = new hasNotBeenDefined() }) => {\n if (initialValue instanceof hasNotBeenDefined) {\n accu[targetPath] = result === 'list' ? [] : null;\n } else {\n accu[targetPath] = initialValue;\n }\n return accu;\n },\n {}\n );\n } else {\n resultsAssignements = { [actionDefinition.resultName]: defaultValue };\n }\n return resultsAssignements;\n },\n },\n});\n\nexport default createDefaultPlugin;\n","import _ from 'lodash';\nimport { combineReducers } from 'redux';\nimport {\n immutableSet,\n createActionType,\n chainReducers,\n mergePlugins,\n checkConflicts,\n immutablyCopyValue,\n} from './tools';\nimport createDefaultPlugin from './defaultPlugin';\n\nconst defaultConfig = {\n useDefaultPlugin: true,\n strict: true,\n /**\n *\n * @param {string} actionType action type name (like 'default' in default plugin)\n * @param {string} pluginName name of the plugin\n * @param {string} adapterType type of adapter: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter'\n * @return {string} changed actionType\n */\n mapActionTypes(actionType, pluginName, adapterType) {\n return actionType;\n },\n};\n\nexport const tools = {\n immutableSet,\n createActionType,\n chainReducers,\n mergePlugins,\n checkConflicts,\n immutablyCopyValue,\n};\n\nconst createReduxBreezeInstance = (actionDefinitions, userConfig = defaultConfig, ...plugins) => {\n const config = {\n ...defaultConfig,\n ...userConfig,\n };\n\n // merging plugins deeply\n const pluginsToMerge = config.useDefaultPlugin\n ? [createDefaultPlugin(tools), ...plugins.map(plugin => plugin(tools, config))]\n : plugins.map(plugin => plugin(tools));\n\n const plugin = mergePlugins(\n pluginsToMerge,\n {\n strict: config.strict,\n mapActionTypes: config.mapActionTypes,\n }\n );\n\n /**\n * Function to generate initialState (and immutably deeply merge it with custom initialState) from actions definitions\n * @param {object} actions object of action definitions\n * @param {object} initialState optional custom initial state\n * @return {object} created initial state (merged with provided initialState)\n */\n const createInitialState = (actions, initialState = {}) => _.reduce(\n actions,\n (actionsState, actionDefinition, actionName) => {\n if (plugin.initialStateAdapter[actionDefinition.type]) {\n return immutableSet(\n actionsState,\n plugin.initialStateAdapter[actionDefinition.type](actionDefinition, actionName)\n );\n }\n return actionsState;\n },\n initialState\n );\n\n return {\n combineReducers(customReducers = {}) {\n const reducers = _.reduce(actionDefinitions, (reducers, actions, reducerName) => {\n // getting final initial state for this combined/chained reducer (triggering custom reducers to get their initial state)\n const initialState = createInitialState(\n actions,\n reducers[reducerName] ? reducers[reducerName](undefined, {}) : {} // eslint-disable-line no-undefined\n );\n\n // creating array of reducers tha are going to be chained on the `reducerName` field\n const reducersToChain = _.map(actions, (actionDefinition, actionName) => {\n if (plugin.reducerAdapter[actionDefinition.type]) {\n return plugin.reducerAdapter[actionDefinition.type](actionDefinition, actionName, initialState);\n }\n throw new Error(`Unknown type '${actionDefinition.type}' of action '${actionName}'. It's most likely because you did not install plugin to handle reducer for this type of actions`);\n });\n\n // adding custom reducer (if one has been provided) at the end of the chain for the user to be able to modify default behaviour\n if (reducers[reducerName]) {\n reducersToChain.push(reducers[reducerName]);\n }\n\n reducers[reducerName] = chainReducers(reducersToChain);\n return reducers;\n }, customReducers);\n return combineReducers(reducers);\n },\n getAction(actionName, config) {\n const actionGroup = _.find(actionDefinitions, actionsList => _.has(actionsList, actionName));\n if (!actionGroup) {\n throw new Error(`${actionName} action has not been found`);\n }\n if (!plugin.actionAdapter[actionGroup[actionName].type]) {\n throw new Error(`Unknown type '${actionGroup[actionName].type}' of '${actionName}' action. It's most likely because you did not install plugin to handle action creation for this type of actions`);\n }\n return plugin.actionAdapter[actionGroup[actionName].type](actionGroup[actionName], actionName, config);\n },\n getActionDefinitions() {\n return actionDefinitions;\n },\n getMergedPlugin() {\n return plugin;\n },\n };\n};\n\nexport default createReduxBreezeInstance;\n"],"names":["chainReducers","state","action","reducers","_","filter","rawReducers","isNil","reducer","isFunction","Error","reduce","accuState","checkConflicts","plugins","adapterType","map","actionType","foundAdapters","forEach","plugin","adapter","mappedActionType","name","push","listOfPlugins","length","join","mergePlugins","strict","mapActionTypes","actionAdapterConflicts","reducerAdapterConflicts","initialStateAdapterConflicts","conflicts","conflictsVerbose","errorMessage","warn","actionAdapter","accu","reducerAdapter","initialStateAdapter","createActionType","actionName","suffix","prefix","upperSnakeCase","snakeCase","toUpperCase","immutableSet","object","path","value","delimiter","isPlainObject","isEmpty","pathSplit","split","childObject","has","tail","immutablyCopyValue","fromObject","fromPath","toObject","toPath","get","hasNotBeenDefined","createDefaultPlugin","config","actionDefinition","params","initialState","type","resultsAssignments","Array","isArray","result","sourcePath","targetPath","defaultValue","isUndefined","resultName","payload","resultsAssignements","initialValue","defaultConfig","pluginName","tools","createReduxBreezeInstance","actionDefinitions","userConfig","pluginsToMerge","useDefaultPlugin","createInitialState","actions","actionsState","customReducers","reducerName","undefined","reducersToChain","combineReducers","actionGroup","find","actionsList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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6C,WAAN,EAAmB7D,UAAnB,CAAf;OAA1B,CAApB;UACI,CAAC2D,WAAL,EAAkB;cACV,IAAI5F,KAAJ,CAAaiC,UAAb,gCAAN;;UAEE,CAACvB,OAAOkB,aAAP,CAAqBgE,YAAY3D,UAAZ,EAAwB8B,IAA7C,CAAL,EAAyD;cACjD,IAAI/D,KAAJ,qBAA2B4F,YAAY3D,UAAZ,EAAwB8B,IAAnD,gBAAgE9B,UAAhE,wHAAN;;aAEKvB,OAAOkB,aAAP,CAAqBgE,YAAY3D,UAAZ,EAAwB8B,IAA7C,EAAmD6B,YAAY3D,UAAZ,CAAnD,EAA4EA,UAA5E,EAAwF0B,MAAxF,CAAP;KAnCG;wBAAA,kCAqCkB;aACdqB,iBAAP;KAtCG;mBAAA,6BAwCa;aACTtE,MAAP;;GAzCJ;CAvCF;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/lib/reduxBreeze.mjs b/lib/reduxBreeze.mjs index 3ac5684..872cc98 100644 --- a/lib/reduxBreeze.mjs +++ b/lib/reduxBreeze.mjs @@ -218,7 +218,7 @@ babelHelpers; /** * Helper for redux to attach reducers to one field instead of composing them into separate fields - * @param {array} reducers + * @param {array} rawReducers array of unchained, not combined reducers * @return {function} reducer */ var chainReducers = function chainReducers(rawReducers) { @@ -273,7 +273,7 @@ var checkConflicts = function checkConflicts(plugins, adapterType) { * @param {array} plugins array of plugins objects * @param {boolean} strict with strict turned on we throw an error on plugin conflicts * @param {function} mapActionTypes function that changes names of action types - * @returns {{actionAdapter, reducerAdapter, initialStateAdapter}} merged plugin object + * @return {{actionAdapter, reducerAdapter, initialStateAdapter}} merged plugin object */ var mergePlugins = function mergePlugins(plugins) { var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, @@ -338,7 +338,7 @@ var mergePlugins = function mergePlugins(plugins) { * @param {string} actionName camelCase name of the action (e.g. someAction) * @param {string} suffix string that is going to be added at the end of the created action type * @param {string} prefix string that is going to be added at the beginning of the created action type - * @returns {string} upperSnakeCase action type (e.g. SOME_ACTION or with example suffix SOME_ACTION_SUFFIX) + * @return {string} upperSnakeCase action type (e.g. SOME_ACTION or with example suffix SOME_ACTION_SUFFIX) */ var createActionType = function createActionType(actionName) { var suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; @@ -351,10 +351,10 @@ var createActionType = function createActionType(actionName) { /** * Works like lodash _.set() but does not mutate object (doesn't work with array style keys like `someArray[2].anotherField`) * @param {object} object source object - * @param {string|{[string]: any}} path in object to set value in or object with paths as keys and values as values (if path is an object it ignores 'value') + * @param {string|object} path in object to set value in or object with paths as keys and values as values (if path is an object it ignores 'value') * @param {any} value to set in given path * @param {string} delimiter path delimiter; by default: '.' - * @returns {object} new object with value(s) changed + * @return {object} new object with value(s) changed */ var immutableSet = function immutableSet(object, path) { var value = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null; @@ -387,13 +387,23 @@ var immutableSet = function immutableSet(object, path) { return _extends({}, object, defineProperty({}, pathSplit[0], immutableSet(childObject, _.tail(pathSplit).join(delimiter), value, delimiter))); }; +/** + * Copy value from fromPath in fromObject and create new object from toObject with that value saved in toPath + * @param {object} fromObject object which you get the value from + * @param {string} fromPath path in fromObject where you get tha value from + * @param {object} toObject object where you save the value to + * @param {string} toPath path in toObject where you save the value + * @return {object} new object created from values in toObject + */ +var immutablyCopyValue = function immutablyCopyValue(fromObject, fromPath, toObject, toPath) { + return immutableSet(toObject, toPath, _.get(fromObject, fromPath)); +}; + var hasNotBeenDefined = function hasNotBeenDefined() { classCallCheck(this, hasNotBeenDefined); }; - - -var createDefaultPlugin = function createDefaultPlugin(_ref) { +var createDefaultPlugin = function createDefaultPlugin(_ref, config) { var createActionType = _ref.createActionType, immutableSet = _ref.immutableSet; return { @@ -401,7 +411,7 @@ var createDefaultPlugin = function createDefaultPlugin(_ref) { * Object of functions that gets `actionDefinition` and `actionName` as arguments and return action creator */ actionAdapter: { - default: function _default(definition, actionName, config) { + default: function _default(actionDefinition, actionName) { return function (params) { return { type: createActionType(actionName), @@ -420,29 +430,60 @@ var createDefaultPlugin = function createDefaultPlugin(_ref) { var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; var action = arguments[1]; - switch (action.type) { - case createActionType(actionName): - var resultsAssignements = {}; - if (Array.isArray(actionDefinition.result)) { - resultsAssignements = actionDefinition.result.reduce(function (accu, _ref2) { - var sourcePath = _ref2.sourcePath, - targetPath = _ref2.targetPath, - _ref2$defaultValue = _ref2.defaultValue, - defaultValue = _ref2$defaultValue === undefined ? new hasNotBeenDefined() : _ref2$defaultValue; - - if (!(defaultValue instanceof hasNotBeenDefined) && _.isUndefined(_.get(action, sourcePath))) { - accu[targetPath] = defaultValue; - } - accu[targetPath] = _.get(action, sourcePath); - return accu; - }, {}); + if (action.type === createActionType(actionName)) { + var resultsAssignments = void 0; + + // result is array of assignments + if (Array.isArray(actionDefinition.result)) { + resultsAssignments = actionDefinition.result.reduce(function (accu, _ref2) { + var sourcePath = _ref2.sourcePath, + targetPath = _ref2.targetPath, + _ref2$defaultValue = _ref2.defaultValue, + defaultValue = _ref2$defaultValue === undefined ? new hasNotBeenDefined() : _ref2$defaultValue, + _ref2$value = _ref2.value, + value = _ref2$value === undefined ? new hasNotBeenDefined() : _ref2$value; + + // setting default value if one has not been provided and defaultValue is defined + if (!(defaultValue instanceof hasNotBeenDefined) && _.isUndefined(_.get(action, sourcePath)) && value instanceof hasNotBeenDefined) { + accu[targetPath] = _.isFunction(defaultValue) ? defaultValue(action) : defaultValue; + + // setting value based on sourcePath + } else if (value instanceof hasNotBeenDefined) { + accu[targetPath] = _.get(action, _.isFunction(sourcePath) ? sourcePath(action) : sourcePath); + + // setting value calculated by a 'value' function + } else if (_.isFunction(value)) { + accu[targetPath] = value(action, _.get(state, targetPath)); + + // setting hardcoded value from 'value' field in the definition + } else { + accu[targetPath] = value; + } + return accu; + }, {}); + + // result is a string ('list', 'entity') or is not provided + } else { + var resultName = actionDefinition.resultName || actionName; + + // setting default value if one has not been provided and defaultValue is defined + if (_.has(actionDefinition, 'defaultValue') && _.isUndefined(action.payload) && _.has()) { + resultsAssignments = defineProperty({}, resultName, actionDefinition.defaultValue); + } else if (!_.has(actionDefinition, 'value')) { + resultsAssignments = defineProperty({}, resultName, action.payload); + + // setting value calculated by a 'value' function + } else if (_.isFunction(actionDefinition.value)) { + resultsAssignments = defineProperty({}, resultName, actionDefinition.value(action, state[resultName])); + + // setting hardcoded value from 'value' field in the definition } else { - resultsAssignements = defineProperty({}, actionDefinition.resultName, action.payload); + resultsAssignments = defineProperty({}, resultName, actionDefinition.value); } - return immutableSet(state, resultsAssignements); - default: - return state; + } + return immutableSet(state, resultsAssignments); } + return state; }; } }, @@ -451,19 +492,19 @@ var createDefaultPlugin = function createDefaultPlugin(_ref) { * Object of functions that gets `actionDefinition` and `actionName` as arguments and return assignment object (with keys = paths, values = values to be saved in those paths) */ initialStateAdapter: { - default: function _default(definition, actionName) { + default: function _default(actionDefinition, actionName) { var resultsAssignements = null; var defaultValue = void 0; - if (_.has(definition, 'initialValue')) { - defaultValue = definition.initialValue; - } else if (definition.result === 'list') { + if (_.has(actionDefinition, 'initialValue')) { + defaultValue = actionDefinition.initialValue; + } else if (actionDefinition.result === 'list') { defaultValue = []; - } else if (definition.result === 'entity') { + } else if (actionDefinition.result === 'entity') { defaultValue = null; } - if (Array.isArray(definition.result)) { - resultsAssignements = definition.result.reduce(function (accu, _ref3) { + if (Array.isArray(actionDefinition.result)) { + resultsAssignements = actionDefinition.result.reduce(function (accu, _ref3) { var targetPath = _ref3.targetPath, result = _ref3.result, _ref3$initialValue = _ref3.initialValue, @@ -477,32 +518,10 @@ var createDefaultPlugin = function createDefaultPlugin(_ref) { return accu; }, {}); } else { - resultsAssignements = defineProperty({}, definition.resultName, defaultValue); + resultsAssignements = defineProperty({}, actionDefinition.resultName, defaultValue); } return resultsAssignements; } - }, - - /** - * Function that gets getActionDefinitions function and return the object of selector functions NOTIMPLEMENTED - * @param {function(array)} getActionDefinitions function that gets array of supported types as argument and returns (still nested in reducerNames) matching definitions - */ - selectorsAdapter: function selectorsAdapter(getActionDefinitions) { - var actionDefinitions = getActionDefinitions(['default']); - }, - - - /** - * Function that gets getActionDefinitions function and return the object of additional reduxBreeze methods NOTIMPLEMENTED - * @param {function(array)} getActionDefinitions function that gets array of supported types as argument and returns (still nested in reducerNames) matching definitions - * @returns {object} object of additional reduxBreeze methods - */ - additionalMethods: function additionalMethods(getActionDefinitions) { - return { - sayHello: function sayHello() { - console.log('hello'); - } - }; } }; }; @@ -515,7 +534,7 @@ var defaultConfig = { * @param {string} actionType action type name (like 'default' in default plugin) * @param {string} pluginName name of the plugin * @param {string} adapterType type of adapter: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter' - * @returns {*} + * @return {string} changed actionType */ mapActionTypes: function mapActionTypes(actionType, pluginName, adapterType) { return actionType; @@ -527,7 +546,8 @@ var tools = { createActionType: createActionType, chainReducers: chainReducers, mergePlugins: mergePlugins, - checkConflicts: checkConflicts + checkConflicts: checkConflicts, + immutablyCopyValue: immutablyCopyValue }; var createReduxBreezeInstance = function createReduxBreezeInstance(actionDefinitions) { @@ -535,11 +555,13 @@ var createReduxBreezeInstance = function createReduxBreezeInstance(actionDefinit plugins[_key - 2] = arguments[_key]; } - var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig; + var userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultConfig; + + var config = _extends({}, defaultConfig, userConfig); // merging plugins deeply var pluginsToMerge = config.useDefaultPlugin ? [createDefaultPlugin(tools)].concat(toConsumableArray(plugins.map(function (plugin) { - return plugin(tools); + return plugin(tools, config); }))) : plugins.map(function (plugin) { return plugin(tools); }); @@ -553,10 +575,10 @@ var createReduxBreezeInstance = function createReduxBreezeInstance(actionDefinit * Function to generate initialState (and immutably deeply merge it with custom initialState) from actions definitions * @param {object} actions object of action definitions * @param {object} initialState optional custom initial state + * @return {object} created initial state (merged with provided initialState) */ var createInitialState = function createInitialState(actions) { var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; - return _.reduce(actions, function (actionsState, actionDefinition, actionName) { if (plugin.initialStateAdapter[actionDefinition.type]) { return immutableSet(actionsState, plugin.initialStateAdapter[actionDefinition.type](actionDefinition, actionName)); @@ -571,7 +593,8 @@ var createReduxBreezeInstance = function createReduxBreezeInstance(actionDefinit var reducers = _.reduce(actionDefinitions, function (reducers, actions, reducerName) { // getting final initial state for this combined/chained reducer (triggering custom reducers to get their initial state) - var initialState = createInitialState(actions, reducers[reducerName] ? reducers[reducerName](undefined, {}) : {}); + var initialState = createInitialState(actions, reducers[reducerName] ? reducers[reducerName](undefined, {}) : {} // eslint-disable-line no-undefined + ); // creating array of reducers tha are going to be chained on the `reducerName` field var reducersToChain = _.map(actions, function (actionDefinition, actionName) { diff --git a/lib/reduxBreeze.mjs.map b/lib/reduxBreeze.mjs.map index 2e648df..871a19d 100644 --- a/lib/reduxBreeze.mjs.map +++ b/lib/reduxBreeze.mjs.map @@ -1 +1 @@ -{"version":3,"file":"reduxBreeze.mjs","sources":["../src/tools.js","../src/defaultPlugin.js","../src/index.js"],"sourcesContent":["import _ from 'lodash';\n\n/**\n * Helper for redux to attach reducers to one field instead of composing them into separate fields\n * @param {array} reducers\n * @return {function} reducer\n */\nexport const chainReducers = rawReducers => (state, action) => {\n const reducers = _.filter(rawReducers, reducer => {\n if (_.isNil(reducer)) {\n return false;\n }\n if (_.isFunction(reducer)) {\n return true;\n }\n throw new Error('reducers passed to chain reducers must be either a valida reducer (function) or nil (null or undefined)');\n });\n return reducers.reduce((accuState, reducer) => reducer(accuState, action), state);\n};\n\n/**\n * Checks if there are conflicts in plugins in given adapterType (conflict = two plugins handling same actionType)\n * @param {array} plugins list of plugins\n * @param {string} adapterType name of the adapter type: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter'\n * @param {function(actionType: string, pluginName: string, adapterType: string)} map function that changes actionTypes to a new values\n * @return {string} error text or empty string if no conflicts found\n */\nexport const checkConflicts = (plugins, adapterType, map = actionType => actionType) => {\n // TODO add checking for plugins having the same name\n const foundAdapters = {};\n plugins.forEach(plugin => {\n if (plugin[adapterType]) {\n _.forEach(plugin[adapterType], (adapter, actionType) => {\n const mappedActionType = map(actionType, plugin.name, adapterType);\n if (!foundAdapters[mappedActionType]) {\n foundAdapters[mappedActionType] = [];\n }\n foundAdapters[mappedActionType].push(plugin.name);\n });\n }\n });\n return _(foundAdapters)\n .map((listOfPlugins, actionType) => listOfPlugins.length > 1 ? `${adapterType} '${actionType}' is defined in plugins: ${listOfPlugins.join(',')}` : null)\n .filter()\n .join('; ');\n};\n\n/**\n * Function to merge different plugins into one plugin object\n * @param {array} plugins array of plugins objects\n * @param {boolean} strict with strict turned on we throw an error on plugin conflicts\n * @param {function} mapActionTypes function that changes names of action types\n * @returns {{actionAdapter, reducerAdapter, initialStateAdapter}} merged plugin object\n */\nexport const mergePlugins = (plugins, { strict = true, mapActionTypes = actionType => actionType } = {}) => {\n const actionAdapterConflicts = checkConflicts(plugins, 'actionAdapter', mapActionTypes);\n const reducerAdapterConflicts = checkConflicts(plugins, 'reducerAdapter', mapActionTypes);\n const initialStateAdapterConflicts = checkConflicts(plugins, 'initialStateAdapter', mapActionTypes);\n const conflicts = [];\n const conflictsVerbose = [];\n if (actionAdapterConflicts) {\n conflicts.push('actionAdapters');\n conflictsVerbose.push(actionAdapterConflicts);\n }\n if (reducerAdapterConflicts) {\n conflicts.push('reducerAdapters');\n conflictsVerbose.push(reducerAdapterConflicts);\n }\n if (initialStateAdapterConflicts) {\n conflicts.push('initialStateAdapters');\n conflictsVerbose.push(initialStateAdapterConflicts);\n }\n\n if (conflicts.length) {\n const errorMessage = `Conflicts in adapters: ${conflicts.join(', ')}. ${conflictsVerbose.join('. ')}.`;\n if (strict) {\n throw new Error(errorMessage);\n }\n console.warn(`${errorMessage} Duplicated adapters will be overwritten!`);\n }\n\n return {\n actionAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.actionAdapter, (accu, actionAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'actionAdapter')] = actionAdapter;\n return accu;\n }, {}),\n }), {}),\n reducerAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.reducerAdapter, (accu, reducerAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'reducerAdapter')] = reducerAdapter;\n return accu;\n }, {})\n }), {}),\n initialStateAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.initialStateAdapter, (accu, initialStateAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'initialStateAdapter')] = initialStateAdapter;\n return accu;\n }, {})\n }), {}),\n\n };\n};\n\n/**\n *\n * @param {string} actionName camelCase name of the action (e.g. someAction)\n * @param {string} suffix string that is going to be added at the end of the created action type\n * @param {string} prefix string that is going to be added at the beginning of the created action type\n * @returns {string} upperSnakeCase action type (e.g. SOME_ACTION or with example suffix SOME_ACTION_SUFFIX)\n */\nexport const createActionType = (actionName, suffix = '', prefix = '') => {\n const upperSnakeCase = _.snakeCase(actionName).toUpperCase();\n return `${prefix ? `${prefix.toUpperCase()}_` : ''}${upperSnakeCase}${suffix ? `_${suffix.toUpperCase()}` : ''}`;\n};\n\n/**\n * Works like lodash _.set() but does not mutate object (doesn't work with array style keys like `someArray[2].anotherField`)\n * @param {object} object source object\n * @param {string|{[string]: any}} path in object to set value in or object with paths as keys and values as values (if path is an object it ignores 'value')\n * @param {any} value to set in given path\n * @param {string} delimiter path delimiter; by default: '.'\n * @returns {object} new object with value(s) changed\n */\nexport const immutableSet = (object, path, value = null, delimiter = '.') => {\n // console.log('immutableSet', {object, path, value, delimiter});\n if (!path) {\n return value;\n }\n if (_.isPlainObject(path)) {\n if (_.isEmpty(path)) {\n return object;\n }\n return _.reduce(path, (accu, value, path) => immutableSet(accu, path, value, delimiter), object);\n }\n\n const pathSplit = path.split(delimiter);\n if (pathSplit.length === 1) {\n return {\n ...object,\n [path]: value,\n }\n }\n let childObject = {};\n if (_.has(object, pathSplit[0])) {\n childObject = object[pathSplit[0]];\n if (!_.isPlainObject(childObject)) {\n throw new Error(`Part of 'path' provided is defined in 'object' and is not a plain JS object but ${typeof childObject}. It's most likely an error. Check the path and object provided to immutableSet function`);\n }\n }\n return {\n ...object,\n [pathSplit[0]]: immutableSet(childObject, _.tail(pathSplit).join(delimiter), value, delimiter),\n };\n};\n","import _ from 'lodash';\n\nclass hasNotBeenDefined{};\n\nconst createDefaultPlugin = ({ createActionType, immutableSet }) => ({\n /**\n * Object of functions that gets `actionDefinition` and `actionName` as arguments and return action creator\n */\n actionAdapter: {\n default(definition, actionName, config) {\n return (params) => {\n return {\n type: createActionType(actionName),\n payload: params,\n }\n };\n },\n },\n\n /**\n * Object of functions that gets `actionDefinition`, `actionName`, and `initialState` and returns a reducer\n */\n reducerAdapter: {\n default(actionDefinition, actionName, initialState) {\n return (state = initialState, action) => {\n switch (action.type) {\n case createActionType(actionName):\n let resultsAssignements = {};\n if (Array.isArray(actionDefinition.result)) {\n resultsAssignements = actionDefinition.result.reduce(\n (accu, { sourcePath, targetPath, defaultValue = new hasNotBeenDefined() }) => {\n if (!(defaultValue instanceof hasNotBeenDefined) && _.isUndefined(_.get(action, sourcePath))) {\n accu[targetPath] = defaultValue;\n }\n accu[targetPath] = _.get(action, sourcePath);\n return accu;\n },\n {}\n );\n } else {\n resultsAssignements = {\n [actionDefinition.resultName]: action.payload,\n };\n }\n return immutableSet(state, resultsAssignements);\n default:\n return state;\n }\n };\n },\n },\n\n /**\n * Object of functions that gets `actionDefinition` and `actionName` as arguments and return assignment object (with keys = paths, values = values to be saved in those paths)\n */\n initialStateAdapter: {\n default (definition, actionName) {\n let resultsAssignements = null;\n let defaultValue;\n if (_.has(definition, 'initialValue')) {\n defaultValue = definition.initialValue;\n } else if (definition.result === 'list') {\n defaultValue = [];\n } else if (definition.result === 'entity') {\n defaultValue = null;\n }\n\n if (Array.isArray(definition.result)) {\n resultsAssignements = definition.result.reduce((accu, { targetPath, result, initialValue = new hasNotBeenDefined }) => {\n if (initialValue instanceof hasNotBeenDefined) {\n accu[targetPath] = result === 'list' ? [] : null;\n } else {\n accu[targetPath] = initialValue;\n }\n return accu;\n }, {});\n } else {\n resultsAssignements = { [definition.resultName]: defaultValue };\n }\n return resultsAssignements;\n },\n },\n\n /**\n * Function that gets getActionDefinitions function and return the object of selector functions NOTIMPLEMENTED\n * @param {function(array)} getActionDefinitions function that gets array of supported types as argument and returns (still nested in reducerNames) matching definitions\n */\n selectorsAdapter(getActionDefinitions) {\n const actionDefinitions = getActionDefinitions(['default']);\n\n },\n\n /**\n * Function that gets getActionDefinitions function and return the object of additional reduxBreeze methods NOTIMPLEMENTED\n * @param {function(array)} getActionDefinitions function that gets array of supported types as argument and returns (still nested in reducerNames) matching definitions\n * @returns {object} object of additional reduxBreeze methods\n */\n additionalMethods(getActionDefinitions) {\n return {\n sayHello() {\n console.log('hello');\n }\n };\n }\n});\n\nexport default createDefaultPlugin;\n","import _ from 'lodash';\nimport { combineReducers } from 'redux';\nimport { immutableSet, createActionType, chainReducers, mergePlugins, checkConflicts } from './tools';\nimport createDefaultPlugin from './defaultPlugin';\n\nconst defaultConfig = {\n useDefaultPlugin: true,\n strict: true,\n /**\n *\n * @param {string} actionType action type name (like 'default' in default plugin)\n * @param {string} pluginName name of the plugin\n * @param {string} adapterType type of adapter: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter'\n * @returns {*}\n */\n mapActionTypes(actionType, pluginName, adapterType) {\n return actionType;\n }\n};\n\nexport const tools = {\n immutableSet,\n createActionType,\n chainReducers,\n mergePlugins,\n checkConflicts,\n};\n\nconst createReduxBreezeInstance = (actionDefinitions, config = defaultConfig, ...plugins) => {\n // merging plugins deeply\n const pluginsToMerge = config.useDefaultPlugin\n ? [createDefaultPlugin(tools), ...plugins.map(plugin => plugin(tools))]\n : plugins.map(plugin => plugin(tools));\n\n const plugin = mergePlugins(\n pluginsToMerge,\n {\n strict: config.strict,\n mapActionTypes: config.mapActionTypes,\n }\n );\n\n /**\n * Function to generate initialState (and immutably deeply merge it with custom initialState) from actions definitions\n * @param {object} actions object of action definitions\n * @param {object} initialState optional custom initial state\n */\n const createInitialState = (actions, initialState = {}) => {\n return _.reduce(actions, (actionsState, actionDefinition, actionName) => {\n if (plugin.initialStateAdapter[actionDefinition.type]) {\n return immutableSet(actionsState, plugin.initialStateAdapter[actionDefinition.type](actionDefinition, actionName));\n }\n return actionsState;\n }, initialState);\n };\n\n return {\n combineReducers(customReducers = {}) {\n const reducers = _.reduce(actionDefinitions, (reducers, actions, reducerName) => {\n // getting final initial state for this combined/chained reducer (triggering custom reducers to get their initial state)\n const initialState = createInitialState(actions, reducers[reducerName] ? reducers[reducerName](undefined, {}) : {});\n\n // creating array of reducers tha are going to be chained on the `reducerName` field\n const reducersToChain = _.map(actions, (actionDefinition, actionName) => {\n if (plugin.reducerAdapter[actionDefinition.type]) {\n return plugin.reducerAdapter[actionDefinition.type](actionDefinition, actionName, initialState);\n }\n throw new Error(`Unknown type '${actionDefinition.type}' of action '${actionName}'. It's most likely because you did not install plugin to handle reducer for this type of actions`);\n });\n\n // adding custom reducer (if one has been provided) at the end of the chain for the user to be able to modify default behaviour\n if (reducers[reducerName]) {\n reducersToChain.push(reducers[reducerName]);\n }\n\n reducers[reducerName] = chainReducers(reducersToChain);\n return reducers;\n }, customReducers);\n return combineReducers(reducers);\n },\n getAction(actionName, config) {\n const actionGroup = _.find(actionDefinitions, (actionsList) => _.has(actionsList, actionName));\n if (!actionGroup) {\n throw new Error(`${actionName} action has not been found`);\n }\n if (!plugin.actionAdapter[actionGroup[actionName].type]) {\n throw new Error(`Unknown type '${actionGroup[actionName].type}' of '${actionName}' action. It's most likely because you did not install plugin to handle action creation for this type of actions`);\n }\n return plugin.actionAdapter[actionGroup[actionName].type](actionGroup[actionName], actionName, config);\n },\n getActionDefinitions() {\n return actionDefinitions;\n },\n getMergedPlugin() {\n return plugin;\n },\n };\n};\n\nexport default createReduxBreezeInstance;\n"],"names":["chainReducers","state","action","reducers","_","filter","rawReducers","isNil","reducer","isFunction","Error","reduce","accuState","checkConflicts","plugins","adapterType","map","actionType","foundAdapters","forEach","plugin","adapter","mappedActionType","name","push","listOfPlugins","length","join","mergePlugins","strict","mapActionTypes","actionAdapterConflicts","reducerAdapterConflicts","initialStateAdapterConflicts","conflicts","conflictsVerbose","errorMessage","warn","actionAdapter","accu","reducerAdapter","initialStateAdapter","createActionType","actionName","suffix","prefix","upperSnakeCase","snakeCase","toUpperCase","immutableSet","object","path","value","delimiter","isPlainObject","isEmpty","pathSplit","split","childObject","has","tail","hasNotBeenDefined","createDefaultPlugin","definition","config","params","actionDefinition","initialState","type","resultsAssignements","Array","isArray","result","sourcePath","targetPath","defaultValue","isUndefined","get","resultName","payload","initialValue","getActionDefinitions","actionDefinitions","log","defaultConfig","pluginName","tools","createReduxBreezeInstance","pluginsToMerge","useDefaultPlugin","createInitialState","actions","actionsState","customReducers","reducerName","undefined","reducersToChain","combineReducers","actionGroup","find","actionsList"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;;AAKA,AAAO,IAAMA,gBAAgB,SAAhBA,aAAgB;SAAe,UAACC,KAAD,EAAQC,MAAR,EAAmB;QACvDC,WAAWC,EAAEC,MAAF,CAASC,WAAT,EAAsB,mBAAW;UAC5CF,EAAEG,KAAF,CAAQC,OAAR,CAAJ,EAAsB;eACb,KAAP;;UAEEJ,EAAEK,UAAF,CAAaD,OAAb,CAAJ,EAA2B;eAClB,IAAP;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B,aAAP,CAAqB4D,YAAYvD,UAAZ,EAAwByB,IAA7C,CAAL,EAAyD;cACjD,IAAI1D,KAAJ,qBAA2BwF,YAAYvD,UAAZ,EAAwByB,IAAnD,gBAAgEzB,UAAhE,wHAAN;;aAEKvB,OAAOkB,aAAP,CAAqB4D,YAAYvD,UAAZ,EAAwByB,IAA7C,EAAmD8B,YAAYvD,UAAZ,CAAnD,EAA4EA,UAA5E,EAAwFqB,MAAxF,CAAP;KAhCG;wBAAA,kCAkCkB;aACdkB,iBAAP;KAnCG;mBAAA,6BAqCa;aACT9D,MAAP;;GAtCJ;CA5BF;;;;;"} \ No newline at end of file +{"version":3,"file":"reduxBreeze.mjs","sources":["../src/tools.js","../src/defaultPlugin.js","../src/index.js"],"sourcesContent":["import _ from 'lodash';\n\n/**\n * Helper for redux to attach reducers to one field instead of composing them into separate fields\n * @param {array} rawReducers array of unchained, not combined reducers\n * @return {function} reducer\n */\nexport const chainReducers = rawReducers => (state, action) => {\n const reducers = _.filter(rawReducers, reducer => {\n if (_.isNil(reducer)) {\n return false;\n }\n if (_.isFunction(reducer)) {\n return true;\n }\n throw new Error('reducers passed to chain reducers must be either a valida reducer (function) or nil (null or undefined)');\n });\n return reducers.reduce((accuState, reducer) => reducer(accuState, action), state);\n};\n\n/**\n * Checks if there are conflicts in plugins in given adapterType (conflict = two plugins handling same actionType)\n * @param {array} plugins list of plugins\n * @param {string} adapterType name of the adapter type: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter'\n * @param {function(actionType: string, pluginName: string, adapterType: string)} map function that changes actionTypes to a new values\n * @return {string} error text or empty string if no conflicts found\n */\nexport const checkConflicts = (plugins, adapterType, map = actionType => actionType) => {\n // TODO add checking for plugins having the same name\n const foundAdapters = {};\n plugins.forEach(plugin => {\n if (plugin[adapterType]) {\n _.forEach(plugin[adapterType], (adapter, actionType) => {\n const mappedActionType = map(actionType, plugin.name, adapterType);\n if (!foundAdapters[mappedActionType]) {\n foundAdapters[mappedActionType] = [];\n }\n foundAdapters[mappedActionType].push(plugin.name);\n });\n }\n });\n return _(foundAdapters)\n .map((listOfPlugins, actionType) => listOfPlugins.length > 1 ? `${adapterType} '${actionType}' is defined in plugins: ${listOfPlugins.join(',')}` : null)\n .filter()\n .join('; ');\n};\n\n/**\n * Function to merge different plugins into one plugin object\n * @param {array} plugins array of plugins objects\n * @param {boolean} strict with strict turned on we throw an error on plugin conflicts\n * @param {function} mapActionTypes function that changes names of action types\n * @return {{actionAdapter, reducerAdapter, initialStateAdapter}} merged plugin object\n */\nexport const mergePlugins = (plugins, { strict = true, mapActionTypes = actionType => actionType } = {}) => {\n const actionAdapterConflicts = checkConflicts(plugins, 'actionAdapter', mapActionTypes);\n const reducerAdapterConflicts = checkConflicts(plugins, 'reducerAdapter', mapActionTypes);\n const initialStateAdapterConflicts = checkConflicts(plugins, 'initialStateAdapter', mapActionTypes);\n const conflicts = [];\n const conflictsVerbose = [];\n if (actionAdapterConflicts) {\n conflicts.push('actionAdapters');\n conflictsVerbose.push(actionAdapterConflicts);\n }\n if (reducerAdapterConflicts) {\n conflicts.push('reducerAdapters');\n conflictsVerbose.push(reducerAdapterConflicts);\n }\n if (initialStateAdapterConflicts) {\n conflicts.push('initialStateAdapters');\n conflictsVerbose.push(initialStateAdapterConflicts);\n }\n\n if (conflicts.length) {\n const errorMessage = `Conflicts in adapters: ${conflicts.join(', ')}. ${conflictsVerbose.join('. ')}.`;\n if (strict) {\n throw new Error(errorMessage);\n }\n console.warn(`${errorMessage} Duplicated adapters will be overwritten!`);\n }\n\n return {\n actionAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.actionAdapter, (accu, actionAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'actionAdapter')] = actionAdapter;\n return accu;\n }, {}),\n }), {}),\n reducerAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.reducerAdapter, (accu, reducerAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'reducerAdapter')] = reducerAdapter;\n return accu;\n }, {}),\n }), {}),\n initialStateAdapter: plugins.reduce((actionAdapter, plugin) => ({\n ...actionAdapter,\n ..._.reduce(plugin.initialStateAdapter, (accu, initialStateAdapter, actionType) => {\n accu[mapActionTypes(actionType, plugin.name, 'initialStateAdapter')] = initialStateAdapter;\n return accu;\n }, {}),\n }), {}),\n\n };\n};\n\n/**\n *\n * @param {string} actionName camelCase name of the action (e.g. someAction)\n * @param {string} suffix string that is going to be added at the end of the created action type\n * @param {string} prefix string that is going to be added at the beginning of the created action type\n * @return {string} upperSnakeCase action type (e.g. SOME_ACTION or with example suffix SOME_ACTION_SUFFIX)\n */\nexport const createActionType = (actionName, suffix = '', prefix = '') => {\n const upperSnakeCase = _.snakeCase(actionName).toUpperCase();\n return `${prefix ? `${prefix.toUpperCase()}_` : ''}${upperSnakeCase}${suffix ? `_${suffix.toUpperCase()}` : ''}`;\n};\n\n/**\n * Works like lodash _.set() but does not mutate object (doesn't work with array style keys like `someArray[2].anotherField`)\n * @param {object} object source object\n * @param {string|object} path in object to set value in or object with paths as keys and values as values (if path is an object it ignores 'value')\n * @param {any} value to set in given path\n * @param {string} delimiter path delimiter; by default: '.'\n * @return {object} new object with value(s) changed\n */\nexport const immutableSet = (object, path, value = null, delimiter = '.') => {\n // console.log('immutableSet', {object, path, value, delimiter});\n if (!path) {\n return value;\n }\n if (_.isPlainObject(path)) {\n if (_.isEmpty(path)) {\n return object;\n }\n return _.reduce(path, (accu, value, path) => immutableSet(accu, path, value, delimiter), object);\n }\n\n const pathSplit = path.split(delimiter);\n if (pathSplit.length === 1) {\n return {\n ...object,\n [path]: value,\n };\n }\n let childObject = {};\n if (_.has(object, pathSplit[0])) {\n childObject = object[pathSplit[0]];\n if (!_.isPlainObject(childObject)) {\n throw new Error(`Part of 'path' provided is defined in 'object' and is not a plain JS object but ${typeof childObject}. It's most likely an error. Check the path and object provided to immutableSet function`);\n }\n }\n return {\n ...object,\n [pathSplit[0]]: immutableSet(childObject, _.tail(pathSplit).join(delimiter), value, delimiter),\n };\n};\n\n/**\n * Copy value from fromPath in fromObject and create new object from toObject with that value saved in toPath\n * @param {object} fromObject object which you get the value from\n * @param {string} fromPath path in fromObject where you get tha value from\n * @param {object} toObject object where you save the value to\n * @param {string} toPath path in toObject where you save the value\n * @return {object} new object created from values in toObject\n */\nexport const immutablyCopyValue = (fromObject, fromPath, toObject, toPath) => {\n return immutableSet(toObject, toPath, _.get(fromObject, fromPath));\n};\n","import _ from 'lodash';\n\nclass hasNotBeenDefined {}\n\nconst createDefaultPlugin = ({ createActionType, immutableSet }, config) => ({\n /**\n * Object of functions that gets `actionDefinition` and `actionName` as arguments and return action creator\n */\n actionAdapter: {\n default(actionDefinition, actionName) {\n return params => ({\n type: createActionType(actionName),\n payload: params,\n });\n },\n },\n\n /**\n * Object of functions that gets `actionDefinition`, `actionName`, and `initialState` and returns a reducer\n */\n reducerAdapter: {\n default(actionDefinition, actionName, initialState) {\n return (state = initialState, action) => {\n if (action.type === createActionType(actionName)) {\n let resultsAssignments;\n\n // result is array of assignments\n if (Array.isArray(actionDefinition.result)) {\n resultsAssignments = actionDefinition.result.reduce(\n (\n accu,\n {\n sourcePath,\n targetPath,\n defaultValue = new hasNotBeenDefined(),\n value = new hasNotBeenDefined(),\n }\n ) => {\n // setting default value if one has not been provided and defaultValue is defined\n if (\n !(defaultValue instanceof hasNotBeenDefined)\n && _.isUndefined(_.get(action, sourcePath))\n && value instanceof hasNotBeenDefined\n ) {\n accu[targetPath] = _.isFunction(defaultValue) ? defaultValue(action) : defaultValue;\n\n // setting value based on sourcePath\n } else if (value instanceof hasNotBeenDefined) {\n accu[targetPath] = _.get(action, _.isFunction(sourcePath) ? sourcePath(action) : sourcePath);\n\n // setting value calculated by a 'value' function\n } else if (_.isFunction(value)) {\n accu[targetPath] = value(action, _.get(state, targetPath));\n\n // setting hardcoded value from 'value' field in the definition\n } else {\n accu[targetPath] = value;\n }\n return accu;\n },\n {}\n );\n\n // result is a string ('list', 'entity') or is not provided\n } else {\n const resultName = actionDefinition.resultName || actionName;\n\n // setting default value if one has not been provided and defaultValue is defined\n if (\n _.has(actionDefinition, 'defaultValue')\n && _.isUndefined(action.payload)\n && _.has()\n ) {\n resultsAssignments = { [resultName]: actionDefinition.defaultValue };\n } else if (!_.has(actionDefinition, 'value')) {\n resultsAssignments = { [resultName]: action.payload };\n\n // setting value calculated by a 'value' function\n } else if (_.isFunction(actionDefinition.value)) {\n resultsAssignments = { [resultName]: actionDefinition.value(action, state[resultName]) };\n\n // setting hardcoded value from 'value' field in the definition\n } else {\n resultsAssignments = { [resultName]: actionDefinition.value };\n }\n }\n return immutableSet(state, resultsAssignments);\n }\n return state;\n };\n },\n },\n\n /**\n * Object of functions that gets `actionDefinition` and `actionName` as arguments and return assignment object (with keys = paths, values = values to be saved in those paths)\n */\n initialStateAdapter: {\n default(actionDefinition, actionName) {\n let resultsAssignements = null;\n let defaultValue;\n if (_.has(actionDefinition, 'initialValue')) {\n defaultValue = actionDefinition.initialValue;\n } else if (actionDefinition.result === 'list') {\n defaultValue = [];\n } else if (actionDefinition.result === 'entity') {\n defaultValue = null;\n }\n\n if (Array.isArray(actionDefinition.result)) {\n resultsAssignements = actionDefinition.result.reduce(\n (accu, { targetPath, result, initialValue = new hasNotBeenDefined() }) => {\n if (initialValue instanceof hasNotBeenDefined) {\n accu[targetPath] = result === 'list' ? [] : null;\n } else {\n accu[targetPath] = initialValue;\n }\n return accu;\n },\n {}\n );\n } else {\n resultsAssignements = { [actionDefinition.resultName]: defaultValue };\n }\n return resultsAssignements;\n },\n },\n});\n\nexport default createDefaultPlugin;\n","import _ from 'lodash';\nimport { combineReducers } from 'redux';\nimport {\n immutableSet,\n createActionType,\n chainReducers,\n mergePlugins,\n checkConflicts,\n immutablyCopyValue,\n} from './tools';\nimport createDefaultPlugin from './defaultPlugin';\n\nconst defaultConfig = {\n useDefaultPlugin: true,\n strict: true,\n /**\n *\n * @param {string} actionType action type name (like 'default' in default plugin)\n * @param {string} pluginName name of the plugin\n * @param {string} adapterType type of adapter: 'actionAdapter', 'reducerAdapter', 'initialStateAdapter'\n * @return {string} changed actionType\n */\n mapActionTypes(actionType, pluginName, adapterType) {\n return actionType;\n },\n};\n\nexport const tools = {\n immutableSet,\n createActionType,\n chainReducers,\n mergePlugins,\n checkConflicts,\n immutablyCopyValue,\n};\n\nconst createReduxBreezeInstance = (actionDefinitions, userConfig = defaultConfig, ...plugins) => {\n const config = {\n ...defaultConfig,\n ...userConfig,\n };\n\n // merging plugins deeply\n const pluginsToMerge = config.useDefaultPlugin\n ? [createDefaultPlugin(tools), ...plugins.map(plugin => plugin(tools, config))]\n : plugins.map(plugin => plugin(tools));\n\n const plugin = mergePlugins(\n pluginsToMerge,\n {\n strict: config.strict,\n mapActionTypes: config.mapActionTypes,\n }\n );\n\n /**\n * Function to generate initialState (and immutably deeply merge it with custom initialState) from actions definitions\n * @param {object} actions object of action definitions\n * @param {object} initialState optional custom initial state\n * @return {object} created initial state (merged with provided initialState)\n */\n const createInitialState = (actions, initialState = {}) => _.reduce(\n actions,\n (actionsState, actionDefinition, actionName) => {\n if (plugin.initialStateAdapter[actionDefinition.type]) {\n return immutableSet(\n actionsState,\n plugin.initialStateAdapter[actionDefinition.type](actionDefinition, actionName)\n );\n }\n return actionsState;\n },\n initialState\n );\n\n return {\n combineReducers(customReducers = {}) {\n const reducers = _.reduce(actionDefinitions, (reducers, actions, reducerName) => {\n // getting final initial state for this combined/chained reducer (triggering custom reducers to get their initial state)\n const initialState = createInitialState(\n actions,\n reducers[reducerName] ? reducers[reducerName](undefined, {}) : {} // eslint-disable-line no-undefined\n );\n\n // creating array of reducers tha are going to be chained on the `reducerName` field\n const reducersToChain = _.map(actions, (actionDefinition, actionName) => {\n if (plugin.reducerAdapter[actionDefinition.type]) {\n return plugin.reducerAdapter[actionDefinition.type](actionDefinition, actionName, initialState);\n }\n throw new Error(`Unknown type '${actionDefinition.type}' of action '${actionName}'. It's most likely because you did not install plugin to handle reducer for this type of actions`);\n });\n\n // adding custom reducer (if one has been provided) at the end of the chain for the user to be able to modify default behaviour\n if (reducers[reducerName]) {\n reducersToChain.push(reducers[reducerName]);\n }\n\n reducers[reducerName] = chainReducers(reducersToChain);\n return reducers;\n }, customReducers);\n return combineReducers(reducers);\n },\n getAction(actionName, config) {\n const actionGroup = _.find(actionDefinitions, actionsList => _.has(actionsList, actionName));\n if (!actionGroup) {\n throw new Error(`${actionName} action has not been found`);\n }\n if (!plugin.actionAdapter[actionGroup[actionName].type]) {\n throw new Error(`Unknown type '${actionGroup[actionName].type}' of '${actionName}' action. It's most likely because you did not install plugin to handle action creation for this type of actions`);\n }\n return plugin.actionAdapter[actionGroup[actionName].type](actionGroup[actionName], actionName, config);\n },\n getActionDefinitions() {\n return actionDefinitions;\n },\n getMergedPlugin() {\n return plugin;\n },\n };\n};\n\nexport default createReduxBreezeInstance;\n"],"names":["chainReducers","state","action","reducers","_","filter","rawReducers","isNil","reducer","isFunction","Error","reduce","accuState","checkConflicts","plugins","adapterType","map","actionType","foundAdapters","forEach","plugin","adapter","mappedActionType","name","push","listOfPlugins","length","join","mergePlugins","strict","mapActionTypes","actionAdapterConflicts","reducerAdapterConflicts","initialStateAdapterConflicts","conflicts","conflictsVerbose","errorMessage","warn","actionAdapter","accu","reducerAdapter","initialStateAdapter","createActionType","actionName","suffix","prefix","upperSnakeCase","snakeCase","toUpperCase","immutableSet","object","path","value","delimiter","isPlainObject","isEmpty","pathSplit","split","childObject","has","tail","immutablyCopyValue","fromObject","fromPath","toObject","toPath","get","hasNotBeenDefined","createDefaultPlugin","config","actionDefinition","params","initialState","type","resultsAssignments","Array","isArray","result","sourcePath","targetPath","defaultValue","isUndefined","resultName","payload","resultsAssignements","initialValue","defaultConfig","pluginName","tools","createReduxBreezeInstance","actionDefinitions","userConfig","pluginsToMerge","useDefaultPlugin","createInitialState","actions","actionsState","customReducers","reducerName","undefined","reducersToChain","combineReducers","actionGroup","find","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AAcoG,eAAd,CAAxB;eACOjG,QAAP;OArBe,EAsBd8F,cAtBc,CAAjB;aAuBOI,gBAAgBlG,QAAhB,CAAP;KAzBG;aAAA,qBA2BKwC,UA3BL,EA2BiB0B,MA3BjB,EA2ByB;UACtBiC,cAAclG,EAAEmG,IAAF,CAAOb,iBAAP,EAA0B;eAAetF,EAAEuD,GAAF,CAAM6C,WAAN,EAAmB7D,UAAnB,CAAf;OAA1B,CAApB;UACI,CAAC2D,WAAL,EAAkB;cACV,IAAI5F,KAAJ,CAAaiC,UAAb,gCAAN;;UAEE,CAACvB,OAAOkB,aAAP,CAAqBgE,YAAY3D,UAAZ,EAAwB8B,IAA7C,CAAL,EAAyD;cACjD,IAAI/D,KAAJ,qBAA2B4F,YAAY3D,UAAZ,EAAwB8B,IAAnD,gBAAgE9B,UAAhE,wHAAN;;aAEKvB,OAAOkB,aAAP,CAAqBgE,YAAY3D,UAAZ,EAAwB8B,IAA7C,EAAmD6B,YAAY3D,UAAZ,CAAnD,EAA4EA,UAA5E,EAAwF0B,MAAxF,CAAP;KAnCG;wBAAA,kCAqCkB;aACdqB,iBAAP;KAtCG;mBAAA,6BAwCa;aACTtE,MAAP;;GAzCJ;CAvCF;;;;;"} \ No newline at end of file diff --git a/package.json b/package.json index 4974386..dedb944 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "redux-breeze", - "version": "0.0.1", + "version": "0.0.1-rc.1", "description": "", "repository": { "type": "git", diff --git a/rollup.config.js b/rollup.config.js index 2ae084f..d9931a2 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -16,6 +16,7 @@ export default { globals: { lodash: '_', debug: 'debug', + redux: 'redux', }, output: [ {