management

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package management provides functionality for managing templates in the LLMreconing Tool.

Package management provides functionality for managing templates in the LLMreconing Tool. It includes components for template loading, parsing, execution, and reporting.

Package management provides functionality for managing templates in the LLMreconing Tool.

Package management provides functionality for managing templates in the LLMreconing Tool.

Package management provides functionality for managing templates.

Package management provides functionality for managing templates in the LLMreconing Tool.

Index

Constants

View Source
const (
	// FileSource indicates the template is from a file
	FileSource = interfaces.FileSource
	// DirectorySource indicates the template is from a directory
	DirectorySource = interfaces.DirectorySource
	// GitHubSource indicates the template is from GitHub
	GitHubSource = interfaces.GitHubSource
	// GitLabSource indicates the template is from GitLab
	GitLabSource = interfaces.GitLabSource
	// HTTPSource indicates the template is from HTTP
	HTTPSource = interfaces.HTTPSource
	// DatabaseSource indicates the template is from a database
	DatabaseSource = interfaces.DatabaseSource
)
View Source
const (
	// StatusLoaded indicates the template has been loaded
	StatusLoaded = interfaces.StatusLoaded
	// StatusValidated indicates the template has been validated
	StatusValidated = interfaces.StatusValidated
	// StatusExecuting indicates the template is being executed
	StatusExecuting = interfaces.StatusExecuting
	// StatusCompleted indicates the template execution has completed
	StatusCompleted = interfaces.StatusCompleted
	// StatusFailed indicates the template execution has failed
	StatusFailed = interfaces.StatusFailed
)
View Source
const OfflineBundleSource = loaders.OfflineBundleSource

OfflineBundleSource is a constant for the offline bundle source

Variables

View Source
var (
	// ValidSeverityLevels are the valid severity levels
	ValidSeverityLevels = []string{"info", "low", "medium", "high", "critical"}
	// ValidDetectionTypes are the valid detection types
	ValidDetectionTypes = []string{"word", "regex", "condition", "status", "size", "dsl", "time"}
	// ValidConditions are the valid conditions
	ValidConditions = []string{"and", "or", "not"}
)

Constants for validation

Functions

func CreateOfflineBundleRepository

func CreateOfflineBundleRepository(bundlePath string, auditTrailManager *auditTrail.AuditTrailManager) (*repository.OfflineBundleRepository, error)

CreateOfflineBundleRepository creates a repository for an offline bundle

func DefaultSchemaValidator

func DefaultSchemaValidator(jsonSchemaPath, yamlSchemaPath string) (interfaces.TemplateValidator, error)

DefaultSchemaValidator creates a default schema validator with standard validators

func DefaultSchemaValidatorForParser added in v0.8.0

func DefaultSchemaValidatorForParser(jsonSchemaPath, yamlSchemaPath string) (interfaces.SchemaValidator, error)

DefaultSchemaValidatorForParser creates a schema validator for the parser

func FindTemplatesByTag

func FindTemplatesByTag(manager *Manager, tag string) []*format.Template

FindTemplatesByTag finds templates by tag

func FindTemplatesByTags

func FindTemplatesByTags(manager *Manager, tags []string) []*format.Template

FindTemplatesByTags finds templates by multiple tags

func GenerateTemplateReport

func GenerateTemplateReport(manager *Manager, results []*interfaces.TemplateResult, format string) ([]byte, error)

GenerateTemplateReport generates a report for template execution results

func GetTemplateByID

func GetTemplateByID(manager *Manager, id string) (*format.Template, error)

GetTemplateByID gets a template by ID

func ListAllTemplates

func ListAllTemplates(manager *Manager) []*format.Template

ListAllTemplates lists all templates

func NewLLMProviderAdapter added in v0.8.0

func NewLLMProviderAdapter(provider execution.LLMProvider) interfaces.LLMProvider

NewLLMProviderAdapter creates a new provider adapter

func NewTemplateExecutorAdapter added in v0.8.0

func NewTemplateExecutorAdapter(executor *execution.OptimizedTemplateExecutor) interfaces.TemplateExecutor

NewTemplateExecutorAdapter creates a new template executor adapter

func RegisterOfflineBundleLoader

func RegisterOfflineBundleLoader(manager *DefaultTemplateManager, _ *auditTrail.AuditTrailManager)

