General

Summary of how to script the system.

Scripting in Exolynk

Scriptingin exolynk is done with the rune scripting language. This language can be executed inside the browser and server. Scripts which are executed in the browser frontend are called Workflows within Exolynk. Scripts which are executed in the backend on the server are called Services.

Custom script workflows and services can be either created for a specific model or as global scripts within the settings.

The oAuth2 authentification method also executes an service. After the successfull receifel of a oAuth2-key by exolynk, you can fetch aditional data from the 3rd party authentofcation system, to match the key to a specific user.

Workflows

A workflow should consist of 3 base functions. The first one is the show() function. This function should return a true when the workflow should be shown to the user and can be executed. When the function returns false or an error it will not show the workflow to a user. This function needs to be pub and is not supporting async.

pub fn show() {
    return true;
}

The main function which will be executed when a user clicks the workflow button is main(). The function can return any value and it's good practice to return ok Ok(()). This function needs to be pub and async.

pub async fn main() {
    Ok(())
}

The last base function is test(). This function is executed while developing the workflow. This function needs to be pub and async.

pub async fn test() {
    Ok(())
}

Services

Services consist only of the main() and test() functions. The test() function will be executed while developing. The main() function is called by rpc calls either from Websocket, Rest or the server itself. The amount of parametrs need to match the amount of values provided by a rpc call.

pub async fn main(number, text) {
    Ok(())
}

pub async fn test() {
    main(123, "example").await?;
    Ok(())
}

Function Trigger

Specifc workflows and services can have a trigger defined. When a specific trigger event is happening inside the system, the flagged code gets automatically executed.

  • Every Night: This trigger is called for global services every midnight
  • Every Hour: This trigger is called every houd for global services
  • Record Opened: This trigger is called whenever a record is opened for a model workflow
  • Render: These trigger functions are getting called after each other and input / output a dom element for a workflow
  • New Record: This trigger is called for newly created records for model workflows & services
  • Value Changed: This code is triggered with the old & new values of the record, when changed for model services

Service hook: update_value

This model service is called, whenever a user want's to change a value of a record. When this service is available it's responsible to apply the changes to the corresponding record. The input parameter are the ident of the value to change and the new value.

pub async fn main(ident, value) {
    let record = exo::get_record()?;
    exo::db::update_record_value(record.uuid, ident, value).await?;
    Ok(())
}

pub async fn test() {}

Dynamic Workflow Variables

Dynamic variables can trigger a workflow to calculate a value in realtime. This workflow is triggered whenever a user changes the value or on the inital rendering. These workflows need to receive to old and new variable. In addition it need to return a Value or Variable which should be rendered.

pub fn show() {
    false
}

pub async fn main(old, new) {
    "Always return this fixed string"
}

pub async fn test() {}