AshVersioned.Resource.Info (ash_versioned v0.1.0)

Copy Markdown

Introspection helpers for the AshVersioned.Resource extension.

Summary

Functions

versioning DSL entities

Returns the list of all read actions that should be exempted from read filtering entirely (explicitly configured actions and the history action).

Returns true if this resource declares an archive entity.

The AshVersioned.Resource.Archive entity for this resource, or nil if none is declared.

Returns the list of read actions that should skip only archived record filtering but keep latest record filtering. Returns [] if the resource isn't archivable.

The name of the archived attribute. Raises if the resource isn't archivable — check versioning_archivable?/1 first.

The name of the timestamp attribute used when inserting a new version. This reflects when this version became active. The attribute must already be defined in attributes.

The name of the timestamp attribute used when inserting a new version. This reflects when this version became active. The attribute must already be defined in attributes.

Filters AshVersioned.Resource entries on the provided entity module or list of entity modules.

Finds the first AshVersioned.Resource entry for the provided entity module or returns nil if not found.

Read actions that should skip the default latest (and archived) scoping applied to every other read action. This could include hand-declared audit or admin-facing actions that need to see stale and archived versions.

Read actions that should skip the default latest (and archived) scoping applied to every other read action. This could include hand-declared audit or admin-facing actions that need to see stale and archived versions.

Update actions intentionally left as ordinary in-place updates instead of appending a new version. Every other update action on the resource is wired to append automatically.

Update actions intentionally left as ordinary in-place updates instead of appending a new version. Every other update action on the resource is wired to append automatically.

The name of the generated read action that returns every version, ignoring the default latest/archived scoping.

The name of the generated read action that returns every version, ignoring the default latest/archived scoping.

The name of the identity attribute.

The name of the latest attribute.

versioning DSL options

If specified, this prefix is applied to the underlying source of the generated AshVersioned fields. Fields adopting defined fields (define_attribute? false) or that declare source ignore this setting.

If specified, this prefix is applied to the underlying source of the generated AshVersioned fields. Fields adopting defined fields (define_attribute? false) or that declare source ignore this setting.

The name of the timestamp attribute updated when a version is marked stale. This reflects when this version became inactive. The attribute must already be defined in attributes.

The name of the timestamp attribute updated when a version is marked stale. This reflects when this version became inactive. The attribute must already be defined in attributes.

The name of the version attribute.

Functions

versioning(dsl_or_extended)

@spec versioning(dsl_or_extended :: module() | map()) :: [struct()]

versioning DSL entities

versioning_all_excluded_read_actions!(dsl_or_resource)

Returns the list of all read actions that should be exempted from read filtering entirely (explicitly configured actions and the history action).

versioning_archivable?(dsl_or_resource)

Returns true if this resource declares an archive entity.

versioning_archive(dsl_or_resource)

The AshVersioned.Resource.Archive entity for this resource, or nil if none is declared.

versioning_archive_excluded_read_actions!(dsl_or_resource)

Returns the list of read actions that should skip only archived record filtering but keep latest record filtering. Returns [] if the resource isn't archivable.

versioning_archived_attribute!(dsl_or_resource)

The name of the archived attribute. Raises if the resource isn't archivable — check versioning_archivable?/1 first.

versioning_create_timestamp_attribute(dsl_or_extended)

