Sigra.Audit.Query (Sigra v1.20.0)

Copy Markdown View Source

Composable Ecto query builder for audit_events.

Supported filters (D-12):

  • :actor_id
  • :action
  • :action_prefix — SQL LIKE with escaped prefix
  • :outcome
  • :from / :toDateTime bounds on inserted_at
  • :target_id
  • :target_type

Pagination uses the or-expanded (inserted_at, id) tiebreak so it is portable across PostgreSQL, MySQL, and SQLite (RESEARCH A3).

Summary

Functions

Returns the canonical list of filter keys accepted by build/2.

Applies cursor + limit + desc ordering using or-expanded tiebreak (portable across PostgreSQL, MySQL, and SQLite).

Functions

allowed_filters()

@spec allowed_filters() :: [atom()]

Returns the canonical list of filter keys accepted by build/2.

Unknown keys raise ArgumentError (D-15 breaking change in v1.1).

build(audit_schema, filters \\ [])

@spec build(
  module(),
  keyword()
) :: Ecto.Query.t()

paginate(query, arg2, limit)

@spec paginate(Ecto.Query.t(), nil | {DateTime.t(), binary()}, pos_integer()) ::
  Ecto.Query.t()

Applies cursor + limit + desc ordering using or-expanded tiebreak (portable across PostgreSQL, MySQL, and SQLite).