RegisterOfflineBundleLoader registers an offline bundle loader with the template manager.

v0.10.0 #180: the auditTrailManager parameter is preserved for API stability but no longer used inside the loader. The previous adapter from src/audit/trail.AuditTrailManager to src/security/access/audit/trail.Manager (which always returned nil) is removed along with the entire src/security/access/ subtree. Callers can still pass their AuditTrailManager; the loader simply doesn't log to it. v0.11.0 may revisit if a clear audit-logging requirement re-emerges.

func RunTemplate

func RunTemplate(ctx context.Context, manager *Manager, templateID string, options map[string]interface{}) (*interfaces.TemplateResult, error)

RunTemplate runs a template with the specified options

func RunTemplates

func RunTemplates(ctx context.Context, manager *Manager, templateIDs []string, options map[string]interface{}) ([]*interfaces.TemplateResult, error)

RunTemplates runs multiple templates with the specified options

func ValidateCondition

func ValidateCondition(condition interface{}) error

ValidateCondition validates a condition

func ValidateDetectionType

func ValidateDetectionType(detectionType interface{}) error

ValidateDetectionType validates a detection type

func ValidateID

func ValidateID(id interface{}) error

ValidateID validates a template ID

func ValidateSeverity

func ValidateSeverity(severity interface{}) error

ValidateSeverity validates a severity level

func ValidateVersion

func ValidateVersion(version interface{}) error

ValidateVersion validates a version string

Types

type DefaultManagerOptions

type DefaultManagerOptions struct {
	// JSONSchemaPath is the path to the JSON schema file
	JSONSchemaPath string
	// YAMLSchemaPath is the path to the YAML schema file
	YAMLSchemaPath string
	// TemplatePaths is the list of paths to load templates from
	TemplatePaths []string
	// RepositoryConfig is the configuration for the repository manager
	RepositoryConfig *repository.Config
	// CacheTTL is the time-to-live for cached templates
	CacheTTL time.Duration
	// CacheMaxSize is the maximum size of the cache
	CacheMaxSize int
	// ExecutionTimeout is the timeout for template execution
	ExecutionTimeout time.Duration
	// RetryCount is the number of retries for failed requests
	RetryCount int
	// RetryDelay is the delay between retries
	RetryDelay time.Duration
	// MaxConcurrent is the maximum number of concurrent executions
	MaxConcurrent int
	// Providers is the list of LLM providers
	Providers []execution.LLMProvider
	// PreExecutionHooks are functions to run before template execution
	PreExecutionHooks []TemplateHook
	// PostExecutionHooks are functions to run after template execution
	PostExecutionHooks []TemplateHook
}

DefaultManagerOptions contains options for creating a default template manager

func DefaultManagerOptionsWithDefaults

func DefaultManagerOptionsWithDefaults() *DefaultManagerOptions

DefaultManagerOptionsWithDefaults creates default manager options with default values

type DefaultTemplateManager

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

DefaultTemplateManager is the default implementation of TemplateManager

func NewTemplateManager

func NewTemplateManager(options *TemplateManagerOptions) (*DefaultTemplateManager, error)

NewTemplateManager creates a new template manager

func (*DefaultTemplateManager) Execute

func (m *DefaultTemplateManager) Execute(ctx context.Context, template *format.Template, options map[string]interface{}) (*types.TemplateResult, error)

Execute executes a template

func (*DefaultTemplateManager) ExecuteBatch

func (m *DefaultTemplateManager) ExecuteBatch(ctx context.Context, templates []*format.Template, options map[string]interface{}) ([]*types.TemplateResult, error)

ExecuteBatch executes multiple templates

func (*DefaultTemplateManager) ExecuteTemplate

func (m *DefaultTemplateManager) ExecuteTemplate(ctx context.Context, templateID string, options map[string]interface{}) (*types.TemplateResult, error)

ExecuteTemplate executes a template

func (*DefaultTemplateManager) ExecuteTemplates

func (m *DefaultTemplateManager) ExecuteTemplates(ctx context.Context, templateIDs []string, options map[string]interface{}) ([]*types.TemplateResult, error)

ExecuteTemplates executes multiple templates

func (*DefaultTemplateManager) GenerateReport

func (m *DefaultTemplateManager) GenerateReport(results []*types.TemplateResult, format string) ([]byte, error)

