import { MediaType } from './MediaGallery'; /** * This enum represent al possible schema field type ids */ export declare enum SchemaTypeIds { TEXT = "text", LONG_TEXT = "long-text", LINKED_CONTENT = "linked-content", CONTENT_REFERENCE = "content-reference", CLOUDINARY_PUBLICID = "cloudinary-publicId", CLOUDINARY_IMAGE = "cloudinary-image", CLOUDINARY_VIDEO = "cloudinary-video", CLOUDINARY_RAW = "cloudinary-raw", NUMBER = "number", BOOLEAN = "boolean", DATE = "date", FRAGMENT = "fragment", ONE_FRAGMENT_OF = "oneFragmentOf", ONE_LINKED_CONTENT_OF = "oneLinkedContentOf", ARRAY = "array", SLUG = "slug", MEDIA = "media" } /** * This enum represent al possible long text sub types */ export declare enum LongTextSubTypes { JSON = "json", MARKDOWN = "markdown", HTML = "html" } /** * This type represent the model of a content definition schema */ export type ContentDefinitionSchema = { /** * The default language of the schema * This value is used to internationalize all friendly labels */ lang: string; /** * The list of fields defined for the definition */ fields: Field[]; /** * The fragments defined for the definition * A Fragment is a custom field defined by the user and can be used internally in the definition */ fragments: FragmentsTable; }; /** * This type represent the model of the attribute fragments in a content definition schema */ export type FragmentsTable = { /** * This value represent how a fragment is defined. * The name is the unique id of the fragment and its value is the model representing the fragment */ [name: string]: FragmentDefinition; }; /** * This type represent the model to define a fragment */ export type FragmentDefinition = { /** * The list of fields defined by the fragment */ fields: Field[]; /** * The friendly labels of the fragment */ labels?: I18NDictionary; }; /** * This type represent the base model of a schema field * @template T The type of field to define */ type BaseSchemaField = T & { /** * The name of the field */ name: string; /** * The friendly labels of the field */ labels: I18NDictionary; /** * A hint that can be displayed to a user to help understand what the field do */ hint?: I18NDictionary; /** * A placeholder for the field value */ placeholder?: I18NDictionary; /** * The type of the field */ type: T['type']; /** * The constraints of the field */ constraints: RequiredFieldConstraints & T['constraints']; /** * mnemonicId of the extension/plugin that handles the field's value */ extension?: string; /** * Indicates whether this field should be returned when linkType = COMPACT */ compact?: boolean; }; /** * This type represent the schema field of a definition schema * @template T The type of field to define * * If the field type is an indexable schema type * then -> the schema field will contain the properties of the type BaseSchemaField and IndexableSchemaTypes type * else -> the schema field will contain only the properties of the type BaseSchemaField */ type SchemaField = BaseSchemaField; /** * This type represent the model of a I18N dictionary */ export type I18NDictionary = { /** * The name represent the locale language code * The value is the label to display */ [name: string]: string; }; /** * This type represent the model of a list of values constraint * @template T the value of a list of values constraint can be a string or a number */ export type ValueList = ListItem[]; /** * This type represent the model of a list of values constraint item * @template T the value of a list of values constraint can be a string or a number */ export type ListItem = { /** * The code unique code of the item */ code: T; /** * The friendly labels that will be displayed to the user instead of the value */ labels: I18NDictionary; }; /** * This type represent the model for a required field constraint */ export type RequiredFieldConstraints = { required: boolean; }; /** * This type represent the model of a text field constraints */ export type TextFieldConstraints = { /** * Set this value to true if a blank value is admitted */ allowEmpty?: boolean; /** * Set this value to define the text min length */ minLength?: number; /** * Set this value to define the text max length */ maxLength?: number; /** * Set this value to define a valid regExp to validate the text */ pattern?: string; /** * Set this value to define a predefined list of text values */ listOfValues?: ValueList; }; /** * This type represent the model of a long text field constraints */ export type LongTextFieldConstraints = { /** * Set this value to true if a blank value is admitted */ allowEmpty?: boolean; /** * Set this value to define the long text sub type */ subType?: LongTextSubTypes; /** * Set this value to define the text min length */ minLength?: number; /** * Set this value to define the text max length */ maxLength?: number; }; /** * This type represent the model of a date field constraint */ export type DateFieldConstraints = { /** * Set this value to define the higher limit of the date value */ before?: string; /** * Set this value to define the lower limit of the date value */ after?: string; }; /** * This type represent the model of a number field constraint */ export type NumberFieldConstraints = { /** * Set this value to define the min value */ min?: number; /** * Set this value to define the max value */ max?: number; /** * Set this value to define a predefined list of number values */ listOfValues?: ValueList; }; export declare enum LinkType { FULL = 0, LAZY = 1, COMPACT = 2 } /** * This type represent the model of a linked content field constraints * @Deprecated */ export type LinkedContentFieldConstraints = { /** * Set this value to define which type of content is possible to link by definition id * In the case where contentDefinitionId an definitionMnemonicId are both defined, definitionMnemonicId has a higher priority */ contentDefinitionId?: number; /** * Set this value to define which type of content is possible to link by definition mnemonic id * In the case where contentDefinitionId an definitionMnemonicId are both defined, definitionMnemonicId has a higher priority */ definitionMnemonicId?: string; /** * Set this value to define if the linked content will be lazy load when requested or not */ lazy?: boolean; linkType?: LinkType; }; /** * This type represent the model of a fragment field constraints */ export type FragmentFieldConstraints = { /** * Set this value to define which fragment the field can use */ name: string; }; /** * This type represent the model of a one fragment field constraints */ export type OneFragmentOfConstraints = { /** * Set this value to define which fragments the field can use */ names: string[]; }; /** * This type represent the model of a one linked content of field constraints */ export type OneLinkedContentOfConstraints = { /** * Set this value to define which type of content is possible to link by definition id * In the case where contentDefinitionIds and definitionMnemonicIds are both defined, definitionMnemonicIds has a higher priority */ contentDefinitionIds?: number[]; /** * Set this value to define which type of contents are possible to link by definition mnemonic id * In the case where contentDefinitionIds and definitionMnemonicIds are both defined, definitionMnemonicIds has a higher priority */ definitionMnemonicIds?: string[]; /** * Set this value to define if the linked content will be lazy load when requested or not */ lazy?: boolean; linkType?: LinkType; }; /** * This type represent the model of an array field constraints * @template T The type of the item used ad children of the array */ export type ArrayFieldConstraints = { /** * Set this property to define the minimum number of element in the array */ minLength?: number; /** * Set this property to define the maximum number of element in the array */ maxLength?: number; /** * This property represent the children of the array */ items: T; }; /** * This type represent the model of a cloudinary public id constraints */ export type CloudinaryPublicIdConstraints = { /** * Set this property to define the type of media */ type: MediaType; }; /** * Slug field type has `suffix` and `prefix` constraints in addition to `required` * Every slug is indexable and translatable and has a pattern that allows only alphanumeric characters (lowercased letters and numbers), hypens and no space */ export type SlugConstraints = { suffix?: string; prefix?: string; allowSlash?: boolean; }; /** * Constraints of a `media` field */ export type MediaConstraints = { /** * Determines type of media (raw, video, image) */ type: MediaType; }; /** * This type represent the model of a Schema Type Field * @template T The type of the field * @template C The type of the constraints */ export type SchemaType = { /** * This attribute represent the type of the field */ type: T; /** * This attribute represent the constraints of the field */ constraints: C; }; /** * This type represent the model of an indexing config */ export type IndexingConf = { /** * Set this attribute to enable faceting in the field */ enableFacet?: boolean; }; /** * A field will have this type when it's subject to localization */ export type TranslatableConf = { /** * Determines whether a field is subject to localization or not */ translatable?: boolean; }; /** * This attribute represent the type of an indexable schema type field, if a field is indexable it can be searched for the indexed value * @template T The type of the field * @template C The type of the constraints */ export type IndexableSchemaType = SchemaType & IndexingConf; /** * When a field is of this type it is subject to localization * @template T Type of the field */ export type TranslatableSchemaType> = T & TranslatableConf; /** * This type represent a text field schema type * A text field can be indexed, searched when requesting the content and localized */ export type TextSchemaType = TranslatableSchemaType>; /** * This type represent a long text field schema type * A long text field can be indexed, searched when requesting the content and localized */ export type LongTextSchemaType = TranslatableSchemaType>; /** * This type represent a linked content field schema type * A linked content field can be indexed and searched when requesting the content */ export type LinkedContentSchemaType = IndexableSchemaType; /** * This type represent a cloudinary public id field schema type */ export type CloudinaryPublicIdSchemaType = TranslatableSchemaType>; /** * This type represent a cloudinary image field schema type */ export type CloudinaryImageSchemaType = TranslatableSchemaType>; /** * This type represent a cloudinary video field schema type */ export type CloudinaryVideoSchemaType = TranslatableSchemaType>; /** * This type represent a cloudinary raw field schema type */ export type CloudinaryRawSchemaType = TranslatableSchemaType>; /** * Media field schema type */ export type MediaSchemaType = TranslatableSchemaType>; /** * This type represent a number field schema type * A number field can be indexed and searched when requesting the content */ export type NumberSchemaType = TranslatableSchemaType>; /** * This type represent a boolean field schema type * A boolean field can be indexed and searched when requesting the content */ export type BooleanSchemaType = IndexableSchemaType; /** * This type represent a date field schema type */ export type DateSchemaType = SchemaType; /** * This type represent a fragment field schema type */ export type FragmentSchemaType = SchemaType; /** * This type represent a one fragment of field schema type */ export type OneFragmentOfSchemaType = SchemaType; /** * This type represent a one linked content of field schema type * A one linked content of field can be indexed and searched when requesting the content */ export type OneLinkedContentOfSchemaType = IndexableSchemaType; /** * Slug schema type * This type is indexable and translatable by default */ export type SlugSchemaType = SchemaType; /** * This type represent an array field schema type * @template SUBTYPE The field to be used inside the array */ export type ArraySchemaType = SchemaType>; /** * This type group all the admitted schema types of a content definition excluded for the array schema type */ export type AllSchemaTypes = PlainSchemaTypes | IndexableSchemaTypes | TranslatableSchemaTypes; /** * This type group all the indexable schema types of a content definition */ export type IndexableSchemaTypes = TextSchemaType | LongTextSchemaType | LinkedContentSchemaType | OneLinkedContentOfSchemaType | BooleanSchemaType | NumberSchemaType; /** * This are all the fields that can be localized */ export type TranslatableSchemaTypes = NumberSchemaType | TextSchemaType | LongTextSchemaType | CloudinaryPublicIdSchemaType | CloudinaryImageSchemaType | CloudinaryVideoSchemaType | CloudinaryRawSchemaType | MediaSchemaType; /** * This type group all the schema types of a content definition that are not indexable */ export type PlainSchemaTypes = DateSchemaType | FragmentSchemaType | OneFragmentOfSchemaType | SlugSchemaType; /** * This type group all schema types of a content definition */ export type SchemaTypes = AllSchemaTypes | ArraySchemaType; /** * This type define the model of a field */ export type Field = T extends SchemaTypes ? SchemaField : never; export {};