AttrEngine.Schema.AttributeSet (attr_engine v0.2.2)

Copy Markdown View Source

Named group of attributes — a reusable content shape.

An AttributeSet groups Attributes via the ASA join table, forming a "schema" for a block, piece, entity, or form. It carries its own ui_config (container-level presentation) and data_config.

Composition

AttributeSets can form DAG hierarchies via AttrEngine.Schema.AttributeSetTree:

  • includes — composition, child attributes added to parent
  • extends — inheritance, child specialises parent
  • overrides — explicit override of specific attributes

Typing

AttributeSets can be classified by Types via AttrEngine.Schema.AttributeSetTypeAssociation, allowing the same system to distinguish "CMS block", "entity schema", "piece", etc.

Multilingual

The translations field holds JSONB maps for translatable metadata: %{"name" => %{"en" => "Hero Banner", "el" => "Κεντρικό Banner"}}

Summary

Functions

Standard changeset with easy_mode support.

Setup changeset for workflow-driven creation with nested attributes.

Functions

changeset(attribute_set, attrs, opts \\ [])

@spec changeset(
  %AttrEngine.Schema.AttributeSet{
    __meta__: term(),
    active: term(),
    attribute_set_attributes: term(),
    attributes: term(),
    code: term(),
    data_config: term(),
    deleted: term(),
    description: term(),
    easy_mode: term(),
    exportable: term(),
    handle: term(),
    id: term(),
    importable: term(),
    inserted_at: term(),
    name: term(),
    pub_id: term(),
    readonly: term(),
    schema: term(),
    searchable: term(),
    sid: term(),
    sort: term(),
    state: term(),
    system: term(),
    translations: term(),
    ui_config: term(),
    updated_at: term(),
    validations: term(),
    visible: term()
  },
  map(),
  keyword()
) :: Ecto.Changeset.t()

Standard changeset with easy_mode support.

In easy_mode, handle, code, state, and flags are auto-generated from the name. In full mode, all fields must be provided explicitly.

Options

  • :tenant_id — when set, validates handle uniqueness within the tenant
  • :prefix — Postgres schema prefix for multi-tenant query scoping

setup_changeset(attribute_set, attrs, opts \\ [])

@spec setup_changeset(
  %AttrEngine.Schema.AttributeSet{
    __meta__: term(),
    active: term(),
    attribute_set_attributes: term(),
    attributes: term(),
    code: term(),
    data_config: term(),
    deleted: term(),
    description: term(),
    easy_mode: term(),
    exportable: term(),
    handle: term(),
    id: term(),
    importable: term(),
    inserted_at: term(),
    name: term(),
    pub_id: term(),
    readonly: term(),
    schema: term(),
    searchable: term(),
    sid: term(),
    sort: term(),
    state: term(),
    system: term(),
    translations: term(),
    ui_config: term(),
    updated_at: term(),
    validations: term(),
    visible: term()
  },
  map(),
  keyword()
) :: Ecto.Changeset.t()

Setup changeset for workflow-driven creation with nested attributes.

Like changeset/3 but uses cast_assoc(:attributes) to create nested Attribute records in a single operation. Used by attribute set creation workflows that define the set and its attributes in one step.

Options

  • :tenant_id — when set, validates handle uniqueness within the tenant
  • :prefix — Postgres schema prefix for multi-tenant query scoping