template

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildVersionInjectableDefaults

func BuildVersionInjectableDefaults(injectables []*entity.VersionInjectableWithDefinition) map[string]string

BuildVersionInjectableDefaults builds a map of default values from version injectables. Priority: TemplateVersionInjectable.DefaultValue > InjectableDefinition.DefaultValue.

func NewInternalRenderService

func NewInternalRenderService(
	tenantRepo port.TenantRepository,
	workspaceRepo port.WorkspaceRepository,
	docTypeRepo port.DocumentTypeRepository,
	templateRepo port.TemplateRepository,
	versionRepo port.TemplateVersionRepository,
	pdfRenderer port.PDFRenderer,
	resolver *injectablesvc.InjectableResolverService,
	templateCache *TemplateCache,
) templateuc.InternalRenderUseCase

NewInternalRenderService creates a new internal render service.

func NewTemplateService

func NewTemplateService(
	templateRepo port.TemplateRepository,
	versionRepo port.TemplateVersionRepository,
	tagRepo port.TemplateTagRepository,
) templateuc.TemplateUseCase

NewTemplateService creates a new template service.

func NewTemplateVersionService

func NewTemplateVersionService(
	versionRepo port.TemplateVersionRepository,
	injectableRepo port.TemplateVersionInjectableRepository,
	templateRepo port.TemplateRepository,
	contentValidator port.ContentValidator,
) templateuc.TemplateVersionUseCase

NewTemplateVersionService creates a new template version service.

Types

type InternalRenderService

type InternalRenderService struct {
	// contains filtered or unexported fields
}

InternalRenderService implements the internal render use case with fallback chain.

func (*InternalRenderService) RenderByDocumentType

RenderByDocumentType resolves a template using the fallback chain and renders a PDF.

func (*InternalRenderService) RenderByWorkspaceID

RenderByWorkspaceID resolves a template using workspace ID and document type code.

type TemplateCache

type TemplateCache struct {
	// contains filtered or unexported fields
}

TemplateCache provides an in-memory cache for resolved template versions.

func NewTemplateCache

func NewTemplateCache(maxEntries int64, ttl time.Duration) (*TemplateCache, error)

NewTemplateCache creates a new template cache. maxEntries controls the approximate number of items the cache will hold. ttl controls how long items remain valid.

func (*TemplateCache) Close

func (c *TemplateCache) Close()

Close releases cache resources.

func (*TemplateCache) Get

func (c *TemplateCache) Get(tenantCode, workspaceCode, docTypeCode string) *entity.TemplateVersionWithDetails

Get retrieves a cached template version, returning nil on miss.

func (*TemplateCache) Set

func (c *TemplateCache) Set(tenantCode, workspaceCode, docTypeCode string, version *entity.TemplateVersionWithDetails)

Set stores a resolved template version in the cache.

type TemplateService

type TemplateService struct {
	// contains filtered or unexported fields
}

TemplateService implements template business logic.

func (*TemplateService) AddTag

func (s *TemplateService) AddTag(ctx context.Context, templateID, tagID string) error

AddTag adds a tag to a template.

func (*TemplateService) AssignDocumentType

AssignDocumentType assigns or unassigns a document type to a template.

func (*TemplateService) CloneTemplate

CloneTemplate creates a copy of an existing template from a specific version.

func (*TemplateService) CreateTemplate

CreateTemplate creates a new template with an initial draft version.

func (*TemplateService) DeleteTemplate

func (s *TemplateService) DeleteTemplate(ctx context.Context, id string) error

DeleteTemplate deletes a template and all its versions.

func (*TemplateService) FindByDocumentTypeCode

func (s *TemplateService) FindByDocumentTypeCode(ctx context.Context, tenantID, code string) ([]*entity.TemplateListItem, error)

FindByDocumentTypeCode finds templates by document type code across a tenant.

func (*TemplateService) GetTemplate

func (s *TemplateService) GetTemplate(ctx context.Context, id string) (*entity.Template, error)

GetTemplate retrieves a template by ID.

func (*TemplateService) GetTemplateWithAllVersions

func (s *TemplateService) GetTemplateWithAllVersions(ctx context.Context, id string) (*entity.TemplateWithAllVersions, error)

GetTemplateWithAllVersions retrieves a template with all its versions.

func (*TemplateService) GetTemplateWithDetails

func (s *TemplateService) GetTemplateWithDetails(ctx context.Context, id string) (*entity.TemplateWithDetails, error)

