JS API Reference

Class: WorkContext

task/work.WorkContext

Groups most common operations that the requestors might need to implement their workflows

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new WorkContext(activity, options): WorkContext

Parameters

NameType
activityActivity
optionsWorkOptions

Returns

WorkContext

Defined in

src/task/work.ts:61

Properties

provider

Readonly provider: ProviderInfo

Defined in

src/task/work.ts:55


activity

Readonly activity: Activity

Defined in

src/task/work.ts:62

Methods

before

before(): Promise<void | Result<any>[]>

Returns

Promise<void | Result<any>[]>

Defined in

src/task/work.ts:75


run

run(commandLine, options?): Promise<Result<any>>

Execute a command on provider using a shell (/bin/sh).

Parameters

NameTypeDescription
commandLinestringShell command to execute.
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:172

run(executable, args, options?): Promise<Result<any>>

Execute an executable on provider.

Parameters

NameTypeDescription
executablestringExecutable to run.
argsstring[]Executable arguments.
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:181


spawn

spawn(commandLine, options?): Promise<RemoteProcess>

Parameters

NameType
commandLinestring
options?Omit<CommandOptions, "capture">

Returns

Promise<RemoteProcess>

Deprecated

Use WorkContext.runAndStream instead

Defined in

src/task/work.ts:199

spawn(executable, args, options?): Promise<RemoteProcess>

Parameters

NameType
executablestring
argsstring[]
options?CommandOptions

Returns

Promise<RemoteProcess>

Deprecated

Use WorkContext.runAndStream instead

Defined in

src/task/work.ts:201


runAndStream

runAndStream(commandLine, options?): Promise<RemoteProcess>

Run an executable on provider and return RemoteProcess that will allow streaming that contain stdout and stderr as Readable

Parameters

NameTypeDescription
commandLinestringShell command to execute.
options?Omit<CommandOptions, "capture">Additional run options.

Returns

Promise<RemoteProcess>

Defined in

src/task/work.ts:218

runAndStream(executable, args, options?): Promise<RemoteProcess>

Parameters

NameTypeDescription
executablestringExecutable to run.
argsstring[]Executable arguments.
options?CommandOptionsAdditional run options.

Returns

Promise<RemoteProcess>

Defined in

src/task/work.ts:224


transfer

transfer(from, to, options?): Promise<Result<any>>

Generic transfer command, requires the user to provide a publicly readable transfer source

Parameters

NameTypeDescription
fromstringpublicly available resource for reading. Supported protocols: file, http, ftp or gftp
tostringfile path
options?CommandOptionsAdditional run options.

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:266


uploadFile

uploadFile(src, dst, options?): Promise<Result<any>>

Parameters

NameType
srcstring
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:271


uploadJson

uploadJson(json, dst, options?): Promise<Result<any>>

Parameters

NameType
jsonany
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:277


uploadData

uploadData(data, dst, options?): Promise<Result<any>>

Parameters

NameType
dataUint8Array
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:283


downloadFile

downloadFile(src, dst, options?): Promise<Result<any>>

Parameters

NameType
srcstring
dststring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:288


downloadData

downloadData(src, options?): Promise<Result<Uint8Array>>

Parameters

NameType
srcstring
options?CommandOptions

Returns

Promise<Result<Uint8Array>>

Defined in

src/task/work.ts:293


downloadJson

downloadJson(src, options?): Promise<Result<any>>

Parameters

NameType
srcstring
options?CommandOptions

Returns

Promise<Result<any>>

Defined in

src/task/work.ts:299


beginBatch

beginBatch(): Batch

Returns

Batch

Defined in

src/task/work.ts:315


getWebsocketUri

getWebsocketUri(port): string

Provides a WebSocket URI that allows communicating with a remote process listening on the target port

Parameters

NameTypeDescription
portnumberThe port number used by the service running within an activity on the provider

Returns

string

Defined in

src/task/work.ts:324


getIp

getIp(): string

Returns

string

Defined in

src/task/work.ts:337


createTcpProxy

createTcpProxy(portOnProvider): TcpProxy

Creates a new TCP proxy that will allow tunnelling the TPC traffic from the provider via the requestor

Parameters

NameTypeDescription
portOnProvidernumberThe port that the service running on the provider is listening to

Returns

TcpProxy

Defined in

src/task/work.ts:354


getState

getState(): Promise<ActivityStateEnum>

Returns

Promise<ActivityStateEnum>

Defined in

src/task/work.ts:360