packs

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 9 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

This section is empty.

Variables

View Source
var (
	ErrInvalidReference    = errors.New("invalid pack reference")
	ErrUnknownPack         = errors.New("unknown pack")
	ErrUnknownVersion      = errors.New("unknown pack version")
	ErrSchemaIncompatible  = errors.New("pack schema incompatible")
	ErrInvalidDefinition   = errors.New("invalid pack definition")
	ErrDuplicateDefinition = errors.New("duplicate pack definition")
)

Functions

This section is empty.

Types

type CompileResult

type CompileResult struct {
	Values map[string]json.RawMessage
}

type Compiler

type Compiler interface {
	Compile(context.Context, Document) (CompileResult, error)
}

type Definition

type Definition struct {
	Metadata Metadata `json:"metadata"`
	Schema   Schema   `json:"schema"`
}

Definition is the immutable, declarative contract for one Pack version. It contains no executable rules; the runtime extension points below are intentionally separate from the data exposed to clients.

type DeletionPolicy

type DeletionPolicy string
const (
	DeletionPolicyRestrict DeletionPolicy = "restrict"
	DeletionPolicyCascade  DeletionPolicy = "cascade"
	DeletionPolicyAllow    DeletionPolicy = "allow"
)

type Diagnostic

type Diagnostic struct {
	Path    string `json:"path"`
	Code    string `json:"code"`
	Message string `json:"message"`
}

type Document

type Document struct {
	SchemaVersion        uint64                       `json:"schema_version"`
	Entities             map[string][]json.RawMessage `json:"entities"`
	EnvironmentOverrides map[string]map[string]any    `json:"environment_overrides"`
}

Document is the Pack-neutral representation passed between future draft, validation, compilation, and diff services. Source and provider adapters do not appear in this contract.

type EntityMetadata

type EntityMetadata struct {
	Name string `json:"name"`
	// Collection is the configuration field that stores the entity records. It
	// is intentionally internal until the public Pack metadata contract gains a
	// collection member.
	Collection                string          `json:"-"`
	Label                     string          `json:"label"`
	Description               string          `json:"description"`
	IDRule                    IDRule          `json:"id_rule"`
	DeletionPolicy            DeletionPolicy  `json:"deletion_policy"`
	EnvironmentOverrideFields []string        `json:"environment_override_fields"`
	ReferenceRules            []ReferenceRule `json:"reference_rules,omitempty"`
}

type EntitySchema

type EntitySchema struct {
	Name   string        `json:"name"`
	Fields []FieldSchema `json:"fields"`
}

type FieldSchema

type FieldSchema struct {
	Name        string          `json:"name"`
	Type        FieldType       `json:"type"`
	Required    bool            `json:"required"`
	Nullable    bool            `json:"nullable"`
	Default     json.RawMessage `json:"default"`
	Sensitivity Sensitivity     `json:"sensitivity"`
	UI          FieldUI         `json:"ui"`
	Validation  FieldValidation `json:"validation"`
}

type FieldType

type FieldType string
const (
	FieldTypeString  FieldType = "string"
	FieldTypeBoolean FieldType = "boolean"
	FieldTypeInteger FieldType = "integer"
	FieldTypeNumber  FieldType = "number"
	FieldTypeObject  FieldType = "object"
	FieldTypeArray   FieldType = "array"
	// FieldTypeAny accepts every non-null JSON value. Domain validators retain
	// responsibility for narrowing the allowed value based on sibling fields.
	FieldTypeAny       FieldType = "any"
	FieldTypeReference FieldType = "reference"
)

type FieldUI

type FieldUI struct {
	Label       string `json:"label"`
	Description string `json:"description"`
	Control     string `json:"control"`
	Group       string `json:"group"`
	Order       int    `json:"order"`
	Placeholder string `json:"placeholder,omitempty"`
}

type FieldValidation

