Selecto.Extension behaviour (Selecto v0.4.3)
Behavior contract for Selecto ecosystem extensions.
Extensions are loaded from domain definitions through the :extensions key.
A single extension can participate in multiple packages (selecto,
selecto_components, selecto_updato) by implementing the callbacks relevant
to that package.
domain-usage
Domain Usage
%{
name: "Store",
source: %{...},
schemas: %{},
joins: %{},
extensions: [
# From the :selecto_postgis package
Selecto.Extensions.PostGIS,
{MyApp.Selecto.Extensions.Timescale, hypertable: "events"}
]
}
Link to this section Summary
Callbacks
Return additional selecto_components view tuples for this extension.
Map Ecto schema field types to Selecto types during Selecto.EctoAdapter
introspection.
Merge extension-provided defaults into a domain during Selecto.configure/3.
Return DSL modules imported by Selecto.Config.OverlayDSL when this extension
is enabled in an overlay module.
Build extension-owned overlay fragments during @before_compile.
Compile-time hook called from Selecto.Config.OverlayDSL.__using__/1.
Merge extension defaults into a domain used by selecto_updato.
Link to this section Types
extension_opts()
@type extension_opts() :: keyword()
extension_spec()
@type extension_spec() :: module() | {module(), extension_opts()}
Link to this section Callbacks
@callback components_views(selecto_or_domain :: map(), opts :: extension_opts()) :: [ tuple() ]
Return additional selecto_components view tuples for this extension.
@callback ecto_type_to_selecto_type(ecto_type :: term(), opts :: extension_opts()) :: atom() | nil
Map Ecto schema field types to Selecto types during Selecto.EctoAdapter
introspection.
Return nil to indicate no mapping for the provided type.
@callback merge_domain(domain :: map(), opts :: extension_opts()) :: map()
Merge extension-provided defaults into a domain during Selecto.configure/3.
@callback overlay_dsl_modules(opts :: extension_opts()) :: [module()]
Return DSL modules imported by Selecto.Config.OverlayDSL when this extension
is enabled in an overlay module.
@callback overlay_fragment(overlay_module :: module(), opts :: extension_opts()) :: map()
Build extension-owned overlay fragments during @before_compile.
@callback overlay_setup(overlay_module :: module(), opts :: extension_opts()) :: :ok
Compile-time hook called from Selecto.Config.OverlayDSL.__using__/1.
Use this to register extension-specific module attributes for overlay DSL directives.
@callback updato_domain(domain :: map(), opts :: extension_opts()) :: map()
Merge extension defaults into a domain used by selecto_updato.