API Reference
Welcome to the comprehensive Cronflow API reference. This documentation covers all the classes, methods, and types available in the Cronflow library, organized by functionality.
API Structure
The Cronflow API is organized into the following categories:
Core Functions
- Core Namespace - Main entry point functions (define, start, stop, trigger, etc.)
- State Management - Global and workflow-specific state management
- Workflow Execution - Step execution and replay functions
- Human-in-the-Loop - Approval and pause management
- Trigger Management - Webhook, schedule, and manual triggers
- Event Management - Custom event handling
- Hook Management - Workflow and step hooks
- Context Management - Context object creation
- Core Status & Performance - Monitoring and benchmarking
Workflow Instance Methods
- Workflow Instance Methods - Step, action, retry, timeout, etc.
- Trigger Methods - onWebhook, onSchedule, onEvent, etc.
- Control Flow Methods - if, parallel, race, while, etc.
- Advanced Control Flow - forEach, batch, humanInTheLoop, etc.
- Workflow Management - Validation, metadata, registration
- Testing API - Test harnesses
Reference
- Context Object - Properties and state management
- Configuration - Workflow and step options
Quick Start
typescript
import { cronflow } from 'cronflow';
// Define a workflow
const workflow = cronflow.define({
id: 'my-workflow',
name: 'My Workflow',
});
// Add steps
workflow
.step('fetch-data', async ctx => {
return await fetchData(ctx.payload);
})
.action('send-notification', async ctx => {
await sendNotification(ctx.last);
});
// Start the engine
await cronflow.start();
// Trigger the workflow
await cronflow.trigger('my-workflow', { data: 'example' });
What's Next?
- Core Features - Learn about workflows, steps, and triggers
- Examples - Real-world workflow examples
- Installation - Set up Cronflow in your project