AshScim.Dsl.Multivalued (ash_scim v0.1.0)

Copy Markdown View Source

Represents a SCIM multi-valued attribute, declared via the multivalued/2 block in the scim section.

A multivalued attribute emits an array of complex objects under a single SCIM key, e.g. SCIM's emails array where each element has value, primary, and type sub-attributes. There are two modes:

Mode A — relationship-backed

Each entry is a row in a has_many relationship. SCIM round-trips arbitrary value/primary/type per entry. Sub-maps reference attributes on the related resource.

multivalued :emails do
  relationship :emails
  mirror_primary_to :email   # optional — also sync to parent column
  map :value,   attribute: :value
  map :primary, attribute: :primary
  map :type,    attribute: :type
end

Mode B — mirror-only (no relationship)

The parent has a single scalar (e.g. :email) and the SCIM emails array is collapsed: writes pick the primary entry's value into the scalar; reads emit one element with value: from the scalar plus any static decorators. Simpler to set up; doesn't preserve primary/type per entry.

multivalued :emails do
  mirror_primary_to :email
  map :primary, value: true
  map :type,    value: "work"
end

At least one of relationship: or mirror_primary_to: must be set.

Summary

Types

t()

@type t() :: %AshScim.Dsl.Multivalued{
  __spark_metadata__: term(),
  maps: [AshScim.Dsl.Map.t()],
  mirror_primary_to: atom() | nil,
  mutability: :read_only | :read_write | :immutable | :write_only | nil,
  name: atom(),
  relationship: atom() | nil,
  returned: :always | :never | :default | :request | nil
}