template

package
v1.0.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddVersionInjectableCommand

type AddVersionInjectableCommand struct {
	VersionID              string
	InjectableDefinitionID string
	IsRequired             bool
	DefaultValue           *string
}

AddVersionInjectableCommand represents the command to add an injectable to a version.

type AssignDocumentTypeCommand

type AssignDocumentTypeCommand struct {
	TemplateID     string
	WorkspaceID    string  // For conflict checking
	DocumentTypeID *string // nil to unassign
	Force          bool    // true = reassign even if type is used by another template
}

AssignDocumentTypeCommand represents the command to assign/unassign a document type.

type AssignDocumentTypeResult

type AssignDocumentTypeResult struct {
	Template *entity.Template
	Conflict *TemplateConflictInfo // Non-nil if there's a conflict and Force=false
}

AssignDocumentTypeResult represents the result of assigning a document type.

type CloneTemplateCommand

type CloneTemplateCommand struct {
	SourceTemplateID string
	VersionID        string
	NewTitle         string
	TargetFolderID   *string
	ClonedBy         string
}

CloneTemplateCommand represents the command to clone a template.

type CreateTemplateCommand

type CreateTemplateCommand struct {
	WorkspaceID      string
	FolderID         *string
	Title            string
	ContentStructure json.RawMessage
	IsPublicLibrary  bool
	CreatedBy        string
}

CreateTemplateCommand represents the command to create a template.

type CreateVersionCommand

type CreateVersionCommand struct {
	TemplateID  string
	Name        string
	Description *string
	CreatedBy   *string
}

CreateVersionCommand represents the command to create a new template version.

type InternalRenderCommand

type InternalRenderCommand struct {
	TenantCode       string
	WorkspaceCode    string
	TemplateTypeCode string
	Injectables      map[string]any
}

InternalRenderCommand contains the parameters for resolving and rendering a template by codes.

type InternalRenderUseCase

type InternalRenderUseCase interface {
	// RenderByDocumentType resolves a template using the fallback chain
	// (workspace → tenant system workspace → global system) and renders a PDF.
	RenderByDocumentType(ctx context.Context, cmd InternalRenderCommand) (*port.RenderPreviewResult, error)

	// RenderByWorkspaceID resolves a template using workspace ID and document type code.
	// Uses the same fallback chain as RenderByDocumentType.
	RenderByWorkspaceID(ctx context.Context, cmd RenderByWorkspaceCommand) (*port.RenderPreviewResult, error)
}

InternalRenderUseCase defines the input port for internal template rendering by codes.

type RenderByWorkspaceCommand

type RenderByWorkspaceCommand struct {
	WorkspaceID      string
	DocumentTypeCode string
	Injectables      map[string]any
}

RenderByWorkspaceCommand contains the parameters for rendering a template by workspace ID.

type ScheduleArchiveCommand

type ScheduleArchiveCommand struct {
	VersionID string
	ArchiveAt time.Time
}

ScheduleArchiveCommand represents the command to schedule version archival.

type SchedulePublishCommand

type SchedulePublishCommand struct {
	VersionID string
	PublishAt time.Time
}

SchedulePublishCommand represents the command to schedule version publication.

type TemplateConflictInfo

type TemplateConflictInfo struct {
	ID    string
	Title string
}

TemplateConflictInfo represents info about a conflicting template.

type TemplateUseCase

