ExScim.QueryFilter.Adapter behaviour (ex_scim v0.2.2)

Copy Markdown View Source

Behaviour for converting SCIM filter ASTs into storage-level query logic.

The SCIM filter parser produces a nested tuple AST representing filter expressions. Implementations translate this AST into queries appropriate for their storage backend (e.g. Ecto where clauses, ETS match specs).

AST structure

Single comparisons:

{:eq, "userName", "alice"}
{:co, "displayName", "john"}
{:sw, "email", "admin@"}
{:gt, "meta.lastModified", "2024-01-01T00:00:00Z"}

Logical operators:

{:and, left_ast, right_ast}
{:or, left_ast, right_ast}
{:not, inner_ast}

Implementations

Summary

Types

The data source to filter: an Ecto queryable, a list of maps, etc.

A SCIM filter AST node.

The filtered result: a modified Ecto query, a filtered list, etc.

Callbacks

Applies the filter AST to the given data source, returning a filtered result.

Types

data_source()

@type data_source() :: term()

The data source to filter: an Ecto queryable, a list of maps, etc.

filter_ast()

@type filter_ast() :: term()

A SCIM filter AST node.

Comparison tuples like {:eq, field, value} or logical combinators like {:and, left, right}. nil means no filter is applied.

result()

@type result() :: term()

The filtered result: a modified Ecto query, a filtered list, etc.

Callbacks

apply_filter(data_source, filter_ast)

@callback apply_filter(data_source(), filter_ast()) :: result()

Applies the filter AST to the given data source, returning a filtered result.