sdk

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides programmatic access to the template engine

func New

func New() *Client

New creates a new SDK client

func (*Client) Extract

func (c *Client) Extract(ctx context.Context, opts ExtractOptions) (*TemplateSchema, error)

Extract creates a template schema from a source directory using the global registry

func (*Client) ExtractAndGenerate

func (c *Client) ExtractAndGenerate(ctx context.Context, sourceDir, templateType,
	projectName, githubRepo, outputDir string,
) error

ExtractAndGenerate extracts a template from a source directory and immediately generates a project This is the main workflow method that combines extraction and generation in one step

func (*Client) ExtractAndGenerateFromType added in v0.0.6

func (c *Client) ExtractAndGenerateFromType(templateType, sourceDir, projectName, githubRepo, outputDir string) error

ExtractAndGenerateFromType is a convenience method that extracts and generates in one step

func (*Client) ExtractSchema added in v0.0.6

func (c *Client) ExtractSchema(templateType, sourceDir string) (*TemplateSchema, error)

ExtractSchema extracts a template schema from a source directory using a template type

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, opts GenerateOptions) error

Generate creates a new project from a registered template schema Note: This method works with pre-registered template schemas, not template types. For template types, use ExtractAndGenerate() workflow instead.

func (*Client) GenerateFromFile

func (c *Client) GenerateFromFile(ctx context.Context, templateFile string, variables Variables) error

GenerateFromFile loads a template schema from a file and generates a project This is a convenience method for when you already have a template.json file

func (*Client) GenerateFromSchema added in v0.0.6

func (c *Client) GenerateFromSchema(ctx context.Context, schemaName string, variables Variables) error

GenerateFromSchema generates a project from a registered template schema

func (*Client) GenerateFromTemplate

func (c *Client) GenerateFromTemplate(ctx context.Context, schema *TemplateSchema, variables Variables) error

GenerateFromTemplate creates a project from a template schema

func (*Client) GetSchemaEnvConfig added in v0.0.6

func (c *Client) GetSchemaEnvConfig(schemaName string) ([]EnvVariable, error)

GetSchemaEnvConfig returns environment configuration for a registered template schema

func (*Client) GetSchemaInfo added in v0.0.6

func (c *Client) GetSchemaInfo(schemaName string) (*TemplateSchemaInfo, error)

GetSchemaInfo returns detailed information about a registered template schema

func (*Client) GetTemplateTypeInfo added in v0.0.6

func (c *Client) GetTemplateTypeInfo(templateType string) (*TemplateTypeInfo, error)

GetTemplateTypeInfo returns metadata for a built-in template type

func (*Client) ListSchemas added in v0.0.6

func (c *Client) ListSchemas() []string

ListSchemas returns registered template schema names

func (*Client) ListTemplateTypes added in v0.0.6

func (c *Client) ListTemplateTypes() []string

ListTemplateTypes returns available built-in template types for extraction

func (*Client) RegisterSchema added in v0.0.6

func (c *Client) RegisterSchema(schemaFile string) error

RegisterSchema registers a template schema from a JSON file

func (*Client) RegisterTemplate added in v0.0.3

func (c *Client) RegisterTemplate(templatePath string) error

RegisterTemplate registers a template schema from a JSON file for use with Generate() This is for working with pre-extracted template schema files, not template types. Template types are automatically registered via the global registry.

func (*Client) Validate

func (c *Client) Validate(schema *TemplateSchema) error

Validate checks if a template schema is valid

func (*Client) ValidateExtractOptions

func (c *Client) ValidateExtractOptions(opts ExtractOptions) error

ValidateExtractOptions validates ExtractOptions

func (*Client) ValidateGenerateOptions

func (c *Client) ValidateGenerateOptions(opts GenerateOptions) error

ValidateGenerateOptions validates GenerateOptions

func (*Client) ValidateVariables

func (c *Client) ValidateVariables(variables Variables) error

ValidateVariables validates Variables

type EnvVariable added in v0.0.6

type EnvVariable = core.EnvVariable

Type aliases to avoid repetitive conversions

type ErrorType

type ErrorType string

ErrorType represents different categories of SDK errors

const (
	ErrorTypeValidation   ErrorType = "validation"
	ErrorTypeExtraction   ErrorType = "extraction"
	ErrorTypeGeneration   ErrorType = "generation"
	ErrorTypeTemplateType ErrorType = "template_type"
	ErrorTypeFileSystem   ErrorType = "filesystem"
	ErrorTypeSchema       ErrorType = "schema"
)

type ExtractOptions

type ExtractOptions struct {
	SourceDir string // Source directory to extract from
	Type      string // Template type
	OutputDir string // Optional: directory to save template file
}

ExtractOptions contains options for extracting a template

type GenerateOptions

type GenerateOptions struct {
	Template    string            // Template name (e.g., "frontend", "go-api")
	ProjectName string            // Name of the project
	GitHubRepo  string            // GitHub repository (e.g., "user/repo")
	OutputDir   string            // Output directory
	Variables   map[string]string // Additional template variables
}

GenerateOptions contains options for generating a project

type SDKError

type SDKError struct {
	Type       ErrorType `json:"type"`
	Message    string    `json:"message"`
	Operation  string    `json:"operation"`
	Details    string    `json:"details,omitempty"`
	Underlying error     `json:"-"`
}

SDKError provides structured error information for SDK operations

func (*SDKError) Error

func (e *SDKError) Error() string

func (*SDKError) Unwrap

func (e *SDKError) Unwrap() error

type TemplateInfo added in v0.0.2

type TemplateInfo struct {
	Name        string              `json:"name"`
	Type        string              `json:"type"`
	Description string              `json:"description"`
	Variables   map[string]Variable `json:"variables"`
}

TemplateInfo represents template metadata and structure

type TemplateSchema added in v0.0.6

type TemplateSchema = core.TemplateSchema

Type aliases to avoid repetitive conversions

type TemplateSchemaInfo added in v0.0.6

type TemplateSchemaInfo struct {
	Name        string              `json:"name"`
	Type        string              `json:"type"`
	Version     string              `json:"version"`
	Description string              `json:"description"`
	Variables   map[string]Variable `json:"variables"`
	FileCount   int                 `json:"file_count"`
	EnvVarCount int                 `json:"env_var_count"`
}

TemplateSchemaInfo represents detailed information about a registered template schema

type TemplateTypeInfo added in v0.0.6

type TemplateTypeInfo struct {
	Name        string              `json:"name"`
	Description string              `json:"description"`
	Variables   map[string]Variable `json:"variables"`
}

TemplateTypeInfo represents metadata for a built-in template type (extractor)

type Variable added in v0.0.2

type Variable = core.Variable

Type aliases to avoid repetitive conversions

type Variables

type Variables struct {
	ProjectName string
	GitHubRepo  string
	OutputDir   string
	Author      string
	Description string
	Custom      map[string]string
}

Variables contains template variables

Jump to

Keyboard shortcuts

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