MishkaGervaz.Table.ArchiveMerger (MishkaGervaz v0.0.1-alpha.2)

Copy Markdown View Source

Resolves the final table archive configuration by merging the resource-level archive map (built from the DSL) with the domain-level archive defaults.

Priority rules

  • Resource has no AshArchival.Resource extension → archive is nil, regardless of what the domain provides. Archive cannot be applied to a resource that does not have AshArchival in its extensions.
  • Resource has AshArchival.Resource and an explicit archive block:
    • enabled: false on the resource block disables archive entirely (used during testing — overrides the domain).
    • Otherwise the resource block wins per key; missing keys fall back to the domain; missing in both → built-in default for that key.
  • Resource has AshArchival.Resource but no archive block:
    • If the domain defines archive defaults, use them (inherit fully).
    • If neither side defines anything, fall back to the built-in defaults (the canonical {:master_*, :*} action set). This preserves existing behaviour for resources that just opt in via AshArchival.

Action value semantics

  • Atom value (e.g. :archived) — used for both master and tenant requests.
  • Tuple value {master, tenant}master for users without site_id, tenant for users scoped to a site_id. Enforcement lives inside the Ash actions themselves; this module only routes which atom to call.

See MishkaGervaz.Table.Transformers.BuildRuntimeConfig (the caller), MishkaGervaz.Table.Dsl.Defaults (where domain-level archive is set), and MishkaGervaz.Resource.Info.Table (downstream reader).

Summary

Functions

Returns the final archive map, or nil when archive does not apply.

Functions

merge(resource_archive, domain_archive, multitenancy, bool)

@spec merge(map() | nil, map() | nil, map(), boolean()) :: map() | nil

Returns the final archive map, or nil when archive does not apply.

  • resource_archive is the raw per-resource archive map (or nil if no archive do block is present).
  • domain_archive is the domain-level archive defaults map (or nil).
  • multitenancy is the resource multitenancy info; used to collapse master/tenant tuples to a single atom for non-multitenant resources.
  • has_archival? is whether the resource has AshArchival.Resource in its extensions.