GenerateReport generates a report for template execution results

func (*DefaultTemplateManager) GetCategories

func (m *DefaultTemplateManager) GetCategories() ([]string, error)

GetCategories returns a list of all template categories

func (*DefaultTemplateManager) GetExecutor

func (m *DefaultTemplateManager) GetExecutor() interface{}

GetExecutor returns the template executor

func (*DefaultTemplateManager) GetLoader

GetLoader returns the template loader

func (*DefaultTemplateManager) GetTemplate

func (m *DefaultTemplateManager) GetTemplate(id string) (*format.Template, error)

GetTemplate gets a template by ID

func (*DefaultTemplateManager) GetTemplateInterface

func (m *DefaultTemplateManager) GetTemplateInterface(id string) (*format.Template, error)

GetTemplateInterface wraps GetTemplate to match interface

func (*DefaultTemplateManager) ListTemplates

func (m *DefaultTemplateManager) ListTemplates() []*format.Template

ListTemplates lists all templates

func (*DefaultTemplateManager) ListTemplatesInterface

func (m *DefaultTemplateManager) ListTemplatesInterface() ([]*format.Template, error)

ListTemplatesInterface wraps ListTemplates to match interface

func (*DefaultTemplateManager) LoadFromOfflineBundle

func (m *DefaultTemplateManager) LoadFromOfflineBundle(ctx context.Context, bundlePath string, validationLevel bundle.ValidationLevel) ([]*format.Template, error)

LoadFromOfflineBundle loads templates from an offline bundle

func (*DefaultTemplateManager) LoadTemplate

func (m *DefaultTemplateManager) LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)

LoadTemplate loads a template from a source

func (*DefaultTemplateManager) LoadTemplateInterface

func (m *DefaultTemplateManager) LoadTemplateInterface(path string) (*format.Template, error)

LoadTemplateInterface wraps LoadTemplate to match interface

func (*DefaultTemplateManager) LoadTemplates

func (m *DefaultTemplateManager) LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)

LoadTemplates loads multiple templates from a source

func (*DefaultTemplateManager) LoadTemplatesFromOfflineBundleRepository

func (m *DefaultTemplateManager) LoadTemplatesFromOfflineBundleRepository(ctx context.Context, repo *repository.OfflineBundleRepository) ([]*format.Template, error)

LoadTemplatesFromOfflineBundleRepository loads templates from an offline bundle repository

func (*DefaultTemplateManager) LoadTemplatesFromSources

func (m *DefaultTemplateManager) LoadTemplatesFromSources(ctx context.Context, sources []types.TemplateSource) error

LoadTemplatesFromSources loads templates from the specified sources

func (*DefaultTemplateManager) ValidateTemplate

func (m *DefaultTemplateManager) ValidateTemplate(template *format.Template) error

ValidateTemplate validates a template

func (*DefaultTemplateManager) ValidateTemplateInterface

func (m *DefaultTemplateManager) ValidateTemplateInterface(template *format.Template) error

ValidateTemplateInterface wraps ValidateTemplate to match interface

type Engine

type Engine interface {
	Execute(ctx context.Context, template Template, target interface{}) (interface{}, error)
	Validate(template Template) error
	GetSupportedFormats() []string
}

Engine represents a template execution engine

type LLMProviderAdapter added in v0.8.0

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

LLMProviderAdapter adapts execution.LLMProvider to interfaces.LLMProvider

func (*LLMProviderAdapter) GetID added in v0.8.0

func (a *LLMProviderAdapter) GetID() string

GetID implements interfaces.LLMProvider

func (*LLMProviderAdapter) GetName added in v0.8.0

func (a *LLMProviderAdapter) GetName() string

GetName implements interfaces.LLMProvider

func (*LLMProviderAdapter) GetSupportedModels added in v0.8.0

func (a *LLMProviderAdapter) GetSupportedModels() []string

GetSupportedModels implements interfaces.LLMProvider

func (*LLMProviderAdapter) GetTimeout added in v0.8.0

func (a *LLMProviderAdapter) GetTimeout() time.Duration

GetTimeout implements interfaces.LLMProvider

func (*LLMProviderAdapter) GetUsage added in v0.8.0

func (a *LLMProviderAdapter) GetUsage() map[string]interface{}

