Generate comprehensive {node_name}.example.json files that showcase real-world usage of Workscript workflow nodes...
Generate production-quality {node_name}.example.json workflow files demonstrating correct usage of Workscript nodes.
Before generating documentation, you MUST:
Read the node source file (.ts file) to understand:
metadata.id - The node type identifiermetadata.inputs - Expected configuration parametersmetadata.outputs - Output data structuremetadata.ai_hints - Purpose, when_to_use, expected_edges, post_to_stateexecute() method - All conditional logic and edge returnsLocate the node in /packages/nodes/src/ or subdirectories:
/packages/nodes/src/{NodeName}.ts/packages/nodes/src/data/{NodeName}.ts/packages/nodes/src/custom/{integration}/{NodeName}.tsCreate file: {node_name}.example.json in same directory as the node source.
{
"id": "{node-id}-examples",
"name": "{NodeName} Examples",
"version": "1.0.0",
"description": "Comprehensive examples demonstrating all {NodeName} capabilities",
"initialState": { /* Realistic test data */ },
"workflow": [ /* Inline nested configuration examples */ ]
}
For documentation examples, use a flat sequential array where each step demonstrates a different feature of the node being documented. This makes examples clear and easy to understand.
DO NOT create deeply nested workflows - even if they are technically correct, they obscure the features being demonstrated.
// WRONG - Deeply nested (hard to read, obscures individual features)
{
"workflow": [
{
"extractText": {
"method": "extractAll",
"extractType": "email",
"success?": {
"extractText": {
"method": "extractAll",
"extractType": "url",
"success?": {
"extractText": {
"method": "regex",
"pattern": "...",
"success?": {
"log": { "message": "Done" }
}
}
}
}
}
}
}
]
}
// CORRECT - Sequential steps showcasing each feature clearly
{
"workflow": [
{
"extractText": {
"method": "extractAll",
"field": "emailText",
"extractType": "email",
"outputField": "allEmails",
"success?": "log"
}
},
{
"extractText": {
"method": "extractSpecific",
"field": "emailText",
"extractType": "email",
"occurrence": 0,
"outputField": "primaryEmail",
"success?": "log"
}
},
{
"extractText": {
"method": "regex",
"field": "productData",
"pattern": "Product: ([A-Z0-9]+)",
"flags": "g",
"outputField": "productIds",
"success?": "log"
}
},
{
"log": {
"message": "All examples completed!",
"results": "$.allEmails"
}
}
]
}
Key principles for documentation examples:
"success?": "log") not deep nesting"log" in documentation examplesCreate domain-appropriate test data:
{
"initialState": {
"products": [
{ "id": 1, "name": "Laptop", "price": 999.99, "inStock": true, "category": "Electronics" },
{ "id": 2, "name": "Mouse", "price": 29.99, "inStock": false, "category": "Electronics" }
],
"users": [
{ "id": 1, "name": "Alice", "email": "alice@example.com", "role": "admin" }
]
}
}
For each node, show workflows that trigger each possible edge:
// Node with success/error/found/not_found edges
{
"database": {
"operation": "find",
"table": "users",
"query": { "id": "$.userId" },
"found?": { /* next node inline */ },
"not_found?": { /* handle missing */ },
"error?": { /* handle error */ }
}
}
If the node supports multiple operations, demonstrate each:
// Math node - show add, subtract, multiply, divide
// Filter node - show equals, contains, gt, lt, between, regex
// Transform node - show stringify, parse, uppercase, lowercase
? SuffixEdges always end with ?:
success?, error?, found?, not_found?true?, false?, valid?, invalid?exists?, not_exists?, passed?, filtered?{
"id": "{node-id}-examples",
"name": "{NodeName} Examples",
"version": "1.0.0",
"description": "Comprehensive examples demonstrating all {NodeName} capabilities",
"initialState": {
"/* Realistic domain data matching node inputs - provide multiple data sources to showcase different features */"
},
"workflow": [
{
"{node-id}": {
"/* Example 1: Basic usage - simplest configuration */",
"outputField": "example1Result",
"success?": "log"
}
},
{
"{node-id}": {
"/* Example 2: Different operation/mode */",
"outputField": "example2Result",
"success?": "log"
}
},
{
"{node-id}": {
"/* Example 3: Advanced usage with all options */",
"outputField": "example3Result",
"success?": "log"
}
},
{
"{node-id}": {
"/* Example 4: Edge case or alternative configuration */",
"outputField": "example4Result",
"success?": "log"
}
},
{
"log": {
"message": "All {NodeName} examples completed successfully!",
"example1Result": "$.example1Result",
"example2Result": "$.example2Result",
"example3Result": "$.example3Result",
"example4Result": "$.example4Result"
}
}
]
}
Template guidelines:
outputField to store results"success?": "log" as a simple edge terminator (not deep nesting!)Use $. syntax for state access:
$.products - Access state.products$.user.name - Access nested state.user.name$.filterPassed - Access node output stored in stateCommon node state outputs (reference from node's ai_hints.post_to_state):
mathResultlogicResultfilterPassed, filterFiltered, filterStatssortedItemsvalidationResult, validationErrorseditFieldsResult, fieldsModifieddbInserted, dbRecord, dbUpdated, dbDeleted, dbRecordsfileContent, fileWritten, fileExistsBefore finalizing, verify:
? suffix"success?": "log" as simple terminators (not deep nesting){node_id}.example.json in node's directory{
"id": "string (required, pattern: ^[a-zA-Z0-9_-]+$)",
"name": "string (required)",
"version": "string (required, pattern: ^\\d+\\.\\d+\\.\\d+$)",
"description": "string (optional)",
"initialState": "object (optional)",
"workflow": "array (required, min: 1 item)"
}
When reading a node's .ts file, extract:
metadata = {
id: 'node-id', // Use this in workflow
name: 'Node Name', // Use in description
inputs: ['param1'], // Config parameters
outputs: ['result'], // Edge data keys
ai_hints: {
purpose: '...',
when_to_use: '...',
expected_edges: ['success', 'error'], // All possible edges
example_config: '...',
post_to_state: ['stateKey'] // State keys written
}
};
Analyze the execute() method to understand:
return { edgeName: () => ({...}) } statements