@lhi/n8m 0.2.4 → 0.3.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 +149 -11
- package/dist/agentic/graph.d.ts +16 -4
- package/dist/agentic/nodes/architect.d.ts +2 -2
- package/dist/agentic/nodes/architect.js +5 -1
- package/dist/agentic/nodes/engineer.d.ts +6 -0
- package/dist/agentic/nodes/engineer.js +39 -5
- package/dist/commands/create.js +38 -1
- package/dist/commands/deploy.d.ts +2 -1
- package/dist/commands/deploy.js +119 -19
- package/dist/commands/fixture.js +31 -8
- package/dist/commands/learn.d.ts +19 -0
- package/dist/commands/learn.js +277 -0
- package/dist/commands/modify.js +210 -68
- package/dist/commands/test.d.ts +4 -0
- package/dist/commands/test.js +118 -14
- package/dist/services/ai.service.d.ts +33 -0
- package/dist/services/ai.service.js +337 -2
- package/dist/services/node-definitions.service.d.ts +8 -0
- package/dist/services/node-definitions.service.js +45 -0
- package/dist/utils/fixtureManager.d.ts +10 -0
- package/dist/utils/fixtureManager.js +43 -4
- package/dist/utils/multilinePrompt.js +33 -47
- package/dist/utils/n8nClient.js +60 -11
- package/docs/DEVELOPER_GUIDE.md +598 -0
- package/docs/N8N_NODE_REFERENCE.md +369 -0
- package/docs/patterns/bigquery-via-http.md +110 -0
- package/oclif.manifest.json +82 -3
- package/package.json +3 -1
- package/dist/fixture-schema.json +0 -162
- package/dist/resources/node-definitions-fallback.json +0 -390
- package/dist/resources/node-test-hints.json +0 -188
- package/dist/resources/workflow-test-fixtures.json +0 -42
package/dist/utils/n8nClient.js
CHANGED
|
@@ -128,13 +128,56 @@ export class N8nClient {
|
|
|
128
128
|
*/
|
|
129
129
|
async updateWorkflow(workflowId, workflowData) {
|
|
130
130
|
try {
|
|
131
|
-
const
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
const w = workflowData;
|
|
132
|
+
const settings = { ...(w.settings || {}) };
|
|
133
|
+
delete settings.timezone;
|
|
134
|
+
const SAFE_NODE_PROPS = new Set([
|
|
135
|
+
'id', 'name', 'type', 'typeVersion', 'position', 'parameters',
|
|
136
|
+
'credentials', 'disabled', 'webhookId', 'notes', 'notesInFlow',
|
|
137
|
+
'continueOnFail', 'alwaysOutputData', 'executeOnce', 'retryOnFail',
|
|
138
|
+
'maxTries', 'waitBetweenTries',
|
|
139
|
+
]);
|
|
140
|
+
const buildPayload = (sanitizeNodes, includeVersionId) => {
|
|
141
|
+
const nodes = sanitizeNodes
|
|
142
|
+
? (w.nodes || []).map((node) => {
|
|
143
|
+
const clean = {};
|
|
144
|
+
for (const key of Object.keys(node)) {
|
|
145
|
+
if (SAFE_NODE_PROPS.has(key))
|
|
146
|
+
clean[key] = node[key];
|
|
147
|
+
}
|
|
148
|
+
return clean;
|
|
149
|
+
})
|
|
150
|
+
: w.nodes;
|
|
151
|
+
const payload = {
|
|
152
|
+
name: w.name,
|
|
153
|
+
nodes,
|
|
154
|
+
connections: w.connections,
|
|
155
|
+
settings,
|
|
156
|
+
};
|
|
157
|
+
if (includeVersionId && w.versionId)
|
|
158
|
+
payload.versionId = w.versionId;
|
|
159
|
+
return payload;
|
|
160
|
+
};
|
|
161
|
+
const attempts = [
|
|
162
|
+
buildPayload(false, true), // full nodes + versionId
|
|
163
|
+
buildPayload(true, true), // sanitized nodes + versionId
|
|
164
|
+
buildPayload(true, false), // sanitized nodes, no versionId
|
|
165
|
+
];
|
|
166
|
+
let response;
|
|
167
|
+
let errorText = '';
|
|
168
|
+
for (const payload of attempts) {
|
|
169
|
+
response = await fetch(`${this.apiUrl}/workflows/${workflowId}`, {
|
|
170
|
+
body: JSON.stringify(payload),
|
|
171
|
+
headers: this.headers,
|
|
172
|
+
method: 'PUT',
|
|
173
|
+
});
|
|
174
|
+
if (response.ok)
|
|
175
|
+
return;
|
|
176
|
+
errorText = await response.text();
|
|
177
|
+
if (response.status !== 400 || !errorText.includes('additional properties'))
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
throw new Error(`update workflow failed: ${response.status} - ${errorText}`);
|
|
138
181
|
}
|
|
139
182
|
catch (error) {
|
|
140
183
|
throw new Error(`Failed to update workflow: ${error.message}`);
|
|
@@ -174,10 +217,15 @@ export class N8nClient {
|
|
|
174
217
|
*/
|
|
175
218
|
async createWorkflow(name, workflowData) {
|
|
176
219
|
try {
|
|
177
|
-
const
|
|
220
|
+
const w = workflowData;
|
|
221
|
+
const settings = { ...(w.settings || {}) };
|
|
222
|
+
delete settings.timezone;
|
|
223
|
+
const payload = {
|
|
178
224
|
name,
|
|
179
|
-
|
|
180
|
-
|
|
225
|
+
nodes: w.nodes ?? [],
|
|
226
|
+
connections: w.connections ?? {},
|
|
227
|
+
settings,
|
|
228
|
+
};
|
|
181
229
|
const response = await fetch(`${this.apiUrl}/workflows`, {
|
|
182
230
|
body: JSON.stringify(payload),
|
|
183
231
|
headers: this.headers,
|
|
@@ -257,7 +305,7 @@ export class N8nClient {
|
|
|
257
305
|
allWorkflows = [...allWorkflows, ...result.data];
|
|
258
306
|
cursor = result.nextCursor;
|
|
259
307
|
} while (cursor);
|
|
260
|
-
return allWorkflows;
|
|
308
|
+
return allWorkflows.filter((w) => !w.isArchived);
|
|
261
309
|
}
|
|
262
310
|
catch (error) {
|
|
263
311
|
throw new Error(`Failed to fetch workflows: ${error.message}`);
|
|
@@ -503,6 +551,7 @@ export class N8nClient {
|
|
|
503
551
|
mode: 'runOnceForAllItems',
|
|
504
552
|
jsCode: N8nClient.buildNetworkShimCode(node.type),
|
|
505
553
|
},
|
|
554
|
+
...(node.onError ? { onError: node.onError } : {}),
|
|
506
555
|
};
|
|
507
556
|
});
|
|
508
557
|
}
|