@octo-cyber/workflow 0.5.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/dist/controllers/ai-workflow-session.controller.d.ts +19 -0
- package/dist/controllers/ai-workflow-session.controller.d.ts.map +1 -0
- package/dist/controllers/ai-workflow-session.controller.js +135 -0
- package/dist/controllers/ai-workflow-session.controller.js.map +1 -0
- package/dist/controllers/credential.controller.d.ts +68 -0
- package/dist/controllers/credential.controller.d.ts.map +1 -0
- package/dist/controllers/credential.controller.js +303 -0
- package/dist/controllers/credential.controller.js.map +1 -0
- package/dist/controllers/index.d.ts +3 -0
- package/dist/controllers/index.d.ts.map +1 -0
- package/dist/controllers/index.js +8 -0
- package/dist/controllers/index.js.map +1 -0
- package/dist/controllers/workflow-ai.controller.d.ts +23 -0
- package/dist/controllers/workflow-ai.controller.d.ts.map +1 -0
- package/dist/controllers/workflow-ai.controller.js +164 -0
- package/dist/controllers/workflow-ai.controller.js.map +1 -0
- package/dist/controllers/workflow.controller.d.ts +66 -0
- package/dist/controllers/workflow.controller.d.ts.map +1 -0
- package/dist/controllers/workflow.controller.js +239 -0
- package/dist/controllers/workflow.controller.js.map +1 -0
- package/dist/core/expression-resolver.d.ts +49 -0
- package/dist/core/expression-resolver.d.ts.map +1 -0
- package/dist/core/expression-resolver.js +113 -0
- package/dist/core/expression-resolver.js.map +1 -0
- package/dist/core/node-registry.d.ts +24 -0
- package/dist/core/node-registry.d.ts.map +1 -0
- package/dist/core/node-registry.js +62 -0
- package/dist/core/node-registry.js.map +1 -0
- package/dist/core/workflow-executor.d.ts +50 -0
- package/dist/core/workflow-executor.d.ts.map +1 -0
- package/dist/core/workflow-executor.js +458 -0
- package/dist/core/workflow-executor.js.map +1 -0
- package/dist/entities/ai-workflow-session.entity.d.ts +17 -0
- package/dist/entities/ai-workflow-session.entity.d.ts.map +1 -0
- package/dist/entities/ai-workflow-session.entity.js +70 -0
- package/dist/entities/ai-workflow-session.entity.js.map +1 -0
- package/dist/entities/ai-workflow-version.entity.d.ts +18 -0
- package/dist/entities/ai-workflow-version.entity.d.ts.map +1 -0
- package/dist/entities/ai-workflow-version.entity.js +71 -0
- package/dist/entities/ai-workflow-version.entity.js.map +1 -0
- package/dist/entities/credential-definition.entity.d.ts +17 -0
- package/dist/entities/credential-definition.entity.d.ts.map +1 -0
- package/dist/entities/credential-definition.entity.js +66 -0
- package/dist/entities/credential-definition.entity.js.map +1 -0
- package/dist/entities/index.d.ts +9 -0
- package/dist/entities/index.d.ts.map +1 -0
- package/dist/entities/index.js +22 -0
- package/dist/entities/index.js.map +1 -0
- package/dist/entities/workflow-definition.entity.d.ts +20 -0
- package/dist/entities/workflow-definition.entity.d.ts.map +1 -0
- package/dist/entities/workflow-definition.entity.js +85 -0
- package/dist/entities/workflow-definition.entity.js.map +1 -0
- package/dist/entities/workflow-execution.entity.d.ts +26 -0
- package/dist/entities/workflow-execution.entity.d.ts.map +1 -0
- package/dist/entities/workflow-execution.entity.js +99 -0
- package/dist/entities/workflow-execution.entity.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -0
- package/dist/n8n/cipher/cipher.d.ts +11 -0
- package/dist/n8n/cipher/cipher.d.ts.map +1 -0
- package/dist/n8n/cipher/cipher.js +54 -0
- package/dist/n8n/cipher/cipher.js.map +1 -0
- package/dist/n8n/controllers/n8n-session.controller.d.ts +20 -0
- package/dist/n8n/controllers/n8n-session.controller.d.ts.map +1 -0
- package/dist/n8n/controllers/n8n-session.controller.js +84 -0
- package/dist/n8n/controllers/n8n-session.controller.js.map +1 -0
- package/dist/n8n/index.d.ts +8 -0
- package/dist/n8n/index.d.ts.map +1 -0
- package/dist/n8n/index.js +14 -0
- package/dist/n8n/index.js.map +1 -0
- package/dist/n8n/launcher/n8n-launcher.d.ts +41 -0
- package/dist/n8n/launcher/n8n-launcher.d.ts.map +1 -0
- package/dist/n8n/launcher/n8n-launcher.js +186 -0
- package/dist/n8n/launcher/n8n-launcher.js.map +1 -0
- package/dist/n8n/nodes/OctoClaudeCliTool.node.d.ts +13 -0
- package/dist/n8n/nodes/OctoClaudeCliTool.node.d.ts.map +1 -0
- package/dist/n8n/nodes/OctoClaudeCliTool.node.js +103 -0
- package/dist/n8n/nodes/OctoClaudeCliTool.node.js.map +1 -0
- package/dist/n8n/nodes/OctoCliChatModel.node.d.ts +14 -0
- package/dist/n8n/nodes/OctoCliChatModel.node.d.ts.map +1 -0
- package/dist/n8n/nodes/OctoCliChatModel.node.js +431 -0
- package/dist/n8n/nodes/OctoCliChatModel.node.js.map +1 -0
- package/dist/n8n/nodes/OctoCodexCliTool.node.d.ts +13 -0
- package/dist/n8n/nodes/OctoCodexCliTool.node.d.ts.map +1 -0
- package/dist/n8n/nodes/OctoCodexCliTool.node.js +100 -0
- package/dist/n8n/nodes/OctoCodexCliTool.node.js.map +1 -0
- package/dist/n8n/nodes/OctoGeminiCliTool.node.d.ts +13 -0
- package/dist/n8n/nodes/OctoGeminiCliTool.node.d.ts.map +1 -0
- package/dist/n8n/nodes/OctoGeminiCliTool.node.js +91 -0
- package/dist/n8n/nodes/OctoGeminiCliTool.node.js.map +1 -0
- package/dist/n8n/nodes/OctoKnowledge.node.d.ts +6 -0
- package/dist/n8n/nodes/OctoKnowledge.node.d.ts.map +1 -0
- package/dist/n8n/nodes/OctoKnowledge.node.js +95 -0
- package/dist/n8n/nodes/OctoKnowledge.node.js.map +1 -0
- package/dist/n8n/nodes/OctoNotification.node.d.ts +6 -0
- package/dist/n8n/nodes/OctoNotification.node.d.ts.map +1 -0
- package/dist/n8n/nodes/OctoNotification.node.js +72 -0
- package/dist/n8n/nodes/OctoNotification.node.js.map +1 -0
- package/dist/n8n/nodes/OctoSyncBridge.node.d.ts +6 -0
- package/dist/n8n/nodes/OctoSyncBridge.node.d.ts.map +1 -0
- package/dist/n8n/nodes/OctoSyncBridge.node.js +60 -0
- package/dist/n8n/nodes/OctoSyncBridge.node.js.map +1 -0
- package/dist/n8n/nodes/n8n-node-types.d.ts +111 -0
- package/dist/n8n/nodes/n8n-node-types.d.ts.map +1 -0
- package/dist/n8n/nodes/n8n-node-types.js +30 -0
- package/dist/n8n/nodes/n8n-node-types.js.map +1 -0
- package/dist/n8n/nodes/octo-cli-chat-model.svg +23 -0
- package/dist/n8n/nodes/package.json +16 -0
- package/dist/n8n/proxy/css-injector.d.ts +3 -0
- package/dist/n8n/proxy/css-injector.d.ts.map +1 -0
- package/dist/n8n/proxy/css-injector.js +62 -0
- package/dist/n8n/proxy/css-injector.js.map +1 -0
- package/dist/n8n/proxy/n8n-proxy.middleware.d.ts +12 -0
- package/dist/n8n/proxy/n8n-proxy.middleware.d.ts.map +1 -0
- package/dist/n8n/proxy/n8n-proxy.middleware.js +131 -0
- package/dist/n8n/proxy/n8n-proxy.middleware.js.map +1 -0
- package/dist/n8n/proxy/n8n-theme.css +45 -0
- package/dist/n8n/sync/n8n-user-sync.service.d.ts +75 -0
- package/dist/n8n/sync/n8n-user-sync.service.d.ts.map +1 -0
- package/dist/n8n/sync/n8n-user-sync.service.js +286 -0
- package/dist/n8n/sync/n8n-user-sync.service.js.map +1 -0
- package/dist/n8n/watcher/n8n-execution-watcher.d.ts +39 -0
- package/dist/n8n/watcher/n8n-execution-watcher.d.ts.map +1 -0
- package/dist/n8n/watcher/n8n-execution-watcher.js +110 -0
- package/dist/n8n/watcher/n8n-execution-watcher.js.map +1 -0
- package/dist/nodes/code.node.d.ts +24 -0
- package/dist/nodes/code.node.d.ts.map +1 -0
- package/dist/nodes/code.node.js +150 -0
- package/dist/nodes/code.node.js.map +1 -0
- package/dist/nodes/error-trigger.node.d.ts +15 -0
- package/dist/nodes/error-trigger.node.d.ts.map +1 -0
- package/dist/nodes/error-trigger.node.js +53 -0
- package/dist/nodes/error-trigger.node.js.map +1 -0
- package/dist/nodes/execute-command.node.d.ts +9 -0
- package/dist/nodes/execute-command.node.d.ts.map +1 -0
- package/dist/nodes/execute-command.node.js +81 -0
- package/dist/nodes/execute-command.node.js.map +1 -0
- package/dist/nodes/filter.node.d.ts +10 -0
- package/dist/nodes/filter.node.d.ts.map +1 -0
- package/dist/nodes/filter.node.js +95 -0
- package/dist/nodes/filter.node.js.map +1 -0
- package/dist/nodes/http-request.node.d.ts +11 -0
- package/dist/nodes/http-request.node.d.ts.map +1 -0
- package/dist/nodes/http-request.node.js +139 -0
- package/dist/nodes/http-request.node.js.map +1 -0
- package/dist/nodes/if.node.d.ts +13 -0
- package/dist/nodes/if.node.d.ts.map +1 -0
- package/dist/nodes/if.node.js +137 -0
- package/dist/nodes/if.node.js.map +1 -0
- package/dist/nodes/index.d.ts +12 -0
- package/dist/nodes/index.d.ts.map +1 -0
- package/dist/nodes/index.js +26 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/manual-trigger.node.d.ts +10 -0
- package/dist/nodes/manual-trigger.node.d.ts.map +1 -0
- package/dist/nodes/manual-trigger.node.js +36 -0
- package/dist/nodes/manual-trigger.node.js.map +1 -0
- package/dist/nodes/merge.node.d.ts +15 -0
- package/dist/nodes/merge.node.d.ts.map +1 -0
- package/dist/nodes/merge.node.js +99 -0
- package/dist/nodes/merge.node.js.map +1 -0
- package/dist/nodes/noop.node.d.ts +12 -0
- package/dist/nodes/noop.node.d.ts.map +1 -0
- package/dist/nodes/noop.node.js +32 -0
- package/dist/nodes/noop.node.js.map +1 -0
- package/dist/nodes/placeholder.node.d.ts +10 -0
- package/dist/nodes/placeholder.node.d.ts.map +1 -0
- package/dist/nodes/placeholder.node.js +50 -0
- package/dist/nodes/placeholder.node.js.map +1 -0
- package/dist/nodes/remove-duplicates.node.d.ts +9 -0
- package/dist/nodes/remove-duplicates.node.d.ts.map +1 -0
- package/dist/nodes/remove-duplicates.node.js +68 -0
- package/dist/nodes/remove-duplicates.node.js.map +1 -0
- package/dist/nodes/respond-to-webhook.node.d.ts +14 -0
- package/dist/nodes/respond-to-webhook.node.d.ts.map +1 -0
- package/dist/nodes/respond-to-webhook.node.js +116 -0
- package/dist/nodes/respond-to-webhook.node.js.map +1 -0
- package/dist/nodes/schedule-trigger.node.d.ts +9 -0
- package/dist/nodes/schedule-trigger.node.d.ts.map +1 -0
- package/dist/nodes/schedule-trigger.node.js +67 -0
- package/dist/nodes/schedule-trigger.node.js.map +1 -0
- package/dist/nodes/set.node.d.ts +12 -0
- package/dist/nodes/set.node.d.ts.map +1 -0
- package/dist/nodes/set.node.js +81 -0
- package/dist/nodes/set.node.js.map +1 -0
- package/dist/nodes/sort.node.d.ts +9 -0
- package/dist/nodes/sort.node.d.ts.map +1 -0
- package/dist/nodes/sort.node.js +61 -0
- package/dist/nodes/sort.node.js.map +1 -0
- package/dist/nodes/split-in-batches.node.d.ts +9 -0
- package/dist/nodes/split-in-batches.node.d.ts.map +1 -0
- package/dist/nodes/split-in-batches.node.js +53 -0
- package/dist/nodes/split-in-batches.node.js.map +1 -0
- package/dist/nodes/split-out.node.d.ts +9 -0
- package/dist/nodes/split-out.node.d.ts.map +1 -0
- package/dist/nodes/split-out.node.js +76 -0
- package/dist/nodes/split-out.node.js.map +1 -0
- package/dist/nodes/switch.node.d.ts +16 -0
- package/dist/nodes/switch.node.d.ts.map +1 -0
- package/dist/nodes/switch.node.js +156 -0
- package/dist/nodes/switch.node.js.map +1 -0
- package/dist/nodes/wait.node.d.ts +12 -0
- package/dist/nodes/wait.node.d.ts.map +1 -0
- package/dist/nodes/wait.node.js +81 -0
- package/dist/nodes/wait.node.js.map +1 -0
- package/dist/nodes/webhook.node.d.ts +9 -0
- package/dist/nodes/webhook.node.d.ts.map +1 -0
- package/dist/nodes/webhook.node.js +69 -0
- package/dist/nodes/webhook.node.js.map +1 -0
- package/dist/services/ai-workflow-session.service.d.ts +31 -0
- package/dist/services/ai-workflow-session.service.d.ts.map +1 -0
- package/dist/services/ai-workflow-session.service.js +118 -0
- package/dist/services/ai-workflow-session.service.js.map +1 -0
- package/dist/services/credential.service.d.ts +57 -0
- package/dist/services/credential.service.d.ts.map +1 -0
- package/dist/services/credential.service.js +155 -0
- package/dist/services/credential.service.js.map +1 -0
- package/dist/services/index.d.ts +10 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +14 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/push.service.d.ts +60 -0
- package/dist/services/push.service.d.ts.map +1 -0
- package/dist/services/push.service.js +121 -0
- package/dist/services/push.service.js.map +1 -0
- package/dist/services/workflow-ai.service.d.ts +61 -0
- package/dist/services/workflow-ai.service.d.ts.map +1 -0
- package/dist/services/workflow-ai.service.js +219 -0
- package/dist/services/workflow-ai.service.js.map +1 -0
- package/dist/services/workflow-context.service.d.ts +32 -0
- package/dist/services/workflow-context.service.d.ts.map +1 -0
- package/dist/services/workflow-context.service.js +155 -0
- package/dist/services/workflow-context.service.js.map +1 -0
- package/dist/services/workflow-engine.service.d.ts +90 -0
- package/dist/services/workflow-engine.service.d.ts.map +1 -0
- package/dist/services/workflow-engine.service.js +305 -0
- package/dist/services/workflow-engine.service.js.map +1 -0
- package/dist/services/workflow.service.d.ts +84 -0
- package/dist/services/workflow.service.d.ts.map +1 -0
- package/dist/services/workflow.service.js +241 -0
- package/dist/services/workflow.service.js.map +1 -0
- package/dist/triggers/cron-trigger.d.ts +39 -0
- package/dist/triggers/cron-trigger.d.ts.map +1 -0
- package/dist/triggers/cron-trigger.js +137 -0
- package/dist/triggers/cron-trigger.js.map +1 -0
- package/dist/triggers/index.d.ts +3 -0
- package/dist/triggers/index.d.ts.map +1 -0
- package/dist/triggers/index.js +8 -0
- package/dist/triggers/index.js.map +1 -0
- package/dist/triggers/webhook-trigger.d.ts +51 -0
- package/dist/triggers/webhook-trigger.d.ts.map +1 -0
- package/dist/triggers/webhook-trigger.js +122 -0
- package/dist/triggers/webhook-trigger.js.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/node.types.d.ts +313 -0
- package/dist/types/node.types.d.ts.map +1 -0
- package/dist/types/node.types.js +23 -0
- package/dist/types/node.types.js.map +1 -0
- package/dist/types/workflow.types.d.ts +153 -0
- package/dist/types/workflow.types.d.ts.map +1 -0
- package/dist/types/workflow.types.js +44 -0
- package/dist/types/workflow.types.js.map +1 -0
- package/dist/utils/n8n-converter.d.ts +52 -0
- package/dist/utils/n8n-converter.d.ts.map +1 -0
- package/dist/utils/n8n-converter.js +107 -0
- package/dist/utils/n8n-converter.js.map +1 -0
- package/dist/utils/n8n-node-map.d.ts +6 -0
- package/dist/utils/n8n-node-map.d.ts.map +1 -0
- package/dist/utils/n8n-node-map.js +59 -0
- package/dist/utils/n8n-node-map.js.map +1 -0
- package/dist/workflow.module.d.ts +40 -0
- package/dist/workflow.module.d.ts.map +1 -0
- package/dist/workflow.module.js +240 -0
- package/dist/workflow.module.js.map +1 -0
- package/package.json +97 -0
- package/web/components/ChatPanel.tsx +344 -0
- package/web/components/N8nIframe.tsx +119 -0
- package/web/components/SessionPanel.tsx +301 -0
- package/web/components/ToolPanel.tsx +404 -0
- package/web/components/WorkflowDiff.tsx +161 -0
- package/web/components/WorkflowGraph.tsx +158 -0
- package/web/components/WorkflowPreviewPanel.tsx +186 -0
- package/web/hooks/use-n8n-session.ts +46 -0
- package/web/index.ts +29 -0
- package/web/manifest.ts +16 -0
- package/web/messages/en-US.json +94 -0
- package/web/messages/zh-CN.json +94 -0
- package/web/pages/AiDesignPage.tsx +215 -0
- package/web/pages/CredentialsPage.tsx +7 -0
- package/web/pages/ExecutionsPage.tsx +7 -0
- package/web/pages/WorkflowsPage.tsx +7 -0
- package/web/services/workflow-ai-service.ts +173 -0
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WorkflowAiController = void 0;
|
|
13
|
+
const core_1 = require("@octo/core");
|
|
14
|
+
const workflow_ai_service_js_1 = require("../services/workflow-ai.service.js");
|
|
15
|
+
const workflow_context_service_js_1 = require("../services/workflow-context.service.js");
|
|
16
|
+
const ai_workflow_session_service_js_1 = require("../services/ai-workflow-session.service.js");
|
|
17
|
+
let WorkflowAiController = class WorkflowAiController {
|
|
18
|
+
get aiService() {
|
|
19
|
+
return core_1.Container.get(workflow_ai_service_js_1.WorkflowAiService);
|
|
20
|
+
}
|
|
21
|
+
get contextService() {
|
|
22
|
+
return core_1.Container.get(workflow_context_service_js_1.WorkflowContextService);
|
|
23
|
+
}
|
|
24
|
+
get sessionService() {
|
|
25
|
+
return core_1.Container.get(ai_workflow_session_service_js_1.AiWorkflowSessionService);
|
|
26
|
+
}
|
|
27
|
+
/** POST /api/v1/workflow-ai/design */
|
|
28
|
+
async design(req, res) {
|
|
29
|
+
const body = req.body;
|
|
30
|
+
if (!body.prompt || typeof body.prompt !== 'string') {
|
|
31
|
+
res.status(400).json(core_1.ApiResponse.error('Missing required field: prompt'));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const request = {
|
|
35
|
+
prompt: body.prompt,
|
|
36
|
+
currentWorkflowJson: body.currentWorkflowJson,
|
|
37
|
+
context: body.context,
|
|
38
|
+
tool: body.tool ?? undefined,
|
|
39
|
+
model: body.model,
|
|
40
|
+
conversationHistory: body.conversationHistory,
|
|
41
|
+
sessionId: body.sessionId,
|
|
42
|
+
};
|
|
43
|
+
const result = await this.aiService.design(request);
|
|
44
|
+
// Auto-save version if sessionId is provided and generation succeeded
|
|
45
|
+
if (request.sessionId && result.success && result.workflowJson) {
|
|
46
|
+
await this.sessionService.addVersion(request.sessionId, {
|
|
47
|
+
workflowJson: JSON.stringify(result.workflowJson),
|
|
48
|
+
changeDescription: request.prompt.slice(0, 200),
|
|
49
|
+
aiTool: request.tool ?? 'claude',
|
|
50
|
+
aiModel: request.model,
|
|
51
|
+
createdBy: req.user?.userId,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
res.json({
|
|
55
|
+
success: result.success,
|
|
56
|
+
data: {
|
|
57
|
+
explanation: result.explanation,
|
|
58
|
+
workflowJson: result.workflowJson,
|
|
59
|
+
suggestions: result.suggestions,
|
|
60
|
+
durationMs: result.durationMs,
|
|
61
|
+
},
|
|
62
|
+
error: result.error,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/** GET /api/v1/workflow-ai/system-prompt — returns the current AI system prompt */
|
|
66
|
+
async getSystemPrompt(_req, res) {
|
|
67
|
+
const prompt = await this.aiService.getSystemPrompt();
|
|
68
|
+
res.json(core_1.ApiResponse.ok({ prompt }));
|
|
69
|
+
}
|
|
70
|
+
/** GET /api/v1/workflow-ai/context/ai-tools */
|
|
71
|
+
async listAiTools(_req, res) {
|
|
72
|
+
const tools = await this.contextService.listAiTools();
|
|
73
|
+
res.json(core_1.ApiResponse.ok(tools));
|
|
74
|
+
}
|
|
75
|
+
/** GET /api/v1/workflow-ai/context/api-docs */
|
|
76
|
+
async listApiDocs(_req, res) {
|
|
77
|
+
const docs = await this.contextService.listApiDocs();
|
|
78
|
+
res.json(core_1.ApiResponse.ok(docs));
|
|
79
|
+
}
|
|
80
|
+
/** GET /api/v1/workflow-ai/context/api-docs/:module */
|
|
81
|
+
async getApiDoc(req, res) {
|
|
82
|
+
const moduleName = String(req.params.module);
|
|
83
|
+
const content = await this.contextService.getApiDocContent(moduleName);
|
|
84
|
+
res.json(core_1.ApiResponse.ok({ module: moduleName, content }));
|
|
85
|
+
}
|
|
86
|
+
/** GET /api/v1/workflow-ai/context/n8n-workflows */
|
|
87
|
+
async listN8nWorkflows(_req, res) {
|
|
88
|
+
const workflows = await this.contextService.listN8nWorkflows();
|
|
89
|
+
res.json(core_1.ApiResponse.ok(workflows));
|
|
90
|
+
}
|
|
91
|
+
/** GET /api/v1/workflow-ai/context/n8n-workflows/:id */
|
|
92
|
+
async getN8nWorkflow(req, res) {
|
|
93
|
+
const workflowId = String(req.params.id);
|
|
94
|
+
const workflow = await this.contextService.getN8nWorkflow(workflowId);
|
|
95
|
+
res.json(core_1.ApiResponse.ok(workflow));
|
|
96
|
+
}
|
|
97
|
+
/** POST /api/v1/workflow-ai/sessions/:id/apply */
|
|
98
|
+
async applyToN8n(req, res) {
|
|
99
|
+
const sessionId = Number(req.params.id);
|
|
100
|
+
const session = await this.sessionService.findSessionById(sessionId);
|
|
101
|
+
if (!session.n8nWorkflowId) {
|
|
102
|
+
throw core_1.AppError.badRequest('Session has no linked n8n workflow');
|
|
103
|
+
}
|
|
104
|
+
if (!session.currentJson) {
|
|
105
|
+
throw core_1.AppError.badRequest('Session has no workflow JSON to apply');
|
|
106
|
+
}
|
|
107
|
+
await this.contextService.updateN8nWorkflow(session.n8nWorkflowId, session.currentJson);
|
|
108
|
+
await this.sessionService.markApplied(sessionId);
|
|
109
|
+
res.json(core_1.ApiResponse.ok({ applied: true, n8nWorkflowId: session.n8nWorkflowId }));
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
exports.WorkflowAiController = WorkflowAiController;
|
|
113
|
+
__decorate([
|
|
114
|
+
(0, core_1.Post)('/design'),
|
|
115
|
+
__metadata("design:type", Function),
|
|
116
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
117
|
+
__metadata("design:returntype", Promise)
|
|
118
|
+
], WorkflowAiController.prototype, "design", null);
|
|
119
|
+
__decorate([
|
|
120
|
+
(0, core_1.Get)('/system-prompt'),
|
|
121
|
+
__metadata("design:type", Function),
|
|
122
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
123
|
+
__metadata("design:returntype", Promise)
|
|
124
|
+
], WorkflowAiController.prototype, "getSystemPrompt", null);
|
|
125
|
+
__decorate([
|
|
126
|
+
(0, core_1.Get)('/context/ai-tools'),
|
|
127
|
+
__metadata("design:type", Function),
|
|
128
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
129
|
+
__metadata("design:returntype", Promise)
|
|
130
|
+
], WorkflowAiController.prototype, "listAiTools", null);
|
|
131
|
+
__decorate([
|
|
132
|
+
(0, core_1.Get)('/context/api-docs'),
|
|
133
|
+
__metadata("design:type", Function),
|
|
134
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
135
|
+
__metadata("design:returntype", Promise)
|
|
136
|
+
], WorkflowAiController.prototype, "listApiDocs", null);
|
|
137
|
+
__decorate([
|
|
138
|
+
(0, core_1.Get)('/context/api-docs/:module'),
|
|
139
|
+
__metadata("design:type", Function),
|
|
140
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
141
|
+
__metadata("design:returntype", Promise)
|
|
142
|
+
], WorkflowAiController.prototype, "getApiDoc", null);
|
|
143
|
+
__decorate([
|
|
144
|
+
(0, core_1.Get)('/context/n8n-workflows'),
|
|
145
|
+
__metadata("design:type", Function),
|
|
146
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
147
|
+
__metadata("design:returntype", Promise)
|
|
148
|
+
], WorkflowAiController.prototype, "listN8nWorkflows", null);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, core_1.Get)('/context/n8n-workflows/:id'),
|
|
151
|
+
__metadata("design:type", Function),
|
|
152
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
153
|
+
__metadata("design:returntype", Promise)
|
|
154
|
+
], WorkflowAiController.prototype, "getN8nWorkflow", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
(0, core_1.Post)('/sessions/:id/apply'),
|
|
157
|
+
__metadata("design:type", Function),
|
|
158
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
159
|
+
__metadata("design:returntype", Promise)
|
|
160
|
+
], WorkflowAiController.prototype, "applyToN8n", null);
|
|
161
|
+
exports.WorkflowAiController = WorkflowAiController = __decorate([
|
|
162
|
+
(0, core_1.Controller)('/api/v1/workflow-ai')
|
|
163
|
+
], WorkflowAiController);
|
|
164
|
+
//# sourceMappingURL=workflow-ai.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-ai.controller.js","sourceRoot":"","sources":["../../src/controllers/workflow-ai.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAqF;AAErF,+EAAuE;AAEvE,yFAAiF;AACjF,+FAAsF;AAS/E,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,IAAY,SAAS;QACnB,OAAO,gBAAS,CAAC,GAAG,CAAC,0CAAiB,CAAC,CAAC;IAC1C,CAAC;IAED,IAAY,cAAc;QACxB,OAAO,gBAAS,CAAC,GAAG,CAAC,oDAAsB,CAAC,CAAC;IAC/C,CAAC;IAED,IAAY,cAAc;QACxB,OAAO,gBAAS,CAAC,GAAG,CAAC,yDAAwB,CAAC,CAAC;IACjD,CAAC;IAED,sCAAsC;IAEhC,AAAN,KAAK,CAAC,MAAM,CAAC,GAAY,EAAE,GAAa;QACtC,MAAM,IAAI,GAAG,GAAG,CAAC,IAA+B,CAAC;QAEjD,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;YACpD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,kBAAW,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC,CAAC;YAC1E,OAAO;QACT,CAAC;QAED,MAAM,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0Cf;AAIK;IADL,IAAA,UAAG,EAAC,gBAAgB,CAAC;;;;2DAIrB;AAIK;IADL,IAAA,UAAG,EAAC,mBAAmB,CAAC;;;;uDAIxB;AAIK;IADL,IAAA,UAAG,EAAC,mBAAmB,CAAC;;;;uDAIxB;AAIK;IADL,IAAA,UAAG,EAAC,2BAA2B,CAAC;;;;qDAKhC;AAIK;IADL,IAAA,UAAG,EAAC,wBAAwB,CAAC;;;;4DAI7B;AAIK;IADL,IAAA,UAAG,EAAC,4BAA4B,CAAC;;;;0DAKjC;AAIK;IADL,IAAA,WAAI,EAAC,qBAAqB,CAAC;;;;sDAmB3B;+BA1HU,oBAAoB;IADhC,IAAA,iBAAU,EAAC,qBAAqB,CAAC;GACrB,oBAAoB,CA2HhC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Request, Response } from '@octo/core';
|
|
2
|
+
export declare class WorkflowController {
|
|
3
|
+
private get workflowService();
|
|
4
|
+
private get nodeRegistry();
|
|
5
|
+
/**
|
|
6
|
+
* GET /api/workflows
|
|
7
|
+
* List all workflow definitions (paginated).
|
|
8
|
+
*/
|
|
9
|
+
list(req: Request, res: Response): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* GET /api/workflows/node-types
|
|
12
|
+
* Get all registered node type descriptions (for the editor).
|
|
13
|
+
*/
|
|
14
|
+
getNodeTypes(_req: Request, res: Response): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* GET /api/workflows/executions/:executionId
|
|
17
|
+
* Get a single execution by ID.
|
|
18
|
+
*/
|
|
19
|
+
getExecution(req: Request, res: Response): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* DELETE /api/workflows/executions/:executionId
|
|
22
|
+
* Delete a single execution record.
|
|
23
|
+
*/
|
|
24
|
+
deleteExecution(req: Request, res: Response): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* POST /api/workflows/import
|
|
27
|
+
* Import a workflow from JSON.
|
|
28
|
+
*/
|
|
29
|
+
importWorkflow(req: Request, res: Response): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* GET /api/workflows/:id
|
|
32
|
+
* Get a workflow by ID.
|
|
33
|
+
*/
|
|
34
|
+
getById(req: Request, res: Response): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* POST /api/workflows
|
|
37
|
+
* Create a new workflow.
|
|
38
|
+
*/
|
|
39
|
+
create(req: Request, res: Response): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* PUT /api/workflows/:id
|
|
42
|
+
* Update a workflow.
|
|
43
|
+
*/
|
|
44
|
+
update(req: Request, res: Response): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* DELETE /api/workflows/:id
|
|
47
|
+
* Delete a workflow.
|
|
48
|
+
*/
|
|
49
|
+
delete(req: Request, res: Response): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* POST /api/workflows/:id/execute
|
|
52
|
+
* Execute a workflow.
|
|
53
|
+
*/
|
|
54
|
+
execute(req: Request, res: Response): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* GET /api/workflows/:id/export
|
|
57
|
+
* Export a workflow as JSON.
|
|
58
|
+
*/
|
|
59
|
+
exportWorkflow(req: Request, res: Response): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* GET /api/workflows/:id/executions
|
|
62
|
+
* Get execution history for a workflow.
|
|
63
|
+
*/
|
|
64
|
+
getExecutions(req: Request, res: Response): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=workflow.controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.controller.d.ts","sourceRoot":"","sources":["../../src/controllers/workflow.controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMpD,qBACa,kBAAkB;IAC7B,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,YAAY,GAEvB;IAED;;;OA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AAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAUhE"}
|
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WorkflowController = void 0;
|
|
13
|
+
const core_1 = require("@octo/core");
|
|
14
|
+
const workflow_service_js_1 = require("../services/workflow.service.js");
|
|
15
|
+
const node_registry_js_1 = require("../core/node-registry.js");
|
|
16
|
+
let WorkflowController = class WorkflowController {
|
|
17
|
+
get workflowService() {
|
|
18
|
+
return core_1.Container.get(workflow_service_js_1.WorkflowService);
|
|
19
|
+
}
|
|
20
|
+
get nodeRegistry() {
|
|
21
|
+
return core_1.Container.get(node_registry_js_1.NodeRegistry);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* GET /api/workflows
|
|
25
|
+
* List all workflow definitions (paginated).
|
|
26
|
+
*/
|
|
27
|
+
async list(req, res) {
|
|
28
|
+
const page = req.query.page ? Number(req.query.page) : 1;
|
|
29
|
+
const pageSize = req.query.pageSize ? Number(req.query.pageSize) : 20;
|
|
30
|
+
const result = await this.workflowService.findAll(page, pageSize);
|
|
31
|
+
res.json(core_1.ApiResponse.paginated(result.items, result.total, page, pageSize));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* GET /api/workflows/node-types
|
|
35
|
+
* Get all registered node type descriptions (for the editor).
|
|
36
|
+
*/
|
|
37
|
+
async getNodeTypes(_req, res) {
|
|
38
|
+
const descriptions = this.nodeRegistry.getAllDescriptions();
|
|
39
|
+
res.json(core_1.ApiResponse.ok(descriptions));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* GET /api/workflows/executions/:executionId
|
|
43
|
+
* Get a single execution by ID.
|
|
44
|
+
*/
|
|
45
|
+
async getExecution(req, res) {
|
|
46
|
+
const executionId = req.params.executionId;
|
|
47
|
+
if (!executionId)
|
|
48
|
+
throw core_1.AppError.badRequest('executionId is required');
|
|
49
|
+
const execution = await this.workflowService.getExecution(executionId);
|
|
50
|
+
res.json(core_1.ApiResponse.ok(execution));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* DELETE /api/workflows/executions/:executionId
|
|
54
|
+
* Delete a single execution record.
|
|
55
|
+
*/
|
|
56
|
+
async deleteExecution(req, res) {
|
|
57
|
+
const executionId = req.params.executionId;
|
|
58
|
+
if (!executionId)
|
|
59
|
+
throw core_1.AppError.badRequest('executionId is required');
|
|
60
|
+
await this.workflowService.deleteExecution(executionId);
|
|
61
|
+
res.json(core_1.ApiResponse.ok(null, 'Execution deleted'));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* POST /api/workflows/import
|
|
65
|
+
* Import a workflow from JSON.
|
|
66
|
+
*/
|
|
67
|
+
async importWorkflow(req, res) {
|
|
68
|
+
const data = req.body;
|
|
69
|
+
if (!data)
|
|
70
|
+
throw core_1.AppError.badRequest('Import data is required');
|
|
71
|
+
const workflow = await this.workflowService.importWorkflow(data);
|
|
72
|
+
res.status(201).json(core_1.ApiResponse.ok(workflow, 'Workflow imported'));
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* GET /api/workflows/:id
|
|
76
|
+
* Get a workflow by ID.
|
|
77
|
+
*/
|
|
78
|
+
async getById(req, res) {
|
|
79
|
+
const id = req.params.id;
|
|
80
|
+
if (!id)
|
|
81
|
+
throw core_1.AppError.badRequest('id is required');
|
|
82
|
+
const workflow = await this.workflowService.findById(id);
|
|
83
|
+
res.json(core_1.ApiResponse.ok(workflow));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* POST /api/workflows
|
|
87
|
+
* Create a new workflow.
|
|
88
|
+
*/
|
|
89
|
+
async create(req, res) {
|
|
90
|
+
const { name, description, definition, triggerType, triggerConfig } = req.body;
|
|
91
|
+
if (!name)
|
|
92
|
+
throw core_1.AppError.badRequest('name is required');
|
|
93
|
+
if (!definition)
|
|
94
|
+
throw core_1.AppError.badRequest('definition is required');
|
|
95
|
+
const workflow = await this.workflowService.create({
|
|
96
|
+
name,
|
|
97
|
+
description,
|
|
98
|
+
definition,
|
|
99
|
+
triggerType,
|
|
100
|
+
triggerConfig,
|
|
101
|
+
});
|
|
102
|
+
res.status(201).json(core_1.ApiResponse.ok(workflow, 'Workflow created'));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* PUT /api/workflows/:id
|
|
106
|
+
* Update a workflow.
|
|
107
|
+
*/
|
|
108
|
+
async update(req, res) {
|
|
109
|
+
const id = req.params.id;
|
|
110
|
+
if (!id)
|
|
111
|
+
throw core_1.AppError.badRequest('id is required');
|
|
112
|
+
const workflow = await this.workflowService.update(id, req.body);
|
|
113
|
+
res.json(core_1.ApiResponse.ok(workflow, 'Workflow updated'));
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* DELETE /api/workflows/:id
|
|
117
|
+
* Delete a workflow.
|
|
118
|
+
*/
|
|
119
|
+
async delete(req, res) {
|
|
120
|
+
const id = req.params.id;
|
|
121
|
+
if (!id)
|
|
122
|
+
throw core_1.AppError.badRequest('id is required');
|
|
123
|
+
await this.workflowService.delete(id);
|
|
124
|
+
res.json(core_1.ApiResponse.ok(null, 'Workflow deleted'));
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* POST /api/workflows/:id/execute
|
|
128
|
+
* Execute a workflow.
|
|
129
|
+
*/
|
|
130
|
+
async execute(req, res) {
|
|
131
|
+
const id = req.params.id;
|
|
132
|
+
if (!id)
|
|
133
|
+
throw core_1.AppError.badRequest('id is required');
|
|
134
|
+
const triggerData = req.body;
|
|
135
|
+
const execution = await this.workflowService.execute(id, triggerData);
|
|
136
|
+
res.json(core_1.ApiResponse.ok(execution, 'Workflow executed'));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* GET /api/workflows/:id/export
|
|
140
|
+
* Export a workflow as JSON.
|
|
141
|
+
*/
|
|
142
|
+
async exportWorkflow(req, res) {
|
|
143
|
+
const id = req.params.id;
|
|
144
|
+
if (!id)
|
|
145
|
+
throw core_1.AppError.badRequest('id is required');
|
|
146
|
+
const data = await this.workflowService.exportWorkflow(id);
|
|
147
|
+
res.json(core_1.ApiResponse.ok(data));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* GET /api/workflows/:id/executions
|
|
151
|
+
* Get execution history for a workflow.
|
|
152
|
+
*/
|
|
153
|
+
async getExecutions(req, res) {
|
|
154
|
+
const id = req.params.id;
|
|
155
|
+
if (!id)
|
|
156
|
+
throw core_1.AppError.badRequest('id is required');
|
|
157
|
+
const page = req.query.page ? Number(req.query.page) : 1;
|
|
158
|
+
const pageSize = req.query.pageSize ? Number(req.query.pageSize) : 20;
|
|
159
|
+
const result = await this.workflowService.getExecutions(id, page, pageSize);
|
|
160
|
+
res.json(core_1.ApiResponse.paginated(result.items, result.total, page, pageSize));
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
exports.WorkflowController = WorkflowController;
|
|
164
|
+
__decorate([
|
|
165
|
+
(0, core_1.Get)('/'),
|
|
166
|
+
__metadata("design:type", Function),
|
|
167
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
168
|
+
__metadata("design:returntype", Promise)
|
|
169
|
+
], WorkflowController.prototype, "list", null);
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, core_1.Get)('/node-types'),
|
|
172
|
+
__metadata("design:type", Function),
|
|
173
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
174
|
+
__metadata("design:returntype", Promise)
|
|
175
|
+
], WorkflowController.prototype, "getNodeTypes", null);
|
|
176
|
+
__decorate([
|
|
177
|
+
(0, core_1.Get)('/executions/:executionId'),
|
|
178
|
+
__metadata("design:type", Function),
|
|
179
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
180
|
+
__metadata("design:returntype", Promise)
|
|
181
|
+
], WorkflowController.prototype, "getExecution", null);
|
|
182
|
+
__decorate([
|
|
183
|
+
(0, core_1.Delete)('/executions/:executionId'),
|
|
184
|
+
__metadata("design:type", Function),
|
|
185
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
186
|
+
__metadata("design:returntype", Promise)
|
|
187
|
+
], WorkflowController.prototype, "deleteExecution", null);
|
|
188
|
+
__decorate([
|
|
189
|
+
(0, core_1.Post)('/import'),
|
|
190
|
+
__metadata("design:type", Function),
|
|
191
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
192
|
+
__metadata("design:returntype", Promise)
|
|
193
|
+
], WorkflowController.prototype, "importWorkflow", null);
|
|
194
|
+
__decorate([
|
|
195
|
+
(0, core_1.Get)('/:id'),
|
|
196
|
+
__metadata("design:type", Function),
|
|
197
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
198
|
+
__metadata("design:returntype", Promise)
|
|
199
|
+
], WorkflowController.prototype, "getById", null);
|
|
200
|
+
__decorate([
|
|
201
|
+
(0, core_1.Post)('/'),
|
|
202
|
+
__metadata("design:type", Function),
|
|
203
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
204
|
+
__metadata("design:returntype", Promise)
|
|
205
|
+
], WorkflowController.prototype, "create", null);
|
|
206
|
+
__decorate([
|
|
207
|
+
(0, core_1.Put)('/:id'),
|
|
208
|
+
__metadata("design:type", Function),
|
|
209
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
210
|
+
__metadata("design:returntype", Promise)
|
|
211
|
+
], WorkflowController.prototype, "update", null);
|
|
212
|
+
__decorate([
|
|
213
|
+
(0, core_1.Delete)('/:id'),
|
|
214
|
+
__metadata("design:type", Function),
|
|
215
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
216
|
+
__metadata("design:returntype", Promise)
|
|
217
|
+
], WorkflowController.prototype, "delete", null);
|
|
218
|
+
__decorate([
|
|
219
|
+
(0, core_1.Post)('/:id/execute'),
|
|
220
|
+
__metadata("design:type", Function),
|
|
221
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
222
|
+
__metadata("design:returntype", Promise)
|
|
223
|
+
], WorkflowController.prototype, "execute", null);
|
|
224
|
+
__decorate([
|
|
225
|
+
(0, core_1.Get)('/:id/export'),
|
|
226
|
+
__metadata("design:type", Function),
|
|
227
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
228
|
+
__metadata("design:returntype", Promise)
|
|
229
|
+
], WorkflowController.prototype, "exportWorkflow", null);
|
|
230
|
+
__decorate([
|
|
231
|
+
(0, core_1.Get)('/:id/executions'),
|
|
232
|
+
__metadata("design:type", Function),
|
|
233
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
234
|
+
__metadata("design:returntype", Promise)
|
|
235
|
+
], WorkflowController.prototype, "getExecutions", null);
|
|
236
|
+
exports.WorkflowController = WorkflowController = __decorate([
|
|
237
|
+
(0, core_1.Controller)('/api/workflows')
|
|
238
|
+
], WorkflowController);
|
|
239
|
+
//# sourceMappingURL=workflow.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.controller.js","sourceRoot":"","sources":["../../src/controllers/workflow.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAkG;AAClG,yEAAkE;AAClE,+DAAwD;AAIjD,IAAM,kBAAkB,GAAxB,MAAM,kBAAk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C;;;;gDAOd;AAOK;IADL,IAAA,WAAI,EAAC,cAAc,CAAC;;;;iDAQpB;AAOK;IADL,IAAA,UAAG,EAAC,aAAa,CAAC;;;;wDAOlB;AAOK;IADL,IAAA,UAAG,EAAC,iBAAiB,CAAC;;;;uDAUtB;6BAnLU,kBAAkB;IAD9B,IAAA,iBAAU,EAAC,gBAAgB,CAAC;GAChB,kBAAkB,CAoL9B"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Expression Resolver — parses and evaluates {{ expressions }} in node parameters.
|
|
3
|
+
*
|
|
4
|
+
* Supports:
|
|
5
|
+
* - {{ $json.fieldName }} — access current item data
|
|
6
|
+
* - {{ $input.item.json.field }} — explicit input reference
|
|
7
|
+
* - {{ $node["NodeName"].json.field }} — reference other node output
|
|
8
|
+
* - {{ $vars.variableName }} — workflow variables
|
|
9
|
+
* - {{ $now }} — current timestamp
|
|
10
|
+
* - Basic JS: {{ $json.price * 1.1 }}, {{ $json.name.toUpperCase() }}
|
|
11
|
+
*/
|
|
12
|
+
export declare class ExpressionResolver {
|
|
13
|
+
private static readonly EXPRESSION_REGEX;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve all expressions in a value.
|
|
16
|
+
* Handles strings, objects, and arrays recursively.
|
|
17
|
+
*/
|
|
18
|
+
static resolve(value: unknown, context: IExpressionContext): unknown;
|
|
19
|
+
/**
|
|
20
|
+
* Resolve expressions in a string.
|
|
21
|
+
* If the entire string is a single expression, return the raw value (not stringified).
|
|
22
|
+
*/
|
|
23
|
+
static resolveString(str: string, context: IExpressionContext): unknown;
|
|
24
|
+
/**
|
|
25
|
+
* Evaluate a single expression string.
|
|
26
|
+
* Uses Function constructor for safe sandboxed evaluation.
|
|
27
|
+
*/
|
|
28
|
+
static evaluateExpression(expression: string, context: IExpressionContext): unknown;
|
|
29
|
+
/** Build the sandbox object with available variables. */
|
|
30
|
+
private static buildSandbox;
|
|
31
|
+
}
|
|
32
|
+
/** Context for expression resolution. */
|
|
33
|
+
export interface IExpressionContext {
|
|
34
|
+
currentItem?: {
|
|
35
|
+
json: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
inputData?: {
|
|
38
|
+
json: Record<string, unknown>;
|
|
39
|
+
}[];
|
|
40
|
+
itemIndex?: number;
|
|
41
|
+
nodeOutputs?: Record<string, {
|
|
42
|
+
json: Record<string, unknown>;
|
|
43
|
+
}>;
|
|
44
|
+
variables?: Record<string, unknown>;
|
|
45
|
+
}
|
|
46
|
+
export declare class ExpressionError extends Error {
|
|
47
|
+
constructor(message: string);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=expression-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expression-resolver.d.ts","sourceRoot":"","sources":["../../src/core/expression-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAA+B;IAEvE;;;OAGG;IACH,MAAM,CAAC,OAAO,CACZ,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,kBAAkB,GAC1B,OAAO;IAiBV;;;OAGG;IACH,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO;IAevE;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CACvB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,kBAAkB,GAC1B,OAAO;IAeV,yDAAyD;IACzD,OAAO,CAAC,MAAM,CAAC,YAAY;CAgC5B;AAED,yCAAyC;AACzC,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC;IAChD,SAAS,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,EAAE,CAAC;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExpressionError = exports.ExpressionResolver = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Expression Resolver — parses and evaluates {{ expressions }} in node parameters.
|
|
6
|
+
*
|
|
7
|
+
* Supports:
|
|
8
|
+
* - {{ $json.fieldName }} — access current item data
|
|
9
|
+
* - {{ $input.item.json.field }} — explicit input reference
|
|
10
|
+
* - {{ $node["NodeName"].json.field }} — reference other node output
|
|
11
|
+
* - {{ $vars.variableName }} — workflow variables
|
|
12
|
+
* - {{ $now }} — current timestamp
|
|
13
|
+
* - Basic JS: {{ $json.price * 1.1 }}, {{ $json.name.toUpperCase() }}
|
|
14
|
+
*/
|
|
15
|
+
class ExpressionResolver {
|
|
16
|
+
static EXPRESSION_REGEX = /\{\{\s*([\s\S]*?)\s*\}\}/g;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve all expressions in a value.
|
|
19
|
+
* Handles strings, objects, and arrays recursively.
|
|
20
|
+
*/
|
|
21
|
+
static resolve(value, context) {
|
|
22
|
+
if (typeof value === 'string') {
|
|
23
|
+
return this.resolveString(value, context);
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
return value.map((item) => this.resolve(item, context));
|
|
27
|
+
}
|
|
28
|
+
if (value !== null && typeof value === 'object') {
|
|
29
|
+
const result = {};
|
|
30
|
+
for (const [k, v] of Object.entries(value)) {
|
|
31
|
+
result[k] = this.resolve(v, context);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Resolve expressions in a string.
|
|
39
|
+
* If the entire string is a single expression, return the raw value (not stringified).
|
|
40
|
+
*/
|
|
41
|
+
static resolveString(str, context) {
|
|
42
|
+
// Check if the entire string is a single expression
|
|
43
|
+
const trimmed = str.trim();
|
|
44
|
+
const singleMatch = /^\{\{\s*([\s\S]*?)\s*\}\}$/.exec(trimmed);
|
|
45
|
+
if (singleMatch) {
|
|
46
|
+
return this.evaluateExpression(singleMatch[1], context);
|
|
47
|
+
}
|
|
48
|
+
// Multiple expressions or mixed content — always returns string
|
|
49
|
+
return str.replace(this.EXPRESSION_REGEX, (_match, expr) => {
|
|
50
|
+
const result = this.evaluateExpression(expr, context);
|
|
51
|
+
return String(result ?? '');
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Evaluate a single expression string.
|
|
56
|
+
* Uses Function constructor for safe sandboxed evaluation.
|
|
57
|
+
*/
|
|
58
|
+
static evaluateExpression(expression, context) {
|
|
59
|
+
try {
|
|
60
|
+
const sandbox = this.buildSandbox(context);
|
|
61
|
+
const keys = Object.keys(sandbox);
|
|
62
|
+
const values = Object.values(sandbox);
|
|
63
|
+
// Create a sandboxed function
|
|
64
|
+
const fn = new Function(...keys, `"use strict"; return (${expression});`);
|
|
65
|
+
return fn(...values);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
69
|
+
throw new ExpressionError(`Failed to evaluate expression: ${expression} — ${msg}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Build the sandbox object with available variables. */
|
|
73
|
+
static buildSandbox(context) {
|
|
74
|
+
return {
|
|
75
|
+
$json: context.currentItem?.json ?? {},
|
|
76
|
+
$input: {
|
|
77
|
+
item: context.currentItem ?? { json: {} },
|
|
78
|
+
all: () => context.inputData ?? [],
|
|
79
|
+
first: () => context.inputData?.[0] ?? { json: {} },
|
|
80
|
+
last: () => context.inputData?.[context.inputData?.length ? context.inputData.length - 1 : 0] ?? { json: {} },
|
|
81
|
+
},
|
|
82
|
+
$item: context.currentItem ?? { json: {} },
|
|
83
|
+
$node: context.nodeOutputs ?? {},
|
|
84
|
+
$vars: context.variables ?? {},
|
|
85
|
+
$now: new Date().toISOString(),
|
|
86
|
+
$today: new Date().toISOString().split('T')[0],
|
|
87
|
+
$itemIndex: context.itemIndex ?? 0,
|
|
88
|
+
// Utility functions
|
|
89
|
+
$if: (condition, trueVal, falseVal) => condition ? trueVal : falseVal,
|
|
90
|
+
JSON,
|
|
91
|
+
Math,
|
|
92
|
+
Date,
|
|
93
|
+
String,
|
|
94
|
+
Number,
|
|
95
|
+
Boolean,
|
|
96
|
+
Array,
|
|
97
|
+
Object,
|
|
98
|
+
parseInt,
|
|
99
|
+
parseFloat,
|
|
100
|
+
encodeURIComponent,
|
|
101
|
+
decodeURIComponent,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.ExpressionResolver = ExpressionResolver;
|
|
106
|
+
class ExpressionError extends Error {
|
|
107
|
+
constructor(message) {
|
|
108
|
+
super(message);
|
|
109
|
+
this.name = 'ExpressionError';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.ExpressionError = ExpressionError;
|
|
113
|
+
//# sourceMappingURL=expression-resolver.js.map
|