AshTypescript.Rpc.LoadRestrictions (ash_typescript v0.18.0)

Copy Markdown View Source

Enforcement of an RPC action's allowed_loads / denied_loads options.

normalize/1 turns the DSL spec into pre-normalized path lists once per request. check!/2 is then called by AshTypescript.Rpc.FieldProcessing.FieldSelector at every point where it appends to the Ash load statement, so a load cannot reach the load statement without passing the restrictions — there is no separate traversal that could disagree with field selection about what is being loaded.

Paths are lists of internal field names, e.g. [:comments, :weighted_score].

Summary

Functions

Validates a single load path against the restrictions.

Normalizes AshTypescript.Manifest.Custom.load_restrictions/1 output into pre-normalized path lists.

Types

paths()

@type paths() :: [[atom()]]

t()

@type t() :: :none | {:allow, paths()} | {:deny, paths()}

Functions

check!(path, arg2)

@spec check!([atom()], t()) :: :ok

Validates a single load path against the restrictions.

Throws {:load_not_allowed, [path]} or {:load_denied, [path]} — the same tuples AshTypescript.Rpc.ErrorBuilder already handles — so callers inside field selection need no extra error plumbing.

normalize(arg1)

@spec normalize(term()) :: t()

Normalizes AshTypescript.Manifest.Custom.load_restrictions/1 output into pre-normalized path lists.