PhiaUiDesign.Mcp.BatchDesign (phia_ui v0.1.17)

Copy Markdown View Source

Execute multiple design operations atomically with bindings and rollback.

Parses a JSON-based DSL of operations (Insert, Copy, Update, Replace, Move, Delete) and executes them sequentially against the scene ETS. If any operation fails, the entire batch is rolled back to the pre-execution snapshot.

Operations

OpActionRequired fields
IInsertparent, data (type, component/tag)
CCopyid, parent
UUpdateid, data (attrs/slots/classes/layout)
RReplaceid, data (new node definition)
MMoveid, parent, optional index
DDeleteid

Bindings

Operations with "bind" store the created/resulting node ID. Subsequent operations can reference "$binding_name" in id or parent fields.

Limits

Maximum 25 operations per batch (matching OpenPencil convention).

Summary

Functions

Execute a batch of operations against the scene.

Functions

execute(scene, operations, state \\ %{})

@spec execute(reference(), [map()], map()) ::
  {:ok, [map()], map()} | {:error, String.t(), integer()}

Execute a batch of operations against the scene.

Returns {:ok, results, bindings} on success or {:error, message, op_index} on failure. On failure, the scene is rolled back to its pre-execution state.