EventSourceable

Type parameters

T: SuperConstructor

T: SuperConstructor

T: SuperConstructor

T: SuperConstructor

Hierarchy

Implements

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

+ new EventSourceable(props: Props): EventSourceable

Overrides Entity.constructor

Creates an instance of EventSourceable. Creates an instance of EventSourceable.

example

new EventSourceable({id: 'my-id'})
new EventSourceable({id: 'my-id', key: 'value'})

example

new EventSourceable({id: 'my-id'})
new EventSourceable({id: 'my-id', key: 'value'})

Parameters:

NameTypeDescription
propsPropsProperties of the type required for construction.

Returns: EventSourceable

Properties

[COMMANDS_KEY]

[COMMANDS_KEY]: Command[]


[EVENTS_KEY]

[EVENTS_KEY]: Event[]


id

id: string | Guid

Overrides Entity.id


Optional metadata

metadata? : Record‹string, any›


Optional schemaVersion

schemaVersion? : number

Overrides Entity.schemaVersion


state

state: State

Implementation of EventSourceable.state

Overrides Entity.state


status

status: Status

Implementation of EventSourceable.status

Overrides Entity.status


version

version: number

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

Attaches metadata to EventSourceable.

Parameters:

NameType
metadataRecord‹string, any›

Returns: void


commandProps

commandProps(): object

Picks base properties(timestamp & metadata) for new Command instance.

example

this.trigger(new MyCommand({
...this.commandProps(),
customerName: command.customerName,
}));

Returns: object

Returns properties for Command instance.

  • 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

Picks base properties(sourceId, timestamp, metadata, version) for new Event instance.

example

this.record(new MyEvent({
...this.eventProps(),
customerName: command.customerName,
}));

Returns: object

Returns properties for Event instance.

  • 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

Returns triggered commands on EventSourceable.

Returns: Command[]

List of recorded Commands.


getEvents

getEvents(): Event[]

Implementation of EventSourceable

Returns recorded events on EventSourceable.

Returns: Event[]

List of recorded Events.


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

Returns current version of EventSourceable.

Returns: number

Current number version of instance.


handle

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

Overrides OneToOneHandlingMixin.handle

Handles message.

async

throws {HandlerNotFoundError} Thrown if handler for type is not found.

Parameters:

NameType
messageCommand | Event

Returns: Promise‹any›

Instance of EventSourceable.


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

Increments version of event sourceable.

Returns: void


initialize

initialize(): Promise‹void›

Implementation of EventSourceable

Overrides OneToOneHandlingMixin.initialize

Initializes EventSourceable.

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

Records state change of EventSourceable as Event and updates event sourceable version.

example

this.record(new MyEvent({
sourceId: this.getId(),
key: 'value'
});
this.record(new MyEvent({
...this.eventProps(),
customerName: command.customerName,
}));

Parameters:

NameTypeDescription
eventEventInstance of Event.

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

Replies event and updates EventSourceable version.

Parameters:

NameTypeDescription
eventEventInstance of Event.

Returns: void


replayHistory

replayHistory(history: History): void

Replies history from list of events.

Parameters:

NameTypeDescription
historyHistoryInstance of History containing Event list.

Returns: void


schedule

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

Implementation of EventSourceable

Schedules command to be delivered at specific time.

Parameters:

NameTypeDescription
commandCommandCommand instance.
deliverAtDateDate instance on which command should be delivered.
assignmentId?string | GuidScheduling assignment identifer.

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

Sets version of EventSourceable.

Parameters:

NameTypeDescription
versionnumberVersion number.

Returns: void

Current number version of instance.


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

Unschedule delivery of a specific command by assignment specification.

Parameters:

NameTypeDescription
assignmentIdstring | GuidScheduling assignment identifer.
commandTypeMessageTypeCommandA Command type that should be unscheduled.

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

Resolves initializing message on EventSourceable.

Returns: MessageTypeCommand | Event› | undefined

Command or Event type.


Static resolveRoutedCommands

resolveRoutedCommands(): MessageTypeCommand›[]

Resolves routed commands.

Returns: MessageTypeCommand›[]

List of all routed Command types.


Static resolveRoutedEvents

resolveRoutedEvents(): MessageTypeEvent›[]

Resolves routed events.

Returns: MessageTypeEvent›[]

List of all routed Event types.


Static resolveRoutedMessages

resolveRoutedMessages(): MessageTypeCommand | Event›[]

Resolves routed messages.

Returns: MessageTypeCommand | Event›[]

List of all routed messages types.


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