orbits

@wbce/orbits / Exports / RevertAction

Class: RevertAction<ActionToRevert>

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

Type parameters

Name Type
ActionToRevert extends Action

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new RevertAction<ActionToRevert>()

Type parameters

Name Type
ActionToRevert extends Action<ActionToRevert>

Inherited from

Workflow.constructor

Defined in

src/workflow-manager.ts:44

Properties

IArgument

IArgument: Object

Interface of the argument of the action

Type declaration

Name Type
actionId string

Overrides

Workflow.IArgument

Defined in

src/workflow-manager.ts:460


IBag

IBag: Object

Interface of the bag of the action

Type declaration

Name Type
actions { [key: string]: { result: any ; state: ActionState }; }
currentStepIndex? number
isRollBackPossible boolean
nTimesCurrentStep number
oldResult any
stepsHistory number[]

Inherited from

Workflow.IBag

Defined in

src/workflow-manager.ts:30


IResult

IResult: Object

Interface of the result of the action

Inherited from

Workflow.IResult

Defined in

src/action-manager.ts:88


RollBackAction

RollBackAction: typeof Action = RollBackAction

The action that rollback this action.

Inherited from

Workflow.RollBackAction

Defined in

src/action-manager.ts:665


RollBackWorkflow

RollBackWorkflow: typeof RevertWorkflow = RevertWorkflow

Inherited from

Workflow.RollBackWorkflow

Defined in

src/workflow-manager.ts:384


app

app: ActionApp

Inherited from

Workflow.app

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

Inherited from

Workflow.cronDefaultSettings

Defined in

src/action-manager.ts:65


dBSession

Optional dBSession: ClientSession

Inherited from

Workflow.dBSession

Defined in

src/workflow-manager.ts:24


dbDoc

dbDoc: ActionSchemaInterface<{ actionId: string }, { actions: { [key: string]: { result: any ; state: ActionState }; } ; currentStepIndex?: number ; isRollBackPossible: boolean ; nTimesCurrentStep: number ; oldResult: any ; stepsHistory: number[] }, {}>

The database document of this action.

Inherited from

Workflow.dbDoc

Defined in

src/action-manager.ts:95


defaultDelay

defaultDelay: number = Infinity

Shorcut to

Link

Action.defaultDelays[ActionState.IN_PROGRESS]

Inherited from

Workflow.defaultDelay

Defined in

src/workflow-manager.ts:21


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

Inherited from

Workflow.defaultDelays

Defined in

src/action-manager.ts:53


docsToSaveAtStepStart

docsToSaveAtStepStart: Document<any, any, any>[] = []

Inherited from

Workflow.docsToSaveAtStepStart

Defined in

src/workflow-manager.ts:26


executor

Optional executor: Executor

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

Inherited from

Workflow.executor

Defined in

src/action-manager.ts:29


isInitialised

isInitialised: boolean = false

Inherited from

Workflow.isInitialised

Defined in

src/action-manager.ts:346


oldAction

oldAction: ActionToRevert

Defined in

src/workflow-manager.ts:464


steps

steps: Step[] = []

Inherited from

Workflow.steps

Defined in

src/workflow-manager.ts:28


permanentRef

Static permanentRef: string

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

Inherited from

Workflow.permanentRef

Defined in

src/action-manager.ts:24

Accessors

_id

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

Returns

this["dbDoc"]["_id"]

Inherited from

Workflow._id

Defined in

src/action-manager.ts:142


argument

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

Returns

this["dbDoc"]["argument"]

Inherited from

Workflow.argument

Defined in

src/action-manager.ts:106

set argument(argument): void

Parameters

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

Returns

void

Inherited from

Workflow.argument

Defined in

src/action-manager.ts:110


bag

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

Returns

this["dbDoc"]["bag"]

Inherited from

Workflow.bag

Defined in

src/action-manager.ts:97

set bag(bag): void

Parameters

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

Returns

void

Inherited from

Workflow.bag

Defined in

src/action-manager.ts:101


cronActivity

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

Returns

this["dbDoc"]["cronActivity"]

Inherited from

Workflow.cronActivity

Defined in

src/action-manager.ts:133

set cronActivity(cronActivity): void

Parameters

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

Returns

void

Inherited from

Workflow.cronActivity