GetUsage implements interfaces.LLMProvider

func (*LLMProviderAdapter) IsHealthy added in v0.8.0

func (a *LLMProviderAdapter) IsHealthy(ctx context.Context) (bool, error)

IsHealthy implements interfaces.LLMProvider

func (*LLMProviderAdapter) SendPrompt added in v0.8.0

func (a *LLMProviderAdapter) SendPrompt(ctx context.Context, prompt string, options map[string]interface{}) (string, error)

SendPrompt implements interfaces.LLMProvider

func (*LLMProviderAdapter) SetTimeout added in v0.8.0

func (a *LLMProviderAdapter) SetTimeout(timeout time.Duration)

SetTimeout implements interfaces.LLMProvider

type Manager

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

Manager is the implementation of the TemplateManager interface

func CreateDefaultManager

func CreateDefaultManager(ctx context.Context, options *DefaultManagerOptions) (*Manager, error)

CreateDefaultManager creates a default template manager with all components

func NewManager

func NewManager(options *ManagerOptions) (*Manager, error)

NewManager creates a new template manager

func (*Manager) AddHook

func (m *Manager) AddHook(hook TemplateHook, pre bool)

AddHook adds a hook to the template manager

func (*Manager) ClearCache

func (m *Manager) ClearCache()

ClearCache clears the template cache

func (*Manager) ClearHooks

func (m *Manager) ClearHooks()

ClearHooks clears all hooks

func (*Manager) ExecuteTemplate

func (m *Manager) ExecuteTemplate(ctx context.Context, templateID string, options map[string]interface{}) (*interfaces.TemplateResult, error)

ExecuteTemplate executes a template

func (*Manager) ExecuteTemplates

func (m *Manager) ExecuteTemplates(ctx context.Context, templateIDs []string, options map[string]interface{}) ([]*interfaces.TemplateResult, error)

ExecuteTemplates executes multiple templates

func (*Manager) FindTemplatesByTag

func (m *Manager) FindTemplatesByTag(tag string) []*format.Template

FindTemplatesByTag finds templates by tag

func (*Manager) FindTemplatesByTags

func (m *Manager) FindTemplatesByTags(tags []string) []*format.Template

FindTemplatesByTags finds templates by multiple tags

func (*Manager) GenerateReport

func (m *Manager) GenerateReport(results []*interfaces.TemplateResult, format string) ([]byte, error)

GenerateReport generates a report for template execution results

func (*Manager) GetStats

func (m *Manager) GetStats() map[string]interface{}

GetStats gets statistics about the template manager

func (*Manager) GetTemplate

func (m *Manager) GetTemplate(id string) (*format.Template, error)

GetTemplate gets a template by ID

func (*Manager) GetTemplateMetadata

func (m *Manager) GetTemplateMetadata(id string) (map[string]interface{}, error)

GetTemplateMetadata gets metadata for a template

func (*Manager) ListTemplates

func (m *Manager) ListTemplates() []*format.Template

ListTemplates lists all templates

func (*Manager) LoadTemplates

func (m *Manager) LoadTemplates(ctx context.Context, sources []interfaces.TemplateSource) error

LoadTemplates loads templates from the specified sources

func (*Manager) PruneCache

func (m *Manager) PruneCache(maxAge time.Duration) int

PruneCache removes old entries from the cache

func (*Manager) RegisterTemplate

func (m *Manager) RegisterTemplate(template *format.Template) error

RegisterTemplate registers a template

func (*Manager) RemoveHook

func (m *Manager) RemoveHook(hook TemplateHook, pre bool) bool

RemoveHook removes a hook from the template manager

func (*Manager) SetTemplateMetadata

func (m *Manager) SetTemplateMetadata(id string, metadata map[string]interface{}) error

SetTemplateMetadata sets metadata for a template

func (*Manager) UnregisterTemplate

func (m *Manager) UnregisterTemplate(id string) error

UnregisterTemplate unregisters a template

func (*Manager) UpdateTemplate

func (m *Manager) UpdateTemplate(template *format.Template) error

UpdateTemplate updates a template

func (*Manager) ValidateTemplate

func (m *Manager) ValidateTemplate(template *format.Template) error

ValidateTemplate validates a template

type ManagerConfig

