orbits

@wbce/orbits / Exports / Action

Class: Action

Action is the class to structure actions Extends this class to build new actions behaviours. You can read more here :

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Action()

Defined in

src/action-manager.ts:155

Properties

IArgument

IArgument: Object

Interface of the argument of the action

Defined in

src/action-manager.ts:75


IBag

IBag: Object

Interface of the bag of the action

Defined in

src/action-manager.ts:82


IResult

IResult: Object

Interface of the result of the action

Defined in

src/action-manager.ts:88


RollBackAction

RollBackAction: typeof Action = RollBackAction

The action that rollback this action.

Defined in

src/action-manager.ts:665


RollBackWorkflow

RollBackWorkflow: typeof Workflow = RevertAction

Defined in

src/action-manager.ts:666


app

app: ActionApp

Defined in

src/action-manager.ts:31


cronDefaultSettings

cronDefaultSettings: Object

Configure the frequence in which a cron will cause the

Link

Action.resume method. You can also dinamically modify the dbDoc.cronActivity property to modify the call to a cron.

Type declaration

Name Type
activityFrequence number

Defined in

src/action-manager.ts:65


dbDoc

dbDoc: ActionSchemaInterface<{}, {}, {}>

The database document of this action.

Defined in

src/action-manager.ts:95


defaultDelay

defaultDelay: number

Shorcut to

Link

Action.defaultDelays[ActionState.IN_PROGRESS]

Defined in

src/action-manager.ts:38


defaultDelays

defaultDelays: Object

For the state ActionState.EXECUTING_MAIN and ActionState.IN_PROGRESS, this object configure the time after which, if no change happened, an action is considered in error. For example, an action can only be in the ActionState.IN_PROGRESS state for as long as defaultDelays[ActionState.IN_PROGRESS] time.

Default Value

You should modify this if your actions have longer timeouts.

Type declaration

Name Type
1 number
2 number

Defined in

src/action-manager.ts:53


executor

Optional executor: Executor

Specify an executor in which all actions of this class will run.

Defined in

src/action-manager.ts:29


isInitialised

isInitialised: boolean = false

Defined in

src/action-manager.ts:346


permanentRef

Static permanentRef: string

The id of the action we store in database. This should be a permanent id that designates your instance. See :

Defined in

src/action-manager.ts:24

Accessors

_id

get _id(): this["dbDoc"]["_id"]

Returns

this["dbDoc"]["_id"]

Defined in

src/action-manager.ts:142


argument

get argument(): this["dbDoc"]["argument"]

Returns

this["dbDoc"]["argument"]

Defined in

src/action-manager.ts:106

set argument(argument): void

Parameters

Name Type
argument this["dbDoc"]["argument"]

Returns

void

Defined in

src/action-manager.ts:110


bag

get bag(): this["dbDoc"]["bag"]

Returns

this["dbDoc"]["bag"]

Defined in

src/action-manager.ts:97

set bag(bag): void

Parameters

Name Type
bag this["dbDoc"]["bag"]

Returns

void

Defined in

src/action-manager.ts:101


cronActivity

get cronActivity(): this["dbDoc"]["cronActivity"]

Returns

this["dbDoc"]["cronActivity"]

Defined in

src/action-manager.ts:133

set cronActivity(cronActivity): void

Parameters

Name Type
cronActivity this["dbDoc"]["cronActivity"]

Returns

void

Defined in

src/action-manager.ts:137


isRollBackPossible

get isRollBackPossible(): boolean

Returns

boolean

Defined in

src/action-manager.ts:624


repeat

get repeat(): this["dbDoc"]["repeat"]

Returns

this["dbDoc"]["repeat"]

Defined in

src/action-manager.ts:124

set repeat(repeat): void

Parameters

Name Type
repeat this["dbDoc"]["repeat"]

Returns

void

Defined in

src/action-manager.ts:128


result

get result(): this["dbDoc"]["result"]

Returns

this["dbDoc"]["result"]

Defined in

src/action-manager.ts:115

set result(result): void

Parameters

Name Type
result this["dbDoc"]["result"]

Returns

void

Defined in

src/action-manager.ts:119

Methods

_resume

_resume(): any

The function resumes the action by calling the appropriate function depending on the current state of the action. It doesn’t take into account the executor.

Returns

any

A promise. You can not rely on this to know when an action is finished.

Defined in

src/action-manager.ts:437


activityLogs

activityLogs(options): any[] | Promise<any[]>

Parameters

Name Type
options any

Returns

any[] | Promise<any[]>

Defined in

src/action-manager.ts:561


changeState

changeState(actionState): Promise<void>

Parameters

Name Type
actionState ActionState

Returns

Promise<void>

Defined in

src/action-manager.ts:478


checkExecutionDelay

Private checkExecutionDelay(): Promise<ActionState>

Returns

Promise<ActionState>

Defined in

src/action-manager.ts:376


createRollBackWorkflow

createRollBackWorkflow(): Workflow

Returns

Workflow

The workflow that wait for the end of this action if needed and then rollback this action.

