LemonChannels.Capabilities.Capability (lemon_channels v0.1.0)

View Source

Represents a single channel capability.

Capabilities can be simple boolean features or complex configurations with constraints and supported sub-features.

Summary

Functions

Creates a capability from a spec.

Merges two capabilities. The override takes precedence.

Creates a new capability.

Validates parameters against capability constraints.

Types

spec()

@type spec() :: type() | {type(), keyword()} | {type(), [atom()]}

t()

@type t() :: %LemonChannels.Capabilities.Capability{
  config: map(),
  enabled: boolean(),
  type: type()
}

type()

@type type() ::
  :attachments
  | :rich_blocks
  | :streaming
  | :threads
  | :reactions
  | :edit
  | :delete
  | :voice
  | :chunk_limit
  | :rate_limit
  | atom()

Functions

from_spec(type)

@spec from_spec(spec()) :: t() | nil

Creates a capability from a spec.

merge(base, override)

@spec merge(t(), t()) :: t()

Merges two capabilities. The override takes precedence.

new(type, opts \\ [])

@spec new(
  type(),
  keyword()
) :: t()

Creates a new capability.

Examples

Capability.new(:threads, enabled: true)
Capability.new(:attachments, enabled: true, max_size: 10_000_000)

validate(capability, params)

@spec validate(t(), map()) :: :ok | {:error, term()}

Validates parameters against capability constraints.