type ManagerConfig struct {
	// CacheTTL is the TTL for cached templates
	CacheTTL time.Duration
	// MaxCacheSize is the maximum number of cached templates
	MaxCacheSize int
	// ConcurrencyLimit is the maximum number of concurrent operations
	ConcurrencyLimit int
	// ExecutionTimeout is the timeout for template execution
	ExecutionTimeout time.Duration
	// LoadTimeout is the timeout for template loading
	LoadTimeout time.Duration
	// RetryCount is the number of retries for failed operations
	RetryCount int
	// RetryDelay is the delay between retries
	RetryDelay time.Duration
	// Debug enables debug logging
	Debug bool
}

ManagerConfig represents configuration for the template manager

type ManagerOptions

type ManagerOptions struct {
	// Loaders is the list of template loaders
	Loaders []interfaces.TemplateLoader
	// Parser is the template parser
	Parser interfaces.TemplateValidator
	// Executor is the template executor
	Executor interfaces.TemplateExecutor
	// Reporter is the template reporter
	Reporter ReporterFunc
	// Cache is the template cache
	Cache TemplateCacheExtended
	// Registry is the template registry
	Registry TemplateRegistryExtended
	// PreExecutionHooks are functions to run before template execution
	PreExecutionHooks []TemplateHook
	// PostExecutionHooks are functions to run after template execution
	PostExecutionHooks []TemplateHook
}

ManagerOptions contains options for creating a new template manager

type ManagerStats

type ManagerStats struct {
	// TotalTemplates is the total number of templates managed
	TotalTemplates int
	// TotalSources is the total number of sources managed
	TotalSources int
	// TotalLoads is the total number of template loads
	TotalLoads int64
	// TotalExecutions is the total number of template executions
	TotalExecutions int64
	// CacheHitRate is the cache hit rate
	CacheHitRate float64
}

ManagerStats tracks manager statistics

type OptimizedTemplateManager

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

OptimizedTemplateManager is an enhanced template manager with improved performance

func NewOptimizedTemplateManager

func NewOptimizedTemplateManager(config *ManagerConfig) (*OptimizedTemplateManager, error)

NewOptimizedTemplateManager creates a new optimized template manager

func (*OptimizedTemplateManager) AddRepository

func (m *OptimizedTemplateManager) AddRepository(config *repository.Config) error

AddRepository adds a repository to the manager

func (*OptimizedTemplateManager) ClearCache

func (m *OptimizedTemplateManager) ClearCache()

ClearCache clears the template cache

func (*OptimizedTemplateManager) Execute

func (m *OptimizedTemplateManager) Execute(ctx context.Context, template *format.Template, options map[string]interface{}) (*interfaces.TemplateResult, error)

Execute executes a template

func (*OptimizedTemplateManager) ExecuteBatch

func (m *OptimizedTemplateManager) ExecuteBatch(ctx context.Context, templates []*format.Template, options map[string]interface{}) ([]*interfaces.TemplateResult, error)

ExecuteBatch executes multiple templates

func (*OptimizedTemplateManager) GetExecutor

GetExecutor returns the template executor

func (*OptimizedTemplateManager) GetLoader

GetLoader returns the template loader

func (*OptimizedTemplateManager) GetRepositories

func (m *OptimizedTemplateManager) GetRepositories() []repository.Repository

GetRepositories gets all repositories

func (*OptimizedTemplateManager) GetRepository

func (m *OptimizedTemplateManager) GetRepository(name string) (repository.Repository, error)

GetRepository gets a repository by name

func (*OptimizedTemplateManager) GetStats

func (m *OptimizedTemplateManager) GetStats() map[string]interface{}

GetStats returns statistics about the manager

func (*OptimizedTemplateManager) GetTemplateIDs

func (m *OptimizedTemplateManager) GetTemplateIDs() []string

GetTemplateIDs returns all template IDs

func (*OptimizedTemplateManager) GetTemplateStats

func (m *OptimizedTemplateManager) GetTemplateStats(templateID string) map[string]interface{}

GetTemplateStats returns statistics about a specific template

func (*OptimizedTemplateManager) LoadTemplate

func (m *OptimizedTemplateManager) LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)

LoadTemplate loads a template from a source

func (*OptimizedTemplateManager) LoadTemplates

func (m *OptimizedTemplateManager) LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)

LoadTemplates loads multiple templates from a source

