MishkaCmsCore.Activity.Sources.RuntimeDraft (Mishka CMS Core v0.0.1)

Copy Markdown View Source

Activity source for ALL runtime drafts — PageDraft, LayoutDraft, ErrorPageDraft — each tagged badge_label: "DRAFT" with a resource label of "Page Draft" / "Layout Draft" / "Error Page Draft" so a viewer can see it came from a draft.

None of these are AshPaperTrail-versioned, AshEvents logs, or Oban jobs, so no other source sees them. They DO broadcast through Ash.Notifier.PubSub (prefixes page_draft / layout_draft / error_page_draft) on created / updated / destroyed, which this adapter consumes for the live feed; for history it reads each draft table directly.

A discard is a live event only

These three resources do NOT archive — destroy :destroy is a plain destroy, so discarding a draft removes the row. A publish leaves one behind (status: :published); a discard does not. So discarded appears on the live feed, as it happens, and never in the history read: there is nothing left in the table to report. An earlier version soft-deleted and the history read archived_at to spot a discard; that column is gone, and MishkaCmsCore.Activity.Query no longer looks for it. On a database that predates the change, rows left behind by that soft delete are cleaned up by Mix.Tasks.MishkaCmsCore.PurgeDraftArchival.

Three user-facing events, derived from the action / row state: saved (create/update), published (publish), discarded (destroy/permanent_destroy — live feed only). Each draft contributes only to feeds whose scope covers its parent resource (the per-resource System Logs) or is unscoped (the /admin/dashboard/runtime/activity page). Config-driven via @drafts. See MishkaCmsCore.Activity.Behaviours.Source and MishkaCmsCore.Activity.Query (the DB-merge branch).

Summary

Functions

Build an entry from a unified MishkaCmsCore.Activity.Query SQL row (the DB-merge path). The label is derived from the row's resource module string, so one dispatch covers all three draft tables.

Functions

entry_from_row(row)

Build an entry from a unified MishkaCmsCore.Activity.Query SQL row (the DB-merge path). The label is derived from the row's resource module string, so one dispatch covers all three draft tables.