@atom8n/n8n 2.4.7 → 2.5.1
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/chat/chat-service.types.d.ts +6 -6
- package/dist/commands/execute-batch.d.ts +2 -2
- package/dist/commands/execute.js +0 -0
- package/dist/commands/import/credentials.d.ts +2 -2
- package/dist/commands/import/credentials.js +0 -0
- package/dist/commands/import/workflow.d.ts +2 -2
- package/dist/commands/ldap/reset.d.ts +2 -2
- package/dist/commands/mcp.d.ts +23 -0
- package/dist/commands/mcp.js +315 -0
- package/dist/commands/run.d.ts +23 -0
- package/dist/commands/run.js +162 -0
- package/dist/controllers/annotation-tags.controller.ee.d.ts +1 -1
- package/dist/controllers/cli.controller.d.ts +26 -0
- package/dist/controllers/cli.controller.js +334 -0
- package/dist/controllers/orchestration.controller.js +0 -0
- package/dist/controllers/users.controller.d.ts +1 -1
- package/dist/environments.ee/source-control/source-control-status.service.ee.d.ts +2 -2
- package/dist/environments.ee/source-control/source-control.controller.ee.d.ts +4 -4
- package/dist/environments.ee/source-control/source-control.service.ee.d.ts +2 -2
- package/dist/environments.ee/source-control/types/source-control-set-branch.js +0 -0
- package/dist/eventbus/event-message-classes/index.js +0 -0
- package/dist/events/relays/workflow-failure-notification.event-relay.d.ts +13 -0
- package/dist/events/relays/workflow-failure-notification.event-relay.js +77 -0
- package/dist/executions/execution-data/types.d.ts +17 -0
- package/dist/executions/execution-data/types.js +2 -0
- package/dist/executions/failed-run-factory.d.ts +4 -0
- package/dist/executions/failed-run-factory.js +71 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +8 -0
- package/dist/interfaces.d.ts +1 -1
- package/dist/license.js +1 -1
- package/dist/middlewares/webview-frame-options.d.ts +2 -0
- package/dist/middlewares/webview-frame-options.js +22 -0
- package/dist/modules/chat-hub/chat-hub-extractor.d.ts +22 -0
- package/dist/modules/chat-hub/chat-hub-extractor.js +63 -0
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-user-entry-storage.d.ts +11 -0
- package/dist/modules/dynamic-credentials.ee/credential-resolvers/storage/dynamic-credential-user-entry-storage.js +58 -0
- package/dist/modules/dynamic-credentials.ee/database/entities/dynamic-credential-user-entry.d.ts +12 -0
- package/dist/modules/dynamic-credentials.ee/database/entities/dynamic-credential-user-entry.js +64 -0
- package/dist/modules/dynamic-credentials.ee/database/repositories/dynamic-credential-user-entry.repository.d.ts +5 -0
- package/dist/modules/dynamic-credentials.ee/database/repositories/dynamic-credential-user-entry.repository.js +25 -0
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.d.ts +5 -0
- package/dist/modules/dynamic-credentials.ee/dynamic-credentials.config.js +36 -0
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.d.ts +12 -0
- package/dist/modules/dynamic-credentials.ee/services/dynamic-credential-cors.service.js +69 -0
- package/dist/modules/dynamic-credentials.ee/services/resolver-config-expression.service.d.ts +7 -0
- package/dist/modules/dynamic-credentials.ee/services/resolver-config-expression.service.js +46 -0
- package/dist/modules/insights/database/entities/insights-metadata.js +1 -1
- package/dist/modules/insights/database/repositories/insights-by-period-query.helper.js +4 -1
- package/dist/modules/insights/database/repositories/insights-by-period.repository.d.ts +1 -1
- package/dist/modules/insights/insights.module.d.ts +1 -1
- package/dist/modules/insights/insights.service.d.ts +1 -1
- package/dist/modules/log-streaming.ee/database/entities/event-destination.entity.d.ts +6 -0
- package/dist/modules/log-streaming.ee/database/entities/event-destination.entity.js +28 -0
- package/dist/modules/log-streaming.ee/database/entities/index.d.ts +1 -0
- package/dist/modules/log-streaming.ee/database/entities/index.js +5 -0
- package/dist/modules/log-streaming.ee/database/repositories/event-destination.repository.d.ts +5 -0
- package/dist/modules/log-streaming.ee/database/repositories/event-destination.repository.js +25 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-from-db.d.ts +4 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-from-db.js +24 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-sentry.ee.d.ts +17 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-sentry.ee.js +131 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.d.ts +22 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-syslog.ee.js +116 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-webhook.ee.d.ts +35 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination-webhook.ee.js +328 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination.ee.d.ts +28 -0
- package/dist/modules/log-streaming.ee/destinations/message-event-bus-destination.ee.js +74 -0
- package/dist/modules/log-streaming.ee/log-streaming-destination.service.d.ts +32 -0
- package/dist/modules/log-streaming.ee/log-streaming-destination.service.js +175 -0
- package/dist/modules/log-streaming.ee/log-streaming.controller.d.ts +15 -0
- package/dist/modules/log-streaming.ee/log-streaming.controller.js +149 -0
- package/dist/modules/log-streaming.ee/log-streaming.module.d.ts +5 -0
- package/dist/modules/log-streaming.ee/log-streaming.module.js +66 -0
- package/dist/modules/mcp/mcp-oauth.helpers.js +0 -0
- package/dist/modules/mcp/mcp.oauth-clients.controller.js +0 -0
- package/dist/modules/mcp/tools/execute-workflow.tool.d.ts +10 -10
- package/dist/modules/mcp/tools/schemas.d.ts +10 -10
- package/dist/modules/source-control.ee/constants.d.ts +17 -0
- package/dist/modules/source-control.ee/constants.js +22 -0
- package/dist/modules/source-control.ee/middleware/source-control-enabled-middleware.ee.d.ts +2 -0
- package/dist/modules/source-control.ee/middleware/source-control-enabled-middleware.ee.js +18 -0
- package/dist/modules/source-control.ee/source-control-export.service.ee.d.ts +37 -0
- package/dist/modules/source-control.ee/source-control-export.service.ee.js +426 -0
- package/dist/modules/source-control.ee/source-control-git.service.ee.d.ts +59 -0
- package/dist/modules/source-control.ee/source-control-git.service.ee.js +427 -0
- package/dist/modules/source-control.ee/source-control-helper.ee.d.ts +49 -0
- package/dist/modules/source-control.ee/source-control-helper.ee.js +241 -0
- package/dist/modules/source-control.ee/source-control-import.service.ee.d.ts +110 -0
- package/dist/modules/source-control.ee/source-control-import.service.ee.js +957 -0
- package/dist/modules/source-control.ee/source-control-preferences.service.ee.d.ts +46 -0
- package/dist/modules/source-control.ee/source-control-preferences.service.ee.js +309 -0
- package/dist/modules/source-control.ee/source-control-resource-helper.d.ts +4 -0
- package/dist/modules/source-control.ee/source-control-resource-helper.js +20 -0
- package/dist/modules/source-control.ee/source-control-scoped.service.d.ts +17 -0
- package/dist/modules/source-control.ee/source-control-scoped.service.js +134 -0
- package/dist/modules/source-control.ee/source-control-status.service.ee.d.ts +90 -0
- package/dist/modules/source-control.ee/source-control-status.service.ee.js +596 -0
- package/dist/modules/source-control.ee/source-control.config.d.ts +3 -0
- package/dist/modules/source-control.ee/source-control.config.js +26 -0
- package/dist/modules/source-control.ee/source-control.controller.ee.d.ts +157 -0
- package/dist/modules/source-control.ee/source-control.controller.ee.js +347 -0
- package/dist/modules/source-control.ee/source-control.module.d.ts +4 -0
- package/dist/modules/source-control.ee/source-control.module.js +59 -0
- package/dist/modules/source-control.ee/source-control.service.ee.d.ts +125 -0
- package/dist/modules/source-control.ee/source-control.service.ee.js +466 -0
- package/dist/modules/source-control.ee/types/export-result.d.ts +10 -0
- package/dist/modules/source-control.ee/types/export-result.js +2 -0
- package/dist/modules/source-control.ee/types/exportable-credential.d.ts +14 -0
- package/dist/modules/source-control.ee/types/exportable-credential.js +2 -0
- package/dist/modules/source-control.ee/types/exportable-folders.d.ts +11 -0
- package/dist/modules/source-control.ee/types/exportable-folders.js +2 -0
- package/dist/modules/source-control.ee/types/exportable-project.d.ts +17 -0
- package/dist/modules/source-control.ee/types/exportable-project.js +2 -0
- package/dist/modules/source-control.ee/types/exportable-tags.d.ts +5 -0
- package/dist/modules/source-control.ee/types/exportable-tags.js +2 -0
- package/dist/modules/source-control.ee/types/exportable-variable.d.ts +7 -0
- package/dist/modules/source-control.ee/types/exportable-variable.js +2 -0
- package/dist/modules/source-control.ee/types/exportable-workflow.d.ts +14 -0
- package/dist/modules/source-control.ee/types/exportable-workflow.js +2 -0
- package/dist/modules/source-control.ee/types/import-result.d.ts +20 -0
- package/dist/modules/source-control.ee/types/import-result.js +2 -0
- package/dist/modules/source-control.ee/types/key-pair-type.d.ts +1 -0
- package/dist/modules/source-control.ee/types/key-pair-type.js +2 -0
- package/dist/modules/source-control.ee/types/key-pair.d.ts +4 -0
- package/dist/modules/source-control.ee/types/key-pair.js +2 -0
- package/dist/modules/source-control.ee/types/requests.d.ts +21 -0
- package/dist/modules/source-control.ee/types/requests.js +2 -0
- package/dist/modules/source-control.ee/types/resource-owner.d.ts +17 -0
- package/dist/modules/source-control.ee/types/resource-owner.js +2 -0
- package/dist/modules/source-control.ee/types/source-control-commit.d.ts +3 -0
- package/dist/modules/source-control.ee/types/source-control-commit.js +20 -0
- package/dist/modules/source-control.ee/types/source-control-context.d.ts +7 -0
- package/dist/modules/source-control.ee/types/source-control-context.js +16 -0
- package/dist/modules/source-control.ee/types/source-control-disconnect.d.ts +3 -0
- package/dist/modules/source-control.ee/types/source-control-disconnect.js +21 -0
- package/dist/modules/source-control.ee/types/source-control-generate-key-pair.d.ts +4 -0
- package/dist/modules/source-control.ee/types/source-control-generate-key-pair.js +21 -0
- package/dist/modules/source-control.ee/types/source-control-get-status.d.ts +10 -0
- package/dist/modules/source-control.ee/types/source-control-get-status.js +42 -0
- package/dist/modules/source-control.ee/types/source-control-preferences.d.ts +17 -0
- package/dist/modules/source-control.ee/types/source-control-preferences.js +88 -0
- package/dist/modules/source-control.ee/types/source-control-push.d.ts +3 -0
- package/dist/modules/source-control.ee/types/source-control-push.js +21 -0
- package/dist/modules/source-control.ee/types/source-control-set-branch.d.ts +3 -0
- package/dist/modules/source-control.ee/types/source-control-set-branch.js +20 -0
- package/dist/modules/source-control.ee/types/source-control-set-read-only.d.ts +3 -0
- package/dist/modules/source-control.ee/types/source-control-set-read-only.js +20 -0
- package/dist/modules/source-control.ee/types/source-control-stage.d.ts +5 -0
- package/dist/modules/source-control.ee/types/source-control-stage.js +31 -0
- package/dist/modules/source-control.ee/types/source-control-workflow-version-id.d.ts +12 -0
- package/dist/modules/source-control.ee/types/source-control-workflow-version-id.js +2 -0
- package/dist/modules/sso-oidc/constants.d.ts +3 -0
- package/dist/modules/sso-oidc/constants.js +6 -0
- package/dist/modules/sso-oidc/oidc.controller.ee.d.ts +23 -0
- package/dist/modules/sso-oidc/oidc.controller.ee.js +123 -0
- package/dist/modules/sso-oidc/oidc.service.ee.d.ts +56 -0
- package/dist/modules/sso-oidc/oidc.service.ee.js +468 -0
- package/dist/modules/sso-oidc/sso-oidc.module.d.ts +4 -0
- package/dist/modules/sso-oidc/sso-oidc.module.js +55 -0
- package/dist/modules/sso-saml/constants.d.ts +3 -0
- package/dist/modules/sso-saml/constants.js +6 -0
- package/dist/modules/sso-saml/errors/invalid-saml-metadata-url.error.d.ts +4 -0
- package/dist/modules/sso-saml/errors/invalid-saml-metadata-url.error.js +10 -0
- package/dist/modules/sso-saml/errors/invalid-saml-metadata.error.d.ts +4 -0
- package/dist/modules/sso-saml/errors/invalid-saml-metadata.error.js +10 -0
- package/dist/modules/sso-saml/middleware/saml-enabled-middleware.d.ts +3 -0
- package/dist/modules/sso-saml/middleware/saml-enabled-middleware.js +22 -0
- package/dist/modules/sso-saml/saml-helpers.d.ts +19 -0
- package/dist/modules/sso-saml/saml-helpers.js +129 -0
- package/dist/modules/sso-saml/saml-validator.d.ts +16 -0
- package/dist/modules/sso-saml/saml-validator.js +129 -0
- package/dist/modules/sso-saml/saml.controller.ee.d.ts +50 -0
- package/dist/modules/sso-saml/saml.controller.ee.js +227 -0
- package/dist/modules/sso-saml/saml.service.ee.d.ts +52 -0
- package/dist/modules/sso-saml/saml.service.ee.js +462 -0
- package/dist/modules/sso-saml/schema/metadata-exchange.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/metadata-exchange.xsd.js +118 -0
- package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-secext-1.0.xsd.js +201 -0
- package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/oasis-200401-wss-wssecurity-utility-1.0.xsd.js +114 -0
- package/dist/modules/sso-saml/schema/saml-schema-assertion-2.0.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/saml-schema-assertion-2.0.xsd.js +289 -0
- package/dist/modules/sso-saml/schema/saml-schema-metadata-2.0.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/saml-schema-metadata-2.0.xsd.js +344 -0
- package/dist/modules/sso-saml/schema/saml-schema-protocol-2.0.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/saml-schema-protocol-2.0.xsd.js +308 -0
- package/dist/modules/sso-saml/schema/ws-addr.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/ws-addr.xsd.js +143 -0
- package/dist/modules/sso-saml/schema/ws-authorization.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/ws-authorization.xsd.js +151 -0
- package/dist/modules/sso-saml/schema/ws-federation.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/ws-federation.xsd.js +476 -0
- package/dist/modules/sso-saml/schema/ws-securitypolicy-1.2.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/ws-securitypolicy-1.2.xsd.js +1211 -0
- package/dist/modules/sso-saml/schema/xenc-schema.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/xenc-schema.xsd.js +151 -0
- package/dist/modules/sso-saml/schema/xml.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/xml.xsd.js +123 -0
- package/dist/modules/sso-saml/schema/xmldsig-core-schema.xsd.d.ts +2 -0
- package/dist/modules/sso-saml/schema/xmldsig-core-schema.xsd.js +324 -0
- package/dist/modules/sso-saml/service-provider.ee.d.ts +6 -0
- package/dist/modules/sso-saml/service-provider.ee.js +44 -0
- package/dist/modules/sso-saml/sso-saml.module.d.ts +4 -0
- package/dist/modules/sso-saml/sso-saml.module.js +55 -0
- package/dist/modules/sso-saml/types.d.ts +4 -0
- package/dist/modules/sso-saml/types.js +2 -0
- package/dist/modules/sso-saml/views/init-sso-post.d.ts +2 -0
- package/dist/modules/sso-saml/views/init-sso-post.js +16 -0
- package/dist/node-lib.d.ts +10 -0
- package/dist/node-lib.js +137 -0
- package/dist/push/index.d.ts +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.js +1 -0
- package/dist/services/cors-service.d.ts +7 -0
- package/dist/services/cors-service.js +50 -0
- package/dist/services/static-auth-service.d.ts +4 -0
- package/dist/services/static-auth-service.js +29 -0
- package/dist/sso.ee/saml/schema/metadata-exchange.xsd.js +0 -0
- package/dist/task-runners/task-broker/errors/task-runner-accept-timeout.error.js +0 -0
- package/dist/typecheck.tsbuildinfo +1 -0
- package/dist/user-management/email/templates/workflow-failure.handlebars +211 -0
- package/dist/utils/cors.util.d.ts +2 -0
- package/dist/utils/cors.util.js +17 -0
- package/dist/webhooks/waiting-forms.js +3 -3
- package/dist/webhooks/waiting-webhooks.js +2 -0
- package/dist/workflows/workflow.service.d.ts +2 -2
- package/dist/workflows/workflows.controller.d.ts +6 -6
- package/package.json +22 -21
|
@@ -0,0 +1,334 @@
|
|
|
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 CliController_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.CliController = void 0;
|
|
14
|
+
const backend_common_1 = require("@n8n/backend-common");
|
|
15
|
+
const db_1 = require("@n8n/db");
|
|
16
|
+
const decorators_1 = require("@n8n/decorators");
|
|
17
|
+
const uuid_1 = require("uuid");
|
|
18
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
19
|
+
const active_executions_1 = require("../active-executions");
|
|
20
|
+
const ownership_service_1 = require("../services/ownership.service");
|
|
21
|
+
const utils_1 = require("../utils");
|
|
22
|
+
const workflow_runner_1 = require("../workflow-runner");
|
|
23
|
+
let CliController = CliController_1 = class CliController {
|
|
24
|
+
constructor(logger, workflowRepository, sharedWorkflowRepository, projectRepository, executionRepository, ownershipService, activeExecutions, workflowRunner) {
|
|
25
|
+
this.logger = logger;
|
|
26
|
+
this.workflowRepository = workflowRepository;
|
|
27
|
+
this.sharedWorkflowRepository = sharedWorkflowRepository;
|
|
28
|
+
this.projectRepository = projectRepository;
|
|
29
|
+
this.executionRepository = executionRepository;
|
|
30
|
+
this.ownershipService = ownershipService;
|
|
31
|
+
this.activeExecutions = activeExecutions;
|
|
32
|
+
this.workflowRunner = workflowRunner;
|
|
33
|
+
}
|
|
34
|
+
isWebhookBasedTrigger(nodeType) {
|
|
35
|
+
return (nodeType === n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE ||
|
|
36
|
+
nodeType === 'n8n-nodes-base.webhook' ||
|
|
37
|
+
nodeType.toLowerCase().includes('webhook'));
|
|
38
|
+
}
|
|
39
|
+
isLocalRequest(req) {
|
|
40
|
+
const remoteAddress = req.ip || req.socket.remoteAddress || '';
|
|
41
|
+
return (remoteAddress === '127.0.0.1' ||
|
|
42
|
+
remoteAddress === '::1' ||
|
|
43
|
+
remoteAddress === '::ffff:127.0.0.1' ||
|
|
44
|
+
remoteAddress === 'localhost');
|
|
45
|
+
}
|
|
46
|
+
async run(req, res) {
|
|
47
|
+
const startTime = Date.now();
|
|
48
|
+
this.logger.info('[cli] ── RUN REQUEST ──');
|
|
49
|
+
if (!this.isLocalRequest(req)) {
|
|
50
|
+
res.status(403).json({ error: 'CLI endpoint is only accessible from localhost' });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const body = req.body;
|
|
54
|
+
if (!body.workflowData) {
|
|
55
|
+
res.status(400).json({ error: 'Missing workflowData in request body' });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const fileData = body.workflowData;
|
|
59
|
+
const chatInput = body.chatInput;
|
|
60
|
+
const inputData = body.inputData;
|
|
61
|
+
this.logger.info(`[cli] inputData: ${inputData ? JSON.stringify(inputData) : '(none)'}`);
|
|
62
|
+
if (!fileData.nodes || !Array.isArray(fileData.nodes)) {
|
|
63
|
+
res.status(400).json({ error: 'Workflow does not contain valid nodes' });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (!fileData.connections || typeof fileData.connections !== 'object') {
|
|
67
|
+
res.status(400).json({ error: 'Workflow does not contain valid connections' });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.logger.info(`[cli] Workflow: "${fileData.name}", Nodes: ${fileData.nodes.length}`);
|
|
71
|
+
try {
|
|
72
|
+
const user = await this.ownershipService.getInstanceOwner();
|
|
73
|
+
const workflowId = await this.syncWorkflow(fileData, user.id);
|
|
74
|
+
const workflow = await this.workflowRepository.findOneBy({ id: workflowId });
|
|
75
|
+
if (!workflow) {
|
|
76
|
+
res.status(500).json({ error: 'Failed to sync workflow to database' });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this.logger.info(`[cli] Synced workflow: "${workflow.name}" (ID: ${workflowId})`);
|
|
80
|
+
const triggerNode = workflow.nodes.find((node) => node.type.toLowerCase().includes('trigger') ||
|
|
81
|
+
node.type.toLowerCase().includes('webhook') ||
|
|
82
|
+
node.type === 'n8n-nodes-base.start');
|
|
83
|
+
if (!triggerNode) {
|
|
84
|
+
res.status(400).json({ error: 'No trigger node found in workflow' });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.logger.info(`[cli] Trigger: "${triggerNode.name}" (${triggerNode.type})`);
|
|
88
|
+
let executionId;
|
|
89
|
+
if (this.isWebhookBasedTrigger(triggerNode.type)) {
|
|
90
|
+
this.logger.info('[cli] Using direct execution (webhook/chat trigger)');
|
|
91
|
+
const isChatTrigger = triggerNode.type === n8n_workflow_1.CHAT_TRIGGER_NODE_TYPE;
|
|
92
|
+
const mockData = isChatTrigger
|
|
93
|
+
? {
|
|
94
|
+
sessionId: `cli-${Date.now()}`,
|
|
95
|
+
action: 'sendMessage',
|
|
96
|
+
chatInput: chatInput ?? 'CLI execution',
|
|
97
|
+
}
|
|
98
|
+
: {
|
|
99
|
+
headers: {},
|
|
100
|
+
params: {},
|
|
101
|
+
query: {},
|
|
102
|
+
body: { chatInput },
|
|
103
|
+
};
|
|
104
|
+
const executionData = (0, n8n_workflow_1.createRunExecutionData)({
|
|
105
|
+
startData: {},
|
|
106
|
+
resultData: {
|
|
107
|
+
pinData: { [triggerNode.name]: [{ json: mockData }] },
|
|
108
|
+
runData: {},
|
|
109
|
+
},
|
|
110
|
+
executionData: {
|
|
111
|
+
contextData: {},
|
|
112
|
+
metadata: {},
|
|
113
|
+
nodeExecutionStack: [
|
|
114
|
+
{
|
|
115
|
+
node: triggerNode,
|
|
116
|
+
data: {
|
|
117
|
+
main: [[{ json: mockData }]],
|
|
118
|
+
},
|
|
119
|
+
source: null,
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
waitingExecution: {},
|
|
123
|
+
waitingExecutionSource: {},
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
const runData = {
|
|
127
|
+
executionMode: isChatTrigger ? 'chat' : 'webhook',
|
|
128
|
+
workflowData: workflow,
|
|
129
|
+
userId: user.id,
|
|
130
|
+
startNodes: [{ name: triggerNode.name, sourceData: null }],
|
|
131
|
+
pinData: { [triggerNode.name]: [{ json: mockData }] },
|
|
132
|
+
executionData,
|
|
133
|
+
};
|
|
134
|
+
executionId = await this.workflowRunner.run(runData);
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
this.logger.info('[cli] Using trigger execution (regular trigger)');
|
|
138
|
+
const triggerData = (inputData ?? {});
|
|
139
|
+
if (chatInput !== undefined && !inputData) {
|
|
140
|
+
triggerData.chatInput = chatInput;
|
|
141
|
+
}
|
|
142
|
+
this.logger.info(`[cli] Trigger input data: ${JSON.stringify(triggerData)}`);
|
|
143
|
+
const executionData = (0, n8n_workflow_1.createRunExecutionData)({
|
|
144
|
+
startData: {},
|
|
145
|
+
resultData: {
|
|
146
|
+
pinData: { [triggerNode.name]: [{ json: triggerData }] },
|
|
147
|
+
runData: {},
|
|
148
|
+
},
|
|
149
|
+
executionData: {
|
|
150
|
+
contextData: {},
|
|
151
|
+
metadata: {},
|
|
152
|
+
nodeExecutionStack: [
|
|
153
|
+
{
|
|
154
|
+
node: triggerNode,
|
|
155
|
+
data: {
|
|
156
|
+
main: [[{ json: triggerData }]],
|
|
157
|
+
},
|
|
158
|
+
source: null,
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
waitingExecution: {},
|
|
162
|
+
waitingExecutionSource: {},
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
const runData = {
|
|
166
|
+
executionMode: 'trigger',
|
|
167
|
+
workflowData: workflow,
|
|
168
|
+
userId: user.id,
|
|
169
|
+
startNodes: [{ name: triggerNode.name, sourceData: null }],
|
|
170
|
+
pinData: { [triggerNode.name]: [{ json: triggerData }] },
|
|
171
|
+
executionData,
|
|
172
|
+
};
|
|
173
|
+
executionId = await this.workflowRunner.run(runData);
|
|
174
|
+
}
|
|
175
|
+
this.logger.info(`[cli] Execution started: ${executionId}`);
|
|
176
|
+
let timeoutId;
|
|
177
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
178
|
+
timeoutId = setTimeout(() => {
|
|
179
|
+
reject(new Error(`Execution timed out after ${CliController_1.MAX_WAIT_MS / 1000}s`));
|
|
180
|
+
}, CliController_1.MAX_WAIT_MS);
|
|
181
|
+
});
|
|
182
|
+
try {
|
|
183
|
+
const runResult = await Promise.race([
|
|
184
|
+
this.activeExecutions.getPostExecutePromise(executionId),
|
|
185
|
+
timeoutPromise,
|
|
186
|
+
]);
|
|
187
|
+
if (timeoutId)
|
|
188
|
+
clearTimeout(timeoutId);
|
|
189
|
+
const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
190
|
+
if (!runResult) {
|
|
191
|
+
this.logger.error('[cli] Execution returned no data');
|
|
192
|
+
res.json({
|
|
193
|
+
success: false,
|
|
194
|
+
executionId,
|
|
195
|
+
status: 'error',
|
|
196
|
+
executionTime: totalTime,
|
|
197
|
+
error: 'Execution returned no data',
|
|
198
|
+
});
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const isSuccess = runResult.status !== 'error' && !runResult.data.resultData?.error;
|
|
202
|
+
this.logger.info(`[cli] Execution completed in ${totalTime}s — status: ${runResult.status}, success: ${isSuccess}`);
|
|
203
|
+
const fullExecution = await this.executionRepository.findSingleExecution(executionId, {
|
|
204
|
+
includeData: true,
|
|
205
|
+
unflattenData: true,
|
|
206
|
+
});
|
|
207
|
+
res.json({
|
|
208
|
+
success: isSuccess,
|
|
209
|
+
executionId,
|
|
210
|
+
status: runResult.status,
|
|
211
|
+
executionTime: totalTime,
|
|
212
|
+
data: fullExecution?.data?.resultData ?? runResult.data.resultData,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
if (timeoutId)
|
|
217
|
+
clearTimeout(timeoutId);
|
|
218
|
+
throw error;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
const totalTime = ((Date.now() - startTime) / 1000).toFixed(1);
|
|
223
|
+
this.logger.error(`[cli] Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
224
|
+
res.status(500).json({
|
|
225
|
+
success: false,
|
|
226
|
+
executionTime: totalTime,
|
|
227
|
+
error: error instanceof Error ? error.message : String(error),
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async syncWorkflow(fileData, userId) {
|
|
232
|
+
if (fileData.id && (0, utils_1.isWorkflowIdValid)(fileData.id)) {
|
|
233
|
+
const existing = await this.workflowRepository.findOneBy({ id: fileData.id });
|
|
234
|
+
if (existing) {
|
|
235
|
+
const fileUpdatedAt = fileData.updatedAt
|
|
236
|
+
? new Date(fileData.updatedAt)
|
|
237
|
+
: null;
|
|
238
|
+
const serverUpdatedAt = existing.updatedAt
|
|
239
|
+
? new Date(existing.updatedAt)
|
|
240
|
+
: null;
|
|
241
|
+
if (fileUpdatedAt && serverUpdatedAt && fileUpdatedAt > serverUpdatedAt) {
|
|
242
|
+
this.logger.info(`[cli] Updating existing workflow (ID match): ${existing.id}`);
|
|
243
|
+
await this.workflowRepository.update(existing.id, {
|
|
244
|
+
nodes: fileData.nodes,
|
|
245
|
+
connections: fileData.connections,
|
|
246
|
+
settings: fileData.settings,
|
|
247
|
+
name: fileData.name,
|
|
248
|
+
updatedAt: new Date(),
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this.logger.info(`[cli] Using existing workflow (ID match): ${existing.id}`);
|
|
253
|
+
}
|
|
254
|
+
return existing.id;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (fileData.name) {
|
|
258
|
+
const existing = await this.workflowRepository.findOneBy({ name: fileData.name });
|
|
259
|
+
if (existing) {
|
|
260
|
+
const fileUpdatedAt = fileData.updatedAt
|
|
261
|
+
? new Date(fileData.updatedAt)
|
|
262
|
+
: null;
|
|
263
|
+
const serverUpdatedAt = existing.updatedAt
|
|
264
|
+
? new Date(existing.updatedAt)
|
|
265
|
+
: null;
|
|
266
|
+
if (fileUpdatedAt && serverUpdatedAt && fileUpdatedAt > serverUpdatedAt) {
|
|
267
|
+
this.logger.info(`[cli] Updating existing workflow (name match): ${existing.id}`);
|
|
268
|
+
await this.workflowRepository.update(existing.id, {
|
|
269
|
+
nodes: fileData.nodes,
|
|
270
|
+
connections: fileData.connections,
|
|
271
|
+
settings: fileData.settings,
|
|
272
|
+
name: fileData.name,
|
|
273
|
+
updatedAt: new Date(),
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
this.logger.info(`[cli] Using existing workflow (name match): ${existing.id}`);
|
|
278
|
+
}
|
|
279
|
+
return existing.id;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const workflowId = fileData.id && (0, utils_1.isWorkflowIdValid)(fileData.id) ? fileData.id : (0, db_1.generateNanoId)();
|
|
283
|
+
fileData.id = workflowId;
|
|
284
|
+
this.logger.info(`[cli] Creating new workflow: "${fileData.name}" (ID: ${workflowId})`);
|
|
285
|
+
const { manager: dbManager } = this.workflowRepository;
|
|
286
|
+
await dbManager.transaction(async (transactionManager) => {
|
|
287
|
+
const personalProject = await this.projectRepository.getPersonalProjectForUserOrFail(userId, transactionManager);
|
|
288
|
+
const workflowEntity = this.workflowRepository.create({
|
|
289
|
+
...fileData,
|
|
290
|
+
active: false,
|
|
291
|
+
isArchived: false,
|
|
292
|
+
versionId: fileData.versionId || (0, uuid_1.v4)(),
|
|
293
|
+
createdAt: fileData.createdAt || new Date(),
|
|
294
|
+
updatedAt: fileData.updatedAt || new Date(),
|
|
295
|
+
});
|
|
296
|
+
const savedWorkflow = await transactionManager.save(workflowEntity);
|
|
297
|
+
const sharedWorkflow = this.sharedWorkflowRepository.create({
|
|
298
|
+
role: 'workflow:owner',
|
|
299
|
+
projectId: personalProject.id,
|
|
300
|
+
workflow: savedWorkflow,
|
|
301
|
+
});
|
|
302
|
+
await transactionManager.save(sharedWorkflow);
|
|
303
|
+
});
|
|
304
|
+
return workflowId;
|
|
305
|
+
}
|
|
306
|
+
async health() {
|
|
307
|
+
return { status: 'ok', timestamp: new Date().toISOString() };
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
exports.CliController = CliController;
|
|
311
|
+
CliController.MAX_WAIT_MS = 5 * 60 * 1000;
|
|
312
|
+
__decorate([
|
|
313
|
+
(0, decorators_1.Post)('/run', { skipAuth: true }),
|
|
314
|
+
__metadata("design:type", Function),
|
|
315
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
316
|
+
__metadata("design:returntype", Promise)
|
|
317
|
+
], CliController.prototype, "run", null);
|
|
318
|
+
__decorate([
|
|
319
|
+
(0, decorators_1.Get)('/health', { skipAuth: true }),
|
|
320
|
+
__metadata("design:type", Function),
|
|
321
|
+
__metadata("design:paramtypes", []),
|
|
322
|
+
__metadata("design:returntype", Promise)
|
|
323
|
+
], CliController.prototype, "health", null);
|
|
324
|
+
exports.CliController = CliController = CliController_1 = __decorate([
|
|
325
|
+
(0, decorators_1.RestController)('/cli'),
|
|
326
|
+
__metadata("design:paramtypes", [backend_common_1.Logger,
|
|
327
|
+
db_1.WorkflowRepository,
|
|
328
|
+
db_1.SharedWorkflowRepository,
|
|
329
|
+
db_1.ProjectRepository,
|
|
330
|
+
db_1.ExecutionRepository,
|
|
331
|
+
ownership_service_1.OwnershipService,
|
|
332
|
+
active_executions_1.ActiveExecutions,
|
|
333
|
+
workflow_runner_1.WorkflowRunner])
|
|
334
|
+
], CliController);
|
|
File without changes
|
|
@@ -63,9 +63,9 @@ export declare class UsersController {
|
|
|
63
63
|
mfaEnabled?: boolean | undefined;
|
|
64
64
|
isOwner?: boolean | undefined;
|
|
65
65
|
projectRelations?: {
|
|
66
|
+
role: string;
|
|
66
67
|
id: string;
|
|
67
68
|
name: string;
|
|
68
|
-
role: string;
|
|
69
69
|
}[] | null | undefined;
|
|
70
70
|
isPending?: boolean | undefined;
|
|
71
71
|
signInType?: string | undefined;
|
|
@@ -23,10 +23,10 @@ export declare class SourceControlStatusService {
|
|
|
23
23
|
getStatus(user: User, options: SourceControlGetStatus): Promise<{
|
|
24
24
|
type: "workflow" | "project" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
25
25
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
26
|
+
file: string;
|
|
26
27
|
id: string;
|
|
27
28
|
name: string;
|
|
28
29
|
updatedAt: string;
|
|
29
|
-
file: string;
|
|
30
30
|
location: "local" | "remote";
|
|
31
31
|
conflict: boolean;
|
|
32
32
|
pushed?: boolean | undefined;
|
|
@@ -63,10 +63,10 @@ export declare class SourceControlStatusService {
|
|
|
63
63
|
sourceControlledFiles: {
|
|
64
64
|
type: "workflow" | "project" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
65
65
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
66
|
+
file: string;
|
|
66
67
|
id: string;
|
|
67
68
|
name: string;
|
|
68
69
|
updatedAt: string;
|
|
69
|
-
file: string;
|
|
70
70
|
location: "local" | "remote";
|
|
71
71
|
conflict: boolean;
|
|
72
72
|
pushed?: boolean | undefined;
|
|
@@ -31,10 +31,10 @@ export declare class SourceControlController {
|
|
|
31
31
|
getStatus(req: SourceControlRequest.GetStatus): Promise<{
|
|
32
32
|
type: "workflow" | "project" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
33
33
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
34
|
+
file: string;
|
|
34
35
|
id: string;
|
|
35
36
|
name: string;
|
|
36
37
|
updatedAt: string;
|
|
37
|
-
file: string;
|
|
38
38
|
location: "local" | "remote";
|
|
39
39
|
conflict: boolean;
|
|
40
40
|
pushed?: boolean | undefined;
|
|
@@ -71,10 +71,10 @@ export declare class SourceControlController {
|
|
|
71
71
|
sourceControlledFiles: {
|
|
72
72
|
type: "workflow" | "project" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
73
73
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
74
|
+
file: string;
|
|
74
75
|
id: string;
|
|
75
76
|
name: string;
|
|
76
77
|
updatedAt: string;
|
|
77
|
-
file: string;
|
|
78
78
|
location: "local" | "remote";
|
|
79
79
|
conflict: boolean;
|
|
80
80
|
pushed?: boolean | undefined;
|
|
@@ -88,10 +88,10 @@ export declare class SourceControlController {
|
|
|
88
88
|
status(req: SourceControlRequest.GetStatus): Promise<{
|
|
89
89
|
type: "workflow" | "project" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
90
90
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
91
|
+
file: string;
|
|
91
92
|
id: string;
|
|
92
93
|
name: string;
|
|
93
94
|
updatedAt: string;
|
|
94
|
-
file: string;
|
|
95
95
|
location: "local" | "remote";
|
|
96
96
|
conflict: boolean;
|
|
97
97
|
pushed?: boolean | undefined;
|
|
@@ -128,10 +128,10 @@ export declare class SourceControlController {
|
|
|
128
128
|
sourceControlledFiles: {
|
|
129
129
|
type: "workflow" | "project" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
130
130
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
131
|
+
file: string;
|
|
131
132
|
id: string;
|
|
132
133
|
name: string;
|
|
133
134
|
updatedAt: string;
|
|
134
|
-
file: string;
|
|
135
135
|
location: "local" | "remote";
|
|
136
136
|
conflict: boolean;
|
|
137
137
|
pushed?: boolean | undefined;
|
|
@@ -57,10 +57,10 @@ export declare class SourceControlService {
|
|
|
57
57
|
getStatus(user: User, options: SourceControlGetStatus): Promise<{
|
|
58
58
|
type: "workflow" | "project" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
59
59
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
60
|
+
file: string;
|
|
60
61
|
id: string;
|
|
61
62
|
name: string;
|
|
62
63
|
updatedAt: string;
|
|
63
|
-
file: string;
|
|
64
64
|
location: "local" | "remote";
|
|
65
65
|
conflict: boolean;
|
|
66
66
|
pushed?: boolean | undefined;
|
|
@@ -97,10 +97,10 @@ export declare class SourceControlService {
|
|
|
97
97
|
sourceControlledFiles: {
|
|
98
98
|
type: "workflow" | "project" | "credential" | "file" | "tags" | "variables" | "folders";
|
|
99
99
|
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
100
|
+
file: string;
|
|
100
101
|
id: string;
|
|
101
102
|
name: string;
|
|
102
103
|
updatedAt: string;
|
|
103
|
-
file: string;
|
|
104
104
|
location: "local" | "remote";
|
|
105
105
|
conflict: boolean;
|
|
106
106
|
pushed?: boolean | undefined;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Logger } from '@n8n/backend-common';
|
|
2
|
+
import { UserRepository } from '@n8n/db';
|
|
3
|
+
import { EventService } from '../../events/event.service';
|
|
4
|
+
import { EventRelay } from '../../events/relays/event-relay';
|
|
5
|
+
import { UserManagementMailer } from '../../user-management/email';
|
|
6
|
+
export declare class WorkflowFailureNotificationEventRelay extends EventRelay {
|
|
7
|
+
private readonly mailer;
|
|
8
|
+
private readonly userRepository;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
constructor(eventService: EventService, mailer: UserManagementMailer, userRepository: UserRepository, logger: Logger);
|
|
11
|
+
init(): void;
|
|
12
|
+
private onFirstProductionWorkflowFailed;
|
|
13
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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.WorkflowFailureNotificationEventRelay = void 0;
|
|
13
|
+
const backend_common_1 = require("@n8n/backend-common");
|
|
14
|
+
const db_1 = require("@n8n/db");
|
|
15
|
+
const di_1 = require("@n8n/di");
|
|
16
|
+
const event_service_1 = require("../../events/event.service");
|
|
17
|
+
const event_relay_1 = require("../../events/relays/event-relay");
|
|
18
|
+
const email_1 = require("../../user-management/email");
|
|
19
|
+
let WorkflowFailureNotificationEventRelay = class WorkflowFailureNotificationEventRelay extends event_relay_1.EventRelay {
|
|
20
|
+
constructor(eventService, mailer, userRepository, logger) {
|
|
21
|
+
super(eventService);
|
|
22
|
+
this.mailer = mailer;
|
|
23
|
+
this.userRepository = userRepository;
|
|
24
|
+
this.logger = logger;
|
|
25
|
+
}
|
|
26
|
+
init() {
|
|
27
|
+
this.setupListeners({
|
|
28
|
+
'instance-first-production-workflow-failed': async (event) => await this.onFirstProductionWorkflowFailed(event),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async onFirstProductionWorkflowFailed(event) {
|
|
32
|
+
const { workflowId, workflowName, userId } = event;
|
|
33
|
+
if (!this.mailer.isEmailSetUp) {
|
|
34
|
+
this.logger.debug('Skipping first production failure email - SMTP not configured', {
|
|
35
|
+
workflowId,
|
|
36
|
+
userId,
|
|
37
|
+
});
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const user = await this.userRepository.findOneBy({ id: userId });
|
|
42
|
+
if (!user || !user.email) {
|
|
43
|
+
this.logger.warn('Cannot send first production failure email - user not found or no email', {
|
|
44
|
+
workflowId,
|
|
45
|
+
userId,
|
|
46
|
+
});
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
await this.mailer.workflowFailure({
|
|
50
|
+
email: user.email,
|
|
51
|
+
firstName: user.firstName,
|
|
52
|
+
workflowId,
|
|
53
|
+
workflowName,
|
|
54
|
+
});
|
|
55
|
+
this.logger.info('Sent first production failure email', {
|
|
56
|
+
workflowId,
|
|
57
|
+
userId,
|
|
58
|
+
email: user.email,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.logger.error('Failed to send first production failure email', {
|
|
63
|
+
workflowId,
|
|
64
|
+
userId,
|
|
65
|
+
error: error instanceof Error ? error.message : String(error),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
exports.WorkflowFailureNotificationEventRelay = WorkflowFailureNotificationEventRelay;
|
|
71
|
+
exports.WorkflowFailureNotificationEventRelay = WorkflowFailureNotificationEventRelay = __decorate([
|
|
72
|
+
(0, di_1.Service)(),
|
|
73
|
+
__metadata("design:paramtypes", [event_service_1.EventService,
|
|
74
|
+
email_1.UserManagementMailer,
|
|
75
|
+
db_1.UserRepository,
|
|
76
|
+
backend_common_1.Logger])
|
|
77
|
+
], WorkflowFailureNotificationEventRelay);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IWorkflowBase } from 'n8n-workflow';
|
|
2
|
+
type ExecutionRef = {
|
|
3
|
+
workflowId: string;
|
|
4
|
+
executionId: string;
|
|
5
|
+
};
|
|
6
|
+
type ExecutionDataPayload = {
|
|
7
|
+
data: string;
|
|
8
|
+
workflowData: IWorkflowBase;
|
|
9
|
+
workflowVersionId: string | null;
|
|
10
|
+
};
|
|
11
|
+
export interface ExecutionDataManager {
|
|
12
|
+
init?(): Promise<void>;
|
|
13
|
+
write(ref: ExecutionRef, payload: ExecutionDataPayload): Promise<void>;
|
|
14
|
+
read(ref: ExecutionRef): Promise<ExecutionDataPayload>;
|
|
15
|
+
delete(ref: ExecutionRef | ExecutionRef[]): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ExecutionError, type INode, type IRun, type WorkflowExecuteMode } from 'n8n-workflow';
|
|
2
|
+
export declare class FailedRunFactory {
|
|
3
|
+
generateFailedExecutionFromError(mode: WorkflowExecuteMode, error: ExecutionError, node: INode | undefined, startTime?: number): IRun;
|
|
4
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.FailedRunFactory = void 0;
|
|
10
|
+
const di_1 = require("@n8n/di");
|
|
11
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
12
|
+
let FailedRunFactory = class FailedRunFactory {
|
|
13
|
+
generateFailedExecutionFromError(mode, error, node, startTime = Date.now()) {
|
|
14
|
+
const executionError = {
|
|
15
|
+
...error,
|
|
16
|
+
message: error.message,
|
|
17
|
+
stack: error.stack,
|
|
18
|
+
};
|
|
19
|
+
const returnData = {
|
|
20
|
+
data: (0, n8n_workflow_1.createRunExecutionData)({
|
|
21
|
+
resultData: {
|
|
22
|
+
error: executionError,
|
|
23
|
+
runData: {},
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
finished: false,
|
|
27
|
+
mode,
|
|
28
|
+
startedAt: new Date(),
|
|
29
|
+
stoppedAt: new Date(),
|
|
30
|
+
status: 'error',
|
|
31
|
+
};
|
|
32
|
+
if (node) {
|
|
33
|
+
returnData.data.startData = {
|
|
34
|
+
destinationNode: {
|
|
35
|
+
nodeName: node.name,
|
|
36
|
+
mode: 'inclusive',
|
|
37
|
+
},
|
|
38
|
+
runNodeFilter: [node.name],
|
|
39
|
+
};
|
|
40
|
+
returnData.data.resultData.lastNodeExecuted = node.name;
|
|
41
|
+
returnData.data.resultData.runData[node.name] = [
|
|
42
|
+
{
|
|
43
|
+
startTime,
|
|
44
|
+
executionIndex: 0,
|
|
45
|
+
executionTime: 0,
|
|
46
|
+
executionStatus: 'error',
|
|
47
|
+
error: executionError,
|
|
48
|
+
source: [],
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
returnData.data.executionData = {
|
|
52
|
+
contextData: {},
|
|
53
|
+
metadata: {},
|
|
54
|
+
waitingExecution: {},
|
|
55
|
+
waitingExecutionSource: {},
|
|
56
|
+
nodeExecutionStack: [
|
|
57
|
+
{
|
|
58
|
+
node,
|
|
59
|
+
data: {},
|
|
60
|
+
source: null,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return returnData;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.FailedRunFactory = FailedRunFactory;
|
|
69
|
+
exports.FailedRunFactory = FailedRunFactory = __decorate([
|
|
70
|
+
(0, di_1.Service)()
|
|
71
|
+
], FailedRunFactory);
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { default } from './node-lib';
|
|
2
|
+
export { run, type N8nRunOptions } from './node-lib';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.run = exports.default = void 0;
|
|
7
|
+
var node_lib_1 = require("./node-lib");
|
|
8
|
+
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(node_lib_1).default; } });
|
|
9
|
+
var node_lib_2 = require("./node-lib");
|
|
10
|
+
Object.defineProperty(exports, "run", { enumerable: true, get: function () { return node_lib_2.run; } });
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { ActiveWorkflowManager } from './active-workflow-manager';
|
|
|
7
7
|
import type { ExternalHooks } from './external-hooks';
|
|
8
8
|
import type WebSocket from 'ws';
|
|
9
9
|
export interface ExtendedWebSocket extends WebSocket {
|
|
10
|
-
isAlive
|
|
10
|
+
isAlive: boolean;
|
|
11
11
|
}
|
|
12
12
|
export interface ICredentialsTypeData {
|
|
13
13
|
[key: string]: CredentialLoadingDetails;
|