@openworkspace/pipeline
v0.1.1
Published
YAML workflow engine with expressions, forEach, parallel, and retries
Downloads
176
Maintainers
Readme
@openworkspace/pipeline
YAML workflow engine with expressions, forEach, parallel, and retries.
Part of the OpenWorkspace monorepo.
Install
npm install @openworkspace/pipeline @openworkspace/coreUsage
YAML Pipeline
name: daily-report
steps:
- id: emails
action: gmail.search
params:
query: "is:unread after:{{ today }}"
- id: notify
action: gmail.send
forEach: "{{ steps.emails.result.messages }}"
params:
to: [email protected]
subject: "FW: {{ item.subject }}"
body: "{{ item.snippet }}"
- id: backup
action: drive.upload
parallel:
- params: { name: "report-a.pdf", content: "{{ steps.genA.result }}" }
- params: { name: "report-b.pdf", content: "{{ steps.genB.result }}" }TypeScript API
import { parseYaml, executePipeline, createContext, createBuiltinActions } from '@openworkspace/pipeline';
import { createHttpClient } from '@openworkspace/core';
const http = createHttpClient({ auth: { accessToken: 'token' } });
const yaml = parseYaml(yamlString);
const actions = createBuiltinActions(http);
const ctx = createContext({ today: '2025-01-15' });
const result = await executePipeline(yaml, ctx, actions);
if (result.ok) {
console.log('Pipeline completed:', result.value);
}API
parseYaml(str)-- Parse YAML string into a pipeline definitionexecutePipeline(pipeline, context, actions)-- Execute a pipelinecreateContext(vars)-- Create an execution context with variablescreateBuiltinActions(http)-- Register built-in service actionsevaluateExpression(expr, context)-- Evaluate a{{ }}expressioncreatePipelineBuilder()-- Fluent builder for pipelines
Features
- Expressions --
{{ steps.id.result.field }}interpolation - forEach -- Iterate over arrays from previous steps
- parallel -- Run multiple variants of a step concurrently
- Retries -- Configurable retry with backoff per step
- Conditions --
when: "{{ steps.check.result.count > 0 }}"guards
