Aggregate

Type parameters

T: SuperConstructor

T: SuperConstructor

Hierarchy

EventSourceable

  • EventSourceable

    Aggregate

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new Aggregate(arg: History | Command‹object› | Props): Aggregate

Overrides EventSourceable.constructor

Creates an instance of Aggregate. Flows:

  1. Replay History - Aggregate is recreated from History instance - list of Events(manual initialization and replay is required before running Aggregate.prototype.replayHistory!).
  2. Command - Command instance is passed as initializing message and Aggregate has assigned id from it.
  3. Properties - Aggregate is deserialized, so props as object are passed. Creates an instance of Aggregate. Flows:
  4. Replay History - Aggregate is recreated from History instance - list of Events(manual initialization and replay is required before running Aggregate.prototype.replayHistory!).
  5. Command - Command instance is passed as initializing message and Aggregate has assigned id from it.
  6. Properties - Aggregate is deserialized, so props as object are passed.

example

new Aggregate(
new History([
new Event({targetId: 'my-id', key: 'value'})
])
); // 1
new Aggregate(new Command({targetId: 'my-id', key: 'value'})); // 2
new Aggregate({id: 'my-id'}); // 3
new Aggregate({id: 'my-id', key: 'value'}); // 3

throws {InvalidInitializingMessageError} Thrown if provided initializing message is not instance of Command.

example

new Aggregate(
new History([
new Event({targetId: 'my-id', key: 'value'})
])
); // 1
new Aggregate(new Command({targetId: 'my-id', key: 'value'})); // 2
new Aggregate({id: 'my-id'}); // 3
new Aggregate({id: 'my-id', key: 'value'}); // 3

throws {InvalidInitializingMessageError} Thrown if provided initializing message is not instance of Command.

Parameters:

NameTypeDescription
argHistory | Command‹object› | PropsInstance of: History, Command or properties.

Returns: Aggregate

Properties

[COMMANDS_KEY]

[COMMANDS_KEY]: Command[]

Overrides EventSourceable.[COMMANDS_KEY]


[EVENTS_KEY]

[EVENTS_KEY]: Event[]

Overrides EventSourceable.[EVENTS_KEY]


id

id: string | Guid

Overrides EventSourceable.id


Optional metadata

metadata? : Record‹string, any›

Overrides EventSourceable.metadata


Optional schemaVersion

schemaVersion? : number

Overrides EventSourceable.schemaVersion


state

state: State

Implementation of EventSourceable.state

Overrides EventSourceable.state


status

status: Status

Implementation of EventSourceable.status

Overrides EventSourceable.status


version

version: number

Overrides EventSourceable.version

Accessors

ableTo

get ableTo(): this

Inherited from Entity.ableTo

Overrides Task.ableTo

Returns: this


can

get can(): any

Inherited from Entity.can

Overrides Task.can

Returns: any


ensure

get ensure(): this & object

Inherited from Entity.ensure

Overrides Task.ensure

Returns: this & object


is

get is(): this & object

Inherited from Entity.is

Overrides Task.is

Returns: this & object

Methods

[ROLLBACK_STATE_METHOD_KEY]

[ROLLBACK_STATE_METHOD_KEY](): void

Implementation of EventSourceable

Inherited from Entity.[ROLLBACK_STATE_METHOD_KEY]

Overrides Task.[ROLLBACK_STATE_METHOD_KEY]

Returns: void


[SAVE_STATE_METHOD_KEY]

[SAVE_STATE_METHOD_KEY](): void

Implementation of EventSourceable

Inherited from Entity.[SAVE_STATE_METHOD_KEY]

Overrides Task.[SAVE_STATE_METHOD_KEY]

Returns: void


assignMetadata

assignMetadata(metadata: Record‹string, any›): void

Implementation of EventSourceable

Inherited from EventSourceable.assignMetadata

Overrides CancelingEmployment.assignMetadata

Parameters:

NameType
metadataRecord‹string, any›

Returns: void


commandProps

commandProps(): object

Inherited from EventSourceable.commandProps

Overrides CancelingEmployment.commandProps

Returns: object

  • metadata: Record‹string, any›

  • timestamp: Date


ensureHandleability

