Documentation
¶
Overview ¶
Package service implements the business logic layer for the CMS plugin.
Package service implements the business logic layer for the CMS plugin.
Index ¶
- func ValidationResultToMap(result *core.ValidationResult) map[string]string
- type ComponentSchemaService
- func (s *ComponentSchemaService) Create(ctx context.Context, req *core.CreateComponentSchemaRequest) (*core.ComponentSchemaDTO, error)
- func (s *ComponentSchemaService) Delete(ctx context.Context, id xid.ID) error
- func (s *ComponentSchemaService) GetByID(ctx context.Context, id xid.ID) (*core.ComponentSchemaDTO, error)
- func (s *ComponentSchemaService) GetByName(ctx context.Context, name string) (*core.ComponentSchemaDTO, error)
- func (s *ComponentSchemaService) GetEffectiveFields(ctx context.Context, field *core.ContentFieldDTO) ([]core.NestedFieldDefDTO, error)
- func (s *ComponentSchemaService) List(ctx context.Context, query *core.ListComponentSchemasQuery) (*core.ListComponentSchemasResponse, error)
- func (s *ComponentSchemaService) ResolveComponentSchema(ctx context.Context, componentName string) ([]core.NestedFieldDefDTO, error)
- func (s *ComponentSchemaService) Update(ctx context.Context, id xid.ID, req *core.UpdateComponentSchemaRequest) (*core.ComponentSchemaDTO, error)
- func (s *ComponentSchemaService) ValidateComponentRef(ctx context.Context, componentSlug string, visited []string) error
- type ComponentSchemaServiceConfig
- type ContentEntryService
- func (s *ContentEntryService) Archive(ctx context.Context, id xid.ID) (*core.ContentEntryDTO, error)
- func (s *ContentEntryService) BulkDelete(ctx context.Context, ids []xid.ID) error
- func (s *ContentEntryService) BulkPublish(ctx context.Context, ids []xid.ID) error
- func (s *ContentEntryService) BulkUnpublish(ctx context.Context, ids []xid.ID) error
- func (s *ContentEntryService) Create(ctx context.Context, contentTypeID xid.ID, req *core.CreateEntryRequest) (*core.ContentEntryDTO, error)
- func (s *ContentEntryService) Delete(ctx context.Context, id xid.ID) error
- func (s *ContentEntryService) GetByID(ctx context.Context, id xid.ID) (*core.ContentEntryDTO, error)
- func (s *ContentEntryService) GetStats(ctx context.Context, contentTypeID xid.ID) (*core.ContentTypeStatsDTO, error)
- func (s *ContentEntryService) List(ctx context.Context, contentTypeID xid.ID, query *core.ListEntriesQuery) (*core.ListEntriesResponse, error)
- func (s *ContentEntryService) ProcessScheduledEntries(ctx context.Context) (int, error)
- func (s *ContentEntryService) Publish(ctx context.Context, id xid.ID, req *core.PublishEntryRequest) (*core.ContentEntryDTO, error)
- func (s *ContentEntryService) Restore(ctx context.Context, id xid.ID, version int) (*core.ContentEntryDTO, error)
- func (s *ContentEntryService) Unpublish(ctx context.Context, id xid.ID) (*core.ContentEntryDTO, error)
- func (s *ContentEntryService) Update(ctx context.Context, id xid.ID, req *core.UpdateEntryRequest) (*core.ContentEntryDTO, error)
- type ContentEntryServiceConfig
- type ContentFieldService
- func (s *ContentFieldService) Create(ctx context.Context, contentTypeID xid.ID, req *core.CreateFieldRequest) (*core.ContentFieldDTO, error)
- func (s *ContentFieldService) Delete(ctx context.Context, id xid.ID) error
- func (s *ContentFieldService) DeleteByName(ctx context.Context, contentTypeID xid.ID, name string) error
- func (s *ContentFieldService) GetByID(ctx context.Context, id xid.ID) (*core.ContentFieldDTO, error)
- func (s *ContentFieldService) GetByName(ctx context.Context, contentTypeID xid.ID, name string) (*core.ContentFieldDTO, error)
- func (s *ContentFieldService) GetFieldWithResolvedNested(ctx context.Context, id xid.ID) (*core.ContentFieldDTO, error)
- func (s *ContentFieldService) List(ctx context.Context, contentTypeID xid.ID) ([]*core.ContentFieldDTO, error)
- func (s *ContentFieldService) Reorder(ctx context.Context, contentTypeID xid.ID, req *core.ReorderFieldsRequest) error
- func (s *ContentFieldService) ResolveNestedFields(ctx context.Context, field *core.ContentFieldDTO) ([]core.NestedFieldDefDTO, error)
- func (s *ContentFieldService) SetComponentSchemaRepository(repo repository.ComponentSchemaRepository)
- func (s *ContentFieldService) SetComponentSchemaService(svc *ComponentSchemaService)
- func (s *ContentFieldService) Update(ctx context.Context, id xid.ID, req *core.UpdateFieldRequest) (*core.ContentFieldDTO, error)
- func (s *ContentFieldService) UpdateByName(ctx context.Context, contentTypeID xid.ID, name string, ...) (*core.ContentFieldDTO, error)
- type ContentFieldServiceConfig
- type ContentTypeService
- func (s *ContentTypeService) Create(ctx context.Context, req *core.CreateContentTypeRequest) (*core.ContentTypeDTO, error)
- func (s *ContentTypeService) Delete(ctx context.Context, id xid.ID) error
- func (s *ContentTypeService) GetByID(ctx context.Context, id xid.ID) (*core.ContentTypeDTO, error)
- func (s *ContentTypeService) GetByName(ctx context.Context, name string) (*core.ContentTypeDTO, error)
- func (s *ContentTypeService) GetStats(ctx context.Context) (*core.CMSStatsDTO, error)
- func (s *ContentTypeService) HardDelete(ctx context.Context, id xid.ID) error
- func (s *ContentTypeService) List(ctx context.Context, query *core.ListContentTypesQuery) (*core.ListContentTypesResponse, error)
- func (s *ContentTypeService) Update(ctx context.Context, id xid.ID, req *core.UpdateContentTypeRequest) (*core.ContentTypeDTO, error)
- type ContentTypeServiceConfig
- type EntryValidator
- func (v *EntryValidator) ApplyDefaults(data map[string]interface{}) map[string]interface{}
- func (v *EntryValidator) GetFieldsForDisplay() []*schema.ContentField
- func (v *EntryValidator) GetRelationFields() []*schema.ContentField
- func (v *EntryValidator) GetRequiredFields() []*schema.ContentField
- func (v *EntryValidator) GetSearchableFields() []*schema.ContentField
- func (v *EntryValidator) SanitizeData(data map[string]interface{}) map[string]interface{}
- func (v *EntryValidator) ValidateCreate(data map[string]interface{}) *core.ValidationResult
- func (v *EntryValidator) ValidateUniqueConstraints(data map[string]interface{}, existingID *xid.ID, ...) *core.ValidationResult
- func (v *EntryValidator) ValidateUpdate(data map[string]interface{}, existingEntry *schema.ContentEntry) *core.ValidationResult
- type RelationService
- func (s *RelationService) AddRelation(ctx context.Context, sourceID xid.ID, fieldSlug string, targetID xid.ID) error
- func (s *RelationService) ClearRelations(ctx context.Context, sourceID xid.ID, fieldSlug string) error
- func (s *RelationService) CreateTypeRelation(ctx context.Context, req *core.CreateTypeRelationRequest) (*core.TypeRelationDTO, error)
- func (s *RelationService) DeleteAllEntryRelations(ctx context.Context, entryID xid.ID) error
- func (s *RelationService) DeleteTypeRelation(ctx context.Context, id xid.ID) error
- func (s *RelationService) GetRelatedIDs(ctx context.Context, sourceID xid.ID, fieldSlug string) ([]xid.ID, error)
- func (s *RelationService) GetRelations(ctx context.Context, sourceID xid.ID, fieldSlug string) ([]*core.RelatedEntryDTO, error)
- func (s *RelationService) GetReverseRelations(ctx context.Context, targetID xid.ID, fieldSlug string) ([]*core.RelatedEntryDTO, error)
- func (s *RelationService) GetTypeRelation(ctx context.Context, id xid.ID) (*core.TypeRelationDTO, error)
- func (s *RelationService) GetTypeRelationByField(ctx context.Context, contentTypeID xid.ID, fieldSlug string) (*core.TypeRelationDTO, error)
- func (s *RelationService) GetTypeRelationsForType(ctx context.Context, contentTypeID xid.ID) ([]*core.TypeRelationDTO, error)
- func (s *RelationService) PopulateRelations(ctx context.Context, entries []*schema.ContentEntry, fieldSlugs []string) error
- func (s *RelationService) PopulateRelationsMap(ctx context.Context, entryID xid.ID, fieldSlugs []string) (map[string][]*core.ContentEntrySummaryDTO, error)
- func (s *RelationService) RemoveRelation(ctx context.Context, sourceID xid.ID, fieldSlug string, targetID xid.ID) error
- func (s *RelationService) ReorderRelations(ctx context.Context, sourceID xid.ID, fieldSlug string, ...) error
- func (s *RelationService) SetRelation(ctx context.Context, sourceID xid.ID, fieldSlug string, targetID xid.ID) error
- func (s *RelationService) SetRelations(ctx context.Context, sourceID xid.ID, fieldSlug string, targetIDs []xid.ID) error
- func (s *RelationService) UpdateTypeRelation(ctx context.Context, id xid.ID, req *core.UpdateTypeRelationRequest) (*core.TypeRelationDTO, error)
- type RelationServiceConfig
- type RevisionService
- func (s *RevisionService) CleanupOld(ctx context.Context, entryID xid.ID, maxRevisions int) error
- func (s *RevisionService) Compare(ctx context.Context, entryID xid.ID, fromVersion, toVersion int) (*core.RevisionCompareDTO, error)
- func (s *RevisionService) Create(ctx context.Context, entryID xid.ID, data map[string]any, ...) (*core.RevisionDTO, error)
- func (s *RevisionService) GetByVersion(ctx context.Context, entryID xid.ID, version int) (*core.RevisionDTO, error)
- func (s *RevisionService) List(ctx context.Context, entryID xid.ID, query *core.ListRevisionsQuery) (*core.PaginatedResponse[*core.RevisionDTO], error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidationResultToMap ¶
func ValidationResultToMap(result *core.ValidationResult) map[string]string
ValidationResultToMap converts validation result to error map for API responses
Types ¶
type ComponentSchemaService ¶
type ComponentSchemaService struct {
// contains filtered or unexported fields
}
ComponentSchemaService handles component schema business logic
func NewComponentSchemaService ¶
func NewComponentSchemaService( repo repository.ComponentSchemaRepository, config ComponentSchemaServiceConfig, ) *ComponentSchemaService
NewComponentSchemaService creates a new component schema service
func (*ComponentSchemaService) Create ¶
func (s *ComponentSchemaService) Create(ctx context.Context, req *core.CreateComponentSchemaRequest) (*core.ComponentSchemaDTO, error)
Create creates a new component schema
func (*ComponentSchemaService) GetByID ¶
func (s *ComponentSchemaService) GetByID(ctx context.Context, id xid.ID) (*core.ComponentSchemaDTO, error)
GetByID retrieves a component schema by ID
func (*ComponentSchemaService) GetByName ¶
func (s *ComponentSchemaService) GetByName(ctx context.Context, name string) (*core.ComponentSchemaDTO, error)
GetBySlug retrieves a component schema by slug
func (*ComponentSchemaService) GetEffectiveFields ¶
func (s *ComponentSchemaService) GetEffectiveFields(ctx context.Context, field *core.ContentFieldDTO) ([]core.NestedFieldDefDTO, error)
GetEffectiveFields returns the effective nested fields for a field, resolving component refs
func (*ComponentSchemaService) List ¶
func (s *ComponentSchemaService) List(ctx context.Context, query *core.ListComponentSchemasQuery) (*core.ListComponentSchemasResponse, error)
List lists component schemas with pagination
func (*ComponentSchemaService) ResolveComponentSchema ¶
func (s *ComponentSchemaService) ResolveComponentSchema(ctx context.Context, componentName string) ([]core.NestedFieldDefDTO, error)
ResolveComponentSchema resolves a component reference and returns the nested fields
func (*ComponentSchemaService) Update ¶
func (s *ComponentSchemaService) Update(ctx context.Context, id xid.ID, req *core.UpdateComponentSchemaRequest) (*core.ComponentSchemaDTO, error)
Update updates a component schema
func (*ComponentSchemaService) ValidateComponentRef ¶
func (s *ComponentSchemaService) ValidateComponentRef(ctx context.Context, componentSlug string, visited []string) error
ValidateComponentRef validates that a component reference is valid and not circular
type ComponentSchemaServiceConfig ¶
ComponentSchemaServiceConfig holds configuration for the service
type ContentEntryService ¶
type ContentEntryService struct {
// contains filtered or unexported fields
}
ContentEntryService handles content entry business logic
func NewContentEntryService ¶
func NewContentEntryService( repo repository.ContentEntryRepository, contentTypeRepo repository.ContentTypeRepository, revisionRepo repository.RevisionRepository, config ContentEntryServiceConfig, ) *ContentEntryService
NewContentEntryService creates a new content entry service
func (*ContentEntryService) Archive ¶
func (s *ContentEntryService) Archive(ctx context.Context, id xid.ID) (*core.ContentEntryDTO, error)
Archive archives a content entry
func (*ContentEntryService) BulkDelete ¶
BulkDelete deletes multiple entries
func (*ContentEntryService) BulkPublish ¶
BulkPublish publishes multiple entries
func (*ContentEntryService) BulkUnpublish ¶
BulkUnpublish unpublishes multiple entries
func (*ContentEntryService) Create ¶
func (s *ContentEntryService) Create(ctx context.Context, contentTypeID xid.ID, req *core.CreateEntryRequest) (*core.ContentEntryDTO, error)
Create creates a new content entry
func (*ContentEntryService) GetByID ¶
func (s *ContentEntryService) GetByID(ctx context.Context, id xid.ID) (*core.ContentEntryDTO, error)
GetByID retrieves a content entry by ID
func (*ContentEntryService) GetStats ¶
func (s *ContentEntryService) GetStats(ctx context.Context, contentTypeID xid.ID) (*core.ContentTypeStatsDTO, error)
GetStats returns statistics for entries
func (*ContentEntryService) List ¶
func (s *ContentEntryService) List(ctx context.Context, contentTypeID xid.ID, query *core.ListEntriesQuery) (*core.ListEntriesResponse, error)
List lists content entries with filtering and pagination
func (*ContentEntryService) ProcessScheduledEntries ¶
func (s *ContentEntryService) ProcessScheduledEntries(ctx context.Context) (int, error)
ProcessScheduledEntries processes entries scheduled for publishing
func (*ContentEntryService) Publish ¶
func (s *ContentEntryService) Publish(ctx context.Context, id xid.ID, req *core.PublishEntryRequest) (*core.ContentEntryDTO, error)
Publish publishes a content entry
func (*ContentEntryService) Restore ¶
func (s *ContentEntryService) Restore(ctx context.Context, id xid.ID, version int) (*core.ContentEntryDTO, error)
Restore restores an entry to a specific revision version
func (*ContentEntryService) Unpublish ¶
func (s *ContentEntryService) Unpublish(ctx context.Context, id xid.ID) (*core.ContentEntryDTO, error)
Unpublish unpublishes a content entry
func (*ContentEntryService) Update ¶
func (s *ContentEntryService) Update(ctx context.Context, id xid.ID, req *core.UpdateEntryRequest) (*core.ContentEntryDTO, error)
Update updates a content entry
type ContentEntryServiceConfig ¶
type ContentEntryServiceConfig struct {
EnableRevisions bool
MaxRevisionsPerEntry int
Logger forge.Logger
}
ContentEntryServiceConfig holds configuration for the service
type ContentFieldService ¶
type ContentFieldService struct {
// contains filtered or unexported fields
}
ContentFieldService handles content field business logic
func NewContentFieldService ¶
func NewContentFieldService( repo repository.ContentFieldRepository, contentTypeRepo repository.ContentTypeRepository, config ContentFieldServiceConfig, ) *ContentFieldService
NewContentFieldService creates a new content field service
func (*ContentFieldService) Create ¶
func (s *ContentFieldService) Create(ctx context.Context, contentTypeID xid.ID, req *core.CreateFieldRequest) (*core.ContentFieldDTO, error)
Create creates a new content field
func (*ContentFieldService) DeleteByName ¶
func (s *ContentFieldService) DeleteByName(ctx context.Context, contentTypeID xid.ID, name string) error
DeleteBySlug deletes a content field by its name within a content type
func (*ContentFieldService) GetByID ¶
func (s *ContentFieldService) GetByID(ctx context.Context, id xid.ID) (*core.ContentFieldDTO, error)
GetByID retrieves a content field by ID
func (*ContentFieldService) GetByName ¶
func (s *ContentFieldService) GetByName(ctx context.Context, contentTypeID xid.ID, name string) (*core.ContentFieldDTO, error)
GetBySlug retrieves a content field by slug
func (*ContentFieldService) GetFieldWithResolvedNested ¶
func (s *ContentFieldService) GetFieldWithResolvedNested(ctx context.Context, id xid.ID) (*core.ContentFieldDTO, error)
GetFieldWithResolvedNested returns a field DTO with resolved nested fields
func (*ContentFieldService) List ¶
func (s *ContentFieldService) List(ctx context.Context, contentTypeID xid.ID) ([]*core.ContentFieldDTO, error)
List lists fields for a content type
func (*ContentFieldService) Reorder ¶
func (s *ContentFieldService) Reorder(ctx context.Context, contentTypeID xid.ID, req *core.ReorderFieldsRequest) error
Reorder reorders fields in a content type
func (*ContentFieldService) ResolveNestedFields ¶
func (s *ContentFieldService) ResolveNestedFields(ctx context.Context, field *core.ContentFieldDTO) ([]core.NestedFieldDefDTO, error)
ResolveNestedFields resolves nested fields for a field, handling component refs
func (*ContentFieldService) SetComponentSchemaRepository ¶
func (s *ContentFieldService) SetComponentSchemaRepository(repo repository.ComponentSchemaRepository)
SetComponentSchemaRepository sets the component schema repository
func (*ContentFieldService) SetComponentSchemaService ¶
func (s *ContentFieldService) SetComponentSchemaService(svc *ComponentSchemaService)
SetComponentSchemaService sets the component schema service for resolving component refs
func (*ContentFieldService) Update ¶
func (s *ContentFieldService) Update(ctx context.Context, id xid.ID, req *core.UpdateFieldRequest) (*core.ContentFieldDTO, error)
Update updates a content field
func (*ContentFieldService) UpdateByName ¶
func (s *ContentFieldService) UpdateByName(ctx context.Context, contentTypeID xid.ID, name string, req *core.UpdateFieldRequest) (*core.ContentFieldDTO, error)
UpdateBySlug updates a content field by its name within a content type
type ContentFieldServiceConfig ¶
ContentFieldServiceConfig holds configuration for the service
type ContentTypeService ¶
type ContentTypeService struct {
// contains filtered or unexported fields
}
ContentTypeService handles content type business logic
func NewContentTypeService ¶
func NewContentTypeService( repo repository.ContentTypeRepository, fieldRepo repository.ContentFieldRepository, config ContentTypeServiceConfig, ) *ContentTypeService
NewContentTypeService creates a new content type service
func (*ContentTypeService) Create ¶
func (s *ContentTypeService) Create(ctx context.Context, req *core.CreateContentTypeRequest) (*core.ContentTypeDTO, error)
Create creates a new content type
func (*ContentTypeService) GetByID ¶
func (s *ContentTypeService) GetByID(ctx context.Context, id xid.ID) (*core.ContentTypeDTO, error)
GetByID retrieves a content type by ID
func (*ContentTypeService) GetByName ¶
func (s *ContentTypeService) GetByName(ctx context.Context, name string) (*core.ContentTypeDTO, error)
GetBySlug retrieves a content type by slug
func (*ContentTypeService) GetStats ¶
func (s *ContentTypeService) GetStats(ctx context.Context) (*core.CMSStatsDTO, error)
GetStats returns statistics for content types
func (*ContentTypeService) HardDelete ¶
HardDelete permanently deletes a content type and all its data
func (*ContentTypeService) List ¶
func (s *ContentTypeService) List(ctx context.Context, query *core.ListContentTypesQuery) (*core.ListContentTypesResponse, error)
List lists content types with filtering and pagination
func (*ContentTypeService) Update ¶
func (s *ContentTypeService) Update(ctx context.Context, id xid.ID, req *core.UpdateContentTypeRequest) (*core.ContentTypeDTO, error)
Update updates a content type
type ContentTypeServiceConfig ¶
ContentTypeServiceConfig holds configuration for the service
type EntryValidator ¶
type EntryValidator struct {
// contains filtered or unexported fields
}
EntryValidator validates content entry data against content type schema
func NewEntryValidator ¶
func NewEntryValidator(contentType *schema.ContentType) *EntryValidator
NewEntryValidator creates a new entry validator for a content type
func (*EntryValidator) ApplyDefaults ¶
func (v *EntryValidator) ApplyDefaults(data map[string]interface{}) map[string]interface{}
ApplyDefaults applies default values to entry data
func (*EntryValidator) GetFieldsForDisplay ¶
func (v *EntryValidator) GetFieldsForDisplay() []*schema.ContentField
GetFieldsForDisplay returns fields that should be displayed (non-hidden)
func (*EntryValidator) GetRelationFields ¶
func (v *EntryValidator) GetRelationFields() []*schema.ContentField
GetRelationFields returns all relation fields
func (*EntryValidator) GetRequiredFields ¶
func (v *EntryValidator) GetRequiredFields() []*schema.ContentField
GetRequiredFields returns all required fields
func (*EntryValidator) GetSearchableFields ¶
func (v *EntryValidator) GetSearchableFields() []*schema.ContentField
GetSearchableFields returns all fields that can be searched
func (*EntryValidator) SanitizeData ¶
func (v *EntryValidator) SanitizeData(data map[string]interface{}) map[string]interface{}
SanitizeData removes hidden and read-only fields from input data
func (*EntryValidator) ValidateCreate ¶
func (v *EntryValidator) ValidateCreate(data map[string]interface{}) *core.ValidationResult
ValidateCreate validates entry data for creation
func (*EntryValidator) ValidateUniqueConstraints ¶
func (v *EntryValidator) ValidateUniqueConstraints( data map[string]interface{}, existingID *xid.ID, checkUnique func(field string, value interface{}, excludeID *xid.ID) (bool, error), ) *core.ValidationResult
ValidateUniqueConstraints validates unique constraints (needs to be called separately with DB access)
func (*EntryValidator) ValidateUpdate ¶
func (v *EntryValidator) ValidateUpdate(data map[string]interface{}, existingEntry *schema.ContentEntry) *core.ValidationResult
ValidateUpdate validates entry data for update
type RelationService ¶
type RelationService struct {
// contains filtered or unexported fields
}
RelationService handles content relations
func NewRelationService ¶
func NewRelationService( repo repository.RelationRepository, entryRepo repository.ContentEntryRepository, contentTypeRepo repository.ContentTypeRepository, config RelationServiceConfig, ) *RelationService
NewRelationService creates a new relation service
func (*RelationService) AddRelation ¶
func (s *RelationService) AddRelation(ctx context.Context, sourceID xid.ID, fieldSlug string, targetID xid.ID) error
AddRelation adds a single relation to existing relations
func (*RelationService) ClearRelations ¶
func (s *RelationService) ClearRelations(ctx context.Context, sourceID xid.ID, fieldSlug string) error
ClearRelations removes all relations for a field
func (*RelationService) CreateTypeRelation ¶
func (s *RelationService) CreateTypeRelation(ctx context.Context, req *core.CreateTypeRelationRequest) (*core.TypeRelationDTO, error)
CreateTypeRelation creates a new type relation definition
func (*RelationService) DeleteAllEntryRelations ¶
DeleteAllEntryRelations removes all relations for an entry (when deleting entry)
func (*RelationService) DeleteTypeRelation ¶
DeleteTypeRelation deletes a type relation definition
func (*RelationService) GetRelatedIDs ¶
func (s *RelationService) GetRelatedIDs(ctx context.Context, sourceID xid.ID, fieldSlug string) ([]xid.ID, error)
GetRelatedIDs returns just the IDs of related entries
func (*RelationService) GetRelations ¶
func (s *RelationService) GetRelations(ctx context.Context, sourceID xid.ID, fieldSlug string) ([]*core.RelatedEntryDTO, error)
GetRelations returns all related entries for a field
func (*RelationService) GetReverseRelations ¶
func (s *RelationService) GetReverseRelations(ctx context.Context, targetID xid.ID, fieldSlug string) ([]*core.RelatedEntryDTO, error)
GetReverseRelations returns all entries that reference this entry
func (*RelationService) GetTypeRelation ¶
func (s *RelationService) GetTypeRelation(ctx context.Context, id xid.ID) (*core.TypeRelationDTO, error)
GetTypeRelation gets a type relation by ID
func (*RelationService) GetTypeRelationByField ¶
func (s *RelationService) GetTypeRelationByField(ctx context.Context, contentTypeID xid.ID, fieldSlug string) (*core.TypeRelationDTO, error)
GetTypeRelationByField gets a type relation by content type and field
func (*RelationService) GetTypeRelationsForType ¶
func (s *RelationService) GetTypeRelationsForType(ctx context.Context, contentTypeID xid.ID) ([]*core.TypeRelationDTO, error)
GetTypeRelationsForType gets all type relations for a content type
func (*RelationService) PopulateRelations ¶
func (s *RelationService) PopulateRelations(ctx context.Context, entries []*schema.ContentEntry, fieldSlugs []string) error
PopulateRelations populates relation fields on entries
func (*RelationService) PopulateRelationsMap ¶
func (s *RelationService) PopulateRelationsMap(ctx context.Context, entryID xid.ID, fieldSlugs []string) (map[string][]*core.ContentEntrySummaryDTO, error)
PopulateRelationsMap returns populated relations as a map of field -> entries
func (*RelationService) RemoveRelation ¶
func (s *RelationService) RemoveRelation(ctx context.Context, sourceID xid.ID, fieldSlug string, targetID xid.ID) error
RemoveRelation removes a single relation
func (*RelationService) ReorderRelations ¶
func (s *RelationService) ReorderRelations(ctx context.Context, sourceID xid.ID, fieldSlug string, orderedTargetIDs []xid.ID) error
ReorderRelations reorders the relations for a field
func (*RelationService) SetRelation ¶
func (s *RelationService) SetRelation(ctx context.Context, sourceID xid.ID, fieldSlug string, targetID xid.ID) error
SetRelation sets a single relation (for one-to-one or many-to-one)
func (*RelationService) SetRelations ¶
func (s *RelationService) SetRelations(ctx context.Context, sourceID xid.ID, fieldSlug string, targetIDs []xid.ID) error
SetRelations sets multiple relations (for one-to-many or many-to-many)
func (*RelationService) UpdateTypeRelation ¶
func (s *RelationService) UpdateTypeRelation(ctx context.Context, id xid.ID, req *core.UpdateTypeRelationRequest) (*core.TypeRelationDTO, error)
UpdateTypeRelation updates a type relation definition
type RelationServiceConfig ¶
type RelationServiceConfig struct {
// MaxRelationsPerField limits relations per field (0 = unlimited)
MaxRelationsPerField int
// AllowCircularRelations allows circular references (default: false)
AllowCircularRelations bool
// Logger for relation operations
Logger forge.Logger
}
RelationServiceConfig holds configuration for the relation service
type RevisionService ¶
type RevisionService struct {
// contains filtered or unexported fields
}
RevisionService handles revision operations
func NewRevisionService ¶
func NewRevisionService(repo repository.RevisionRepository, logger forge.Logger) *RevisionService
NewRevisionService creates a new revision service
func (*RevisionService) CleanupOld ¶
CleanupOld removes old revisions exceeding the max count
func (*RevisionService) Compare ¶
func (s *RevisionService) Compare(ctx context.Context, entryID xid.ID, fromVersion, toVersion int) (*core.RevisionCompareDTO, error)
Compare compares two revisions and returns the differences
func (*RevisionService) Create ¶
func (s *RevisionService) Create(ctx context.Context, entryID xid.ID, data map[string]any, changedBy, reason string) (*core.RevisionDTO, error)
Create creates a new revision
func (*RevisionService) GetByVersion ¶
func (s *RevisionService) GetByVersion(ctx context.Context, entryID xid.ID, version int) (*core.RevisionDTO, error)
GetByVersion returns a specific revision by version
func (*RevisionService) List ¶
func (s *RevisionService) List(ctx context.Context, entryID xid.ID, query *core.ListRevisionsQuery) (*core.PaginatedResponse[*core.RevisionDTO], error)
List returns revisions for an entry