config

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const CurrentVersion = 1

CurrentVersion defines the supported schema version for mergeway.yaml files.

View Source
const DefaultWriteTemplate = "{id}.yaml"

DefaultWriteTemplate is the canonical template used for new object files.

View Source
const PathIdentifierField = "$path"

PathIdentifierField is the reserved identifier value that derives IDs from file paths.

Variables

This section is empty.

Functions

func DerivePathSourceValue added in v0.6.0

func DerivePathSourceValue(source *FieldSourceDefinition, path string) (string, error)

DerivePathSourceValue resolves a declared field source from a normalized relative file path.

Types

type Config

type Config struct {
	Version int
	Types   map[string]*TypeDefinition
	Write   WriteDefaults
}

Config captures the normalized database configuration.

func Load

func Load(path string) (*Config, error)

Load reads the configuration entry file and resolves includes.

func LoadWithOps added in v0.7.0

func LoadWithOps(path string, ops fileutil.Ops) (*Config, error)

LoadWithOps reads the configuration entry file and resolves includes using the provided file operations.

func (*Config) AssignableTypes added in v0.8.0

func (c *Config) AssignableTypes(typeName string) []string

AssignableTypes returns the named type followed by any descendants.

func (*Config) DescendantTypes added in v0.8.0

func (c *Config) DescendantTypes(typeName string) []string

DescendantTypes returns the names of all descendants for the given type.

func (*Config) IsA added in v0.8.0

func (c *Config) IsA(child, parent string) bool

IsA reports whether child is the same as or inherits from parent.

func (*Config) Sources

func (c *Config) Sources() []string

Sources returns a sorted list of files that contributed entity definitions.

func (*Config) String

func (c *Config) String() string

String returns a string representation for debugging purposes.

type FieldDefinition

type FieldDefinition struct {
	Name           string
	Type           string
	ReferenceTypes []string
	Required       bool
	Repeated       bool
	Format         string
	Enum           []string
	Default        any
	Properties     map[string]*FieldDefinition
	Unique         bool
	Pattern        string
	Description    string
	PropertyOrder  []string
	Source         *FieldSourceDefinition `yaml:"source,omitempty" json:"source,omitempty"`
}

FieldDefinition holds schema information for a field.

func (*FieldDefinition) HasReferenceUnion added in v0.3.0

func (d *FieldDefinition) HasReferenceUnion() bool

HasReferenceUnion returns true when the field can reference more than one entity type.

func (*FieldDefinition) IsReference added in v0.3.0

func (d *FieldDefinition) IsReference() bool

IsReference returns true when the field stores an identifier for one or more entity types.

func (*FieldDefinition) ReferenceLabel added in v0.3.0

func (d *FieldDefinition) ReferenceLabel() string

ReferenceLabel returns the canonical textual representation of the field's reference targets.

type FieldSourceDefinition added in v0.6.0

type FieldSourceDefinition struct {
	Path           bool `yaml:"path,omitempty" json:"path,omitempty"`
	PathSegment    *int `yaml:"path_segment,omitempty" json:"path_segment,omitempty"`
	PathSegmentRev *int `yaml:"path_segment_rev,omitempty" json:"path_segment_rev,omitempty"`
}

FieldSourceDefinition describes a synthetic field value derived at read time.

func (*FieldSourceDefinition) IsPathDerived added in v0.6.0

func (d *FieldSourceDefinition) IsPathDerived() bool

IsPathDerived returns true when the field value is derived from the backing file path.

type IdentifierDefinition

type IdentifierDefinition struct {
	Field     string
	Generated bool
	Pattern   string
}

IdentifierDefinition specifies the identifier field metadata.

func (IdentifierDefinition) IsPath added in v0.3.0

func (d IdentifierDefinition) IsPath() bool

IsPath returns true when identifiers are derived from workspace-relative file paths.

type IncludeDefinition

type IncludeDefinition struct {
	Path     string
	Selector string
}

IncludeDefinition links a type to data files and selectors.

type TypeDefinition

type TypeDefinition struct {
	Name        string
	Source      string
	Description string
	Extends     string
	Ancestors   []string
	Descendants []string
	JSONSchema  string
	Identifier  IdentifierDefinition
	Include     []IncludeDefinition
	Fields      map[string]*FieldDefinition
	FieldOrder  []string
	InlineData  []map[string]any
	Write       WriteDefinition
}

TypeDefinition describes a single object type.

type WriteDefaults

type WriteDefaults struct {
	Template string
	Format   WriteFormat
}

WriteDefaults captures global defaults for write behaviour.

type WriteDefinition

type WriteDefinition struct {
	Template string
	Format   WriteFormat
}

WriteDefinition describes how to emit a single object to disk.

type WriteFormat

type WriteFormat string

WriteFormat enumerates supported serialization formats for writes.

const (
	WriteFormatYAML WriteFormat = "yaml"
	WriteFormatJSON WriteFormat = "json"
)

Jump to

Keyboard shortcuts

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