[fabric/domain] Rename event types to DomainEvent
This commit is contained in:
parent
55f6d788db
commit
e92de85fe8
@ -7,10 +7,10 @@ import type {
|
||||
VariantTag,
|
||||
} from "@fabric/core";
|
||||
import type { StoreQueryError } from "../errors/query-error.ts";
|
||||
import type { Event } from "./event.ts";
|
||||
import type { DomainEvent } from "./event.ts";
|
||||
import type { StoredEvent } from "./stored-event.ts";
|
||||
|
||||
export interface EventStore<TEvents extends Event> {
|
||||
export interface EventStore<TEvents extends DomainEvent> {
|
||||
/**
|
||||
* Store a new event in the event store.
|
||||
*/
|
||||
@ -28,7 +28,7 @@ export interface EventStore<TEvents extends Event> {
|
||||
): void;
|
||||
}
|
||||
|
||||
export type EventSubscriber<TEvents extends Event = Event> = (
|
||||
export type EventSubscriber<TEvents extends DomainEvent = DomainEvent> = (
|
||||
event: StoredEvent<TEvents>,
|
||||
) => MaybePromise<void>;
|
||||
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
// deno-lint-ignore-file no-explicit-any
|
||||
import type { VariantTag } from "@fabric/core";
|
||||
import type { TaggedVariant, VariantTag } from "@fabric/core";
|
||||
import type { UUID } from "../../core/types/uuid.ts";
|
||||
|
||||
/**
|
||||
* An event is a tagged variant with a payload and a timestamp.
|
||||
*/
|
||||
export interface Event<TTag extends string = string, TPayload = any> {
|
||||
readonly [VariantTag]: TTag;
|
||||
export interface DomainEvent<TTag extends string = string, TPayload = any>
|
||||
extends TaggedVariant<TTag> {
|
||||
readonly id: UUID;
|
||||
readonly streamId: UUID;
|
||||
readonly payload: TPayload;
|
||||
}
|
||||
|
||||
export type EventFromKey<
|
||||
TEvents extends Event,
|
||||
TEvents extends DomainEvent,
|
||||
TKey extends TEvents[VariantTag],
|
||||
> = Extract<TEvents, { [VariantTag]: TKey }>;
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import type { PosixDate } from "@fabric/core";
|
||||
import type { Event } from "./event.ts";
|
||||
import type { DomainEvent } from "./event.ts";
|
||||
|
||||
/**
|
||||
* A stored event is an inmutable event, already stored, with it's version in the stream and timestamp.
|
||||
*/
|
||||
export type StoredEvent<TEvent extends Event> = TEvent & {
|
||||
export type StoredEvent<TEvent extends DomainEvent> = TEvent & {
|
||||
readonly version: bigint;
|
||||
readonly timestamp: PosixDate;
|
||||
};
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import type { VariantTag } from "@fabric/core";
|
||||
import type { Event } from "../events/event.ts";
|
||||
import type { DomainEvent } from "../events/event.ts";
|
||||
import type { StoredEvent } from "../events/stored-event.ts";
|
||||
import type { AggregateModel, ModelToType } from "../models/model.ts";
|
||||
|
||||
export interface Projection<
|
||||
TModel extends AggregateModel,
|
||||
TEvents extends Event,
|
||||
TEvents extends DomainEvent,
|
||||
> {
|
||||
model: TModel;
|
||||
events: TEvents[VariantTag][];
|
||||
|
||||
@ -1,18 +1,24 @@
|
||||
// deno-lint-ignore-file no-explicit-any
|
||||
import type { TaggedError } from "@fabric/core";
|
||||
import type { DomainEvent } from "../events/event.ts";
|
||||
import type { UseCase } from "./use-case.ts";
|
||||
|
||||
export type Command<
|
||||
TDependencies = any,
|
||||
TPayload = any,
|
||||
TEvent extends Event = any,
|
||||
TEvent extends DomainEvent = any,
|
||||
TErrors extends TaggedError<string> = any,
|
||||
> = BasicCommandDefinition<TDependencies, TPayload, TEvent, TErrors>;
|
||||
> = BasicCommandDefinition<
|
||||
TDependencies,
|
||||
TPayload,
|
||||
TEvent,
|
||||
TErrors
|
||||
>;
|
||||
|
||||
interface BasicCommandDefinition<
|
||||
TDependencies,
|
||||
TPayload,
|
||||
TEvent extends Event,
|
||||
TEvent extends DomainEvent,
|
||||
TErrors extends TaggedError<string>,
|
||||
> {
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user