templateops

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DocumentVersion    = "v1"
	KindPipeline       = "emerald-pipeline"
	KindTemplate       = "emerald-template"
	KindTemplateBundle = "emerald-template-bundle"
	DefaultCategory    = "custom"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateTemplateInput

type CreateTemplateInput struct {
	Name        string
	Description *string
	Category    string
	Definition  Definition
}

type Definition

type Definition struct {
	Nodes    json.RawMessage `json:"nodes"`
	Edges    json.RawMessage `json:"edges"`
	Viewport json.RawMessage `json:"viewport,omitempty"`
}

type DefinitionValidator

type DefinitionValidator interface {
	ValidateDefinition(ctx context.Context, nodesJSON string, edgesJSON string, allowUnavailablePlugins bool) error
}

type ImportFailure

type ImportFailure struct {
	Index int    `json:"index"`
	Name  string `json:"name,omitempty"`
	Error string `json:"error"`
}

type ImportResult

type ImportResult struct {
	Created      []TemplateSummary `json:"created"`
	Errors       []ImportFailure   `json:"errors"`
	CreatedCount int               `json:"created_count"`
	FailedCount  int               `json:"failed_count"`
}

type PipelineCreator

type PipelineCreator interface {
	Create(ctx context.Context, pipeline *models.Pipeline) error
}

type PipelineDocument

type PipelineDocument struct {
	Version     string     `json:"version"`
	Kind        string     `json:"kind"`
	Name        string     `json:"name"`
	Description *string    `json:"description,omitempty"`
	Status      string     `json:"status,omitempty"`
	Definition  Definition `json:"definition"`
}

func BuildPipelineDocument

func BuildPipelineDocument(pipelineModel models.Pipeline) (*PipelineDocument, error)

type Service

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

func NewService

func NewService(templates TemplateStore, pipelines PipelineCreator, validators ...DefinitionValidator) *Service

func (*Service) Clone

func (s *Service) Clone(ctx context.Context, id string) (*TemplateDetail, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, input CreateTemplateInput) (*TemplateDetail, error)

func (*Service) CreatePipeline

func (s *Service) CreatePipeline(ctx context.Context, id string) (*models.Pipeline, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id string) error

func (*Service) ExportBundle

func (s *Service) ExportBundle(ctx context.Context) (*TemplateBundle, error)

func (*Service) ExportTemplate

func (s *Service) ExportTemplate(ctx context.Context, id string) (*TemplateDocument, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, id string) (*TemplateDetail, error)

func (*Service) Import

func (s *Service) Import(ctx context.Context, raw []byte) (*ImportResult, error)

func (*Service) List

func (s *Service) List(ctx context.Context) ([]TemplateSummary, error)

type TemplateBundle

type TemplateBundle struct {
	Version   string             `json:"version"`
	Kind      string             `json:"kind"`
	Templates []TemplateDocument `json:"templates"`
}

type TemplateDetail

type TemplateDetail struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	Description *string    `json:"description,omitempty"`
	Category    string     `json:"category"`
	CreatedAt   time.Time  `json:"created_at"`
	Definition  Definition `json:"definition"`
}

type TemplateDocument

type TemplateDocument struct {
	Version     string     `json:"version"`
	Kind        string     `json:"kind"`
	Name        string     `json:"name"`
	Description *string    `json:"description,omitempty"`
	Definition  Definition `json:"definition"`
}

func BuildTemplateDocument

func BuildTemplateDocument(template models.Template) (*TemplateDocument, error)

type TemplateStore

type TemplateStore interface {
	List(ctx context.Context) ([]models.Template, error)
	GetByID(ctx context.Context, id string) (*models.Template, error)
	Create(ctx context.Context, template *models.Template) error
	Delete(ctx context.Context, id string) error
}

type TemplateSummary

type TemplateSummary struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	Description *string   `json:"description,omitempty"`
	Category    string    `json:"category"`
	CreatedAt   time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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