# decree v0.1.0 - API Reference

## Modules

- [Mix.Decree.Store](Mix.Decree.Store.md): Conveniences for writing Decree.Store related Mix tasks.

- Store
  - [Decree.Store](Decree.Store.md): Decree.Store allows you to define one or more event store modules to append,
read, and subscribe to streams of events.
  - [Decree.Store.AppendCondition](Decree.Store.AppendCondition.md): The `:condition` of a conditional `c:Decree.Store.append_to_stream/4`.
  - [Decree.Store.AppendError](Decree.Store.AppendError.md): An append that the database did not accept, classified by what a caller can
do about it.
  - [Decree.Store.AppendResult](Decree.Store.AppendResult.md): What an append wrote, answered by `c:Decree.Store.append_to_stream/4` and
`c:Decree.Store.append_to_streams/2` when called with `returning: :append_result`.
  - [Decree.Store.Config](Decree.Store.Config.md): Provides access to the Decree.Store configuration.

  - [Decree.Store.EventData](Decree.Store.EventData.md): EventData contains the data for a single event before being persisted to storage
  - [Decree.Store.JsonSerializer](Decree.Store.JsonSerializer.md): A serializer that uses the JSON format.

  - [Decree.Store.Notifications.Connection](Decree.Store.Notifications.Connection.md): **Temporary.** This module stands in for `Postgrex.Notifications` because Postgrex
0.22.4, the newest release on Hex, drops a notification that arrives while its idle ping
runs. The fix, elixir-ecto/postgrex#795 (commit `bd402a5310`), is in no release yet.
Remove this module, and go back to `Postgrex.Notifications`, at the first Hex Postgrex
release that contains `bd402a5310` (expected to be 0.23). sparkle-space/sparklespace#8532
tracks that clean-up. Before removing it, check that the release's
`Postgrex.Notifications` also covers what 0.22.4's lacks besides the ping:
  * it answers a failed `LISTEN` `{:ok, ref}` and never listens on that channel;
  * a `LISTEN` it issues on a reconnect that loses its connection strands it: 0.22.4's
    `SimpleConnection` drops the reconnect after a query issued from `handle_connect/1`
    disconnects;
  * a query waits for its answer with no timeout.
  - [Decree.Store.Notifications.Listener](Decree.Store.Notifications.Listener.md): A GenStage producer which listens for event stream notifications from PostgreSQL using the
PostgreSQL `LISTEN/NOTIFY` mechanism and emits `Decree.Store.Notifications.Notification` events
for subscribed `Decree.Store.Notifications.Publisher` processes.
  - [Decree.Store.Notifications.Notification](Decree.Store.Notifications.Notification.md): Represents a notification received from PostgreSQL's `LISTEN/NOTIFY` mechanism.
  - [Decree.Store.Notifications.Publisher](Decree.Store.Notifications.Publisher.md): A GenStage consumer which subscribes to a `Decree.Store.Notifications.Listener` and receives
`Decree.Store.Notifications.Notification` events, reading the corresponding range of events from
storage, deserializing them, and broadcasting them to PubSub subscribers for the relevant storage
stream.

  - [Decree.Store.Notifications.Publisher.State](Decree.Store.Notifications.Publisher.State.md)
  - [Decree.Store.PubSub](Decree.Store.PubSub.md): Pub/sub using Elixir's local `Registry` module.

  - [Decree.Store.Query](Decree.Store.Query.md): What `c:Decree.Store.read_query/2` and `c:Decree.Store.stream_query/2` search for.
  - [Decree.Store.ReadResult](Decree.Store.ReadResult.md): What `c:Decree.Store.read_query/2` answers, all of it from one database snapshot.
  - [Decree.Store.RecordedEvent](Decree.Store.RecordedEvent.md): `Decree.Store.RecordedEvent` contains the persisted data and metadata for a
single event.
  - [Decree.Store.Serializer](Decree.Store.Serializer.md): Specification of a serializer to convert between an Elixir term and its
representation in the database.

  - [Decree.Store.Snapshots.SnapshotData](Decree.Store.Snapshots.SnapshotData.md): Snapshot data.
  - [Decree.Store.Streams.StreamInfo](Decree.Store.Streams.StreamInfo.md)
  - [Decree.Store.TagIndex](Decree.Store.TagIndex.md): The grammar of the facts that say whether a tag index can be trusted.
  - [Decree.Store.Tasks.Create](Decree.Store.Tasks.Create.md): Task to create the Decree.Store

  - [Decree.Store.Tasks.Drop](Decree.Store.Tasks.Drop.md): Task to drop the Decree.Store database.

  - [Decree.Store.Tasks.Init](Decree.Store.Tasks.Init.md): Task to initalize the Decree.Store database

  - [Decree.Store.Tasks.Migrate](Decree.Store.Tasks.Migrate.md): Task to migrate Decree.Store

  - [Decree.Store.Tasks.Migration](Decree.Store.Tasks.Migration.md)
  - [Decree.Store.Tasks.Migrations](Decree.Store.Tasks.Migrations.md): Task to show the migration status of Decree.Store

  - [Decree.Store.UnknownEventTypeError](Decree.Store.UnknownEventTypeError.md): Raised by a read (`read_*`, `stream_*`, `read_query`) that meets an event whose type the
