AttrEngine.Schema.Attribute (attr_engine v0.3.0)

Copy Markdown View Source

Structural primitive — defines a single configurable field.

An Attribute is a reusable building block: "text_input", "email_input", "asset", "select", etc. It carries default data_config and ui_config that can be overridden at the ASA and ASD layers.

Key fields

  • handle — unique machine identifier, used in templates and data resolution
  • data_config — embedded DataConfig: data type, validation rules, source mapping
  • ui_config — embedded UIConfig: input type, tag, classes, edit/view modules
  • draft_config — staged config changes before promotion
  • translations — JSONB map for translatable metadata (name, description)
  • state — lifecycle state, used by workflows and pipelines

Virtual fields

  • sample — preview sample value
  • data_preview — data configuration preview for UI
  • ui_preview — UI configuration preview for UI
  • ui_state — transient UI state (expanded, selected, etc.)
  • easy_mode — auto-generates handle/code/state from name

Config cascade

Attribute provides the base layer (layer 1) of the 4-layer cascade: Attribute defaults → ASA overrides → ASD instance → runtime enrichment.

Summary

Functions

Builds a changeset for attribute creation and updates.

Functions

changeset(attribute, attrs)

Builds a changeset for attribute creation and updates.

Handles auto-injection of handle, code, and state when easy_mode is enabled. Casts embedded UI and data configurations, and prevents modification of locked identifiers on persisted records.