Skip to main content
Version: v5.0

IafScriptEngine Overview

Platform API allows users to write their own scripts carefully (in Javascript) and store onto the system to use. May it be data analytics, queries, or setup your own environment, IafScriptEngine empowers users to accomplish their tasks with flexibility and convenience.

More specifically, IafScriptEngine is the core of this powerful tool. It provides dynamic import features and utility functions for extensibility.

Storing scripts#

Scripts are saved onto Item Service and usually identified by _userType or _id.

A script file has to be a module or class. Below is an example. Just like a regular ES module, you can choose to have a default import or no. Either way is fine.

let UserGroupScripts = {  async getUserGroups(PlatformApi, ctx){    let proj = await PlatformApi.IafProj.getCurrent(ctx)    console.log("project: " + proj)    let res = await PlatformApi.IafProj.getUserGroups(proj, ctx)    console.log("In UserGroupScripts, res: " + res)    return res  }
}
export default UserGroupScripts

File Service#

In our eco system, we have both Node.js and browser apps utilizing file upload features. Please include tus-js-client npm package in your package.json when utilizing file upload features. Within tus-js-client it will determine what environment it is in (node or browser) and perform accordingly.

For more details on how to use the script engine in Node.js and browser apps, please go to the following section:

Apps Setup#

Node.js Apps

Browser Apps