GetTemplateWithDetails retrieves a template with published version, tags, and folder.

func (*TemplateService) ListPublicLibrary

func (s *TemplateService) ListPublicLibrary(ctx context.Context, workspaceID string) ([]*entity.TemplateListItem, error)

ListPublicLibrary lists all public library templates.

func (*TemplateService) ListTemplates

func (s *TemplateService) ListTemplates(ctx context.Context, workspaceID string, filters port.TemplateFilters) ([]*entity.TemplateListItem, error)

ListTemplates lists all templates in a workspace with optional filters.

func (*TemplateService) ListTemplatesByFolder

func (s *TemplateService) ListTemplatesByFolder(ctx context.Context, folderID string) ([]*entity.TemplateListItem, error)

ListTemplatesByFolder lists all templates in a folder.

func (*TemplateService) RemoveTag

func (s *TemplateService) RemoveTag(ctx context.Context, templateID, tagID string) error

RemoveTag removes a tag from a template.

func (*TemplateService) UpdateTemplate

UpdateTemplate updates a template's metadata. Supports partial updates - only non-nil fields are updated.

type TemplateVersionService

type TemplateVersionService struct {
	// contains filtered or unexported fields
}

TemplateVersionService implements template version business logic.

func (*TemplateVersionService) AddInjectable

AddInjectable adds an injectable to a version.

func (*TemplateVersionService) ArchiveVersion

func (s *TemplateVersionService) ArchiveVersion(ctx context.Context, id string, userID string) error

ArchiveVersion manually archives a published version.

func (*TemplateVersionService) CancelSchedule

func (s *TemplateVersionService) CancelSchedule(ctx context.Context, versionID string) error

CancelSchedule cancels any scheduled publication or archival.

func (*TemplateVersionService) CreateVersion

CreateVersion creates a new version for a template.

func (*TemplateVersionService) CreateVersionFromExisting

func (s *TemplateVersionService) CreateVersionFromExisting(ctx context.Context, sourceVersionID string, name string, description *string, createdBy *string) (*entity.TemplateVersion, error)

CreateVersionFromExisting creates a new version copying content from an existing version.

func (*TemplateVersionService) DeleteVersion

func (s *TemplateVersionService) DeleteVersion(ctx context.Context, id string) error

DeleteVersion deletes a draft version.

func (*TemplateVersionService) GetPublishedVersion

func (s *TemplateVersionService) GetPublishedVersion(ctx context.Context, templateID string) (*entity.TemplateVersionWithDetails, error)

GetPublishedVersion gets the currently published version for a template.

func (*TemplateVersionService) GetVersion

GetVersion retrieves a template version by ID.

func (*TemplateVersionService) GetVersionWithDetails

func (s *TemplateVersionService) GetVersionWithDetails(ctx context.Context, id string) (*entity.TemplateVersionWithDetails, error)

GetVersionWithDetails retrieves a version with all related data.

func (*TemplateVersionService) ListVersions

func (s *TemplateVersionService) ListVersions(ctx context.Context, templateID string) ([]*entity.TemplateVersion, error)

ListVersions lists all versions for a template.

func (*TemplateVersionService) ProcessScheduledArchivals

func (s *TemplateVersionService) ProcessScheduledArchivals(ctx context.Context) error

ProcessScheduledArchivals archives all published versions whose scheduled archive time has passed.

func (*TemplateVersionService) ProcessScheduledPublications

func (s *TemplateVersionService) ProcessScheduledPublications(ctx context.Context) error

ProcessScheduledPublications publishes all versions whose scheduled time has passed.

func (*TemplateVersionService) PublishVersion

func (s *TemplateVersionService) PublishVersion(ctx context.Context, id string, userID string) error

PublishVersion publishes a version (archives current published if exists).

func (*TemplateVersionService) RemoveInjectable

func (s *TemplateVersionService) RemoveInjectable(ctx context.Context, id string) error

RemoveInjectable removes an injectable from a version.

func (*TemplateVersionService) ScheduleArchive

ScheduleArchive schedules the current published version for future archival.

func (*TemplateVersionService) SchedulePublish

SchedulePublish schedules a version for future publication.

func (*TemplateVersionService) UpdateVersion

UpdateVersion updates a template version.

Directories

Path Synopsis
Package contentvalidator provides content structure validation for template versions.
Package contentvalidator provides content structure validation for template versions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL