Alternera.Resource.Verifiers (alternera_resource_sdk v0.9.0)

Copy Markdown View Source

The contract a resource of a resource package must keep, one module per rule (data-model.md § Validation rules):

  1. Multitenancy: attribute multitenancy on tenant_id, not global.
  2. DataLayer: AshPostgres on Alternera.Resource.Repo, in the package's schema resources_<package id>.
  3. Policies: the policy prefix comes first.
  4. LookupKey: a lookup key is unique per tenant through an identity on it alone.
  5. Expose: every exposed route and action exists, with the right type.
  6. ListFields: the list fields are public attributes.
  7. PaperTrail: the paper trail is on, in snapshot mode, with versions on destroy.
  8. Cache: cache is false, true or [ttl_ms: n] with n > 0.
  9. TenantReferences: every belongs_to is matched on tenant_id.
  10. UI: the ui section names public attributes, unique ids and Ash actions that fit what each action acts on.

Alternera.Resource.Transformers.Verify runs them at compile time; problems/1 runs them on a compiled resource, for the contract test kit.

Summary

Functions

What use Alternera.Resource recorded about the resource (%{package_id, resource_id, table, schema}), or nil for a resource that adds the extension without it.

The rules a resource breaks, as {rule, message}, for a compiled module or a DSL state during compilation. Empty when it keeps the contract.

The rule modules, in order.

Functions

identity(module)

@spec identity(module() | map()) :: map() | nil

What use Alternera.Resource recorded about the resource (%{package_id, resource_id, table, schema}), or nil for a resource that adds the extension without it.

problems(dsl_or_module)

@spec problems(module() | map()) :: [{module(), String.t()}]

The rules a resource breaks, as {rule, message}, for a compiled module or a DSL state during compilation. Empty when it keeps the contract.

rules()

@spec rules() :: [module()]

The rule modules, in order.