@8base/utils
Advanced tools
Comparing version 0.4.18 to 0.4.19
@@ -404,2 +404,4 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
var formatDataForMutation_formatDataForMutation = function formatDataForMutation(type, tableName, data, schema) { | ||
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}; | ||
if (external_ramda_["not"](type in MUTATION_TYPE)) { | ||
@@ -423,5 +425,13 @@ throw new Error('Invalid mutation type: ' + type); | ||
if (!fieldSchema) { | ||
throw new Error('Field schema with ' + fieldName + ' name not found in table schema with ' + tableSchema.name + ' name.'); | ||
// throw new Error(`Field schema with ${fieldName} name not found in table schema with ${tableSchema.name} name.`); | ||
return result; | ||
} | ||
var skip = options.skip; | ||
if (typeof skip === 'function' && skip(data[fieldName], fieldSchema)) { | ||
return result; | ||
} | ||
if (isMetaField(fieldSchema)) { | ||
@@ -431,3 +441,12 @@ return result; | ||
return Object.assign({}, result, _defineProperty({}, fieldName, formatFieldDataForMutation_formatFieldDataForMutation(type, fieldSchema, data[fieldName], schema))); | ||
var formatedFieldData = formatFieldDataForMutation_formatFieldDataForMutation(type, fieldSchema, data[fieldName], schema); | ||
var mutate = options.mutate; | ||
if (typeof mutate === 'function') { | ||
formatedFieldData = mutate(formatedFieldData, data[fieldName], fieldSchema); | ||
} | ||
return Object.assign({}, result, _defineProperty({}, fieldName, formatedFieldData)); | ||
}, {}, external_ramda_["keys"](data)); | ||
@@ -434,0 +453,0 @@ |
{ | ||
"name": "@8base/utils", | ||
"version": "0.4.18", | ||
"version": "0.4.19", | ||
"main": "lib/utils.js", | ||
@@ -9,3 +9,3 @@ "scripts": { | ||
"test": "NPM_ENV=test jest", | ||
"watch": "NODE_ENV=development babel src -d es --watch --ignore __tests__" | ||
"watch": "webpack --progress --colors --watch --env dev" | ||
}, | ||
@@ -23,3 +23,3 @@ "jest": { | ||
"devDependencies": { | ||
"@8base/webpack-configuration": "^0.4.18", | ||
"@8base/webpack-configuration": "^0.4.19", | ||
"babel-cli": "^6.26.0", | ||
@@ -26,0 +26,0 @@ "babel-core": "^6.26.3", |
@@ -17,3 +17,3 @@ //@flow | ||
*/ | ||
const formatDataForMutation = (type: MutationType, tableName: string, data: Object, schema: Schema) => { | ||
const formatDataForMutation = (type: MutationType, tableName: string, data: Object, schema: Schema, options: Object = {}) => { | ||
if (R.not(type in MUTATION_TYPE)) { | ||
@@ -37,5 +37,12 @@ throw new Error(`Invalid mutation type: ${type}`); | ||
if (!fieldSchema) { | ||
throw new Error(`Field schema with ${fieldName} name not found in table schema with ${tableSchema.name} name.`); | ||
// throw new Error(`Field schema with ${fieldName} name not found in table schema with ${tableSchema.name} name.`); | ||
return result; | ||
} | ||
const { skip } = options; | ||
if (typeof skip === 'function' && skip(data[fieldName], fieldSchema)) { | ||
return result; | ||
} | ||
if (isMetaField(fieldSchema)) { | ||
@@ -45,5 +52,13 @@ return result; | ||
let formatedFieldData = formatFieldDataForMutation(type, fieldSchema, data[fieldName], schema); | ||
const { mutate } = options; | ||
if (typeof mutate === 'function') { | ||
formatedFieldData = mutate(formatedFieldData, data[fieldName], fieldSchema); | ||
} | ||
return { | ||
...result, | ||
[fieldName]: formatFieldDataForMutation(type, fieldSchema, data[fieldName], schema), | ||
[fieldName]: formatedFieldData, | ||
}; | ||
@@ -50,0 +65,0 @@ }, {}, R.keys(data)); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
299738
775