import { AnyContentType, PermittedTypes } from './contentTypes.js'; import { PropertyGroupKey } from './buildConfig.js'; /** All possible content type properties */ export type AnyProperty = ArrayProperty | ArrayItems; export type INDEX_TYPE = 'disabled' | 'queryable' | 'searchable'; /** A "Base" content type property that includes all common attributes for all content type properties */ type BaseProperty = { format?: string; displayName?: string; description?: string; isRequired?: boolean; isLocalized?: boolean; group?: PropertyGroupKey; sortOrder?: number; indexingType?: INDEX_TYPE; }; type WithEnum = { enum?: { value: T; displayName: string; }[]; }; export type ArrayProperty = BaseProperty & { type: 'array'; items: T; minItems?: number; maxItems?: number; }; export type ArrayItems = StringProperty | BooleanProperty | BinaryProperty | JsonProperty | DateTimeProperty | RichTextProperty | UrlProperty | IntegerProperty | FloatProperty | ContentReferenceProperty | ContentProperty | ComponentProperty | LinkProperty; /** Represents the content type property "String" */ export type StringProperty = BaseProperty & { type: 'string'; /** * Regular expression. * * @example "\\d\\d\\d\\d-\\d\\d-\\d\\d" */ pattern?: string; minLength?: number; maxLength?: number; } & WithEnum; export type BooleanProperty = BaseProperty & { type: 'boolean'; }; export type BinaryProperty = BaseProperty & { type: 'binary'; }; export type JsonProperty = BaseProperty & { type: 'json'; }; export type DateTimeProperty = BaseProperty & { type: 'dateTime'; minimum?: string; maximum?: string; }; export type RichTextProperty = BaseProperty & { type: 'richText'; }; export type UrlProperty = BaseProperty & { type: 'url'; }; export type IntegerProperty = BaseProperty & { type: 'integer'; minimum?: number; maximum?: number; } & WithEnum; export type FloatProperty = BaseProperty & { type: 'float'; minimum?: number; maximum?: number; } & WithEnum; export type ContentReferenceProperty = BaseProperty & { type: 'contentReference'; contentType?: AnyContentType; allowedTypes?: PermittedTypes[]; restrictedTypes?: PermittedTypes[]; }; export type ContentProperty = BaseProperty & { type: 'content'; contentType?: AnyContentType; allowedTypes?: PermittedTypes[]; restrictedTypes?: PermittedTypes[]; }; /** * Reprensents the content type property "Component". * Note: this is called "Block" in the GUI */ export type ComponentProperty = BaseProperty & { type: 'component'; contentType: T; }; export type LinkProperty = BaseProperty & { type: 'link'; }; export {};