ensureHandleability(messageType: MessageTypeMessage›, handleableTypes?: MessageTypeMessage› | MessageTypeMessage›[]): boolean

Implementation of EventSourceable

Inherited from HandlingMixin.ensureHandleability

Overrides CancelingEmployment.ensureHandleability

Parameters:

NameType
messageTypeMessageTypeMessage
handleableTypes?MessageTypeMessage› | MessageTypeMessage›[]

Returns: boolean


equals

equals(otherEntity: Entity): boolean

Inherited from Entity.equals

Overrides DefinableMixin.equals

Parameters:

NameType
otherEntityEntity

Returns: boolean


eventProps

eventProps(): object

Implementation of EventSourceable

Inherited from EventSourceable.eventProps

Overrides CancelingEmployment.eventProps

Returns: object

  • metadata: Record‹string, any›

  • sourceId: Guid | string

  • timestamp: Date

  • version: number


getActions

getActions(): Actions

Implementation of Hookable

Inherited from HookableMixin.getActions

Overrides CreateEmployee.getActions

Returns: Actions


getCommands

getCommands(): Command[]

Implementation of EventSourceable

Inherited from EventSourceable.getCommands

Overrides CancelingEmployment.getCommands

Returns: Command[]


getEvents

getEvents(): Event[]

Implementation of EventSourceable

Inherited from EventSourceable.getEvents

Overrides CancelingEmployment.getEvents

Returns: Event[]


getHandleableTypes

getHandleableTypes(): MessageTypeMessage›[]

Implementation of EventSourceable

Inherited from HandlingMixin.getHandleableTypes

Overrides CancelingEmployment.getHandleableTypes

Returns: MessageTypeMessage›[]


getHandled

getHandled(messageType: MessageTypeMessage›): MessageTypeMessage›[]

Implementation of EventSourceable

Inherited from HandlingMixin.getHandled

Overrides CancelingEmployment.getHandled

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: MessageTypeMessage›[]


getHandledCommands

getHandledCommands(): MessageTypeCommand›[]

Inherited from HandlingMixin.getHandledCommands

Overrides CancelingEmployment.getHandledCommands

Returns: MessageTypeCommand›[]


getHandledEvents

getHandledEvents(): MessageTypeEvent›[]

Inherited from HandlingMixin.getHandledEvents

Overrides CancelingEmployment.getHandledEvents

Returns: MessageTypeEvent›[]


getHandledMessages

getHandledMessages(): MessageTypeMessage›[]

Inherited from HandlingMixin.getHandledMessages

Overrides CancelingEmployment.getHandledMessages

Returns: MessageTypeMessage›[]


getHandledTypes

getHandledTypes(): MessageTypeMessage›[]

Implementation of EventSourceable

Inherited from HandlingMixin.getHandledTypes

Overrides CancelingEmployment.getHandledTypes

Returns: MessageTypeMessage›[]


getHandledTypesNames

getHandledTypesNames(): TypeName[]

Inherited from HandlingMixin.getHandledTypesNames

Overrides CancelingEmployment.getHandledTypesNames

Returns: TypeName[]


getHandler

getHandler(messageType: MessageTypeMessage›): Handler | undefined

Implementation of EventSourceable

Inherited from OneToOneHandlingMixin.getHandler

Overrides CancelingEmployment.getHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: Handler | undefined


getHandlerOrThrow

getHandlerOrThrow(messageType: MessageTypeMessage›): Handler

Implementation of EventSourceable

Inherited from OneToOneHandlingMixin.getHandlerOrThrow

Overrides CancelingEmployment.getHandlerOrThrow

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: Handler


getHandlers

getHandlers(): Map‹MessageTypeMessage›, Handler | Handler[]›

Implementation of EventSourceable

Inherited from HandlingMixin.getHandlers

Overrides CancelingEmployment.getHandlers

Returns: Map‹MessageTypeMessage›, Handler | Handler[]›


getHook

getHook(action: string, id: string): Hook | undefined

Implementation of Hookable

Inherited from HookableMixin.getHook

Overrides CreateEmployee.getHook

Parameters:

NameType
actionstring
idstring

Returns: Hook | undefined


getHookOrThrow

getHookOrThrow(action: string, id: string): Hook

Implementation of Hookable