func (*OptimizedTemplateManager) RegisterDetectionEngine

func (m *OptimizedTemplateManager) RegisterDetectionEngine(engine interfaces.DetectionEngine)

RegisterDetectionEngine registers a detection engine

func (*OptimizedTemplateManager) RegisterProvider

func (m *OptimizedTemplateManager) RegisterProvider(provider execution.LLMProvider)

RegisterProvider registers an LLM provider

func (*OptimizedTemplateManager) RemoveRepository

func (m *OptimizedTemplateManager) RemoveRepository(name string) error

RemoveRepository removes a repository by name

func (*OptimizedTemplateManager) SetCacheSize

func (m *OptimizedTemplateManager) SetCacheSize(size int)

SetCacheSize sets the cache size

func (*OptimizedTemplateManager) SetCacheTTL

func (m *OptimizedTemplateManager) SetCacheTTL(ttl time.Duration)

SetCacheTTL sets the cache TTL

func (*OptimizedTemplateManager) SetConcurrencyLimit

func (m *OptimizedTemplateManager) SetConcurrencyLimit(limit int)

SetConcurrencyLimit sets the concurrency limit

func (*OptimizedTemplateManager) SetDebug

func (m *OptimizedTemplateManager) SetDebug(debug bool)

SetDebug sets the debug flag

func (*OptimizedTemplateManager) SetExecutionTimeout

func (m *OptimizedTemplateManager) SetExecutionTimeout(timeout time.Duration)

SetExecutionTimeout sets the execution timeout

func (*OptimizedTemplateManager) SetLoadTimeout

func (m *OptimizedTemplateManager) SetLoadTimeout(timeout time.Duration)

SetLoadTimeout sets the load timeout

type ReporterFunc added in v0.8.0

type ReporterFunc func(results []*interfaces.TemplateResult, format string) ([]byte, error)

ReporterFunc represents a function that generates reports

type SchemaFormat

type SchemaFormat string

SchemaFormat represents the format of a schema

const (
	// JSONSchema represents a JSON schema
	JSONSchema SchemaFormat = "json"
	// YAMLSchema represents a YAML schema
	YAMLSchema SchemaFormat = "yaml"
)

type SchemaValidator

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

SchemaValidator is responsible for validating templates against a schema

func NewSchemaValidator

func NewSchemaValidator(jsonSchemaPath, yamlSchemaPath string) (*SchemaValidator, error)

NewSchemaValidator creates a new schema validator

func (*SchemaValidator) AddCustomValidator

func (v *SchemaValidator) AddCustomValidator(field string, validator func(interface{}) error)

AddCustomValidator adds a custom validator function for a specific field

func (*SchemaValidator) ValidateJSON

func (v *SchemaValidator) ValidateJSON(data []byte) error

ValidateJSON validates JSON data against the JSON schema

func (*SchemaValidator) ValidateSchema added in v0.8.0

func (v *SchemaValidator) ValidateSchema(data interface{}) error

ValidateSchema validates template data against a schema

func (*SchemaValidator) ValidateTemplate

func (v *SchemaValidator) ValidateTemplate(template interface{}) error

ValidateTemplate validates a template against the schema

func (*SchemaValidator) ValidateTemplateFile

func (v *SchemaValidator) ValidateTemplateFile(filePath string) error

ValidateTemplateFile validates a template file against the schema

func (*SchemaValidator) ValidateYAML

func (v *SchemaValidator) ValidateYAML(data []byte) error

ValidateYAML validates YAML data against the YAML schema

type SchemaValidatorAdapter added in v0.8.0

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

SchemaValidatorAdapter adapts SchemaValidator to implement interfaces.SchemaValidator

func (*SchemaValidatorAdapter) ValidateSchema added in v0.8.0

func (a *SchemaValidatorAdapter) ValidateSchema(data interface{}) error

ValidateSchema validates schema data (interface compatibility)

func (*SchemaValidatorAdapter) ValidateTemplate added in v0.8.0

func (a *SchemaValidatorAdapter) ValidateTemplate(template interface{}) error

ValidateTemplate validates template (interface compatibility)

type Template

type Template = format.Template

Template is an alias for format.Template to maintain consistency

type TemplateCache

type TemplateCache interface {
	Get(key string) (*Template, bool)
	Set(key string, template *Template)
}