@spec versioning_create_timestamp_attribute(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error

The name of the timestamp attribute used when inserting a new version. This reflects when this version became active. The attribute must already be defined in attributes.

versioning_create_timestamp_attribute!(dsl_or_extended)

@spec versioning_create_timestamp_attribute!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()

The name of the timestamp attribute used when inserting a new version. This reflects when this version became active. The attribute must already be defined in attributes.

versioning_entities(dsl_or_resource, modules)

Filters AshVersioned.Resource entries on the provided entity module or list of entity modules.

versioning_entity(dsl_or_resource, module)

Finds the first AshVersioned.Resource entry for the provided entity module or returns nil if not found.

versioning_exclude_read_actions(dsl_or_extended)

@spec versioning_exclude_read_actions(dsl_or_extended :: module() | map()) ::
  {:ok, [atom()]} | :error

Read actions that should skip the default latest (and archived) scoping applied to every other read action. This could include hand-declared audit or admin-facing actions that need to see stale and archived versions.

versioning_exclude_read_actions!(dsl_or_extended)

@spec versioning_exclude_read_actions!(dsl_or_extended :: module() | map()) ::
  [atom()] | no_return()

Read actions that should skip the default latest (and archived) scoping applied to every other read action. This could include hand-declared audit or admin-facing actions that need to see stale and archived versions.

versioning_exclude_update_actions(dsl_or_extended)

@spec versioning_exclude_update_actions(dsl_or_extended :: module() | map()) ::
  {:ok, [atom()]} | :error

Update actions intentionally left as ordinary in-place updates instead of appending a new version. Every other update action on the resource is wired to append automatically.

WARNING: This should only be used in exceptional circumstances, because it breaks the core promise of SCD (type 2) versioning: inactive versions don't change.

versioning_exclude_update_actions!(dsl_or_extended)

@spec versioning_exclude_update_actions!(dsl_or_extended :: module() | map()) ::
  [atom()] | no_return()

Update actions intentionally left as ordinary in-place updates instead of appending a new version. Every other update action on the resource is wired to append automatically.

WARNING: This should only be used in exceptional circumstances, because it breaks the core promise of SCD (type 2) versioning: inactive versions don't change.

versioning_history_action(dsl_or_extended)

@spec versioning_history_action(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error

The name of the generated read action that returns every version, ignoring the default latest/archived scoping.

versioning_history_action!(dsl_or_extended)

@spec versioning_history_action!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()

The name of the generated read action that returns every version, ignoring the default latest/archived scoping.

versioning_identity(dsl_or_resource)

The AshVersioned.Resource.Identity entity for this resource.

versioning_identity_attribute(dsl_or_resource)

The name of the identity attribute.

versioning_latest(dsl_or_resource)

The AshVersioned.Resource.Latest entity for this resource.

versioning_latest_attribute(dsl_or_resource)

The name of the latest attribute.

versioning_options(dsl_or_extended)

@spec versioning_options(dsl_or_extended :: module() | map()) :: %{
  required(atom()) => any()
}

versioning DSL options

Returns a map containing the and any configured or default values.

versioning_source_prefix(dsl_or_extended)

@spec versioning_source_prefix(dsl_or_extended :: module() | map()) ::
  {:ok, String.t()} | :error

If specified, this prefix is applied to the underlying source of the generated AshVersioned fields. Fields adopting defined fields (define_attribute? false) or that declare source ignore this setting.

versioning do
  archive()
  source_prefix "vo_"
end

This is equivalent to:

versioning do
  archive :archived, source: :vo_archived
  identity :resource_id, source: :vo_resource_id
  latest :latest_version, source: :vo_latest_version
  version :version_number, source: :vo_version_number
end

The prefix is applied in front of any name given, so identity :mo_id would become identity :mo_id, source: :vo_mo_id.

versioning_source_prefix!(dsl_or_extended)

@spec versioning_source_prefix!(dsl_or_extended :: module() | map()) ::
  String.t() | no_return()

If specified, this prefix is applied to the underlying source of the generated AshVersioned fields. Fields adopting defined fields (define_attribute? false) or that declare source ignore this setting.

versioning do
  archive()
  source_prefix "vo_"
end

This is equivalent to:

versioning do
  archive :archived, source: :vo_archived
  identity :resource_id, source: :vo_resource_id
  latest :latest_version, source: :vo_latest_version
  version :version_number, source: :vo_version_number
end

The prefix is applied in front of any name given, so identity :mo_id would become identity :mo_id, source: :vo_mo_id.

versioning_update_timestamp_attribute(dsl_or_extended)

@spec versioning_update_timestamp_attribute(dsl_or_extended :: module() | map()) ::
  {:ok, atom()} | :error

The name of the timestamp attribute updated when a version is marked stale. This reflects when this version became inactive. The attribute must already be defined in attributes.

versioning_update_timestamp_attribute!(dsl_or_extended)

@spec versioning_update_timestamp_attribute!(dsl_or_extended :: module() | map()) ::
  atom() | no_return()

The name of the timestamp attribute updated when a version is marked stale. This reflects when this version became inactive. The attribute must already be defined in attributes.

versioning_version(dsl_or_resource)

The AshVersioned.Resource.Version entity for this resource.

versioning_version_attribute(dsl_or_resource)

The name of the version attribute.