Inherited from HookableMixin.getHookOrThrow

Overrides CreateEmployee.getHookOrThrow

Parameters:

NameType
actionstring
idstring

Returns: Hook


getHooks

getHooks(action: string): Mappings

Implementation of Hookable

Inherited from HookableMixin.getHooks

Overrides CreateEmployee.getHooks

Parameters:

NameType
actionstring

Returns: Mappings


getId

getId(): string | Guid

Implementation of EventSourceable

Inherited from Entity.getId

Overrides Task.getId

Returns: string | Guid


getLegacyTransformer

getLegacyTransformer(schemaVersion: number): Hook

Implementation of EventSourceable

Inherited from VersionableMixin.getLegacyTransformer

Overrides CreateEmployee.getLegacyTransformer

Parameters:

NameType
schemaVersionnumber

Returns: Hook


getLegacyTransformers

getLegacyTransformers(): LegacyTransformers

Implementation of EventSourceable

Inherited from VersionableMixin.getLegacyTransformers

Overrides CreateEmployee.getLegacyTransformers

Returns: LegacyTransformers


getPropTypes

getPropTypes(): Props

Implementation of EventSourceable

Inherited from DefinableMixin.getPropTypes

Overrides CreateEmployee.getPropTypes

Returns: Props


getPropertyInitializers

getPropertyInitializers(): Props

Implementation of EventSourceable

Inherited from DefinableMixin.getPropertyInitializers

Overrides CreateEmployee.getPropertyInitializers

Returns: Props


getSchemaVersion

getSchemaVersion(): number | undefined

Implementation of EventSourceable

Inherited from VersionableMixin.getSchemaVersion

Overrides CreateEmployee.getSchemaVersion

Returns: number | undefined


getSelectableStates

getSelectableStates(): Record‹string, State

Implementation of EventSourceable

Inherited from StatefulMixin.getSelectableStates

Overrides Task.getSelectableStates

Returns: Record‹string, State


getSelectableStatuses

getSelectableStatuses(): Record‹string, Status

Implementation of EventSourceable

Inherited from StatusfulMixin.getSelectableStatuses

Overrides Task.getSelectableStatuses

Returns: Record‹string, Status


getState

getState(): State

Implementation of EventSourceable

Inherited from StatefulMixin.getState

Overrides Task.getState

Returns: State


getStatus

getStatus(): Status

Implementation of EventSourceable

Inherited from StatusfulMixin.getStatus

Overrides Task.getStatus

Returns: Status


getTypeByHandler

getTypeByHandler(handlerReference: Handler): any | undefined

Inherited from OneToOneHandlingMixin.getTypeByHandler

Overrides CancelingEmployment.getTypeByHandler

Parameters:

NameType
handlerReferenceHandler

Returns: any | undefined


getTypeName

getTypeName(): TypeName

Implementation of EventSourceable

Inherited from SerializableMixin.getTypeName

Overrides CreateEmployee.getTypeName

Returns: TypeName


getVersion

getVersion(): number

Implementation of EventSourceable

Inherited from EventSourceable.getVersion

Overrides CancelingEmployment.getVersion

Returns: number


handle

handle(message: Command | Event): Promise‹any›

Inherited from EventSourceable.handle

Overrides OneToOneHandlingMixin.handle

Parameters:

NameType
messageCommand | Event

Returns: Promise‹any›


handles

handles(): Map‹MessageTypeCommand›, Handler

Implementation of EventSourceable

Inherited from HandlingMixin.handles

Overrides CancelingEmployment.handles

Returns: Map‹MessageTypeCommand›, Handler


hasAction

hasAction(action: string): boolean

Implementation of Hookable

Inherited from HookableMixin.hasAction

Overrides CreateEmployee.hasAction

Parameters:

NameType
actionstring

Returns: boolean


hasHandler

hasHandler(messageType: MessageTypeMessage›): boolean

Implementation of EventSourceable

Inherited from HandlingMixin.hasHandler

Overrides CancelingEmployment.hasHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: boolean


hasHook

hasHook(action: string, id: string): boolean

Implementation of Hookable

Inherited from HookableMixin.hasHook

Overrides CreateEmployee.hasHook

Parameters:

