@8base/utils
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -23,2 +23,5 @@ "use strict"; | ||
}; | ||
const isFieldRemoved = ({ initialValue, value }) => { | ||
return !R.isNil(initialValue) && R.isNil(value); | ||
}; | ||
/** | ||
@@ -44,2 +47,3 @@ * Formats entity data for create or update mutation based on passed schema. | ||
options = R.mergeDeepRight(DEFAULT_OPTIONS, options); | ||
const dataKeys = R.pipe(R.mergeRight(data), R.keys)(initialData); | ||
const formatedData = R.reduce((result, fieldName) => { | ||
@@ -65,4 +69,6 @@ if (fieldName === '_description' || | ||
} | ||
let formatedFieldData = data[fieldName]; | ||
const initialFieldData = R.path([fieldName], initialData); | ||
let formatedFieldData = isFieldRemoved({ initialValue: initialFieldData, value: data[fieldName] }) | ||
? null | ||
: data[fieldName]; | ||
if ((verifiers_1.isFileField(fieldSchema) || verifiers_1.isRelationField(fieldSchema)) && verifiers_1.isListField(fieldSchema)) { | ||
@@ -88,3 +94,3 @@ if (R.isNil(formatedFieldData)) { | ||
return Object.assign({}, result, { [fieldName]: formatedFieldData }); | ||
}, {}, R.keys(data)); | ||
}, {}, dataKeys); | ||
return omitDeep_1.omitDeep(['_description', '__typename'], formatedData); | ||
@@ -91,0 +97,0 @@ }; |
{ | ||
"name": "@8base/utils", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"repository": "https://github.com/8base/sdk", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/8base/sdk/tree/master/packages/utils#readme", |
@@ -26,2 +26,6 @@ import * as R from 'ramda'; | ||
const isFieldRemoved = ({ initialValue, value }: { initialValue: any; value: any }) => { | ||
return !R.isNil(initialValue) && R.isNil(value); | ||
}; | ||
/** | ||
@@ -61,2 +65,7 @@ * Formats entity data for create or update mutation based on passed schema. | ||
const dataKeys = R.pipe( | ||
R.mergeRight(data), | ||
R.keys, | ||
)(initialData); | ||
const formatedData = R.reduce( | ||
@@ -91,5 +100,8 @@ (result: { [key: string]: any }, fieldName: string) => { | ||
let formatedFieldData = data[fieldName]; | ||
const initialFieldData = R.path([fieldName], initialData); | ||
let formatedFieldData = isFieldRemoved({ initialValue: initialFieldData, value: data[fieldName] }) | ||
? null | ||
: data[fieldName]; | ||
if ((isFileField(fieldSchema) || isRelationField(fieldSchema)) && isListField(fieldSchema)) { | ||
@@ -127,3 +139,3 @@ if (R.isNil(formatedFieldData)) { | ||
{}, | ||
R.keys(data) as string[], | ||
dataKeys, | ||
); | ||
@@ -130,0 +142,0 @@ |
Sorry, the diff of this file is not supported yet
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
290284
4745