@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,46 @@
|
|
|
1
|
+
import { Logger } from '@n8n/backend-common';
|
|
2
|
+
import { SettingsRepository } from '@n8n/db';
|
|
3
|
+
import type { ValidationError } from 'class-validator';
|
|
4
|
+
import { Cipher, InstanceSettings } from 'n8n-core';
|
|
5
|
+
import { SourceControlConfig } from './source-control.config';
|
|
6
|
+
import type { KeyPairType } from './types/key-pair-type';
|
|
7
|
+
import { SourceControlPreferences } from './types/source-control-preferences';
|
|
8
|
+
export declare class SourceControlPreferencesService {
|
|
9
|
+
private readonly instanceSettings;
|
|
10
|
+
private readonly logger;
|
|
11
|
+
private readonly cipher;
|
|
12
|
+
private readonly settingsRepository;
|
|
13
|
+
private readonly sourceControlConfig;
|
|
14
|
+
private _sourceControlPreferences;
|
|
15
|
+
readonly sshKeyName: string;
|
|
16
|
+
readonly sshFolder: string;
|
|
17
|
+
readonly gitFolder: string;
|
|
18
|
+
constructor(instanceSettings: InstanceSettings, logger: Logger, cipher: Cipher, settingsRepository: SettingsRepository, sourceControlConfig: SourceControlConfig);
|
|
19
|
+
get sourceControlPreferences(): SourceControlPreferences;
|
|
20
|
+
set sourceControlPreferences(preferences: Partial<SourceControlPreferences>);
|
|
21
|
+
isSourceControlSetup(): string | false;
|
|
22
|
+
private getKeyPairFromDatabase;
|
|
23
|
+
private getPrivateKeyFromDatabase;
|
|
24
|
+
private getPublicKeyFromDatabase;
|
|
25
|
+
private getHttpsCredentialsFromDatabase;
|
|
26
|
+
getDecryptedHttpsCredentials(): Promise<{
|
|
27
|
+
username: string;
|
|
28
|
+
password: string;
|
|
29
|
+
}>;
|
|
30
|
+
saveHttpsCredentials(username: string, password: string): Promise<void>;
|
|
31
|
+
deleteHttpsCredentials(): Promise<void>;
|
|
32
|
+
getPrivateKeyPath(): Promise<string>;
|
|
33
|
+
getPublicKey(): Promise<string>;
|
|
34
|
+
deleteKeyPair(): Promise<void>;
|
|
35
|
+
resetKnownHosts(): Promise<void>;
|
|
36
|
+
generateAndSaveKeyPair(keyPairType?: KeyPairType): Promise<SourceControlPreferences>;
|
|
37
|
+
isBranchReadOnly(): boolean;
|
|
38
|
+
isSourceControlConnected(): boolean;
|
|
39
|
+
isSourceControlLicensedAndEnabled(): boolean;
|
|
40
|
+
getBranchName(): string;
|
|
41
|
+
getPreferences(): SourceControlPreferences;
|
|
42
|
+
validateSourceControlPreferences(preferences: Partial<SourceControlPreferences>, allowMissingProperties?: boolean): Promise<ValidationError[]>;
|
|
43
|
+
setPreferences(preferences: Partial<SourceControlPreferences>, saveToDb?: boolean, broadcastReload?: boolean): Promise<SourceControlPreferences>;
|
|
44
|
+
private broadcastReloadSourceControlConfiguration;
|
|
45
|
+
loadFromDbAndApplySourceControlPreferences(): Promise<SourceControlPreferences | undefined>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.SourceControlPreferencesService = void 0;
|
|
46
|
+
const backend_common_1 = require("@n8n/backend-common");
|
|
47
|
+
const db_1 = require("@n8n/db");
|
|
48
|
+
const di_1 = require("@n8n/di");
|
|
49
|
+
const class_validator_1 = require("class-validator");
|
|
50
|
+
const promises_1 = require("fs/promises");
|
|
51
|
+
const n8n_core_1 = require("n8n-core");
|
|
52
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
53
|
+
const promises_2 = require("node:fs/promises");
|
|
54
|
+
const path = __importStar(require("path"));
|
|
55
|
+
const constants_1 = require("./constants");
|
|
56
|
+
const source_control_helper_ee_1 = require("./source-control-helper.ee");
|
|
57
|
+
const source_control_config_1 = require("./source-control.config");
|
|
58
|
+
const source_control_preferences_1 = require("./types/source-control-preferences");
|
|
59
|
+
let SourceControlPreferencesService = class SourceControlPreferencesService {
|
|
60
|
+
constructor(instanceSettings, logger, cipher, settingsRepository, sourceControlConfig) {
|
|
61
|
+
this.instanceSettings = instanceSettings;
|
|
62
|
+
this.logger = logger;
|
|
63
|
+
this.cipher = cipher;
|
|
64
|
+
this.settingsRepository = settingsRepository;
|
|
65
|
+
this.sourceControlConfig = sourceControlConfig;
|
|
66
|
+
this._sourceControlPreferences = new source_control_preferences_1.SourceControlPreferences();
|
|
67
|
+
this.sshFolder = path.join(instanceSettings.n8nFolder, constants_1.SOURCE_CONTROL_SSH_FOLDER);
|
|
68
|
+
this.gitFolder = path.join(instanceSettings.n8nFolder, constants_1.SOURCE_CONTROL_GIT_FOLDER);
|
|
69
|
+
this.sshKeyName = path.join(this.sshFolder, constants_1.SOURCE_CONTROL_SSH_KEY_NAME);
|
|
70
|
+
}
|
|
71
|
+
get sourceControlPreferences() {
|
|
72
|
+
return {
|
|
73
|
+
...this._sourceControlPreferences,
|
|
74
|
+
connected: this._sourceControlPreferences.connected ?? false,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
set sourceControlPreferences(preferences) {
|
|
78
|
+
this._sourceControlPreferences = source_control_preferences_1.SourceControlPreferences.merge(preferences, this._sourceControlPreferences);
|
|
79
|
+
}
|
|
80
|
+
isSourceControlSetup() {
|
|
81
|
+
return (this.isSourceControlLicensedAndEnabled() &&
|
|
82
|
+
this.getPreferences().repositoryUrl &&
|
|
83
|
+
this.getPreferences().branchName);
|
|
84
|
+
}
|
|
85
|
+
async getKeyPairFromDatabase() {
|
|
86
|
+
const dbSetting = await this.settingsRepository.findByKey('features.sourceControl.sshKeys');
|
|
87
|
+
if (!dbSetting?.value)
|
|
88
|
+
return null;
|
|
89
|
+
return (0, n8n_workflow_1.jsonParse)(dbSetting.value, { fallbackValue: null });
|
|
90
|
+
}
|
|
91
|
+
async getPrivateKeyFromDatabase() {
|
|
92
|
+
const dbKeyPair = await this.getKeyPairFromDatabase();
|
|
93
|
+
if (!dbKeyPair)
|
|
94
|
+
throw new n8n_workflow_1.UnexpectedError('Failed to find key pair in database');
|
|
95
|
+
return this.cipher.decrypt(dbKeyPair.encryptedPrivateKey);
|
|
96
|
+
}
|
|
97
|
+
async getPublicKeyFromDatabase() {
|
|
98
|
+
const dbKeyPair = await this.getKeyPairFromDatabase();
|
|
99
|
+
if (!dbKeyPair)
|
|
100
|
+
throw new n8n_workflow_1.UnexpectedError('Failed to find key pair in database');
|
|
101
|
+
return dbKeyPair.publicKey;
|
|
102
|
+
}
|
|
103
|
+
async getHttpsCredentialsFromDatabase() {
|
|
104
|
+
const dbSetting = await this.settingsRepository.findByKey('features.sourceControl.httpsCredentials');
|
|
105
|
+
if (!dbSetting?.value)
|
|
106
|
+
throw new n8n_workflow_1.UnexpectedError('No credentials found for https connection');
|
|
107
|
+
return (0, n8n_workflow_1.jsonParse)(dbSetting.value);
|
|
108
|
+
}
|
|
109
|
+
async getDecryptedHttpsCredentials() {
|
|
110
|
+
const credentials = await this.getHttpsCredentialsFromDatabase();
|
|
111
|
+
return {
|
|
112
|
+
username: this.cipher.decrypt(credentials.encryptedUsername),
|
|
113
|
+
password: this.cipher.decrypt(credentials.encryptedPassword),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
async saveHttpsCredentials(username, password) {
|
|
117
|
+
try {
|
|
118
|
+
await this.settingsRepository.save({
|
|
119
|
+
key: 'features.sourceControl.httpsCredentials',
|
|
120
|
+
value: JSON.stringify({
|
|
121
|
+
encryptedUsername: this.cipher.encrypt(username),
|
|
122
|
+
encryptedPassword: this.cipher.encrypt(password),
|
|
123
|
+
}),
|
|
124
|
+
loadOnStartup: true,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw new n8n_workflow_1.UnexpectedError('Failed to save HTTPS credentials to database', { cause: error });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
async deleteHttpsCredentials() {
|
|
132
|
+
try {
|
|
133
|
+
await this.settingsRepository.delete({ key: 'features.sourceControl.httpsCredentials' });
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
this.logger.error('Failed to delete HTTPS credentials from database', { error });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async getPrivateKeyPath() {
|
|
140
|
+
const dbPrivateKey = await this.getPrivateKeyFromDatabase();
|
|
141
|
+
const tempFilePath = path.join(this.instanceSettings.n8nFolder, 'ssh_private_key_temp');
|
|
142
|
+
const normalizedKey = dbPrivateKey.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
143
|
+
try {
|
|
144
|
+
await (0, promises_1.rm)(tempFilePath, { force: true });
|
|
145
|
+
await (0, promises_2.writeFile)(tempFilePath, normalizedKey, { mode: 0o600 });
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
this.logger.error('Failed to write SSH private key to temp file', {
|
|
149
|
+
tempFilePath,
|
|
150
|
+
error: error instanceof Error ? error.message : String(error),
|
|
151
|
+
});
|
|
152
|
+
throw new n8n_workflow_1.UnexpectedError('Failed to create SSH private key file', { cause: error });
|
|
153
|
+
}
|
|
154
|
+
return tempFilePath;
|
|
155
|
+
}
|
|
156
|
+
async getPublicKey() {
|
|
157
|
+
try {
|
|
158
|
+
const dbPublicKey = await this.getPublicKeyFromDatabase();
|
|
159
|
+
if (dbPublicKey)
|
|
160
|
+
return dbPublicKey;
|
|
161
|
+
return await (0, promises_2.readFile)(this.sshKeyName + '.pub', { encoding: 'utf8' });
|
|
162
|
+
}
|
|
163
|
+
catch (e) {
|
|
164
|
+
const error = e instanceof Error ? e : new Error(`${e}`);
|
|
165
|
+
this.logger.error(`Failed to read SSH public key: ${error.message}`);
|
|
166
|
+
}
|
|
167
|
+
return '';
|
|
168
|
+
}
|
|
169
|
+
async deleteKeyPair() {
|
|
170
|
+
try {
|
|
171
|
+
await (0, promises_1.rm)(this.sshFolder, { recursive: true });
|
|
172
|
+
await this.settingsRepository.delete({ key: 'features.sourceControl.sshKeys' });
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
const error = e instanceof Error ? e : new Error(`${e}`);
|
|
176
|
+
this.logger.error(`Failed to delete SSH key pair: ${error.message}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async resetKnownHosts() {
|
|
180
|
+
const knownHostsPath = path.join(this.sshFolder, 'known_hosts');
|
|
181
|
+
try {
|
|
182
|
+
await (0, promises_1.rm)(knownHostsPath, { force: true });
|
|
183
|
+
this.logger.debug('Cleared SSH known_hosts file');
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
this.logger.warn('Failed to clear known_hosts file', { error });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
async generateAndSaveKeyPair(keyPairType) {
|
|
190
|
+
if (!keyPairType) {
|
|
191
|
+
keyPairType =
|
|
192
|
+
this.getPreferences().keyGeneratorType ?? this.sourceControlConfig.defaultKeyPairType;
|
|
193
|
+
}
|
|
194
|
+
const keyPair = await (0, source_control_helper_ee_1.generateSshKeyPair)(keyPairType);
|
|
195
|
+
try {
|
|
196
|
+
await this.settingsRepository.save({
|
|
197
|
+
key: 'features.sourceControl.sshKeys',
|
|
198
|
+
value: JSON.stringify({
|
|
199
|
+
encryptedPrivateKey: this.cipher.encrypt(keyPair.privateKey),
|
|
200
|
+
publicKey: keyPair.publicKey,
|
|
201
|
+
}),
|
|
202
|
+
loadOnStartup: true,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
throw new n8n_workflow_1.UnexpectedError('Failed to write key pair to database', { cause: error });
|
|
207
|
+
}
|
|
208
|
+
if (keyPairType !== this.getPreferences().keyGeneratorType) {
|
|
209
|
+
await this.setPreferences({ keyGeneratorType: keyPairType });
|
|
210
|
+
}
|
|
211
|
+
return this.getPreferences();
|
|
212
|
+
}
|
|
213
|
+
isBranchReadOnly() {
|
|
214
|
+
return this._sourceControlPreferences.branchReadOnly;
|
|
215
|
+
}
|
|
216
|
+
isSourceControlConnected() {
|
|
217
|
+
return this.sourceControlPreferences.connected;
|
|
218
|
+
}
|
|
219
|
+
isSourceControlLicensedAndEnabled() {
|
|
220
|
+
return this.isSourceControlConnected() && (0, source_control_helper_ee_1.isSourceControlLicensed)();
|
|
221
|
+
}
|
|
222
|
+
getBranchName() {
|
|
223
|
+
return this.sourceControlPreferences.branchName;
|
|
224
|
+
}
|
|
225
|
+
getPreferences() {
|
|
226
|
+
return this.sourceControlPreferences;
|
|
227
|
+
}
|
|
228
|
+
async validateSourceControlPreferences(preferences, allowMissingProperties = true) {
|
|
229
|
+
const preferencesObject = new source_control_preferences_1.SourceControlPreferences(preferences);
|
|
230
|
+
const validationResult = await (0, class_validator_1.validate)(preferencesObject, {
|
|
231
|
+
forbidUnknownValues: false,
|
|
232
|
+
skipMissingProperties: allowMissingProperties,
|
|
233
|
+
stopAtFirstError: false,
|
|
234
|
+
validationError: { target: false },
|
|
235
|
+
});
|
|
236
|
+
if (validationResult.length > 0) {
|
|
237
|
+
throw new n8n_workflow_1.UnexpectedError('Invalid source control preferences', {
|
|
238
|
+
extra: { preferences: validationResult },
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return validationResult;
|
|
242
|
+
}
|
|
243
|
+
async setPreferences(preferences, saveToDb = true, broadcastReload = true) {
|
|
244
|
+
const noKeyPair = (await this.getKeyPairFromDatabase()) === null;
|
|
245
|
+
if (noKeyPair &&
|
|
246
|
+
(preferences.connectionType === 'ssh' || preferences.connectionType === undefined)) {
|
|
247
|
+
await this.generateAndSaveKeyPair();
|
|
248
|
+
}
|
|
249
|
+
const sanitizedPreferences = { ...preferences };
|
|
250
|
+
if (preferences.httpsUsername && preferences.httpsPassword) {
|
|
251
|
+
await this.saveHttpsCredentials(preferences.httpsUsername, preferences.httpsPassword);
|
|
252
|
+
}
|
|
253
|
+
delete sanitizedPreferences.httpsUsername;
|
|
254
|
+
delete sanitizedPreferences.httpsPassword;
|
|
255
|
+
this.sourceControlPreferences = sanitizedPreferences;
|
|
256
|
+
if (saveToDb) {
|
|
257
|
+
const settingsValue = JSON.stringify(this._sourceControlPreferences);
|
|
258
|
+
try {
|
|
259
|
+
await this.settingsRepository.save({
|
|
260
|
+
key: constants_1.SOURCE_CONTROL_PREFERENCES_DB_KEY,
|
|
261
|
+
value: settingsValue,
|
|
262
|
+
loadOnStartup: true,
|
|
263
|
+
}, { transaction: false });
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
throw new n8n_workflow_1.UnexpectedError('Failed to save source control preferences', { cause: error });
|
|
267
|
+
}
|
|
268
|
+
if (broadcastReload) {
|
|
269
|
+
await this.broadcastReloadSourceControlConfiguration();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return this.sourceControlPreferences;
|
|
273
|
+
}
|
|
274
|
+
async broadcastReloadSourceControlConfiguration() {
|
|
275
|
+
if (this.instanceSettings.isMultiMain) {
|
|
276
|
+
const { Publisher } = await Promise.resolve().then(() => __importStar(require('../../scaling/pubsub/publisher.service')));
|
|
277
|
+
await di_1.Container.get(Publisher).publishCommand({ command: 'reload-source-control-config' });
|
|
278
|
+
this.logger.debug('Broadcasting source control configuration reload to other main instances');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async loadFromDbAndApplySourceControlPreferences() {
|
|
282
|
+
const loadedPreferences = await this.settingsRepository.findOne({
|
|
283
|
+
where: { key: constants_1.SOURCE_CONTROL_PREFERENCES_DB_KEY },
|
|
284
|
+
});
|
|
285
|
+
if (loadedPreferences) {
|
|
286
|
+
try {
|
|
287
|
+
const preferences = (0, n8n_workflow_1.jsonParse)(loadedPreferences.value);
|
|
288
|
+
if (preferences) {
|
|
289
|
+
await this.setPreferences(preferences, false, false);
|
|
290
|
+
return preferences;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
this.logger.warn(`Could not parse Source Control settings from database: ${error.message}`);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
await this.setPreferences(new source_control_preferences_1.SourceControlPreferences(), true, false);
|
|
298
|
+
return this.sourceControlPreferences;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
exports.SourceControlPreferencesService = SourceControlPreferencesService;
|
|
302
|
+
exports.SourceControlPreferencesService = SourceControlPreferencesService = __decorate([
|
|
303
|
+
(0, di_1.Service)(),
|
|
304
|
+
__metadata("design:paramtypes", [n8n_core_1.InstanceSettings,
|
|
305
|
+
backend_common_1.Logger,
|
|
306
|
+
n8n_core_1.Cipher,
|
|
307
|
+
db_1.SettingsRepository,
|
|
308
|
+
source_control_config_1.SourceControlConfig])
|
|
309
|
+
], SourceControlPreferencesService);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SourceControlledFile } from '@n8n/api-types';
|
|
2
|
+
export declare function filterByType(files: SourceControlledFile[], resourceType: SourceControlledFile['type']): SourceControlledFile[];
|
|
3
|
+
export declare function getDeletedResources(files: SourceControlledFile[], resourceType: SourceControlledFile['type']): SourceControlledFile[];
|
|
4
|
+
export declare function getNonDeletedResources(files: SourceControlledFile[], resourceType: SourceControlledFile['type']): SourceControlledFile[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterByType = filterByType;
|
|
4
|
+
exports.getDeletedResources = getDeletedResources;
|
|
5
|
+
exports.getNonDeletedResources = getNonDeletedResources;
|
|
6
|
+
function filterByType(files, resourceType) {
|
|
7
|
+
return files.filter((file) => file.type === resourceType);
|
|
8
|
+
}
|
|
9
|
+
function filterByStatus(files, resourceType, status) {
|
|
10
|
+
return filterByType(files, resourceType).filter((file) => file.status === status);
|
|
11
|
+
}
|
|
12
|
+
function filterByStatusExcluding(files, resourceType, status) {
|
|
13
|
+
return filterByType(files, resourceType).filter((file) => file.status !== status);
|
|
14
|
+
}
|
|
15
|
+
function getDeletedResources(files, resourceType) {
|
|
16
|
+
return filterByStatus(files, resourceType, 'deleted');
|
|
17
|
+
}
|
|
18
|
+
function getNonDeletedResources(files, resourceType) {
|
|
19
|
+
return filterByStatusExcluding(files, resourceType, 'deleted');
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ProjectRepository, WorkflowRepository } from '@n8n/db';
|
|
2
|
+
import { type AuthenticatedRequest, type CredentialsEntity, type Folder, type Project, type WorkflowEntity, type WorkflowTagMapping } from '@n8n/db';
|
|
3
|
+
import type { FindOptionsWhere } from '@n8n/typeorm';
|
|
4
|
+
import { SourceControlContext } from './types/source-control-context';
|
|
5
|
+
export declare class SourceControlScopedService {
|
|
6
|
+
private readonly projectRepository;
|
|
7
|
+
private readonly workflowRepository;
|
|
8
|
+
constructor(projectRepository: ProjectRepository, workflowRepository: WorkflowRepository);
|
|
9
|
+
ensureIsAllowedToPush(req: AuthenticatedRequest): Promise<void>;
|
|
10
|
+
getAuthorizedProjectsFromContext(context: SourceControlContext): Promise<Project[]>;
|
|
11
|
+
getWorkflowsInAdminProjectsFromContext(context: SourceControlContext, id?: string): Promise<WorkflowEntity[] | undefined>;
|
|
12
|
+
getProjectsWithPushScopeByContextFilter(context: SourceControlContext): FindOptionsWhere<Project> | undefined;
|
|
13
|
+
getFoldersInAdminProjectsFromContextFilter(context: SourceControlContext): FindOptionsWhere<Folder>;
|
|
14
|
+
getWorkflowsInAdminProjectsFromContextFilter(context: SourceControlContext): FindOptionsWhere<WorkflowEntity>;
|
|
15
|
+
getCredentialsInAdminProjectsFromContextFilter(context: SourceControlContext): FindOptionsWhere<CredentialsEntity>;
|
|
16
|
+
getWorkflowTagMappingInAdminProjectsFromContextFilter(context: SourceControlContext): FindOptionsWhere<WorkflowTagMapping>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
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.SourceControlScopedService = void 0;
|
|
13
|
+
const db_1 = require("@n8n/db");
|
|
14
|
+
const di_1 = require("@n8n/di");
|
|
15
|
+
const permissions_1 = require("@n8n/permissions");
|
|
16
|
+
const source_control_context_1 = require("./types/source-control-context");
|
|
17
|
+
const forbidden_error_1 = require("../../errors/response-errors/forbidden.error");
|
|
18
|
+
let SourceControlScopedService = class SourceControlScopedService {
|
|
19
|
+
constructor(projectRepository, workflowRepository) {
|
|
20
|
+
this.projectRepository = projectRepository;
|
|
21
|
+
this.workflowRepository = workflowRepository;
|
|
22
|
+
}
|
|
23
|
+
async ensureIsAllowedToPush(req) {
|
|
24
|
+
if ((0, permissions_1.hasGlobalScope)(req.user, 'sourceControl:push')) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const ctx = new source_control_context_1.SourceControlContext(req.user);
|
|
28
|
+
const projectsWithAdminAccess = await this.getAuthorizedProjectsFromContext(ctx);
|
|
29
|
+
if (projectsWithAdminAccess?.length === 0) {
|
|
30
|
+
throw new forbidden_error_1.ForbiddenError('You are not allowed to push changes');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async getAuthorizedProjectsFromContext(context) {
|
|
34
|
+
if (context.hasAccessToAllProjects()) {
|
|
35
|
+
return await this.projectRepository.find({
|
|
36
|
+
relations: {
|
|
37
|
+
projectRelations: {
|
|
38
|
+
user: true,
|
|
39
|
+
role: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return await this.projectRepository.find({
|
|
45
|
+
relations: {
|
|
46
|
+
projectRelations: {
|
|
47
|
+
user: true,
|
|
48
|
+
role: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
select: {
|
|
52
|
+
id: true,
|
|
53
|
+
name: true,
|
|
54
|
+
type: true,
|
|
55
|
+
},
|
|
56
|
+
where: this.getProjectsWithPushScopeByContextFilter(context),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async getWorkflowsInAdminProjectsFromContext(context, id) {
|
|
60
|
+
if (context.hasAccessToAllProjects()) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const where = this.getWorkflowsInAdminProjectsFromContextFilter(context);
|
|
64
|
+
if (id) {
|
|
65
|
+
where.id = id;
|
|
66
|
+
}
|
|
67
|
+
return await this.workflowRepository.find({
|
|
68
|
+
select: {
|
|
69
|
+
id: true,
|
|
70
|
+
},
|
|
71
|
+
where,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
getProjectsWithPushScopeByContextFilter(context) {
|
|
75
|
+
if (context.hasAccessToAllProjects()) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
type: 'team',
|
|
80
|
+
projectRelations: {
|
|
81
|
+
role: {
|
|
82
|
+
scopes: {
|
|
83
|
+
slug: 'sourceControl:push',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
userId: context.user.id,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
getFoldersInAdminProjectsFromContextFilter(context) {
|
|
91
|
+
if (context.hasAccessToAllProjects()) {
|
|
92
|
+
return {};
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
homeProject: this.getProjectsWithPushScopeByContextFilter(context),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
getWorkflowsInAdminProjectsFromContextFilter(context) {
|
|
99
|
+
if (context.hasAccessToAllProjects()) {
|
|
100
|
+
return {};
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
shared: {
|
|
104
|
+
role: 'workflow:owner',
|
|
105
|
+
project: this.getProjectsWithPushScopeByContextFilter(context),
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
getCredentialsInAdminProjectsFromContextFilter(context) {
|
|
110
|
+
if (context.hasAccessToAllProjects()) {
|
|
111
|
+
return {};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
shared: {
|
|
115
|
+
role: 'credential:owner',
|
|
116
|
+
project: this.getProjectsWithPushScopeByContextFilter(context),
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
getWorkflowTagMappingInAdminProjectsFromContextFilter(context) {
|
|
121
|
+
if (context.hasAccessToAllProjects()) {
|
|
122
|
+
return {};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
workflows: this.getWorkflowsInAdminProjectsFromContextFilter(context),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
exports.SourceControlScopedService = SourceControlScopedService;
|
|
130
|
+
exports.SourceControlScopedService = SourceControlScopedService = __decorate([
|
|
131
|
+
(0, di_1.Service)(),
|
|
132
|
+
__metadata("design:paramtypes", [db_1.ProjectRepository,
|
|
133
|
+
db_1.WorkflowRepository])
|
|
134
|
+
], SourceControlScopedService);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Logger } from '@n8n/backend-common';
|
|
2
|
+
import { FolderRepository, type TagEntity, TagRepository, type User } from '@n8n/db';
|
|
3
|
+
import { EventService } from '../../events/event.service';
|
|
4
|
+
import { SourceControlGitService } from './source-control-git.service.ee';
|
|
5
|
+
import { SourceControlImportService } from './source-control-import.service.ee';
|
|
6
|
+
import { SourceControlPreferencesService } from './source-control-preferences.service.ee';
|
|
7
|
+
import type { StatusExportableCredential } from './types/exportable-credential';
|
|
8
|
+
import type { ExportableFolder } from './types/exportable-folders';
|
|
9
|
+
import type { ExportableProjectWithFileName } from './types/exportable-project';
|
|
10
|
+
import { ExportableVariable } from './types/exportable-variable';
|
|
11
|
+
import type { SourceControlGetStatus } from './types/source-control-get-status';
|
|
12
|
+
import type { SourceControlWorkflowVersionId } from './types/source-control-workflow-version-id';
|
|
13
|
+
export declare class SourceControlStatusService {
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private readonly gitService;
|
|
16
|
+
private readonly sourceControlImportService;
|
|
17
|
+
private readonly sourceControlPreferencesService;
|
|
18
|
+
private readonly tagRepository;
|
|
19
|
+
private readonly folderRepository;
|
|
20
|
+
private readonly eventService;
|
|
21
|
+
constructor(logger: Logger, gitService: SourceControlGitService, sourceControlImportService: SourceControlImportService, sourceControlPreferencesService: SourceControlPreferencesService, tagRepository: TagRepository, folderRepository: FolderRepository, eventService: EventService);
|
|
22
|
+
private get gitFolder();
|
|
23
|
+
getStatus(user: User, options: SourceControlGetStatus): Promise<{
|
|
24
|
+
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
25
|
+
type: "tags" | "project" | "credential" | "file" | "workflow" | "variables" | "folders";
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
updatedAt: string;
|
|
29
|
+
file: string;
|
|
30
|
+
location: "local" | "remote";
|
|
31
|
+
conflict: boolean;
|
|
32
|
+
pushed?: boolean | undefined;
|
|
33
|
+
owner?: {
|
|
34
|
+
type: "personal" | "team";
|
|
35
|
+
projectId: string;
|
|
36
|
+
projectName: string;
|
|
37
|
+
} | undefined;
|
|
38
|
+
}[] | {
|
|
39
|
+
wfRemoteVersionIds: SourceControlWorkflowVersionId[];
|
|
40
|
+
wfLocalVersionIds: SourceControlWorkflowVersionId[];
|
|
41
|
+
wfMissingInLocal: SourceControlWorkflowVersionId[];
|
|
42
|
+
wfMissingInRemote: SourceControlWorkflowVersionId[];
|
|
43
|
+
wfModifiedInEither: SourceControlWorkflowVersionId[];
|
|
44
|
+
credMissingInLocal: StatusExportableCredential[];
|
|
45
|
+
credMissingInRemote: StatusExportableCredential[];
|
|
46
|
+
credModifiedInEither: StatusExportableCredential[];
|
|
47
|
+
varMissingInLocal: ExportableVariable[];
|
|
48
|
+
varMissingInRemote: import("@n8n/db").Variables[];
|
|
49
|
+
varModifiedInEither: ExportableVariable[];
|
|
50
|
+
tagsMissingInLocal: TagEntity[];
|
|
51
|
+
tagsMissingInRemote: TagEntity[];
|
|
52
|
+
tagsModifiedInEither: TagEntity[];
|
|
53
|
+
mappingsMissingInLocal: import("@n8n/db").WorkflowTagMapping[];
|
|
54
|
+
mappingsMissingInRemote: import("@n8n/db").WorkflowTagMapping[];
|
|
55
|
+
foldersMissingInLocal: ExportableFolder[];
|
|
56
|
+
foldersMissingInRemote: ExportableFolder[];
|
|
57
|
+
foldersModifiedInEither: ExportableFolder[];
|
|
58
|
+
projectsRemote: ExportableProjectWithFileName[];
|
|
59
|
+
projectsLocal: ExportableProjectWithFileName[];
|
|
60
|
+
projectsMissingInLocal: ExportableProjectWithFileName[];
|
|
61
|
+
projectsMissingInRemote: ExportableProjectWithFileName[];
|
|
62
|
+
projectsModifiedInEither: ExportableProjectWithFileName[];
|
|
63
|
+
sourceControlledFiles: {
|
|
64
|
+
status: "unknown" | "new" | "modified" | "deleted" | "created" | "renamed" | "conflicted" | "ignored" | "staged";
|
|
65
|
+
type: "tags" | "project" | "credential" | "file" | "workflow" | "variables" | "folders";
|
|
66
|
+
id: string;
|
|
67
|
+
name: string;
|
|
68
|
+
updatedAt: string;
|
|
69
|
+
file: string;
|
|
70
|
+
location: "local" | "remote";
|
|
71
|
+
conflict: boolean;
|
|
72
|
+
pushed?: boolean | undefined;
|
|
73
|
+
owner?: {
|
|
74
|
+
type: "personal" | "team";
|
|
75
|
+
projectId: string;
|
|
76
|
+
projectName: string;
|
|
77
|
+
} | undefined;
|
|
78
|
+
}[];
|
|
79
|
+
}>;
|
|
80
|
+
private resetWorkfolder;
|
|
81
|
+
private getStatusWorkflows;
|
|
82
|
+
private getStatusCredentials;
|
|
83
|
+
private getStatusVariables;
|
|
84
|
+
private getStatusTagsMappings;
|
|
85
|
+
private getStatusFoldersMapping;
|
|
86
|
+
private getStatusProjects;
|
|
87
|
+
private areVariablesEqual;
|
|
88
|
+
private isProjectModified;
|
|
89
|
+
private isProjectIconModified;
|
|
90
|
+
}
|