Implement complete collection persistence with database-backed survival across server restarts

• Add full multi-table schema for collections with normalized design (collections, collection_templates, collection_items, collection_item_versions)
• Implement collection detection and processing in enhancement pipeline for .insertr-add elements
• Add template extraction and storage from existing HTML children with multi-variant support
• Enable collection reconstruction from database on server restart with proper DOM rebuilding
• Extend ContentClient interface with collection operations and full database integration
• Update enhance command to use engine.DatabaseClient for collection persistence support
This commit is contained in:
2025-09-22 18:29:58 +02:00
parent b25663f76b
commit 2315ba4750
36 changed files with 4356 additions and 46 deletions

View File

@@ -9,20 +9,58 @@ import (
)
type Querier interface {
CreateCollection(ctx context.Context, arg CreateCollectionParams) (Collection, error)
CreateCollectionItem(ctx context.Context, arg CreateCollectionItemParams) (CollectionItem, error)
// Collection item versions table queries
CreateCollectionItemVersion(ctx context.Context, arg CreateCollectionItemVersionParams) error
CreateCollectionTemplate(ctx context.Context, arg CreateCollectionTemplateParams) (CollectionTemplate, error)
CreateContent(ctx context.Context, arg CreateContentParams) (Content, error)
CreateContentVersion(ctx context.Context, arg CreateContentVersionParams) error
DeleteAllSiteCollections(ctx context.Context, siteID string) error
DeleteAllSiteContent(ctx context.Context, siteID string) error
DeleteCollection(ctx context.Context, arg DeleteCollectionParams) error
DeleteCollectionItem(ctx context.Context, arg DeleteCollectionItemParams) error
DeleteCollectionItems(ctx context.Context, arg DeleteCollectionItemsParams) error
DeleteCollectionTemplate(ctx context.Context, templateID int64) error
DeleteCollectionTemplates(ctx context.Context, arg DeleteCollectionTemplatesParams) error
DeleteContent(ctx context.Context, arg DeleteContentParams) error
DeleteOldCollectionItemVersions(ctx context.Context, arg DeleteOldCollectionItemVersionsParams) error
DeleteOldVersions(ctx context.Context, arg DeleteOldVersionsParams) error
GetAllCollectionItemVersionsForSite(ctx context.Context, arg GetAllCollectionItemVersionsForSiteParams) ([]GetAllCollectionItemVersionsForSiteRow, error)
GetAllCollections(ctx context.Context, siteID string) ([]Collection, error)
GetAllContent(ctx context.Context, siteID string) ([]Content, error)
GetAllVersionsForSite(ctx context.Context, arg GetAllVersionsForSiteParams) ([]GetAllVersionsForSiteRow, error)
GetBulkContent(ctx context.Context, arg GetBulkContentParams) ([]Content, error)
// Collections table queries
GetCollection(ctx context.Context, arg GetCollectionParams) (Collection, error)
// Collection items table queries
GetCollectionItem(ctx context.Context, arg GetCollectionItemParams) (CollectionItem, error)
GetCollectionItemVersion(ctx context.Context, versionID int64) (CollectionItemVersion, error)
GetCollectionItemVersionHistory(ctx context.Context, arg GetCollectionItemVersionHistoryParams) ([]CollectionItemVersion, error)
GetCollectionItems(ctx context.Context, arg GetCollectionItemsParams) ([]CollectionItem, error)
GetCollectionItemsWithTemplate(ctx context.Context, arg GetCollectionItemsWithTemplateParams) ([]GetCollectionItemsWithTemplateRow, error)
// Collection templates table queries
GetCollectionTemplate(ctx context.Context, templateID int64) (CollectionTemplate, error)
GetCollectionTemplates(ctx context.Context, arg GetCollectionTemplatesParams) ([]CollectionTemplate, error)
GetContent(ctx context.Context, arg GetContentParams) (Content, error)
GetContentVersion(ctx context.Context, versionID int64) (ContentVersion, error)
GetContentVersionHistory(ctx context.Context, arg GetContentVersionHistoryParams) ([]ContentVersion, error)
GetDefaultTemplate(ctx context.Context, arg GetDefaultTemplateParams) (CollectionTemplate, error)
GetMaxPosition(ctx context.Context, arg GetMaxPositionParams) (interface{}, error)
InitializeCollectionItemVersionsTable(ctx context.Context) error
InitializeCollectionItemsTable(ctx context.Context) error
InitializeCollectionTemplatesTable(ctx context.Context) error
InitializeCollectionsTable(ctx context.Context) error
InitializeSchema(ctx context.Context) error
InitializeVersionsTable(ctx context.Context) error
ReorderCollectionItems(ctx context.Context, arg ReorderCollectionItemsParams) error
SetTemplateAsDefault(ctx context.Context, arg SetTemplateAsDefaultParams) error
UpdateCollection(ctx context.Context, arg UpdateCollectionParams) (Collection, error)
UpdateCollectionItem(ctx context.Context, arg UpdateCollectionItemParams) (CollectionItem, error)
UpdateCollectionItemPosition(ctx context.Context, arg UpdateCollectionItemPositionParams) error
UpdateCollectionTemplate(ctx context.Context, arg UpdateCollectionTemplateParams) (CollectionTemplate, error)
UpdateContent(ctx context.Context, arg UpdateContentParams) (Content, error)
UpsertCollection(ctx context.Context, arg UpsertCollectionParams) (Collection, error)
UpsertContent(ctx context.Context, arg UpsertContentParams) (Content, error)
}