Skip to main content

Secure data transformation tool supporting JQ and JavaScript (Bun)

Project description

LAM

LAM is a data transformation tool designed for Laminar's API integration platform.

Overview

LAM enables you to write efficient transformations for your API data using either JavaScript (Bun) or Python. It's designed to be secure, fast, and easy to integrate into your Laminar workflows.

Features

  • Dual Engine Support: Choose between JavaScript (Bun runtime) for fast execution or Python for complex data processing
  • Built-in Libraries: Access lodash and date-fns in JavaScript, comprehensive Python standard library modules
  • Security: Runs in sandboxed environments with strict resource limits and security restrictions
  • Performance: Uses Bun runtime for JavaScript and sandboxed Python interpreter
  • Monitoring: Built-in execution statistics and error tracking

Execution Environments

Bun JavaScript Runtime (js)

Configuration:

  • Engine: Bun
  • Timeout: 5 seconds
  • Execution: Isolated with --no-fetch --smol --silent flags
  • Storage: No localStorage/sessionStorage support
  • Modules: Shared node_modules directory

Available Libraries:

  • lodash (^4.17.21): Utility library for array/object manipulation, data transformations (Global: _)
  • date-fns (^2.30.0): Modern date utility library with format, parseISO functions

Transform Function Signature:

(input) => { /* transform logic */ return result; }

Python Interpreter with Sandboxing (py)

Configuration:

  • Engine: Python interpreter
  • Timeout: 5 seconds
  • Memory Limit: 100MB
  • CPU Limit: 5 seconds (RLIMIT_CPU)
  • Virtual Memory: 100MB (RLIMIT_AS)
  • Execution: Isolated with -I flag (ignores environment/site packages)

Security Restrictions:

  • Blocked Modules: subprocess, sys, os, shutil, pathlib, importlib, builtins, _thread, ctypes, socket, pickle, multiprocessing
  • Blocked Functions: import, eval, exec, globals, locals, getattr, setattr, delattr, compile, open
  • Blocked Patterns: subclasses, dunder attributes access

Available Standard Library Modules:

  • json: JSON encoder and decoder
  • datetime: Date and time handling
  • time: Time-related functions
  • math: Mathematical functions and constants
  • statistics: Statistical functions (mean, median, mode, standard deviation)
  • collections: Counter, defaultdict, OrderedDict, deque
  • itertools: Efficient looping, combinations, permutations
  • functools: reduce, partial, lru_cache
  • re: Regular expression operations
  • copy: Shallow and deep copy operations
  • decimal: Precise decimal calculations
  • csv: CSV file reading and writing
  • io: StringIO, BytesIO for in-memory files
  • dataclasses: Data classes for storing data
  • typing: Type hints support
  • enum: Support for enumerations
  • random: Random number generation
  • uuid: UUID generation
  • hashlib: Secure hash and message digest algorithms
  • base64: Base64 encoding and decoding
  • urllib: URL handling modules
  • urllib.parse: URL parsing utilities
  • html: HTML processing utilities
  • xml: XML processing
  • xml.etree: XML ElementTree API
  • xml.etree.ElementTree: XML parsing and creation
  • string: String constants and classes
  • textwrap: Text wrapping and filling
  • operator: Standard operators as functions
  • bisect: Array bisection algorithm
  • heapq: Heap queue algorithm
  • array: Efficient arrays of numeric values
  • unicodedata: Unicode character database
  • locale: Internationalization services
  • calendar: Calendar-related functions
  • zoneinfo: Time zone support (Python 3.9+)
  • struct: Pack and unpack binary data
  • binascii: Binary/ASCII conversions
  • codecs: Encode and decode data
  • difflib: Sequence comparison utilities
  • pprint: Pretty-printer for data structures
  • reprlib: Alternate repr() implementation
  • abc: Abstract base classes
  • contextlib: Context management utilities
  • secrets: Cryptographically secure random numbers
  • fractions: Rational numbers
  • numbers: Numeric abstract base classes

Safe Built-in Functions: abs, all, any, bool, chr, dict, divmod, enumerate, filter, float, format, frozenset, hash, hex, int, isinstance, issubclass, iter, len, list, map, max, min, next, oct, ord, pow, print, range, repr, reversed, round, set, slice, sorted, str, sum, tuple, type, zip

Transform Function Signature:

def transform(input_data):
    # transform logic
    return result

Examples

JavaScript (Bun) Transformations

Perfect for fast data manipulation with familiar syntax:

(input) => {
    // Use lodash for data manipulation
    const processed = _.map(input.data, item => ({
        id: item.id,
        formattedDate: format(parseISO(item.date), 'MMM dd, yyyy'),
        value: item.value * 2
    }));

    return {
        processed,
        summary: {
            total: _.sumBy(processed, 'value'),
            count: processed.length
        }
    };
}

Python Transformations

Ideal for complex data processing and statistical analysis:

def transform(input_data):
    import statistics
    from collections import Counter
    
    # Process numerical data
    values = [item["value"] for item in input_data["data"] if "value" in item]
    
    return {
        "statistics": {
            "mean": statistics.mean(values) if values else 0,
            "median": statistics.median(values) if values else 0,
            "count": len(values)
        },
        "frequency": dict(Counter(item["category"] for item in input_data["data"])),
        "processedAt": datetime.now().isoformat()
    }

Integration with Laminar

LAM is designed to work seamlessly with Laminar's integration platform:

  1. Flows: Add data transformations to your API flows
  2. Automation: Schedule and automate data processing
  3. Monitoring: Track execution statistics and errors

Getting Started

Using LAM in Laminar

  1. Create a new flow in Laminar
  2. Add a transformation step
  3. Choose your engine (JavaScript or Python)
  4. Write your transformation function
  5. Deploy and monitor

Resources

Support

Get help with LAM:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lam_cli-1.0.1.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lam_cli-1.0.1-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file lam_cli-1.0.1.tar.gz.

File metadata

  • Download URL: lam_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 39.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lam_cli-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2f87fbf80f2dd234ea6b447addc952ef9ec425a9b327ed654a86d6f4a6c6eee5
MD5 b099b4c46736b130daa618734652ba74
BLAKE2b-256 41607f9c14817a30d2f84da911bd035d7d594ed6b27c519adfce0cec21935a15

See more details on using hashes here.

Provenance

The following attestation bundles were made for lam_cli-1.0.1.tar.gz:

Publisher: publish.yml on laminar-run/lam-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lam_cli-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: lam_cli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lam_cli-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cd1c99a1ac91cce26db81186a7f9aed7f0909acaa4bb3c74354f8a13410ea54
MD5 d8df069c2f97c9973ad48456af88e48c
BLAKE2b-256 a50e902fd9d1801020969957a5d072ed40e324e60c00ef65577a13031e8a690a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lam_cli-1.0.1-py3-none-any.whl:

Publisher: publish.yml on laminar-run/lam-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page