@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,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @node decorator implementation
|
|
3
|
+
*/
|
|
4
|
+
import 'reflect-metadata';
|
|
5
|
+
import { NodeDecoratorMetadata } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* @node decorator
|
|
8
|
+
*
|
|
9
|
+
* Marks a property as an n8n node and stores metadata
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @node({
|
|
14
|
+
* name: "🕘 Schedule Trigger",
|
|
15
|
+
* type: "n8n-nodes-base.scheduleTrigger",
|
|
16
|
+
* version: 1.2,
|
|
17
|
+
* position: [-1072, 720]
|
|
18
|
+
* })
|
|
19
|
+
* ScheduleTrigger = {
|
|
20
|
+
* rule: { interval: [{ field: "cronExpression", expression: "0 9 * * 1-5" }] }
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function node(metadata: NodeDecoratorMetadata): (target: any, propertyKey: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Extract all node metadata from a class
|
|
27
|
+
* Used by the TypeScript → JSON compiler
|
|
28
|
+
*
|
|
29
|
+
* @returns Map of propertyName → NodeDecoratorMetadata
|
|
30
|
+
*/
|
|
31
|
+
export declare function getNodeMetadata(target: any): Map<string, NodeDecoratorMetadata>;
|
|
32
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/decorators/node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAiB,MAAM,YAAY,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,qBAAqB,IAC/B,QAAQ,GAAG,EAAE,aAAa,MAAM,UAUpD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAE/E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @node decorator implementation
|
|
3
|
+
*/
|
|
4
|
+
import 'reflect-metadata';
|
|
5
|
+
import { METADATA_KEYS } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* @node decorator
|
|
8
|
+
*
|
|
9
|
+
* Marks a property as an n8n node and stores metadata
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @node({
|
|
14
|
+
* name: "🕘 Schedule Trigger",
|
|
15
|
+
* type: "n8n-nodes-base.scheduleTrigger",
|
|
16
|
+
* version: 1.2,
|
|
17
|
+
* position: [-1072, 720]
|
|
18
|
+
* })
|
|
19
|
+
* ScheduleTrigger = {
|
|
20
|
+
* rule: { interval: [{ field: "cronExpression", expression: "0 9 * * 1-5" }] }
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function node(metadata) {
|
|
25
|
+
return function (target, propertyKey) {
|
|
26
|
+
// Get existing nodes metadata or create new map
|
|
27
|
+
const existingNodes = Reflect.getMetadata(METADATA_KEYS.NODE, target.constructor) || new Map();
|
|
28
|
+
// Store metadata for this specific property
|
|
29
|
+
existingNodes.set(propertyKey, metadata);
|
|
30
|
+
// Update metadata on class
|
|
31
|
+
Reflect.defineMetadata(METADATA_KEYS.NODE, existingNodes, target.constructor);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Extract all node metadata from a class
|
|
36
|
+
* Used by the TypeScript → JSON compiler
|
|
37
|
+
*
|
|
38
|
+
* @returns Map of propertyName → NodeDecoratorMetadata
|
|
39
|
+
*/
|
|
40
|
+
export function getNodeMetadata(target) {
|
|
41
|
+
return Reflect.getMetadata(METADATA_KEYS.NODE, target) || new Map();
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/decorators/node.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAyB,aAAa,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,IAAI,CAAC,QAA+B;IAChD,OAAO,UAAU,MAAW,EAAE,WAAmB;QAC7C,gDAAgD;QAChD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;QAE/F,4CAA4C;QAC5C,aAAa,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QAEzC,2BAA2B;QAC3B,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAClF,CAAC,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAW;IACvC,OAAO,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,GAAG,EAAE,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorator Types and Metadata
|
|
3
|
+
*/
|
|
4
|
+
import { WorkflowSettings, CredentialReference } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Metadata for @workflow decorator
|
|
7
|
+
*/
|
|
8
|
+
export interface WorkflowDecoratorMetadata {
|
|
9
|
+
id: string;
|
|
10
|
+
name: string;
|
|
11
|
+
active: boolean;
|
|
12
|
+
settings?: WorkflowSettings;
|
|
13
|
+
projectId?: string;
|
|
14
|
+
projectName?: string;
|
|
15
|
+
homeProject?: {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
isArchived?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Metadata for @node decorator
|
|
24
|
+
*/
|
|
25
|
+
export interface NodeDecoratorMetadata {
|
|
26
|
+
/** Display name of the node */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Node type (e.g., "n8n-nodes-base.scheduleTrigger") */
|
|
29
|
+
type: string;
|
|
30
|
+
/** Node version */
|
|
31
|
+
version: number;
|
|
32
|
+
/** Position [x, y] - optional for auto-layout */
|
|
33
|
+
position?: [number, number];
|
|
34
|
+
/** Credentials for this node */
|
|
35
|
+
credentials?: Record<string, CredentialReference>;
|
|
36
|
+
/** Error handling behavior */
|
|
37
|
+
onError?: 'continueErrorOutput' | 'continueRegularOutput' | 'stopWorkflow';
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Node proxy for fluent API in defineRouting()
|
|
41
|
+
*/
|
|
42
|
+
export interface NodeProxy {
|
|
43
|
+
/** Reference to property name */
|
|
44
|
+
_propertyName: string;
|
|
45
|
+
/** Output connection builder */
|
|
46
|
+
out(index: number): OutputConnection;
|
|
47
|
+
/** Input connection builder */
|
|
48
|
+
in(index: number): InputConnection;
|
|
49
|
+
/** Error output connection builder */
|
|
50
|
+
error(): OutputConnection;
|
|
51
|
+
/** AI dependency injection */
|
|
52
|
+
uses(dependencies: AIDependencyMap): void;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Output connection (from node)
|
|
56
|
+
*/
|
|
57
|
+
export interface OutputConnection {
|
|
58
|
+
_from: {
|
|
59
|
+
node: string;
|
|
60
|
+
output: number;
|
|
61
|
+
isError?: boolean;
|
|
62
|
+
};
|
|
63
|
+
/** Connect to input */
|
|
64
|
+
to(input: InputConnection): void;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Input connection (to node)
|
|
68
|
+
*/
|
|
69
|
+
export interface InputConnection {
|
|
70
|
+
_to: {
|
|
71
|
+
node: string;
|
|
72
|
+
input: number;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* AI dependency map (for .uses())
|
|
77
|
+
*/
|
|
78
|
+
export interface AIDependencyMap {
|
|
79
|
+
ai_languageModel?: {
|
|
80
|
+
output: any;
|
|
81
|
+
};
|
|
82
|
+
ai_memory?: {
|
|
83
|
+
output: any;
|
|
84
|
+
};
|
|
85
|
+
ai_outputParser?: {
|
|
86
|
+
output: any;
|
|
87
|
+
};
|
|
88
|
+
ai_tool?: Array<{
|
|
89
|
+
output: any;
|
|
90
|
+
}>;
|
|
91
|
+
ai_agent?: {
|
|
92
|
+
output: any;
|
|
93
|
+
};
|
|
94
|
+
ai_chain?: {
|
|
95
|
+
output: any;
|
|
96
|
+
};
|
|
97
|
+
ai_document?: Array<{
|
|
98
|
+
output: any;
|
|
99
|
+
}>;
|
|
100
|
+
ai_textSplitter?: {
|
|
101
|
+
output: any;
|
|
102
|
+
};
|
|
103
|
+
ai_embedding?: {
|
|
104
|
+
output: any;
|
|
105
|
+
};
|
|
106
|
+
ai_retriever?: {
|
|
107
|
+
output: any;
|
|
108
|
+
};
|
|
109
|
+
ai_reranker?: {
|
|
110
|
+
output: any;
|
|
111
|
+
};
|
|
112
|
+
ai_vectorStore?: {
|
|
113
|
+
output: any;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export declare const METADATA_KEYS: {
|
|
117
|
+
readonly WORKFLOW: "n8n:workflow";
|
|
118
|
+
readonly NODE: "n8n:node";
|
|
119
|
+
readonly CONNECTIONS: "n8n:connections";
|
|
120
|
+
readonly AI_DEPENDENCIES: "n8n:ai_dependencies";
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/decorators/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorator Types and Metadata
|
|
3
|
+
*/
|
|
4
|
+
// =====================================================================
|
|
5
|
+
// METADATA KEYS (for reflect-metadata)
|
|
6
|
+
// =====================================================================
|
|
7
|
+
export const METADATA_KEYS = {
|
|
8
|
+
WORKFLOW: 'n8n:workflow',
|
|
9
|
+
NODE: 'n8n:node',
|
|
10
|
+
CONNECTIONS: 'n8n:connections',
|
|
11
|
+
AI_DEPENDENCIES: 'n8n:ai_dependencies'
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/decorators/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAqHH,wEAAwE;AACxE,uCAAuC;AACvC,wEAAwE;AAExE,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,QAAQ,EAAE,cAAc;IACxB,IAAI,EAAE,UAAU;IAChB,WAAW,EAAE,iBAAiB;IAC9B,eAAe,EAAE,qBAAqB;CAChC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @workflow decorator implementation
|
|
3
|
+
*/
|
|
4
|
+
import 'reflect-metadata';
|
|
5
|
+
import { WorkflowDecoratorMetadata } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* @workflow decorator
|
|
8
|
+
*
|
|
9
|
+
* Marks a class as an n8n workflow and stores metadata
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @workflow({
|
|
14
|
+
* id: "G9GXzwX97XBKAwcj",
|
|
15
|
+
* name: "Job Application Assistant",
|
|
16
|
+
* active: false,
|
|
17
|
+
* settings: { executionOrder: "v1" }
|
|
18
|
+
* })
|
|
19
|
+
* export class JobApplicationWorkflow {
|
|
20
|
+
* // ...
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function workflow(metadata: WorkflowDecoratorMetadata): <T extends {
|
|
25
|
+
new (...args: any[]): {};
|
|
26
|
+
}>(constructor: T) => T;
|
|
27
|
+
/**
|
|
28
|
+
* Extract workflow metadata from a class
|
|
29
|
+
* Used by the TypeScript → JSON compiler
|
|
30
|
+
*/
|
|
31
|
+
export declare function getWorkflowMetadata(target: any): WorkflowDecoratorMetadata | null;
|
|
32
|
+
//# sourceMappingURL=workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/decorators/workflow.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAAiB,MAAM,YAAY,CAAC;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,yBAAyB,IACvC,CAAC,SAAS;IAAE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAA;CAAE,EAAE,aAAa,CAAC,OAM1E;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,yBAAyB,GAAG,IAAI,CAEjF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @workflow decorator implementation
|
|
3
|
+
*/
|
|
4
|
+
import 'reflect-metadata';
|
|
5
|
+
import { METADATA_KEYS } from './types.js';
|
|
6
|
+
/**
|
|
7
|
+
* @workflow decorator
|
|
8
|
+
*
|
|
9
|
+
* Marks a class as an n8n workflow and stores metadata
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* @workflow({
|
|
14
|
+
* id: "G9GXzwX97XBKAwcj",
|
|
15
|
+
* name: "Job Application Assistant",
|
|
16
|
+
* active: false,
|
|
17
|
+
* settings: { executionOrder: "v1" }
|
|
18
|
+
* })
|
|
19
|
+
* export class JobApplicationWorkflow {
|
|
20
|
+
* // ...
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function workflow(metadata) {
|
|
25
|
+
return function (constructor) {
|
|
26
|
+
// Store workflow metadata on the class
|
|
27
|
+
Reflect.defineMetadata(METADATA_KEYS.WORKFLOW, metadata, constructor);
|
|
28
|
+
return constructor;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Extract workflow metadata from a class
|
|
33
|
+
* Used by the TypeScript → JSON compiler
|
|
34
|
+
*/
|
|
35
|
+
export function getWorkflowMetadata(target) {
|
|
36
|
+
return Reflect.getMetadata(METADATA_KEYS.WORKFLOW, target) || null;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../../src/decorators/workflow.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAA6B,aAAa,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAmC;IACxD,OAAO,UAAkD,WAAc;QACnE,uCAAuC;QACvC,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;QAEtE,OAAO,WAAW,CAAC;IACvB,CAAC,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAW;IAC3C,OAAO,OAAO,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC;AACvE,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @n8n-as-code/transformer
|
|
3
|
+
*
|
|
4
|
+
* Bidirectional transformer: n8n JSON workflows ↔ TypeScript
|
|
5
|
+
*/
|
|
6
|
+
export { workflow, node, links } from './decorators/index.js';
|
|
7
|
+
export type { WorkflowDecoratorMetadata, NodeDecoratorMetadata, NodeProxy, OutputConnection, InputConnection, AIDependencyMap } from './decorators/index.js';
|
|
8
|
+
export { JsonToAstParser } from './parser/index.js';
|
|
9
|
+
export { AstToTypeScriptGenerator } from './parser/index.js';
|
|
10
|
+
export { TypeScriptParser } from './compiler/index.js';
|
|
11
|
+
export { WorkflowBuilder } from './compiler/index.js';
|
|
12
|
+
export type { WorkflowAST, NodeAST, ConnectionAST, WorkflowMetadata, N8nWorkflow, N8nNode, N8nConnections, JsonToTypeScriptOptions, TypeScriptToJsonOptions, ValidationResult, ValidationError, ValidationWarning } from './types.js';
|
|
13
|
+
export { generatePropertyName, generateClassName, createPropertyNameContext } from './utils/index.js';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACH,QAAQ,EACR,IAAI,EACJ,KAAK,EACR,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACR,yBAAyB,EACzB,qBAAqB,EACrB,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,eAAe,EAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,YAAY,EACR,WAAW,EACX,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,cAAc,EACd,uBAAuB,EACvB,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACpB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACH,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EAC5B,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @n8n-as-code/transformer
|
|
3
|
+
*
|
|
4
|
+
* Bidirectional transformer: n8n JSON workflows ↔ TypeScript
|
|
5
|
+
*/
|
|
6
|
+
// Decorators (public API for workflow .ts files)
|
|
7
|
+
export { workflow, node, links } from './decorators/index.js';
|
|
8
|
+
// Transformers (for internal use by sync/skills packages)
|
|
9
|
+
export { JsonToAstParser } from './parser/index.js';
|
|
10
|
+
export { AstToTypeScriptGenerator } from './parser/index.js';
|
|
11
|
+
export { TypeScriptParser } from './compiler/index.js';
|
|
12
|
+
export { WorkflowBuilder } from './compiler/index.js';
|
|
13
|
+
// Utilities
|
|
14
|
+
export { generatePropertyName, generateClassName, createPropertyNameContext } from './utils/index.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iDAAiD;AACjD,OAAO,EACH,QAAQ,EACR,IAAI,EACJ,KAAK,EACR,MAAM,uBAAuB,CAAC;AAW/B,0DAA0D;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAkBtD,YAAY;AACZ,OAAO,EACH,oBAAoB,EACpB,iBAAiB,EACjB,yBAAyB,EAC5B,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AST to TypeScript Generator
|
|
3
|
+
*
|
|
4
|
+
* Generates TypeScript code from AST representation
|
|
5
|
+
*/
|
|
6
|
+
import { WorkflowAST, JsonToTypeScriptOptions } from '../types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Generate TypeScript code from AST
|
|
9
|
+
*/
|
|
10
|
+
export declare class AstToTypeScriptGenerator {
|
|
11
|
+
/**
|
|
12
|
+
* Generate TypeScript code
|
|
13
|
+
*/
|
|
14
|
+
generate(ast: WorkflowAST, options?: JsonToTypeScriptOptions): Promise<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Generate the workflow-map comment block.
|
|
17
|
+
* This block is ignored by TypeScriptParser (it is a plain comment) but
|
|
18
|
+
* provides a fast orientation index for AI agents and human developers:
|
|
19
|
+
* 1. NODE INDEX — property name, line hint (approximate), short node type
|
|
20
|
+
* 2. ROUTING MAP — ASCII flow of main + AI connections
|
|
21
|
+
*
|
|
22
|
+
* Agents should read this block first (between <workflow-map> tags) before
|
|
23
|
+
* opening the full file, to quickly locate the sections they need to edit.
|
|
24
|
+
*/
|
|
25
|
+
private generateWorkflowMap;
|
|
26
|
+
/**
|
|
27
|
+
* Generate imports
|
|
28
|
+
*/
|
|
29
|
+
private generateImports;
|
|
30
|
+
/**
|
|
31
|
+
* Generate class header with @workflow decorator
|
|
32
|
+
*/
|
|
33
|
+
private generateClassHeader;
|
|
34
|
+
/**
|
|
35
|
+
* Format @workflow decorator content
|
|
36
|
+
*/
|
|
37
|
+
private formatWorkflowDecorator;
|
|
38
|
+
/**
|
|
39
|
+
* Generate node declarations
|
|
40
|
+
*/
|
|
41
|
+
private generateNodes;
|
|
42
|
+
/**
|
|
43
|
+
* Generate single node declaration
|
|
44
|
+
*/
|
|
45
|
+
private generateNodeDeclaration;
|
|
46
|
+
/**
|
|
47
|
+
* Format @node decorator content
|
|
48
|
+
*/
|
|
49
|
+
private formatNodeDecorator;
|
|
50
|
+
/**
|
|
51
|
+
* Generate routing section (@links)
|
|
52
|
+
*/
|
|
53
|
+
private generateRouting;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=ast-to-typescript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-to-typescript.d.ts","sourceRoot":"","sources":["../../src/parser/ast-to-typescript.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAA0B,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAQ3F;;GAEG;AACH,qBAAa,wBAAwB;IACjC;;OAEG;IACG,QAAQ,CAAC,GAAG,EAAE,WAAW,EAAE,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,MAAM,CAAC;IAuCxF;;;;;;;;;OASG;IACH,OAAO,CAAC,mBAAmB;IA4G3B;;OAEG;IACH,OAAO,CAAC,eAAe;IAOvB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAgB/B;;OAEG;IACH,OAAO,CAAC,aAAa;IAkBrB;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAkB/B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAuB3B;;OAEG;IACH,OAAO,CAAC,eAAe;CA+F1B"}
|