@8base/utils
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -0,1 +1,3 @@ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
import * as R from 'ramda'; | ||
@@ -5,2 +7,3 @@ | ||
import { getFieldSchemaByName, getTableSchemaByName } from '../selectors'; | ||
import { isMetaField } from '../verifiers'; | ||
import { formatFieldDataForMutation } from './formatFieldDataForMutation'; | ||
@@ -27,3 +30,7 @@ | ||
var formatedData = R.mapObjIndexed(function (data, fieldName) { | ||
var formatedData = R.reduce(function (result, fieldName) { | ||
if (fieldName === '_description' || fieldName === '__typename') { | ||
return result; | ||
} | ||
var fieldSchema = getFieldSchemaByName(fieldName, tableSchema); | ||
@@ -35,5 +42,9 @@ | ||
return formatFieldDataForMutation(type, fieldSchema, data, schema); | ||
}, data); | ||
if (isMetaField(fieldSchema)) { | ||
return result; | ||
} | ||
return Object.assign({}, result, _defineProperty({}, fieldName, formatFieldDataForMutation(type, fieldSchema, data[fieldName], schema))); | ||
}, {}, R.keys(data)); | ||
return formatedData; | ||
@@ -40,0 +51,0 @@ }; |
@@ -5,4 +5,5 @@ export { isFileField } from './isFileField'; | ||
export { isListField } from './isListField'; | ||
export { isMetaField } from './isMetaField'; | ||
export { isRelationField } from './isRelationField'; | ||
export { isRelationInstance } from './isRelationInstance'; | ||
export { isRelationReference } from './isRelationReference'; |
{ | ||
"name": "@8base/utils", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"main": "es/index.js", | ||
@@ -5,0 +5,0 @@ "module": "es/index.js", |
@@ -6,2 +6,3 @@ //@flow | ||
import { getFieldSchemaByName, getTableSchemaByName } from '../selectors'; | ||
import { isMetaField } from '../verifiers'; | ||
import { formatFieldDataForMutation } from './formatFieldDataForMutation'; | ||
@@ -28,15 +29,23 @@ import type { MutationType, FieldSchema, TableSchema, Schema } from '../types'; | ||
const formatedData = R.mapObjIndexed( | ||
(data: Object, fieldName: string) => { | ||
const fieldSchema: ?FieldSchema = getFieldSchemaByName(fieldName, tableSchema); | ||
const formatedData = R.reduce((result: Object, fieldName: string) => { | ||
if (fieldName === '_description' || fieldName === '__typename') { | ||
return result; | ||
} | ||
if (!fieldSchema) { | ||
throw new Error(`Field schema with ${fieldName} name not found in table schema with ${tableSchema.name} name.`); | ||
} | ||
const fieldSchema: ?FieldSchema = getFieldSchemaByName(fieldName, tableSchema); | ||
return formatFieldDataForMutation(type, fieldSchema, data, schema); | ||
}, | ||
data, | ||
); | ||
if (!fieldSchema) { | ||
throw new Error(`Field schema with ${fieldName} name not found in table schema with ${tableSchema.name} name.`); | ||
} | ||
if (isMetaField(fieldSchema)) { | ||
return result; | ||
} | ||
return { | ||
...result, | ||
[fieldName]: formatFieldDataForMutation(type, fieldSchema, data[fieldName], schema), | ||
}; | ||
}, {}, R.keys(data)); | ||
return formatedData; | ||
@@ -43,0 +52,0 @@ }; |
@@ -5,4 +5,5 @@ export { isFileField } from './isFileField'; | ||
export { isListField } from './isListField'; | ||
export { isMetaField } from './isMetaField'; | ||
export { isRelationField } from './isRelationField'; | ||
export { isRelationInstance } from './isRelationInstance'; | ||
export { isRelationReference } from './isRelationReference'; |
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
222787
48
480