Script Structure

1. Script Structure

someGlobalVar = "hello ";

function handleNode(context) {
  msg = context.getParam("msg");

  // levelops.serviceXYZ().doSomething() - invoke a levelops service

  return {
    state: "success",
    output: {
      echo: someGlobalVar + msg
    }
  };
}

2. Notes

  • The handleNode function is the entry point to the script.

  • context is an object and has methods to look-up input variables.

  • The return value is an object containing output data.

  • levelops is an object used to invoke LevelOps services.

3. Context Methods

  1. context.getParam(name, [defaultValue=null])

  2. Access the node input parameters.

  3. If not found, returns null.

  4. Not typed.

  5. context.getData(name, [defaultValue=null])

  6. Access intermediate data of the node. (useful for long running tasks where the node will wake up multiple times)

  7. If not found, returns null.

4. Output Schema

{
  state: "success" | "running" | "failure", // required
  output: { "k1" : "v" , "k2" : ["v1", "v2"], "k3" : {}} // optional, map of output variables
  data: {} // optional, node's internal data
}

Last updated