Defined in

src/action-manager.ts:137


isRollBackPossible

get isRollBackPossible(): boolean

Returns

boolean

Inherited from

Workflow.isRollBackPossible

Defined in

src/workflow-manager.ts:370


repeat

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

Returns

this["dbDoc"]["repeat"]

Inherited from

Workflow.repeat

Defined in

src/action-manager.ts:124

set repeat(repeat): void

Parameters

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

Returns

void

Inherited from

Workflow.repeat

Defined in

src/action-manager.ts:128


result

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

Returns

this["dbDoc"]["result"]

Inherited from

Workflow.result

Defined in

src/action-manager.ts:115

set result(result): void

Parameters

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

Returns

void

Inherited from

Workflow.result

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.

Inherited from

Workflow._resume

Defined in

src/action-manager.ts:437


activityLogs

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

Parameters

Name Type
options any

Returns

any[] | Promise<any[]>

Inherited from

Workflow.activityLogs

Defined in

src/action-manager.ts:561


catch

catch(cb, opts?): RevertAction<ActionToRevert>

Parameters

Name Type
cb (…args: any[]) => void | Action | Action[] | Promise<void | Action | Action[]>
opts? Object
opts.retry number

Returns

RevertAction<ActionToRevert>

Inherited from

Workflow.catch

Defined in

src/workflow-manager.ts:58


changeState

changeState(actionState): Promise<void>

Parameters

Name Type
actionState ActionState

Returns

Promise<void>

Inherited from

Workflow.changeState

Defined in

src/action-manager.ts:478


createRollBackWorkflow

createRollBackWorkflow(): Workflow

Returns

Workflow

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

Inherited from

Workflow.createRollBackWorkflow

Defined in

src/action-manager.ts:673


declareActionEnd

declareActionEnd(dbDoc): void

Parameters

Name Type
dbDoc ActionSchemaInterface<any, any, any>

Returns

void

Inherited from

Workflow.declareActionEnd

Defined in

src/workflow-manager.ts:173


declareActionStart

declareActionStart(dbDoc): void

Parameters

Name Type
dbDoc ActionSchemaInterface<any, any, any>

Returns

void

Inherited from

Workflow.declareActionStart

Defined in

src/workflow-manager.ts:160


define

define(): Promise<void>

Returns

Promise<void>

Overrides

Workflow.define

Defined in

src/workflow-manager.ts:476


endStep

endStep(): Promise<ActionState>

Returns

Promise<ActionState>

Inherited from

Workflow.endStep

Defined in

src/workflow-manager.ts:286


finally

finally(cb, opts?): RevertAction<ActionToRevert>

Parameters

Name Type
cb (…args: any[]) => void | Action | Action[] | Promise<void | Action | Action[]>
opts? Object
opts.retry number

Returns

RevertAction<ActionToRevert>

Inherited from

Workflow.finally

Defined in

src/workflow-manager.ts:67


getLogs

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

Parameters

Name Type
options Object
options.endTime? number

Returns

Promise<any[]>

Inherited from

Workflow.getLogs

Defined in

src/action-manager.ts:565


getNextStep

getNextStep(): Promise<void | Action | Action[]>

Returns

Promise<void | Action | Action[]>

Inherited from

Workflow.getNextStep

Defined in

src/workflow-manager.ts:184


goTo

goTo(name, onState): RevertAction<ActionToRevert>

Parameters

Name Type
name string
onState ActionState

Returns

RevertAction<ActionToRevert>

Inherited from

Workflow.goTo

Defined in

src/workflow-manager.ts:138


goToStep

goToStep(name): ResolveAction

Parameters

Name Type
name string

Returns

ResolveAction

Inherited from

Workflow.goToStep

Defined in

src/workflow-manager.ts:130


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>

Overrides

Workflow.init

Defined in

src/workflow-manager.ts:466


initialisation

initialisation(): Promise<void>

Returns

Promise<void>

Inherited from

Workflow.initialisation

Defined in

src/workflow-manager.ts:304


internalLog

internalLog(message): void

Parameters

Name Type
message string

Returns

void

Inherited from

Workflow.internalLog

Defined in

src/action-manager.ts:606


internalLogError

internalLogError(err): void

Parameters

Name Type
err Error

