import { withFields , string , fields , onSet } from "@commodo/fields" ; import { object } from "commodo-fields-object" ; import trimEnd from "lodash/trimEnd" ; const trimTrailingSlashes = value => trimEnd ( value , "/" ) ; const extractPid = ( value ) : string => { if ( typeof value !== "string" ) { return null ; } const [ pid ] = value . split ( "#" ) ; return pid || null ; } ; export default withFields ( { name : string ( { validation : "required,maxLength:500" } ) , websiteUrl : onSet ( trimTrailingSlashes ) ( string ( { validation : "url,maxLength:500" } ) ) , websitePreviewUrl : onSet ( trimTrailingSlashes ) ( string ( { validation : "url,maxLength:500" } ) ) , favicon : object ( { } ) , logo : object ( { } ) , prerendering : fields ( { instanceOf : withFields ( { app : fields ( { instanceOf : withFields ( { url : onSet ( trimTrailingSlashes ) ( string ( { validation : "url" } ) ) } ) ( ) } ) , storage : fields ( { instanceOf : withFields ( { name : string ( { validation : "maxLength:500" } ) } ) ( ) } ) , meta : object ( ) } ) ( ) } ) , social : fields ( { value : { } , instanceOf : withFields ( { facebook : string ( { validation : "url,maxLength:500" } ) , twitter : string ( { validation : "url,maxLength:500" } ) , instagram : string ( { validation : "url,maxLength:500" } ) , image : object ( { } ) } ) ( ) } ) , pages : fields ( { value : { } , instanceOf : withFields ( { home : onSet ( extractPid ) ( string ( ) ) , notFound : onSet ( extractPid ) ( string ( ) ) } ) ( ) } ) , theme : string ( ) } ) ( ) ;