Selecto.Extension behaviour (Selecto v0.3.8)

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

Link to this type

extension_opts()

@type extension_opts() :: keyword()
Link to this type

extension_spec()

@type extension_spec() :: module() | {module(), extension_opts()}

Link to this section Callbacks

Link to this callback

components_views(selecto_or_domain, opts)

(optional)
@callback components_views(selecto_or_domain :: map(), opts :: extension_opts()) :: [
  tuple()
]

Return additional selecto_components view tuples for this extension.

Link to this callback

ecto_type_to_selecto_type(ecto_type, opts)

(optional)
@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.

Link to this callback

merge_domain(domain, opts)

(optional)
@callback merge_domain(domain :: map(), opts :: extension_opts()) :: map()

Merge extension-provided defaults into a domain during Selecto.configure/3.

Link to this callback

overlay_dsl_modules(opts)

(optional)
@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.

Link to this callback

overlay_fragment(overlay_module, opts)

(optional)
@callback overlay_fragment(overlay_module :: module(), opts :: extension_opts()) :: map()

Build extension-owned overlay fragments during @before_compile.

Link to this callback

overlay_setup(overlay_module, opts)

(optional)
@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.

Link to this callback

updato_domain(domain, opts)

(optional)
@callback updato_domain(domain :: map(), opts :: extension_opts()) :: map()

Merge extension defaults into a domain used by selecto_updato.