Interface IEventSourcingOrchestratingAggregate<C, S, E, V, CM, EM>

Event sourcing orchestrating aggregate interface is using/delegating a decider of type IDecider<C, S, E> to handle commands and produce events. In order to handle the command, aggregate needs to fetch the current state (represented as a list of events) via IEventRepository.fetchEvents function, and then delegate the command to the decider which can produce new event(s) as a result.

If the decider is combined out of many deciders via combine function, an optional EventSourcingOrchestratingAggregate.saga could be used to react on new events and send new commands to the decider recursively, in one transaction.

Produced events are then stored via IEventRepository.save function.

Author

Иван Дугалић / Ivan Dugalic /

Idugalic

interface IEventSourcingOrchestratingAggregate<C, S, E, V, CM, EM> {
    decide: ((command, state) => readonly E[]);
    evolve: ((state, event) => S);
    fetch: ((command) => Promise<readonly (E & V & EM)[]>);
    handle: ((command) => Promise<readonly (E & V & EM)[]>);
    initialState: S;
    react: ((actionResult) => readonly C[]);
    save: ((events, commandMetadata, versionProvider) => Promise<readonly (E & V & EM)[]>);
    versionProvider: ((event) => Promise<null | V>);
}

Type Parameters

  • C

    Commands of type C that this aggregate can handle

  • S

    Aggregate state of type S

  • E

    Events of type E that this aggregate can publish

  • V

    Version

  • CM

    Command Metadata

  • EM

    Event Metadata

Hierarchy (view full)

Implemented by

Properties

decide: ((command, state) => readonly E[])

Type declaration

    • (command, state): readonly E[]
    • Parameters

      • command: C
      • state: S

      Returns readonly E[]

evolve: ((state, event) => S)

Type declaration

    • (state, event): S
    • Parameters

      • state: S
      • event: E

      Returns S

fetch: ((command) => Promise<readonly (E & V & EM)[]>)

Fetch events

Type declaration

    • (command): Promise<readonly (E & V & EM)[]>
    • Parameters

      • command: C & CM

        Command of type C with metadata of type CM

      Returns Promise<readonly (E & V & EM)[]>

Returns

list of Events with Version and Event Metadata

handle: ((command) => Promise<readonly (E & V & EM)[]>)

Handles the command of type C, and returns new persisted list of pairs of event and its version.

Type declaration

    • (command): Promise<readonly (E & V & EM)[]>
    • Parameters

      • command: C & CM

        Command of type C with Command Metadata

      Returns Promise<readonly (E & V & EM)[]>

Returns

list of persisted events with Version and Event Metadata

initialState: S
react: ((actionResult) => readonly C[])

Type declaration

    • (actionResult): readonly C[]
    • Parameters

      • actionResult: E

      Returns readonly C[]

save: ((events, commandMetadata, versionProvider) => Promise<readonly (E & V & EM)[]>)

Save events

Type declaration

    • (events, commandMetadata, versionProvider): Promise<readonly (E & V & EM)[]>
    • Parameters

      • events: readonly E[]

        list of Events

      • commandMetadata: CM

        Command Metadata of the command that initiated events

      • versionProvider: ((e) => Promise<null | V>)

        A provider for the Latest Event in this stream and its Version/Sequence

          • (e): Promise<null | V>
          • Parameters

            Returns Promise<null | V>

      Returns Promise<readonly (E & V & EM)[]>

Returns

a list of newly saved Event(s) of type E with Version of type V and with Event Metadata of type EM

versionProvider: ((event) => Promise<null | V>)

Get the latest event stream version / sequence

Type declaration

    • (event): Promise<null | V>
    • Parameters

      • event: E

        Event of type E

      Returns Promise<null | V>

Returns

the latest version / sequence of the event stream that this event belongs to.

Generated using TypeDoc