Function Operation

The Function operation executes JavaScript/TypeScript code synchronously via the Function Service. Functions return results directly and are ideal for custom business logic that cannot be expressed in GraphQL, data transformations, integration with external APIs, and complex calculations.

For more details on writing functions, refer to the Function Service documentation.

Configuration Example

executor_function.tf

resource "tailor_executor" "function_executor" {
  workspace_id = tailor_workspace.ims.id
  name         = "function-executor"
  description  = "Execute synchronous function"

  trigger = {
    # Choose one of the trigger types:
    # event = { ... }
    # webhook = { ... }
    # schedule = { ... }
  }

  operation = {
    function = {
      name      = "processData"
      script    = file("${path.module}/scripts/process_data.js")
      variables = <<EOF
        ({
           "data": args.record,
           "timestamp": (new Date()).toISOString()
        }) 
      EOF
    }
  }
}
#functionExecutor: executor.#Executor & {
  Name:        "function-executor"
  Description: "Execute synchronous function"
  Trigger: {
    // Choose one of the trigger types:
    // executor.#TriggerEvent & { ... }
    // executor.#TriggerIncomingWebhook & { ... }
    // executor.#TriggerSchedule & { ... }
  }
  Target: executor.#TargetFunction & {
    Name:       "processData"
    ScriptPath: "script/process_data.js"
    Variables: common.#Script & {
      Expr: """
      ({
         "data": args.record,
         "timestamp": (new Date()).toISOString()
      })
      """
    }
  }
}

Properties

Executor Properties

PropertyTypeRequiredDescription
namestringYesThe name of the executor. The name field has the validation rule ^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$, and it does not allow capital letters
workspace_idstringYesThe ID of the workspace that the executor namespace belongs to
descriptionstringNoThe description of the executor
triggerobjectYesThe type of trigger (webhook, event, or schedule)

Function Operation Properties

PropertyTypeSupports ScriptingRequiredDescription
namestring-YesThe name of the function
scriptstring-YesThe JavaScript/TypeScript code to execute
invokerobject-NoThe invoker of the operation
variablesstringJavaScript / CELNoThe variables to pass to the function. Can access trigger-specific data via args object

Executor Properties

PropertyTypeRequiredDescription
NamestringYesThe name of the executor. The name field has the validation rule ^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]$, and it does not allow capital letters
DescriptionstringNoThe description of the executor
TriggerobjectYesThe type of trigger (e.g., #TriggerIncomingWebhook, #TriggerEvent, #TriggerSchedule)

TargetFunction Properties

PropertyTypeSupports ScriptingRequiredDescription
Namestring-YesThe name of the function
ScriptPathstring-YesThe path to the JavaScript/TypeScript script file
Invokerobject-NoThe invoker of the operation
VariablesstringJavaScript / CELNoThe variables to pass to the function. Can access trigger-specific data via args object

Related Documentation