Mesa Script Specification

The most basic Mesa Script is exports a class with a script() method. The code is executed in a V8 environment and can be written in standard Javascript or ES6. The class can contain additional methods or variables.

Parameters

During runtime, the script() method will be called and passed two parameters, payload and context:

Name Type Description  
payload object The payload data  
context object Contains data relative to the current task that is running.  
context.task object Metadata about the current Task that is executing. Available on: All Inputs and Outputs.  
context.input object Metadata about the Input that triggered the Task. Available on: All Inputs. Optional
context.output object Metadata about the Output that triggered the Task. Available on: All Outputs. Optional
context.headers object The headers passed from the webhook. Available on: Shopify Webhook and JSON Webhook Inputs. Optional
context.filename object The name of the file that was read or is being saved on the FTP ServerAvailable on: FTP Inputs and FTP Outputs. Optional

Basic Mesa Script

Below is the example Mesa Script scaffold that is created when a new Script is created from the Dashboard:

const Mesa = require('./vendor/Mesa1.js');

/**
 * A Mesa Script exports a class with a script() method.
 */
module.exports = new class {

  /**
   * Mesa Script
   *
   * @param {object} payload The payload data
   * @param {object} context Additional context about this task
   */
  script = (payload, context) => {

    // Your code goes here
  }
}

What goes in each script?

Input Scripts

Output Scripts

See more example Mesa Scripts.

Naming Conventions

Input/Output keys

All lowercase alpha-numeric characters with dashes. They should be prefixed by their type. Examples:

Typically every in- key should have a corresponding out- key. Virtual Output keys should have a -vo suffix.

Script file names

All lowercase alpha-numeric characters with dashes. They should be prefixed by their type and generally match their input/output. Examples:

Secrets and Storage

All lowercase alpha-numeric characters with dashes. Storage items can have an optional .json or .liquid suffix.

Timezones

All system timezones are UTC. If you need to get dates in a different timezone, consider adding and requiring the Moment and Moment Timezone minified files in your Scripts.

Unsupported nodejs methods

Scripts are run in a stock V8 environment. This means that some common NodeJS methods are not available: