TaskList
Type parameters
▪ T: SuperConstructor
Hierarchy
Aggregate
↳ TaskList
Implements
- Controller
- Stateful
- Definable
- Hookable
- Ejsonable
- Statusful
- Entity
- EventSourceable
Index
Constructors
Properties
- [COMMANDS_KEY]
- [EVENTS_KEY]
- employeeId
- id
- metadata
- schemaVersion
- state
- status
- taskCompletionPolicy
- tasks
- title
- version
Accessors
Methods
- AcceptTask
- AssignTaskList
- ChangeTaskPriority
- CloseTaskList
- CompleteTask
- CreateTask
- CreateTaskList
- DeclineTask
- ExpireTask
- HoldTask
- OpenTaskList
- PostponeTask
- QuitTask
- StartTask
- TaskAccepted
- TaskCompleted
- TaskCreated
- TaskDeclined
- TaskExpired
- TaskHold
- TaskListAssigned
- TaskListClosed
- TaskListCreated
- TaskListOpened
- TaskPostponed
- TaskPriorityChanged
- TaskQuitted
- TaskStarted
- [ROLLBACK_STATE_METHOD_KEY]
- [SAVE_STATE_METHOD_KEY]
- assignMetadata
- commandProps
- ensureHandleability
- equals
- eventProps
- getActions
- getCommands
- getEvents
- getHandleableTypes
- getHandled
- getHandledCommands
- getHandledEvents
- getHandledMessages
- getHandledTypes
- getHandledTypesNames
- getHandler
- getHandlerOrThrow
- getHandlers
- getHook
- getHookOrThrow
- getHooks
- getId
- getLegacyTransformer
- getLegacyTransformers
- getPropTypes
- getPropertyInitializers
- getSchemaVersion
- getSelectableStates
- getSelectableStatuses
- getState
- getStatus
- getTypeByHandler
- getTypeName
- getVersion
- handle
- handles
- hasAction
- hasHandler
- hasHook
- hasLegacyTransformer
- hasState
- hasStatus
- in
- incrementVersion
- initialize
- isHandleabe
- isInOneOfStates
- isInOneOfStatuses
- isInState
- isInStatus
- isStateSaved
- on
- overrideHandler
- overrideHook
- overrideLegacyTransformer
- processSerializableList
- record
- registerHandler
- registerHook
- registerLegacyTransformer
- removeHandler
- removeHook
- replay
- replayHistory
- schedule
- setHandleableTypes
- setState
- setStatus
- setVersion
- subscribes
- toJSONValue
- toPlainObject
- toString
- transformLegacyProps
- typeName
- unschedule
- validateProps
- validateState
- validateStatus
- disableSerializableLists
- enableSerializableLists
- from
- getPropTypes
- getPropertyInitializers
- getTypeName
- resolveInitializingMessage
- resolveRoutedCommands
- resolveRoutedEvents
- resolveRoutedMessages
- toString
- typeName
Object literals
Constructors
constructor
+ new TaskList(arg
: History | Command‹object› | Props): TaskList
Inherited from Employee.constructor
Overrides void
Creates an instance of Aggregate
.
Flows:
- Replay History -
Aggregate
is recreated fromHistory
instance - list ofEvents
(manual initialization and replay is required before running Aggregate.prototype.replayHistory!). - Command -
Command
instance is passed as initializing message andAggregate
has assigned id from it. - Properties -
Aggregate
is deserialized, so props as object are passed.
example
throws
{InvalidInitializingMessageError}
Thrown if provided initializing message is not instance of Command
.
Parameters:
Name | Type | Description |
---|---|---|
arg | History | Command‹object› | Props | Instance of: History , Command or properties. |
Returns: TaskList
Properties
[COMMANDS_KEY]
• [COMMANDS_KEY]: Command[]
Inherited from Employee.[COMMANDS_KEY]
Overrides void
[EVENTS_KEY]
• [EVENTS_KEY]: Event[]
Inherited from Employee.[EVENTS_KEY]
Overrides void
Optional
employeeId
• employeeId? : Guid
id
• id: string | Guid
Overrides void
Optional
metadata
• metadata? : Record‹string, any›
Inherited from Employee.metadata
Overrides void
Optional
schemaVersion
• schemaVersion? : number
Inherited from Employee.schemaVersion
Overrides void
state
• state: State
Overrides void
status
• status: Status
Inherited from Employee.status
Overrides void
taskCompletionPolicy
• taskCompletionPolicy: any
tasks
• tasks: Task[]
title
• title: string
version
• version: number
Inherited from Employee.version
Overrides void
Accessors
ableTo
• get ableTo(): this
Method to enforce TypeScript compliance with Asserter
and AbilityAssertion
.
Returns: this
can
• get can(): any
Evaluates if action can be taken on Entity
.
Prior to invocation of any non-assertion methods snapshot of current state
is done - that will be automatically rollbacked after method execution.
Proxified instance wraps the executed method and ensures that boolean is
returned as result indicating if method indeed can be executed(true
) - or
fail with thrown error(false
)
Returns: any
Proxified instance of Entity
.
ensure
• get ensure(): this & object
Exposes the ensure
BDD assertion for Entity
.
remarks
The entity.ensure
getter-method will return a Proxified instance of the
Entity
. This proxified instance listens to all get methods and
catches the requested method name.
If the requested get method/property name matches exactly or partially
one of registered apis on Asserter
(like: is
) it returns associated
object assigned to that assertion. Like for example - for registered
AbilityAssertion
, calling entity with:
Will result with returned object:
That can be called like:
Same rules of behavior will apply to other assertions like:
StatefulAssertion
, StatusfulAssertion
.
However, since we want to enable an expressive apis on Entities - we allow users to defined their own apis. By calling:
A backup of the entity state will be created that will be rollbacked directly * after the invocation of the method(and that will happen automatically)
(it behaves exactly like ensure.is.ableTo
assertion from AbilityAssertion
)
This allows for evaluation of state change on command handlers directly without writing unnecessary duplicated code that would ensure that state indeed can be changed(first method) and then actually change it(second method).
Returns: this & object
Proxified instance of Entity
.
is
• get is(): this & object
Method to enforce TypeScript compliance with Asserter
and AbilityAssertion
.
Returns: this & object
Methods
AcceptTask
▸ AcceptTask(command
: AcceptTask): void
Parameters:
Name | Type |
---|---|
command | AcceptTask |
Returns: void
AssignTaskList
▸ AssignTaskList(command
: AssignTaskList): void
Parameters:
Name | Type |
---|---|
command | AssignTaskList |
Returns: void
ChangeTaskPriority
▸ ChangeTaskPriority(command
: ChangeTaskPriority): void
Parameters:
Name | Type |
---|---|
command | ChangeTaskPriority |
Returns: void
CloseTaskList
▸ CloseTaskList(_command
: CloseTaskList): void
Parameters:
Name | Type |
---|---|
_command | CloseTaskList |
Returns: void
CompleteTask
▸ CompleteTask(command
: CompleteTask): void
Parameters:
Name | Type |
---|---|
command | CompleteTask |
Returns: void
CreateTask
▸ CreateTask(command
: CreateTask): void
Parameters:
Name | Type |
---|---|
command | CreateTask |
Returns: void
CreateTaskList
▸ CreateTaskList(command
: CreateTaskList): void
Parameters:
Name | Type |
---|---|
command | CreateTaskList |
Returns: void
DeclineTask
▸ DeclineTask(command
: DeclineTask): void
Parameters:
Name | Type |
---|---|
command | DeclineTask |
Returns: void
ExpireTask
▸ ExpireTask(command
: ExpireTask): void
Parameters:
Name | Type |
---|---|
command | ExpireTask |
Returns: void
HoldTask
▸ HoldTask(command
: HoldTask): void
Parameters:
Name | Type |
---|---|
command | HoldTask |
Returns: void
OpenTaskList
▸ OpenTaskList(_command
: OpenTaskList): void
Parameters:
Name | Type |
---|---|
_command | OpenTaskList |
Returns: void
PostponeTask
▸ PostponeTask(command
: PostponeTask): void
Parameters:
Name | Type |
---|---|
command | PostponeTask |
Returns: void
QuitTask
▸ QuitTask(command
: QuitTask): void
Parameters:
Name | Type |
---|---|
command | QuitTask |
Returns: void
StartTask
▸ StartTask(command
: StartTask): void
Parameters:
Name | Type |
---|---|
command | StartTask |
Returns: void
TaskAccepted
▸ TaskAccepted(event
: TaskAccepted): void
Parameters:
Name | Type |
---|---|
event | TaskAccepted |
Returns: void
TaskCompleted
▸ TaskCompleted(event
: TaskCompleted): void
Parameters:
Name | Type |
---|---|
event | TaskCompleted |
Returns: void
TaskCreated
▸ TaskCreated(event
: TaskCreated): void
Parameters:
Name | Type |
---|---|
event | TaskCreated |
Returns: void
TaskDeclined
▸ TaskDeclined(event
: TaskDeclined): void
Parameters:
Name | Type |
---|---|
event | TaskDeclined |
Returns: void
TaskExpired
▸ TaskExpired(event
: TaskExpired): void
Parameters:
Name | Type |
---|---|
event | TaskExpired |
Returns: void
TaskHold
▸ TaskHold(event
: TaskHold): void
Parameters:
Name | Type |
---|---|
event | TaskHold |
Returns: void
TaskListAssigned
▸ TaskListAssigned(event
: TaskListAssigned): void
Parameters:
Name | Type |
---|---|
event | TaskListAssigned |
Returns: void
TaskListClosed
▸ TaskListClosed(_event
: TaskListClosed): void
Parameters:
Name | Type |
---|---|
_event | TaskListClosed |
Returns: void
TaskListCreated
▸ TaskListCreated(event
: TaskListCreated): void
Parameters:
Name | Type |
---|---|
event | TaskListCreated |
Returns: void
TaskListOpened
▸ TaskListOpened(_event
: TaskListOpened): void
Parameters:
Name | Type |
---|---|
_event | TaskListOpened |
Returns: void
TaskPostponed
▸ TaskPostponed(event
: TaskPostponed): void
Parameters:
Name | Type |
---|---|
event | TaskPostponed |
Returns: void
TaskPriorityChanged
▸ TaskPriorityChanged(event
: TaskPriorityChanged): void
Parameters:
Name | Type |
---|---|
event | TaskPriorityChanged |
Returns: void
TaskQuitted
▸ TaskQuitted(event
: TaskQuitted): void
Parameters:
Name | Type |
---|---|
event | TaskQuitted |
Returns: void
TaskStarted
▸ TaskStarted(event
: TaskStarted): void
Parameters:
Name | Type |
---|---|
event | TaskStarted |
Returns: void
[ROLLBACK_STATE_METHOD_KEY]
▸ [ROLLBACK_STATE_METHOD_KEY](): void
Inherited from Task.[ROLLBACK_STATE_METHOD_KEY]
Rollbacks entity to previous state.
throws
{SavedStateNotFoundError}
Thrown if rollback is done on Entity
without prior saved state.
Returns: void
[SAVE_STATE_METHOD_KEY]
▸ [SAVE_STATE_METHOD_KEY](): void
Inherited from Task.[SAVE_STATE_METHOD_KEY]
Saves current entity state.
Returns: void
assignMetadata
▸ assignMetadata(metadata
: Record‹string, any›): void
Inherited from CancelingEmployment.assignMetadata
Attaches metadata to EventSourceable
.
Parameters:
Name | Type |
---|---|
metadata | Record‹string, any› |
Returns: void
commandProps
▸ commandProps(): object
Inherited from CancelingEmployment.commandProps
Picks base properties(timestamp
& metadata
) for new Command
instance.
example
Returns: object
Returns properties for Command
instance.
metadata: Record‹string, any›
timestamp: Date
ensureHandleability
▸ ensureHandleability(messageType
: MessageType‹Message›, handleableTypes
: MessageType‹Message› | MessageType‹Message›[]): boolean
Inherited from CancelingEmployment.ensureHandleability
Ensures that provided type can be handled by verifying it against handleable types.
throws
{UnhandleableTypeError}
Thrown if message type is not one of handleable types.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
messageType | MessageType‹Message› | - | Type implementing MessageableType interface. |
handleableTypes | MessageType‹Message› | MessageType‹Message›[] | this.getHandleableTypes() | Optional handleable types to be verified against on runtime. |
Returns: boolean
Returns true if type
is handleable, else false
.
equals
▸ equals(otherEntity
: Entity): boolean
Overrides CreateEmployee.equals
Evaluates if one entity is equal to other by its constructor and identifier.
Parameters:
Name | Type | Description |
---|---|---|
otherEntity | Entity | Other Entity instance. |
Returns: boolean
Returns true
if both Entities instances are equal, else false
.
eventProps
▸ eventProps(): object
Inherited from CancelingEmployment.eventProps
Picks base properties(sourceId
, timestamp
, metadata
, version
) for new Event
instance.
example
Returns: object
Returns properties for Event
instance.
metadata: Record‹string, any›
sourceId: Guid | string
timestamp: Date
version: number
getActions
▸ getActions(): Actions
Inherited from CreateEmployee.getActions
Returns a collection of all available actions with matching registered hooks as nested collection.
Returns: Actions
Collection of actions(key) with matching registered hooks as nested collection(value).
getCommands
▸ getCommands(): Command[]
Inherited from CancelingEmployment.getCommands
Returns triggered commands on EventSourceable
.
Returns: Command[]
List of recorded Commands
.
getEvents
▸ getEvents(): Event[]
Inherited from CancelingEmployment.getEvents
Returns recorded events on EventSourceable
.
Returns: Event[]
List of recorded Events
.
getHandleableTypes
▸ getHandleableTypes(): MessageType‹Message›[]
Inherited from CancelingEmployment.getHandleableTypes
Returns handleable message types.
Returns: MessageType‹Message›[]
Returns handleable message types as a list with message types.
getHandled
▸ getHandled(messageType
: MessageType‹Message›): MessageType‹Message›[]
Inherited from CancelingEmployment.getHandled
Returns all message types that matches evaluated one by equal constructor or subclassing.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: MessageType‹Message›[]
List of all handled types matching evaluated one.
getHandledCommands
▸ getHandledCommands(): MessageType‹Command›[]
Inherited from CancelingEmployment.getHandledCommands
Returns all commands that can be handled.
Returns: MessageType‹Command›[]
List of all handled types matching Command
.
getHandledEvents
▸ getHandledEvents(): MessageType‹Event›[]
Inherited from CancelingEmployment.getHandledEvents
Returns all commands that can be handled.
Returns: MessageType‹Event›[]
List of all handled types matching Event
.
getHandledMessages
▸ getHandledMessages(): MessageType‹Message›[]
Inherited from CancelingEmployment.getHandledMessages
Returns all messages that can be handled.
Returns: MessageType‹Message›[]
List of all handled types matching Message
.
getHandledTypes
▸ getHandledTypes(): MessageType‹Message›[]
Inherited from CancelingEmployment.getHandledTypes
Returns all handled message types.
Returns: MessageType‹Message›[]
List of all handled message types.
getHandledTypesNames
▸ getHandledTypesNames(): TypeName[]
Inherited from CancelingEmployment.getHandledTypesNames
Returns all type names that can be handled.
Returns: TypeName[]
List of all handled type names
getHandler
▸ getHandler(messageType
: MessageType‹Message›): Handler | undefined
Inherited from CancelingEmployment.getHandler
Returns handler for message type.
throws
{InvalidMessageableType}
Thrown if the message type argument is not implementing Messageable
interface.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: Handler | undefined
Handler as a function if found, else undefined
.
getHandlerOrThrow
▸ getHandlerOrThrow(messageType
: MessageType‹Message›): Handler
Inherited from CancelingEmployment.getHandlerOrThrow
Return handler for message type or throws error if not found.
throws
{HandlerNotFoundError}
Thrown if handler for message type is not found.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: Handler
Handler as a function if found, else throws.
getHandlers
▸ getHandlers(): Map‹MessageType‹Message›, Handler | Handler[]›
Inherited from CancelingEmployment.getHandlers
Returns all available handler mappings.
Returns: Map‹MessageType‹Message›, Handler | Handler[]›
Returns mappings of all available handlers by message type: handler(s) relation.
getHook
▸ getHook(action
: string, id
: string): Hook | undefined
Inherited from CreateEmployee.getHook
Returns hook for action and id.
example
Parameters:
Name | Type | Description |
---|---|---|
action | string | Action for which hook is resolved. |
id | string | Identifier under which hook was was registered. |
Returns: Hook | undefined
Hook as a function
matching declaration, else undefined
.
getHookOrThrow
▸ getHookOrThrow(action
: string, id
: string): Hook
Inherited from CreateEmployee.getHookOrThrow
Returns hook for action and id or throws.
throws
{HandlerNotFoundError}
Thrown if there is no hook registered for action with id.
Parameters:
Name | Type | Description |
---|---|---|
action | string | Action for which hook is resolved. |
id | string | Identifier under which hook was was registered. |
Returns: Hook
Hook as a function
matching declaration, else throws.
getHooks
▸ getHooks(action
: string): Mappings
Inherited from CreateEmployee.getHooks
Returns a collection of all available hooks registered for action.
Parameters:
Name | Type | Description |
---|---|---|
action | string | Action for which hooks are resolved. |
Returns: Mappings
Collection of hooks.
getId
▸ getId(): string | Guid
Returns identifier for Entity.
Returns: string | Guid
Entities identifier as Guid
instance or string.
getLegacyTransformer
▸ getLegacyTransformer(schemaVersion
: number): Hook
Inherited from CreateEmployee.getLegacyTransformer
Returns legacy transformer for schema version.
throws
{LegacyTransformerNotFoundError}
Thrown if transformer for schema version can't be found.
Parameters:
Name | Type | Description |
---|---|---|
schemaVersion | number | Schema version. |
Returns: Hook
Legacy transformer for schema version.
getLegacyTransformers
▸ getLegacyTransformers(): LegacyTransformers
Inherited from CreateEmployee.getLegacyTransformers
Returns all available legacy transformers.
Returns: LegacyTransformers
Map instance of all registered legacy transformers with number version as a key and transformer function as a value.
getPropTypes
▸ getPropTypes(): Props
Inherited from CreateEmployee.getPropTypes
Returns class properties types from whole inheritance tree.
example
Returns: Props
Plain object representation of properties types.
getPropertyInitializers
▸ getPropertyInitializers(): Props
Inherited from CreateEmployee.getPropertyInitializers
Returns default values metadata from property initializers conversion for whole inheritance tree.
example
Returns: Props
Default values for properties.
getSchemaVersion
▸ getSchemaVersion(): number | undefined
Inherited from CreateEmployee.getSchemaVersion
Returns current instance schema version.
Returns: number | undefined
Schema version as a number, else undefined
.
getSelectableStates
▸ getSelectableStates(): Record‹string, State›
Inherited from Task.getSelectableStates
Returns all selectable states.
Returns: Record‹string, State›
Collection of available states.
getSelectableStatuses
▸ getSelectableStatuses(): Record‹string, Status›
Inherited from Task.getSelectableStatuses
Returns all selectable status.
Returns: Record‹string, Status›
Collection of available status.
getState
▸ getState(): State
Returns current state of instance.
Returns: State
Current state of instance as string
.
getStatus
▸ getStatus(): Status
Returns current status of instance.
Returns: Status
Current status of instance as string
.
getTypeByHandler
▸ getTypeByHandler(handlerReference
: Handler): any | undefined
Inherited from CancelingEmployment.getTypeByHandler
Resolves message type by handler reference.
Parameters:
Name | Type | Description |
---|---|---|
handlerReference | Handler | Reference to handler function. |
Returns: any | undefined
Message type if handler is matching one of handlers on class, else undefined
.
getTypeName
▸ getTypeName(): TypeName
Inherited from CreateEmployee.getTypeName
Returns definable type name.
Returns: TypeName
Type name as a string.
getVersion
▸ getVersion(): number
Inherited from CancelingEmployment.getVersion
Returns current version of EventSourceable
.
Returns: number
Current number version of instance.
handle
▸ handle(message
: Command | Event): Promise‹any›
Inherited from CancelingEmployment.handle
Overrides void
Handles message.
async
throws
{HandlerNotFoundError}
Thrown if handler for type is not found.
Parameters:
Name | Type |
---|---|
message | Command | Event |
Returns: Promise‹any›
Instance of EventSourceable
.
handles
▸ handles(): Map‹MessageType‹Command›, Handler›
Inherited from CancelingEmployment.handles
Returns all handled Command
mappings.
example
Returns: Map‹MessageType‹Command›, Handler›
Returns all handled Command
(s) defined with @handle
annotation
or allows developer to define manually handlers.
hasAction
▸ hasAction(action
: string): boolean
Inherited from CreateEmployee.hasAction
Evaluates if hooks for action are registered.
Parameters:
Name | Type | Description |
---|---|---|
action | string | Action for which hook is existence is evaluated. |
Returns: boolean
Returns true if hooks for action exists, else false.
hasHandler
▸ hasHandler(messageType
: MessageType‹Message›): boolean
Inherited from CancelingEmployment.hasHandler
Evaluates if handler for message type is registered.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: boolean
Returns true
if handler for message type is registered, else false
.
hasHook
▸ hasHook(action
: string, id
: string): boolean
Inherited from CreateEmployee.hasHook
Evaluates if hook for action with id is registered.
Parameters:
Name | Type | Description |
---|---|---|
action | string | Action for which hook is existence is evaluated. |
id | string | Identifier under which hook was was registered. |
Returns: boolean
Returns true if hook exists, else false.
hasLegacyTransformer
▸ hasLegacyTransformer(schemaVersion
: number): boolean
Inherited from CreateEmployee.hasLegacyTransformer
Evaluates is there is registered legacy transformer for schema version.
Parameters:
Name | Type | Description |
---|---|---|
schemaVersion | number | Schema version. |
Returns: boolean
Returns true
if legacy transformer for schema version is registered, else false
.
hasState
▸ hasState(): boolean
Evaluates if target has state set on instance(is not nil
).
Returns: boolean
Returns true
if instance has state set(not nil
), else false
.
hasStatus
▸ hasStatus(): boolean
Evaluates if target has status set on instance(is not nil
).
Returns: boolean
Returns true
if instance has status set(not nil
), else false
.
in
▸ in‹T›(listName
: string): List‹T›
Inherited from CreateEmployee.in
Returns List
for Serializable
array.
throws
{InvalidListError}
Thrown if the provided container name does not point to list of supported Serializables
.
example
Type parameters:
▪ T
Parameters:
Name | Type | Description |
---|---|---|
listName | string | Property name of the Serializable list on this instance. |
Returns: List‹T›
Instance of List
implementation.
incrementVersion
▸ incrementVersion(): void
Inherited from CancelingEmployment.incrementVersion
Increments version of event sourceable.
Returns: void
initialize
▸ initialize(): Promise‹void›
Inherited from CancelingEmployment.initialize
Overrides void
Initializes EventSourceable.
Returns: Promise‹void›
isHandleabe
▸ isHandleabe(messageType
: MessageType‹Message›, handleableTypes
: MessageType‹Message› | MessageType‹Message›[]): boolean
Inherited from CancelingEmployment.isHandleabe
Evaluates if type can be handled.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
messageType | MessageType‹Message› | - | Type implementing MessageableType interface. |
handleableTypes | MessageType‹Message› | MessageType‹Message›[] | this.getHandleableTypes() | Optional handleable types to be verified against on runtime. |
Returns: boolean
Returns true
if message type can be handled, else false
.
isInOneOfStates
▸ isInOneOfStates(states
: State | State[]): boolean
Inherited from Task.isInOneOfStates
Evaluates if target is in one of expected state.
Parameters:
Name | Type | Description |
---|---|---|
states | State | State[] | Expected states in which one of instance should be. |
Returns: boolean
Returns true if instance is in one of states, else false.
isInOneOfStatuses
▸ isInOneOfStatuses(status
: Status | Status[]): boolean
Inherited from Task.isInOneOfStatuses
Evaluates if target is in one of expected status.
Parameters:
Name | Type | Description |
---|---|---|
status | Status | Status[] | Expected status in which one of instance should be. |
Returns: boolean
Returns true if instance is in one of status, else false.
isInState
▸ isInState(state
: State | State[]): boolean
Evaluates if target is in expected state.
Parameters:
Name | Type | Description |
---|---|---|
state | State | State[] | Expected state in which instance should be. |
Returns: boolean
Returns true
if instance is in state, else false
.
isInStatus
▸ isInStatus(status
: Status | Status[]): boolean
Inherited from Task.isInStatus
Evaluates if target is in expected status.
Parameters:
Name | Type | Description |
---|---|---|
status | Status | Status[] | Expected status in which instance should be. |
Returns: boolean
Returns true
if instance is in status, else false
.
isStateSaved
▸ isStateSaved(): boolean
Inherited from Task.isStateSaved
Evaluates if state of entity is saved.
Returns: boolean
Returns true
if state of entity is saved, else false
.
on
▸ on(action
: string | Stringifiable): this
Sets current action for asserting state of Entity
.
Parameters:
Name | Type | Description |
---|---|---|
action | string | Stringifiable | Name of action to be taken or Command that is handled. |
Returns: this
Instance implementing Asserter
interface.
overrideHandler
▸ overrideHandler(messageType
: MessageType‹Message›, handler
: Handler): void
Inherited from CancelingEmployment.overrideHandler
Overrides already existing handler for message type.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
handler | Handler | Handler function that will executed upon handling message type. |
Returns: void
overrideHook
▸ overrideHook(action
: string, id
: string, hook
: Hook): void
Inherited from CreateEmployee.overrideHook
Overrides registered hook by action and id or registers a new one.
throws
{InvalidHookActionError}
Thrown if the the action argument is not a string
.
throws
{InvalidHookIdError}
Thrown if the the id argument is not a string
.
Parameters:
Name | Type | Description |
---|---|---|
action | string | Action for which hook will be registered(like onConstruction , onSend , onPublish etc.) |
id | string | Identifier under which hook will be registered for further reference. |
hook | Hook | Hook as a function matching declaration for required action that will be invoked upon action. |
Returns: void
overrideLegacyTransformer
▸ overrideLegacyTransformer(schemaVersion
: number, transformer
: Hook): void
Inherited from CreateEmployee.overrideLegacyTransformer
Overrides registered transformer by schema version or registers a new one.
throws
{InvalidSchemaVersionError}
Thrown if the the schema version argument is not a number.
Parameters:
Name | Type | Description |
---|---|---|
schemaVersion | number | Schema version. |
transformer | Hook | Transformer function. |
Returns: void
processSerializableList
▸ processSerializableList(props
: Props): Props
Inherited from CreateEmployee.processSerializableList
Processes properties for Serializable by wrapping each serializable list property with List
.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
props | Props | {} | Properties of the type required for construction. |
Returns: Props
Processed properties with any registered onConstruction
hooks and
validates them against prop types.
record
▸ record(event
: Event): void
Inherited from CancelingEmployment.record
Records state change of EventSourceable
as Event
and updates event sourceable version.
example
Parameters:
Name | Type | Description |
---|---|---|
event | Event | Instance of Event . |
Returns: void
registerHandler
▸ registerHandler(messageType
: MessageType‹Message›, handler
: Handler, shouldOverride
: boolean): void
Inherited from CancelingEmployment.registerHandler
Overrides void
Registers handler for message type.
throws
{UnhandleableTypeError}
Thrown if the type argument is not one of handleable types.
throws
{InvalidHandlerError}
Thrown if the handler argument is not a function.
throws
{HandlerExistError}
Thrown if handler would overridden without explicit call.
example
Parameters:
Name | Type | Default | Description |
---|---|---|---|
messageType | MessageType‹Message› | - | Type implementing MessageableType interface. |
handler | Handler | - | Handler function that will executed upon handling message type. |
shouldOverride | boolean | false | Flag indicating that handler should be overridden if exist. |
Returns: void
registerHook
▸ registerHook(action
: string, id
: string, hook
: Hook, shouldOverride
: boolean): void
Inherited from CreateEmployee.registerHook
Registers hook by action type and id.
throws
{InvalidHookActionError}
Thrown if the the action argument is not a string.
throws
{InvalidHookIdError}
Thrown if the the id argument is not a string.
throws
{HookAlreadyExistsError}
Thrown if the existing hook with id would be overridden.
example
Parameters:
Name | Type | Default | Description |
---|---|---|---|
action | string | - | Action for which hook will be registered(like onConstruction , onSend , onPublish etc.) |
id | string | - | Identifier under which hook will be registered for further reference. |
hook | Hook | - | Hook as a function matching declaration for required action that will be invoked upon action. |
shouldOverride | boolean | false | Flag indicating that hook should be overridden if exist. |
Returns: void
registerLegacyTransformer
▸ registerLegacyTransformer(schemaVersion
: number, transformer
: Hook, shouldOverride
: boolean): void
Inherited from CreateEmployee.registerLegacyTransformer
Registers legacy transformer for version.
throws
{InvalidSchemaVersionError}
Thrown if the the schema version argument is not a number.
throws
{LegacyTransformerAlreadyExistsError}
Thrown if transformer for version would overridden without explicit call.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
schemaVersion | number | - | Schema version. |
transformer | Hook | - | Transformer function. |
shouldOverride | boolean | false | Flag indicating that transformer should be overridden if exist. |
Returns: void
removeHandler
▸ removeHandler(messageType
: MessageType‹Message›): void
Inherited from CancelingEmployment.removeHandler
Removes handler by type.
Parameters:
Name | Type | Description |
---|---|---|
messageType | MessageType‹Message› | Type implementing MessageableType interface. |
Returns: void
removeHook
▸ removeHook(action
: string, id
: string): void
Inherited from CreateEmployee.removeHook
Removes a hook by action and id.
example
Parameters:
Name | Type | Description |
---|---|---|
action | string | Action for which hook is removed. |
id | string | Identifier under which hook was was registered. |
Returns: void
replay
▸ replay(event
: Event): void
Inherited from CancelingEmployment.replay
Replies event and updates EventSourceable
version.
Parameters:
Name | Type | Description |
---|---|---|
event | Event | Instance of Event . |
Returns: void
replayHistory
▸ replayHistory(history
: History): void
Inherited from CancelingEmployment.replayHistory
Replies history from list of events.
Parameters:
Name | Type | Description |
---|---|---|
history | History | Instance of History containing Event list. |
Returns: void
schedule
▸ schedule(command
: Command, deliverAt
: Date, assignmentId
: string | Guid): void
Inherited from CancelingEmployment.schedule
Schedules command to be delivered at specific time.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
command | Command | - | Command instance. |
deliverAt | Date | - | Date instance on which command should be delivered. |
assignmentId | string | Guid | this.getId() | Scheduling assignment identifer. |
Returns: void
setHandleableTypes
▸ setHandleableTypes(handleableTypes
: MessageType‹Message› | MessageType‹Message›[]): void
Inherited from CancelingEmployment.setHandleableTypes
Sets the only allowed handleable message types.
Parameters:
Name | Type | Description |
---|---|---|
handleableTypes | MessageType‹Message› | MessageType‹Message›[] | List of allowed types for handling. |
Returns: void
setState
▸ setState(state
: State): void
Sets instance state.
throws
{ValidationError}
Thrown if the provided state does not match one of the selectable states.
throws
{UndefinedStatesError}
Thrown if the instance does not have any states assigned.
Parameters:
Name | Type | Description |
---|---|---|
state | State | State to which instance should be set. |
Returns: void
setStatus
▸ setStatus(status
: Status): void
Sets instance status.
throws
{ValidationError}
Thrown if the provided status does not match one of the selectable status.
throws
{UndefinedStatusesError}
Thrown if the instance does not have any status assigned.
Parameters:
Name | Type | Description |
---|---|---|
status | Status | Status to which instance should be set. |
Returns: void
setVersion
▸ setVersion(version
: number): void
Inherited from CancelingEmployment.setVersion
Sets version of EventSourceable
.
Parameters:
Name | Type | Description |
---|---|---|
version | number | Version number. |
Returns: void
Current number version of instance.
subscribes
▸ subscribes(): Map‹MessageType‹Event›, Handler›
Inherited from CancelingEmployment.subscribes
Returns all handled Event
mappings.
example
Returns: Map‹MessageType‹Event›, Handler›
Returns all handled Events
(s) defined with @subscribe
annotation
or allows developer to define manually handlers.
toJSONValue
▸ toJSONValue(): Record‹string, any›
Inherited from CreateEmployee.toJSONValue
Serializes value into a JSON-compatible value. It preserves all custom field types, however the initial value type is not saved.
example
Returns: Props
Public properties with assigned values as plain object.
toString
▸ toString(): TypeName
Inherited from CreateEmployee.toString
Returns definable type name
Returns: TypeName
Type name as a string.
transformLegacyProps
▸ transformLegacyProps(props
: Props): Props
Inherited from CreateEmployee.transformLegacyProps
Registrable hook for transforming legacy schema.
Parameters:
Name | Type | Description |
---|---|---|
props | Props | Properties object to be transformed. |
Returns: Props
Transformed legacy properties or their unchanged state if up to date.
typeName
▸ typeName(): TypeName
Inherited from CreateEmployee.typeName
alias
getTypeName
remarks
Compatibility for EJSON serializer: @eveble/ejson
Returns: TypeName
unschedule
▸ unschedule(assignmentId
: string | Guid, commandType
: MessageType‹Command›): void
Inherited from CancelingEmployment.unschedule
Unschedule delivery of a specific command by assignment specification.
Parameters:
Name | Type | Description |
---|---|---|
assignmentId | string | Guid | Scheduling assignment identifer. |
commandType | MessageType‹Command› | A Command type that should be unscheduled. |
Returns: void
validateProps
▸ validateProps(props
: Props, propTypes
: PropTypes, isStrict
: boolean): boolean
Inherited from CreateEmployee.validateProps
Validates if provided properties matches prop types.
throws
{ValidationError}
Thrown if the passed properties do not match prop types.
remarks
Disabling of runtime validation is possible via Kernel's configuration(and by
that env flags also) or by annotating class with @validable(false)
.
This is useful when there is external layer(like transportation) that does all the heavy lifting of validation and there are no other sources of incoming data beside points that is handled by layer.
Use env EVEBLE_VALIDATION_TYPE
set to manual
to disable validation on
initialization. You ca re-enable it again on your application configuration via
path validation.type
set to runtime
before staring application.
example
Parameters:
Name | Type | Default | Description |
---|---|---|---|
props | Props | {} | Properties to validate. |
propTypes | PropTypes | - | Properties types. |
isStrict | boolean | true | Flag indicating that validation should be done in strict mode. |
Returns: boolean
Returns true
if properties are valid, else throws.
validateState
▸ validateState(stateOrStates
: State | State[], error?
: Error): boolean
Inherited from Task.validateState
Validates if instance is in allowed state(s).
throws
{InvalidStateError}
Thrown if target is not in correct(one of allowed) state.
Parameters:
Name | Type | Description |
---|---|---|
stateOrStates | State | State[] | Expected states list in one of which instance should be. |
error? | Error | Optional error instance for case where state does not match expected one. |
Returns: boolean
Returns true
if instance is in correct state, else throws.
validateStatus
▸ validateStatus(statusOrStatuses
: Status | Status[], error?
: Error): boolean
Inherited from Task.validateStatus
Validates if instance is in allowed status(s).
throws
{InvalidStatusError}
Thrown if target is not in correct(one of allowed) status.
Parameters:
Name | Type | Description |
---|---|---|
statusOrStatuses | Status | Status[] | Expected status list in one of which instance should be. |
error? | Error | Optional error instance for case where status does not match expected one. |
Returns: boolean
Returns true
if instance is in correct status, else throws.
Static
disableSerializableLists
▸ disableSerializableLists(): void
Inherited from CreateEmployee.disableSerializableLists
Disables conversion of serializable lists to List
instances.
Returns: void
Static
enableSerializableLists
▸ enableSerializableLists(): void
Inherited from CreateEmployee.enableSerializableLists
Enables conversion of serializable lists to List
instances.
remarks
Since using mixins with polytype on extendable classes like: Serializable
, Entity
,
EventSourceable
, ValueObject
will result in loosing all registered hooks on metadata
- this ensures that hook can be easily re-applied.
Returns: void
Static
from
▸ from(...sources
: Record‹string, any›[]): any
Inherited from CreateEmployee.from
Create an Serializable
from multiple property sources. Have similar api
like Object.assign
.
throws
{ValidationError}
Thrown if the passed properties does not match serializeble's property types.
example
Parameters:
Name | Type | Description |
---|---|---|
...sources | Record‹string, any›[] | One or more source of properties. |
Returns: any
New instance of Serializable
with assigned properties.
Static
getPropTypes
▸ getPropTypes(): Props
Inherited from CreateEmployee.getPropTypes
Returns class properties types from whole inheritance tree.
example
Returns: Props
Plain object representation of properties types.
Static
getPropertyInitializers
▸ getPropertyInitializers(): Props
Inherited from CreateEmployee.getPropertyInitializers
Returns class property initializers for whole inheritance tree.
example
Returns: Props
Plain object representation of property initializers.
Static
getTypeName
▸ getTypeName(): TypeName
Inherited from CreateEmployee.getTypeName
Returns definable type name.
Returns: TypeName
Type name as a string.
Static
resolveInitializingMessage
▸ resolveInitializingMessage(): MessageType‹Command | Event› | undefined
Inherited from CancelingEmployment.resolveInitializingMessage
Resolves initializing message on EventSourceable
.
Returns: MessageType‹Command | Event› | undefined
Command
or Event
type.
Static
resolveRoutedCommands
▸ resolveRoutedCommands(): MessageType‹Command›[]
Inherited from CancelingEmployment.resolveRoutedCommands
Resolves routed commands.
Returns: MessageType‹Command›[]
List of all routed Command
types.
Static
resolveRoutedEvents
▸ resolveRoutedEvents(): MessageType‹Event›[]
Inherited from CancelingEmployment.resolveRoutedEvents
Resolves routed events.
Returns: MessageType‹Event›[]
List of all routed Event
types.
Static
resolveRoutedMessages
▸ resolveRoutedMessages(): MessageType‹Command | Event›[]
Inherited from CancelingEmployment.resolveRoutedMessages
Resolves routed messages.
Returns: MessageType‹Command | Event›[]
List of all routed messages types.
Static
toString
▸ toString(): TypeName
Inherited from CreateEmployee.toString
Returns definable type name
Returns: TypeName
Type name as a string.
Static
typeName
▸ typeName(): TypeName
Inherited from CreateEmployee.typeName
alias
getTypeName
remarks
Compatibility for EJSON serializer: @eveble/ejson
Returns: TypeName
Object literals
Static
STATES
▪ STATES: object
closed
• closed: string = "closed"
created
• created: string = "created"
open
• open: string = "open"
removed
• removed: string = "removed"