Skip to content

v2.0.1

Compare
Choose a tag to compare
@idugalic idugalic released this 11 Apr 16:59
· 173 commits to main since this release
e6a439b

Fmodel provides just enough tactical Domain-Driven Design patterns, optimized for Event Sourcing and CQRS.

The domain components are fully isolated from the application layer and API-related concerns.
It represents a pure declaration (pure functions) of the program logic.
Decider, View, and Saga

The application components orchestrate the execution of the logic by loading the state, executing domain components, and storing a new state.
EventSourcingAggregate, StateStoredAggregate, MaterializedView, and SagaManager

Install

npm i @fraktalio/fmodel-ts

Available on https://www.npmjs.com/package/@fraktalio/fmodel-ts

Learn more

What's Changed

The most important change is that versionProvider (part of the application EventSourcingAggregate API) uses both Event/E and EventMetadata/EM to provide the version of the stream / previously it was only E/Event:

export interface IEventRepository<C, E, V, CM, EM> {
  /**
   * Fetch events
   *
   * @param command - Command of type `C` with metadata of type `CM`
   *
   * @return list of Events with Version and Event Metadata
   */
  readonly fetch: (command: C & CM) => Promise<readonly (E & V & EM)[]>;

  /**
   * Get the latest event stream version / sequence
   *
   * @param event - Event of type `E & EM`
   *
   * @return the latest version / sequence of the event stream that this event belongs to.
   */
  readonly versionProvider: (event: E & EM) => Promise<V | null>;

  /**
   * Save events
   *
   * @param events - list of Events
   * @param commandMetadata - Command Metadata of the command that initiated `events`
   * @param versionProvider - A provider for the stream Version/Sequence
   * @return  a list of newly saved Event(s) of type `E` with Version of type `V` and with Event Metadata of type `EM`
   */
  readonly save: (
    events: readonly E[],
    commandMetadata: CM,
    versionProvider: (e: E & EM) => Promise<V | null>
  ) => Promise<readonly (E & V & EM)[]>;
}

We hope that E/Event can be liberated from the technical data/properties that do not influence core domain logic/computation. In this case, the EM properties can be used to find the version of the stream and these properties don't have to leak into the E/Event.

  • build(deps-dev): bump @types/node from 20.11.27 to 20.11.28 by @dependabot in #702
  • build(deps-dev): bump @types/node from 20.11.28 to 20.11.29 by @dependabot in #703
  • build(deps-dev): bump @types/node from 20.11.29 to 20.11.30 by @dependabot in #704
  • build(deps-dev): bump typescript from 5.4.2 to 5.4.3 by @dependabot in #705
  • build(deps-dev): bump eslint-plugin-functional from 6.1.1 to 6.3.0 by @dependabot in #707
  • build(deps-dev): bump cspell from 8.6.0 to 8.6.1 by @dependabot in #708
  • build(deps-dev): bump @types/node from 20.11.30 to 20.12.2 by @dependabot in #709
  • build(deps-dev): bump eslint-plugin-functional from 6.3.0 to 6.4.0 by @dependabot in #710
  • build(deps-dev): bump @types/node from 20.12.2 to 20.12.3 by @dependabot in #711
  • build(deps-dev): bump @types/node from 20.12.3 to 20.12.4 by @dependabot in #712
  • build(deps-dev): bump typescript from 5.4.3 to 5.4.4 by @dependabot in #713
  • build(deps-dev): bump @types/node from 20.12.4 to 20.12.5 by @dependabot in #714
  • build(deps-dev): bump typedoc from 0.25.12 to 0.25.13 by @dependabot in #715
  • build(deps-dev): bump @types/node from 20.12.5 to 20.12.7 by @dependabot in #716
  • build(deps-dev): bump cspell from 8.6.1 to 8.7.0 by @dependabot in #717
  • build(deps-dev): bump typescript from 5.4.4 to 5.4.5 by @dependabot in #718
  • Include event metadata as param in the version provider by @idugalic in #719

Full Changelog: v2.0.0...v2.0.1