Functions

Function implement logic of Membrane Interfaces.

Think of functions as pieces of code that run inside Membrane and have access to the current customer, API credentials, and other integrations-related context.

In many cases functions are pieces of Javascript/Typescript code that looks like this:

module.exports = async function(args) {
   console.log('I am a log')
   retunr 'I am function output'
}

Besides JavaScript, there are many possible function types that are typically defined in YAML. They are created to simplify the integration logic as much as possible and reduce the possibility of errors, especially when generated by AI.

Functions Types

Functions can be implemented in one of the following ways depending on where the function is used:

  • Mapping – Transform input data using JSONata expressions without making API calls
  • REST API Mapping – Map to REST API endpoints
  • JavaScript – Write custom code for maximum flexibility
  • not-supported – Mark function as not supported by the external API (to distinguish it from "it's unknown if it's supported or not" when the type is simply empty).