import { ModelValueType } from './glossary' ; import { ManyOf , OneOf , Relation , RelationKind } from './relations/Relation' ; export type NullableGetter < ValueType extends ModelValueType > = ( ) => ValueType | null ; export class NullableProperty < ValueType extends ModelValueType > { public getValue : NullableGetter < ValueType > ; constructor ( getter ) { this . getValue = getter ; } } export function nullable < ValueType extends ModelValueType > ( value ) ; export function nullable < ValueType extends Relation < any , any , any , { nullable : false ; } > > ( value ) ; export function nullable ( value ) { if ( typeof value === 'function' ) { return new NullableProperty ( value ) ; } return new Relation ( { kind : value . kind , to : value . target . modelName , attributes : { ... value . attributes , nullable : true } } ) ; }