Defines the behavior and macros for creating Bobbin nodes.
A node is the fundamental unit of logic in a flow. It consists of a definition/0
describing its interface and a handler/2 to process data.
Example
defmodule MyNodes.HttpNode do
use Bobbin.Node
definition do
%{
name: "http_request",
title: "HTTP Request",
category: :network,
color: "bg-blue-500",
icon: "hero-globe-alt",
inputs: [:exec, :url],
outputs: [:success, :error]
}
end
@impl true
def handler(context, input) do
{:ok, context, :success}
end
end
Summary
Functions
Macro to define the node metadata.
Converts a node module's definition to a Rete.js-compatible map.
Types
@type context() :: map()
@type input() :: any()
@type node_definition() :: %{ :name => String.t(), :title => String.t(), optional(:category) => atom() | String.t(), optional(:color) => String.t(), optional(:icon) => String.t(), optional(:inputs) => [map() | atom() | String.t()], optional(:outputs) => [map() | atom() | String.t()], optional(atom()) => any() }
Callbacks
@callback definition() :: node_definition()
Returns the metadata and interface definition for the node.
@callback handler(context(), input()) :: {:ok, context(), output_port()} | {:error, term()}
Processes the node logic.
Returns {:ok, new_context, output_port} on success, or {:error, reason} on failure.
Functions
Macro to define the node metadata.
Converts a node module's definition to a Rete.js-compatible map.
The returned map follows the Rete.js node schema with id, label,
inputs, and outputs structured as socket definitions.
Example
Bobbin.Node.to_rete(MyNodes.HttpNode)
# => %{
# id: "http_request",
# label: "HTTP Request",
# color: "bg-blue-500",
# inputs: [%{id: "exec", label: "Exec"}, %{id: "url", label: "Url"}],
# outputs: [%{id: "success", label: "Success"}, %{id: "error", label: "Error"}]
# }