template

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 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
	Process          string // defaults to "default" if empty
	ProcessType      string // defaults to "CANONICAL_NAME" if empty
	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 PromoteVersionCommand

type PromoteVersionCommand struct {
	SourceVersionID   string  // Version ID to promote (must be PUBLISHED)
	SourceTemplateID  string  // Source template ID (for validation)
	TargetWorkspaceID string  // Production workspace ID
	Mode              string  // "NEW_TEMPLATE" or "NEW_VERSION"
	TargetTemplateID  *string // Required for NEW_VERSION mode
	TargetFolderID    *string // Optional for NEW_TEMPLATE mode
	VersionName       *string // Optional, default: "Promoted from Sandbox"
	PromotedBy        string  // User ID performing the promotion
}

PromoteVersionCommand represents the command to promote a version from sandbox to production.

type PromoteVersionResult

type PromoteVersionResult struct {
	Template *entity.Template        // Only set for NEW_TEMPLATE mode
	Version  *entity.TemplateVersion // Always set
}

PromoteVersionResult contains the result of a version promotion.

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 SetProcessFieldsCommand

type SetProcessFieldsCommand struct {
	TemplateID  string
	WorkspaceID string
	Process     string
	ProcessType string
}

SetProcessFieldsCommand represents the command to set process fields on a template.

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

	// SetProcessFields sets the process and processType on a template.
	SetProcessFields(ctx context.Context, cmd SetProcessFieldsCommand) (*entity.Template, 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

	// PromoteVersion promotes a published version from sandbox to production.
	// Can create a new template (NEW_TEMPLATE mode) or add as a new version to existing template (NEW_VERSION mode).
	PromoteVersion(ctx context.Context, cmd PromoteVersionCommand) (*PromoteVersionResult, error)

	// UpdateVersionContent updates the content of a DRAFT version after validating injectables.
	// Returns an error if the version is not in DRAFT status or if injectable validation fails.
	UpdateVersionContent(ctx context.Context, versionID string, content json.RawMessage) 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