NameType
actionstring
idstring

Returns: boolean


hasLegacyTransformer

hasLegacyTransformer(schemaVersion: number): boolean

Implementation of EventSourceable

Inherited from VersionableMixin.hasLegacyTransformer

Overrides CreateEmployee.hasLegacyTransformer

Parameters:

NameType
schemaVersionnumber

Returns: boolean


hasState

hasState(): boolean

Implementation of EventSourceable

Inherited from StatefulMixin.hasState

Overrides Task.hasState

Returns: boolean


hasStatus

hasStatus(): boolean

Implementation of EventSourceable

Inherited from StatusfulMixin.hasStatus

Overrides Task.hasStatus

Returns: boolean


in

inT›(listName: string): List‹T›

Inherited from Serializable.in

Overrides CreateEmployee.in

Type parameters:

T

Parameters:

NameType
listNamestring

Returns: List‹T›


incrementVersion

incrementVersion(): void

Implementation of EventSourceable

Inherited from EventSourceable.incrementVersion

Overrides CancelingEmployment.incrementVersion

Returns: void


initialize

initialize(): Promise‹void›

Implementation of EventSourceable

Inherited from EventSourceable.initialize

Overrides OneToOneHandlingMixin.initialize

Returns: Promise‹void›


isHandleabe

isHandleabe(messageType: MessageTypeMessage›, handleableTypes?: MessageTypeMessage› | MessageTypeMessage›[]): boolean

Inherited from HandlingMixin.isHandleabe

Overrides CancelingEmployment.isHandleabe

Parameters:

NameType
messageTypeMessageTypeMessage
handleableTypes?MessageTypeMessage› | MessageTypeMessage›[]

Returns: boolean


isInOneOfStates

isInOneOfStates(states: State | State[]): boolean

Implementation of EventSourceable

Inherited from StatefulMixin.isInOneOfStates

Overrides Task.isInOneOfStates

Parameters:

NameType
statesState | State[]

Returns: boolean


isInOneOfStatuses

isInOneOfStatuses(status: Status | Status[]): boolean

Implementation of EventSourceable

Inherited from StatusfulMixin.isInOneOfStatuses

Overrides Task.isInOneOfStatuses

Parameters:

NameType
statusStatus | Status[]

Returns: boolean


isInState

isInState(state: State | State[]): boolean

Implementation of EventSourceable

Inherited from StatefulMixin.isInState

Overrides Task.isInState

Parameters:

NameType
stateState | State[]

Returns: boolean


isInStatus

isInStatus(status: Status | Status[]): boolean

Implementation of EventSourceable

Inherited from StatusfulMixin.isInStatus

Overrides Task.isInStatus

Parameters:

NameType
statusStatus | Status[]

Returns: boolean


isStateSaved

isStateSaved(): boolean

Implementation of EventSourceable

Inherited from Entity.isStateSaved

Overrides Task.isStateSaved

Returns: boolean


on

on(action: string | Stringifiable): this

Implementation of EventSourceable

Inherited from Entity.on

Overrides Task.on

Parameters:

NameType
actionstring | Stringifiable

Returns: this


overrideHandler

overrideHandler(messageType: MessageTypeMessage›, handler: Handler): void

Implementation of EventSourceable

Inherited from HandlingMixin.overrideHandler

Overrides CancelingEmployment.overrideHandler

Parameters:

NameType
messageTypeMessageTypeMessage
handlerHandler

Returns: void


overrideHook

overrideHook(action: string, id: string, hook: Hook): void

Implementation of Hookable

Inherited from HookableMixin.overrideHook

Overrides CreateEmployee.overrideHook

Parameters:

NameType
actionstring
idstring
hookHook

Returns: void


overrideLegacyTransformer

overrideLegacyTransformer(schemaVersion: number, transformer: Hook): void

Implementation of EventSourceable

Inherited from VersionableMixin.overrideLegacyTransformer

Overrides CreateEmployee.overrideLegacyTransformer

Parameters:

NameType
schemaVersionnumber
transformerHook

Returns: void


processSerializableList

processSerializableList(props?: Props): Props

Inherited from Serializable.processSerializableList

Overrides CreateEmployee.processSerializableList

Parameters:

NameType
props?Props

