Bloccs.Web.Resolver behaviour (bloccs_web v0.1.0)

Copy Markdown View Source

The integration seam between the dashboard and the host application: who is looking, what they may see, and which features are enabled.

A host provides a module implementing this behaviour and passes it to bloccs_dashboard/2 via :resolver. Every callback has a default (see Bloccs.Web.Access), so the simplest mount needs no resolver at all.

The Pro seam

resolve_features/1 is how the open-core / Pro split is expressed without any LiveView change: the free build returns every feature, a future licensed build returns a subset, and panels gate themselves with Bloccs.Web.Access.enabled?/2. The dashboard ships only the seam — no license logic.

Summary

Types

A coarse access level for the session. The dashboard is observe-only, so the meaningful distinction is full access vs. forbidden.

A feature flag the dashboard consults before rendering gated UI.

An opaque user term resolved from the connection (whatever the host uses).

Callbacks

Resolve the access level for a user. Defaults to :all.

Resolve the set of enabled features for a user. Defaults to :all (every feature on — the free baseline). A licensed build returns an explicit list.

Resolve the current user from the Plug session map. Defaults to nil.

Types

access()

@type access() :: :all | {:forbidden, reason :: term()}

A coarse access level for the session. The dashboard is observe-only, so the meaningful distinction is full access vs. forbidden.

feature()

@type feature() :: atom()

A feature flag the dashboard consults before rendering gated UI.

user()

@type user() :: term()

An opaque user term resolved from the connection (whatever the host uses).

Callbacks

resolve_access(user)

(optional)
@callback resolve_access(user()) :: access()

Resolve the access level for a user. Defaults to :all.

resolve_features(user)

(optional)
@callback resolve_features(user()) :: :all | [feature()]

Resolve the set of enabled features for a user. Defaults to :all (every feature on — the free baseline). A licensed build returns an explicit list.

resolve_user(session)

(optional)
@callback resolve_user(session :: map()) :: user()

Resolve the current user from the Plug session map. Defaults to nil.