# `MishkaGervaz.Table.Behaviours.TypeRegistry`
[🔗](https://github.com/mishka-group/mishka_gervaz/blob/v0.0.1-alpha.3/lib/mishka_gervaz/table/behaviours/type_registry.ex#L1)

Behaviour for type registry modules.

Ensures consistent API across column, filter, and action type registries.
Each registry maps atom names to module implementations.

## Usage

### Simple format (for filters, actions)

    defmodule MyApp.Table.Types.Filter do
      use MishkaGervaz.Table.Behaviours.TypeRegistry,
        builtin: %{
          text: MyApp.Table.Types.Filter.Text,
          select: MyApp.Table.Types.Filter.Select
        },
        default: MyApp.Table.Types.Filter.Text
    end

### Tuple format with Ash type inference (for columns)

    defmodule MyApp.Table.Types.Column do
      use MishkaGervaz.Table.Behaviours.TypeRegistry,
        builtin: %{
          text: {MyApp.Table.Types.Column.Text, []},
          boolean: {MyApp.Table.Types.Column.Boolean, [Ash.Type.Boolean]},
          number: {MyApp.Table.Types.Column.Number, [Ash.Type.Integer, Ash.Type.Float]}
        },
        default: MyApp.Table.Types.Column.Text
    end

When using tuple format `{Module, [AshTypes]}`, the macro automatically generates
`infer_from_ash_type/1` that maps Ash types to the corresponding module.

## Provided Functions

When you `use` this behaviour, you get:

- `get/1` - Get module by atom name (returns module or nil)
- `builtin_types/0` - List all registered type names
- `builtin?/1` - Check if type name is registered
- `default/0` - Get the default type module
- `get_or_passthrough/1` - Get module, or return type as-is for custom modules
- `infer_from_ash_type/1` - (tuple format only) Infer module from Ash attribute type

## Optional Callbacks

- `resolve_type/1` - Resolve type from config map (single context)
- `resolve_type/2` - Resolve type from config map with extra context

## Consumers

This behaviour is `use`-d by:

- `MishkaGervaz.Table.Types.Column` (column registry)
- `MishkaGervaz.Table.Types.Filter` (filter registry)
- `MishkaGervaz.Table.Types.Action` (action registry)
- `MishkaGervaz.Form.Types.Field` (form field registry)

See `MishkaGervaz.Table.Behaviours.ColumnType`,
`MishkaGervaz.Table.Behaviours.FilterType`,
`MishkaGervaz.Table.Behaviours.ActionType`, and
`MishkaGervaz.Form.Behaviours.FieldType`.

# `builtin?`

```elixir
@callback builtin?(type :: atom()) :: boolean()
```

Check if a type name is a built-in type.

# `builtin_types`

```elixir
@callback builtin_types() :: [atom()]
```

List all built-in type names.

# `get`

```elixir
@callback get(type :: atom()) :: module() | nil
```

Get the module for a built-in type.

Returns the module if found, nil otherwise.

# `resolve_type`
*optional* 

```elixir
@callback resolve_type(config :: map()) :: module()
```

Resolve type module from configuration.

Used when type needs to be determined from a config map
(e.g., filter config with `:type` key).

# `resolve_type`
*optional* 

```elixir
@callback resolve_type(config :: map(), context :: map()) :: module()
```

Resolve type module from configuration with additional context.

Used when type resolution needs extra context
(e.g., column config + resource attributes).

---

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