AuditLog.Query (AuditLog v0.3.0)

Copy Markdown View Source

Builds composable Ecto queries for audit timelines.

Every helper returns an %Ecto.Query{} and uses occurred_at, id for a deterministic display order. UUID order is only a tie-breaker; it does not imply causality.

All helpers accept:

  • :order - :desc by default, or :asc
  • :prefix - optional PostgreSQL schema prefix matching [a-z_][a-z0-9_]*

Invalid values and option containers raise AuditLog.InvalidValueError before Ecto builds the query.

Summary

Functions

Returns the complete event timeline.

Filters events to the half-open [from, to) time window.

Filters the timeline to one actor.

Filters the timeline to one correlation UUID.

Filters the timeline to one subject.

Functions

all(opts \\ [])

@spec all(keyword()) :: Ecto.Query.t()

Returns the complete event timeline.

between(from, to, opts \\ [])

@spec between(DateTime.t(), DateTime.t(), keyword()) :: Ecto.Query.t()

Filters events to the half-open [from, to) time window.

Both boundaries must be DateTime values and from must be earlier than to.

for_actor(type, id, opts \\ [])

@spec for_actor(String.Chars.t(), String.Chars.t(), keyword()) :: Ecto.Query.t()

Filters the timeline to one actor.

The public representation is an explicit application-owned actor type and identifier. The filter includes and normalizes both values. Invalid values raise AuditLog.InvalidValueError.

for_correlation(correlation_id, opts \\ [])

@spec for_correlation(
  Ecto.UUID.t(),
  keyword()
) :: Ecto.Query.t()

Filters the timeline to one correlation UUID.

for_subject(type, id, opts \\ [])

@spec for_subject(String.Chars.t(), String.Chars.t(), keyword()) :: Ecto.Query.t()

Filters the timeline to one subject.

The public representation is an explicit application-owned subject type and identifier. The filter includes and normalizes both values. Invalid values raise AuditLog.InvalidValueError.