event store's serializer does not know (see `c:Decree.Store.Serializer.known_type?/1`).
Typically an event appended by a newer release of the application, read by an older one.

- Framework
  - [Decree](Decree.md): Use Decree to build your own Elixir applications following the CQRS/ES pattern.
  - [Decree.Aggregate](Decree.Aggregate.md): What an aggregate module declares about itself, read where the aggregate is defined.
  - [Decree.Aggregate.Multi](Decree.Aggregate.Multi.md): Use `Decree.Aggregate.Multi` to generate multiple events from a single
command.
  - [Decree.Aggregates.Aggregate](Decree.Aggregates.Aggregate.md): Aggregate is a `GenServer` process used to provide access to an
instance of an event sourced aggregate.
  - [Decree.Aggregates.AggregateLifespan](Decree.Aggregates.AggregateLifespan.md): The `Decree.Aggregates.AggregateLifespan` behaviour is used to control the
aggregate `GenServer` process lifespan.
  - [Decree.Aggregates.AggregateStateBuilder](Decree.Aggregates.AggregateStateBuilder.md): Builds an aggregate's state by loading its snapshot and/or events from the
event store.
  - [Decree.Aggregates.DefaultLifespan](Decree.Aggregates.DefaultLifespan.md): The default implementation of the `Decree.Aggregates.AggregateLifespan`
behaviour.
  - [Decree.Aggregates.ExecutionContext](Decree.Aggregates.ExecutionContext.md): Defines the arguments used to execute a command for an aggregate.
  - [Decree.Aggregates.Supervisor](Decree.Aggregates.Supervisor.md): Supervises `Decree.Aggregates.Aggregate` instance processes.

  - [Decree.Application](Decree.Application.md): Defines a Decree application.
  - [Decree.Command](Decree.Command.md): A command whose `command_id` its requester mints.
  - [Decree.Commands.CompositeRouter](Decree.Commands.CompositeRouter.md): Composite router allows you to combine multiple router modules into a single
router able to dispatch any registered command from an included child router.
  - [Decree.Commands.ExecutionResult](Decree.Commands.ExecutionResult.md): Contains the aggregate, events, and metadata created by a successfully
executed command.
  - [Decree.Commands.Handler](Decree.Commands.Handler.md): Defines the behaviour a command handler module must implement to support command dispatch.
  - [Decree.Commands.Router](Decree.Commands.Router.md): Command routing macro to allow configuration of each command to its command handler.
  - [Decree.Decision](Decree.Decision.md): A rule decided over events, with no aggregate process and no stream of its own to replay.
  - [Decree.Decision.AppenderMap](Decree.Decision.AppenderMap.md): Finds the event types a decision's condition can miss.
  - [Decree.Decision.Assertions](Decree.Decision.Assertions.md): Test helpers for a `Decree.Decision`, for an application to import.
  - [Decree.Decision.Rule](Decree.Decision.Rule.md): What an aggregate's append has to check beyond its own stream.
  - [Decree.Decision.Rule.Result](Decree.Decision.Rule.Result.md): What a rule's reads answered, for one call of `execute/2`.
  - [Decree.Event.Append](Decree.Event.Append.md): The one function that runs just before the store append.

  - [Decree.Event.ErrorHandler](Decree.Event.ErrorHandler.md)
  - [Decree.Event.FailureContext](Decree.Event.FailureContext.md): Data related to an event handling failure.
  - [Decree.Event.Handler](Decree.Event.Handler.md): Defines the behaviour an event handler must implement and
provides a convenience macro that implements the behaviour, allowing you to
handle only the events you are interested in processing.
  - [Decree.Event.Mapper](Decree.Event.Mapper.md): Map events to/from the structs used for persistence.
  - [Decree.Event.PersonalFields](Decree.Event.PersonalFields.md): Which of an event's fields and metadata entries hold personal data, and whose.
  - [Decree.Event.RequiredTags](Decree.Event.RequiredTags.md): The tag kinds an event may not be appended without.
  - [Decree.Event.TagContext](Decree.Event.TagContext.md): What `Decree.Event.Tags.tags/2` may read besides the event.
  - [Decree.Event.TagCoverage](Decree.Event.TagCoverage.md): Finds the event modules with no `Decree.Event.Tags` implementation.
  - [Decree.Event.Tags](Decree.Event.Tags.md): The tags an event carries in the store, beyond the ones the framework adds.
  - [Decree.Event.Upcaster](Decree.Event.Upcaster.md): Protocol to allow an event to be transformed before being passed to a
consumer.
  - [Decree.EventStore](Decree.EventStore.md): Use the event store configured for a Decree application: the `Decree.Store` module named by