Returns

void

Inherited from

Workflow.internalLogError

Defined in

src/action-manager.ts:615


isActionActive

isActionActive(action): boolean

Parameters

Name Type
action Action

Returns

boolean

Inherited from

Workflow.isActionActive

Defined in

src/workflow-manager.ts:156


main

main(): Promise<unknown>

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

Returns

Promise<unknown>

Inherited from

Workflow.main

Defined in

src/workflow-manager.ts:317


name

name(name): RevertAction<ActionToRevert>

Parameters

Name Type
name string

Returns

RevertAction<ActionToRevert>

Inherited from

Workflow.name

Defined in

src/workflow-manager.ts:122


next

next(cb, opts?): RevertAction<ActionToRevert>

Parameters

Name Type
cb (…args: any[]) => void | Action | Action[] | Promise<void | Action | Action[]>
opts? Object
opts.retry number

Returns

RevertAction<ActionToRevert>

Inherited from

Workflow.next

Defined in

src/workflow-manager.ts:49


onErrorGoTo

onErrorGoTo(name): RevertAction<ActionToRevert>

Parameters

Name Type
name string

Returns

RevertAction<ActionToRevert>

Inherited from

Workflow.onErrorGoTo

Defined in

src/workflow-manager.ts:151


onStateNotification

onStateNotification(actionState?): Promise<void>

Parameters

Name Type Default value
actionState ActionState ActionState.UNKNOW

Returns

Promise<void>

Inherited from

Workflow.onStateNotification

Defined in

src/action-manager.ts:487


onSuccessGoTo

onSuccessGoTo(name): RevertAction<ActionToRevert>

Parameters

Name Type
name string

Returns

RevertAction<ActionToRevert>

Inherited from

Workflow.onSuccessGoTo

Defined in

src/workflow-manager.ts:146


registerDocToSaveAtStepStart

registerDocToSaveAtStepStart(doc): void

Parameters

Name Type
doc Document<any, any, any>

Returns

void

Inherited from

Workflow.registerDocToSaveAtStepStart

Defined in

src/workflow-manager.ts:300


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.

Inherited from

Workflow.resume

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

Inherited from

Workflow.resyncWithDb

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>

Inherited from

Workflow.rollBack

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>

Inherited from

Workflow.rollBackWatcher

Defined in

src/action-manager.ts:651


rollback

rollback(cb, opts?): RevertAction<ActionToRevert>

Parameters

Name Type
cb (…args: any[]) => void | Action | Action[] | Promise<void | Action | Action[]>
opts? Object
opts.retry number

Returns

RevertAction<ActionToRevert>

Inherited from

Workflow.rollback

Defined in

src/workflow-manager.ts:113


save

save(): Promise<ActionSchemaInterface<{ actionId: string }, { actions: { [key: string]: { result: any ; state: ActionState }; } ; currentStepIndex?: number ; isRollBackPossible: boolean ; nTimesCurrentStep: number ; oldResult: any ; stepsHistory: number[] }, {}>>

Returns

Promise<ActionSchemaInterface<{ actionId: string }, { actions: { [key: string]: { result: any ; state: ActionState }; } ; currentStepIndex?: number ; isRollBackPossible: boolean ; nTimesCurrentStep: number ; oldResult: any ; stepsHistory: number[] }, {}>>

Inherited from

Workflow.save

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.
args.actionId string -

Returns

void

Inherited from

Workflow.setArgument

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

Inherited from

Workflow.setFilter

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

Inherited from

Workflow.setRepeat

Defined in

src/action-manager.ts:305


setResult

setResult(result): void

Set the result of the action.

Parameters

Name Type
result Object

Returns

void

Inherited from

Workflow.setResult

Defined in

src/action-manager.ts:329


startStep

startStep(): Promise<unknown>

Returns

Promise<unknown>

Inherited from

Workflow.startStep

Defined in

src/workflow-manager.ts:226


watcher

watcher(): Promise<ActionState>

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

Returns

Promise<ActionState>

Inherited from

Workflow.watcher

Defined in

src/workflow-manager.ts:332


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

Inherited from

Workflow.constructFromDb

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.

Inherited from

Workflow.reject

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.

Inherited from

Workflow.resolve

Defined in

src/action-manager.ts:229