-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtest-user-import.mjs
More file actions
60 lines (50 loc) · 1.96 KB
/
test-user-import.mjs
File metadata and controls
60 lines (50 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env node
import { readFileSync } from 'fs';
import { yamlParser } from './packages/transpiler/dist/parser/YamlParser.js';
console.log('=== Testing User YAML Import ===\n');
try {
const yamlContent = readFileSync('./test-user-yaml.yaml', 'utf-8');
console.log('YAML Content (first 200 chars):');
console.log(yamlContent.substring(0, 200) + '...\n');
const result = yamlParser.parse(yamlContent);
if (result.success && result.graph) {
console.log('✅ Import successful!');
console.log(` Graph Name: ${result.graph.name}`);
console.log(` Nodes: ${result.graph.nodes.length}`);
console.log(` Edges: ${result.graph.edges.length}`);
console.log(` Had metadata: ${result.hadMetadata}\n`);
console.log('Node types:');
result.graph.nodes.forEach((node, i) => {
console.log(` ${i + 1}. ${node.type} (${node.id})`);
if (node.type === 'trigger') {
console.log(` - platform: ${node.data.platform}`);
console.log(` - entity_id: ${node.data.entity_id}`);
} else if (node.type === 'condition') {
console.log(` - condition: ${node.data.condition}`);
} else if (node.type === 'action') {
console.log(` - service: ${node.data.service}`);
}
});
console.log('\nEdges:');
result.graph.edges.forEach((edge, i) => {
console.log(
` ${i + 1}. ${edge.source} -> ${edge.target}${edge.sourceHandle ? ` (${edge.sourceHandle})` : ''}`
);
});
if (result.warnings.length > 0) {
console.log('\n⚠️ Warnings:');
result.warnings.forEach((w) => console.log(` - ${w}`));
}
} else {
console.log('❌ Import failed!');
console.log('Errors:', result.errors);
if (result.warnings.length > 0) {
console.log('Warnings:', result.warnings);
}
}
} catch (error) {
console.error('❌ Test failed:', error.message);
console.error(error.stack);
process.exit(1);
}
console.log('\n=== Test complete ===');