/** * Stackbit Model Types */ import type { Field, FieldExtension, FieldGroupItem, DocumentPreview, DocumentFieldPreview, PreviewFields, ClientField } from './model-fields'; import { ModelPermissions, ModelPermissionsFunction } from './content-permissions'; import type { Document } from './content-source-document'; import { CustomActionClientModel, CustomActionDocument, CustomActionModel, CustomActionModelObject, CustomActionObjectModel } from './custom-actions'; export type Model = ObjectModel | DataModel | PageModel | ConfigModel; export type ModelWithSource = ModelType & { srcType: string; srcProjectId: string; }; export type ClientModel = ObjectClientModel | DataClientModel | PageClientModel | ConfigClientModel; export type NamelessModelMap = Record; export type NamelessModel = DistributeNamelessModels; export type DistributeNamelessModels = Type extends Model ? Omit : never; export type DistributeModelExtensions = Type extends Model ? Partial> & { name: string; fields?: FieldExtension[]; } & { srcType?: string; srcProjectId?: string; } : never; export type ModelExtension = DistributeModelExtensions; export interface ModelCommonFields { /** * The name of the model, must be unique. * When extending content source models using the {@link Config.modelExtensions} * property, set it to the unique name or the unique ID of the model as it * appear in the CMS. **/ name: string; /** The label of the model. If not specified, the name will be title cased. */ label?: string; description?: string; thumbnail?: string; /** @deprecated */ extends?: string | string[]; readOnly?: boolean; labelField?: string; /** @deprecated */ variantField?: string; groups?: string[]; fieldGroups?: FieldGroupItem[]; fields?: Field[]; context?: ModelContext; hidden?: boolean; permissions?: ModelPermissionsFunction | ModelPermissions; } export interface ModelMatchFields { singleInstance?: boolean; file?: string; folder?: string; match?: string | string[]; exclude?: string | string[]; } export interface ObjectModel extends ModelCommonFields { type: 'object'; preview?: DocumentFieldPreview; actions?: (CustomActionObjectModel | CustomActionModelObject)[]; } export type ObjectClientModel = Omit & { preview?: PreviewFields; actions?: CustomActionClientModel[]; fields: ClientField[]; permissions?: ModelPermissions; }; /** @deprecated */ export interface ConfigModel extends ModelCommonFields, ModelLocalized { type: 'config'; file?: string; } /** @deprecated */ export type ConfigClientModel = Omit & { preview?: PreviewFields; actions?: CustomActionClientModel[]; fields: ClientField[]; permissions?: ModelPermissions; }; export interface PageModel extends ModelCommonFields, ModelMatchFields, ModelLocalized { type: 'page'; /** @deprecated */ layout?: string; /** * @deprecated * Use the {@link StackbitConfig.sitemap} function to define the relations * between documents representing website pages and their URL. */ urlPath?: string; /** The filePath property should be used with git-cms models only. */ filePath?: string | DocumentFilePathFunction; /** * By default, the markdown content below the frontmatter in .md files will * be exposed under the 'markdown_content' markdown field. * If the content of the .md file does not need to be edited, * set this property to false. * This property should be used with git-cms models only. */ hideContent?: boolean; preview?: DocumentPreview; actions?: (CustomActionDocument | CustomActionModel)[]; canDelete?: boolean; } export type PageClientModel = Omit & { preview?: PreviewFields; actions?: CustomActionClientModel[]; filePath?: string; fields: ClientField[]; permissions?: ModelPermissions; }; export interface DataModel extends ModelCommonFields, ModelMatchFields, ModelLocalized { type: 'data'; /** The filePath property should be used with git-cms models only. */ filePath?: string | DocumentFilePathFunction; preview?: DocumentPreview; actions?: (CustomActionDocument | CustomActionModel)[]; canDelete?: boolean; } export type DataClientModel = Omit & { preview?: PreviewFields; actions?: CustomActionClientModel[]; fields: ClientField[]; permissions?: ModelPermissions; }; export interface ModelLocalized { /** * Boolean flag indicating if documents belonging to this model are localized. * If localized is set to true, provide the `locale` function to set the * document `locale` */ localized?: boolean; /** * The `locale` function should return the locale for the passed `document`. */ locale?: (options: { document: Document; /** * The model of the passed `document`. */ model: DataModel | PageModel; }) => string; } export type DocumentFilePathFunction = (options: { data: Record; model: DataModel | PageModel; currentLocale?: string; }) => Promise; //# sourceMappingURL=models.d.ts.map