import type * as core from '@contentlayer/core' ; import type { Thunk } from '@contentlayer/utils' ; import type { ComputedField } from './computed-field.js' ; import type { FieldDef , FieldDefWithName } from './field.js' ; export * from './field.js' ; export type SchemaDef = { documentTypeDefs : DocumentTypeDef [ ] ; } ; export type DocumentBodyType = 'markdown' | 'mdx' | 'none' ; export type TypeExtensions < DefName extends string = string > = { stackbit ? : core . StackbitExtension . TypeExtension < DefName > ; } ; export type FieldDefs = Record < string , FieldDef > | FieldDefWithName [ ] ; export type DocumentTypeDef < DefName extends string = string > = { name : DefName ; description ? : string ; /**
     * The field definitions can either be provided as an embedded with the field names as keys or
     * as an array of all field definitions including the name as an extra field. (The array definition
     * can be used if you want more control over the order of the fields.)
     */ fields : FieldDefs ; computedFields ? : ComputedFields < DefName > ; /** Path is relative to the `contentDirPath` config */ filePathPattern ? : string ; /**
     * Default is `markdown`
     *
     * Choose `none` e.g. for a `.json` or `.yaml` file
     */ bodyType ? : DocumentBodyType ; isSingleton ? : boolean ; extensions ? : TypeExtensions < DefName > ; } ; export type ComputedFields < DefName extends string = string > = Record < string , ComputedField < DefName > > ; export type NestedTypeDef < DefName extends string = string > = { name : DefName ; description ? : string ; fields : FieldDefs ; extensions ? : TypeExtensions < DefName > ; } ; export const isNestedTypeDef = ( _ ) : _ is NestedTypeDef => _ . hasOwnProperty ( 'name' ) ; export type NestedUnnamedTypeDef = { fields : FieldDefs ; extensions ? : TypeExtensions ; } ; export const isNestedUnnamedTypeDef = ( _ ) : _ is NestedUnnamedTypeDef => ! _ . hasOwnProperty ( 'name' ) ; export type NestedType < DefName extends string = string > = { type : 'nested' ; def : Thunk < NestedTypeDef < DefName > | NestedUnnamedTypeDef > ; } ; export type DocumentType < DefName extends string = string > = { type : 'document' ; def : Thunk < DocumentTypeDef < DefName > > ; } ; export type DocumentTypes = DocumentType < any > [ ] | Record < string , DocumentType < any > > ; export const defineNestedType = < DefName extends string > ( def ) : NestedType => ( { type : 'nested' , def , } ) ; export const defineDocumentType = < DefName extends string > ( def ) : DocumentType => ( { type : 'document' , def , } ) ;