Laminar
  • Laminar
  • Platform
    • Overview
    • Getting Started
    • Advanced
      • Configurations
      • HTTP Request Batching
      • Workflow Exit Points
      • Invoke Secondary Workflows
      • Managing Notifications
    • Best Practices
    • Keywords
      • lam.resolveThenExecute
      • lam.exit
      • lam.execute
      • lam.asyncExecute
      • lam.httpRequest
      • lam.httpRequests
  • Concepts
    • Workflows
      • Global Workflow Object
    • Flows
      • Flow Types
        • HTTP Request
        • Data Transformations
      • Flow Runs
      • Supported Languages
    • API Key
    • Configurations
    • API
      • Reference
        • Workspaces
          • Issues
          • Users
          • Invitations
            • Decline
            • Accept
            • Received
            • Created
          • Workflows
          • Flows
          • Auth credentials
          • Api keys
          • Api descriptions
        • Workflow
          • Execute
            • External
          • Flows
          • Executions
        • Users
        • Flows
          • Runs
          • Versions
          • Stats
          • Recent runs
          • Read
        • Configurations
          • Properties
          • Flow credentials
          • Workspace
        • Auth credentials
        • Api descriptions
        • Api keys
        • Transform
          • Test
        • Lami
          • Public
          • Direct
        • Auth
          • Signin
          • Register
          • Refresh
          • Me
          • Users
            • Password
    • Changelog
  • External Links
    • Book a Demo
    • Playground
    • Sign In
  • Specification
Powered by GitBook
On this page
  • Overview
  • JavaScript
  • JQ
  • Choosing a Language

Was this helpful?

  1. Platform

Languages

Learn about Languages in Laminar

Overview

Laminar supports both JavaScript and JQ for writing flow transformations. Each language has its own strengths and use cases.

JavaScript

JavaScript transformations use a simple function pattern:

(payload) => {
  // Access data from previous steps or input
  const { input, step_1 } = payload;
  
  // Perform transformations
  const transformed = {
    // ... transformation logic
  };
  
  // Return result object
  return {
    "data": transformed,
    // Optional Laminar keywords
    "lam.httpRequest": {/*...*/}
  };
}

Advantages

  • Familiar syntax for most developers

  • Rich ecosystem of npm packages

  • Native JSON handling

  • Powerful array/object manipulation

Example Transformation

(payload) => {
  const { step_1 } = payload;
  
  // Filter users who spent over $20
  const highValueUsers = step_1.data.users
    .filter(user => user.totalSpent > 20)
    .map(user => ({
      "lam.workflowId": 49,
      "lam.payload": {
        "lam.queryParams": {
          "email": user.email
        },
        "lam.body": user
      }
    }));

  return {
    "lam.result": highValueUsers
  };
}

JQ

JQ is a lightweight, powerful language specifically designed for JSON processing:

# Access input data using dot notation
.input | 
# Transform using JQ operators
map(select(.totalSpent > 20)) |
# Output transformed data
{
  "lam.result": .
}

Advantages

  • Concise syntax for JSON manipulation

  • Powerful built-in functions

  • Excellent performance for JSON processing

  • Native streaming support

Example Transformation

.step_1.data.users |
map(
  select(.totalSpent > 20) |
  {
    "lam.workflowId": 49,
    "lam.payload": {
      "lam.queryParams": {
        "email": .email
      },
      "lam.body": .
    }
  }
)

Choosing a Language

  • Choose JavaScript when:

    • You need complex business logic

    • Your team is more familiar with JavaScript

    • You want to use npm packages

    • You need advanced string/array operations

  • Choose JQ when:

    • You're primarily doing JSON transformation

    • You want concise, readable transformations

    • Performance is critical

    • You're working with streaming data

Last updated 2 months ago

Was this helpful?