Lotus.Visibility.Matcher (Lotus v1.2.0)

Copy Markdown View Source

The compiled form of a visibility rule set.

Lotus.Visibility.compile/2 turns the schema, table and column rules a resolver returns into one of these, once. Exact names go into sets, regex rules into short ordered lists, and the built-in denies of the source's adapter are merged into the deny sets. Every check in Lotus.Visibility then runs against the compiled form instead of walking the raw rules.

The struct is opaque to callers. Build it with Lotus.Visibility.compile/2 and pass it to the Lotus.Visibility check functions. Precedence and matching are exactly those documented in Lotus.Visibility.

Summary

Types

column_rules()

@type column_rules() :: %{
  schema_table: [{term(), term(), term(), term()}],
  table: [{term(), term(), term()}],
  exact: %{required(String.t()) => {non_neg_integer(), term()}},
  patterns: [{non_neg_integer(), term(), term()}]
}

name_set()

@type name_set() :: %{exact: MapSet.t(String.t()), patterns: [Regex.t()]}

t()

@type t() :: %Lotus.Visibility.Matcher{
  column: column_rules(),
  schema_allow: :all | name_set(),
  schema_deny: name_set(),
  table_allow: table_allow(),
  table_deny: table_set()
}

table_allow()

@type table_allow() ::
  :all
  | %{
      applies_to_all?: boolean(),
      schemas: name_set(),
      nil_schema?: boolean(),
      rules: table_set()
    }

table_set()

@type table_set() :: %{
  exact: MapSet.t({String.t() | nil, String.t()}),
  bare: MapSet.t(String.t()),
  patterns: [{term(), term()}]
}