@onlineapps/cookbook-core
v2.1.16
Published
Core cookbook parsing and validation - lightweight foundation for workflow definitions
Maintainers
Readme
@onlineapps/cookbook-core
Core cookbook parsing and validation library - lightweight foundation for workflow definitions.
Overview
This package provides the essential parsing and validation functionality for cookbook workflow definitions. It contains no heavy dependencies and focuses purely on structural validation.
Installation
npm install @onlineapps/cookbook-coreFeatures
- JSON Schema validation - Strict schema enforcement
- Recursive step validation - All step types supported
- Unique ID validation - Ensures no duplicate step IDs
- Lightweight - ~50KB with minimal dependencies
- Zero external dependencies - Only uses
ajvfor validation
Usage
Basic parsing and validation
const {
parseCookbookFromFile,
parseCookbookFromObject,
validateCookbook
} = require('@onlineapps/cookbook-core');
// Parse from file
const cookbook = await parseCookbookFromFile('./workflow.json');
// Parse from object
const cookbookObj = parseCookbookFromObject(rawData);
// Validate only
validateCookbook(cookbookData); // throws CookbookValidationError if invalidError handling
const { CookbookValidationError } = require('@onlineapps/cookbook-core');
try {
validateCookbook(data);
} catch (error) {
if (error instanceof CookbookValidationError) {
console.error('Validation failed:', error.message);
}
}Schema access
const { CookbookSchema } = require('@onlineapps/cookbook-core');
// Access the raw JSON schema for custom validation
console.log(CookbookSchema.properties);API Reference
Parser Functions
parseCookbookFromFile(filePath)- Async file parsingparseCookbookFromFileSync(filePath)- Sync file parsingparseCookbookFromObject(object)- Object parsing
Validator Functions
validateCookbook(cookbook)- Full cookbook validationvalidateStep(step)- Single step validation
Schema Functions
loadSchema()- Load cookbook JSON schemaCookbookSchema- Pre-loaded schema object
Error Classes
CookbookValidationError- Validation error class
Step Types Supported (V2.1)
task- Service operation executionforeach- Iteration over arrays (bodyis an array of steps)fork_join- Parallel execution branches (branchesis an object)switch- Conditional branching (casesis an object keyed by value)steps- Nested group of steps (replacessub_workflow)wait- Time delay (durationMs)dispatch- Webhook/HTTP/GRPC/Kafka/SQS/custom dispatch
Documentation
- Schema Audit Report - Critical analysis of validation rules
- Test Coverage - Progressive test scenarios
Related Packages
@onlineapps/cookbook-executor- Workflow execution engine@onlineapps/cookbook-transformer- OpenAPI mapping@onlineapps/cookbook-router- Message routing@onlineapps/connector-cookbook- Full-featured wrapper for microservices
Known Issues
See Schema Audit for current validation limitations and recommendations.
License
PROPRIETARY - All rights reserved
