Skip to main content

Class: TrackPromise

Defined in: core/actions/src/workflow-manager.ts:867

Structure actions.

Extends this class to build new actions behaviors.

Extends​

Constructors​

Constructor​

new TrackPromise(): TrackPromise

Defined in: core/actions/src/action-manager.ts:201

Returns​

TrackPromise

Inherited from​

Action.constructor

Properties​

dbDoc​

dbDoc: ActionSchemaInterface<JSONObject, { cbReturnAnAction: boolean; trackActionId: string; }, void | Error | JSONObject>

Defined in: core/actions/src/action-manager.ts:106

Action Database Document

Inherited from​

Action.dbDoc


executor?​

optional executor: Executor

Defined in: core/actions/src/action-manager.ts:40

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

Inherited from​

Action.executor


getPromiseLauncher()​

getPromiseLauncher: () => () => Promise<any>

Defined in: core/actions/src/workflow-manager.ts:873

Returns​

(): Promise<any>

Returns​

Promise<any>


IArgument​

IArgument: JSONObject

Defined in: core/actions/src/action-manager.ts:91

Action argument

Inherited from​

Action.IArgument


IBag​

IBag: object

Defined in: core/actions/src/workflow-manager.ts:868

Action bag

cbReturnAnAction​

cbReturnAnAction: boolean

trackActionId​

trackActionId: string

Overrides​

Action.IBag


IResult​

IResult: void | Error | JSONObject

Defined in: core/actions/src/action-manager.ts:101

Action result

Inherited from​

Action.IResult


isExecutorSet​

isExecutorSet: boolean = false

Defined in: core/actions/src/action-manager.ts:497

Inherited from​

Action.isExecutorSet


isInitialized​

isInitialized: boolean = false

Defined in: core/actions/src/action-manager.ts:482

Inherited from​

Action.isInitialized


notifyHealthPromise​

notifyHealthPromise: Promise<any> = undefined

Defined in: core/actions/src/action-manager.ts:945

Send a signal to indicate that the action is still in progress.. Useful for preventing timeouts when the action's duration is long but not precisely predictable.

Inherited from​

Action.notifyHealthPromise


runtime​

runtime: ActionRuntime = ActionRuntime.activeRuntime

Defined in: core/actions/src/action-manager.ts:42

Inherited from​

Action.runtime


subAction​

subAction: Action

Defined in: core/actions/src/workflow-manager.ts:875


cronDefaultSettings​

static cronDefaultSettings: object

Defined in: core/actions/src/action-manager.ts:82

Configure the frequency at which a cron will launch Action.resume. It is also possible to dynamically modify the dbDoc.cronActivity property to modify the call to a cron. If not set, this property will be 'inherited' from the first parent class where it is.

activityFrequency​

activityFrequency: number

Inherited from​

Action.cronDefaultSettings


defaultDelay​

static defaultDelay: number

Defined in: core/actions/src/action-manager.ts:49

Shortcut to [ActionState.IN_PROGRESS].

If not set, this property will be 'inherited' from the first parent class where it is.

Inherited from​

Action.defaultDelay


defaultDelays​

static defaultDelays: object

Defined in: core/actions/src/action-manager.ts:70

For the states ActionState.EXECUTING_MAIN and ActionState.IN_PROGRESS, this object configures 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.

1?​

optional 1: number

2?​

optional 2: number

Default Value​

{
[ActionState.IN_PROGRESS]: this.defaultDelay,
[ActionState.EXECUTING_MAIN]: 2*60*1000,
}

You should configure this if your actions have longer timeouts.

If not set, this property will be 'inherited' from the first parent class where it is.

Inherited from​

Action.defaultDelays


permanentRef​

static permanentRef: string | string[]

Defined in: core/actions/src/action-manager.ts:35

Id of the action stored in database. It should be a permanent id that designates the action instance.

Inherited from​

Action.permanentRef

Accessors​

_id​

Get Signature​

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

Defined in: core/actions/src/action-manager.ts:157

Returns​

this["dbDoc"]["_id"]

Inherited from​

Action._id


argument​

Get Signature​

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

Defined in: core/actions/src/action-manager.ts:121

Returns​

this["dbDoc"]["argument"]

Set Signature​

set argument(argument): void

Defined in: core/actions/src/action-manager.ts:125

Parameters​
argument​

this["dbDoc"]["argument"]

Returns​

void

Inherited from​

Action.argument


bag​

Get Signature​

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

Defined in: core/actions/src/action-manager.ts:112

Returns​

this["dbDoc"]["bag"]

Set Signature​

set bag(bag): void

Defined in: core/actions/src/action-manager.ts:116

Parameters​
bag​

this["dbDoc"]["bag"]

