import type { NestedUnnamedTypeDef } from './index.js' ; export type FieldDefType = FieldDef [ 'type' ] ; export type FieldDef = ListFieldDef | ListPolymorphicFieldDef | StringFieldDef | NumberFieldDef | BooleanFieldDef | JSONFieldDef | DateFieldDef | MarkdownFieldDef | MDXFieldDef | EnumFieldDef | NestedFieldDef | NestedPolymorphicFieldDef | NestedUnnamedFieldDef | ReferenceFieldDef | ReferencePolymorphicFieldDef ; export interface FieldDefBase { /** Field name should contain only alphanumeric characters, underscore and a hyphen [A-Za-z0-9_]. Must start with a letter. Must not end with an underscore or a hyphen. */ name : string ; /** Short description to editors how the field is to be used */ description : string | undefined ; /**
     * Default: false
     */ isRequired : boolean ; isSystemField : boolean ; } export interface ListFieldDef extends FieldDefBase { type : 'list' ; default : readonly any [ ] | undefined ; of : ListFieldDefItem . Item ; } export const isListFieldDef = ( _ ) : _ is ListFieldDef => _ . type === 'list' ; export interface ListPolymorphicFieldDef extends FieldDefBase { type : 'list_polymorphic' ; default : readonly any [ ] | undefined ; of : readonly ListFieldDefItem . Item [ ] ; /** Field needed to distinguish list data items at run time */ typeField : string ; } export namespace ListFieldDefItem { export type Item = ItemString | ItemEnum | ItemBoolean | ItemNested | ItemNestedUnnamed | ItemReference ; type BaseItem = { } ; export type ItemString = BaseItem & { type : 'string' ; } ; export type ItemEnum = BaseItem & { type : 'enum' ; options : readonly string [ ] ; } ; export type ItemBoolean = BaseItem & { type : 'boolean' ; } ; export type ItemNested = BaseItem & { type : 'nested' ; nestedTypeName : string ; } ; export type ItemNestedUnnamed = BaseItem & { type : 'nested_unnamed' ; typeDef : NestedUnnamedTypeDef ; } ; export const isDefItemNested = ( _ ) : _ is ItemNested => _ . type === 'nested' ; export type ItemReference = BaseItem & { type : 'reference' ; documentTypeName : string ; experimental default embedDocument : boolean ; } ; export const isDefItemReference = ( _ ) : _ is ItemReference => _ . type === 'reference' ; } export type StringFieldDef = FieldDefBase & { type : 'string' ; default : string | undefined ; } ; export type NumberFieldDef = FieldDefBase & { type : 'number' ; default : number | undefined ; } ; export type BooleanFieldDef = FieldDefBase & { type : 'boolean' ; default : boolean | undefined ; } ; export type JSONFieldDef = FieldDefBase & { type : 'json' ; default : any | undefined ; } ; export type SlugFieldDef = FieldDefBase & { type : 'slug' ; default : string | undefined ; } ; export type DateFieldDef = FieldDefBase & { type : 'date' ; default : string | undefined ; } ; export type MarkdownFieldDef = FieldDefBase & { type : 'markdown' ; default : string | undefined ; } ; export type MDXFieldDef = FieldDefBase & { type : 'mdx' ; default : string | undefined ; } ; export type TextFieldDef = FieldDefBase & { type : 'text' ; default : string | undefined ; } ; export type ImageFieldDef = FieldDefBase & { type : 'image' ; default : string | undefined ; } ; export type UrlFieldDef = FieldDefBase & { type : 'url' ; default : string | undefined ; } ; export type EnumFieldDef = FieldDefBase & { type : 'enum' ; default : string | undefined ; options : readonly string [ ] ; } ; export type NestedFieldDef = FieldDefBase & { type : 'nested' ; default : any | undefined ; /** References entry in NestedDefMap */ nestedTypeName : string ; } ; export const isNestedFieldDef = ( _ ) : _ is NestedFieldDef => _ . type === 'nested' ; export type NestedPolymorphicFieldDef = FieldDefBase & { type : 'nested_polymorphic' ; default : any | undefined ; /** References entries in NestedDefMap */ nestedTypeNames : readonly string [ ] ; /** Field needed to distinguish list data items at run time */ typeField : string ; } ; export const isNestedPolymorphicFieldDef = ( _ ) : _ is NestedPolymorphicFieldDef => _ . type === 'nested_polymorphic' ; export type NestedUnnamedFieldDef = FieldDefBase & { type : 'nested_unnamed' ; default : any | undefined ; typeDef : NestedUnnamedTypeDef ; } ; export const isNestedUnnamedFieldDef = ( _ ) : _ is NestedUnnamedFieldDef => _ . type === 'nested_unnamed' ; export type ReferenceFieldDef = FieldDefBase & { type : 'reference' ; default : string | undefined ; documentTypeName : string ; experimental default embedDocument : boolean ; } ; export type ReferencePolymorphicFieldDef = FieldDefBase & { type : 'reference_polymorphic' ; default : string | undefined ; documentTypeNames : readonly string [ ] ; /** Field needed to distinguish list data items at run time */ typeField : string ; } ; export const isReferenceField = ( _ ) : _ is ReferenceFieldDef => _ . type === 'reference' ;