`event_store: [event_store: MyApp.EventStore]` in its config, called with the store process's
`name:`. The framework's `Decree.EventStore.EventData`, `RecordedEvent` and `SnapshotData` are
mapped to the store's structs and back here.
  - [Decree.EventStore.EventData](Decree.EventStore.EventData.md): EventData contains the data for a single event before being persisted to
storage.

  - [Decree.EventStore.RecordedEvent](Decree.EventStore.RecordedEvent.md): Contains the persisted stream identity, type, data, and metadata for a single event.
  - [Decree.EventStore.SnapshotData](Decree.EventStore.SnapshotData.md): Snapshot data
  - [Decree.EventStore.TypeProvider](Decree.EventStore.TypeProvider.md): Specification to convert between an Elixir struct and a corresponding string type.

  - [Decree.Middleware](Decree.Middleware.md): Middleware provides an extension point to add functions that you want to be
called for every command the router dispatches.
  - [Decree.Middleware.CommandId](Decree.Middleware.CommandId.md): An internal `Decree.Middleware` that refuses a command whose `command_id` is not a
lowercase canonical UUID.
  - [Decree.Middleware.ExtractAggregateIdentity](Decree.Middleware.ExtractAggregateIdentity.md): An internal `Decree.Middleware` that extracts the target aggregate's
identity from the command.
  - [Decree.Middleware.Pipeline](Decree.Middleware.Pipeline.md): Pipeline is a struct used as an argument in the callback functions of modules
implementing the `Decree.Middleware` behaviour.
  - [Decree.PersonalFields](Decree.PersonalFields.md): Personal fields: values encrypted under their subject's key before they reach the store.
  - [Decree.PersonalFields.Aggregate](Decree.PersonalFields.Aggregate.md): What an aggregate reads of its personal fields.
  - [Decree.PersonalFields.Declaration](Decree.PersonalFields.Declaration.md): What an event declares through `Decree.Event.PersonalFields`.
  - [Decree.PersonalFields.Envelope](Decree.PersonalFields.Envelope.md): The stored form of a personal value: a JSON object, never a string.
  - [Decree.PersonalFields.KeySource](Decree.PersonalFields.KeySource.md): Where the data keys of `Decree.PersonalFields` come from.
  - [Decree.PersonalFields.KeyStream](Decree.PersonalFields.KeyStream.md): A subject's wrapped data key, on a stream of its own that can be hard deleted.
  - [Decree.PersonalFields.KeyStream.Head](Decree.PersonalFields.KeyStream.Head.md): A key stream's last event, read: its wrap, and the version a rewrap appends at.
  - [Decree.PersonalFields.RedactedError](Decree.PersonalFields.RedactedError.md): Stands in for an exception raised while a decrypted value was in hand.
  - [Decree.PersonalFields.SubjectDataKeyMinted](Decree.PersonalFields.SubjectDataKeyMinted.md): A subject's data key, wrapped, as the first event of its stream.
  - [Decree.PersonalFields.SubjectDataKeyRewrapped](Decree.PersonalFields.SubjectDataKeyRewrapped.md): A subject's data key under a new wrap, with its `key_id` unchanged.
  - [Decree.Projections.Ecto](Decree.Projections.Ecto.md): Read model projections for Decree using Ecto.
  - [Decree.Registration](Decree.Registration.md): Use the process registry configured for a Decree application.

  - [Decree.Registration.Adapter](Decree.Registration.Adapter.md): Defines a behaviour for a process registry to be used by Decree.
  - [Decree.Registration.LocalRegistry](Decree.Registration.LocalRegistry.md): Local process registration, restricted to a single node, using Elixir's
`Registry` module.

  - [Decree.Serialization.JsonDecoder](Decree.Serialization.JsonDecoder.md)
  - [Decree.Serialization.JsonSerializer](Decree.Serialization.JsonSerializer.md): A serializer that uses the JSON format and Jason library.

  - [Decree.Serialization.ModuleNameTypeProvider](Decree.Serialization.ModuleNameTypeProvider.md): A type provider that uses the Elixir module name
  - [Decree.Serialization.Serializer](Decree.Serialization.Serializer.md): Specification of a generic serializer.

  - [Decree.UUID](Decree.UUID.md): Generate and format random, version 4 UUIDs.

  - [Decree.Verify.Eventless](Decree.Verify.Eventless.md): Finds the routed handler arms that can accept a command without an event.

## Mix Tasks

- [mix decree.store.create](Mix.Tasks.Decree.Store.Create.md): Create the database for the Decree.Store.
- [mix decree.store.drop](Mix.Tasks.Decree.Store.Drop.md): Drop the database for the Decree.Store.
- [mix decree.store.init](Mix.Tasks.Decree.Store.Init.md): Initialize the database for the Decree.Store.
- [mix decree.store.migrate](Mix.Tasks.Decree.Store.Migrate.md): Migrate an existing Decree.Store database.
- [mix decree.store.migrations](Mix.Tasks.Decree.Store.Migrations.md): Show the migration status of an existing Decree.Store database.
- [mix decree.verify.eventless](Mix.Tasks.Decree.Verify.Eventless.md): Fails on any routed handler arm that can accept a command without appending an event.

