import {field} from '../field' import {mergeConfig} from '../../configStore' import type {ReferenceField, FieldReturn} from '../../types' export const reference = ( types: string[] | string, props?: ReferenceField, mergeProps?: Partial, ): FieldReturn => { const typesArray = Array.isArray(types) ? types : [types] const name = props?.name || typesArray[0] const to = typesArray.map((type) => ({type})) return field('reference', { ...mergeConfig('slug', props, mergeProps), to, name, }) }