Documentation
¶
Overview ¶
Package core provides core types and utilities for the CMS plugin.
Index ¶
- Constants
- func ErrAccessDenied(reason string) error
- func ErrAppContextMissing() error
- func ErrCircularComponentRef(path string) error
- func ErrCircularRelation(path string) error
- func ErrComponentSchemaExists(slug string) error
- func ErrComponentSchemaInUse(slug string, usageCount int) error
- func ErrComponentSchemaNotFound(identifier string) error
- func ErrContentTypeExists(slug string) error
- func ErrContentTypeHasEntries(slug string, entryCount int) error
- func ErrContentTypeNotFound(identifier string) error
- func ErrDatabaseError(message string, cause error) error
- func ErrEntryAlreadyPublished() error
- func ErrEntryLimitReached(contentType string, limit int) error
- func ErrEntryNotFound(identifier string) error
- func ErrEntryNotPublished() error
- func ErrEntryValidationFailed(errors map[string]string) error
- func ErrEntryValidationFailedSingle(field, reason string) error
- func ErrEnvContextMissing() error
- func ErrFieldExists(slug string) error
- func ErrFieldNotFound(identifier string) error
- func ErrFieldRequired(fieldName string) error
- func ErrInternalError(message string, cause error) error
- func ErrInvalidComponentSchemaSlug(slug, reason string) error
- func ErrInvalidContentTypeSlug(slug, reason string) error
- func ErrInvalidFieldSlug(slug, reason string) error
- func ErrInvalidFieldType(fieldType string) error
- func ErrInvalidFilter(filter, reason string) error
- func ErrInvalidOperator(operator string) error
- func ErrInvalidQuery(reason string) error
- func ErrInvalidRelation(reason string) error
- func ErrInvalidRequest(reason string) error
- func ErrInvalidSort(sort, reason string) error
- func ErrRelationConstraint(reason string) error
- func ErrRelationNotFound(identifier string) error
- func ErrRevisionNotFound(entryID string, version int) error
- func ErrRevisionsNotEnabled() error
- func ErrRollbackFailed(reason string, cause error) error
- func ErrTypeRelationNotFound(identifier string) error
- func ErrUniqueConstraint(field, value string) error
- func GetFieldTypesByCategory() map[string][]FieldTypeInfo
- func InternalError(message string, cause error) error
- type CMSStatsDTO
- type ChoiceDTO
- type ComponentSchemaDTO
- type ComponentSchemaSummaryDTO
- type ContentEntryDTO
- type ContentEntrySummaryDTO
- type ContentFieldDTO
- type ContentRevisionDTO
- type ContentTypeDTO
- type ContentTypeSettingsDTO
- type ContentTypeStatsDTO
- type ContentTypeSummaryDTO
- type CreateComponentSchemaRequest
- type CreateContentTypeRequest
- type CreateEntryRequest
- type CreateFieldRequest
- type CreateTypeRelationRequest
- type DiffType
- type EntryStatus
- type FieldConditionDTO
- type FieldDifference
- type FieldOptionsDTO
- type FieldOrderItem
- type FieldType
- func (t FieldType) IsArray() bool
- func (t FieldType) IsDate() bool
- func (t FieldType) IsNested() bool
- func (t FieldType) IsNumeric() bool
- func (t FieldType) IsObject() bool
- func (t FieldType) IsOneOf() bool
- func (t FieldType) IsSelectable() bool
- func (t FieldType) IsText() bool
- func (t FieldType) IsValid() bool
- func (t FieldType) RequiresOptions() bool
- func (t FieldType) String() string
- func (t FieldType) SupportsIndex() bool
- func (t FieldType) SupportsSearch() bool
- func (t FieldType) SupportsUnique() bool
- type FieldTypeInfo
- type FieldValidator
- type ListComponentSchemasQuery
- type ListComponentSchemasResponse
- type ListContentTypesQuery
- type ListContentTypesResponse
- type ListEntriesQuery
- type ListEntriesResponse
- type ListRevisionsQuery
- type ListRevisionsResponse
- type NestedFieldDefDTO
- type OnDeleteAction
- type OneOfSchemaOptionDTO
- type PaginatedResponse
- type PublishEntryRequest
- type RelatedEntryDTO
- type RelationType
- type ReorderFieldsRequest
- type ReorderRelationsRequest
- type RevisionCompareDTO
- type RevisionDTO
- type RollbackEntryRequest
- type SetRelationRequest
- type SetRelationsRequest
- type TypeRelationDTO
- type UpdateComponentSchemaRequest
- type UpdateContentTypeRequest
- type UpdateEntryRequest
- type UpdateFieldRequest
- type UpdateTypeRelationRequest
- type ValidationError
- type ValidationResult
- func ValidateArrayData(items []map[string]interface{}, fields []NestedFieldDefDTO, ...) *ValidationResult
- func ValidateNestedData(data map[string]interface{}, fields []NestedFieldDefDTO) *ValidationResult
- func ValidateOneOfWithDiscriminator(data map[string]interface{}, discriminatorValue string, ...) *ValidationResult
Constants ¶
const ( // Content Type errors ErrCodeContentTypeNotFound = "CMS_CONTENT_TYPE_NOT_FOUND" ErrCodeContentTypeExists = "CMS_CONTENT_TYPE_EXISTS" ErrCodeContentTypeHasEntries = "CMS_CONTENT_TYPE_HAS_ENTRIES" ErrCodeInvalidContentTypeSlug = "CMS_INVALID_CONTENT_TYPE_SLUG" // Content Field errors ErrCodeFieldNotFound = "CMS_FIELD_NOT_FOUND" ErrCodeFieldExists = "CMS_FIELD_EXISTS" ErrCodeInvalidFieldSlug = "CMS_INVALID_FIELD_SLUG" ErrCodeInvalidFieldType = "CMS_INVALID_FIELD_TYPE" ErrCodeFieldRequired = "CMS_FIELD_REQUIRED" // Component Schema errors ErrCodeComponentSchemaNotFound = "CMS_COMPONENT_SCHEMA_NOT_FOUND" ErrCodeComponentSchemaExists = "CMS_COMPONENT_SCHEMA_EXISTS" ErrCodeComponentSchemaInUse = "CMS_COMPONENT_SCHEMA_IN_USE" ErrCodeInvalidComponentSchemaSlug = "CMS_INVALID_COMPONENT_SCHEMA_SLUG" ErrCodeCircularComponentRef = "CMS_CIRCULAR_COMPONENT_REF" // Content Entry errors ErrCodeEntryNotFound = "CMS_ENTRY_NOT_FOUND" ErrCodeEntryValidationFailed = "CMS_ENTRY_VALIDATION_FAILED" ErrCodeEntryAlreadyPublished = "CMS_ENTRY_ALREADY_PUBLISHED" ErrCodeEntryNotPublished = "CMS_ENTRY_NOT_PUBLISHED" ErrCodeEntryLimitReached = "CMS_ENTRY_LIMIT_REACHED" ErrCodeUniqueConstraint = "CMS_UNIQUE_CONSTRAINT_VIOLATION" // Revision errors ErrCodeRevisionNotFound = "CMS_REVISION_NOT_FOUND" ErrCodeRollbackFailed = "CMS_ROLLBACK_FAILED" // Relation errors ErrCodeRelationNotFound = "CMS_RELATION_NOT_FOUND" ErrCodeInvalidRelation = "CMS_INVALID_RELATION" ErrCodeCircularRelation = "CMS_CIRCULAR_RELATION" ErrCodeRelationConstraint = "CMS_RELATION_CONSTRAINT_VIOLATION" // Query errors ErrCodeInvalidQuery = "CMS_INVALID_QUERY" ErrCodeInvalidFilter = "CMS_INVALID_FILTER" ErrCodeInvalidSort = "CMS_INVALID_SORT" ErrCodeInvalidOperator = "CMS_INVALID_OPERATOR" // General errors ErrCodeAccessDenied = "CMS_ACCESS_DENIED" ErrCodeInvalidRequest = "CMS_INVALID_REQUEST" ErrCodeAppContextMissing = "CMS_APP_CONTEXT_MISSING" ErrCodeEnvContextMissing = "CMS_ENV_CONTEXT_MISSING" )
Error codes for the CMS plugin
Variables ¶
This section is empty.
Functions ¶
func ErrAccessDenied ¶
ErrAccessDenied returns a forbidden error when access is denied
func ErrAppContextMissing ¶
func ErrAppContextMissing() error
ErrAppContextMissing returns a bad request error when app context is missing
func ErrCircularComponentRef ¶
ErrCircularComponentRef returns an error when a circular component reference is detected
func ErrCircularRelation ¶
ErrCircularRelation returns an error when a circular relation is detected
func ErrComponentSchemaExists ¶
ErrComponentSchemaExists returns a conflict error when a component schema already exists
func ErrComponentSchemaInUse ¶
ErrComponentSchemaInUse returns an error when trying to delete a component schema that is in use
func ErrComponentSchemaNotFound ¶
ErrComponentSchemaNotFound returns a not found error for a component schema
func ErrContentTypeExists ¶
ErrContentTypeExists returns a conflict error when a content type already exists
func ErrContentTypeHasEntries ¶
ErrContentTypeHasEntries returns an error when trying to delete a content type with entries
func ErrContentTypeNotFound ¶
ErrContentTypeNotFound returns a not found error for a content type
func ErrDatabaseError ¶
ErrDatabaseError returns an internal server error for database issues
func ErrEntryAlreadyPublished ¶
func ErrEntryAlreadyPublished() error
ErrEntryAlreadyPublished returns a conflict error when entry is already published
func ErrEntryLimitReached ¶
ErrEntryLimitReached returns an error when entry limit is reached for a content type
func ErrEntryNotFound ¶
ErrEntryNotFound returns a not found error for a content entry
func ErrEntryNotPublished ¶
func ErrEntryNotPublished() error
ErrEntryNotPublished returns a bad request error when entry is not published
func ErrEntryValidationFailed ¶
ErrEntryValidationFailed returns a bad request error when entry validation fails
func ErrEntryValidationFailedSingle ¶
ErrEntryValidationFailedSingle returns a bad request error for a single validation failure
func ErrEnvContextMissing ¶
func ErrEnvContextMissing() error
ErrEnvContextMissing returns a bad request error when environment context is missing
func ErrFieldExists ¶
ErrFieldExists returns a conflict error when a field already exists
func ErrFieldNotFound ¶
ErrFieldNotFound returns a not found error for a content field
func ErrFieldRequired ¶
ErrFieldRequired returns a bad request error when a required field is missing
func ErrInternalError ¶
ErrInternalError is an alias for InternalError for consistency
func ErrInvalidComponentSchemaSlug ¶
ErrInvalidComponentSchemaSlug returns a bad request error for invalid component schema slug format
func ErrInvalidContentTypeSlug ¶
ErrInvalidContentTypeSlug returns a bad request error for invalid slug format
func ErrInvalidFieldSlug ¶
ErrInvalidFieldSlug returns a bad request error for invalid field name
func ErrInvalidFieldType ¶
ErrInvalidFieldType returns a bad request error for invalid field type
func ErrInvalidFilter ¶
ErrInvalidFilter returns an error for invalid filter expression
func ErrInvalidOperator ¶
ErrInvalidOperator returns an error for invalid query operator
func ErrInvalidQuery ¶
ErrInvalidQuery returns an error for invalid query syntax
func ErrInvalidRelation ¶
ErrInvalidRelation returns an error for invalid relation configuration
func ErrInvalidRequest ¶
ErrInvalidRequest returns a bad request error for generic invalid requests
func ErrInvalidSort ¶
ErrInvalidSort returns an error for invalid sort expression
func ErrRelationConstraint ¶
ErrRelationConstraint returns an error when a relation constraint is violated
func ErrRelationNotFound ¶
ErrRelationNotFound returns a not found error for a relation
func ErrRevisionNotFound ¶
ErrRevisionNotFound returns a not found error for a revision
func ErrRevisionsNotEnabled ¶
func ErrRevisionsNotEnabled() error
ErrRevisionsNotEnabled returns an error when revisions are not enabled
func ErrRollbackFailed ¶
ErrRollbackFailed returns an error when rollback fails
func ErrTypeRelationNotFound ¶
ErrTypeRelationNotFound returns a not found error for a type relation
func ErrUniqueConstraint ¶
ErrUniqueConstraint returns an error when a unique constraint is violated
func GetFieldTypesByCategory ¶
func GetFieldTypesByCategory() map[string][]FieldTypeInfo
GetFieldTypesByCategory returns field types grouped by category
func InternalError ¶
InternalError returns an internal server error with the given message
Types ¶
type CMSStatsDTO ¶
type CMSStatsDTO struct {
TotalContentTypes int `json:"totalContentTypes"`
TotalEntries int `json:"totalEntries"`
TotalRevisions int `json:"totalRevisions"`
EntriesByStatus map[string]int `json:"entriesByStatus"`
EntriesByType map[string]int `json:"entriesByType"`
RecentlyUpdated int `json:"recentlyUpdated"`
ScheduledEntries int `json:"scheduledEntries"`
}
CMSStatsDTO contains overall CMS statistics
type ChoiceDTO ¶
type ChoiceDTO struct {
Value string `json:"value"`
Label string `json:"label"`
Icon string `json:"icon,omitempty"`
Color string `json:"color,omitempty"`
Disabled bool `json:"disabled,omitempty"`
}
ChoiceDTO represents a choice option for select fields
type ComponentSchemaDTO ¶
type ComponentSchemaDTO struct {
ID string `json:"id"`
AppID string `json:"appId"`
EnvironmentID string `json:"environmentId"`
Title string `json:"title"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Fields []NestedFieldDefDTO `json:"fields"`
UsageCount int `json:"usageCount,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
UpdatedBy string `json:"updatedBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ComponentSchemaDTO is the API response for a component schema
type ComponentSchemaSummaryDTO ¶
type ComponentSchemaSummaryDTO struct {
ID string `json:"id"`
Title string `json:"title"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
FieldCount int `json:"fieldCount"`
UsageCount int `json:"usageCount"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ComponentSchemaSummaryDTO is a lightweight component schema for lists
type ContentEntryDTO ¶
type ContentEntryDTO struct {
ID string `json:"id"`
ContentTypeID string `json:"contentTypeId"`
ContentType *ContentTypeSummaryDTO `json:"contentType,omitempty"`
AppID string `json:"appId"`
EnvironmentID string `json:"environmentId"`
Data map[string]any `json:"data"`
Status string `json:"status"`
Version int `json:"version"`
PublishedAt *time.Time `json:"publishedAt,omitempty"`
ScheduledAt *time.Time `json:"scheduledAt,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
UpdatedBy string `json:"updatedBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
// Relations maps field names to related entry IDs
Relations map[string][]string `json:"relations,omitempty"`
}
ContentEntryDTO is the API response for a content entry
type ContentEntrySummaryDTO ¶
type ContentEntrySummaryDTO struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Status string `json:"status"`
Version int `json:"version"`
PublishedAt *time.Time `json:"publishedAt,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ContentEntrySummaryDTO is a lightweight entry for lists
type ContentFieldDTO ¶
type ContentFieldDTO struct {
ID string `json:"id"`
ContentTypeID string `json:"contentTypeId"`
Title string `json:"title"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Type string `json:"type"`
Required bool `json:"required"`
Unique bool `json:"unique"`
Indexed bool `json:"indexed"`
Localized bool `json:"localized"`
DefaultValue any `json:"defaultValue,omitempty"`
Options FieldOptionsDTO `json:"options,omitempty"`
Order int `json:"order"`
Hidden bool `json:"hidden"`
ReadOnly bool `json:"readOnly"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ContentFieldDTO is the API response for a content field
type ContentRevisionDTO ¶
type ContentRevisionDTO struct {
ID string `json:"id"`
EntryID string `json:"entryId"`
Version int `json:"version"`
Data map[string]any `json:"data"`
Status string `json:"status"`
ChangeReason string `json:"changeReason,omitempty"`
ChangedBy string `json:"changedBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
ContentRevisionDTO is the API response for a content revision
type ContentTypeDTO ¶
type ContentTypeDTO struct {
ID string `json:"id"`
AppID string `json:"appId"`
EnvironmentID string `json:"environmentId"`
Title string `json:"title"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Settings ContentTypeSettingsDTO `json:"settings"`
Fields []*ContentFieldDTO `json:"fields,omitempty"`
EntryCount int `json:"entryCount,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
UpdatedBy string `json:"updatedBy,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ContentTypeDTO is the API response for a content type
type ContentTypeSettingsDTO ¶
type ContentTypeSettingsDTO struct {
// Display settings
TitleField string `json:"titleField,omitempty"`
DescriptionField string `json:"descriptionField,omitempty"`
PreviewField string `json:"previewField,omitempty"`
// Features
EnableRevisions bool `json:"enableRevisions"`
EnableDrafts bool `json:"enableDrafts"`
EnableSoftDelete bool `json:"enableSoftDelete"`
EnableSearch bool `json:"enableSearch"`
EnableScheduling bool `json:"enableScheduling"`
// Permissions
DefaultPermissions []string `json:"defaultPermissions,omitempty"`
// Limits
MaxEntries int `json:"maxEntries,omitempty"`
}
ContentTypeSettingsDTO represents content type settings
type ContentTypeStatsDTO ¶
type ContentTypeStatsDTO struct {
ContentTypeID string `json:"contentTypeId"`
TotalEntries int `json:"totalEntries"`
DraftEntries int `json:"draftEntries"`
PublishedEntries int `json:"publishedEntries"`
ArchivedEntries int `json:"archivedEntries"`
EntriesByStatus map[string]int `json:"entriesByStatus"`
LastEntryAt *time.Time `json:"lastEntryAt,omitempty"`
}
ContentTypeStatsDTO contains statistics for a specific content type
type ContentTypeSummaryDTO ¶
type ContentTypeSummaryDTO struct {
ID string `json:"id"`
Title string `json:"title"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
EntryCount int `json:"entryCount"`
FieldCount int `json:"fieldCount"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
ContentTypeSummaryDTO is a lightweight content type for lists
type CreateComponentSchemaRequest ¶
type CreateComponentSchemaRequest struct {
Title string `json:"title" validate:"required,min=1,max=100"`
Name string `json:"name" validate:"required"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Fields []NestedFieldDefDTO `json:"fields,omitempty"`
}
CreateComponentSchemaRequest is the request to create a component schema
type CreateContentTypeRequest ¶
type CreateContentTypeRequest struct {
Title string `json:"title" validate:"required,min=1,max=100"`
Name string `json:"name" validate:"required"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Settings *ContentTypeSettingsDTO `json:"settings,omitempty"`
}
CreateContentTypeRequest is the request to create a content type
type CreateEntryRequest ¶
type CreateEntryRequest struct {
Data map[string]any `json:"data" validate:"required"`
Status string `json:"status,omitempty"`
ScheduledAt *time.Time `json:"scheduledAt,omitempty"`
}
CreateEntryRequest is the request to create a content entry
type CreateFieldRequest ¶
type CreateFieldRequest struct {
Title string `json:"title" validate:"required,min=1,max=100"`
Name string `json:"name" validate:"required"`
Description string `json:"description,omitempty"`
Type string `json:"type" validate:"required"`
Required bool `json:"required"`
Unique bool `json:"unique"`
Indexed bool `json:"indexed"`
Localized bool `json:"localized"`
DefaultValue any `json:"defaultValue,omitempty"`
Options *FieldOptionsDTO `json:"options,omitempty"`
Order int `json:"order"`
Hidden bool `json:"hidden"`
ReadOnly bool `json:"readOnly"`
}
CreateFieldRequest is the request to create a content field
type CreateTypeRelationRequest ¶
type CreateTypeRelationRequest struct {
SourceContentTypeID xid.ID `json:"sourceContentTypeId"`
TargetContentTypeID xid.ID `json:"targetContentTypeId"`
SourceFieldName string `json:"sourceFieldName"`
TargetFieldName string `json:"targetFieldName,omitempty"`
RelationType string `json:"relationType"`
OnDelete string `json:"onDelete,omitempty"`
}
CreateTypeRelationRequest is the request to create a type relation
type EntryStatus ¶
type EntryStatus string
EntryStatus defines the status of a content entry
const ( // EntryStatusDraft indicates the entry is a draft EntryStatusDraft EntryStatus = "draft" // EntryStatusPublished indicates the entry is published EntryStatusPublished EntryStatus = "published" // EntryStatusArchived indicates the entry is archived EntryStatusArchived EntryStatus = "archived" // EntryStatusScheduled indicates the entry is scheduled for publishing EntryStatusScheduled EntryStatus = "scheduled" )
func ParseEntryStatus ¶
func ParseEntryStatus(s string) (EntryStatus, bool)
ParseEntryStatus parses a string into an EntryStatus
func (EntryStatus) IsValid ¶
func (s EntryStatus) IsValid() bool
IsValid checks if the status is valid
func (EntryStatus) String ¶
func (s EntryStatus) String() string
String returns the string representation of the status
type FieldConditionDTO ¶
type FieldConditionDTO struct {
Field string `json:"field"` // Field name to watch
Operator string `json:"operator"` // eq, ne, in, notIn, exists, notExists
Value any `json:"value,omitempty"` // Value(s) to compare
}
FieldConditionDTO defines a condition for showing/hiding fields
type FieldDifference ¶
type FieldDifference struct {
Field string `json:"field"`
OldValue any `json:"oldValue,omitempty"`
NewValue any `json:"newValue,omitempty"`
Type DiffType `json:"type"`
}
FieldDifference represents a difference in a specific field
type FieldOptionsDTO ¶
type FieldOptionsDTO struct {
// Text fields
MinLength int `json:"minLength,omitempty"`
MaxLength int `json:"maxLength,omitempty"`
Pattern string `json:"pattern,omitempty"`
// Number fields
Min *float64 `json:"min,omitempty"`
Max *float64 `json:"max,omitempty"`
Step *float64 `json:"step,omitempty"`
Integer bool `json:"integer,omitempty"`
// Select fields
Choices []ChoiceDTO `json:"choices,omitempty"`
// Relation fields
RelatedType string `json:"relatedType,omitempty"`
RelationType string `json:"relationType,omitempty"`
OnDelete string `json:"onDelete,omitempty"`
InverseField string `json:"inverseField,omitempty"`
// Rich text fields
AllowHTML bool `json:"allowHtml,omitempty"`
MaxWords int `json:"maxWords,omitempty"`
// Media fields
AllowedMimeTypes []string `json:"allowedMimeTypes,omitempty"`
MaxFileSize int64 `json:"maxFileSize,omitempty"`
// Slug fields
SourceField string `json:"sourceField,omitempty"`
// JSON fields
Schema string `json:"schema,omitempty"`
// Date fields
MinDate *time.Time `json:"minDate,omitempty"`
MaxDate *time.Time `json:"maxDate,omitempty"`
DateFormat string `json:"dateFormat,omitempty"`
// Object/Array fields (nested structures)
NestedFields []NestedFieldDefDTO `json:"nestedFields,omitempty"` // Inline sub-field definitions
ComponentRef string `json:"componentRef,omitempty"` // Reference to ComponentSchema slug
MinItems *int `json:"minItems,omitempty"` // For array: minimum items
MaxItems *int `json:"maxItems,omitempty"` // For array: maximum items
Collapsible bool `json:"collapsible,omitempty"` // UI: collapsible in form
DefaultExpanded bool `json:"defaultExpanded,omitempty"` // UI: expanded by default
// OneOf fields (discriminated union)
DiscriminatorField string `json:"discriminatorField,omitempty"` // Field name to watch for schema selection
Schemas map[string]OneOfSchemaOptionDTO `json:"schemas,omitempty"` // Value -> schema mapping
ClearOnDiscriminatorChange bool `json:"clearOnDiscriminatorChange,omitempty"` // Clear data when discriminator changes
// Conditional visibility
ShowWhen *FieldConditionDTO `json:"showWhen,omitempty"` // Show field when condition is met
HideWhen *FieldConditionDTO `json:"hideWhen,omitempty"` // Hide field when condition is met
ClearWhenHidden bool `json:"clearWhenHidden,omitempty"` // Clear value when hidden
}
FieldOptionsDTO contains type-specific field options
type FieldOrderItem ¶
type FieldOrderItem struct {
FieldID string `json:"fieldId" validate:"required"`
Order int `json:"order"`
}
FieldOrderItem represents a field and its new order
type FieldType ¶
type FieldType string
FieldType defines the type of data a field holds
const ( // FieldTypeText is a short text field (varchar) FieldTypeText FieldType = "text" // FieldTypeRichText is a long formatted text field FieldTypeRichText FieldType = "richText" // FieldTypeNumber is a numeric field (integer or float) FieldTypeNumber FieldType = "number" // FieldTypeBoolean is a true/false field FieldTypeBoolean FieldType = "boolean" // FieldTypeDate is a date-only field FieldTypeDate FieldType = "date" // FieldTypeDateTime is a date and time field FieldTypeDateTime FieldType = "datetime" // FieldTypeTime is a time-only field FieldTypeTime FieldType = "time" // FieldTypeEmail is an email field with validation FieldTypeEmail FieldType = "email" // FieldTypeURL is a URL field with validation FieldTypeURL FieldType = "url" // FieldTypeJSON is an arbitrary JSON object/array field FieldTypeJSON FieldType = "json" // FieldTypeSelect is a single select from options FieldTypeSelect FieldType = "select" // FieldTypeMultiSelect is a multi-select from options FieldTypeMultiSelect FieldType = "multiSelect" // FieldTypeRelation is a reference to another content type FieldTypeRelation FieldType = "relation" // FieldTypeMedia is a file/image reference FieldTypeMedia FieldType = "media" // FieldTypeSlug is a URL-friendly slug (auto-generated) FieldTypeSlug FieldType = "slug" // FieldTypeUUID is a UUID field FieldTypeUUID FieldType = "uuid" // FieldTypeColor is a color picker field FieldTypeColor FieldType = "color" // FieldTypePassword is a password field (hashed) FieldTypePassword FieldType = "password" // FieldTypePhone is a phone number field FieldTypePhone FieldType = "phone" // FieldTypeTextarea is a multiline text field FieldTypeTextarea FieldType = "textarea" // FieldTypeMarkdown is a markdown text field FieldTypeMarkdown FieldType = "markdown" // FieldTypeEnumeration is an enumeration field FieldTypeEnumeration FieldType = "enumeration" // FieldTypeInteger is an integer-only number field FieldTypeInteger FieldType = "integer" // FieldTypeFloat is a float/decimal number field FieldTypeFloat FieldType = "float" // FieldTypeBigInteger is a big integer field FieldTypeBigInteger FieldType = "bigInteger" // FieldTypeDecimal is a decimal field with precision FieldTypeDecimal FieldType = "decimal" // FieldTypeObject is a nested object with sub-fields FieldTypeObject FieldType = "object" // FieldTypeArray is an array of objects with sub-fields FieldTypeArray FieldType = "array" // FieldTypeOneOf is a discriminated union - schema determined by another field's value FieldTypeOneOf FieldType = "oneOf" )
func ParseFieldType ¶
ParseFieldType parses a string into a FieldType
func (FieldType) IsSelectable ¶
IsSelectable returns true if the field type has selectable options
func (FieldType) RequiresOptions ¶
RequiresOptions returns true if the field type requires options configuration
func (FieldType) SupportsIndex ¶
SupportsIndex returns true if the field type supports indexing
func (FieldType) SupportsSearch ¶
SupportsSearch returns true if the field type supports full-text search
func (FieldType) SupportsUnique ¶
SupportsUnique returns true if the field type supports unique constraint
type FieldTypeInfo ¶
type FieldTypeInfo struct {
Type FieldType `json:"type"`
Name string `json:"name"`
Description string `json:"description"`
Category string `json:"category"`
Icon string `json:"icon"`
SupportsUnique bool `json:"supportsUnique"`
SupportsIndex bool `json:"supportsIndex"`
SupportsSearch bool `json:"supportsSearch"`
RequiresOptions bool `json:"requiresOptions"`
}
FieldTypeInfo provides metadata about a field type
func GetAllFieldTypes ¶
func GetAllFieldTypes() []FieldTypeInfo
GetAllFieldTypes returns information about all available field types
func GetFieldTypeInfo ¶
func GetFieldTypeInfo(t FieldType) *FieldTypeInfo
GetFieldTypeInfo returns information about a specific field type
type FieldValidator ¶
type FieldValidator struct {
FieldName string
FieldType FieldType
Required bool
Unique bool
Options *FieldOptionsDTO
}
FieldValidator validates a field value against its type and options
func NewFieldValidator ¶
func NewFieldValidator(name string, fieldType FieldType, required, unique bool, options *FieldOptionsDTO) *FieldValidator
NewFieldValidator creates a new field validator
func (*FieldValidator) Validate ¶
func (v *FieldValidator) Validate(value interface{}) *ValidationResult
Validate validates a value against the field's type and options
type ListComponentSchemasQuery ¶
type ListComponentSchemasQuery struct {
Search string `json:"search,omitempty"`
SortBy string `json:"sortBy,omitempty"`
SortOrder string `json:"sortOrder,omitempty"`
Page int `json:"page,omitempty"`
PageSize int `json:"pageSize,omitempty"`
}
ListComponentSchemasQuery defines query parameters for listing component schemas
type ListComponentSchemasResponse ¶
type ListComponentSchemasResponse struct {
Components []*ComponentSchemaSummaryDTO `json:"components"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
TotalItems int `json:"totalItems"`
TotalPages int `json:"totalPages"`
}
ListComponentSchemasResponse is the response for listing component schemas
type ListContentTypesQuery ¶
type ListContentTypesQuery struct {
Search string `json:"search,omitempty"`
SortBy string `json:"sortBy,omitempty"`
SortOrder string `json:"sortOrder,omitempty"`
Page int `json:"page,omitempty"`
PageSize int `json:"pageSize,omitempty"`
}
ListContentTypesQuery defines query parameters for listing content types
type ListContentTypesResponse ¶
type ListContentTypesResponse struct {
ContentTypes []*ContentTypeSummaryDTO `json:"contentTypes"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
TotalItems int `json:"totalItems"`
TotalPages int `json:"totalPages"`
}
ListContentTypesResponse is the response for listing content types
type ListEntriesQuery ¶
type ListEntriesQuery struct {
Status string `json:"status,omitempty"`
Search string `json:"search,omitempty"`
Filters map[string]any `json:"filters,omitempty"`
SortBy string `json:"sortBy,omitempty"`
SortOrder string `json:"sortOrder,omitempty"`
Page int `json:"page,omitempty"`
PageSize int `json:"pageSize,omitempty"`
Select []string `json:"select,omitempty"`
Populate []string `json:"populate,omitempty"`
}
ListEntriesQuery defines query parameters for listing entries
type ListEntriesResponse ¶
type ListEntriesResponse struct {
Entries []*ContentEntryDTO `json:"entries"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
TotalItems int `json:"totalItems"`
TotalPages int `json:"totalPages"`
}
ListEntriesResponse is the response for listing entries
type ListRevisionsQuery ¶
type ListRevisionsQuery struct {
Page int `json:"page,omitempty"`
PageSize int `json:"pageSize,omitempty"`
}
ListRevisionsQuery defines query parameters for listing revisions
type ListRevisionsResponse ¶
type ListRevisionsResponse struct {
Revisions []*ContentRevisionDTO `json:"revisions"`
Page int `json:"page"`
PageSize int `json:"pageSize"`
TotalItems int `json:"totalItems"`
TotalPages int `json:"totalPages"`
}
ListRevisionsResponse is the response for listing revisions
type NestedFieldDefDTO ¶
type NestedFieldDefDTO struct {
Title string `json:"title"`
Name string `json:"name"`
Type string `json:"type"`
Required bool `json:"required,omitempty"`
Description string `json:"description,omitempty"`
Options *FieldOptionsDTO `json:"options,omitempty"`
}
NestedFieldDefDTO represents a field definition within a nested object or component schema
type OnDeleteAction ¶
type OnDeleteAction string
OnDeleteAction defines what happens when a related entry is deleted
const ( // OnDeleteCascade deletes the related entries OnDeleteCascade OnDeleteAction = "cascade" // OnDeleteSetNull sets the relation to null OnDeleteSetNull OnDeleteAction = "setNull" // OnDeleteRestrict prevents deletion if related entries exist OnDeleteRestrict OnDeleteAction = "restrict" // OnDeleteNoAction takes no action OnDeleteNoAction OnDeleteAction = "noAction" )
func (OnDeleteAction) IsValid ¶
func (a OnDeleteAction) IsValid() bool
IsValid checks if the on-delete action is valid
type OneOfSchemaOptionDTO ¶
type OneOfSchemaOptionDTO struct {
ComponentRef string `json:"componentRef,omitempty"` // Reference to ComponentSchema slug
NestedFields []NestedFieldDefDTO `json:"nestedFields,omitempty"` // Or inline field definitions
Label string `json:"label,omitempty"` // Display label for this option
}
OneOfSchemaOptionDTO defines a schema option for oneOf fields
type PaginatedResponse ¶
type PaginatedResponse[T any] struct { Items []T `json:"items"` Total int `json:"total"` Page int `json:"page"` PageSize int `json:"pageSize"` TotalPages int `json:"totalPages"` }
PaginatedResponse is a generic paginated response wrapper
type PublishEntryRequest ¶
PublishEntryRequest is the request to publish an entry
type RelatedEntryDTO ¶
type RelatedEntryDTO struct {
ID string `json:"id"`
Order int `json:"order"`
Entry *ContentEntrySummaryDTO `json:"entry,omitempty"`
}
RelatedEntryDTO represents a related entry
type RelationType ¶
type RelationType string
RelationType defines the type of relation between content types
const ( // RelationTypeOneToOne represents a one-to-one relation RelationTypeOneToOne RelationType = "oneToOne" // RelationTypeOneToMany represents a one-to-many relation RelationTypeOneToMany RelationType = "oneToMany" // RelationTypeManyToOne represents a many-to-one relation RelationTypeManyToOne RelationType = "manyToOne" // RelationTypeManyToMany represents a many-to-many relation RelationTypeManyToMany RelationType = "manyToMany" )
func (RelationType) IsValid ¶
func (r RelationType) IsValid() bool
IsValid checks if the relation type is valid
func (RelationType) String ¶
func (r RelationType) String() string
String returns the string representation
type ReorderFieldsRequest ¶
type ReorderFieldsRequest struct {
FieldOrders []FieldOrderItem `json:"fieldOrders" validate:"required,min=1"`
}
ReorderFieldsRequest is the request to reorder fields
type ReorderRelationsRequest ¶
ReorderRelationsRequest is the request to reorder relations
type RevisionCompareDTO ¶
type RevisionCompareDTO struct {
From *RevisionDTO `json:"from"`
To *RevisionDTO `json:"to"`
Differences []FieldDifference `json:"differences"`
}
RevisionCompareDTO contains revision comparison results
type RevisionDTO ¶
type RevisionDTO struct {
ID string `json:"id"`
EntryID string `json:"entryId"`
Version int `json:"version"`
Data map[string]any `json:"data"`
ChangedBy string `json:"changedBy,omitempty"`
Reason string `json:"reason,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
RevisionDTO represents a content revision
type RollbackEntryRequest ¶
type RollbackEntryRequest struct {
TargetVersion int `json:"targetVersion" validate:"required,min=1"`
Reason string `json:"reason,omitempty"`
}
RollbackEntryRequest is the request to rollback an entry
type SetRelationRequest ¶
SetRelationRequest is the request to set a relation
type SetRelationsRequest ¶
SetRelationsRequest is the request to set multiple relations
type TypeRelationDTO ¶
type TypeRelationDTO struct {
ID string `json:"id"`
SourceContentTypeID string `json:"sourceContentTypeId"`
TargetContentTypeID string `json:"targetContentTypeId"`
SourceContentTypeTitle string `json:"sourceContentTypeTitle,omitempty"`
SourceContentTypeName string `json:"sourceContentTypeName,omitempty"`
TargetContentTypeTitle string `json:"targetContentTypeTitle,omitempty"`
TargetContentTypeName string `json:"targetContentTypeName,omitempty"`
SourceFieldName string `json:"sourceFieldName"`
TargetFieldName string `json:"targetFieldName,omitempty"`
RelationType string `json:"relationType"`
OnDelete string `json:"onDelete"`
CreatedAt time.Time `json:"createdAt"`
}
TypeRelationDTO represents a type relation definition
type UpdateComponentSchemaRequest ¶
type UpdateComponentSchemaRequest struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Fields []NestedFieldDefDTO `json:"fields,omitempty"`
}
UpdateComponentSchemaRequest is the request to update a component schema
type UpdateContentTypeRequest ¶
type UpdateContentTypeRequest struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Icon string `json:"icon,omitempty"`
Settings *ContentTypeSettingsDTO `json:"settings,omitempty"`
}
UpdateContentTypeRequest is the request to update a content type
type UpdateEntryRequest ¶
type UpdateEntryRequest struct {
Data map[string]any `json:"data,omitempty"`
Status string `json:"status,omitempty"`
ScheduledAt *time.Time `json:"scheduledAt,omitempty"`
ChangeReason string `json:"changeReason,omitempty"`
}
UpdateEntryRequest is the request to update a content entry
type UpdateFieldRequest ¶
type UpdateFieldRequest struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Required *bool `json:"required,omitempty"`
Unique *bool `json:"unique,omitempty"`
Indexed *bool `json:"indexed,omitempty"`
Localized *bool `json:"localized,omitempty"`
DefaultValue any `json:"defaultValue,omitempty"`
Options *FieldOptionsDTO `json:"options,omitempty"`
Order *int `json:"order,omitempty"`
Hidden *bool `json:"hidden,omitempty"`
ReadOnly *bool `json:"readOnly,omitempty"`
}
UpdateFieldRequest is the request to update a content field
type UpdateTypeRelationRequest ¶
type UpdateTypeRelationRequest struct {
TargetFieldName *string `json:"targetFieldName,omitempty"`
OnDelete *string `json:"onDelete,omitempty"`
}
UpdateTypeRelationRequest is the request to update a type relation
type ValidationError ¶
type ValidationError struct {
Field string `json:"field"`
Message string `json:"message"`
Code string `json:"code,omitempty"`
}
ValidationError represents a validation error for a field
type ValidationResult ¶
type ValidationResult struct {
Valid bool `json:"valid"`
Errors []ValidationError `json:"errors,omitempty"`
}
ValidationResult holds the result of validation
func ValidateArrayData ¶
func ValidateArrayData(items []map[string]interface{}, fields []NestedFieldDefDTO, minItems, maxItems *int) *ValidationResult
ValidateArrayData validates an array of data against nested field definitions
func ValidateNestedData ¶
func ValidateNestedData(data map[string]interface{}, fields []NestedFieldDefDTO) *ValidationResult
ValidateNestedData validates data against nested field definitions (exported for use by services)
func ValidateOneOfWithDiscriminator ¶
func ValidateOneOfWithDiscriminator(data map[string]interface{}, discriminatorValue string, options *FieldOptionsDTO) *ValidationResult
ValidateOneOfWithDiscriminator validates oneOf data with a specific discriminator value