Accrue.Entitlements.Snapshot (accrue v1.5.1)

Copy Markdown View Source

A deterministic, privacy-bounded view of an account's effective grants.

The snapshot is derived from current grant rows; it is never persisted and never contains provider evidence or lineage identifiers.

Summary

Functions

The material authorization fields used for monotonic revision decisions.

Fetches and folds an account's current grants without mutating state.

Types

source()

@type source() :: %{
  :rail => atom(),
  :environment => atom(),
  :logical_plan => atom(),
  :effective_at => DateTime.t(),
  optional(:expires_at) => DateTime.t() | nil,
  optional(:revoked_at) => DateTime.t() | nil
}

t()

@type t() :: %Accrue.Entitlements.Snapshot{
  account_id: Ecto.UUID.t() | String.t(),
  authorization_bounds: term(),
  features: [atom()],
  plans: [atom()],
  quantities: %{optional(atom()) => pos_integer()},
  revision: non_neg_integer(),
  sources: [source()]
}

Functions

authorization_signature(snapshot)

@spec authorization_signature(t()) :: term()

The material authorization fields used for monotonic revision decisions.

fetch(repo, account, opts \\ [])

@spec fetch(Ecto.Repo.t(), map() | Ecto.UUID.t(), keyword()) :: t() | nil

Fetches and folds an account's current grants without mutating state.

from_grants(grants, opts)

@spec from_grants(
  [Accrue.Entitlements.Grant.t() | map()],
  keyword()
) :: t()