|
| 1 | +import { parsePipeline, analyzePipeline } from './src/operations/pipeline/index.js'; |
| 2 | +import * as fs from 'fs'; |
| 3 | + |
| 4 | +const xml = fs.readFileSync('/Users/clavery/code/sitegenesis/app_storefront_pipelines/cartridge/pipelines/Product.xml', 'utf-8'); |
| 5 | + |
| 6 | +async function main() { |
| 7 | + const pipeline = await parsePipeline(xml, 'Product'); |
| 8 | + |
| 9 | + // Find GetProduct start node |
| 10 | + let getProductStartId: string | undefined; |
| 11 | + for (const [id, node] of pipeline.nodes) { |
| 12 | + if (node.type === 'start' && node.name === 'GetProduct') { |
| 13 | + getProductStartId = id; |
| 14 | + console.log('GetProduct start node:', id); |
| 15 | + console.log(' transitions:', JSON.stringify(node.transitions, null, 2)); |
| 16 | + break; |
| 17 | + } |
| 18 | + } |
| 19 | + |
| 20 | + // Trace the path from GetProduct start |
| 21 | + if (getProductStartId) { |
| 22 | + console.log('\n=== Tracing GetProduct path ==='); |
| 23 | + let currentId = getProductStartId; |
| 24 | + const visited = new Set<string>(); |
| 25 | + |
| 26 | + while (currentId && !visited.has(currentId)) { |
| 27 | + visited.add(currentId); |
| 28 | + const node = pipeline.nodes.get(currentId); |
| 29 | + if (!node) break; |
| 30 | + |
| 31 | + console.log(`\nNode ${currentId}: ${node.type}`); |
| 32 | + if (node.type === 'decision') { |
| 33 | + console.log(' condition:', (node as any).condition); |
| 34 | + } |
| 35 | + if (node.type === 'pipelet') { |
| 36 | + console.log(' pipeletName:', (node as any).pipeletName); |
| 37 | + console.log(' hasErrorBranch:', (node as any).hasErrorBranch); |
| 38 | + } |
| 39 | + if (node.type === 'interaction') { |
| 40 | + console.log(' template:', (node as any).templateName); |
| 41 | + } |
| 42 | + if (node.type === 'end') { |
| 43 | + console.log(' name:', (node as any).name); |
| 44 | + } |
| 45 | + console.log(' transitions:', JSON.stringify(node.transitions, null, 2)); |
| 46 | + |
| 47 | + // Follow first/default transition |
| 48 | + currentId = node.transitions[0]?.targetId; |
| 49 | + } |
| 50 | + } |
| 51 | + |
| 52 | + // Find all interaction nodes with error/notfound |
| 53 | + console.log('\n=== Interaction nodes with error/notfound ==='); |
| 54 | + for (const [id, node] of pipeline.nodes) { |
| 55 | + if (node.type === 'interaction' && (node as any).templateName === 'error/notfound') { |
| 56 | + console.log('Found error/notfound:', id); |
| 57 | + // Find what leads to this node |
| 58 | + for (const [srcId, srcNode] of pipeline.nodes) { |
| 59 | + for (const t of srcNode.transitions) { |
| 60 | + if (t.targetId === id) { |
| 61 | + console.log(` <- from ${srcId} (${srcNode.type})`); |
| 62 | + } |
| 63 | + } |
| 64 | + } |
| 65 | + } |
| 66 | + } |
| 67 | + |
| 68 | + // Run analysis |
| 69 | + console.log('\n=== Analysis ==='); |
| 70 | + const analysis = analyzePipeline(pipeline); |
| 71 | + console.log('Total warnings:', analysis.warnings.length); |
| 72 | + for (const w of analysis.warnings) { |
| 73 | + console.log(' ', w); |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +main().catch(console.error); |
0 commit comments