Defined in

src/action-manager.ts:673


destroy

Private destroy(): Promise<ActionSchemaInterface<{}, {}, {}>>

Returns

Promise<ActionSchemaInterface<{}, {}, {}>>

Defined in

src/action-manager.ts:557


end

Private end(): Promise<unknown>

Returns

Promise<unknown>

Defined in

src/action-manager.ts:494


execute

Private execute(): Promise<unknown>

Returns

Promise<unknown>

Defined in

src/action-manager.ts:249


getLogs

getLogs(options?): Promise<any[]>

Parameters

Name Type
options Object
options.endTime? number

Returns

Promise<any[]>

Defined in

src/action-manager.ts:565


init

init(): Promise<any>

Initialize the action from the action stored in the database.

Example

In order to not store secrets in the database, you can set a vault id in the argument and retrieve the secret at the initialization of the action

Example

You cannot store class object on the database. If your action use complex object, they can be initialized here

Returns

Promise<any>

Defined in

src/action-manager.ts:285


initialisation

initialisation(): Promise<any>

Returns

Promise<any>

Defined in

src/action-manager.ts:347


internalLog

internalLog(message): void

Parameters

Name Type
message string

Returns

void

Defined in

src/action-manager.ts:606


internalLogError

internalLogError(err): void

Parameters

Name Type
err Error

Returns

void

Defined in

src/action-manager.ts:615


main

main(): unknown

This method should launched the main action processus It is called only one time. It returns a state value.

Returns

unknown

Defined in

src/action-manager.ts:405


onStateNotification

onStateNotification(actionState?): Promise<void>

Parameters

Name Type Default value
actionState ActionState ActionState.UNKNOW

Returns

Promise<void>

Defined in

src/action-manager.ts:487


quit

Private quit(): Promise<ActionState>

Returns

Promise<ActionState>

Defined in

src/action-manager.ts:535


resume

resume(): Promise<unknown>

The function resumes the action by calling the appropriate executor if needed and then by calling the appropriate function depending on the current state of the action

Returns

Promise<unknown>

A promise. You can not rely on this to know when an action is finished.

Defined in

src/action-manager.ts:414


resyncWithDb

resyncWithDb(): Promise<void>

This function will update the current instance of the model with the latest data from the database

Returns

Promise<void>

A promise that resolves when the last document version has be loaded

Defined in

src/action-manager.ts:212


rollBack

rollBack(): Promise<ActionState>

Shortcut to configure a rollback. Will be encapsulated in a larger action

Returns

Promise<ActionState>

Defined in

src/action-manager.ts:643


rollBackWatcher

rollBackWatcher(): Promise<UNKNOW | SUCCESS>

Shortcut to configure the watcher of the rollback Action

Returns

Promise<UNKNOW | SUCCESS>

Defined in

src/action-manager.ts:651


save

save(): Promise<ActionSchemaInterface<{}, {}, {}>>

Returns

Promise<ActionSchemaInterface<{}, {}, {}>>

Defined in

src/action-manager.ts:146


setArgument

setArgument(args): void

It takes an object of type IArgument and sets the argument that will be stored in the database. Once set, the argument of an action should not be modified.

Parameters

Name Type Description
args Object The arguments that you want to set.

Returns

void

Defined in

src/action-manager.ts:295


setFilter

setFilter(filter): void

To make filtering easier, you can pass filter to an action. This filters are stored on the database with the filter property and allow you to search for an action or a group of actions

Parameters

Name Type
filter Object

Returns

void

Defined in

src/action-manager.ts:319


setRepeat

setRepeat(opts): void

Configure the number of times an action is repeated.

Parameters

Name Type
opts Object
opts.4? number
opts.5? number

Returns

void

Defined in

src/action-manager.ts:305


setResult

setResult(result): void

Set the result of the action.

Parameters

Name Type
result Object

Returns

void

Defined in

src/action-manager.ts:329


watch

Private watch(): Promise<ActionState>

Returns

Promise<ActionState>

Defined in

src/action-manager.ts:359


watcher

watcher(): Promise<ActionState>

This method should calculate the current state of the action. It is called :

Returns

Promise<ActionState>

Defined in

src/action-manager.ts:342


constructFromDb

Static constructFromDb(actionDb): Action

Permit to construct an action from a document stored in the database.

Parameters

Name Type Description
actionDb ActionSchemaInterface<any, any, any> a document coming from the database

Returns

Action

an action for which dbDoc property is equal to actionDb

Defined in

src/action-manager.ts:199


reject

Static reject(result?): RejectAction

static reject(result?){

The above function is a static function that returns a new RejectAction object. The function takes an optional parameter called result

Parameters

Name Type Description
result? any The result of the action.

Returns

RejectAction

A new instance of the RejectAction class.

Defined in

src/action-manager.ts:243


resolve

Static resolve(result?): ResolveAction

It returns a new ResolveAction object.

Parameters

Name Type Description
result? any The result of the action.

Returns

ResolveAction

A new instance of the ResolveAction class.

Defined in

src/action-manager.ts:229