AshBoundary

CI

AshBoundary is a Spark DSL extension for Ash domains. It derives a boundary declaration from the domain DSL. The boundary compiler enforces the declaration on each build.

Every option in the boundary block passes straight through to boundary, unchanged: deps, exports, check, type, dirty_xrefs all mean exactly what they mean on a hand-written use Boundary. AshBoundary computes one thing on top: exports gains the domain module itself and every resource with at least one domain-level define.

Conventions

Installation

Add ash_boundary and boundary to the deps in mix.exs:

def deps do
[
{:ash_boundary, "~> 0.1.0"},
{:boundary, "~> 0.10", runtime: false}
]
end

Add the :boundary compiler to the project configuration:

def project do
[
app: :my_app,
compilers: [:boundary] ++ Mix.compilers(),
# ...
]
end

Usage

Add AshBoundary to the extensions of a domain. Declare dependencies on other domains, and any public module that is not a resource, in a boundary block:

defmodule MyApp.Blog do
use Ash.Domain, extensions: [AshBoundary]
boundary do
deps [MyApp.Accounts]
exports [MyApp.Blog.PostStatus]
end
resources do
resource MyApp.Blog.Post do
define :get_post, action: :read
define :update_post, action: :update
end
resource MyApp.Blog.Comment
end
end

This configuration has these effects:

Examples

Three examples live in examples/, each its own Mix project:

Clarity

With clarity installed, each domain gains a "Boundary Dependencies" tab holding a diagram of its deps, where clicking a node opens that domain.

The diagram stacks domains in tiers by their distance from the domains that depend on nothing, and leaves out any edge a longer path already implies.

Usage rules

The package ships a usage-rules.md for usage_rules. List :ash_boundary in your project's usage_rules and run mix usage_rules.sync:

def project do
[
usage_rules: [:ash_boundary],
# ...
]
end

Documentation

Docs for latest main is published at mbuhot.github.io/ash_boundary. Docs for versioned releases will be available at hexdocs.pm/ash_boundary.

See also the boundary docs.

License

MIT. See LICENSE.