Skip to main content

Script API reference

In scripts, the definitions below are available through the kreya object. Additionally all general Kreya APIs and bundled modules are available, see general script API reference.

kreya.trace('Starting script invocation of ' + kreya.script.current.name);

await kreya.invokeOperation('my-gRPC-operation');

let success = false;
while (!success) {
const result = await kreya.invokeOperation('my-rest-operation');
success = result.success;

await kreya.wait(100);
}

Variables​

script​

const script: InvokerScriptContainerScriptApi;

InvokerScriptContainerScriptApi
Kreya scripting API for scripts.

Functions​

invokeOperation()​

function invokeOperation(operationPath: string): Promise<ScriptOperationResult>;

Invoke an operation.

Parameters​

ParameterTypeDescription
operationPathstringThe path of the operation to invoke. Must be relative to the script.

Returns​

Promise<ScriptOperationResult>

Returns the result of the operation invocation.

Type Aliases​

InvokerScriptContainerScriptApi​

type InvokerScriptContainerScriptApi = {
current: InvokerScriptCurrentScriptApi;
};

Kreya scripting API for scripts.

Properties​

current​
readonly current: InvokerScriptCurrentScriptApi;

The current script.


InvokerScriptCurrentScriptApi​

type InvokerScriptCurrentScriptApi = {
name: string;
};

APIs to access a script.

Properties​

name​
readonly name: string;

The name of the script.


ScriptOperationResult​

type ScriptOperationResult = {
status?: ScriptOperationStatus;
success: boolean;
};

The result of an operation invocation.

Properties​

status?​
optional status?: ScriptOperationStatus;

Detailed information about the response status.

success​
success: boolean;

If the operation contains tests, this returns true if all tests were successful. If the operation does not contain tests, this returns true if the response status code indicates success.


ScriptOperationStatus​

type ScriptOperationStatus = {
code: number;
detailMessage?: string;
statusName: string;
success: boolean;
};

The status of an operation response.

Properties​

code​
code: number;

The response status code, ex. 200 for a successful REST response.

detailMessage?​
optional detailMessage?: string;

An optional detail message about the status, received from the server.

statusName​
statusName: string;

The response status name, ex. OK for a successful REST response.

success​
success: boolean;

True if the status indicates success.