Step Programs

Once a step is created, it needs to be programmed to execute the intended task.

In Laminar, step logic can be programmed in various languages including:

  • Javascript

  • Python

Step Program Format

All step programs must follow a specific function signature to ensure proper execution and data flow.

Javascript

In JavaScript, your program must be a lambda function that accepts one argument, data.

(data) => {
    // Your code here to process 'data' and return an action or transformed data
    return {}; // Always return an object, even if empty
}

Javascript Available Libraries

lodash (as _) [Pre-loaded]

date-fns (format, parseISO functions) [Pre-loaded]

Python

In Python, your program must be a regular function named transform that accepts one argument, data.

Python Available Libraries

json, datetime, math, statistics, collections, itertools, functools, re, copy, decimal, csv, io, dataclasses, typing, enum

Step Program Input (Global Workflow Object)

The data input of each step program is a Global Workflow Object (GWO).

The GWO is a special object that represents the cumulative input/output state of the workflow at the runtime of the current step.

To illustrate how the GWO works, suppose a workflow has 3 steps. The JSON below illustrates what each step program would receive as input:

Example: Let's take the order fulfillment workflow from Getting Started. It has the following steps

1

Transform incoming order data (Data Transformation)

As the very first step, the step program would receive as input the following object:

2

Send transformed order data to Fulfillment Centre (HTTP Request)

Next, the step program would receive:

3

Update order status (HTTP Request)

Finally, the step program would receive:

Step Program Output

As previously stated, step programs must always return a JSON-serializable object, regardless of the program language.

Laminar uses specific keywords within the object returned by your step program to define the type of action Laminar should perform.

HTTP Step Types

When writing an HTTP Request step program, your program must include the lam.httpRequest keyword in the returned object and it must follow the structure below:

Shell Step Types

When writing an Shell step program, your program must include the lam.shell keyword in the returned object and it must follow the structure below:

Data Transformation Step Types

For data transformations, no keywords are needed. You can return any JSON object.

Editing and Saving Step Programs in Laminar

Writing step programs in Laminar is fairly straightforward.

  1. Click on a step to expand. The expand action will reveal an editor

  2. Write your step program

  3. Save your changes

Step Programs

Last updated

Was this helpful?