This is a TypeScript port of the Python recipe validator from workato-platform-cli.
# Install dependencies
npm install
# Build the TypeScript code
npm run build# Show help
npm run cli -- --help
# Validate a recipe
npm run cli -- -i sample-recipe.json
# Validate with verbose output
npm run cli -- -i sample-recipe.json -v
# Validate and save JSON results
npm run cli -- -i sample-recipe.json -f json -o results.json
# Validate with summary format (great for batch processing)
npm run cli -- -i sample-recipe.json -f summarySee CLI_USAGE.md for complete CLI documentation.
# Run the example directly with ts-node
npm run exampleimport { RecipeValidator } from './validator';
// See example.ts for full usageConverted from: /Users/jacobgorenm4/src/workato-platform-cli/src/workato_platform/cli/commands/recipes/validator.py
- Keyword: Recipe structure keywords (trigger, action, if, foreach, etc.)
- ErrorType: Validation error types
- ValidationError: Individual validation error details
- ValidationResult: Complete validation result with errors and warnings
- RecipeLine: Recipe line/step structure with all properties
- RecipeAccountId: Recipe account identification
- RecipeConfig: Recipe configuration
- Recipe: Complete recipe structure
- WorkatoClient: Simplified Workato API client interface
- PlatformConnector: Platform connector metadata
- CustomConnector: Custom connector metadata
validateRecipe(recipeData): Main validation entry point (async)
validateRecipeStructure(): Validates overall recipe structurevalidateStructureRecursive(): Recursive structure validationvalidateLineStructure(): Line-specific structure validationvalidateIfStructure(): IF block validationvalidateForeachStructure(): FOREACH block validationvalidateRepeatStructure(): REPEAT block validationvalidateTryStructure(): TRY/CATCH block validationvalidateActionStructure(): ACTION validationvalidateProviders(): Provider and connector validationvalidateUniqueAsValues(): Ensures unique 'as' values across recipevalidateReferencesWithContext(): Validates data pill references with contextvalidateDataPillReferencesWithContext(): Validates data pill format and cross-referencesvalidateDataPillCrossReference(): Validates specific data pill cross-referencesvalidateSchemas(): Schema validationvalidateExpressions(): Expression validationvalidateInputExpressions(): Input field expression validationvalidateConfigCoverage(): Config section coverage validationvalidateArrayMappings(): Array mapping validationvalidateDataPillStructures(): Data pill structure validationvalidateArrayConsistency(): Array structure consistency validationvalidateBlockStructure(): Block numbering validationvalidateInputModes(): Input mode consistency validationvalidateFormulaSyntax(): Formula syntax validationvalidateGenericSchemaUsage(): Generic schema usage validationvalidateArrayMappingsEnhanced(): Enhanced array mapping validation
parseRecipeLine(): Parses raw JSON into RecipeLine structureextractDataPills(): Extracts data pill references from textisValidDataPill(): Validates data pill formatisExpression(): Checks if text is an expressionisValidExpression(): Validates expression syntaxcollectProviders(): Collects all providers used in recipestepExists(): Checks if a step existsfindStepByAs(): Finds a step by provider and 'as' valueextractPathFromDp(): Extracts path from _dp() stringisValidElementPath(): Validates element path consistencyisControlBlock(): Checks if step is a control blockstepUsesDataPills(): Checks if step uses data pillsstepIsReferenced(): Checks if step is referenced by othersfindReferencesToStep(): Finds references to a specific stepsearchForReferencePattern(): Searches for reference patterns
ensureConnectorsLoaded(): Ensures connector metadata is loadedloadBuiltinConnectors(): Loads connector metadata from API (async)loadCachedConnectors(): Loads connector metadata from cachesaveConnectorsToCache(): Saves connector metadata to cache
- Type System: Uses TypeScript interfaces instead of Pydantic models
- Validation: Manual validation in
parseRecipeLineinstead of Pydantic validators - Pattern Matching: Uses RegExp instead of Python's
remodule - File I/O: Uses Node.js
fsmodule instead of Python'spathlibandopen() - JSON Parsing: Native
JSON.parse/stringifyinstead of Python'sjsonmodule - Async/Await: Both use async/await, but TypeScript uses
Promise<T>return types
import { RecipeValidator } from './validator';
// Create a Workato API client (implementation not shown)
const workatoClient: WorkatoClient = {
connectors: {
listPlatformConnectors: async (page, perPage) => { /* ... */ },
listCustomConnectors: async () => { /* ... */ },
getCustomConnectorCode: async (id) => { /* ... */ }
}
};
// Create validator instance
const validator = new RecipeValidator(workatoClient);
// Validate a recipe
const recipeData = {
name: 'My Recipe',
description: 'A test recipe',
private: false,
concurrency: 1,
code: {
number: 0,
keyword: 'trigger',
uuid: '12345678-1234-1234-1234-123456789012',
provider: 'salesforce',
name: 'new_object',
// ... more fields
},
config: [
{
keyword: 'application',
provider: 'salesforce',
// ... more config
}
]
};
const result = await validator.validateRecipe(recipeData);
if (result.isValid) {
console.log('Recipe is valid!');
} else {
console.log('Validation errors:');
result.errors.forEach(error => {
console.log(` - ${error.message} (line ${error.lineNumber})`);
});
}Connector metadata is cached at: ~/.workato_platform/cli/connector_cache.json
Cache expires after 24 hours by default.
- The TypeScript version maintains 100% functional parity with the Python version
- All validation methods have been ported
- All helper methods have been ported
- Legacy compatibility methods are preserved
- The code structure closely mirrors the Python version for easy maintenance