AshDispatch.Resource.Dsl.Counter (AshDispatch v0.5.0)

View Source

Data structure representing a counter definition from the DSL.

This is the target of the counter entity in the counters section.

Fields

  • :name - Unique counter identifier in DSL (atom, e.g., :pending_orders_counter)
  • :trigger_on - List of action names that trigger this counter
  • :counter_name - Counter name to broadcast (atom)
  • :resource - Ash resource module to query for counting (optional, defaults to current resource)
  • :query_filter - Ash.Query filter expression to count items
  • :audience - Audience atom (any atom configured in :ash_dispatch, :audiences)
  • :invalidates - Frontend query keys to invalidate (list of strings)
  • :user_id_path - Relationship path to user_id (e.g., [:cart, :user_id] for nested relationships)
  • :scope - Ash expression for scoping queries (e.g., expr(user_id == ^actor(:id)))
  • :filter_by_record - Filter counted resource by triggering record field (e.g., [field: :cart_id])
  • :group - Counter group for TypeScript generation (e.g., :orders, :tickets)
  • :authorize? - Whether to use Ash authorization (default: true)
  • :aggregate - Ash aggregate name to use instead of query_filter

Summary

Types

t()

@type t() :: %AshDispatch.Resource.Dsl.Counter{
  __spark_metadata__: term(),
  aggregate: atom() | nil,
  audience: atom(),
  authorize?: boolean(),
  counter_name: atom(),
  filter_by_record: keyword() | map() | nil,
  group: atom() | nil,
  invalidates: [String.t()],
  name: atom(),
  query_filter: any(),
  resource: module() | nil,
  scope: Ash.Expr.t() | nil,
  trigger_on: [atom()],
  user_id_path: [atom()] | nil
}