StatifierBlocks.Block (StatifierBlocks v0.1.0)

Copy Markdown View Source

One node of a block document (ADR-0001).

A block is {type, id, config, slots}, plus the type_version axis decision 4 adds - and nothing else (decision 2). No field is added for layout, selection, collapse state, validation results, generated SCXML, or a provenance map: every one of those is a function of the document plus a block-type registry, and this layer stores none of them.

Summary

Types

Owned and interpreted by the block type; opaque to this layer.

Document-unique, stable, never reused. "blk_" <> uxid.

Any value expressible in canonical JSON. Note: no floats.

t()

Namespaced block-type name, e.g. "core.branch", "myapp.authorize".

Functions

Builds a block of the given type.

Types

config()

@type config() :: %{optional(String.t()) => json()}

Owned and interpreted by the block type; opaque to this layer.

id()

@type id() :: String.t()

Document-unique, stable, never reused. "blk_" <> uxid.

json()

@type json() ::
  nil
  | boolean()
  | integer()
  | String.t()
  | [json()]
  | %{optional(String.t()) => json()}

Any value expressible in canonical JSON. Note: no floats.

slot_name()

@type slot_name() :: String.t()

t()

@type t() :: %StatifierBlocks.Block{
  config: config(),
  id: id(),
  slots: %{optional(slot_name()) => [t()]},
  type: type_name(),
  type_version: pos_integer()
}

type_name()

@type type_name() :: String.t()

Namespaced block-type name, e.g. "core.branch", "myapp.authorize".

Functions

new(type, opts \\ [])

@spec new(
  type_name(),
  keyword()
) :: t()

Builds a block of the given type.

Options: :id (default a freshly minted StatifierBlocks.Id.block/0), :type_version (default 1), :config (default %{}), :slots (default %{}).