type TemplateUseCase interface {
	// CreateTemplate creates a new template with an initial draft version.
	CreateTemplate(ctx context.Context, cmd CreateTemplateCommand) (*entity.Template, *entity.TemplateVersion, error)

	// GetTemplate retrieves a template by ID.
	GetTemplate(ctx context.Context, id string) (*entity.Template, error)

	// GetTemplateWithDetails retrieves a template with published version, tags, and folder.
	GetTemplateWithDetails(ctx context.Context, id string) (*entity.TemplateWithDetails, error)

	// GetTemplateWithAllVersions retrieves a template with all its versions.
	GetTemplateWithAllVersions(ctx context.Context, id string) (*entity.TemplateWithAllVersions, error)

	// ListTemplates lists all templates in a workspace with optional filters.
	ListTemplates(ctx context.Context, workspaceID string, filters port.TemplateFilters) ([]*entity.TemplateListItem, error)

	// ListTemplatesByFolder lists all templates in a folder.
	ListTemplatesByFolder(ctx context.Context, folderID string) ([]*entity.TemplateListItem, error)

	// ListPublicLibrary lists all public library templates.
	ListPublicLibrary(ctx context.Context, workspaceID string) ([]*entity.TemplateListItem, error)

	// UpdateTemplate updates a template's metadata.
	UpdateTemplate(ctx context.Context, cmd UpdateTemplateCommand) (*entity.Template, error)

	// CloneTemplate creates a copy of an existing template from its published version.
	CloneTemplate(ctx context.Context, cmd CloneTemplateCommand) (*entity.Template, *entity.TemplateVersion, error)

	// DeleteTemplate deletes a template and all its versions.
	DeleteTemplate(ctx context.Context, id string) error

	// AddTag adds a tag to a template.
	AddTag(ctx context.Context, templateID, tagID string) error

	// RemoveTag removes a tag from a template.
	RemoveTag(ctx context.Context, templateID, tagID string) error

	// AssignDocumentType assigns or unassigns a document type to a template.
	// If the type is already assigned to another template in the workspace and Force=false,
	// returns conflict info without making changes.
	AssignDocumentType(ctx context.Context, cmd AssignDocumentTypeCommand) (*AssignDocumentTypeResult, error)

	// FindByDocumentTypeCode finds templates by document type code across a tenant.
	FindByDocumentTypeCode(ctx context.Context, tenantID, code string) ([]*entity.TemplateListItem, error)
}

TemplateUseCase defines the input port for template operations.

type TemplateVersionUseCase

type TemplateVersionUseCase interface {
	// CreateVersion creates a new version for a template.
	CreateVersion(ctx context.Context, cmd CreateVersionCommand) (*entity.TemplateVersion, error)

	// CreateVersionFromExisting creates a new version copying content from an existing version.
	CreateVersionFromExisting(ctx context.Context, sourceVersionID string, name string, description *string, createdBy *string) (*entity.TemplateVersion, error)

	// GetVersion retrieves a template version by ID.
	GetVersion(ctx context.Context, id string) (*entity.TemplateVersion, error)

	// GetVersionWithDetails retrieves a version with all related data.
	GetVersionWithDetails(ctx context.Context, id string) (*entity.TemplateVersionWithDetails, error)

	// ListVersions lists all versions for a template.
	ListVersions(ctx context.Context, templateID string) ([]*entity.TemplateVersion, error)

	// GetPublishedVersion gets the currently published version for a template.
	GetPublishedVersion(ctx context.Context, templateID string) (*entity.TemplateVersionWithDetails, error)

	// UpdateVersion updates a template version.
	UpdateVersion(ctx context.Context, cmd UpdateVersionCommand) (*entity.TemplateVersion, error)

	// PublishVersion publishes a version (archives current published if exists).
	PublishVersion(ctx context.Context, id string, userID string) error

	// SchedulePublish schedules a version for future publication.
	SchedulePublish(ctx context.Context, cmd SchedulePublishCommand) error

	// ScheduleArchive schedules the current published version for future archival.
	ScheduleArchive(ctx context.Context, cmd ScheduleArchiveCommand) error

	// CancelSchedule cancels any scheduled publication or archival.
	CancelSchedule(ctx context.Context, versionID string) error

	// ArchiveVersion manually archives a published version.
	ArchiveVersion(ctx context.Context, id string, userID string) error

	// DeleteVersion deletes a draft version.
	DeleteVersion(ctx context.Context, id string) error

	// AddInjectable adds an injectable to a version.
	AddInjectable(ctx context.Context, cmd AddVersionInjectableCommand) (*entity.TemplateVersionInjectable, error)

	// RemoveInjectable removes an injectable from a version.
	RemoveInjectable(ctx context.Context, id string) error

	// ProcessScheduledPublications publishes all versions whose scheduled time has passed.
	ProcessScheduledPublications(ctx context.Context) error

	// ProcessScheduledArchivals archives all published versions whose scheduled archive time has passed.
	ProcessScheduledArchivals(ctx context.Context) error
}

TemplateVersionUseCase defines the input port for template version operations.

type UpdateTemplateCommand

type UpdateTemplateCommand struct {
	ID              string
	Title           *string
	FolderID        *string
	IsPublicLibrary *bool
}

UpdateTemplateCommand represents the command to update a template. All fields except ID are optional to support partial updates.

type UpdateVersionCommand

type UpdateVersionCommand struct {
	ID               string
	Name             *string
	Description      *string
	ContentStructure json.RawMessage
}

UpdateVersionCommand represents the command to update a template version.

Jump to

Keyboard shortcuts

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