import { CmsFieldTypePlugins , CmsModel , CmsModelFieldDefinition , CmsModelFieldToGraphQLPlugin } from "~/types" ; interface RenderFields { ( params ) : CmsModelFieldDefinition [ ] ; } export const renderFields = ( { model , type , fieldTypePlugins } ) => { return model . fields . map ( field => renderField ( { model , type , field , fieldTypePlugins } ) ) . filter ( Boolean ) ; } ; export const renderField = ( { model , type , field , fieldTypePlugins } ) => { const plugin = fieldTypePlugins [ field . type ] ; if ( ! plugin ) { return ; } const defs = plugin [ type ] . createTypeField ( { model , field , fieldTypePlugins } ) ; if ( ! defs ) { return null ; } else if ( typeof defs === "string" ) { return { fields : defs } ; } return defs ; } ;