@n8n-as-code/transformer 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +215 -0
- package/dist/compiler/index.d.ts +6 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +6 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/typescript-parser.d.ts +87 -0
- package/dist/compiler/typescript-parser.d.ts.map +1 -0
- package/dist/compiler/typescript-parser.js +379 -0
- package/dist/compiler/typescript-parser.js.map +1 -0
- package/dist/compiler/workflow-builder.d.ts +48 -0
- package/dist/compiler/workflow-builder.d.ts.map +1 -0
- package/dist/compiler/workflow-builder.js +231 -0
- package/dist/compiler/workflow-builder.js.map +1 -0
- package/dist/decorators/helpers.d.ts +27 -0
- package/dist/decorators/helpers.d.ts.map +1 -0
- package/dist/decorators/helpers.js +97 -0
- package/dist/decorators/helpers.js.map +1 -0
- package/dist/decorators/index.d.ts +11 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +10 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/decorators/links.d.ts +70 -0
- package/dist/decorators/links.d.ts.map +1 -0
- package/dist/decorators/links.js +85 -0
- package/dist/decorators/links.js.map +1 -0
- package/dist/decorators/node.d.ts +32 -0
- package/dist/decorators/node.d.ts.map +1 -0
- package/dist/decorators/node.js +43 -0
- package/dist/decorators/node.js.map +1 -0
- package/dist/decorators/types.d.ts +122 -0
- package/dist/decorators/types.d.ts.map +1 -0
- package/dist/decorators/types.js +13 -0
- package/dist/decorators/types.js.map +1 -0
- package/dist/decorators/workflow.d.ts +32 -0
- package/dist/decorators/workflow.d.ts.map +1 -0
- package/dist/decorators/workflow.js +38 -0
- package/dist/decorators/workflow.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/ast-to-typescript.d.ts +55 -0
- package/dist/parser/ast-to-typescript.d.ts.map +1 -0
- package/dist/parser/ast-to-typescript.js +337 -0
- package/dist/parser/ast-to-typescript.js.map +1 -0
- package/dist/parser/index.d.ts +6 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +6 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/json-to-ast.d.ts +61 -0
- package/dist/parser/json-to-ast.d.ts.map +1 -0
- package/dist/parser/json-to-ast.js +222 -0
- package/dist/parser/json-to-ast.js.map +1 -0
- package/dist/types.d.ts +227 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/formatting.d.ts +33 -0
- package/dist/utils/formatting.d.ts.map +1 -0
- package/dist/utils/formatting.js +83 -0
- package/dist/utils/formatting.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +6 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/naming.d.ts +39 -0
- package/dist/utils/naming.d.ts.map +1 -0
- package/dist/utils/naming.js +161 -0
- package/dist/utils/naming.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST to TypeScript Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates TypeScript code from AST representation
|
|
5
|
+
*/
|
|
6
|
+
import { formatTypeScript, generateSectionComment, generateImportStatement, generateClassName } from '../utils/index.js';
|
|
7
|
+
/**
|
|
8
|
+
* Generate TypeScript code from AST
|
|
9
|
+
*/
|
|
10
|
+
export class AstToTypeScriptGenerator {
|
|
11
|
+
/**
|
|
12
|
+
* Generate TypeScript code
|
|
13
|
+
*/
|
|
14
|
+
async generate(ast, options = {}) {
|
|
15
|
+
const { format = true, commentStyle = 'verbose', className: customClassName } = options;
|
|
16
|
+
const className = customClassName || generateClassName(ast.metadata.name);
|
|
17
|
+
// Generate code sections
|
|
18
|
+
const imports = this.generateImports();
|
|
19
|
+
const workflowMap = this.generateWorkflowMap(ast);
|
|
20
|
+
const classHeader = this.generateClassHeader(ast, className, commentStyle);
|
|
21
|
+
const nodes = this.generateNodes(ast, commentStyle);
|
|
22
|
+
const routing = this.generateRouting(ast, commentStyle);
|
|
23
|
+
const classFooter = '}';
|
|
24
|
+
// Combine sections
|
|
25
|
+
let code = [
|
|
26
|
+
imports,
|
|
27
|
+
'',
|
|
28
|
+
workflowMap,
|
|
29
|
+
'',
|
|
30
|
+
classHeader,
|
|
31
|
+
'',
|
|
32
|
+
nodes,
|
|
33
|
+
'',
|
|
34
|
+
routing,
|
|
35
|
+
classFooter
|
|
36
|
+
].join('\n');
|
|
37
|
+
// Format with Prettier if requested
|
|
38
|
+
if (format) {
|
|
39
|
+
code = await formatTypeScript(code);
|
|
40
|
+
}
|
|
41
|
+
return code;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Generate the workflow-map comment block.
|
|
45
|
+
* This block is ignored by TypeScriptParser (it is a plain comment) but
|
|
46
|
+
* provides a fast orientation index for AI agents and human developers:
|
|
47
|
+
* 1. NODE INDEX — property name, line hint (approximate), short node type
|
|
48
|
+
* 2. ROUTING MAP — ASCII flow of main + AI connections
|
|
49
|
+
*
|
|
50
|
+
* Agents should read this block first (between <workflow-map> tags) before
|
|
51
|
+
* opening the full file, to quickly locate the sections they need to edit.
|
|
52
|
+
*/
|
|
53
|
+
generateWorkflowMap(ast) {
|
|
54
|
+
const lines = [];
|
|
55
|
+
lines.push('// <workflow-map>');
|
|
56
|
+
lines.push(`// Workflow : ${ast.metadata.name}`);
|
|
57
|
+
lines.push(`// Nodes : ${ast.nodes.length} | Connections: ${ast.connections.length}`);
|
|
58
|
+
lines.push('//');
|
|
59
|
+
// ── NODE INDEX ────────────────────────────────────────────────────────
|
|
60
|
+
lines.push('// NODE INDEX');
|
|
61
|
+
lines.push('// ──────────────────────────────────────────────────────────────────');
|
|
62
|
+
lines.push('// Property name Node type (short) Flags');
|
|
63
|
+
const shortType = (type) => type.split('.').pop() ?? type;
|
|
64
|
+
for (const n of ast.nodes) {
|
|
65
|
+
const prop = n.propertyName.padEnd(34);
|
|
66
|
+
const t = shortType(n.type).padEnd(26);
|
|
67
|
+
const flags = [];
|
|
68
|
+
if (n.aiDependencies && Object.keys(n.aiDependencies).length > 0)
|
|
69
|
+
flags.push('[AI]');
|
|
70
|
+
if (n.onError === 'continueErrorOutput')
|
|
71
|
+
flags.push('[onError→out(1)]');
|
|
72
|
+
if (n.onError === 'continueRegularOutput')
|
|
73
|
+
flags.push('[onError→regular]');
|
|
74
|
+
if (n.credentials && Object.keys(n.credentials).length > 0)
|
|
75
|
+
flags.push('[creds]');
|
|
76
|
+
lines.push(`// ${prop} ${t} ${flags.join(' ')}`);
|
|
77
|
+
}
|
|
78
|
+
lines.push('//');
|
|
79
|
+
// ── ROUTING MAP ───────────────────────────────────────────────────────
|
|
80
|
+
lines.push('// ROUTING MAP');
|
|
81
|
+
lines.push('// ──────────────────────────────────────────────────────────────────');
|
|
82
|
+
// Build adjacency: from-node → [{to, fromOutput}]
|
|
83
|
+
const adj = new Map();
|
|
84
|
+
for (const conn of ast.connections) {
|
|
85
|
+
if (!adj.has(conn.from.node))
|
|
86
|
+
adj.set(conn.from.node, []);
|
|
87
|
+
adj.get(conn.from.node).push({ to: conn.to.node, out: conn.from.output, in: conn.to.input });
|
|
88
|
+
}
|
|
89
|
+
// Find root nodes (no incoming main connections)
|
|
90
|
+
const hasIncoming = new Set(ast.connections.map(c => c.to.node));
|
|
91
|
+
const roots = ast.nodes
|
|
92
|
+
.filter(n => !hasIncoming.has(n.propertyName))
|
|
93
|
+
.filter(n => adj.has(n.propertyName)); // Only nodes that have outgoing connections
|
|
94
|
+
// If no clear roots, just list all connections flat
|
|
95
|
+
if (roots.length === 0) {
|
|
96
|
+
for (const conn of ast.connections) {
|
|
97
|
+
const outLabel = conn.from.output > 0 ? `.out(${conn.from.output})` : '';
|
|
98
|
+
const inLabel = conn.to.input > 0 ? `.in(${conn.to.input})` : '';
|
|
99
|
+
lines.push(`// ${conn.from.node}${outLabel} → ${conn.to.node}${inLabel}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// DFS from each root, tracking visited to handle loops
|
|
104
|
+
const visited = new Set();
|
|
105
|
+
const renderNode = (name, indent, parentIndent) => {
|
|
106
|
+
const children = adj.get(name) ?? [];
|
|
107
|
+
// Sort by output index so out(0) comes before out(1)
|
|
108
|
+
const sorted = [...children].sort((a, b) => a.out - b.out);
|
|
109
|
+
for (const child of sorted) {
|
|
110
|
+
const outLabel = child.out > 0 ? `.out(${child.out})` : '';
|
|
111
|
+
const inLabel = child.in > 0 ? `.in(${child.in})` : '';
|
|
112
|
+
const arrow = `${outLabel} → ${child.to}${inLabel}`;
|
|
113
|
+
if (visited.has(child.to)) {
|
|
114
|
+
lines.push(`// ${indent}${arrow} (↩ loop)`);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
lines.push(`// ${indent}${arrow}`);
|
|
118
|
+
visited.add(child.to);
|
|
119
|
+
renderNode(child.to, indent + ' ', indent);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
for (const root of roots) {
|
|
124
|
+
lines.push(`// ${root.propertyName}`);
|
|
125
|
+
visited.add(root.propertyName);
|
|
126
|
+
renderNode(root.propertyName, ' ', '');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// AI connections — group by consumer (agent node), aiDeps are stored on the sub-node
|
|
130
|
+
// e.g. OpenaiChatModel.aiDependencies = { ai_languageModel: "AgentIa" }
|
|
131
|
+
// means: AgentIa.uses({ ai_languageModel: OpenaiChatModel })
|
|
132
|
+
const aiSubNodes = ast.nodes.filter(n => n.aiDependencies && Object.keys(n.aiDependencies).length > 0);
|
|
133
|
+
if (aiSubNodes.length > 0) {
|
|
134
|
+
// Invert: group { consumer → { role → subNode } }
|
|
135
|
+
const consumers = new Map();
|
|
136
|
+
for (const subNode of aiSubNodes) {
|
|
137
|
+
for (const [role, consumer] of Object.entries(subNode.aiDependencies)) {
|
|
138
|
+
const consumerName = Array.isArray(consumer) ? consumer[0] : consumer;
|
|
139
|
+
if (!consumerName)
|
|
140
|
+
continue;
|
|
141
|
+
if (!consumers.has(consumerName))
|
|
142
|
+
consumers.set(consumerName, []);
|
|
143
|
+
const val = Array.isArray(consumer)
|
|
144
|
+
? `${role}: [${consumer.join(', ')}]`
|
|
145
|
+
: `${role}: ${subNode.propertyName}`;
|
|
146
|
+
consumers.get(consumerName).push(val);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
lines.push('//');
|
|
150
|
+
lines.push('// AI CONNECTIONS');
|
|
151
|
+
for (const [consumer, deps] of consumers) {
|
|
152
|
+
lines.push(`// ${consumer}.uses({ ${deps.join(', ')} })`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
lines.push('// </workflow-map>');
|
|
156
|
+
return lines.join('\n');
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Generate imports
|
|
160
|
+
*/
|
|
161
|
+
generateImports() {
|
|
162
|
+
return generateImportStatement(['workflow', 'node', 'links'], '@n8n-as-code/transformer');
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Generate class header with @workflow decorator
|
|
166
|
+
*/
|
|
167
|
+
generateClassHeader(ast, className, commentStyle) {
|
|
168
|
+
const lines = [];
|
|
169
|
+
// Section comment
|
|
170
|
+
if (commentStyle === 'verbose') {
|
|
171
|
+
lines.push(generateSectionComment('METADATA DU WORKFLOW'));
|
|
172
|
+
lines.push('');
|
|
173
|
+
}
|
|
174
|
+
// Decorator
|
|
175
|
+
const decoratorContent = this.formatWorkflowDecorator(ast.metadata);
|
|
176
|
+
lines.push(`@workflow(${decoratorContent})`);
|
|
177
|
+
// Class declaration
|
|
178
|
+
lines.push(`export class ${className} {`);
|
|
179
|
+
return lines.join('\n');
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Format @workflow decorator content
|
|
183
|
+
*/
|
|
184
|
+
formatWorkflowDecorator(metadata) {
|
|
185
|
+
const parts = [];
|
|
186
|
+
parts.push(`id: "${metadata.id}"`);
|
|
187
|
+
parts.push(`name: "${metadata.name}"`);
|
|
188
|
+
parts.push(`active: ${metadata.active}`);
|
|
189
|
+
if (metadata.settings && Object.keys(metadata.settings).length > 0) {
|
|
190
|
+
const settings = JSON.stringify(metadata.settings)
|
|
191
|
+
.replace(/"([^"]+)":/g, '$1:'); // Remove quotes from keys
|
|
192
|
+
parts.push(`settings: ${settings}`);
|
|
193
|
+
}
|
|
194
|
+
return `{\n ${parts.join(',\n ')}\n}`;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Generate node declarations
|
|
198
|
+
*/
|
|
199
|
+
generateNodes(ast, commentStyle) {
|
|
200
|
+
const lines = [];
|
|
201
|
+
// Section comment
|
|
202
|
+
if (commentStyle === 'verbose') {
|
|
203
|
+
lines.push(' ' + generateSectionComment('CONFIGURATION DES NOEUDS'));
|
|
204
|
+
lines.push('');
|
|
205
|
+
}
|
|
206
|
+
// Generate each node
|
|
207
|
+
ast.nodes.forEach(node => {
|
|
208
|
+
lines.push(' ' + this.generateNodeDeclaration(node));
|
|
209
|
+
lines.push('');
|
|
210
|
+
});
|
|
211
|
+
return lines.join('\n');
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Generate single node declaration
|
|
215
|
+
*/
|
|
216
|
+
generateNodeDeclaration(node) {
|
|
217
|
+
const lines = [];
|
|
218
|
+
// Decorator
|
|
219
|
+
const decoratorContent = this.formatNodeDecorator(node);
|
|
220
|
+
lines.push(`@node(${decoratorContent})`);
|
|
221
|
+
// Property declaration
|
|
222
|
+
const params = JSON.stringify(node.parameters, null, 4)
|
|
223
|
+
.split('\n')
|
|
224
|
+
.map((line, i) => i === 0 ? line : ' ' + line)
|
|
225
|
+
.join('\n');
|
|
226
|
+
lines.push(`${node.propertyName} = ${params};`);
|
|
227
|
+
return lines.join('\n ');
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Format @node decorator content
|
|
231
|
+
*/
|
|
232
|
+
formatNodeDecorator(node) {
|
|
233
|
+
const parts = [];
|
|
234
|
+
parts.push(`name: "${node.displayName}"`);
|
|
235
|
+
parts.push(`type: "${node.type}"`);
|
|
236
|
+
parts.push(`version: ${node.version}`);
|
|
237
|
+
if (node.position) {
|
|
238
|
+
parts.push(`position: [${node.position.join(', ')}]`);
|
|
239
|
+
}
|
|
240
|
+
if (node.credentials) {
|
|
241
|
+
const creds = JSON.stringify(node.credentials).replace(/"([^"]+)":/g, '$1:');
|
|
242
|
+
parts.push(`credentials: ${creds}`);
|
|
243
|
+
}
|
|
244
|
+
if (node.onError) {
|
|
245
|
+
parts.push(`onError: "${node.onError}"`);
|
|
246
|
+
}
|
|
247
|
+
return `{\n ${parts.join(',\n ')}\n }`;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Generate routing section (@links)
|
|
251
|
+
*/
|
|
252
|
+
generateRouting(ast, commentStyle) {
|
|
253
|
+
const lines = [];
|
|
254
|
+
// Section comment
|
|
255
|
+
if (commentStyle === 'verbose') {
|
|
256
|
+
lines.push(' ' + generateSectionComment('ROUTAGE ET CONNEXIONS'));
|
|
257
|
+
lines.push('');
|
|
258
|
+
}
|
|
259
|
+
// Method declaration
|
|
260
|
+
lines.push(' @links()');
|
|
261
|
+
lines.push(' defineRouting() {');
|
|
262
|
+
// Generate regular connections (main/error)
|
|
263
|
+
if (ast.connections.length > 0) {
|
|
264
|
+
ast.connections.forEach(conn => {
|
|
265
|
+
const fromMethod = conn.from.isError ? 'error()' : `out(${conn.from.output})`;
|
|
266
|
+
const line = ` this.${conn.from.node}.${fromMethod}.to(this.${conn.to.node}.in(${conn.to.input}));`;
|
|
267
|
+
lines.push(line);
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
// Generate AI dependency injections (.uses() calls)
|
|
271
|
+
const nodesWithAIDeps = ast.nodes.filter(node => node.aiDependencies && Object.keys(node.aiDependencies).length > 0);
|
|
272
|
+
if (nodesWithAIDeps.length > 0) {
|
|
273
|
+
if (ast.connections.length > 0) {
|
|
274
|
+
lines.push(''); // Blank line separator
|
|
275
|
+
}
|
|
276
|
+
nodesWithAIDeps.forEach(node => {
|
|
277
|
+
const deps = node.aiDependencies;
|
|
278
|
+
const depLines = [];
|
|
279
|
+
// Single AI dependencies
|
|
280
|
+
if (deps.ai_languageModel) {
|
|
281
|
+
depLines.push(`ai_languageModel: this.${deps.ai_languageModel}.output`);
|
|
282
|
+
}
|
|
283
|
+
if (deps.ai_memory) {
|
|
284
|
+
depLines.push(`ai_memory: this.${deps.ai_memory}.output`);
|
|
285
|
+
}
|
|
286
|
+
if (deps.ai_outputParser) {
|
|
287
|
+
depLines.push(`ai_outputParser: this.${deps.ai_outputParser}.output`);
|
|
288
|
+
}
|
|
289
|
+
if (deps.ai_agent) {
|
|
290
|
+
depLines.push(`ai_agent: this.${deps.ai_agent}.output`);
|
|
291
|
+
}
|
|
292
|
+
if (deps.ai_chain) {
|
|
293
|
+
depLines.push(`ai_chain: this.${deps.ai_chain}.output`);
|
|
294
|
+
}
|
|
295
|
+
if (deps.ai_textSplitter) {
|
|
296
|
+
depLines.push(`ai_textSplitter: this.${deps.ai_textSplitter}.output`);
|
|
297
|
+
}
|
|
298
|
+
if (deps.ai_embedding) {
|
|
299
|
+
depLines.push(`ai_embedding: this.${deps.ai_embedding}.output`);
|
|
300
|
+
}
|
|
301
|
+
if (deps.ai_retriever) {
|
|
302
|
+
depLines.push(`ai_retriever: this.${deps.ai_retriever}.output`);
|
|
303
|
+
}
|
|
304
|
+
if (deps.ai_reranker) {
|
|
305
|
+
depLines.push(`ai_reranker: this.${deps.ai_reranker}.output`);
|
|
306
|
+
}
|
|
307
|
+
if (deps.ai_vectorStore) {
|
|
308
|
+
depLines.push(`ai_vectorStore: this.${deps.ai_vectorStore}.output`);
|
|
309
|
+
}
|
|
310
|
+
// Array AI dependencies
|
|
311
|
+
if (deps.ai_tool && deps.ai_tool.length > 0) {
|
|
312
|
+
const tools = deps.ai_tool.map(t => `this.${t}.output`).join(', ');
|
|
313
|
+
depLines.push(`ai_tool: [${tools}]`);
|
|
314
|
+
}
|
|
315
|
+
if (deps.ai_document && deps.ai_document.length > 0) {
|
|
316
|
+
const documents = deps.ai_document.map(d => `this.${d}.output`).join(', ');
|
|
317
|
+
depLines.push(`ai_document: [${documents}]`);
|
|
318
|
+
}
|
|
319
|
+
if (depLines.length > 0) {
|
|
320
|
+
lines.push(` this.${node.propertyName}.uses({`);
|
|
321
|
+
depLines.forEach((depLine, idx) => {
|
|
322
|
+
const comma = idx < depLines.length - 1 ? ',' : '';
|
|
323
|
+
lines.push(` ${depLine}${comma}`);
|
|
324
|
+
});
|
|
325
|
+
lines.push(' });');
|
|
326
|
+
}
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
// If no connections or AI deps
|
|
330
|
+
if (ast.connections.length === 0 && nodesWithAIDeps.length === 0) {
|
|
331
|
+
lines.push(' // No connections defined');
|
|
332
|
+
}
|
|
333
|
+
lines.push(' }');
|
|
334
|
+
return lines.join('\n');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=ast-to-typescript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-to-typescript.js","sourceRoot":"","sources":["../../src/parser/ast-to-typescript.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACpB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,MAAM,OAAO,wBAAwB;IACjC;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAgB,EAAE,UAAmC,EAAE;QAClE,MAAM,EACF,MAAM,GAAG,IAAI,EACb,YAAY,GAAG,SAAS,EACxB,SAAS,EAAE,eA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,eAAe,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC;oBACjD,CAAC,CAAC,CAAC;oBACH,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBAC9B,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;QAED,+BAA+B;QAC/B,IAAI,GAAG,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC/D,KAAK,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QACpD,CAAC;QAED,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAEpB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON to AST Parser
|
|
3
|
+
*
|
|
4
|
+
* Converts n8n workflow JSON to intermediate AST representation
|
|
5
|
+
*/
|
|
6
|
+
import { N8nWorkflow, WorkflowAST } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Parse n8n workflow JSON to AST
|
|
9
|
+
*/
|
|
10
|
+
export declare class JsonToAstParser {
|
|
11
|
+
/**
|
|
12
|
+
* Parse workflow JSON to AST
|
|
13
|
+
*/
|
|
14
|
+
parse(workflow: N8nWorkflow): WorkflowAST;
|
|
15
|
+
/**
|
|
16
|
+
* Parse single node
|
|
17
|
+
*/
|
|
18
|
+
private parseNode;
|
|
19
|
+
/**
|
|
20
|
+
* Parse connections from n8n format to AST format
|
|
21
|
+
*
|
|
22
|
+
* n8n format:
|
|
23
|
+
* {
|
|
24
|
+
* "Node A": {
|
|
25
|
+
* "main": [
|
|
26
|
+
* [{ node: "Node B", type: "main", index: 0 }]
|
|
27
|
+
* ],
|
|
28
|
+
* "ai_languageModel": [
|
|
29
|
+
* [{ node: "Agent", type: "ai_languageModel", index: 0 }]
|
|
30
|
+
* ]
|
|
31
|
+
* }
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* AST format:
|
|
35
|
+
* [
|
|
36
|
+
* { from: { node: "NodeA", output: 0 }, to: { node: "NodeB", input: 0 } }
|
|
37
|
+
* ]
|
|
38
|
+
*
|
|
39
|
+
* NOTE: AI connections (ai_*) are extracted separately via extractAIDependencies()
|
|
40
|
+
*/
|
|
41
|
+
private parseConnections;
|
|
42
|
+
/**
|
|
43
|
+
* Extract AI dependencies from connections and populate node aiDependencies
|
|
44
|
+
*
|
|
45
|
+
* AI dependencies are connections like:
|
|
46
|
+
* - ai_languageModel: The LLM model for an agent
|
|
47
|
+
* - ai_memory: Memory buffer for an agent
|
|
48
|
+
* - ai_outputParser: Output parser for structured responses
|
|
49
|
+
* - ai_tool: Tools available to an agent (array)
|
|
50
|
+
* - ai_agent: Agent sub-node
|
|
51
|
+
* - ai_chain: Chain sub-node
|
|
52
|
+
* - ai_document: Document loaders (array)
|
|
53
|
+
* - ai_textSplitter: Text splitter sub-node
|
|
54
|
+
* - ai_embedding: Embedding model sub-node
|
|
55
|
+
* - ai_retriever: Retriever sub-node for RAG
|
|
56
|
+
* - ai_reranker: Reranker sub-node
|
|
57
|
+
* - ai_vectorStore: Vector store sub-node
|
|
58
|
+
*/
|
|
59
|
+
private extractAIDependencies;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=json-to-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-to-ast.d.ts","sourceRoot":"","sources":["../../src/parser/json-to-ast.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,WAAW,EAA+C,MAAM,aAAa,CAAC;AAGpG;;GAEG;AACH,qBAAa,eAAe;IACxB;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,WAAW,GAAG,WAAW;IAoCzC;;OAEG;IACH,OAAO,CAAC,SAAS;IAajB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,OAAO,CAAC,gBAAgB;IA0DxB;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,qBAAqB;CAiFhC"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON to AST Parser
|
|
3
|
+
*
|
|
4
|
+
* Converts n8n workflow JSON to intermediate AST representation
|
|
5
|
+
*/
|
|
6
|
+
import { createPropertyNameContext, generatePropertyName } from '../utils/naming.js';
|
|
7
|
+
/**
|
|
8
|
+
* Parse n8n workflow JSON to AST
|
|
9
|
+
*/
|
|
10
|
+
export class JsonToAstParser {
|
|
11
|
+
/**
|
|
12
|
+
* Parse workflow JSON to AST
|
|
13
|
+
*/
|
|
14
|
+
parse(workflow) {
|
|
15
|
+
// Create context for property name generation
|
|
16
|
+
const nameContext = createPropertyNameContext();
|
|
17
|
+
// Create mapping: node displayName → propertyName
|
|
18
|
+
const nodeNameMap = new Map();
|
|
19
|
+
// Parse nodes
|
|
20
|
+
const nodes = workflow.nodes.map(node => {
|
|
21
|
+
const propertyName = generatePropertyName(node.name, nameContext);
|
|
22
|
+
nodeNameMap.set(node.name, propertyName);
|
|
23
|
+
return this.parseNode(node, propertyName);
|
|
24
|
+
});
|
|
25
|
+
// Parse connections (main/error) and AI dependencies
|
|
26
|
+
const connections = this.parseConnections(workflow.connections, nodeNameMap);
|
|
27
|
+
this.extractAIDependencies(workflow.connections, nodeNameMap, nodes);
|
|
28
|
+
// Build AST
|
|
29
|
+
return {
|
|
30
|
+
metadata: {
|
|
31
|
+
id: workflow.id,
|
|
32
|
+
name: workflow.name,
|
|
33
|
+
active: workflow.active,
|
|
34
|
+
settings: workflow.settings,
|
|
35
|
+
projectId: workflow.projectId,
|
|
36
|
+
projectName: workflow.projectName,
|
|
37
|
+
homeProject: workflow.homeProject,
|
|
38
|
+
isArchived: workflow.isArchived
|
|
39
|
+
},
|
|
40
|
+
nodes,
|
|
41
|
+
connections
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Parse single node
|
|
46
|
+
*/
|
|
47
|
+
parseNode(node, propertyName) {
|
|
48
|
+
return {
|
|
49
|
+
propertyName,
|
|
50
|
+
displayName: node.name,
|
|
51
|
+
type: node.type,
|
|
52
|
+
version: node.typeVersion || 1,
|
|
53
|
+
position: node.position || [0, 0],
|
|
54
|
+
parameters: node.parameters || {},
|
|
55
|
+
credentials: node.credentials,
|
|
56
|
+
onError: node.onError
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parse connections from n8n format to AST format
|
|
61
|
+
*
|
|
62
|
+
* n8n format:
|
|
63
|
+
* {
|
|
64
|
+
* "Node A": {
|
|
65
|
+
* "main": [
|
|
66
|
+
* [{ node: "Node B", type: "main", index: 0 }]
|
|
67
|
+
* ],
|
|
68
|
+
* "ai_languageModel": [
|
|
69
|
+
* [{ node: "Agent", type: "ai_languageModel", index: 0 }]
|
|
70
|
+
* ]
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
*
|
|
74
|
+
* AST format:
|
|
75
|
+
* [
|
|
76
|
+
* { from: { node: "NodeA", output: 0 }, to: { node: "NodeB", input: 0 } }
|
|
77
|
+
* ]
|
|
78
|
+
*
|
|
79
|
+
* NOTE: AI connections (ai_*) are extracted separately via extractAIDependencies()
|
|
80
|
+
*/
|
|
81
|
+
parseConnections(connections, nodeNameMap) {
|
|
82
|
+
const result = [];
|
|
83
|
+
if (!connections) {
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
// AI connection types (these are handled separately)
|
|
87
|
+
const AI_CONNECTION_TYPES = ['ai_languageModel', 'ai_memory', 'ai_outputParser', 'ai_tool'];
|
|
88
|
+
for (const [sourceNodeName, outputs] of Object.entries(connections)) {
|
|
89
|
+
const sourcePropertyName = nodeNameMap.get(sourceNodeName);
|
|
90
|
+
if (!sourcePropertyName) {
|
|
91
|
+
console.warn(`Warning: Unknown source node "${sourceNodeName}" in connections`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
// Iterate output types (usually "main", "error", or ai_*)
|
|
95
|
+
for (const [outputType, outputGroups] of Object.entries(outputs)) {
|
|
96
|
+
// Skip AI connection types (handled by extractAIDependencies)
|
|
97
|
+
if (AI_CONNECTION_TYPES.includes(outputType)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
// For each output index
|
|
101
|
+
outputGroups.forEach((group, outputIndex) => {
|
|
102
|
+
// For each target in this output
|
|
103
|
+
group.forEach((target) => {
|
|
104
|
+
const targetPropertyName = nodeNameMap.get(target.node);
|
|
105
|
+
if (!targetPropertyName) {
|
|
106
|
+
console.warn(`Warning: Unknown target node "${target.node}" in connections`);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
result.push({
|
|
110
|
+
from: {
|
|
111
|
+
node: sourcePropertyName,
|
|
112
|
+
output: outputIndex,
|
|
113
|
+
isError: outputType === 'error'
|
|
114
|
+
},
|
|
115
|
+
to: {
|
|
116
|
+
node: targetPropertyName,
|
|
117
|
+
input: target.index || 0
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Extract AI dependencies from connections and populate node aiDependencies
|
|
128
|
+
*
|
|
129
|
+
* AI dependencies are connections like:
|
|
130
|
+
* - ai_languageModel: The LLM model for an agent
|
|
131
|
+
* - ai_memory: Memory buffer for an agent
|
|
132
|
+
* - ai_outputParser: Output parser for structured responses
|
|
133
|
+
* - ai_tool: Tools available to an agent (array)
|
|
134
|
+
* - ai_agent: Agent sub-node
|
|
135
|
+
* - ai_chain: Chain sub-node
|
|
136
|
+
* - ai_document: Document loaders (array)
|
|
137
|
+
* - ai_textSplitter: Text splitter sub-node
|
|
138
|
+
* - ai_embedding: Embedding model sub-node
|
|
139
|
+
* - ai_retriever: Retriever sub-node for RAG
|
|
140
|
+
* - ai_reranker: Reranker sub-node
|
|
141
|
+
* - ai_vectorStore: Vector store sub-node
|
|
142
|
+
*/
|
|
143
|
+
extractAIDependencies(connections, nodeNameMap, nodes) {
|
|
144
|
+
if (!connections) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
// Create map for quick node lookup
|
|
148
|
+
const nodesByPropertyName = new Map();
|
|
149
|
+
nodes.forEach(node => nodesByPropertyName.set(node.propertyName, node));
|
|
150
|
+
for (const [sourceNodeName, outputs] of Object.entries(connections)) {
|
|
151
|
+
const sourcePropertyName = nodeNameMap.get(sourceNodeName);
|
|
152
|
+
if (!sourcePropertyName) {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
// Check each output type for AI connections
|
|
156
|
+
for (const [outputType, outputGroups] of Object.entries(outputs)) {
|
|
157
|
+
if (!outputType.startsWith('ai_')) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
// For each output index
|
|
161
|
+
outputGroups.forEach((group) => {
|
|
162
|
+
// For each target in this output
|
|
163
|
+
group.forEach((target) => {
|
|
164
|
+
const targetPropertyName = nodeNameMap.get(target.node);
|
|
165
|
+
if (!targetPropertyName) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
// Get the target node
|
|
169
|
+
const targetNode = nodesByPropertyName.get(targetPropertyName);
|
|
170
|
+
if (!targetNode) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Initialize aiDependencies if not exists
|
|
174
|
+
if (!targetNode.aiDependencies) {
|
|
175
|
+
targetNode.aiDependencies = {};
|
|
176
|
+
}
|
|
177
|
+
// Add dependency based on type
|
|
178
|
+
if (outputType === 'ai_languageModel') {
|
|
179
|
+
targetNode.aiDependencies.ai_languageModel = sourcePropertyName;
|
|
180
|
+
}
|
|
181
|
+
else if (outputType === 'ai_memory') {
|
|
182
|
+
targetNode.aiDependencies.ai_memory = sourcePropertyName;
|
|
183
|
+
}
|
|
184
|
+
else if (outputType === 'ai_outputParser') {
|
|
185
|
+
targetNode.aiDependencies.ai_outputParser = sourcePropertyName;
|
|
186
|
+
}
|
|
187
|
+
else if (outputType === 'ai_agent') {
|
|
188
|
+
targetNode.aiDependencies.ai_agent = sourcePropertyName;
|
|
189
|
+
}
|
|
190
|
+
else if (outputType === 'ai_chain') {
|
|
191
|
+
targetNode.aiDependencies.ai_chain = sourcePropertyName;
|
|
192
|
+
}
|
|
193
|
+
else if (outputType === 'ai_textSplitter') {
|
|
194
|
+
targetNode.aiDependencies.ai_textSplitter = sourcePropertyName;
|
|
195
|
+
}
|
|
196
|
+
else if (outputType === 'ai_embedding') {
|
|
197
|
+
targetNode.aiDependencies.ai_embedding = sourcePropertyName;
|
|
198
|
+
}
|
|
199
|
+
else if (outputType === 'ai_retriever') {
|
|
200
|
+
targetNode.aiDependencies.ai_retriever = sourcePropertyName;
|
|
201
|
+
}
|
|
202
|
+
else if (outputType === 'ai_reranker') {
|
|
203
|
+
targetNode.aiDependencies.ai_reranker = sourcePropertyName;
|
|
204
|
+
}
|
|
205
|
+
else if (outputType === 'ai_vectorStore') {
|
|
206
|
+
targetNode.aiDependencies.ai_vectorStore = sourcePropertyName;
|
|
207
|
+
}
|
|
208
|
+
else if (outputType === 'ai_tool' || outputType === 'ai_document') {
|
|
209
|
+
// ai_tool and ai_document are arrays
|
|
210
|
+
const arrayKey = outputType;
|
|
211
|
+
if (!targetNode.aiDependencies[arrayKey]) {
|
|
212
|
+
targetNode.aiDependencies[arrayKey] = [];
|
|
213
|
+
}
|
|
214
|
+
targetNode.aiDependencies[arrayKey].push(sourcePropertyName);
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=json-to-ast.js.map
|