Skip to content

PIPELINE Pillar

The PIPELINE pillar provides logic composition and workflow orchestration with functional programming patterns.

Overview

The PIPELINE pillar includes 8 core methods and 5 utilities for complete workflow management:

Core Methods:

  • map() - Transform each item
  • filter() - Filter items by predicate
  • reduce() - Reduce to single value
  • compose() - Compose operations
  • chain() - Chain operations
  • branch() - Conditional branching
  • parallel() - Parallel execution
  • validate() - Validate pipeline data

Quick Start

typescript
import { pipeline, Result } from '@sanzoku-labs/kairo'

// Map transformation
const processed = pipeline.map(items, item => transform(item))

// Filter data
const filtered = pipeline.filter(items, item => item.active)

// Compose operations
const processor = pipeline.compose([
  items => pipeline.filter(items, item => item.active),
  items => pipeline.map(items, item => transform(item)),
  items => pipeline.reduce(items, (acc, item) => acc + item.value, 0)
])

Pipeline Composition

typescript
const dataProcessor = pipeline.compose([
  // Step 1: Validate input
  data => pipeline.validate(data, InputSchema),
  
  // Step 2: Transform data
  data => pipeline.map(data, item => transformItem(item)),
  
  // Step 3: Filter valid items
  data => pipeline.filter(data, item => item.isValid),
  
  // Step 4: Aggregate results
  data => data.aggregate(data, {
    groupBy: ['category'],
    sum: ['amount']
  })
])

Next Steps

Released under the MIT License.