import { AuthorResponse } from './Author'; import { PagedListResponse } from './common'; import { ContentDefinitionSchema, Field, I18NDictionary } from './ContentDefinitionSchema'; import { Extension } from './Extension'; /** * This type represent the unique content definition id type */ export type ContentDefinitionId = number; /** * This type represent the data needed to make a get content definition API request */ export type GetContentDefinitionRequest = { /** * The unique content definition id */ id: ContentDefinitionId; }; export type ArrayField = { path: string; }; /** * This type represent the data needed to make a list content definition API request */ export type ListContentDefinitionsRequest = { /** * The content definitions to skip (value used to paginate the response) */ skip: number; /** * The content definitions to take (value used to paginate the response) */ take: number; /** * The admitted data to filter the list of content definition */ filters: { /** * This filter is used to search content definition that contain the value inserted in the name */ name?: string; /** * This filter is used to search contents that contain the value inserted in the mnemonic id */ mnemonicId?: string; }; }; /** * This type represent the single item returned from a list content definition API request */ export type ListContentDefinitionsItem = { /** * The unique content definition if */ id: ContentDefinitionId; /** * The content definition name */ name: string; /** * The content definition creation date */ createdDate: Date; /** * The content definition last modified date */ lastModifiedDate: Date; /** * The content definition author */ author: AuthorResponse; /** * The content definition latest modifier */ latestContributor: AuthorResponse; /** * The content definition mnemonic id */ mnemonicId: string; /** * Extensions used by the definition */ extensions: string[]; }; /** * This type represent the response of a list content definition API request */ export type ListContentDefinitionsResponse = PagedListResponse; /** * This type represent the data needed to make create content definition API request */ export type CreateContentDefinitionRequest = { /** * The name of the content definition */ name: string; /** * The mnemonic id of the content definition */ mnemonicId: string; /** * The content definition fields schema */ schema: ContentDefinitionSchema; /** * will bypass content definition mnemonicId validation for every linked-content field */ bypassLinkedContentValidation?: boolean; }; /** * This type represent the data needed to make an update content definition API request */ export type UpdateContentDefinitionRequest = { /** * The content definition unique id to update */ id: ContentDefinitionId; /** * The content definition name */ name: string; /** * The content definition mnemonic id */ mnemonicId: string; /** * The content definition fields schema */ schema: ContentDefinitionSchema; /** * will bypass content definition mnemonicId validation for every linked-content field */ bypassLinkedContentValidation?: boolean; }; /** * This type represent the model of a content definition */ export type ContentDefinitionResponse = { /** * The content definition unique id */ id: ContentDefinitionId; /** * The content definition name */ name: string; /** * The content definition fields schema */ schema: ContentDefinitionSchema; /** * The content definition creation date */ createdDate: Date; /** * The content definition last modified date */ lastModifiedDate: Date; /** * The content definition author */ author: AuthorResponse; /** * The content definition latest modifier */ latestContributor: AuthorResponse; /** * The content definition mnemonic id */ mnemonicId: string; /** * Extensions used by the definition (type Extension or string (mnemonicId) depending if they are resolved or not) */ extensions: Extension[] | string[]; /** * Valued with paths to each array or null if definition is legacy */ trackableArrayFields?: ArrayField[] | null; }; /** * This type represent the response of a create content definition API request */ export type CreateContentDefinitionResponse = ContentDefinitionResponse; /** * This type represent the response of an update content definition API request */ export type UpdateContentDefinitionResponse = ContentDefinitionResponse; /** * This type represent the response of a get content definition API request */ export type GetContentDefinitionResponse = ContentDefinitionResponse | undefined; /** * This type represent the data needed to make a validate definition field API request */ export type ValidateDefinitionFieldRequest = { /** * The field to validate */ field: Field; /** * The fragment names already existing in the schema */ fragmentNames: string[]; /** * The default content definition schema language */ defaultLanguage: string; }; /** * This type represent the response of a validate definition field API request */ export type ValidateDefinitionFieldResponse = boolean; /** * This type represent the data needed to make a validate definition fragment API request */ export type ValidateDefinitionFragmentRequest = { /** * The fragment name to validate */ name: string; /** * The fragment list of fields */ fields: Field[]; /** * The fragment friendly labels */ labels?: I18NDictionary; /** * The other fragment names already existing in the schema */ fragmentNames: string[]; /** * The default content definition schema language */ defaultLanguage: string; }; /** * This type represent the response of a validate definition fragment API request */ export type ValidateDefinitionFragmentResponse = boolean; /** * This type represent the response of a create/update content definition API request when there a invalid fields or invalid fragments */ export type ContentDefinitionSchemaErrors = { /** * This attribute represents all the error that occurs inside the fields attribute of the definition schema object * * - The value is a string if the fields value is not in the expected format * - The value is a list of SchemaFieldViolationsErrors if the fields has the expected format but there are fields inside with validation errors */ fields?: string | SchemaFieldViolationsErrors[]; /** * This attribute represents all the error that occurs inside the fragments attribute of the definition schema object * * e.g. * - The value is a string if the fragment value is not in the expected format * - The value is a SchemaFragmentErrors if the fragment has the expected format but there internal validation errors occurred */ fragments?: string | SchemaFragmentErrors; /** * This attribute represents an error if the language of the schema is not a valid string */ lang?: string; }; /** * This type represent the model for the schema fragment errors */ export type SchemaFragmentErrors = { /** * The key is the name of the fragment that had the error * The value is a list of possible errors * e.g. * - The value is a SchemaFieldViolationErrors if the fragment is valid but there are internal fields with validation validation errors * - The value is a AttributeViolation if the fragment has invalid attributes */ [key: string]: (SchemaFieldViolationsErrors | AttributeViolation)[]; }; /** * This type represent the model for the schema field errors */ export type SchemaFieldViolationsErrors = { /** * The index of the field that had the error */ fieldIndex: number; /** * The list of violations that a field have * * e.g. * - The value is a string if the field is not in the expected format * - The value is list of AttributeViolation or ArrayAttributeViolation if the field is in the expected format but internal validation errors occurred */ violations: string | (AttributeViolation | ArrayAttributeViolation)[]; }; /** * This type represent an error that occurred in an attribute of a field or a fragment */ export type AttributeViolation = { /** * The attribute key that is invalid */ key: string; /** * The detailed list of errors that occurred */ details: AttributeViolationDetail[]; }; /** * This type represent a single detailed error that occurred inside a field or fragment attribute */ export type AttributeViolationDetail = { /** * The error code * For all error code refer to [[SchemaFieldViolationCodes]] */ errorCode: string; /** * The attributes affected by the error * */ affectedAttributes: string[]; }; /** * This type represent an error that occurred in an attribute that is a list of values */ export type ArrayAttributeViolation = { /** * The attribute that have the error */ key: string; /** * The list of errors inside the attribute */ itemsDetails: ArrayAttributeViolationDetail[]; }; /** * This type represent the detailed error that occurred in an a list of values */ export type ArrayAttributeViolationDetail = { /** * The index of the value that have the error */ index: number; /** * The detailed errors of the value */ details: AttributeViolationDetail[]; }; /** * Thin enum represent all definition schema fields violations error codes */ export declare enum SchemaFieldViolationCodes { unknownAttribute = "unknownAttribute", unknownFieldType = "unknownFieldType", requiredAttributeMissing = "requiredAttributeMissing", duplicateFieldName = "duplicateFieldName", invalidCharactersInString = "invalidCharactersInString", invalidStringValue = "invalidStringValue", invalidRegExpValue = "invalidRegExpValue", invalidStringValueInList = "invalidStringValueInList", invalidDateValue = "invalidDateValue", invalidI18NValue = "invalidI18NValue", invalidObjectValue = "invalidObjectValue", invalidBooleanValue = "invalidBooleanValue", invalidNumberValue = "invalidNumberValue", invalidNumberValueInList = "invalidNumberValueInList", invalidArrayValue = "invalidArrayValue", invalidEmptyArray = "invalidEmptyArray", invalidListOfValuesValue = "invalidListOfValuesValue", fragmentNameNotFound = "fragmentNameNotFound", fragmentNameAlreadyInUse = "fragmentNameAlreadyInUse", invalidSubType = "invalidSubType", invalidType = "invalidType", badMinMax = "invalidMinMax", badMinMaxLengths = "badMinMaxLengths", badDefinitionIdMnemonicId = "badDefinitionIdMnemonicId", badDefinitionIdsMnemonicIds = "badDefinitionIdsMnemonicIds", badBeforeAfter = "badBeforeAfter", missingDefinitionById = "missingDefinitionById", missingDefinitionByIds = "missingDefinitionByIds", missingDefinitionByMnemonicId = "missingDefinitionByMnemonicId", missingDefinitionByMnemonicIds = "missingDefinitionByMnemonicIds", missingDefaultLabel = "missingDefaultLabel", enableFacetNotPermitted = "enableFacetNotPermitted", labelValueInvalid = "labelValueInvalid", extensionNotFound = "extensionNotFound", extensionNotSupportedForType = "extensionNotSupportedForType", translatableNotAllowed = "translatableNotAllowed", invalidEnumValue = "invalidEnumValue", compactCannotBeNested = "compactCannotBeNested" }