import { CMSType , EntityValues , Property , PropertyOrBuilder } from "../../models" ; import { mergeDeep } from "./objects" ; export function buildPropertyFrom < T extends CMSType , M extends { [ Key ] : any ; } > ( { propertyOrBuilder , values , path , entityId , propertyOverride } ) { let result ; if ( typeof propertyOrBuilder === "function" ) { result = propertyOrBuilder ( { values , entityId , path } ) ; if ( ! result ) { console . error ( "Wrong function" , path , entityId , propertyOrBuilder ) ; throw Error ( "Not returning property from property builder" ) ; } } else { result = propertyOrBuilder ; } if ( propertyOverride ) result = mergeDeep ( result , propertyOverride ) ; return result ; }