UNPKG

contentful-orm

Version:

A TypeScript-first ORM for Contentful CMS that enables a code-first approach to content modeling

59 lines (58 loc) 2.08 kB
import { ContentfulField, ContentfulValidation, ContentfulEnvironmentId, ContentfulSpaceId } from './contentful.js'; export declare const ContentfulFieldType: { readonly Symbol: "Symbol"; readonly Text: "Text"; readonly RichText: "RichText"; readonly Number: "Number"; readonly Integer: "Integer"; readonly Date: "Date"; readonly Location: "Location"; readonly Media: "Media"; readonly Boolean: "Boolean"; readonly Reference: "Reference"; readonly Array: "Array"; readonly Object: "Object"; }; export type ContentfulFieldTypeValues = typeof ContentfulFieldType[keyof typeof ContentfulFieldType]; export interface ContentTypeOptions { name: string; displayField: string; description?: string; } export interface BaseFieldOptions { required?: boolean; localized?: boolean; validations?: ContentfulValidation[]; defaultValue?: any; disabled?: boolean; omitted?: boolean; } export interface LinkFieldOptions extends BaseFieldOptions { type: typeof ContentfulFieldType.Reference | typeof ContentfulFieldType.Media; linkType: 'Entry' | 'Asset'; validations?: (ContentfulValidation & { linkContentType?: string[]; linkMimetypeGroup?: string[]; })[]; } export interface MediaFieldOptions extends LinkFieldOptions { type: typeof ContentfulFieldType.Media; linkType: 'Asset'; validations?: (ContentfulValidation & { linkMimetypeGroup?: string[]; })[]; } export interface ArrayFieldOptions extends BaseFieldOptions { type: typeof ContentfulFieldType.Array; itemsType: ContentfulFieldTypeValues; itemsLinkType?: 'Entry' | 'Asset'; itemsValidations?: ContentfulValidation[]; } export interface FieldOptions extends BaseFieldOptions { type: ContentfulFieldTypeValues; itemsType?: ContentfulFieldTypeValues; itemsLinkType?: 'Entry' | 'Asset'; itemsValidations?: ContentfulValidation[]; linkType?: 'Entry' | 'Asset'; } export type { ContentfulField, ContentfulValidation, ContentfulEnvironmentId, ContentfulSpaceId };