type FieldValidation struct {
	Enum      []json.RawMessage `json:"enum"`
	MinLength *int              `json:"min_length,omitempty"`
	MaxLength *int              `json:"max_length,omitempty"`
	Minimum   *float64          `json:"minimum,omitempty"`
	Maximum   *float64          `json:"maximum,omitempty"`
}

type IDRule

type IDRule struct {
	Pattern   string `json:"pattern"`
	MinLength int    `json:"min_length"`
	MaxLength int    `json:"max_length"`
}

type Metadata

type Metadata struct {
	Name         string           `json:"name"`
	Version      string           `json:"version"`
	Description  string           `json:"description"`
	Capabilities []string         `json:"capabilities"`
	EntityTypes  []EntityMetadata `json:"entity_types"`
}

type Reference

type Reference struct {
	Name    string
	Version string
}

Reference preserves the name/version identity of a Pack without changing the manifest's opaque pack.id string.

func ParseReference

func ParseReference(value string) (Reference, error)

func (Reference) String

func (r Reference) String() string

type ReferenceRule added in v0.6.0

type ReferenceRule struct {
	Field            string         `json:"field"`
	TargetEntityType string         `json:"target_entity_type"`
	Shape            ReferenceShape `json:"shape"`
}

type ReferenceShape added in v0.6.0

type ReferenceShape string
const (
	ReferenceShapeScalar     ReferenceShape = "scalar"
	ReferenceShapeArrayItems ReferenceShape = "array_items"
	ReferenceShapeObjectKeys ReferenceShape = "object_keys"
)

type Registry

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

Registry is safe for concurrent readers and registration during startup. It only accepts compiled-in declarations; it never loads or executes user supplied Pack code.

func BuiltinRegistry

func BuiltinRegistry() *Registry

BuiltinRegistry contains Pack declarations compiled into the Conflow binary.

func MustNewRegistry

func MustNewRegistry(definitions ...Definition) *Registry

func NewRegistry

func NewRegistry(definitions ...Definition) (*Registry, error)

func (*Registry) Get

func (r *Registry) Get(name, version string) (Definition, uint64, error)

func (*Registry) List

func (r *Registry) List() Snapshot

func (*Registry) Register

func (r *Registry) Register(definition Definition) error

func (*Registry) Resolve

func (r *Registry) Resolve(reference string) (Definition, uint64, error)

func (*Registry) Schema

func (r *Registry) Schema(name, version string, requestedVersion *uint64) (Schema, uint64, error)

type Schema

type Schema struct {
	Version    uint64            `json:"version"`
	Entities   []EntitySchema    `json:"entities"`
	Migrations []SchemaMigration `json:"migrations"`
}

type SchemaIncompatibleError

type SchemaIncompatibleError struct {
	Requested uint64
	Current   uint64
}

func (*SchemaIncompatibleError) Error

func (e *SchemaIncompatibleError) Error() string

func (*SchemaIncompatibleError) Unwrap

func (e *SchemaIncompatibleError) Unwrap() error

type SchemaMigration

type SchemaMigration struct {
	FromVersion uint64 `json:"from_version"`
	ToVersion   uint64 `json:"to_version"`
	Description string `json:"description"`
}

type SchemaMigrator

type SchemaMigrator interface {
	Migrate(context.Context, Document, uint64) (Document, error)
}

type SemanticChange

type SemanticChange struct {
	Path    string `json:"path"`
	Kind    string `json:"kind"`
	Summary string `json:"summary"`
}

type SemanticDiff

type SemanticDiff struct {
	Changes []SemanticChange `json:"changes"`
}

type SemanticDiffer

type SemanticDiffer interface {
	Diff(context.Context, Document, Document) (SemanticDiff, error)
}

type Sensitivity

type Sensitivity string
const (
	SensitivityPublic    Sensitivity = "public"
	SensitivitySensitive Sensitivity = "sensitive"
)

type Snapshot

type Snapshot struct {
	Definitions []Definition
	Revision    uint64
}

type Validator

type Validator interface {
	Validate(context.Context, Document) ([]Diagnostic, error)
}

Jump to

Keyboard shortcuts

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