Pax.Adapter behaviour (Pax v0.0.1-dev.20251023)
View SourceSummary
Callbacks
A function that returns a valid Pax.Config spec for configuration keys and types accepted by the adapter.
The adapter initialization function, must return a map of initialized adapter state.
A function that merges any additional configuration options into the adapter's opts map.
Types
@type adapter_module() :: module()
@type callback_module() :: module()
@type socket() :: Phoenix.LiveView.Socket.t()
A Phoenix.LiveView socket
@type unsigned_params() :: Phoenix.LiveView.unsigned_params()
Unsigned params from a Phoenix.LiveView handle_params/3
Callbacks
@callback change_object( opts(), Pax.Interface.object(), unsigned_params(), fields :: [Pax.Field.t()] ) :: Ecto.Changeset.t()
A function that returns a valid Pax.Config spec for configuration keys and types accepted by the adapter.
@callback create_object(opts(), Pax.Interface.object(), Ecto.Changeset.t()) :: {:ok, map()} | {:error, Ecto.Changeset.t()}
@callback default_fields(opts()) :: Pax.Index.fields()
@callback get_object(opts(), lookup(), criteria(), socket()) :: Pax.Interface.object()
@callback init(callback_module(), opts :: []) :: opts()
The adapter initialization function, must return a map of initialized adapter state.
@callback list_objects(opts(), criteria()) :: [Pax.Interface.object()]
A function that merges any additional configuration options into the adapter's opts map.
@callback new_object(opts(), socket()) :: Pax.Interface.object()
@callback object_ids(opts(), Pax.Interface.object()) :: [String.Chars.t()] | nil
@callback object_name(opts(), Pax.Interface.object()) :: String.t() | nil
@callback update_object(opts(), Pax.Interface.object(), Ecto.Changeset.t()) :: {:ok, map()} | {:error, Ecto.Changeset.t()}
Functions
@spec change_object( t(), Pax.Interface.object(), unsigned_params(), fields :: [Pax.Field.t()] ) :: Ecto.Changeset.t()
@spec default_fields(t()) :: Pax.Index.fields()
@spec get_object(t(), lookup(), criteria(), socket()) :: Pax.Interface.object()
@spec list_objects(t(), criteria()) :: [Pax.Interface.object()]
@spec new_object(t(), socket()) :: Pax.Interface.object()
@spec object_ids(t(), Pax.Interface.object()) :: [String.Chars.t()]
@spec object_name(t(), Pax.Interface.object()) :: String.t() | nil
@spec update_object(t(), Pax.Interface.object(), Ecto.Changeset.t()) :: {:ok, any()} | {:error, Ecto.Changeset.t()}
@spec update_object(t(), Pax.Interface.object(), Ecto.Changeset.t()) :: {:ok, any()} | {:error, Ecto.Changeset.t()}