Caravela.Schema.Domain (Caravela v0.13.0)

Copy Markdown View Source

A whole domain: the top-level IR produced by compilation.

Summary

Functions

The first entity that declares an authenticatable block, or nil if none do. Caravela currently supports a single authenticatable entity per domain.

True if the domain has an authenticatable entity.

The fallback policy for entities without a declared policy block. :deny (default): scope filters to zero rows, every field hidden, every write gate denies. :allow: legacy permissive behavior.

Lookup an entity by its DSL name.

Does the domain declare a hook for action on entity?

Is the domain multi-tenant (row-level scoped by tenant_id)?

Policy entry for entity, or nil if none was declared.

Explicit API version declared via version "v1" in the DSL. Returns the raw string (e.g. "v1") or nil when no version was declared.

Camelized version segment usable as a module name suffix ("v1""V1"). Returns nil when no version is declared.

Types

t()

@type t() :: %Caravela.Schema.Domain{
  entities: [Caravela.Schema.Entity.t()],
  hooks: [Caravela.Schema.Hook.t()],
  module: module(),
  opts: keyword(),
  policies: [Caravela.Policy.Entry.t()],
  relations: [Caravela.Schema.Relation.t()]
}

Functions

auth_entity(domain)

@spec auth_entity(t()) :: Caravela.Schema.Entity.t() | nil

The first entity that declares an authenticatable block, or nil if none do. Caravela currently supports a single authenticatable entity per domain.

authenticated?(d)

@spec authenticated?(t()) :: boolean()

True if the domain has an authenticatable entity.

default_policy(domain)

@spec default_policy(t()) :: :deny | :allow

The fallback policy for entities without a declared policy block. :deny (default): scope filters to zero rows, every field hidden, every write gate denies. :allow: legacy permissive behavior.

fetch_entity(domain, name)

@spec fetch_entity(t(), atom()) :: Caravela.Schema.Entity.t() | nil

Lookup an entity by its DSL name.

has_hook?(domain, action, entity)

@spec has_hook?(t(), Caravela.Schema.Hook.action(), atom()) :: boolean()

Does the domain declare a hook for action on entity?

multi_tenant?(domain)

@spec multi_tenant?(t()) :: boolean()

Is the domain multi-tenant (row-level scoped by tenant_id)?

policy_for(domain, entity)

@spec policy_for(t(), atom()) :: Caravela.Policy.Entry.t() | nil

Policy entry for entity, or nil if none was declared.

version(domain)

@spec version(t()) :: String.t() | nil

Explicit API version declared via version "v1" in the DSL. Returns the raw string (e.g. "v1") or nil when no version was declared.

version_segment(domain)

@spec version_segment(t()) :: String.t() | nil

Camelized version segment usable as a module name suffix ("v1""V1"). Returns nil when no version is declared.