Returns​

void

Inherited from​

Action.bag


cronActivity​

Get Signature​

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

Defined in: core/actions/src/action-manager.ts:148

Returns​

this["dbDoc"]["cronActivity"]

Set Signature​

set cronActivity(cronActivity): void

Defined in: core/actions/src/action-manager.ts:152

Parameters​
cronActivity​

this["dbDoc"]["cronActivity"]

Returns​

void

Inherited from​

Action.cronActivity


repeat​

Get Signature​

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

Defined in: core/actions/src/action-manager.ts:139

Returns​

this["dbDoc"]["repeat"]

Set Signature​

set repeat(repeat): void

Defined in: core/actions/src/action-manager.ts:143

Parameters​
repeat​

this["dbDoc"]["repeat"]

Returns​

void

Inherited from​

Action.repeat


result​

Get Signature​

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

Defined in: core/actions/src/action-manager.ts:130

Returns​

this["dbDoc"]["result"]

Set Signature​

set result(result): void

Defined in: core/actions/src/action-manager.ts:134

Parameters​
result​

this["dbDoc"]["result"]

Returns​

void

Inherited from​

Action.result

Methods​

_resume()​

_resume(): any

Defined in: core/actions/src/action-manager.ts:636

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​

Action._resume


activityLogs()​

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

Defined in: core/actions/src/action-manager.ts:790

Parameters​

options​

any

Returns​

any[] | Promise<any[]>

Inherited from​

Action.activityLogs


clone()​

clone(): any

Defined in: core/actions/src/action-manager.ts:914

Clone the action.

Returns​

any

a new action with the same argument

Inherited from​

Action.clone


dynamicallyDefineFromWorkflowStep()​

dynamicallyDefineFromWorkflowStep(workflow, marker): void

Defined in: core/actions/src/action-manager.ts:312

Parameters​

workflow​

Workflow

marker​

string

Returns​

void

Inherited from​

Action.dynamicallyDefineFromWorkflowStep


getLogs()​

getLogs(options): Promise<any[]>

Defined in: core/actions/src/action-manager.ts:794

Parameters​

options​
endTime?​

number

Returns​

Promise<any[]>

Inherited from​

Action.getLogs


init()​

init(): Promise<any>

Defined in: core/actions/src/action-manager.ts:398

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>

Inherited from​

Action.init


initialization()​

initialization(): Promise<void>

Defined in: core/actions/src/action-manager.ts:489

Mainly used for workflows. Can also complement init(). If it gets too complex, use hooks.

Returns​

Promise<void>

Inherited from​

Action.initialization


internalLog()​

internalLog(message, opts): void

Defined in: core/actions/src/workflow-manager.ts:894

Log a message in the internal logger.

Parameters​

message​

string

The message to log.

opts​

Options for logging, such as the log level. the final log message will be:

{
actionRef: this.dbDoc.actionRef,
actionId: this.dbDoc._id.toString(),
filter: this.dbDoc.filter,
definedIn: this.dbDoc.definitionFrom.workflow?.toObject(),
timestamp: new Date().toISOString(),
level: opts.level || 'info',
message: message,
}
level​

string = 'debug'

Returns​

void

Overrides​

Action.internalLog


internalLogError()​

internalLogError(err): void

Defined in: core/actions/src/action-manager.ts:890

Log an error in the internal logger.

Parameters​

err​

Error

The error to log. the final log message will be:

{
actionRef: this.dbDoc.actionRef,
actionId: this.dbDoc._id.toString(),
filter: this.dbDoc.filter,
definedIn: this.dbDoc.definitionFrom.workflow?.toObject(),
err: err,
timestamp: new Date().toISOString(),
}

Returns​

void

Inherited from​

Action.internalLogError


main()​

main(): Promise<ActionState>

Defined in: core/actions/src/workflow-manager.ts:877

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

Returns​

Promise<ActionState>

Overrides​

Action.main


notifyHealth()​

notifyHealth(): Promise<any>

Defined in: core/actions/src/action-manager.ts:946

Returns​

Promise<any>

Inherited from​

Action.notifyHealth


onMainTimeout()​

onMainTimeout(): ActionState | Promise<ActionState>

Defined in: core/actions/src/workflow-manager.ts:886

Called in case of timeout in ActionState.EXECUTING_MAIN state.

It can return ActionState.SLEEPING if the process infers that main() has not run and the action must be retried.

Returns​

ActionState | Promise<ActionState>

a ActionState value.

Overrides​

Action.onMainTimeout


resume()​

resume(): Promise<any>

Defined in: core/actions/src/action-manager.ts:605

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<any>

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

Inherited from​

Action.resume


resyncWithDb()​

resyncWithDb(): Promise<void>

