MishkaCmsCore.Activity.Discovery (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Runtime discovery of the resources that feed the activity log, scanning every configured Ash domain (config :mishka_cms, ash_domains) — so the log adapts to whatever extensions are installed, and to future ones, with no hardcoded resource or extension names.

  • paper_trailed/0 — resources carrying AshPaperTrail.Resource whose version resource exposes the project's :sorted_versions read action.
  • event_logs/0 — resources carrying AshEvents.EventLog (central event logs such as MishkaDocument.EventLog).
  • areas/1 — the permission areas a resource's own policies ask for, which decide whose Activity log shows its entries.

Results are memoised in :persistent_term (read O(1), hot on the live handles?/1 path). Call invalidate/0 when the installed extension set changes (the same lifecycle that mutates ash_domains); a fresh scan recomputes the set.

See MishkaCmsCore.Activity.Sources.PaperTrail and MishkaCmsCore.Activity.Sources.EventLog.

Summary

Functions

The dashboard names resource's own policies ask for — every admin:dashboard:<area> name a MishkaCmsCore.Accounts.Checks.AccessPermissions check among them lists, such as ["admin:dashboard:runtime:media"] — and [] for a resource that names none.

Central AshEvents.EventLog resources across all domains.

Drop the cached discovery sets so the next call rescans the domains.

Paper-trailed resources across all domains (with a :sorted_versions guard).

Every resource of every Ash domain the host application lists.

Functions

areas(resource)

@spec areas(module()) :: [String.t()]

The dashboard names resource's own policies ask for — every admin:dashboard:<area> name a MishkaCmsCore.Accounts.Checks.AccessPermissions check among them lists, such as ["admin:dashboard:runtime:media"] — and [] for a resource that names none.

event_logs()

Central AshEvents.EventLog resources across all domains.

invalidate()

Drop the cached discovery sets so the next call rescans the domains.

paper_trailed()

Paper-trailed resources across all domains (with a :sorted_versions guard).

resources()

@spec resources() :: [Ash.Resource.t()]

Every resource of every Ash domain the host application lists.