TemplateCache represents a template cache interface

type TemplateCacheExtended added in v0.8.0

type TemplateCacheExtended interface {
	interfaces.TemplateCache
	// GetStats returns cache statistics
	GetStats() map[string]interface{}
	// Prune removes old entries from the cache
	Prune(maxAge time.Duration) int
}

TemplateCacheExtended extends the basic cache interface with additional functionality

type TemplateExecutor

type TemplateExecutor interface {
	Execute(ctx context.Context, template *Template, options map[string]interface{}) (interface{}, error)
	RegisterProvider(provider interface{})
}

TemplateExecutor represents a template executor interface

type TemplateExecutorAdapter added in v0.8.0

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

TemplateExecutorAdapter adapts OptimizedTemplateExecutor to interfaces.TemplateExecutor

func (*TemplateExecutorAdapter) Execute added in v0.8.0

func (a *TemplateExecutorAdapter) Execute(ctx context.Context, template interfaces.Template, data interface{}) ([]byte, error)

Execute implements interfaces.TemplateExecutor

func (*TemplateExecutorAdapter) ExecuteWithOptions added in v0.8.0

func (a *TemplateExecutorAdapter) ExecuteWithOptions(ctx context.Context, template interfaces.Template, data interface{}, options map[string]interface{}) ([]byte, error)

ExecuteWithOptions implements interfaces.TemplateExecutor

type TemplateHook

type TemplateHook func(ctx context.Context, template *format.Template, result *interfaces.TemplateResult) error

TemplateHook represents a function that can be called before or after template execution

type TemplateIndexEntry

type TemplateIndexEntry struct {
	// Source is the source of the template
	Source string
	// SourceType is the type of the source
	SourceType string
	// LastAccessed is the time the template was last accessed
	LastAccessed time.Time
	// AccessCount is the number of times the template has been accessed
	AccessCount int
}

TemplateIndexEntry contains information about a template source

type TemplateLoader

type TemplateLoader interface {
	LoadFromPath(ctx context.Context, path string, recursive bool) ([]*Template, error)
}

TemplateLoader represents a template loader interface

type TemplateLoaderExtended added in v0.8.0

type TemplateLoaderExtended interface {
	interfaces.TemplateLoader
	// LoadTemplates loads multiple templates from a source
	LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
}

TemplateLoaderExtended extends the basic loader interface to support batch operations

type TemplateManager

type TemplateManager interface {
	GetTemplate(id string) (Template, error)
	ListTemplates() ([]Template, error)
	GetCategories() ([]string, error)
	LoadTemplate(path string) (Template, error)
	ValidateTemplate(template Template) error
}

TemplateManager manages templates

func NewTemplateManagerWrapper

func NewTemplateManagerWrapper(manager *DefaultTemplateManager) TemplateManager

NewTemplateManagerWrapper creates a new wrapper for DefaultTemplateManager

type TemplateManagerOptions

type TemplateManagerOptions struct {
	// Loaders is the list of template loaders
	Loaders []types.TemplateLoader
	// Parser is the template parser
	Parser *parser.TemplateParser
	// Executor is the template executor
	Executor *execution.TemplateExecutor
	// Reporter is the template reporter
	Reporter *reporting.TemplateReporter
	// Cache is the template cache
	Cache *cache.TemplateCache
	// Registry is the template registry
	Registry *registry.TemplateRegistry
	// PreExecutionHooks are functions to run before template execution
	PreExecutionHooks []func(ctx context.Context, template *format.Template, result *interfaces.TemplateResult) error
	// PostExecutionHooks are functions to run after template execution
	PostExecutionHooks []func(ctx context.Context, template *format.Template, result *interfaces.TemplateResult) error
}

TemplateManagerOptions contains options for the template manager

type TemplateManagerWrapper

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

TemplateManagerWrapper wraps DefaultTemplateManager to implement the TemplateManager interface

func (*TemplateManagerWrapper) GetCategories

func (w *TemplateManagerWrapper) GetCategories() ([]string, error)

GetCategories implements TemplateManager interface

func (*TemplateManagerWrapper) GetTemplate

func (w *TemplateManagerWrapper) GetTemplate(id string) (Template, error)

GetTemplate implements TemplateManager interface

func (*TemplateManagerWrapper) ListTemplates

