n8n 2.29.8 → 2.29.9
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/dist/build.tsbuildinfo +1 -1
- package/dist/controllers/instance-ai-examples.controller.d.ts +31 -0
- package/dist/controllers/instance-ai-examples.controller.js +104 -0
- package/dist/controllers/instance-ai-examples.controller.js.map +1 -0
- package/dist/instance-ai-examples.data.json +277957 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +1 -0
- package/dist/server.js.map +1 -1
- package/package.json +26 -26
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InstanceAiExamplesQueryDto } from '@n8n/api-types';
|
|
2
|
+
interface ExampleNode {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
iconData?: {
|
|
7
|
+
type: string;
|
|
8
|
+
fileBuffer?: string;
|
|
9
|
+
icon?: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ExampleWorkflow {
|
|
13
|
+
id: number;
|
|
14
|
+
name: string;
|
|
15
|
+
category: string;
|
|
16
|
+
subcategory?: string;
|
|
17
|
+
relevanceScore?: number;
|
|
18
|
+
prompt?: string;
|
|
19
|
+
nodes: ExampleNode[];
|
|
20
|
+
}
|
|
21
|
+
export declare class InstanceAiExamplesController {
|
|
22
|
+
private cachedData;
|
|
23
|
+
getExamples(_req: unknown, _res: unknown, query: InstanceAiExamplesQueryDto): {
|
|
24
|
+
categories: string[];
|
|
25
|
+
subcategories: Record<string, string[]>;
|
|
26
|
+
totalWorkflows: number;
|
|
27
|
+
workflows: ExampleWorkflow[];
|
|
28
|
+
};
|
|
29
|
+
private loadData;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.InstanceAiExamplesController = void 0;
|
|
16
|
+
const api_types_1 = require("@n8n/api-types");
|
|
17
|
+
const decorators_1 = require("@n8n/decorators");
|
|
18
|
+
const node_fs_1 = require("node:fs");
|
|
19
|
+
const node_path_1 = require("node:path");
|
|
20
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
21
|
+
const constants_1 = require("../constants");
|
|
22
|
+
const NATIVE_NODE_PREFIXES = ['@n8n/n8n-nodes-langchain.'];
|
|
23
|
+
const NATIVE_NODES = new Set([
|
|
24
|
+
'n8n-nodes-base.code',
|
|
25
|
+
'n8n-nodes-base.httpRequest',
|
|
26
|
+
'n8n-nodes-base.html',
|
|
27
|
+
'n8n-nodes-base.crypto',
|
|
28
|
+
'n8n-nodes-base.editImage',
|
|
29
|
+
'n8n-nodes-base.ftp',
|
|
30
|
+
'n8n-nodes-base.evaluation',
|
|
31
|
+
'n8n-nodes-base.emailSend',
|
|
32
|
+
'n8n-nodes-base.sms77',
|
|
33
|
+
'n8n-nodes-base.apiTemplateIo',
|
|
34
|
+
]);
|
|
35
|
+
function hasVisibleNodes(nodes) {
|
|
36
|
+
return nodes.some((n) => !NATIVE_NODES.has(n.name) && !NATIVE_NODE_PREFIXES.some((p) => n.name.startsWith(p)));
|
|
37
|
+
}
|
|
38
|
+
let InstanceAiExamplesController = class InstanceAiExamplesController {
|
|
39
|
+
constructor() {
|
|
40
|
+
this.cachedData = null;
|
|
41
|
+
}
|
|
42
|
+
getExamples(_req, _res, query) {
|
|
43
|
+
const data = this.loadData();
|
|
44
|
+
const { category, subcategory, page, limit } = query;
|
|
45
|
+
let workflows = data.workflows;
|
|
46
|
+
if (category) {
|
|
47
|
+
workflows = workflows.filter((w) => w.category === category);
|
|
48
|
+
}
|
|
49
|
+
if (subcategory) {
|
|
50
|
+
workflows = workflows.filter((w) => w.subcategory === subcategory);
|
|
51
|
+
}
|
|
52
|
+
const totalWorkflows = workflows.length;
|
|
53
|
+
const offset = (page - 1) * limit;
|
|
54
|
+
const paginatedWorkflows = workflows.slice(offset, offset + limit);
|
|
55
|
+
return {
|
|
56
|
+
categories: data.categories,
|
|
57
|
+
subcategories: data.subcategories,
|
|
58
|
+
totalWorkflows,
|
|
59
|
+
workflows: paginatedWorkflows,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
loadData() {
|
|
63
|
+
if (this.cachedData) {
|
|
64
|
+
return this.cachedData;
|
|
65
|
+
}
|
|
66
|
+
const filePath = (0, node_path_1.resolve)(constants_1.CLI_DIR, 'dist', 'instance-ai-examples.data.json');
|
|
67
|
+
const raw = (0, node_fs_1.readFileSync)(filePath, 'utf-8');
|
|
68
|
+
const rawData = (0, n8n_workflow_1.jsonParse)(raw);
|
|
69
|
+
const workflows = rawData.workflows.map((w) => ({
|
|
70
|
+
...w,
|
|
71
|
+
nodes: w.nodes.map((n) => ({
|
|
72
|
+
...n,
|
|
73
|
+
iconData: rawData.nodeIcons[n.name],
|
|
74
|
+
})),
|
|
75
|
+
}));
|
|
76
|
+
workflows.sort((a, b) => {
|
|
77
|
+
const scoreDiff = (b.relevanceScore ?? 0) - (a.relevanceScore ?? 0);
|
|
78
|
+
if (scoreDiff !== 0)
|
|
79
|
+
return scoreDiff;
|
|
80
|
+
const aVisible = hasVisibleNodes(a.nodes) ? 1 : 0;
|
|
81
|
+
const bVisible = hasVisibleNodes(b.nodes) ? 1 : 0;
|
|
82
|
+
return bVisible - aVisible;
|
|
83
|
+
});
|
|
84
|
+
this.cachedData = {
|
|
85
|
+
categories: rawData.categories,
|
|
86
|
+
subcategories: rawData.subcategories,
|
|
87
|
+
totalWorkflows: rawData.totalWorkflows,
|
|
88
|
+
workflows,
|
|
89
|
+
};
|
|
90
|
+
return this.cachedData;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
exports.InstanceAiExamplesController = InstanceAiExamplesController;
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, decorators_1.Get)('/', { skipAuth: true }),
|
|
96
|
+
__param(2, decorators_1.Query),
|
|
97
|
+
__metadata("design:type", Function),
|
|
98
|
+
__metadata("design:paramtypes", [Object, Object, api_types_1.InstanceAiExamplesQueryDto]),
|
|
99
|
+
__metadata("design:returntype", void 0)
|
|
100
|
+
], InstanceAiExamplesController.prototype, "getExamples", null);
|
|
101
|
+
exports.InstanceAiExamplesController = InstanceAiExamplesController = __decorate([
|
|
102
|
+
(0, decorators_1.RestController)('/instance-ai-examples')
|
|
103
|
+
], InstanceAiExamplesController);
|
|
104
|
+
//# sourceMappingURL=instance-ai-examples.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-ai-examples.controller.js","sourceRoot":"","sources":["../../src/controllers/instance-ai-examples.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,8CAA4D;AAC5D,gDAA6D;AAC7D,qCAAuC;AACvC,yCAAoC;AACpC,+CAAyC;AAEzC,2CAAsC;AAkCtC,MAAM,oBAAoB,GAAG,CAAC,2BAA2B,CAAC,CAAC;AAC3D,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC5B,qBAAqB;IACr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