Returns: Props


record

record(event: Event): void

Implementation of EventSourceable

Inherited from EventSourceable.record

Overrides CancelingEmployment.record

Parameters:

NameType
eventEvent

Returns: void


registerHandler

registerHandler(messageType: MessageTypeMessage›, handler: Handler, shouldOverride?: boolean): void

Implementation of EventSourceable

Inherited from OneToOneHandlingMixin.registerHandler

Overrides HandlingMixin.registerHandler

Parameters:

NameType
messageTypeMessageTypeMessage
handlerHandler
shouldOverride?boolean

Returns: void


registerHook

registerHook(action: string, id: string, hook: Hook, shouldOverride?: boolean): void

Implementation of Hookable

Inherited from HookableMixin.registerHook

Overrides CreateEmployee.registerHook

Parameters:

NameType
actionstring
idstring
hookHook
shouldOverride?boolean

Returns: void


registerLegacyTransformer

registerLegacyTransformer(schemaVersion: number, transformer: Hook, shouldOverride?: boolean): void

Implementation of EventSourceable

Inherited from VersionableMixin.registerLegacyTransformer

Overrides CreateEmployee.registerLegacyTransformer

Parameters:

NameType
schemaVersionnumber
transformerHook
shouldOverride?boolean

Returns: void


removeHandler

removeHandler(messageType: MessageTypeMessage›): void

Implementation of EventSourceable

Inherited from HandlingMixin.removeHandler

Overrides CancelingEmployment.removeHandler

Parameters:

NameType
messageTypeMessageTypeMessage

Returns: void


removeHook

removeHook(action: string, id: string): void

Implementation of Hookable

Inherited from HookableMixin.removeHook

Overrides CreateEmployee.removeHook

Parameters:

NameType
actionstring
idstring

Returns: void


replay

replay(event: Event): void

Implementation of EventSourceable

Inherited from EventSourceable.replay

Overrides CancelingEmployment.replay

Parameters:

NameType
eventEvent

Returns: void


replayHistory

replayHistory(history: History): void

Inherited from EventSourceable.replayHistory

Overrides CancelingEmployment.replayHistory

Parameters:

NameType
historyHistory

Returns: void


schedule

schedule(command: Command, deliverAt: Date, assignmentId?: string | Guid): void

Implementation of EventSourceable

Inherited from EventSourceable.schedule

Overrides CancelingEmployment.schedule

Parameters:

NameType
commandCommand
deliverAtDate
assignmentId?string | Guid

Returns: void


setHandleableTypes

setHandleableTypes(handleableTypes: MessageTypeMessage› | MessageTypeMessage›[]): void

Implementation of EventSourceable

Inherited from HandlingMixin.setHandleableTypes

Overrides CancelingEmployment.setHandleableTypes

Parameters:

NameType
handleableTypesMessageTypeMessage› | MessageTypeMessage›[]

Returns: void


setState

setState(state: State): void

Implementation of EventSourceable

Inherited from StatefulMixin.setState

Overrides Task.setState

Parameters:

NameType
stateState

Returns: void


setStatus

setStatus(status: Status): void

Implementation of EventSourceable

Inherited from StatusfulMixin.setStatus

Overrides Task.setStatus

Parameters:

NameType
statusStatus

Returns: void


setVersion

setVersion(version: number): void

Inherited from EventSourceable.setVersion

Overrides CancelingEmployment.setVersion

Parameters:

NameType
versionnumber

Returns: void


subscribes

subscribes(): Map‹MessageTypeEvent›, Handler

Implementation of EventSourceable

Inherited from HandlingMixin.subscribes

Overrides CancelingEmployment.subscribes

Returns: Map‹MessageTypeEvent›, Handler


toJSONValue

toJSONValue(): Record‹string, any›

Implementation of Ejsonable

Inherited from SerializableMixin.toJSONValue

Overrides CreateEmployee.toJSONValue

Returns: Record‹string, any›


toPlainObject

toPlainObject(): Props

Implementation of EventSourceable

Inherited from DefinableMixin.toPlainObject

Overrides CreateEmployee.toPlainObject

Returns: Props


toString

toString(): TypeName

Implementation of EventSourceable

Inherited from SerializableMixin.toString

