Introspection

v0.0.1

Gervaz compiles each resource's mishka_gervaz block into one persisted config map at compile time, and the runtime reads that map. The Info modules read it for you. Use them in a LiveView, a template, a test or an iex session instead of re-deriving what the DSL already says. This page lists the functions of each module.

Modules

ModuleReads
MishkaGervaz.Resource.Info.TableThe merged table config of a resource.
MishkaGervaz.Resource.Info.FormThe form config of a resource.
MishkaGervaz.Domain.Info.TableThe table defaults of a domain. Its config/1 returns the whole domain config, both sides.
MishkaGervaz.Domain.Info.FormThe form defaults of a domain. Its config/1 returns the whole domain config, both sides.
MishkaGervaz.Domain.InfoThe navigation of a domain, and delegates to the two above.
MishkaGervaz.ResourceInfoFlat delegates to the two resource modules.
MishkaGervaz.DomainInfoFlat delegates to the domain modules.

In MishkaGervaz.ResourceInfo and MishkaGervaz.DomainInfo, every function is the original name with a table_ or form_ prefix and the same arity. ResourceInfo.table_columns/1 calls Resource.Info.Table.columns/1, and DomainInfo.form_submit/1 calls Domain.Info.Form.submit/1. DomainInfo.navigation/1 and DomainInfo.menu_groups/1 have no prefix. get_hook, builtins and preload_aliases of the table module, and preload_aliases of the form module, have no delegate in ResourceInfo.

elixir
table_config = MishkaGervaz.Resource.Info.Table.config(MishkaBlog.Tag)
columns = MishkaGervaz.Resource.Info.Table.columns(MishkaBlog.Tag)
form_id = MishkaGervaz.Resource.Info.Form.component_id(MishkaBlog.Tag)
defaults = MishkaGervaz.Domain.Info.Table.defaults(MishkaBlog)

Resource.Info.Table

FunctionReturns
config/1The full compiled table config, merged with the domain defaults.
columns/1, column/2, column_order/1All columns, one column by name, and the column order.
filters/1, filter/2, filter_mode/1All filters, one filter by name, and the filter mode.
filter_groups/1, filter_group/2All filter groups and one by name.
row_actions/1, row_action/2, bulk_actions/1The row actions, one row action by name, and the bulk actions.
action_for/3The Ash action for :read, :get or :destroy, given master_user?.
archive_action_for/3, archive_enabled?/1The archive action for :read, :get, :restore or :destroy, and whether archive is on.
detected_preloads/1, all_preloads/2, preload_aliases/2Preloads detected from column sources, every preload for a role, and the alias map for a role.
pagination/1, pagination_enabled?/1, pagination_type/1The pagination config, whether it is on, and its type.
page_size/1, page_size_options/1, max_page_size/1, pagination_ui/1The page size values and the pagination UI labels.
layout/1, header/1, footer/1The chrome. Each returns nil when not declared.
notices/1, notice/2, notices_at/2All notices, one by name, and the notices at a position.
hooks/1, get_hook/2, builtins/1The hooks map, one hook by key, and the built-in transition flags.
refresh/1, url_sync/1The refresh and URL sync config.
features/1, feature_enabled?/2The enabled features and a check for one.
route/1, stream_name/1The identity values.
state/1, data_loader/1, events/1The override modules.

Resource.Info.Form

FunctionReturns
config/1The full compiled form config.
fields/1, field/2, field_order/1All fields, one field by name, and the field order.
groups/1, uploads/1, submit/1The groups, the uploads and the submit config.
layout/1, navigation/1, persistence/1The layout, and its navigation and persistence values.
steps/1, step/2, step_groups/2All steps, one by name, and the group maps of a step.
header/1, footer/1, notices/1, notice/2, notices_at/2The chrome.
action_for/3The Ash action for :create, :update or :read, given master_user?.
hooks/1, js_hook/2The hooks map, and one JS hook function by name.
detected_preloads/1, all_preloads/2, preload_aliases/2The preloads of the form.
component_id/1The identity name as a string, the id to mount the form component with. nil without a form identity.
route/1, stream_name/1The identity values.
state/1, data_loader/1, events/1The override modules.

Domain.Info

ModuleFunctions
Domain.Info.Tableconfig/1, defaults/1, ui_adapter/1, ui_adapter_opts/1, actor_key/1, master_check/1, pagination/1, page_size/1, page_size_options/1, max_page_size/1, realtime/1, theme/1, actions/1, refresh/1, url_sync/1
Domain.Info.Formconfig/1, defaults/1, ui_adapter/1, ui_adapter_opts/1, actor_key/1, master_check/1, actions/1, theme/1, layout/1, template/1, features/1, submit/1
Domain.Infonavigation/1 returns the navigation config, or nil when the domain declares none. menu_groups/1 returns the menu groups.

Helpers

MishkaGervaz.Helpers holds the small functions that templates and handlers share. The ones you are likely to call from a custom template or an override are:

FunctionDoes
humanize/1Turns an atom into a title-cased string, so :first_name becomes "First Name".
resolve_label/1Resolves a label that is a string or a zero-arity function, translating a string.
resolve_options/1Calls an options value that is a zero-arity function, and returns a list as it is.
normalize_options/1Turns every label and value of an options list into strings.
translate_options/1Translates the labels and the group labels of an options list.
accessible?/2Applies restricted and visible to an element for a state. restricted: true passes only for a master user. A function restricted is ignored, and visible is a boolean or a function of the state.
format_filesize/1Formats a byte count.
dynamic_component/1Renders the function named in the :function assign on the module in the :module assign. Templates use it to reach the UI adapter.
strip_tags/1Removes HTML tags from a string.

Errors

Failures are Splode errors under MishkaGervaz.Errors. MishkaGervaz.Errors.format_flash_message/2 turns any of them, and Ash errors, into a flash string. MishkaGervaz.Errors.extract_error_message/2 pulls the message out of an error for a resource.