Defined in: core/actions/src/action-manager.ts:327

Update the current model instance with latest data from database

Returns​

Promise<void>

a promise that resolves when the document has been loaded

Inherited from​

Action.resyncWithDb


save()​

save(): Promise<ActionSchemaInterface<JSONObject, { cbReturnAnAction: boolean; trackActionId: string; }, void | Error | JSONObject>>

Defined in: core/actions/src/action-manager.ts:165

Save an action in the database. Will then be managed by the worker.

Returns​

Promise<ActionSchemaInterface<JSONObject, { cbReturnAnAction: boolean; trackActionId: string; }, void | Error | JSONObject>>

a promise that resolves when the action has been saved

Inherited from​

Action.save


setArgument()​

setArgument(args): TrackPromise

Defined in: core/actions/src/action-manager.ts:407

Set the argument that will be stored in the database. Once set, the argument of an action should not be modified.

Parameters​

args​

JSONObject

The argument to set.

Returns​

TrackPromise

Inherited from​

Action.setArgument


setExecutor()​

setExecutor(): void | Executor | Promise<void | Executor>

Defined in: core/actions/src/action-manager.ts:516

Set the executor for this action. It is called only once when the action is created. If you want to set an executor, you should override this method.

Returns​

void | Executor | Promise<void | Executor>

a promise that resolves when you have set the executor is set

Inherited from​

Action.setExecutor


setFilter()​

setFilter(filter): TrackPromise

Defined in: core/actions/src/action-manager.ts:438

Make filtering actions easier with the filter property. These filters are stored in database with the filter property and allow to search for an action or a group of actions

Parameters​

filter​

Object

Returns​

TrackPromise

Inherited from​

Action.setFilter


setRepeat()​

setRepeat(opts): TrackPromise

Defined in: core/actions/src/action-manager.ts:422

Configure the number of times an action is repeated.

Parameters​

opts​
4?​

number

5?​

number

Returns​

TrackPromise

Inherited from​

Action.setRepeat


setResult()​

setResult(...results): TrackPromise

Defined in: core/actions/src/action-manager.ts:448

Set the action result.

Parameters​

results​

...any[]

Returns​

TrackPromise

Inherited from​

Action.setResult


watcher()​

watcher(): Promise<ActionState>

Defined in: core/actions/src/workflow-manager.ts:890

Watch the action state.

It is called :

  • potentially many times when the action is in IN_PROGRESS state
  • one time if the action is in EXECUTING_MAIN state and the executing_main delay has expired.

Returns​

Promise<ActionState>

promise

Overrides​

Action.watcher


_constructFromDb()​

static _constructFromDb(actionDb): Action

Defined in: core/actions/src/action-manager.ts:256

Construct an action from a document stored in the database.

Parameters​

actionDb​

ActionSchemaInterface<any>

a document coming from the database

Returns​

Action

an action for which dbDoc property is equal to actionDb

Inherited from​

Action._constructFromDb


_constructFromWorkflow()​

static _constructFromWorkflow(dbDoc): Promise<Action>

Defined in: core/actions/src/action-manager.ts:281

Construct an action from a document stored in the database and whose definition depends on a workflow.

Parameters​

dbDoc​

ActionSchemaInterface<any>

Returns​

Promise<Action>

an action for which dbDoc property is equal to actionDb

Inherited from​

Action._constructFromWorkflow


constructFromDb()​

static constructFromDb(actionDb): Promise<Action>

Defined in: core/actions/src/action-manager.ts:304

Construct an action from a document stored in the database.

Parameters​

actionDb​

ActionSchemaInterface<any>

a document coming from the database

Returns​

Promise<Action>

an action for which dbDoc property is equal to actionDb

Inherited from​

Action.constructFromDb


reject()​

static reject(result?): RejectAction

Defined in: core/actions/src/action-manager.ts:355

Return a new RejectAction object.

Parameters​

result?​

any

action result

Returns​

RejectAction

new RejectActioninstance

Inherited from​

Action.reject


resolve()​

static resolve(result?): ResolveAction

Defined in: core/actions/src/action-manager.ts:344

Return a new ResolveAction object.

Parameters​

result?​

any

action result

Returns​

ResolveAction

new ResolveActioninstance

Inherited from​

Action.resolve


trackActionAsPromise()​

static trackActionAsPromise(action, states): Promise<unknown>

Defined in: core/actions/src/action-manager.ts:926

Track an action until it reaches one of the given states.

Parameters​

action​

Action

The action to track.

states​

ActionState[] = ...

The states to reach.

Returns​

Promise<unknown>

A promise that resolves when the action reaches one of the given states. The promise resolves with the state reached.

Inherited from​

Action.trackActionAsPromise