# `Choreo.Lab.View`
[🔗](https://github.com/code-shoily/choreo/blob/v0.14.1/lib/choreo/lab/view.ex#L1)

Pipe-friendly view helpers for exploring Choreo models in Livebook.

This module is ordinary Elixir, not a macro DSL. It is a thin convenience
layer over `Choreo.View` that keeps the stable view API intact while making
common zoom, focus, filter, path, and collapse operations easier to compose in
pipelines.

`Choreo.View` remains the primitive graph-lens API. `Choreo.Lab.View` is the
ergonomic exploration API: a place to try friendlier names, positional forms,
and common predicates before deciding whether any of them should graduate into
core `Choreo.View`.

Prefer alias-qualified usage for better editor autocomplete:

    alias Choreo.Lab.View

    system
    |> View.zoom(1)
    |> View.only_type([:service, :database, :cache])
    |> View.focus(:api, depth: 2)

The functions return ordinary Choreo structs rebuilt through the
`Choreo.Viewable` protocol.

# `node_id`

```elixir
@type node_id() :: Yog.node_id()
```

# `node_type`

```elixir
@type node_type() :: atom()
```

# `viewable`

```elixir
@type viewable() :: struct()
```

# `between`

```elixir
@spec between(viewable(), node_id(), node_id(), keyword()) :: viewable()
```

Keeps the shortest path between two nodes, optionally with surrounding radius.

# `collapse_nodes`

```elixir
@spec collapse_nodes(viewable(), node_id() | [node_id()], node_id(), keyword()) ::
  viewable()
```

Collapses the listed node IDs into `new_id`.

# `collapse_type`

```elixir
@spec collapse_type(viewable(), node_type() | [node_type()], node_id(), keyword()) ::
  viewable()
```

Collapses all nodes of the given type(s) into `new_id`.

# `focus`

```elixir
@spec focus(viewable(), node_id(), keyword()) :: viewable()
```

Keeps `node` and its surrounding neighbourhood.

Accepts either `:depth` or `:radius`; both map to `Choreo.View.focus/3`'s
`:radius` option. `:mode` may be `:neighbors`, `:successors`, or
`:predecessors`.

# `neighborhood`

```elixir
@spec neighborhood(viewable(), node_id(), keyword()) :: viewable()
```

Alias for `focus/3` that reads naturally in exploratory pipelines.

# `only`

```elixir
@spec only(viewable(), keyword()) :: viewable()
```

Generic keep filter for small Livebook experiments.

Supported options:

  * `:nodes` — node ID or IDs to keep
  * `:type` / `:types` — semantic node type or types to keep

When both are supplied, a node may match either condition.

# `only_nodes`

```elixir
@spec only_nodes(viewable(), node_id() | [node_id()], keyword()) :: viewable()
```

Keeps only the listed node IDs.

# `only_type`

```elixir
@spec only_type(viewable(), node_type() | [node_type()], keyword()) :: viewable()
```

Keeps only nodes whose `:node_type` or `:type` matches the given type(s).

# `path`

```elixir
@spec path(viewable(), node_id(), node_id(), keyword()) :: viewable()
```

Alias for `between/4`.

# `tabs`

```elixir
@spec tabs(viewable(), keyword()) :: any()
```

Renders the diagram as a tabbed layout in Livebook featuring Siren, Graphviz, and Sketch.

Only active when `Kino` is loaded. Returns the Kino widget tab layout.
If Kino is not loaded, returns the diagram unmodified.

# `taxonomy`

```elixir
@spec taxonomy() :: %{
  transforms: [atom()],
  filters: [atom()],
  collapse: [atom()],
  options: [atom()],
  renders: [atom()]
}
```

Returns the view helper vocabulary for Livebook discovery.

    iex> taxonomy = Choreo.Lab.View.taxonomy()
    iex> :zoom in taxonomy.transforms
    true
    iex> :only_type in taxonomy.filters
    true
    iex> :collapse_type in taxonomy.collapse
    true

# `to_dot`

```elixir
@spec to_dot(viewable(), keyword()) :: String.t()
```

Converts the diagram to a Graphviz DOT string.

# `to_mermaid`

```elixir
@spec to_mermaid(viewable(), keyword()) :: String.t()
```

Converts the diagram to a Mermaid string.

# `to_siren`

```elixir
@spec to_siren(viewable(), keyword()) :: any()
```

Renders the diagram using the Siren Kino widget in Livebook.

Only active when `Kino` is loaded. Returns the Kino widget.
If Kino is not loaded, returns the diagram unmodified.

# `to_sketch`

```elixir
@spec to_sketch(viewable(), keyword()) :: any()
```

Renders the diagram using the Sketch Kino widget in Livebook.

Only active when `Kino` is loaded. Returns the Kino widget.
If Kino is not loaded, returns the diagram unmodified.

# `trace`

```elixir
@spec trace(viewable(), node_id(), node_id(), keyword()) :: viewable()
```

Keeps a trace path between two nodes using `Choreo.View.focus_trace/4`.

# `verbs`

```elixir
@spec verbs() :: %{
  transforms: [atom()],
  filters: [atom()],
  collapse: [atom()],
  options: [atom()],
  renders: [atom()]
}
```

Compatibility alias for `taxonomy/0`.

# `without`

```elixir
@spec without(viewable(), keyword()) :: viewable()
```

Generic remove filter for small Livebook experiments.

Supported options mirror `only/2`.

# `without_nodes`

```elixir
@spec without_nodes(viewable(), node_id() | [node_id()], keyword()) :: viewable()
```

Removes the listed node IDs.

# `without_type`

```elixir
@spec without_type(viewable(), node_type() | [node_type()], keyword()) :: viewable()
```

Removes nodes whose `:node_type` or `:type` matches the given type(s).

# `zoom`

```elixir
@spec zoom(viewable(), non_neg_integer(), keyword()) :: viewable()
```

Applies `Choreo.View.zoom/2` with a positional level.

    iex> system = Choreo.new() |> Choreo.add_service(:api) |> Choreo.add_database(:db)
    iex> system |> Choreo.Lab.View.zoom(0) |> Choreo.nodes()
    %{api: %{label: "api", node_type: :service}}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
