# `Decree.EventStore.RecordedEvent`
[🔗](https://github.com/sparkle-space/decree/blob/v0.1.0/lib/decree/event_store/recorded_event.ex#L1)

Contains the persisted stream identity, type, data, and metadata for a single event.

Events are immutable once recorded.

## Recorded event fields

  - `event_id` - a globally unique UUID to identify the event.

  - `event_number` - a globally unique, monotonically incrementing and gapless
    integer used to order the event amongst all events.

  - `stream_id` - the stream identity for the event.

  - `stream_version` - the version of the stream for the event.

  - `causation_id` - an optional UUID identifier used to identify which
    message you are responding to.

  - `correlation_id` - an optional UUID identifier used to correlate related
    messages.

  - `data` - the event data deserialized into a struct.

  - `metadata` - a string keyed map of metadata associated with the event.

  - `created_at` - the datetime, in UTC, indicating when the event was
    created.

# `causation_id`

```elixir
@type causation_id() :: uuid() | nil
```

# `correlation_id`

```elixir
@type correlation_id() :: uuid() | nil
```

# `created_at`

```elixir
@type created_at() :: DateTime.t()
```

# `data`

```elixir
@type data() :: domain_event()
```

# `domain_event`

```elixir
@type domain_event() :: struct()
```

# `enriched_metadata`

```elixir
@type enriched_metadata() :: %{
  :event_id =&gt; event_id(),
  :event_number =&gt; event_number(),
  :stream_id =&gt; stream_id(),
  :stream_version =&gt; stream_version(),
  :correlation_id =&gt; correlation_id(),
  :causation_id =&gt; causation_id(),
  :created_at =&gt; created_at(),
  optional(atom()) =&gt; term(),
  optional(String.t()) =&gt; term()
}
```

# `event_id`

```elixir
@type event_id() :: uuid()
```

# `event_number`

```elixir
@type event_number() :: non_neg_integer()
```

# `event_type`

```elixir
@type event_type() :: String.t()
```

# `metadata`

```elixir
@type metadata() :: map()
```

# `stream_id`

```elixir
@type stream_id() :: String.t()
```

# `stream_version`

```elixir
@type stream_version() :: non_neg_integer()
```

# `t`

```elixir
@type t() :: %Decree.EventStore.RecordedEvent{
  causation_id: causation_id(),
  correlation_id: correlation_id(),
  created_at: created_at(),
  data: data(),
  event_id: event_id(),
  event_number: event_number(),
  event_type: event_type(),
  metadata: metadata(),
  stream_id: stream_id(),
  stream_version: stream_version()
}
```

# `uuid`

```elixir
@type uuid() :: String.t()
```

# `enrich_metadata`

```elixir
@spec enrich_metadata(t(), [{:additional_metadata, map()}]) :: enriched_metadata()
```

Enrich the event's metadata with fields from the `RecordedEvent` struct and
any additional metadata passed as an option.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