func (w *TemplateManagerWrapper) ListTemplates() ([]Template, error)

ListTemplates implements TemplateManager interface

func (*TemplateManagerWrapper) LoadTemplate

func (w *TemplateManagerWrapper) LoadTemplate(path string) (Template, error)

LoadTemplate implements TemplateManager interface

func (*TemplateManagerWrapper) ValidateTemplate

func (w *TemplateManagerWrapper) ValidateTemplate(template Template) error

ValidateTemplate implements TemplateManager interface

type TemplateParser

type TemplateParser interface {
	Parse(data []byte) (*Template, error)
	Validate(template *Template) error
}

TemplateParser represents a template parser interface

type TemplateRegistry

type TemplateRegistry interface {
	Register(template *Template) error
	Get(id string) (*Template, error)
	List() []*Template
	FindByTag(tag string) []*Template
	FindByTags(tags []string) []*Template
}

TemplateRegistry represents a template registry interface

type TemplateRegistryExtended added in v0.8.0

type TemplateRegistryExtended interface {
	interfaces.TemplateRegistry
	// FindByTag finds templates by tag
	FindByTag(tag string) []*format.Template
	// FindByTags finds templates by multiple tags
	FindByTags(tags []string) []*format.Template
	// GetMetadata gets metadata for a template
	GetMetadata(id string) (map[string]interface{}, error)
	// SetMetadata sets metadata for a template
	SetMetadata(id string, metadata map[string]interface{}) error
	// Count returns the number of templates
	Count() int
	// Update updates a template
	Update(template *format.Template) error
}

TemplateRegistryExtended extends the basic registry interface with additional functionality

type TemplateReporter

type TemplateReporter interface {
	GenerateReport(results interface{}, format string) ([]byte, error)
}

TemplateReporter represents a template reporter interface

type TemplateResult

type TemplateResult = interfaces.TemplateResult

TemplateResult is an alias for the interface type to maintain consistency

type TemplateStatus

type TemplateStatus = interfaces.TemplateStatus

TemplateStatus is an alias for interfaces.TemplateStatus

type TemplateValidatorAdapter added in v0.8.0

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

TemplateValidatorAdapter adapts SchemaValidator to implement interfaces.TemplateValidator

func (*TemplateValidatorAdapter) Validate added in v0.8.0

func (a *TemplateValidatorAdapter) Validate(template interfaces.Template) error

Validate validates a template

func (*TemplateValidatorAdapter) ValidateContent added in v0.8.0

func (a *TemplateValidatorAdapter) ValidateContent(content []byte) error

ValidateContent validates template content

func (*TemplateValidatorAdapter) ValidateSchema added in v0.8.0

func (a *TemplateValidatorAdapter) ValidateSchema(template interfaces.Template, schema interface{}) error

ValidateSchema validates against a schema

Directories

Path Synopsis
Package benchmark provides tools for benchmarking template operations.
Package benchmark provides tools for benchmarking template operations.
Package cache provides caching functionality for templates.
Package cache provides caching functionality for templates.
Package execution provides functionality for executing templates against LLM systems.
Package execution provides functionality for executing templates against LLM systems.
Package loader provides functionality for loading templates from various sources.
Package loader provides functionality for loading templates from various sources.
Package loaders provides template loaders for different sources
Package loaders provides template loaders for different sources
Package monitoring provides performance monitoring for template operations.
Package monitoring provides performance monitoring for template operations.
Package parser provides functionality for parsing and validating templates.
Package parser provides functionality for parsing and validating templates.
Package ratelimit provides rate limiting functionality for template execution.
Package ratelimit provides rate limiting functionality for template execution.
Package registry provides functionality for registering and managing templates.
Package registry provides functionality for registering and managing templates.
Package reporting provides functionality for generating reports of template execution results.
Package reporting provides functionality for generating reports of template execution results.
Package streaming provides functionality for streaming processing of templates.
Package streaming provides functionality for streaming processing of templates.
Package structure provides functionality for optimizing template structure.
Package structure provides functionality for optimizing template structure.
Package types provides common types and interfaces for template management.
Package types provides common types and interfaces for template management.
Package validation provides functionality for validating templates and inputs before execution.
Package validation provides functionality for validating templates and inputs before execution.

Jump to

Keyboard shortcuts

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