# `Gno.CommitOperation.Type`
[🔗](https://github.com/rdf-elixir/gno/blob/v0.1.0/lib/gno/commit/operation/type.ex#L1)

Behaviour for custom commit operation types.

A custom commit operation type can be defined by implementing this behaviour and using the `use Gno.CommitOperation.Type` macro.

This provides a macro `def_commit_operation/2` that can be used to define the
Grax schema of the commit operation.
The schema should only define properties for configuration that is loaded from
the RDF manifest. Runtime state belongs on the `Gno.Commit.Processor` (via
`assigns`, `metadata`, etc.), so that middlewares can access it.

# `t`

```elixir
@type t() :: Grax.Schema.t()
```

# `all_changes`

```elixir
@callback all_changes(Gno.Commit.Processor.t()) :: %{optional(atom()) =&gt; any()}
```

Returns all changes that should be applied in the commit operation.

This includes the effective changeset and any additional changes that should be
applied in the same transaction.

# `handle_empty_changeset`

```elixir
@callback handle_empty_changeset(
  Gno.Commit.Processor.t(),
  handling :: binary(),
  Gno.EffectiveChangeset.t()
) ::
  {:ok, Gno.Commit.Processor.t()}
  | {:skip_transaction, Gno.Commit.Processor.t()}
  | {:error, any()}
```

Handles the case that no effective changes result from the changeset.

Implementations can in particular implement custom handling of the
`:on_no_effective_changes` option with additional `handling` values.

# `handle_step`

```elixir
@callback handle_step(step :: atom(), Gno.Commit.Processor.t()) ::
  {:ok, Gno.Commit.Processor.t()}
  | {:error, term()}
  | {:error, term(), Gno.Commit.Processor.t()}
```

Handles state transitions during the commit process.

# `prepare_commit`

```elixir
@callback prepare_commit(Gno.Commit.Processor.t()) ::
  {:ok, Gno.Commit.Processor.t()} | {:error, any()}
```

Prepares the final commit and adding its metadata.

Note, that this callback is called by the default implementation of the `handle_step/2` of
the `:preparation` step, allowing its customization. So, it is only needed when this
default implementation is reused.

# `result`

```elixir
@callback result(Gno.Commit.Processor.t()) ::
  {:ok, any(), Gno.Commit.Processor.t()} | {:error, any()}
```

Returns the result of the commit operation.

# `rollback`

```elixir
@callback rollback(state :: atom(), Gno.Commit.Processor.t()) ::
  {:ok, Gno.Commit.Processor.t()}
  | {:error, term()}
  | {:error, term(), Gno.Commit.Processor.t()}
```

Rolls back changes when an error occurs during the commit process.

# `def_commit_operation`
*macro* 

---

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