Overrides CreateEmployee.toString

Returns: TypeName


transformLegacyProps

transformLegacyProps(props: Props): Props

Implementation of EventSourceable

Inherited from VersionableMixin.transformLegacyProps

Overrides CreateEmployee.transformLegacyProps

Parameters:

NameType
propsProps

Returns: Props


typeName

typeName(): TypeName

Implementation of Ejsonable

Inherited from EjsonableMixin.typeName

Overrides CreateEmployee.typeName

Returns: TypeName


unschedule

unschedule(assignmentId: string | Guid, commandType: MessageTypeCommand›): void

Implementation of EventSourceable

Inherited from EventSourceable.unschedule

Overrides CancelingEmployment.unschedule

Parameters:

NameType
assignmentIdstring | Guid
commandTypeMessageTypeCommand

Returns: void


validateProps

validateProps(props: Record‹string | number | symbol, any› | undefined, propTypes: PropTypes, isStrict?: boolean): boolean

Inherited from DefinableMixin.validateProps

Overrides CreateEmployee.validateProps

Parameters:

NameType
propsRecord‹string | number | symbol, any› | undefined
propTypesPropTypes
isStrict?boolean

Returns: boolean


validateState

validateState(stateOrStates: State | State[], error?: Error): boolean

Implementation of EventSourceable

Inherited from StatefulMixin.validateState

Overrides Task.validateState

Parameters:

NameType
stateOrStatesState | State[]
error?Error

Returns: boolean


validateStatus

validateStatus(statusOrStatuses: Status | Status[], error?: Error): boolean

Implementation of EventSourceable

Inherited from StatusfulMixin.validateStatus

Overrides Task.validateStatus

Parameters:

NameType
statusOrStatusesStatus | Status[]
error?Error

Returns: boolean


Static disableSerializableLists

disableSerializableLists(): void

Inherited from Serializable.disableSerializableLists

Overrides CreateEmployee.disableSerializableLists

Returns: void


Static enableSerializableLists

enableSerializableLists(): void

Inherited from Serializable.enableSerializableLists

Overrides CreateEmployee.enableSerializableLists

Returns: void


Static from

from(...sources: Record‹string, any›[]): any

Inherited from Serializable.from

Overrides CreateEmployee.from

Parameters:

NameType
...sourcesRecord‹string, any›[]

Returns: any


Static getPropTypes

getPropTypes(): Props

Inherited from DefinableMixin.getPropTypes

Overrides CreateEmployee.getPropTypes

Returns: Props


Static getPropertyInitializers

getPropertyInitializers(): Props

Inherited from DefinableMixin.getPropertyInitializers

Overrides CreateEmployee.getPropertyInitializers

Returns: Props


Static getTypeName

getTypeName(): TypeName

Inherited from SerializableMixin.getTypeName

Overrides CreateEmployee.getTypeName

Returns: TypeName


Static resolveInitializingMessage

resolveInitializingMessage(): MessageTypeCommand | Event› | undefined

Inherited from EventSourceable.resolveInitializingMessage

Overrides CancelingEmployment.resolveInitializingMessage

Returns: MessageTypeCommand | Event› | undefined


Static resolveRoutedCommands

resolveRoutedCommands(): MessageTypeCommand›[]

Inherited from EventSourceable.resolveRoutedCommands

Overrides CancelingEmployment.resolveRoutedCommands

Returns: MessageTypeCommand›[]


Static resolveRoutedEvents

resolveRoutedEvents(): MessageTypeEvent›[]

Inherited from EventSourceable.resolveRoutedEvents

Overrides CancelingEmployment.resolveRoutedEvents

Returns: MessageTypeEvent›[]


Static resolveRoutedMessages

resolveRoutedMessages(): MessageTypeCommand | Event›[]

Inherited from EventSourceable.resolveRoutedMessages

Overrides CancelingEmployment.resolveRoutedMessages

Returns: MessageTypeCommand | Event›[]


Static toString

toString(): TypeName

Inherited from SerializableMixin.toString

Overrides CreateEmployee.toString

Returns: TypeName


Static typeName

typeName(): TypeName

Inherited from EjsonableMixin.typeName

Overrides CreateEmployee.typeName

Returns: TypeName